01: /* ====================================================================
02: The Jicarilla Software License
03:
04: Copyright (c) 2003 Leo Simons.
05: All rights reserved.
06:
07: Permission is hereby granted, free of charge, to any person obtaining
08: a copy of this software and associated documentation files (the
09: "Software"), to deal in the Software without restriction, including
10: without limitation the rights to use, copy, modify, merge, publish,
11: distribute, sublicense, and/or sell copies of the Software, and to
12: permit persons to whom the Software is furnished to do so, subject to
13: the following conditions:
14:
15: The above copyright notice and this permission notice shall be
16: included in all copies or substantial portions of the Software.
17:
18: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21: IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22: CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23: TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24: SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25: ==================================================================== */
26: package org.jicarilla.container;
27:
28: import java.lang.reflect.Constructor;
29: import java.util.Set;
30:
31: /**
32: * Exception that is thrown when an {@link Adapter} or {@link Factory}
33: * cannot create an instance because none of its public constructors has
34: * an argument list that can be properly satisfied.
35: *
36: * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
37: * @version $Id: NoSatisfiableConstructorAvailableException.java,v 1.6 2004/02/29 19:21:35 lsimons Exp $
38: */
39: public class NoSatisfiableConstructorAvailableException extends
40: UnsatisfiableDependencyException {
41: /** The least demanding constructor that was still problematic. */
42: private final Constructor m_problematicConstructor;
43:
44: /**
45: * Create a new instance identifying the specified constructor of the
46: * specified class as the problem because the specified arguments could
47: * not be provided.
48: *
49: * @param clazz the class of which no instance could be created.
50: * @param constructor the constructor that could not be called properly.
51: * @param unsatisfiedDependencies the arguments that could not be provided
52: * to the constructor.
53: */
54: public NoSatisfiableConstructorAvailableException(
55: final Class clazz, final Constructor constructor,
56: final Set unsatisfiedDependencies) {
57: super (
58: clazz,
59: unsatisfiedDependencies,
60: clazz.getName()
61: + " has no Satisfiable constructors! Even the most conservative"
62: + " constructor (" + constructor + ") failed, "
63: + " because these dependencies failed: "
64: + unsatisfiedDependencies);
65: if (constructor == null)
66: throw new NullPointerException("constructor");
67: m_problematicConstructor = constructor;
68: }
69:
70: /**
71: * Returns the constructor that could not be called properly.
72: *
73: * @return the constructor that could not be called properly.
74: */
75: public Constructor getProblematicConstructor() {
76: return m_problematicConstructor;
77: }
78: }
|