Source Code Cross Referenced for BeanCreationException.java in  » J2EE » spring-framework-2.5 » org » springframework » beans » factory » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » spring framework 2.5 » org.springframework.beans.factory 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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 java.io.PrintStream;
020:        import java.io.PrintWriter;
021:        import java.util.Iterator;
022:        import java.util.LinkedList;
023:        import java.util.List;
024:
025:        import org.springframework.beans.FatalBeanException;
026:        import org.springframework.core.NestedRuntimeException;
027:
028:        /**
029:         * Exception thrown when a BeanFactory encounters an error when
030:         * attempting to create a bean from a bean definition.
031:         *
032:         * @author Juergen Hoeller
033:         */
034:        public class BeanCreationException extends FatalBeanException {
035:
036:            private String beanName;
037:
038:            private String resourceDescription;
039:
040:            private List relatedCauses;
041:
042:            /**
043:             * Create a new BeanCreationException.
044:             * @param msg the detail message
045:             */
046:            public BeanCreationException(String msg) {
047:                super (msg);
048:            }
049:
050:            /**
051:             * Create a new BeanCreationException.
052:             * @param msg the detail message
053:             * @param cause the root cause
054:             */
055:            public BeanCreationException(String msg, Throwable cause) {
056:                super (msg, cause);
057:            }
058:
059:            /**
060:             * Create a new BeanCreationException.
061:             * @param beanName the name of the bean requested
062:             * @param msg the detail message
063:             */
064:            public BeanCreationException(String beanName, String msg) {
065:                this (beanName, msg, (Throwable) null);
066:            }
067:
068:            /**
069:             * Create a new BeanCreationException.
070:             * @param beanName the name of the bean requested
071:             * @param msg the detail message
072:             * @param cause the root cause
073:             */
074:            public BeanCreationException(String beanName, String msg,
075:                    Throwable cause) {
076:                super ("Error creating bean with name '" + beanName + "': "
077:                        + msg, cause);
078:                this .beanName = beanName;
079:            }
080:
081:            /**
082:             * Create a new BeanCreationException.
083:             * @param resourceDescription description of the resource
084:             * that the bean definition came from
085:             * @param beanName the name of the bean requested
086:             * @param msg the detail message
087:             */
088:            public BeanCreationException(String resourceDescription,
089:                    String beanName, String msg) {
090:                this (resourceDescription, beanName, msg, null);
091:            }
092:
093:            /**
094:             * Create a new BeanCreationException.
095:             * @param resourceDescription description of the resource
096:             * that the bean definition came from
097:             * @param beanName the name of the bean requested
098:             * @param msg the detail message
099:             * @param cause the root cause
100:             */
101:            public BeanCreationException(String resourceDescription,
102:                    String beanName, String msg, Throwable cause) {
103:                super ("Error creating bean with name '"
104:                        + beanName
105:                        + "'"
106:                        + (resourceDescription != null ? " defined in "
107:                                + resourceDescription : "") + ": " + msg, cause);
108:                this .resourceDescription = resourceDescription;
109:                this .beanName = beanName;
110:            }
111:
112:            /**
113:             * Return the name of the bean requested, if any.
114:             */
115:            public String getBeanName() {
116:                return this .beanName;
117:            }
118:
119:            /**
120:             * Return the description of the resource that the bean
121:             * definition came from, if any.
122:             */
123:            public String getResourceDescription() {
124:                return this .resourceDescription;
125:            }
126:
127:            /**
128:             * Add a related cause to this bean creation exception,
129:             * not being a direct cause of the failure but having occured
130:             * earlier in the creation of the same bean instance.
131:             * @param ex the related cause to add
132:             */
133:            public void addRelatedCause(Throwable ex) {
134:                if (this .relatedCauses == null) {
135:                    this .relatedCauses = new LinkedList();
136:                }
137:                this .relatedCauses.add(ex);
138:            }
139:
140:            /**
141:             * Return the related causes, if any.
142:             * @return the array of related causes, or <code>null</code> if none
143:             */
144:            public Throwable[] getRelatedCauses() {
145:                if (this .relatedCauses == null) {
146:                    return null;
147:                }
148:                return (Throwable[]) this .relatedCauses
149:                        .toArray(new Throwable[this .relatedCauses.size()]);
150:            }
151:
152:            public String toString() {
153:                StringBuffer sb = new StringBuffer(super .toString());
154:                if (this .relatedCauses != null) {
155:                    for (Iterator it = this .relatedCauses.iterator(); it
156:                            .hasNext();) {
157:                        Throwable relatedCause = (Throwable) it.next();
158:                        sb.append("\nRelated cause: ");
159:                        sb.append(relatedCause);
160:                    }
161:                }
162:                return sb.toString();
163:            }
164:
165:            public void printStackTrace(PrintStream ps) {
166:                synchronized (ps) {
167:                    super .printStackTrace(ps);
168:                    if (this .relatedCauses != null) {
169:                        for (Iterator it = this .relatedCauses.iterator(); it
170:                                .hasNext();) {
171:                            Throwable relatedCause = (Throwable) it.next();
172:                            ps.println("Related cause:");
173:                            relatedCause.printStackTrace(ps);
174:                        }
175:                    }
176:                }
177:            }
178:
179:            public void printStackTrace(PrintWriter pw) {
180:                synchronized (pw) {
181:                    super .printStackTrace(pw);
182:                    if (this .relatedCauses != null) {
183:                        for (Iterator it = this .relatedCauses.iterator(); it
184:                                .hasNext();) {
185:                            Throwable relatedCause = (Throwable) it.next();
186:                            pw.println("Related cause:");
187:                            relatedCause.printStackTrace(pw);
188:                        }
189:                    }
190:                }
191:            }
192:
193:            public boolean contains(Class exClass) {
194:                if (super .contains(exClass)) {
195:                    return true;
196:                }
197:                if (this .relatedCauses != null) {
198:                    for (Iterator it = this .relatedCauses.iterator(); it
199:                            .hasNext();) {
200:                        Throwable relatedCause = (Throwable) it.next();
201:                        if (relatedCause instanceof  NestedRuntimeException
202:                                && ((NestedRuntimeException) relatedCause)
203:                                        .contains(exClass)) {
204:                            return true;
205:                        }
206:                    }
207:                }
208:                return false;
209:            }
210:
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.