KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 2002-2007 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.beans.FatalBeanException;
20
21 /**
22  * Exception thrown when a BeanFactory encounters an error when
23  * attempting to create a bean from a bean definition.
24  *
25  * @author Juergen Hoeller
26  */

27 public class BeanCreationException extends FatalBeanException {
28
29     private String JavaDoc beanName;
30
31     private String JavaDoc resourceDescription;
32
33
34     /**
35      * Create a new BeanCreationException.
36      * @param msg the detail message
37      */

38     public BeanCreationException(String JavaDoc msg) {
39         super(msg);
40     }
41
42     /**
43      * Create a new BeanCreationException.
44      * @param msg the detail message
45      * @param cause the root cause
46      */

47     public BeanCreationException(String JavaDoc msg, Throwable JavaDoc cause) {
48         super(msg, cause);
49     }
50
51     /**
52      * Create a new BeanCreationException.
53      * @param beanName the name of the bean requested
54      * @param msg the detail message
55      */

56     public BeanCreationException(String JavaDoc beanName, String JavaDoc msg) {
57         this(beanName, msg, (Throwable JavaDoc) null);
58     }
59
60     /**
61      * Create a new BeanCreationException.
62      * @param beanName the name of the bean requested
63      * @param msg the detail message
64      * @param cause the root cause
65      */

66     public BeanCreationException(String JavaDoc beanName, String JavaDoc msg, Throwable JavaDoc cause) {
67         super("Error creating bean with name '" + beanName + "': " + msg, cause);
68         this.beanName = beanName;
69     }
70
71     /**
72      * Create a new BeanCreationException.
73      * @param resourceDescription description of the resource
74      * that the bean definition came from
75      * @param beanName the name of the bean requested
76      * @param msg the detail message
77      */

78     public BeanCreationException(String JavaDoc resourceDescription, String JavaDoc beanName, String JavaDoc msg) {
79         this(resourceDescription, beanName, msg, null);
80     }
81
82     /**
83      * Create a new BeanCreationException.
84      * @param resourceDescription description of the resource
85      * that the bean definition came from
86      * @param beanName the name of the bean requested
87      * @param msg the detail message
88      * @param cause the root cause
89      */

90     public BeanCreationException(String JavaDoc resourceDescription, String JavaDoc beanName, String JavaDoc msg, Throwable JavaDoc cause) {
91         super("Error creating bean with name '" + beanName + "'" +
92                 (resourceDescription != null ? " defined in " + resourceDescription : "") +
93                 ": " + msg, cause);
94         this.resourceDescription = resourceDescription;
95         this.beanName = beanName;
96     }
97
98
99     /**
100      * Return the name of the bean requested, if any.
101      */

102     public String JavaDoc getBeanName() {
103         return this.beanName;
104     }
105
106     /**
107      * Return the description of the resource that the bean
108      * definition came from, if any.
109      */

110     public String JavaDoc getResourceDescription() {
111         return this.resourceDescription;
112     }
113
114 }
115
Popular Tags