001: /*
002: * Copyright 2002-2007 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.springframework.beans.factory;
018:
019: import org.springframework.beans.FatalBeanException;
020: import org.springframework.core.io.Resource;
021:
022: /**
023: * Exception thrown when a BeanFactory encounters an internal error, and
024: * its definitions are invalid: for example, if an XML document containing
025: * bean definitions isn't well-formed.
026: *
027: * @author Rod Johnson
028: * @author Juergen Hoeller
029: * @author Rob Harrop
030: */
031: public class BeanDefinitionStoreException extends FatalBeanException {
032:
033: private String resourceDescription;
034:
035: private String beanName;
036:
037: /**
038: * Create a new BeanDefinitionStoreException.
039: * @param msg the detail message (used as exception message as-is)
040: */
041: public BeanDefinitionStoreException(String msg) {
042: super (msg);
043: }
044:
045: /**
046: * Create a new BeanDefinitionStoreException.
047: * @param msg the detail message (used as exception message as-is)
048: * @param cause the root cause (may be <code>null</code>)
049: */
050: public BeanDefinitionStoreException(String msg, Throwable cause) {
051: super (msg, cause);
052: }
053:
054: /**
055: * Create a new BeanDefinitionStoreException.
056: * @param resourceDescription description of the resource that the bean definition came from
057: * @param msg the detail message (used as exception message as-is)
058: */
059: public BeanDefinitionStoreException(String resourceDescription,
060: String msg) {
061: super (msg);
062: this .resourceDescription = resourceDescription;
063: }
064:
065: /**
066: * Create a new BeanDefinitionStoreException.
067: * @param resourceDescription description of the resource that the bean definition came from
068: * @param msg the detail message (used as exception message as-is)
069: * @param cause the root cause (may be <code>null</code>)
070: */
071: public BeanDefinitionStoreException(String resourceDescription,
072: String msg, Throwable cause) {
073: super (msg, cause);
074: this .resourceDescription = resourceDescription;
075: }
076:
077: /**
078: * Create a new BeanDefinitionStoreException.
079: * @param resourceDescription description of the resource that the bean definition came from
080: * @param beanName the name of the bean requested
081: * @param msg the detail message (appended to an introductory message that indicates
082: * the resource and the name of the bean)
083: */
084: public BeanDefinitionStoreException(String resourceDescription,
085: String beanName, String msg) {
086: this (resourceDescription, beanName, msg, null);
087: }
088:
089: /**
090: * Create a new BeanDefinitionStoreException.
091: * @param resourceDescription description of the resource that the bean definition came from
092: * @param beanName the name of the bean requested
093: * @param msg the detail message (appended to an introductory message that indicates
094: * the resource and the name of the bean)
095: * @param cause the root cause (may be <code>null</code>)
096: */
097: public BeanDefinitionStoreException(String resourceDescription,
098: String beanName, String msg, Throwable cause) {
099: super ("Error registering bean with name '" + beanName
100: + "' defined in " + resourceDescription + ": " + msg,
101: cause);
102: this .resourceDescription = resourceDescription;
103: this .beanName = beanName;
104: }
105:
106: /**
107: * Create a new BeanDefinitionStoreException.
108: * @param documentLocation descriptor of the resource location that the bean definition came from
109: * @param beanName the name of the bean requested
110: * @param msg the detail message (appended to an introductory message that indicates
111: * the resource and the name of the bean)
112: * @deprecated as of Spring 2.0,
113: * in favor of the constructor variant with a resource description argument
114: * @see #BeanDefinitionStoreException(String, String, String)
115: */
116: public BeanDefinitionStoreException(Resource documentLocation,
117: String beanName, String msg) {
118: this (documentLocation.getDescription(), beanName, msg, null);
119: }
120:
121: /**
122: * Create a new BeanDefinitionStoreException.
123: * @param documentLocation descriptor of the resource location that the bean definition came from
124: * @param beanName the name of the bean requested
125: * @param msg the detail message (appended to an introductory message that indicates
126: * the resource and the name of the bean)
127: * @param cause the root cause
128: * @deprecated as of Spring 2.0,
129: * in favor of the constructor variant with a resource description argument
130: * @see #BeanDefinitionStoreException(String, String, String, Throwable)
131: */
132: public BeanDefinitionStoreException(Resource documentLocation,
133: String beanName, String msg, Throwable cause) {
134: this (documentLocation.getDescription(), beanName, msg, cause);
135: }
136:
137: /**
138: * Return the description of the resource that the bean
139: * definition came from, if any.
140: */
141: public String getResourceDescription() {
142: return this .resourceDescription;
143: }
144:
145: /**
146: * Return the name of the bean requested, if any.
147: */
148: public String getBeanName() {
149: return this.beanName;
150: }
151:
152: }
|