com.google.code.rees.scope.session
Class SessionAdapter

java.lang.Object
  extended by com.google.code.rees.scope.session.SessionAdapter
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
StrutsSessionAdapter

public abstract class SessionAdapter
extends Object
implements Serializable

A simple abstract adapter used to adapt frameworks to the session management components. Makes use of ThreadLocal to make the current request's adapter available through the static call SessionAdapter.getAdapter().

Author:
rees.byars
See Also:
Serialized Form

Field Summary
protected static ThreadLocal<SessionAdapter> sessionAdapter
           
 
Constructor Summary
SessionAdapter()
           
 
Method Summary
abstract  void addPostProcessor(SessionPostProcessor sessionPostProcessor)
          Add a SessionPostProcessor that is guaranteed to be executed after action execution.
abstract  Object getAction()
          The controller instance, such as a Struts2 action class or a Spring MVC controller
abstract  String getActionId()
          A string identifying the current action.
static SessionAdapter getAdapter()
          Get the ThreadLocal SessionAdapter associated with the current request
abstract  Map<String,Object> getSessionContext()
          Returns a session-scoped map.
static void setAdapter(SessionAdapter adapter)
          Set the ThreadLocal SessionAdapter for use with the current request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sessionAdapter

protected static ThreadLocal<SessionAdapter> sessionAdapter
Constructor Detail

SessionAdapter

public SessionAdapter()
Method Detail

getAction

public abstract Object getAction()
The controller instance, such as a Struts2 action class or a Spring MVC controller

Returns:

getActionId

public abstract String getActionId()
A string identifying the current action. The convention employed by the DefaultSessionConfigurationProvider is the name of the controller method being executed.

Returns:

getSessionContext

public abstract Map<String,Object> getSessionContext()
Returns a session-scoped map. For Struts2, the returned map is the Struts2 SessionMap.

Returns:

addPostProcessor

public abstract void addPostProcessor(SessionPostProcessor sessionPostProcessor)
Add a SessionPostProcessor that is guaranteed to be executed after action execution. Calling SessionPostProcessor.postProcessSession(SessionAdapter) is the responsibility of the concrete SessionAdapter extending class.

Parameters:
sessionPostProcessor -

setAdapter

public static void setAdapter(SessionAdapter adapter)
Set the ThreadLocal SessionAdapter for use with the current request. Called in the constructor to force new instances into the ThreadLocal.

Parameters:
adapter -

getAdapter

public static SessionAdapter getAdapter()
Get the ThreadLocal SessionAdapter associated with the current request

Returns:


Copyright © 2012-2013. All Rights Reserved.