KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > beans > factory > UnsatisfiedDependencyException


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.beans.factory;
18
19 import org.springframework.util.ClassUtils;
20
21 /**
22  * Exception thrown when a bean depends on other beans or simple properties
23  * that were not specified in the bean factory definition, although
24  * dependency checking was enabled.
25  *
26  * @author Rod Johnson
27  * @author Juergen Hoeller
28  * @since 03.09.2003
29  */

30 public class UnsatisfiedDependencyException extends BeanCreationException {
31
32     /**
33      * Create a new UnsatisfiedDependencyException.
34      * @param resourceDescription description of the resource
35      * that the bean definition came from
36      * @param beanName the name of the bean requested
37      * @param propertyName the name of the bean property that
38      * couldn't be satisfied
39      * @param msg the detail message
40      */

41     public UnsatisfiedDependencyException(
42             String JavaDoc resourceDescription, String JavaDoc beanName, String JavaDoc propertyName, String JavaDoc msg) {
43
44         super(resourceDescription, beanName,
45                 "Unsatisfied dependency expressed through bean property '" + propertyName + "'" +
46                 (msg != null ? ": " + msg : ""));
47     }
48
49     /**
50      * Create a new UnsatisfiedDependencyException.
51      * @param resourceDescription description of the resource
52      * that the bean definition came from
53      * @param beanName the name of the bean requested
54      * @param ctorArgIndex the index of the constructor argument
55      * that couldn't be satisfied
56      * @param ctorArgType the type of the constructor argument
57      * that couldn't be satisfied
58      * @param msg the detail message
59      */

60     public UnsatisfiedDependencyException(
61             String JavaDoc resourceDescription, String JavaDoc beanName, int ctorArgIndex, Class JavaDoc ctorArgType, String JavaDoc msg) {
62
63         super(resourceDescription, beanName,
64                 "Unsatisfied dependency expressed through constructor argument with index " +
65                 ctorArgIndex + " of type [" + ClassUtils.getQualifiedName(ctorArgType) + "]" +
66                 (msg != null ? ": " + msg : ""));
67     }
68
69 }
70
Popular Tags