Source Code Cross Referenced for JBossResourceException.java in  » EJB-Server-JBoss-4.2.1 » connector » org » jboss » resource » 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 » EJB Server JBoss 4.2.1 » connector » org.jboss.resource 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package org.jboss.resource;
023:
024:        import java.io.PrintWriter;
025:        import java.io.PrintStream;
026:        import java.lang.reflect.UndeclaredThrowableException;
027:
028:        import javax.resource.ResourceException;
029:
030:        import org.jboss.util.NestedThrowable;
031:
032:        /**
033:         * Thrown to indicate a problem with a resource related operation.
034:         *
035:         * <p>
036:         * Properly displays linked exception (ie. nested exception)
037:         * when printing the stack trace.
038:         *
039:         * @version <tt>$Revision: 57189 $</tt>
040:         * @author  <a href="mailto:jason@planet57.com">Jason Dillon</a>
041:         */
042:        public class JBossResourceException extends ResourceException implements 
043:                NestedThrowable {
044:            /** The servial version uid*/
045:            private static final long serialVersionUID = 6614203184612359692L;
046:
047:            /**
048:             * Rethrow as a resource exception if it is not already
049:             * 
050:             * @param message the message
051:             * @param t the original exception
052:             * @throws ResourceException the resource exception
053:             */
054:            public static void rethrowAsResourceException(String message,
055:                    Throwable t) throws ResourceException {
056:                if (t instanceof  ResourceException)
057:                    throw (ResourceException) t;
058:                else
059:                    throw new JBossResourceException(message, t);
060:            }
061:
062:            /**
063:             * Construct a <tt>JBossResourceException</tt> with the specified detail
064:             * message.
065:             *
066:             * @param msg  Detail message.
067:             */
068:            public JBossResourceException(final String msg) {
069:                super (msg);
070:            }
071:
072:            /**
073:             * Construct a <tt>JBossResourceException</tt> with the specified detail
074:             * message and error code.
075:             *
076:             * @param msg   Detail message.
077:             * @param code  Error code.
078:             */
079:            public JBossResourceException(final String msg, final String code) {
080:                super (msg, code);
081:            }
082:
083:            /**
084:             * Construct a <tt>JBossResourceException</tt> with the specified detail
085:             * message, error code and linked <tt>Exception</tt>.
086:             *
087:             * @param msg     Detail message.
088:             * @param code    Error code.
089:             * @param linked  Linked <tt>Exception</tt>.
090:             */
091:            public JBossResourceException(final String msg, final String code,
092:                    final Throwable linked) {
093:                super (msg, code);
094:                setLinkedException(process(linked));
095:            }
096:
097:            /**
098:             * Construct a <tt>JBossResourceException</tt> with the specified detail
099:             * message and linked <tt>Exception</tt>.
100:             *
101:             * @param msg     Detail message.
102:             * @param linked  Linked <tt>Exception</tt>.
103:             */
104:            public JBossResourceException(final String msg,
105:                    final Throwable linked) {
106:                super (msg);
107:                setLinkedException(process(linked));
108:            }
109:
110:            /**
111:             * Construct a <tt>JBossResourceException</tt> with the specified
112:             * linked <tt>Exception</tt>.
113:             *
114:             * @param linked  Linked <tt>Exception</tt>.
115:             */
116:            public JBossResourceException(final Throwable linked) {
117:                this (linked.getMessage(), linked);
118:            }
119:
120:            /**
121:             * Return the nested <tt>Throwable</tt>.
122:             *
123:             * @return  Nested <tt>Throwable</tt>.
124:             */
125:            public Throwable getNested() {
126:                return getLinkedException();
127:            }
128:
129:            /**
130:             * Return the nested <tt>Throwable</tt>.
131:             *
132:             * <p>For JDK 1.4 compatibility.
133:             *
134:             * @return  Nested <tt>Throwable</tt>.
135:             */
136:            public Throwable getCause() {
137:                return getLinkedException();
138:            }
139:
140:            /**
141:             * Returns the composite throwable message.
142:             *
143:             * @return  The composite throwable message.
144:             */
145:            public String getMessage() {
146:                return NestedThrowable.Util.getMessage(super .getMessage(),
147:                        getLinkedException());
148:            }
149:
150:            /**
151:             * Prints the composite message and the embedded stack trace to the
152:             * specified print stream.
153:             *
154:             * @param stream  Stream to print to.
155:             */
156:            public void printStackTrace(final PrintStream stream) {
157:                Exception linked = getLinkedException();
158:                if (linked == null || NestedThrowable.PARENT_TRACE_ENABLED) {
159:                    super .printStackTrace(stream);
160:                }
161:                NestedThrowable.Util.print(linked, stream);
162:            }
163:
164:            /**
165:             * Prints the composite message and the embedded stack trace to the
166:             * specified print writer.
167:             *
168:             * @param writer  Writer to print to.
169:             */
170:            public void printStackTrace(final PrintWriter writer) {
171:                Exception linked = getLinkedException();
172:                if (linked == null || NestedThrowable.PARENT_TRACE_ENABLED) {
173:                    super .printStackTrace(writer);
174:                }
175:                NestedThrowable.Util.print(linked, writer);
176:            }
177:
178:            /**
179:             * Prints the composite message and the embedded stack trace to
180:             * <tt>System.err</tt>.
181:             */
182:            public void printStackTrace() {
183:                printStackTrace(System.err);
184:            }
185:
186:            private Exception process(Throwable t) {
187:                if (t instanceof  Exception) {
188:                    return (Exception) t;
189:                } // end of if ()
190:                return new UndeclaredThrowableException(t);
191:            }
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.