uk.org.ogsadai.sessions.impl
Class TransientInternalSession

java.lang.Object
  |
  +--uk.org.ogsadai.sessions.impl.TransientSession
        |
        +--uk.org.ogsadai.sessions.impl.TransientInternalSession
All Implemented Interfaces:
InternalSession, Session

public class TransientInternalSession
extends TransientSession
implements InternalSession

A thread-safe InternalSession implementation that allows only one SessionParticipant to join at a time.

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
           
private static DAILogger LOG
           
private  SessionEventDispatcher mDispatcher
           
private  java.util.Map mExternalInputs
           
private  java.util.Map mExternalOutputs
           
private  SessionParticipant mParticipant
           
private  Properties mProperties
           
private  SessionSettings mSettings
           
private  ProcessingStatus mStatus
           
 
Fields inherited from class uk.org.ogsadai.sessions.impl.TransientSession
 
Constructor Summary
TransientInternalSession(SessionSettings settings, java.util.Set attributes, Properties properties)
          Creates a new TransientInternalSession.
 
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.
 void addSessionListener(SessionListener listener)
          Registers a session listener with the session.
 void admit(SessionParticipant participant)
          Admits a new session participant to the session.
 void cleanUp()
          Cleans up the session before it is made eligible for garbage collection.
 int countParticants()
          Returns the number of session participants that are currently joined to the session.
 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.
 SessionSettings getSettings()
          Returns a SessionSettings object encapsulating the settings for this session.
 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 release(SessionParticipant participant)
          Releases the specified session participant from the session.
 void removeExternalInput(java.lang.String name)
          Removes an external input session stream.
 void removeExternalOutput(java.lang.String name)
          Removes an external output session stream.
 java.lang.String toString()
           
 
Methods inherited from class uk.org.ogsadai.sessions.impl.TransientSession
containsAttribute, countAttributes, getAttribute, getAttributeNames, getAttributeValue, removeAttribute, setAttribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface uk.org.ogsadai.sessions.Session
containsAttribute, countAttributes, getAttribute, getAttributeNames, getAttributeValue, removeAttribute, setAttribute
 

Field Detail

COPYRIGHT_NOTICE

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

LOG

private static final DAILogger LOG

mDispatcher

private final SessionEventDispatcher mDispatcher

mParticipant

private SessionParticipant mParticipant

mSettings

private final SessionSettings mSettings

mProperties

private final Properties mProperties

mStatus

private final ProcessingStatus mStatus

mExternalOutputs

private final java.util.Map mExternalOutputs

mExternalInputs

private final java.util.Map mExternalInputs
Constructor Detail

TransientInternalSession

public TransientInternalSession(SessionSettings settings,
                                java.util.Set attributes,
                                Properties properties)
                         throws SessionCreationException
Creates a new TransientInternalSession.

Parameters:
settings - The configuration settings for the session
attributes - The initial set of static session attributes for the session to contain, or null if there are none.
properties - Data service resource properties. Session participants may may access and update these.
Throws:
java.lang.IllegalArgumentException - if settings or properties are null.
SessionCreationException - if attributes contains duplicate names.
Method Detail

addSessionListener

public void addSessionListener(SessionListener listener)
Description copied from interface: InternalSession
Registers a session listener with the session. The listener will be notified each time a session event occurs.

Specified by:
addSessionListener in interface InternalSession
Parameters:
listener - The SessionListener to register.

admit

public void admit(SessionParticipant participant)
           throws SessionJoinDeniedException,
                  SessionJoinException
Description copied from interface: InternalSession
Admits a new session participant to the session.

After this method has been invoked, the session participant is said to have joined the session.

Specified by:
admit in interface InternalSession
Parameters:
participant - The SessionParticipant to join.
Throws:
SessionJoinException - if there is an internal problem that occurs during the join.
SessionJoinDeniedException - if there is an application-specific reason why the participant is not allowed to join.

cleanUp

public void cleanUp()
Description copied from interface: InternalSession
Cleans up the session before it is made eligible for garbage collection.

Specified by:
cleanUp in interface InternalSession
Overrides:
cleanUp in class TransientSession

countParticants

public int countParticants()
Description copied from interface: InternalSession
Returns the number of session participants that are currently joined to the session.

Specified by:
countParticants in interface InternalSession
Returns:
number of participants.

getID

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

Specified by:
getID in interface Session
Specified by:
getID in class TransientSession
Returns:
SessionID

getSettings

public SessionSettings getSettings()
Description copied from interface: InternalSession
Returns a SessionSettings object encapsulating the settings for this session.

Specified by:
getSettings in interface InternalSession
Returns:
settings.

release

public void release(SessionParticipant participant)
Description copied from interface: InternalSession
Releases the specified session participant from the session.

After this method has been invoked, the session participant is said to have left the session. It must be responsible for no further interactions with the session. If the specified session participant is not currently a participant of this session then nothing happens.

Specified by:
release in interface InternalSession
Parameters:
participant - The SessionParticipant to release.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

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.

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.

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.

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.