uk.org.ogsadai.sessions.impl
Class TransientSession

java.lang.Object
  |
  +--uk.org.ogsadai.sessions.impl.TransientSession
All Implemented Interfaces:
Session
Direct Known Subclasses:
TransientInternalSession

public abstract class TransientSession
extends java.lang.Object
implements Session

A thread-safe Session implementation that stores session attributes in memory.

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
           
private  java.util.Map mAttributes
           
 
Constructor Summary
TransientSession()
           
 
Method Summary
 void cleanUp()
          Internal method to remove all session attributes from the session.
 boolean containsAttribute(javax.xml.namespace.QName name)
          Indicates whether or not the session contains a session attribute with the specified name.
 int countAttributes()
          Returns the number of session attributes contained in the session.
private  void ensureChangeable(javax.xml.namespace.QName name)
          Ensures that the specified attribute is changable, and if not raises an exception.
 SessionAttribute getAttribute(javax.xml.namespace.QName name)
          Gets the session attribute for the given name or null if no such attribute exists.
 java.util.Set getAttributeNames()
          Returns a set of the names of the session attributes contained in the session.
 java.lang.Object getAttributeValue(javax.xml.namespace.QName name)
          Gets the actual value of the session attribute with the given name.
abstract  SessionID getID()
          Returns the SessionID object identifying the session.
 void removeAttribute(javax.xml.namespace.QName name)
          Removes a named session attribute from the session unless it is a static session attribute.
 void setAttribute(SessionAttribute property)
          Sets the specified session attribute, storing it in the session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uk.org.ogsadai.sessions.Session
addExternalInput, addExternalOutput, getExternalInput, getExternalOutput, getProperties, getRequestStatus, hasExternalInput, hasExternalOutput, removeExternalInput, removeExternalOutput
 

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
See Also:
Constant Field Values

mAttributes

private final java.util.Map mAttributes
Constructor Detail

TransientSession

public TransientSession()
Method Detail

getID

public abstract SessionID getID()
Description copied from interface: Session
Returns the SessionID object identifying the session.

Specified by:
getID in interface Session
Returns:
SessionID

containsAttribute

public boolean containsAttribute(javax.xml.namespace.QName name)
Description copied from interface: Session
Indicates whether or not the session contains a session attribute with the specified name.

Specified by:
containsAttribute in interface Session
Parameters:
name - The name of the session attribute as a QName.
Returns:
true if the session attribute exists, false otherwise.

countAttributes

public int countAttributes()
Description copied from interface: Session
Returns the number of session attributes contained in the session.

Specified by:
countAttributes in interface Session
Returns:
number of attributes.

getAttribute

public SessionAttribute getAttribute(javax.xml.namespace.QName name)
Description copied from interface: Session
Gets the session attribute for the given name or null if no such attribute exists.

Specified by:
getAttribute in interface Session
Parameters:
name - The name of the session attribute as a QName.
Returns:
name or null.

getAttributeNames

public java.util.Set getAttributeNames()
Description copied from interface: Session
Returns a set of the names of the session attributes contained in the session.

Specified by:
getAttributeNames in interface Session
Returns:
a set of QName objects.

getAttributeValue

public java.lang.Object getAttributeValue(javax.xml.namespace.QName name)
Description copied from interface: Session
Gets the actual value of the session attribute with the given name.

Session attributes encapsulate a name-value pair, so this method is provided as a convenient way to access the session attribute value directly. It is equivalent to getSessionAttribute().getValue().

Specified by:
getAttributeValue in interface Session
Parameters:
name - The name of the session attribute as a QName.
Returns:
the Object that is the session attribute value or null if the attribute does not exist (or the attribute value is actually null).

removeAttribute

public void removeAttribute(javax.xml.namespace.QName name)
                     throws StaticSessionAttrException
Description copied from interface: Session
Removes a named session attribute from the session unless it is a static session attribute.

Static session attributes are identified by the false return value of their isChangable method. If the named session attribute does not exist then no action is taken.

Specified by:
removeAttribute in interface Session
Parameters:
name - The QName of the session attribute to remove.
Throws:
StaticSessionAttrException - If name identifies a static session attribute.

setAttribute

public void setAttribute(SessionAttribute property)
                  throws StaticSessionAttrException
Description copied from interface: Session
Sets the specified session attribute, storing it in the session.

If an attribute with the same name already exists, then the existing attribute is overwritten, unless it is a static session attribute. Static session attributes cannot be overwritten.

Specified by:
setAttribute in interface Session
Parameters:
property - The SessionAttribute to store in the session.
Throws:
StaticSessionAttrException - If name identifies a static session attribute.

ensureChangeable

private void ensureChangeable(javax.xml.namespace.QName name)
                       throws StaticSessionAttrException
Ensures that the specified attribute is changable, and if not raises an exception.

Parameters:
name - Attribute name.
Throws:
StaticSessionAttrException - if the attribute is not changable.

cleanUp

public void cleanUp()
Internal method to remove all session attributes from the session.

Note that this includes the static session attributes and the session should not be used again afterwards.