Class AbstractResponseFactory

  extended by
All Implemented Interfaces:
Direct Known Subclasses:
FileResponseFactory, SkwishResponseFactory

public abstract class AbstractResponseFactory
extends Object
implements ResponseFactory

A skeletal implementation of a ResponseFactory that honors the server's asynchHint. Instead of implementing ResponseFactory.getResponse(RequestHeader, StageletStack, boolean), a subclass implements prepareResponseImpl(RequestHeader, StageletStack): asynchronous processing hints (i.e. when the asynchHint parameter in a getResponse invocation is true) are automatically handled by returning a AsynchStagelet that asynchronously calls prepareResponseImpl on init.

Babak Farhang
See Also:
prepareResponseImpl(RequestHeader, StageletStack)

Constructor Summary
Method Summary
protected  Stagelet badRequest(RequestHeader request, StageletStack stack)
 Stagelet getResponse(RequestHeader request, StageletStack stack, boolean asynchHint)
          Returns the implementation-specific stagelet.
protected  Stagelet notFound(RequestHeader request, StageletStack stack)
protected abstract  Stagelet prepareResponseImpl(RequestHeader request, StageletStack stack)
          Returns the factory-specific (i.e.
protected  String urlDecode(String value)
          URL-decodes and returns the given value.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public AbstractResponseFactory()
Method Detail


public Stagelet getResponse(RequestHeader request,
                            StageletStack stack,
                            boolean asynchHint)
Returns the implementation-specific stagelet. If asynch is false, then prepareResponseImpl(RequestHeader, StageletStack) is returned immediately; o.w., an AsynchStagelet that'll later invoke prepareResponseImpl(RequestHeader, StageletStack) is returned.

Specified by:
getResponse in interface ResponseFactory
stack - if the returned stagelet is itself stack-aware, then it will push additional stagelets (e.g. the header response stage) onto the given stack. The rules for when and how stagelets can be pushed on the stack are described in the Stagelet interface.
asynchHint - if true, then the response stagelet should try to process non-network I/O based tasks asynchronously.
See Also:
Stagelet, HandletContext.processAsynch()


protected abstract Stagelet prepareResponseImpl(RequestHeader request,
                                                StageletStack stack)
Returns the factory-specific (i.e. app-specific) stagelet. The returned instance will not be in the PROCESSING state.


protected Stagelet notFound(RequestHeader request,
                            StageletStack stack)


protected Stagelet badRequest(RequestHeader request,
                              StageletStack stack)


protected final String urlDecode(String value)
URL-decodes and returns the given value. If value is null, then null is returned. Logo