Expresso 5-6

com.jcorporate.expresso.core.controller.session
Class SimplePersistentSession

java.lang.Object
  extended bycom.jcorporate.expresso.core.controller.session.SimplePersistentSession
All Implemented Interfaces:
PersistentSession, Serializable

public class SimplePersistentSession
extends Object
implements PersistentSession

This is an implementation of PersistentSession that is useful for command line usage. The code containing the controller should hand the controller an instantiated SimplePersistentSession so that the state handlers can use ControllerRequest.getSession() and simply use it without any cares in the world.

Example Usage:

 SimplePersistentSession session = new SimplePersistentSession();
 Controller con = ConfigManager.getControllerFactory().getController(
 controllerName);
 ControllerRequest params = new ControllerRequest();
 params.setUid(3);
 params.setSession(mySession);
 
 
 

Since:
Expresso 4.0
Author:
Michael Nash
See Also:
PersistentSession, Serialized Form

Constructor Summary
SimplePersistentSession()
          Creates new SimplePersistentSession
 
Method Summary
 Object getAttribute(String attribName)
          Retrieves the object from the request context.
 Enumeration getAttributeNames()
          Retrieves all attribute names in the request context.
 String getClientAttribute(String attribName)
          Retrieves a value of a cookie set on the client's system.
 Enumeration getPeristentAttributeNames()
          Retrieves all attribute names from the session context.
 Object getPersistentAttribute(String attribName)
          Retrieves the object from the session context.
 Map getPersistentAttributes()
          Retrieves the persistent attributes table.
 void invalidate()
          Clear out the session.
 void removeAttribute(String attribName)
          Clears an attribute from the request context
 void removePersistentAttribute(String attribName)
          Clears an attribute from the session context
 void setAttribute(String attribName, Object attribValue)
          Sets an attribute that is valid for the duration of the request.
 void setClientAttribute(String attribName, String attribValue)
          Does nothing.
 void setPersistentAttribute(String attribName, Object attribValue)
          Saves an attribute to the actual session, rather than simply the response.
 void setPersistentAttributes(Map newAttributes)
          Sets the persistent attributes that may have been saved across instances of command line 'session'
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimplePersistentSession

public SimplePersistentSession()
Creates new SimplePersistentSession

Method Detail

setAttribute

public void setAttribute(String attribName,
                         Object attribValue)
Sets an attribute that is valid for the duration of the request.

Specified by:
setAttribute in interface PersistentSession
Parameters:
attribName - The name of the object you wish to set.
attribValue - the object you want to set.

getAttribute

public Object getAttribute(String attribName)
Retrieves the object from the request context.

Specified by:
getAttribute in interface PersistentSession
Parameters:
attribName - the name of the object to retrieve
Returns:
the object or null if it doesn't exist.

getAttributeNames

public Enumeration getAttributeNames()
Retrieves all attribute names in the request context.

Specified by:
getAttributeNames in interface PersistentSession
Returns:
java.util.Enumeration

setClientAttribute

public void setClientAttribute(String attribName,
                               String attribValue)
Does nothing. In a command line environment, cookies don't make sense.

Specified by:
setClientAttribute in interface PersistentSession
Parameters:
attribName - the name of the attribute to
attribValue - the value of the attribute to set.

getClientAttribute

public String getClientAttribute(String attribName)
Retrieves a value of a cookie set on the client's system. It also decrypts the value with the password you set up in your expresso-config.xml file.

Specified by:
getClientAttribute in interface PersistentSession
Parameters:
attribName - the name of the cookie to retrieve
Returns:
java.lang.String the value of the cookie or null if the cookie doesn't exist.

getPersistentAttributes

public Map getPersistentAttributes()
Retrieves the persistent attributes table. Useful if you wish to actually persisten these attributes across a command line 'session'

Returns:
java.util.HashMap
Since:
Expresso 5.1

setPersistentAttributes

public void setPersistentAttributes(Map newAttributes)
Sets the persistent attributes that may have been saved across instances of command line 'session'

Parameters:
newAttributes - Map of attributes to set for the session.

getPeristentAttributeNames

public Enumeration getPeristentAttributeNames()
Retrieves all attribute names from the session context.

Specified by:
getPeristentAttributeNames in interface PersistentSession
Returns:
java.util.Enumeration

setPersistentAttribute

public void setPersistentAttribute(String attribName,
                                   Object attribValue)
Saves an attribute to the actual session, rather than simply the response. Use this for storing objects between requests, but only use it with care since the extra memory used may bog down systems under high load.

Specified by:
setPersistentAttribute in interface PersistentSession
Parameters:
attribName - the name of the attribute to set
attribValue - a Serializable java object.
See Also:
Serializable

getPersistentAttribute

public Object getPersistentAttribute(String attribName)
Retrieves the object from the session context.

Specified by:
getPersistentAttribute in interface PersistentSession
Parameters:
attribName - the name of the object to retrieve
Returns:
the object or null if it doesn't exist.

invalidate

public void invalidate()
Clear out the session. Invalidates the entire session.

Specified by:
invalidate in interface PersistentSession

removeAttribute

public void removeAttribute(String attribName)
Clears an attribute from the request context

Specified by:
removeAttribute in interface PersistentSession
Parameters:
attribName - the name of the attribute to remove.

removePersistentAttribute

public void removePersistentAttribute(String attribName)
Clears an attribute from the session context

Specified by:
removePersistentAttribute in interface PersistentSession
Parameters:
attribName - the name of the attribute to remove.

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.