uk.org.ogsadai.sessions.impl
Class SafeSession

java.lang.Object
  |
  +--uk.org.ogsadai.sessions.impl.SafeSession
All Implemented Interfaces:
Session

public class SafeSession
extends java.lang.Object
implements Session

Adapts the InternalSession interface to the Session interface. This protects the management operations defined in the InternalSession interface.

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
           
private  InternalSession mSession
           
 
Constructor Summary
SafeSession(InternalSession session)
          Constructs a safe session wrapping the specified internal session.
 
Method Summary
 void addExternalInput(java.lang.String name, Pipe input)
          Adds an external input session stream.
 void addExternalOutput(java.lang.String name, Pipe output)
          Adds an external output session stream.
 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.
 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.
 Pipe getExternalInput(java.lang.String name)
          Gets the Pipe for the external input with the specified name allowing data to be written into the pipe or read from it.
 Pipe getExternalOutput(java.lang.String name)
          Gets the Pipe for the external output with the specified name allowing data to be written to it of read from it.
 SessionID getID()
          Returns the SessionID object identifying the session.
 Properties getProperties()
          Gets the set of data service resource properties that are available to this session.
 ProcessingStatus getRequestStatus()
          Gets the session request processing status.
 boolean hasExternalInput(java.lang.String name)
          Checks whether the context contains a Pipe for an external input with the specified name.
 boolean hasExternalOutput(java.lang.String name)
          Checks whether the context contains a Pipe for an external output with the specified name.
 void removeAttribute(javax.xml.namespace.QName name)
          Removes a named session attribute from the session unless it is a static session attribute.
 void removeExternalInput(java.lang.String name)
          Removes an external input session stream.
 void removeExternalOutput(java.lang.String name)
          Removes an external output session stream.
 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
 

Field Detail

COPYRIGHT_NOTICE

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

mSession

private final InternalSession mSession
Constructor Detail

SafeSession

public SafeSession(InternalSession session)
Constructs a safe session wrapping the specified internal session.

Parameters:
session - The InternalSession to wrap.
Throws:
java.lang.IllegalArgumentException - if session is null.
Method Detail

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).

getID

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

Specified by:
getID in interface Session
Returns:
SessionID

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.

getProperties

public Properties getProperties()
Description copied from interface: Session
Gets the set of data service resource properties that are available to this session.

Session participants, such as activities, may query, add and remove properties from this at runtime.

Specified by:
getProperties in interface Session
Returns:
a Properties object

getRequestStatus

public ProcessingStatus getRequestStatus()
Description copied from interface: Session
Gets the session request processing status.

This is the status of the current request that is processing in the session.

Specified by:
getRequestStatus in interface Session
Returns:
the observable ProcessingStatus.

hasExternalInput

public boolean hasExternalInput(java.lang.String name)
Description copied from interface: Session
Checks whether the context contains a Pipe for an external input with the specified name.

Specified by:
hasExternalInput in interface Session
Parameters:
name - The name of the external input.
Returns:
true if the input exists, false otherwise.

hasExternalOutput

public boolean hasExternalOutput(java.lang.String name)
Description copied from interface: Session
Checks whether the context contains a Pipe for an external output with the specified name.

Specified by:
hasExternalOutput in interface Session
Parameters:
name - The name of the external output.
Returns:
true if the output exists, false otherwise.

getExternalOutput

public Pipe getExternalOutput(java.lang.String name)
Description copied from interface: Session
Gets the Pipe for the external output with the specified name allowing data to be written to it of read from it.

Specified by:
getExternalOutput in interface Session
Parameters:
name - The name of the external output.
Returns:
A Pipe from which data can be read or null if there is no output with the specified name.

getExternalInput

public Pipe getExternalInput(java.lang.String name)
Description copied from interface: Session
Gets the Pipe for the external input with the specified name allowing data to be written into the pipe or read from it.

Specified by:
getExternalInput in interface Session
Parameters:
name - The name of the external input.
Returns:
A Pipe to which data can be written or null if there is no input with the specified name.

addExternalInput

public void addExternalInput(java.lang.String name,
                             Pipe input)
                      throws SessionStreamDuplicateException
Description copied from interface: Session
Adds an external input session stream.

This is a Pipe that can receive input data from an external agent and be read from by an activity or session participant.

Specified by:
addExternalInput in interface Session
Parameters:
name - The name of the session stream.
input - The pipe for the data.
Throws:
SessionStreamDuplicateException - if an external input session stream with the same name has already been added to the session.

addExternalOutput

public void addExternalOutput(java.lang.String name,
                              Pipe output)
                       throws SessionStreamDuplicateException
Description copied from interface: Session
Adds an external output session stream.

This is a Pipe that can receive input data from an activity or session participant. This data can then be read by an external agent.

Specified by:
addExternalOutput in interface Session
Parameters:
name - The name of the session stream.
output - The pipe for the data.
Throws:
SessionStreamDuplicateException - if an external output session stream with the same name has already been added to the session.

removeExternalInput

public void removeExternalInput(java.lang.String name)
Description copied from interface: Session
Removes an external input session stream.

After this method has returned the session stream will no longer be available to external agents.

Specified by:
removeExternalInput in interface Session
Parameters:
name - The name of the session stream. If no stream exists with this name then no action is taken.

removeExternalOutput

public void removeExternalOutput(java.lang.String name)
Description copied from interface: Session
Removes an external output session stream.

After this method has returned the session stream will no longer be available to external agents.

Specified by:
removeExternalOutput in interface Session
Parameters:
name - The name of the session stream. If no stream exists with this name then no action is taken.