Source Code Cross Referenced for ServiceException.java in  » GIS » deegree » org » deegree » enterprise » 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 » GIS » deegree » org.deegree.enterprise 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/enterprise/ServiceException.java $
002:        /*----------------    FILE HEADER  ------------------------------------------
003:
004:         This file is part of deegree.
005:         Copyright (C) 2001-2008 by:
006:         EXSE, Department of Geography, University of Bonn
007:         http://www.giub.uni-bonn.de/deegree/
008:         lat/lon GmbH
009:         http://www.lat-lon.de
010:
011:         This library is free software; you can redistribute it and/or
012:         modify it under the terms of the GNU Lesser General Public
013:         License as published by the Free Software Foundation; either
014:         version 2.1 of the License, or (at your option) any later version.
015:
016:         This library is distributed in the hope that it will be useful,
017:         but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
019:         Lesser General Public License for more details.
020:
021:         You should have received a copy of the GNU Lesser General Public
022:         License along with this library; if not, write to the Free Software
023:         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
024:
025:         Contact:
026:
027:         Andreas Poth
028:         lat/lon GmbH
029:         Aennchenstr. 19
030:         53115 Bonn
031:         Germany
032:         E-Mail: poth@lat-lon.de
033:
034:         Prof. Dr. Klaus Greve
035:         Department of Geography
036:         University of Bonn
037:         Meckenheimer Allee 166
038:         53115 Bonn
039:         Germany
040:         E-Mail: greve@giub.uni-bonn.de
041:
042:        
043:         ---------------------------------------------------------------------------*/
044:        package org.deegree.enterprise;
045:
046:        // JDK 1.3
047:        import java.io.PrintStream;
048:        import java.io.PrintWriter;
049:        import java.io.StringWriter;
050:
051:        /**
052:         * The <code>ServiceException</code> class is used across all core framework services and is also
053:         * suitable for use by developers extending the framework using the framework SPI.
054:         * 
055:         * Based on code published by Terren Suydam in JavaWorld
056:         * 
057:         * @see <a href="http://www.javaworld.com/javaworld/javatips/jw-javatip91.html">JavaWorld tip 91</a>
058:         * 
059:         * @author <a href="mailto:tfr@users.sourceforge.net">Torsten Friebe </A>
060:         * @author last edited by: $Author: apoth $
061:         * 
062:         * @version $Revision: 9338 $, $Date: 2007-12-27 04:31:31 -0800 (Thu, 27 Dec 2007) $
063:         */
064:        public class ServiceException extends Exception implements 
065:                java.io.Serializable {
066:
067:            /**
068:             * 
069:             */
070:            private static final long serialVersionUID = 1L;
071:
072:            // the nested exception
073:            private Throwable nestedException;
074:
075:            // String representation of stack trace - not transient!
076:            private String stackTraceString;
077:
078:            /**
079:             * Convert a stack trace to a String so it can be serialized
080:             * 
081:             * @param t
082:             * 
083:             * @return
084:             */
085:            public static String generateStackTraceString(Throwable t) {
086:                StringWriter s = new StringWriter();
087:
088:                t.printStackTrace(new PrintWriter(s));
089:
090:                return s.toString();
091:            }
092:
093:            /**
094:             * java.lang.Exception constructors
095:             */
096:            public ServiceException() {
097:            }
098:
099:            /**
100:             * Constructor declaration
101:             * 
102:             * @param msg
103:             * 
104:             */
105:            public ServiceException(String msg) {
106:                super (msg);
107:            }
108:
109:            /**
110:             * additional c'tors - nest the exceptions, storing the stack trace
111:             * 
112:             * @param nestedException
113:             */
114:            public ServiceException(Throwable nestedException) {
115:                this .nestedException = nestedException;
116:                stackTraceString = generateStackTraceString(nestedException);
117:            }
118:
119:            /**
120:             * Constructor declaration
121:             * 
122:             * 
123:             * @param msg
124:             * @param nestedException
125:             * 
126:             * 
127:             */
128:            public ServiceException(String msg, Throwable nestedException) {
129:                this (msg);
130:
131:                this .nestedException = nestedException;
132:                stackTraceString = generateStackTraceString(nestedException);
133:            }
134:
135:            // methods
136:
137:            /**
138:             * Method declaration
139:             * 
140:             * 
141:             * @return nestedException
142:             * 
143:             */
144:            public Throwable getNestedException() {
145:                return nestedException;
146:            }
147:
148:            /**
149:             * descend through linked-list of nesting exceptions, & output trace note that this displays the
150:             * 'deepest' trace first
151:             * 
152:             * @return
153:             * 
154:             */
155:            public String getStackTraceString() {
156:
157:                // if there's no nested exception, there's no stackTrace
158:                if (nestedException == null) {
159:                    return null;
160:                }
161:
162:                StringBuffer traceBuffer = new StringBuffer();
163:
164:                if (nestedException instanceof  ServiceException) {
165:                    traceBuffer.append(((ServiceException) nestedException)
166:                            .getStackTraceString());
167:                    traceBuffer.append(" nested by:\n");
168:                }
169:
170:                traceBuffer.append(stackTraceString);
171:
172:                return traceBuffer.toString();
173:            }
174:
175:            // overrides Exception.getMessage()
176:
177:            /**
178:             * Method declaration
179:             * 
180:             * 
181:             * @return
182:             * 
183:             */
184:            public String getMessage() {
185:
186:                // superMsg will contain whatever String was passed into the
187:                // constructor, and null otherwise.
188:                String super Msg = super .getMessage();
189:
190:                // if there's no nested exception, do like we would always do
191:                if (getNestedException() == null) {
192:                    return super Msg;
193:                }
194:
195:                StringBuffer theMsg = new StringBuffer();
196:
197:                // get the nested exception's message
198:                String nestedMsg = getNestedException().getMessage();
199:
200:                if (super Msg != null) {
201:                    theMsg.append(super Msg).append(": ").append(nestedMsg);
202:                } else {
203:                    theMsg.append(nestedMsg);
204:                }
205:
206:                return theMsg.toString();
207:            }
208:
209:            // overrides Exception.toString()
210:
211:            /**
212:             * Method declaration
213:             * 
214:             * 
215:             * @return
216:             * 
217:             */
218:            public String toString() {
219:                StringBuffer theMsg = new StringBuffer(super .toString());
220:
221:                if (getNestedException() != null) {
222:                    theMsg.append("; \n\t---> nested ").append(
223:                            getNestedException());
224:                }
225:
226:                return theMsg.toString();
227:            }
228:
229:            /**
230:             * Method declaration
231:             * 
232:             * 
233:             * 
234:             */
235:            public void printStackTrace() {
236:                if (this .getNestedException() != null) {
237:                    this .getNestedException().printStackTrace();
238:                } else {
239:                    super .printStackTrace();
240:                }
241:            }
242:
243:            /**
244:             * Method declaration
245:             * 
246:             * 
247:             * @param inPrintStream
248:             * 
249:             * 
250:             */
251:            public void printStackTrace(PrintStream inPrintStream) {
252:                this .printStackTrace(new PrintWriter(inPrintStream));
253:            }
254:
255:            /**
256:             * Method declaration
257:             * 
258:             * 
259:             * @param inPrintWriter
260:             * 
261:             * 
262:             */
263:            public void printStackTrace(PrintWriter inPrintWriter) {
264:                if (this.getNestedException() != null) {
265:                    this.getNestedException().printStackTrace(inPrintWriter);
266:                } else {
267:                    super.printStackTrace(inPrintWriter);
268:                }
269:            }
270:
271:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.