KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.springframework.core.io.Resource;
21
22 /**
23  * Exception thrown when a BeanFactory encounters an internal error, and
24  * its definitions are invalid: for example, if an XML document containing
25  * bean definitions isn't well-formed.
26  *
27  * @author Rod Johnson
28  * @author Juergen Hoeller
29  * @author Rob Harrop
30  */

31 public class BeanDefinitionStoreException extends FatalBeanException {
32
33     private String JavaDoc resourceDescription;
34
35     private String JavaDoc beanName;
36
37
38     /**
39      * Create a new BeanDefinitionStoreException.
40      * @param msg the detail message (used as exception message as-is)
41      */

42     public BeanDefinitionStoreException(String JavaDoc msg) {
43         super(msg);
44     }
45
46     /**
47      * Create a new BeanDefinitionStoreException.
48      * @param msg the detail message (used as exception message as-is)
49      * @param cause the root cause (may be <code>null</code>)
50      */

51     public BeanDefinitionStoreException(String JavaDoc msg, Throwable JavaDoc cause) {
52         super(msg, cause);
53     }
54
55     /**
56      * Create a new BeanDefinitionStoreException.
57      * @param resourceDescription description of the resource that the bean definition came from
58      * @param msg the detail message (used as exception message as-is)
59      */

60     public BeanDefinitionStoreException(String JavaDoc resourceDescription, String JavaDoc msg) {
61         super(msg);
62         this.resourceDescription = resourceDescription;
63     }
64
65     /**
66      * Create a new BeanDefinitionStoreException.
67      * @param resourceDescription description of the resource that the bean definition came from
68      * @param msg the detail message (used as exception message as-is)
69      * @param cause the root cause (may be <code>null</code>)
70      */

71     public BeanDefinitionStoreException(String JavaDoc resourceDescription, String JavaDoc msg, Throwable JavaDoc cause) {
72         super(msg, cause);
73         this.resourceDescription = resourceDescription;
74     }
75
76     /**
77      * Create a new BeanDefinitionStoreException.
78      * @param resourceDescription description of the resource that the bean definition came from
79      * @param beanName the name of the bean requested
80      * @param msg the detail message (appended to an introductory message that indicates
81      * the resource and the name of the bean)
82      */

83     public BeanDefinitionStoreException(String JavaDoc resourceDescription, String JavaDoc beanName, String JavaDoc msg) {
84         this(resourceDescription, beanName, msg, null);
85     }
86
87     /**
88      * Create a new BeanDefinitionStoreException.
89      * @param resourceDescription description of the resource that the bean definition came from
90      * @param beanName the name of the bean requested
91      * @param msg the detail message (appended to an introductory message that indicates
92      * the resource and the name of the bean)
93      * @param cause the root cause (may be <code>null</code>)
94      */

95     public BeanDefinitionStoreException(String JavaDoc resourceDescription, String JavaDoc beanName, String JavaDoc msg, Throwable JavaDoc cause) {
96         super("Error registering bean with name '" + beanName + "' defined in " + resourceDescription + ": " + msg, cause);
97         this.resourceDescription = resourceDescription;
98         this.beanName = beanName;
99     }
100
101     /**
102      * Create a new BeanDefinitionStoreException.
103      * @param documentLocation descriptor of the resource location that the bean definition came from
104      * @param beanName the name of the bean requested
105      * @param msg the detail message (appended to an introductory message that indicates
106      * the resource and the name of the bean)
107      * @deprecated as of Spring 2.0,
108      * in favor of the constructor variant with a resource description argument
109      * @see #BeanDefinitionStoreException(String, String, String)
110      */

111     public BeanDefinitionStoreException(Resource documentLocation, String JavaDoc beanName, String JavaDoc msg) {
112         this(documentLocation.getDescription(), beanName, msg, null);
113     }
114
115     /**
116      * Create a new BeanDefinitionStoreException.
117      * @param documentLocation descriptor of the resource location that the bean definition came from
118      * @param beanName the name of the bean requested
119      * @param msg the detail message (appended to an introductory message that indicates
120      * the resource and the name of the bean)
121      * @param cause the root cause
122      * @deprecated as of Spring 2.0,
123      * in favor of the constructor variant with a resource description argument
124      * @see #BeanDefinitionStoreException(String, String, String, Throwable)
125      */

126     public BeanDefinitionStoreException(Resource documentLocation, String JavaDoc beanName, String JavaDoc msg, Throwable JavaDoc cause) {
127         this(documentLocation.getDescription(), beanName, msg, cause);
128     }
129
130
131     /**
132      * Return the description of the resource that the bean
133      * definition came from, if any.
134      */

135     public String JavaDoc getResourceDescription() {
136         return this.resourceDescription;
137     }
138
139     /**
140      * Return the name of the bean requested, if any.
141      */

142     public String JavaDoc getBeanName() {
143         return this.beanName;
144     }
145
146 }
147
Popular Tags