CADI.Server.Session
Class Session

java.lang.Object
  extended by CADI.Server.Session.Session

public class Session
extends java.lang.Object

This class is uses to save information about a client sessions.

For further information about JPIP sessions, see ISO/IEC 15444-9 section B.2

Version:
1.0 2007/10/26
Author:
Group on Interactive Coding of Images (GICI)

Field Summary
 long DEFAULT_EXPIRATION_TIME
          The default expiration time.
private  long expirationTime
          Expiration time of the session.
private  Mutex mutex
          Is a mutex to lock the object when a thread is setting some attribute.
private  int returnType
          Definition in ServerControlField.type
private  java.util.ArrayList<SessionTarget> targets
          A list of logical targets that belongs to this session.
 
Constructor Summary
Session()
          Constructor.
 
Method Summary
 void closeChannel(java.lang.String cid)
          Closes a channel.
 boolean contains(java.lang.String cid)
          Checks if the channel cid belongs to this session.
 java.lang.String createSession(int returnType, java.lang.String transport)
          Creates a new session.
 ServerCache getCache(java.lang.String cid)
          Returns the cache which is associated with the channel.
 int getReturnType()
          Returns the returnType attribute.
 java.lang.String getTid(java.lang.String cid)
          See SessionTarget.getTid().
private  int indexOf(java.lang.String cid)
          Returns the index of the session which the channel cid belongs to.
 boolean isExpired()
          Checks whether the session has expired or it has not.
 void list(java.io.PrintStream out)
          Prints this Session out to the specified output stream.
 void remove()
          Removes the session.
 void setCache(java.lang.String cid, ServerCache cache)
           
 void setTid(java.lang.String cid, java.lang.String tid)
          See SessionTarget.setTid(String).
 java.lang.String toString()
           
private  void updateExpirationTime()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mutex

private Mutex mutex
Is a mutex to lock the object when a thread is setting some attribute.


returnType

private int returnType
Definition in ServerControlField.type


targets

private java.util.ArrayList<SessionTarget> targets
A list of logical targets that belongs to this session.


expirationTime

private long expirationTime
Expiration time of the session. When this expiration time is reached, the session will be removed.


DEFAULT_EXPIRATION_TIME

public final long DEFAULT_EXPIRATION_TIME
The default expiration time.

See Also:
Constant Field Values
Constructor Detail

Session

public Session()
Constructor.

Method Detail

createSession

public java.lang.String createSession(int returnType,
                                      java.lang.String transport)
Creates a new session.

Parameters:
returnType -
transport -
Returns:
the session identifier

contains

public boolean contains(java.lang.String cid)
Checks if the channel cid belongs to this session.

Parameters:
cid - the unique channel identifier.
Returns:
true if the channel belongs to this session. Otherwise, returns false.

closeChannel

public void closeChannel(java.lang.String cid)
Closes a channel. If there is no more left channels, the session target will be removed.

Parameters:
cid - the unique channel identifier.

remove

public void remove()
Removes the session.


getReturnType

public int getReturnType()
Returns the returnType attribute.

Returns:
the returnType attribute.

setTid

public void setTid(java.lang.String cid,
                   java.lang.String tid)
See SessionTarget.setTid(String).

Parameters:
cid - the channel identifier.
tid - the target identifier.

getTid

public java.lang.String getTid(java.lang.String cid)
See SessionTarget.getTid().

Parameters:
cid - the channel identifier.

setCache

public void setCache(java.lang.String cid,
                     ServerCache cache)
Parameters:
cid -
cache -

getCache

public ServerCache getCache(java.lang.String cid)
Returns the cache which is associated with the channel.

Parameters:
cid -
Returns:
return cache object.

isExpired

public boolean isExpired()
Checks whether the session has expired or it has not.

Returns:
true if the session has expired. Otherwise, returns false.

toString

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

list

public void list(java.io.PrintStream out)
Prints this Session out to the specified output stream. This method is useful for debugging.

Parameters:
out - an output stream.

indexOf

private int indexOf(java.lang.String cid)
Returns the index of the session which the channel cid belongs to. If the channel is not in the sessions, returns -1 .

Parameters:
cid - the channel identifier.
Returns:
the index of the session in the targets, or -1 if the channel is not the list.

updateExpirationTime

private void updateExpirationTime()


CADI - Copyright (C) 2007
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Group on Interactive Coding of Images (GICI) (contact)