BEA Systems, Inc.

BEA WebLogic Server 9.1 API Reference


weblogic.servlet.http
Class AbstractAsyncServlet

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended byweblogic.servlet.http.AbstractAsyncServlet
All Implemented Interfaces:
FutureResponseModel, Serializable, Servlet, ServletConfig

public abstract class AbstractAsyncServlet
extends HttpServlet
implements FutureResponseModel

Implementations of AbstractAsyncServlet decouple the receiving of a servlet request from the sending of its response. Responses may be sent in the future through the use of the notify(weblogic.servlet.http.RequestResponseKey, java.lang.Object) function. The servlet does not consume any threads while waiting for notify(weblogic.servlet.http.RequestResponseKey, java.lang.Object) to be called making it suitable for scalable proxying to remote systems. The servlet instance used for sending the response is only guaranteed to be the same as that used to process the request when SingleThreadModel is used.

Stale requests are scavanged based on timeout settings modifiable through setTimeout(int) and setScavangeInterval(int). The scavange interval is global to all AbstractAsyncServlets. The timeout period is per-servlet instance. If a timeout occurs then the doTimeout(weblogic.servlet.http.RequestResponseKey) method is called on an appropriate servlet instance, giving implementors a chance to feedback timeout information to the caller.

Only direct client requests can be used with AbstractAsyncServlet, it cannot be used as the target of request dispatching includes or forwards. It can however be used to dispatch to forwards and includes that are not instances of AbstractAsyncServlet

Servlet filters which get applied before AbstractAsyncServlets, will not be able to take advantage of post processing of the response.

See Also:
Serialized Form
Copyright © 2005 BEA Systems, Inc. All Rights Reserved.

Field Summary
static int DEFAULT_SCAVANGE_INTERVAL
          The default interval period in milliseconds at which requests will be checked for timeouts.
static int DEFAULT_TIMEOUT
          The default request timeout period in milliseconds.
 
Constructor Summary
AbstractAsyncServlet()
           
 
Method Summary
protected abstract  boolean doRequest(RequestResponseKey rrk)
          Process the servlet request.
protected abstract  void doResponse(RequestResponseKey rrk, Object context)
          Process the servlet response.
protected abstract  void doTimeout(RequestResponseKey rrk)
          Send back a servlet response error when notify(weblogic.servlet.http.RequestResponseKey, java.lang.Object) is not called within the timeout period.
static void notify(RequestResponseKey id, Object context)
          notify the servlet implementation that a response should be sent for the key id.
protected  void service(HttpServletRequest req, HttpServletResponse rsp)
          Implementation of the standard HttpServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) method.
static void setScavangeInterval(int period)
          Sets the interval period in milliseconds at which requests will be checked for timeouts.
protected  void setTimeout(int period)
          Sets the request timeout period in milliseconds for this servlet.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SCAVANGE_INTERVAL

public static final int DEFAULT_SCAVANGE_INTERVAL
The default interval period in milliseconds at which requests will be checked for timeouts.

See Also:
Constant Field Values

DEFAULT_TIMEOUT

public static final int DEFAULT_TIMEOUT
The default request timeout period in milliseconds.

See Also:
Constant Field Values
Constructor Detail

AbstractAsyncServlet

public AbstractAsyncServlet()
Method Detail

doRequest

protected abstract boolean doRequest(RequestResponseKey rrk)
                              throws IOException,
                                     ServletException
Process the servlet request. Implementors should override this method. The request and response streams are available in the RequestResponseKey.

Parameters:
rrk - the RequestResponseKey, containing the servlet request and response
Throws:
IOException
ServletException

doResponse

protected abstract void doResponse(RequestResponseKey rrk,
                                   Object context)
                            throws IOException,
                                   ServletException
Process the servlet response. Implementors should override this method. There is no guarantee that the same servlet instance is used for processing doResponse as doRequest(weblogic.servlet.http.RequestResponseKey). If an exception occurs during processing then the container will arrange for the error to be sent back to the client. The request and response streams are available in the RequestResponseKey.

Parameters:
rrk - the RequestResponseKey, containing the servlet request and response
Throws:
IOException
ServletException

doTimeout

protected abstract void doTimeout(RequestResponseKey rrk)
                           throws IOException,
                                  ServletException
Send back a servlet response error when notify(weblogic.servlet.http.RequestResponseKey, java.lang.Object) is not called within the timeout period. Implementors should override this method. There is no guarantee that the same servlet instance is used for processing doTimeout as doRequest(weblogic.servlet.http.RequestResponseKey). The request and response streams are available in the RequestResponseKey.

Parameters:
rrk - the RequestResponseKey, containing the servlet request and response
Throws:
IOException
ServletException

notify

public static final void notify(RequestResponseKey id,
                                Object context)
                         throws IOException
notify the servlet implementation that a response should be sent for the key id. id must be the key provided as an argument to doRequest(weblogic.servlet.http.RequestResponseKey). Then notify> synchronously sends out the servlet response after having called doResponse(weblogic.servlet.http.RequestResponseKey, java.lang.Object). Notify will pass the context object to doResponse(weblogic.servlet.http.RequestResponseKey, java.lang.Object), if provided with one.

Parameters:
id - the key used to identify the response that should be sent back.
Throws:
IOException

service

protected final void service(HttpServletRequest req,
                             HttpServletResponse rsp)
                      throws IOException,
                             ServletException
Implementation of the standard HttpServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) method. This method cannot be overridden, implementors should instead override doRequest(weblogic.servlet.http.RequestResponseKey) and doResponse(weblogic.servlet.http.RequestResponseKey, java.lang.Object).

Throws:
IOException
ServletException

setScavangeInterval

public static final void setScavangeInterval(int period)
Sets the interval period in milliseconds at which requests will be checked for timeouts. This setting affects all implementations of AbstractAsyncServlet.

Parameters:
period - the interval period in milliseconds. A timeout period <= 0 is illegal.

setTimeout

protected void setTimeout(int period)
Sets the request timeout period in milliseconds for this servlet. This method should typically be called from the GenericServlet.init(javax.servlet.ServletConfig) method. The new value applies only to requests started after this method call. To set the timeout for a specific servlet request, use RequestResponseKey.setTimeout(int)

Parameters:
period - the timeout period in milliseconds. A timeout period <= 0 means that requests will never be timed out.

Documentation is available at
http://download.oracle.com/docs/cd/E13222_01/wls/docs91
Copyright 2005 BEA Systems Inc.