org.apache.jetspeed.services.statemanager
Interface StateManagerService

All Known Implementing Classes:
BaseStateManagerService

public interface StateManagerService

The StateManagerService is a service that manages SessionState information. Each SessionState is identified by a unique key in this service. The SessionState is composed of name - value sets of attributes, stored under the key by the service.

See the proposal: jakarta-jetspeed/proposals/StateManager.txt for more details.

Attribute values placed into SessionStates may be automatically removed, for example when a SessionState expires in some way, or by means of some other automatic service. These value objects can be notified of their placement into and out of the SessionState. Objects that wish to receive this notification implement the SessionStateBindingListener interface. This is based on and similar to the HttpSessionBindingListener mechanism.

To support the "current" routines; the ability to get a session state based on the current http session, this service must be installed properly into the procssing of each http request. At the start of the request, the HttpSession of the request must be passed into the setCurrentContext() method. At the end of the request, clearCurrentContext() is called. For Jetspeed, this is done in the JetspeedRunDataService, which is always going to be called by Turbine in this way.

Version:
$Revision: 1.5 $
Author:
Glenn R. Golden
See Also:
SessionState, SessionStateBindingListener

Field Summary
static java.lang.String SERVICE_NAME
          The name used to find the service in the service manager.
 
Method Summary
 void clear(java.lang.String key)
          Remove all state attribute of the keyed state.
 void clearCurrentContext()
          Clear the "current context for this thread - Call at the end of each request, balanced with calls to setCurrentContext()
 java.lang.Object getAttribute(java.lang.String key, java.lang.String name)
          Access the named attribute of the keyed state.
 java.lang.String[] getAttributeNames(java.lang.String key)
          Access an array of all names of attributes stored in the keyed state.
 SessionState getCurrentSessionState()
          Access the SessionState object associated with the current request's http session.
 SessionState getCurrentSessionState(java.lang.String key)
          Access the SessionState object associated with the current request's http session with the given key.
 SessionState getSessionState(java.lang.String key)
          Access an SessionState object with the given key.
 void removeAttribute(java.lang.String key, java.lang.String name)
          Remove the named state attribute of the keyed state, if it exists.
 void retireState(java.lang.String keyStart)
          Retire, forget about and clean up all states that start with the given key.
 void setAttribute(java.lang.String key, java.lang.String name, java.lang.Object value)
          Set the named state attribute of the keyed state with the provided object.
 void setCurrentContext(javax.servlet.http.HttpSession session)
          Set the "current" context for this thread - Call this at the start of each request, and call %%% at the end.
 

Field Detail

SERVICE_NAME

public static final java.lang.String SERVICE_NAME
The name used to find the service in the service manager.

See Also:
Constant Field Values
Method Detail

getAttribute

public java.lang.Object getAttribute(java.lang.String key,
                                     java.lang.String name)
Access the named attribute of the keyed state.

Parameters:
key - The state key.
name - The attribute name.
Returns:
The named attribute value of the keyed state.

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.String name,
                         java.lang.Object value)
Set the named state attribute of the keyed state with the provided object.

Parameters:
key - The state key.
name - The attribute name.
value - The new value of the attribute (any object type).

removeAttribute

public void removeAttribute(java.lang.String key,
                            java.lang.String name)
Remove the named state attribute of the keyed state, if it exists.

Parameters:
key - The state key.
name - The attribute name.

clear

public void clear(java.lang.String key)
Remove all state attribute of the keyed state.

Parameters:
key - The state key.

getAttributeNames

public java.lang.String[] getAttributeNames(java.lang.String key)
Access an array of all names of attributes stored in the keyed state.

Parameters:
key - The state key.
Returns:
An array of all names of attributes stored in the keyed state.

getSessionState

public SessionState getSessionState(java.lang.String key)
Access an SessionState object with the given key.

Parameters:
key - The SessionState key.
Returns:
an SessionState object with the given key.

getCurrentSessionState

public SessionState getCurrentSessionState()
Access the SessionState object associated with the current request's http session. The session id is used as the key.

Returns:
an SessionState object associated with the current request's http session.

getCurrentSessionState

public SessionState getCurrentSessionState(java.lang.String key)
Access the SessionState object associated with the current request's http session with the given key.

Parameters:
key - The string to add to the session id to form the SessionState key.
Returns:
an SessionState object associated with the current request's http session with the given key.

retireState

public void retireState(java.lang.String keyStart)
Retire, forget about and clean up all states that start with the given key.

Parameters:
keyStart - The beginning of the key of the states to clean up.

setCurrentContext

public void setCurrentContext(javax.servlet.http.HttpSession session)
Set the "current" context for this thread - Call this at the start of each request, and call %%% at the end. getCurrentSession() uses this for the session state key.

Parameters:
session - the HttpSession of the current request.

clearCurrentContext

public void clearCurrentContext()
Clear the "current context for this thread - Call at the end of each request, balanced with calls to setCurrentContext()



Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.