org.apache.beehive.netui.pageflow.internal
Class DeferredSessionStorageHandler

Object
  extended by BaseHandler
      extended by DefaultHandler
          extended by DeferredSessionStorageHandler
All Implemented Interfaces:
Serializable, Handler, StorageHandler

public class DeferredSessionStorageHandler
extends DefaultHandler
implements StorageHandler

This alternate session storage handler does not write any attribute into the session until the very end of a chain of forwarded requests (i.e., not even at the end of an inner forwarded request). This allows it to handle multiple concurrent forwarded requests, each of which is modifying the same data, in a more reasonable way. Basically, each request works in its own snapshot of the session, and the last one to commit is the one whose snapshot wins. This is a better alternative thatn allowing them to interfere with each other in the middle of the request chain.

See Also:
Serialized Form

Constructor Summary
DeferredSessionStorageHandler(ServletContext servletContext)
           
 
Method Summary
 boolean allowBindingEvent(Object event)
          Tell whether a given binding event should be allowed to occur.
 void applyChanges(RequestContext context)
          Apply any deferred changes, at the end of a chain of requests.
 void ensureFailover(RequestContext context, String attributeName, Object value)
          Ensure that the given named attribute is replicated in a cluster for session failover, if appropriate.
 Object getAttribute(RequestContext context, String attributeName)
          Get a named attribute.
 void removeAttribute(RequestContext context, String attrName)
          Remove a named attribute.
 void setAttribute(RequestContext context, String attrName, Object value)
          Set a named attribute.
 
Methods inherited from class DefaultHandler
getRegisteredHandler, setRegisteredHandler
 
Methods inherited from class BaseHandler
getConfig, getPreviousHandler, getServletContext, init, reinit
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Handler
init, reinit
 

Constructor Detail

DeferredSessionStorageHandler

public DeferredSessionStorageHandler(ServletContext servletContext)
Method Detail

setAttribute

public void setAttribute(RequestContext context,
                         String attrName,
                         Object value)
Description copied from interface: StorageHandler
Set a named attribute.

Specified by:
setAttribute in interface StorageHandler
Parameters:
context - the current RequestContext.
attrName - the name of the attribute to set.
value - the attribute value.

removeAttribute

public void removeAttribute(RequestContext context,
                            String attrName)
Description copied from interface: StorageHandler
Remove a named attribute.

Specified by:
removeAttribute in interface StorageHandler
Parameters:
context - the current RequestContext.
attrName - the name of the attribute to remove.

getAttribute

public Object getAttribute(RequestContext context,
                           String attributeName)
Description copied from interface: StorageHandler
Get a named attribute.

Specified by:
getAttribute in interface StorageHandler
Parameters:
context - the current RequestContext.
attributeName - the name of the attribute to get.
Returns:
the attribute, or null if there is no such named attribute.

applyChanges

public void applyChanges(RequestContext context)
Description copied from interface: StorageHandler
Apply any deferred changes, at the end of a chain of requests.

Specified by:
applyChanges in interface StorageHandler
Parameters:
context - the current request context.

ensureFailover

public void ensureFailover(RequestContext context,
                           String attributeName,
                           Object value)
Description copied from interface: StorageHandler
Ensure that the given named attribute is replicated in a cluster for session failover, if appropriate.

Specified by:
ensureFailover in interface StorageHandler
Parameters:
context - the current request context.
attributeName - the name of the attribute for which failover should be ensured.
value - the value of the attribute for which failover should be ensured.

allowBindingEvent

public boolean allowBindingEvent(Object event)
Description copied from interface: StorageHandler
Tell whether a given binding event should be allowed to occur. This is mainly useful in cases when this handler writes data to some underlying storage (like the HttpSession) at some time other than when StorageHandler.setAttribute(org.apache.beehive.netui.pageflow.RequestContext, java.lang.String, java.lang.Object) is called, in which case a binding event would be misleading. Only PageFlowManagedObjects pay attention to this.

Specified by:
allowBindingEvent in interface StorageHandler
Parameters:
event - the binding event, e.g., javax.servlet.http.HttpSessionBindingEvent
Returns:
true if the event should be processed.