001: /* ====================================================================
002: The Jicarilla Software License
003:
004: Copyright (c) 2003 Leo Simons.
005: All rights reserved.
006:
007: Permission is hereby granted, free of charge, to any person obtaining
008: a copy of this software and associated documentation files (the
009: "Software"), to deal in the Software without restriction, including
010: without limitation the rights to use, copy, modify, merge, publish,
011: distribute, sublicense, and/or sell copies of the Software, and to
012: permit persons to whom the Software is furnished to do so, subject to
013: the following conditions:
014:
015: The above copyright notice and this permission notice shall be
016: included in all copies or substantial portions of the Software.
017:
018: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
019: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
020: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
021: IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
022: CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
023: TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
024: SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
025: ==================================================================== */
026: package org.jicarilla.container;
027:
028: import java.util.Set;
029:
030: /**
031: * Exception that is thrown when an {@link Adapter} or {@link Factory}
032: * cannot create an instance because the instance has a dependency that
033: * cannot be satisfied.
034: *
035: * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
036: * @version $Id: UnsatisfiableDependencyException.java,v 1.8 2004/02/29 19:21:35 lsimons Exp $
037: */
038: public class UnsatisfiableDependencyException extends
039: JicarillaInstantiationException {
040: /** the class of which no instance could be created. */
041: protected final Class m_problematicClass;
042: /** the arguments that could not be provided to the constructor. */
043: protected final Set m_unsatisfiedDependencies;
044:
045: /**
046: * Create a new instance identifying the specified class as the problem
047: * because the specified dependencies could not be provided.
048: *
049: * @param clazz the class of which no instance could be created.
050: * @param unsatisfiedDependencies the arguments that could not be provided
051: * to the constructor.
052: */
053: public UnsatisfiableDependencyException(final Class clazz,
054: final Set unsatisfiedDependencies) {
055: this (clazz, unsatisfiedDependencies, clazz.getName()
056: + " has an unsatisfiable depency: "
057: + unsatisfiedDependencies);
058: //if( clazz == null )
059: // throw new NullPointerException("clazz");
060: //if( unsatisfiedDependencies == null )
061: // throw new NullPointerException("unsatisfiedDependencies");
062: }
063:
064: /**
065: * Create a new instance identifying the specified class as the problem
066: * because the specified dependencies could not be provided, with the
067: * specified custom message.
068: *
069: * @param clazz the class of which no instance could be created.
070: * @param unsatisfiedDependencies the arguments that could not be provided
071: * to the constructor.
072: * @param message the message containing a further description of the
073: * problem.
074: */
075: public UnsatisfiableDependencyException(final Class clazz,
076: final Set unsatisfiedDependencies, final String message) {
077: super (message);
078: if (clazz == null)
079: throw new NullPointerException("clazz");
080: if (unsatisfiedDependencies == null)
081: throw new NullPointerException("unsatisfiedDependencies");
082: m_problematicClass = clazz;
083: m_unsatisfiedDependencies = unsatisfiedDependencies;
084: }
085:
086: /**
087: * Returns the dependencies that could not be satisfied.
088: *
089: * @return the dependencies that could not be satisfied.
090: */
091: public Set getUnsatisfiedDependencies() {
092: return m_unsatisfiedDependencies;
093: }
094:
095: /**
096: * Returns the class that could not be instantiated.
097: *
098: * @return the class that could not be instantiated.
099: */
100: public Class getProblematicClass() {
101: return m_problematicClass;
102: }
103: }
|