home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 September / PCWorld_2000-09_cd.bin / Komunik / sambar / _setup.1 / javaeng.jar / javax / servlet / UnavailableException.java < prev   
Text File  |  2000-04-03  |  4KB  |  146 lines

  1. /*
  2.  * UnavailableException.java -- Exception indicating that this servlet is
  3.  *                              unavailable
  4.  *
  5.  * Copyright (c) 1998, 1999 by Free Software Foundation, Inc.
  6.  * Written by Paul Siegmann (pauls@euronet.nl)
  7.  *
  8.  * This program is free software; you can redistribute it and/or modify
  9.  * it under the terms of the GNU Library General Public License as published
  10.  * by the Free Software Foundation, version 2. (see COPYING.LIB)
  11.  *
  12.  * This program is distributed in the hope that it will be useful, but
  13.  * WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  * GNU General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU General Public License
  18.  * along with this program; if not, write to the Free Software Foundation
  19.  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307 USA
  20.  */
  21.  
  22. package javax.servlet;
  23.  
  24. /**
  25.  * This is a special kind of exception telling the server that this particular
  26.  * servlet is currently not available.
  27.  * It has two kinds of unavailability:
  28.  * <DL>
  29.  * <DT>Permanent unavailable
  30.  * <DD>This servlet is now and forever in the future unavailable.
  31.  * If another class in spite of this fact asks this exception for how long it 
  32.  * is unavailable it returns a negative number of seconds.
  33.  * (-1 as a matter of fact)
  34.  * <DT>Temporary unavailable
  35.  * The servlet is currently unavailable, but will be available within
  36.  * a certain number of seconds.
  37.  * A class can ask the exception for that number of seconds.
  38.  * </DL>
  39.  *
  40. #ifdef SERVLET_2_0
  41.  * @version Servlet API 2.0 
  42. #endif
  43. #ifdef SERVLET_2_1
  44.  * @version Servlet API 2.1
  45. #endif
  46. #ifdef SERVLET_2_2
  47.  * @version Servlet API 2.2
  48. #endif
  49.  * @since Servlet API 1.0
  50.  */
  51. public class UnavailableException
  52.     extends ServletException 
  53. {
  54.     private Servlet    servlet;
  55.     private int    seconds;
  56.  
  57. #ifdef SERVLET_2_2
  58.  
  59.     /**
  60.      * Constructor for a permanent unavailable exception
  61.      *
  62.      * @since Servlet API 2.2
  63.      */
  64.     public UnavailableException(String message) {
  65.         super(message);
  66.         seconds = -1;
  67.     }
  68.  
  69.  
  70.     /**
  71.      * Constructor for a temporary unavailable exception
  72.      *
  73.      * @since Servlet API 2.2
  74.      */
  75.     public UnavailableException(String message, int seconds) {
  76.         super(message);
  77.         this.seconds = seconds;
  78.     }
  79.  
  80. #endif
  81.     /**
  82.      * Constructor for a permanent unavailable exception
  83.      *
  84. #ifdef SERVLET_2_2
  85.      * @deprecated
  86. #endif
  87.      * @since Servlet API 1.0
  88.      */
  89.     public UnavailableException(Servlet servlet, String message) {
  90.         super(message);
  91.         this.servlet = servlet;
  92.         seconds = -1;
  93.     }
  94.  
  95.  
  96.     /**
  97.      * Constructor for a temporary unavailable exception
  98. #ifdef SERVLET_2_2
  99.      * @deprecated
  100. #endif
  101.      *
  102.      * @since Servlet API 1.0
  103.      */
  104.     public UnavailableException(int seconds, Servlet servlet, String message) {
  105.         super(message);
  106.         this.servlet = servlet;
  107.         this.seconds = seconds;
  108.     }
  109.  
  110.  
  111.     /**
  112.      * Check whether the servlet is permanently unavailable
  113.      *
  114.      * @since Servlet API 1.0
  115.      *
  116.      * @return whether the servlet is permanently unavailable
  117.      */
  118.     public boolean isPermanent() {
  119.         return seconds < 0;
  120.     }
  121.  
  122.  
  123.     /**
  124.      * Gets the servlet that is unavailable
  125.      *
  126. #ifdef SERVLET_2_2
  127.      * @deprecated
  128. #endif
  129.      * @since Servlet API 1.0
  130.      */
  131.     public Servlet getServlet() {
  132.         return servlet;
  133.     }
  134.  
  135.     /**
  136.      * Gets the number of seconds the servlet is unavailable
  137.      *
  138.      * @since Servlet API 1.0
  139.      *
  140.      * @return the number of seconds. Negative if permanently unavailable
  141.      */
  142.     public int getUnavailableSeconds() {
  143.         return seconds;
  144.     }
  145. }
  146.