Source Code Cross Referenced for UnavailableException.java in  » Sevlet-Container » apache-tomcat-6.0.14 » javax » servlet » 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 » Sevlet Container » apache tomcat 6.0.14 » javax.servlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package javax.servlet;
019:
020:        /**
021:         * Defines an exception that a servlet or filter throws to indicate
022:         * that it is permanently or temporarily unavailable. 
023:         *
024:         * <p>When a servlet or filter is permanently unavailable, something is wrong
025:         * with it, and it cannot handle
026:         * requests until some action is taken. For example, a servlet
027:         * might be configured incorrectly, or a filter's state may be corrupted.
028:         * The component should log both the error and the corrective action
029:         * that is needed.
030:         *
031:         * <p>A servlet or filter is temporarily unavailable if it cannot handle
032:         * requests momentarily due to some system-wide problem. For example,
033:         * a third-tier server might not be accessible, or there may be 
034:         * insufficient memory or disk storage to handle requests. A system
035:         * administrator may need to take corrective action.
036:         *
037:         * <p>Servlet containers can safely treat both types of unavailable
038:         * exceptions in the same way. However, treating temporary unavailability
039:         * effectively makes the servlet container more robust. Specifically,
040:         * the servlet container might block requests to the servlet or filter for a period
041:         * of time suggested by the exception, rather than rejecting them until
042:         * the servlet container restarts.
043:         *
044:         *
045:         * @author 	Various
046:         * @version 	$Version$
047:         *
048:         */
049:
050:        public class UnavailableException extends ServletException {
051:
052:            private Servlet servlet; // what's unavailable
053:            private boolean permanent; // needs admin action?
054:            private int seconds; // unavailability estimate
055:
056:            /**
057:             * 
058:             * @deprecated	As of Java Servlet API 2.2, use {@link
059:             * 			#UnavailableException(String)} instead.
060:             *
061:             * @param servlet 	the <code>Servlet</code> instance that is
062:             *                  unavailable
063:             *
064:             * @param msg 	a <code>String</code> specifying the
065:             *                  descriptive message
066:             *
067:             */
068:
069:            public UnavailableException(Servlet servlet, String msg) {
070:                super (msg);
071:                this .servlet = servlet;
072:                permanent = true;
073:            }
074:
075:            /**
076:             * @deprecated	As of Java Servlet API 2.2, use {@link
077:             *			#UnavailableException(String, int)} instead.
078:             *
079:             * @param seconds	an integer specifying the number of seconds
080:             * 			the servlet expects to be unavailable; if
081:             *			zero or negative, indicates that the servlet
082:             *			can't make an estimate
083:             *
084:             * @param servlet	the <code>Servlet</code> that is unavailable
085:             * 
086:             * @param msg	a <code>String</code> specifying the descriptive 
087:             *			message, which can be written to a log file or 
088:             *			displayed for the user.
089:             *
090:             */
091:
092:            public UnavailableException(int seconds, Servlet servlet, String msg) {
093:                super (msg);
094:                this .servlet = servlet;
095:                if (seconds <= 0)
096:                    this .seconds = -1;
097:                else
098:                    this .seconds = seconds;
099:                permanent = false;
100:            }
101:
102:            /**
103:             * 
104:             * Constructs a new exception with a descriptive
105:             * message indicating that the servlet is permanently
106:             * unavailable.
107:             *
108:             * @param msg 	a <code>String</code> specifying the
109:             *                  descriptive message
110:             *
111:             */
112:
113:            public UnavailableException(String msg) {
114:                super (msg);
115:
116:                permanent = true;
117:            }
118:
119:            /**
120:             * Constructs a new exception with a descriptive message
121:             * indicating that the servlet is temporarily unavailable
122:             * and giving an estimate of how long it will be unavailable.
123:             * 
124:             * <p>In some cases, the servlet cannot make an estimate. For
125:             * example, the servlet might know that a server it needs is
126:             * not running, but not be able to report how long it will take
127:             * to be restored to functionality. This can be indicated with
128:             * a negative or zero value for the <code>seconds</code> argument.
129:             *
130:             * @param msg	a <code>String</code> specifying the
131:             *                  descriptive message, which can be written
132:             *                  to a log file or displayed for the user.
133:             *
134:             * @param seconds	an integer specifying the number of seconds
135:             * 			the servlet expects to be unavailable; if
136:             *			zero or negative, indicates that the servlet
137:             *			can't make an estimate
138:             *
139:             */
140:
141:            public UnavailableException(String msg, int seconds) {
142:                super (msg);
143:
144:                if (seconds <= 0)
145:                    this .seconds = -1;
146:                else
147:                    this .seconds = seconds;
148:
149:                permanent = false;
150:            }
151:
152:            /**
153:             *
154:             * Returns a <code>boolean</code> indicating
155:             * whether the servlet is permanently unavailable.
156:             * If so, something is wrong with the servlet, and the
157:             * system administrator must take some corrective action.
158:             *
159:             * @return		<code>true</code> if the servlet is
160:             *			permanently unavailable; <code>false</code>
161:             *			if the servlet is available or temporarily
162:             *			unavailable
163:             *
164:             */
165:
166:            public boolean isPermanent() {
167:                return permanent;
168:            }
169:
170:            /**
171:             * @deprecated	As of Java Servlet API 2.2, with no replacement.
172:             *
173:             * Returns the servlet that is reporting its unavailability.
174:             * 
175:             * @return		the <code>Servlet</code> object that is 
176:             *			throwing the <code>UnavailableException</code>
177:             *
178:             */
179:
180:            public Servlet getServlet() {
181:                return servlet;
182:            }
183:
184:            /**
185:             * Returns the number of seconds the servlet expects to 
186:             * be temporarily unavailable.  
187:             *
188:             * <p>If this method returns a negative number, the servlet
189:             * is permanently unavailable or cannot provide an estimate of
190:             * how long it will be unavailable. No effort is
191:             * made to correct for the time elapsed since the exception was
192:             * first reported.
193:             *
194:             * @return		an integer specifying the number of seconds
195:             *			the servlet will be temporarily unavailable,
196:             *			or a negative number if the servlet is permanently
197:             *			unavailable or cannot make an estimate
198:             *
199:             */
200:
201:            public int getUnavailableSeconds() {
202:                return permanent ? -1 : seconds;
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.