UnavailableException (Java EE 5)

Java EE API


javax.servlet Class UnavailableException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by javax.servlet.ServletException
              extended by javax.servlet.UnavailableException
All Implemented Interfaces:
Serializable

public class UnavailableException
extends ServletException

Extends: Throwable > Exception > ServletException

定义 servlet 或过滤器抛出的指示该 servlet 或过滤器永久或暂时不可用的异常。

当 servlet 或过滤器是永久不可用时,该 servlet 或过滤器的某些地方出错,在采取某个操作之前,该 servlet 或过滤器一直无法处理请求。例如,可能以不正确的方式配置了某个 servlet,或者过滤器的状态可能被破坏。组件应该记录错误和需要的校正操作。

如果由于某个系统范围的问题导致 servlet 或过滤器暂时无法处理请求,则该 servlet 或过滤器是暂时不可用。例如,可能无法访问第三层服务器,或者没有处理请求的足够内存或磁盘存储。系统管理员可能需要采取校正操作。

servlet 容器能够以相同的方式安全地处理这两种类型的不可用异常。但是,有效处理暂时不可用性可使 servlet 容器更健壮。确切地说,servlet 容器可能会将对该 servlet 或过滤器的请求阻塞一段时间(该异常建议的时间),而不是在 servlet 容器重启之前一直拒绝它们。

英文文档:

Defines an exception that a servlet or filter throws to indicate that it is permanently or temporarily unavailable.

When a servlet or filter is permanently unavailable, something is wrong with it, and it cannot handle requests until some action is taken. For example, a servlet might be configured incorrectly, or a filter's state may be corrupted. The component should log both the error and the corrective action that is needed.

A servlet or filter is temporarily unavailable if it cannot handle requests momentarily due to some system-wide problem. For example, a third-tier server might not be accessible, or there may be insufficient memory or disk storage to handle requests. A system administrator may need to take corrective action.

Servlet containers can safely treat both types of unavailable exceptions in the same way. However, treating temporary unavailability effectively makes the servlet container more robust. Specifically, the servlet container might block requests to the servlet or filter for a period of time suggested by the exception, rather than rejecting them until the servlet container restarts.

Author:
Various
See Also:
Serialized Form

Constructor Summary
 
Method Summary
 Servlet
 int
 boolean
 
Methods inherited from class javax.servlet.ServletException
 
Methods inherited from class java.lang.Throwable
 
Methods inherited from class java.lang.Object
 

Constructor Detail

public UnavailableException(Servlet servlet, String msg)
deprecated 从 Java Servlet API 2.2 起,请改用 #UnavailableException(String)
servlet 不可用的 Servlet 实例
msg 指定描述性消息的 String
英文文档:

UnavailableException

public UnavailableException(Servlet servlet,
                            String msg)
Deprecated. As of Java Servlet API 2.2, use UnavailableException(String) instead.

Parameters:
servlet - the Servlet instance that is unavailable
msg - a String specifying the descriptive message


public UnavailableException(int seconds, Servlet servlet, String msg)
deprecated 从 Java Servlet API 2.2 起,请改用 #UnavailableException(String, int)
seconds 一个整数,指定 servlet 希望不可用的秒数;如果为 0 或为负,指示 servlet 无法做出估计
servlet 不可用的 Servlet
msg 指定描述性消息的 String,可以写入日志文件或显示给用户。
英文文档:

UnavailableException

public UnavailableException(int seconds,
                            Servlet servlet,
                            String msg)
Deprecated. As of Java Servlet API 2.2, use UnavailableException(String, int) instead.

Parameters:
seconds - an integer specifying the number of seconds the servlet expects to be unavailable; if zero or negative, indicates that the servlet can't make an estimate
servlet - the Servlet that is unavailable
msg - a String specifying the descriptive message, which can be written to a log file or displayed for the user.


public UnavailableException(String msg)
构造带描述性消息的新异常,指示该 servlet 是永久不可用。
msg 指定描述性消息的 String
英文文档:

UnavailableException

public UnavailableException(String msg)
Constructs a new exception with a descriptive message indicating that the servlet is permanently unavailable.

Parameters:
msg - a String specifying the descriptive message


public UnavailableException(String msg, int seconds)
构造带描述性消息的新异常,指示该 servlet 是暂时不可用,并提供对其不可用时间长度的估计。

在某些情况下,servlet 无法做出估计。例如,servlet 可能知道它需要的服务器没有运行,但无法报告该服务器要花多长时间才能恢复功能。可通过对 seconds 参数使用负值或 0 来指示这一点。

msg 指定描述性消息的 String,可以写入日志文件或显示给用户。
seconds 一个整数,指定 servlet 希望不可用的秒数;如果为 0 或为负,指示 servlet 无法做出估计

英文文档:

UnavailableException

public UnavailableException(String msg,
                            int seconds)
Constructs a new exception with a descriptive message indicating that the servlet is temporarily unavailable and giving an estimate of how long it will be unavailable.

In some cases, the servlet cannot make an estimate. For example, the servlet might know that a server it needs is not running, but not be able to report how long it will take to be restored to functionality. This can be indicated with a negative or zero value for the seconds argument.

Parameters:
msg - a String specifying the descriptive message, which can be written to a log file or displayed for the user.
seconds - an integer specifying the number of seconds the servlet expects to be unavailable; if zero or negative, indicates that the servlet can't make an estimate

Method Detail

public boolean isPermanent()
返回指示该 servlet 是否是永久不可用的 boolean 值。如果是永久不可用,则该 servlet 的某些地方出错,系统管理员必须采取校正操作。
return 如果 servlet 是永久不可用,则返回 true;如果 servlet 是可用的或者是暂时不可用,则返回 false
英文文档:

isPermanent

public boolean isPermanent()
Returns a boolean indicating whether the servlet is permanently unavailable. If so, something is wrong with the servlet, and the system administrator must take some corrective action.

Returns:
true if the servlet is permanently unavailable; false if the servlet is available or temporarily unavailable

public Servlet getServlet()
deprecated 从 Java Servlet API 2.2 起,不再提供替代方法。 返回报告其不可用性的 servlet。
return 抛出 UnavailableExceptionServlet 对象
英文文档:

getServlet

public Servlet getServlet()
Deprecated. As of Java Servlet API 2.2, with no replacement. Returns the servlet that is reporting its unavailability.

Returns:
the Servlet object that is throwing the UnavailableException

public int getUnavailableSeconds()
返回 servlet 希望暂时不可用的秒数。

如果此方法返回一个负数,则 servlet 是永久不可用,或者无法提供对其不可用时间长度的估计。在自第一次报告该异常起经过的指定时间内不做任何校正努力。

return 一个整数,指定 servlet 暂时不可用的秒数;如果 servlet 是永久不可用或者无法做出估计,则返回一个负数

英文文档:

getUnavailableSeconds

public int getUnavailableSeconds()
Returns the number of seconds the servlet expects to be temporarily unavailable.

If this method returns a negative number, the servlet is permanently unavailable or cannot provide an estimate of how long it will be unavailable. No effort is made to correct for the time elapsed since the exception was first reported.

Returns:
an integer specifying the number of seconds the servlet will be temporarily unavailable, or a negative number if the servlet is permanently unavailable or cannot make an estimate


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!