Project Wonder 5.0

er.extensions.appserver
Class ERXDelayedRequestHandler

java.lang.Object
  extended by com.webobjects.appserver.WORequestHandler
      extended by er.extensions.appserver.ERXDelayedRequestHandler

public class ERXDelayedRequestHandler
extends com.webobjects.appserver.WORequestHandler

When this request handler is set via registerRequestHandlerForKey(new ERXDelayedRequestHandler(), ERXDelayedRequestHandler.KEY), then a request that takes too long is automatically detached and a poor man's long response is returned. It is pretty cool in that:

Author:
ak

Nested Class Summary
 class ERXDelayedRequestHandler.DelayedRequest
          Helper to wrap a future and the accompanying request.
 
Field Summary
static java.lang.String KEY
           
protected static org.apache.log4j.Logger log
           
 
Fields inherited from class com.webobjects.appserver.WORequestHandler
DidHandleRequestNotification
 
Constructor Summary
ERXDelayedRequestHandler()
          Creates a handler with the default values of 5 second refresh and 5 seconds maxRequestTime.
ERXDelayedRequestHandler(int refreshTimeSeconds, int maxRequestTimeSeconds)
          Creates a handler with the supplied values for refreshTimeSeconds and maxRequestTimeSeconds.
ERXDelayedRequestHandler(int refreshTimeSeconds, int maxRequestTimeSeconds, int cancelRequestAfterSeconds)
          Creates a handler with the supplied values for refreshTimeSeconds, maxRequestTimeSeconds and maxRequestTimeSeconds.
ERXDelayedRequestHandler(int refreshTimeSeconds, int maxRequestTimeSeconds, int cancelRequestAfterSeconds, java.lang.String cssUrl)
          Creates a request handler instance.
 
Method Summary
 com.webobjects.foundation.NSArray<ERXDelayedRequestHandler.DelayedRequest> activeRequests()
          Returns all active delayed requests.
protected  boolean canHandleRequest(com.webobjects.appserver.WORequest request)
          Returns true if the request handler key can be handled.
protected  com.webobjects.appserver.WOResponse createErrorResponse(com.webobjects.appserver.WORequest request)
          Create an error page when the future wasn't found anymore.
protected  com.webobjects.appserver.WOResponse createRefreshResponse(com.webobjects.appserver.WORequest request, java.lang.String url)
          Create a refresh page.
protected  com.webobjects.appserver.WOResponse createStoppedResponse(com.webobjects.appserver.WORequest request)
          Create a "stopped" page.
protected  java.lang.String cssUrl(com.webobjects.appserver.WORequest request)
           
protected  com.webobjects.appserver.WOResponse handle(com.webobjects.appserver.WORequest request, ERXDelayedRequestHandler.DelayedRequest delayedRequest, java.lang.String id)
          Override to handle specific actions for the current future.
 com.webobjects.appserver.WOResponse handleRequest(com.webobjects.appserver.WORequest request)
          Handles the request and returns the applicable response.
protected  int maxRequestTimeMillis()
          Returns the maximum time in milliseconds for allowed for a request before returning the message page.
protected  int refresh()
          Returns the refresh time in seconds for the message page;
 
Methods inherited from class com.webobjects.appserver.WORequestHandler
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static final org.apache.log4j.Logger log

KEY

public static java.lang.String KEY
Constructor Detail

ERXDelayedRequestHandler

public ERXDelayedRequestHandler(int refreshTimeSeconds,
                                int maxRequestTimeSeconds,
                                int cancelRequestAfterSeconds,
                                java.lang.String cssUrl)
Creates a request handler instance.

Parameters:
refreshTimeSeconds - time in seconds for the refresh of the page
maxRequestTimeSeconds - time in seconds that a request can take at most before the delayed page is returned
cancelRequestAfterSeconds - time in seconds that a request can take at most before it is cancelled
cssUrl - url for a style sheet for the message page

ERXDelayedRequestHandler

public ERXDelayedRequestHandler(int refreshTimeSeconds,
                                int maxRequestTimeSeconds,
                                int cancelRequestAfterSeconds)
Creates a handler with the supplied values for refreshTimeSeconds, maxRequestTimeSeconds and maxRequestTimeSeconds.

Parameters:
refreshTimeSeconds -
maxRequestTimeSeconds -
cancelRequestAfterSeconds -

ERXDelayedRequestHandler

public ERXDelayedRequestHandler(int refreshTimeSeconds,
                                int maxRequestTimeSeconds)
Creates a handler with the supplied values for refreshTimeSeconds and maxRequestTimeSeconds. cancelRequestAfterSeconds is set o 5*maxRequestTimeSeconds.

Parameters:
refreshTimeSeconds -
maxRequestTimeSeconds -

ERXDelayedRequestHandler

public ERXDelayedRequestHandler()
Creates a handler with the default values of 5 second refresh and 5 seconds maxRequestTime. Requests taking longer than 25 seconds are cancelled.

Method Detail

handleRequest

public com.webobjects.appserver.WOResponse handleRequest(com.webobjects.appserver.WORequest request)
Handles the request and returns the applicable response.

Specified by:
handleRequest in class com.webobjects.appserver.WORequestHandler

canHandleRequest

protected boolean canHandleRequest(com.webobjects.appserver.WORequest request)
Returns true if the request handler key can be handled.

Parameters:
request -

handle

protected com.webobjects.appserver.WOResponse handle(com.webobjects.appserver.WORequest request,
                                                     ERXDelayedRequestHandler.DelayedRequest delayedRequest,
                                                     java.lang.String id)
Override to handle specific actions for the current future.

Parameters:
request -
delayedRequest -
id -

createErrorResponse

protected com.webobjects.appserver.WOResponse createErrorResponse(com.webobjects.appserver.WORequest request)
Create an error page when the future wasn't found anymore. This happens hen the user backtracks and it is no longer in the cache. Note that the session has not been awakened.

Parameters:
request -

createStoppedResponse

protected com.webobjects.appserver.WOResponse createStoppedResponse(com.webobjects.appserver.WORequest request)
Create a "stopped" page. Note that the session has not been awakened yet and you probably shouldn't do it either. The default implementation redirect to the entry.

Parameters:
request -

cssUrl

protected java.lang.String cssUrl(com.webobjects.appserver.WORequest request)

createRefreshResponse

protected com.webobjects.appserver.WOResponse createRefreshResponse(com.webobjects.appserver.WORequest request,
                                                                    java.lang.String url)
Create a refresh page. Note that the session has not been awakened yet and you probably shouldn't do it either.

Parameters:
request -
url -

refresh

protected int refresh()
Returns the refresh time in seconds for the message page;


maxRequestTimeMillis

protected int maxRequestTimeMillis()
Returns the maximum time in milliseconds for allowed for a request before returning the message page.


activeRequests

public com.webobjects.foundation.NSArray<ERXDelayedRequestHandler.DelayedRequest> activeRequests()
Returns all active delayed requests.


Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.