001 /***************************************************************************** 002 * Copyright (C) PicoContainer Organization. All rights reserved. * 003 * ------------------------------------------------------------------------- * 004 * The software in this package is published under the terms of the BSD * 005 * style license a copy of which has been included with this distribution in * 006 * the LICENSE.txt file. * 007 * * 008 * Original code by * 009 *****************************************************************************/ 010 package org.picocontainer.defaults; 011 012 import org.picocontainer.ComponentAdapter; 013 import org.picocontainer.PicoIntrospectionException; 014 import org.picocontainer.PicoContainer; 015 016 import java.util.Set; 017 018 /** 019 * Exception thrown when some of the component's dependencies are not satisfiable. 020 * 021 * @author Aslak Hellesøy 022 * @author Mauro Talevi 023 * @version $Revision: 2838 $ 024 */ 025 public class UnsatisfiableDependenciesException extends PicoIntrospectionException { 026 027 private final ComponentAdapter instantiatingComponentAdapter; 028 private final Set unsatisfiableDependencies; 029 private final Class unsatisfiedDependencyType; 030 private final PicoContainer leafContainer; 031 032 public UnsatisfiableDependenciesException(ComponentAdapter instantiatingComponentAdapter, 033 Set unsatisfiableDependencies, PicoContainer leafContainer) { 034 super(instantiatingComponentAdapter.getComponentImplementation().getName() + " has unsatisfiable dependencies: " 035 + unsatisfiableDependencies + " where " + leafContainer 036 + " was the leaf container being asked for dependencies."); 037 this.instantiatingComponentAdapter = instantiatingComponentAdapter; 038 this.unsatisfiableDependencies = unsatisfiableDependencies; 039 this.unsatisfiedDependencyType = null; 040 this.leafContainer = leafContainer; 041 } 042 043 public UnsatisfiableDependenciesException(ComponentAdapter instantiatingComponentAdapter, 044 Class unsatisfiedDependencyType, Set unsatisfiableDependencies, 045 PicoContainer leafContainer) { 046 super(instantiatingComponentAdapter.getComponentImplementation().getName() + " has unsatisfied dependency: " + unsatisfiedDependencyType 047 +" among unsatisfiable dependencies: "+unsatisfiableDependencies + " where " + leafContainer 048 + " was the leaf container being asked for dependencies."); 049 this.instantiatingComponentAdapter = instantiatingComponentAdapter; 050 this.unsatisfiableDependencies = unsatisfiableDependencies; 051 this.unsatisfiedDependencyType = unsatisfiedDependencyType; 052 this.leafContainer = leafContainer; 053 } 054 055 public ComponentAdapter getUnsatisfiableComponentAdapter() { 056 return instantiatingComponentAdapter; 057 } 058 059 public Set getUnsatisfiableDependencies() { 060 return unsatisfiableDependencies; 061 } 062 063 public Class getUnsatisfiedDependencyType() { 064 return unsatisfiedDependencyType; 065 } 066 067 public PicoContainer getLeafContainer() { 068 return leafContainer; 069 } 070 071 }