01: /*
02: * Copyright 2003-2006 Rick Knowles <winstone-devel at lists sourceforge net>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: */
07: package javax.servlet;
08:
09: /**
10: * Thrown if a servlet is permanently or temporarily unavailable
11: *
12: * @author <a href="mailto:rick_knowles@hotmail.com">Rick Knowles</a>
13: * @version $Id: UnavailableException.java,v 1.2 2006/02/28 07:32:47 rickknowles Exp $
14: */
15: public class UnavailableException extends ServletException {
16: private int seconds;
17:
18: private Servlet servlet;
19:
20: /**
21: * @deprecated As of Java Servlet API 2.2, use UnavailableException(String,
22: * int) instead.
23: */
24: public UnavailableException(int seconds, Servlet servlet, String msg) {
25: this (servlet, msg);
26: this .seconds = (seconds <= 0 ? 0 : seconds);
27: }
28:
29: /**
30: * @deprecated As of Java Servlet API 2.2, use UnavailableException(String)
31: * instead.
32: */
33: public UnavailableException(Servlet servlet, String msg) {
34: this (msg);
35: this .servlet = servlet;
36: }
37:
38: /**
39: * Constructs a new exception with a descriptive message indicating that the
40: * servlet is permanently unavailable.
41: */
42: public UnavailableException(String msg) {
43: super (msg);
44: }
45:
46: /**
47: * Constructs a new exception with a descriptive message indicating that the
48: * servlet is temporarily unavailable and giving an estimate of how long it
49: * will be unavailable.
50: */
51: public UnavailableException(String msg, int seconds) {
52: this (msg);
53: this .seconds = (seconds <= 0 ? 0 : seconds);
54: }
55:
56: /**
57: * @deprecated As of Java Servlet API 2.2, with no replacement. Returns the
58: * servlet that is reporting its unavailability.
59: */
60: public Servlet getServlet() {
61: return this .servlet;
62: }
63:
64: /**
65: * Returns the number of seconds the servlet expects to be temporarily
66: * unavailable.
67: */
68: public int getUnavailableSeconds() {
69: return this .seconds;
70: }
71:
72: /**
73: * Returns a boolean indicating whether the servlet is permanently
74: * unavailable.
75: */
76: public boolean isPermanent() {
77: return this .seconds <= 0;
78: }
79:
80: }
|