ERXDelayedRequestHandler Class Reference

Inherits com::webobjects::appserver::WORequestHandler.

Collaboration diagram for ERXDelayedRequestHandler:

Collaboration graph
[legend]

List of all members.

Classes

class  DelayedRequest

Public Member Functions

NSArray< DelayedRequestactiveRequests ()
 ERXDelayedRequestHandler ()
 ERXDelayedRequestHandler (int refreshTimeSeconds, int maxRequestTimeSeconds)
 ERXDelayedRequestHandler (int refreshTimeSeconds, int maxRequestTimeSeconds, int cancelRequestAfterSeconds)
 ERXDelayedRequestHandler (int refreshTimeSeconds, int maxRequestTimeSeconds, int cancelRequestAfterSeconds, String cssUrl)
WOResponse handleRequest (final WORequest request)

Static Public Attributes

static String KEY = "_edr_"

Protected Member Functions

boolean canHandleRequest (WORequest request)
WOResponse createErrorResponse (WORequest request)
WOResponse createRefreshResponse (WORequest request, String url)
WOResponse createStoppedResponse (WORequest request)
String cssUrl (WORequest request)
WOResponse handle (WORequest request, DelayedRequest delayedRequest, String id)
int maxRequestTimeMillis ()
int refresh ()

Static Protected Attributes

static final Logger log = Logger.getLogger(ERXDelayedRequestHandler.class)

Private Attributes

String _cssUrl
ExecutorService _executor
ERXExpiringCache< String,
DelayedRequest
_futures
int _maxRequestTimeMillis
int _refreshTimeSeconds
ERXExpiringCache< String, String_urls


Detailed Description

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

Constructor & Destructor Documentation

ERXDelayedRequestHandler ( int  refreshTimeSeconds,
int  maxRequestTimeSeconds,
int  cancelRequestAfterSeconds,
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 ( int  refreshTimeSeconds,
int  maxRequestTimeSeconds,
int  cancelRequestAfterSeconds 
)

Creates a handler with the supplied values for refreshTimeSeconds, maxRequestTimeSeconds and maxRequestTimeSeconds.

Parameters:
refreshTimeSeconds 
maxRequestTimeSeconds 
cancelRequestAfterSeconds 

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 

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


Member Function Documentation

NSArray<DelayedRequest> activeRequests (  ) 

Returns all active delayed requests.

boolean canHandleRequest ( WORequest  request  )  [protected]

Returns true if the request handler key can be handled.

Parameters:
request 

WOResponse createErrorResponse ( WORequest  request  )  [protected]

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 

WOResponse createRefreshResponse ( WORequest  request,
String  url 
) [protected]

Create a refresh page. Note that the session has not been awakened yet and you probably shouldn't do it either.

Parameters:
request 
url 

WOResponse createStoppedResponse ( WORequest  request  )  [protected]

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 

String cssUrl ( WORequest  request  )  [protected]

WOResponse handle ( WORequest  request,
DelayedRequest  delayedRequest,
String  id 
) [protected]

Override to handle specific actions for the current future.

Parameters:
request 
delayedRequest 
id 

WOResponse handleRequest ( final WORequest  request  ) 

Handles the request and returns the applicable response.

int maxRequestTimeMillis (  )  [protected]

Returns the maximum time in milliseconds for allowed for a request before returning the message page.

int refresh (  )  [protected]

Returns the refresh time in seconds for the message page;


Member Data Documentation

String _cssUrl [private]

ExecutorService _executor [private]

ERXExpiringCache<String, DelayedRequest> _futures [private]

int _maxRequestTimeMillis [private]

int _refreshTimeSeconds [private]

ERXExpiringCache<String, String> _urls [private]

String KEY = "_edr_" [static]

final Logger log = Logger.getLogger(ERXDelayedRequestHandler.class) [static, protected]


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:02 2012 for Project Wonder by  doxygen 1.5.8