com.sibvisions.rad.server
Class AbstractSession

java.lang.Object
  extended by com.sibvisions.rad.server.AbstractSession
All Implemented Interfaces:
ISession

public abstract class AbstractSession
extends Object
implements ISession

A Session is a server side session which will be started when an IConnection connects to a remote server.
The session persists for a specified time period, across more than one request from the IConnection.

See Also:
ISession

Field Summary
protected  ChangedHashtable<String,Object> chtExternalProperties
          the properties got via constructor.
protected  ChangedHashtable<String,Object> chtProperties
          the client and server properties.
protected  ILogger log
          the log instance.
 
Method Summary
protected  void addCallBackResult(ResultObject pResult)
          Adds the result of an asynchronous call to the cache.
 Object call(String pObjectName, String pMethod, Object... pParams)
          Executes a method from an object in the life-cycle object.
 Object callAction(String pAction, Object... pParams)
          Executes an action from the life-cycle object.
protected  void checkAccess()
          Checks if it is allowed to create the session.
protected  Object executeWithSessionContext(SessionContext pContext, com.sibvisions.rad.server.Call pCall)
          Executes a remote method call.
 Object get(String pObjectName)
          Gets an object from the life-cycle object.
abstract  IAccessController getAccessController()
          Gets the IAccessController for checking the access to server side objects and calls.
 long getAliveInterval()
          Gets the desired client-side communication interval for this session.
 String getApplicationName()
          Gets the associated application name of the session.
protected abstract  ApplicationZone getApplicationZone()
          Gets the application zone for which the session was created.
 Object getId()
          Gets the session identifier.
 long getLastAccessTime()
          Gets the time of the last session access.
 long getLastAliveTime()
          Gets the time of the last communication of the session.
 String getLifeCycleName()
          Gets the name of the life-cycle object.
 int getMaxInactiveInterval()
          Returns the maximum time interval, in minutes, that this session will be active.
 InjectObject getObject(String pName)
          Gets an object from the cache.
 String getPassword()
          Gets the sessions password.
 ChangedHashtable<String,Object> getProperties()
          Gets a reference to the internal properties.
 Object getProperty(String pName)
          Gets the value of a property.
protected  DefaultSessionManager getSessionManager()
          Gets the session manager for this session.
 long getStartTime()
          Gets the session start/create time.
 String getUserName()
          Gets the sessions user name.
 boolean isAlive(long pAccessTime)
          Checks if the session is alive.
protected  boolean isExecuting()
          Returns whether the session is execution at least one command.
 boolean isInactive(long pAccessTime)
          Checks if the session is inactive.
 Object put(String pObjectName, Object pObject)
          Puts an object to the life-cycle object.
 InjectObject putObject(InjectObject pObject)
          Puts an object to the cache.
 InjectObject removeObject(InjectObject pObject)
          Removes an object from the cache.
 void setAliveInterval(long pAliveInterval)
          Sets the desired client-side communication interval for this session.
protected  void setExecuting(boolean pExecuting)
          Sets that the session is executiong a command.
 void setLastAccessTime(long pLastAccessTime)
          Sets the time of the last session access.
 void setLastAliveTime(long pLastAliveTime)
          Sets the time of the last communication of the session.
 void setMaxInactiveInterval(int pMaxInactiveInterval)
          Specifies the time, in minutes, between access before the session will be inactive.
 void setPassword(String pPassword)
          Sets the session password.
 void setProperty(String pName, Object pValue)
          Sets a property.
protected  void setPropertyIntern(String pName, Object pValue)
          Sets internal members with property values.
 void setUserName(String pUserName)
          Sets the sessions user name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.rad.server.ISession
getConfig
 

Field Detail

log

protected ILogger log
the log instance.


chtProperties

protected ChangedHashtable<String,Object> chtProperties
the client and server properties.


chtExternalProperties

protected ChangedHashtable<String,Object> chtExternalProperties
the properties got via constructor.

Method Detail

getApplicationZone

protected abstract ApplicationZone getApplicationZone()
Gets the application zone for which the session was created.

Returns:
the application zone

getAccessController

public abstract IAccessController getAccessController()
Gets the IAccessController for checking the access to server side objects and calls.

Returns:
the object inspector or null if no inspector is available

getId

public Object getId()
Gets the session identifier.

Specified by:
getId in interface ISession
Returns:
session id

getLifeCycleName

public String getLifeCycleName()
Gets the name of the life-cycle object.

Specified by:
getLifeCycleName in interface ISession
Returns:
the name of the life-cycle object

getApplicationName

public final String getApplicationName()
Gets the associated application name of the session.

Specified by:
getApplicationName in interface ISession
Returns:
service name

getUserName

public final String getUserName()
Gets the sessions user name.

Specified by:
getUserName in interface ISession
Returns:
the user name

getPassword

public final String getPassword()
Gets the sessions password.

Specified by:
getPassword in interface ISession
Returns:
the password

getProperty

public Object getProperty(String pName)
Gets the value of a property. The access time will be updated.

Specified by:
getProperty in interface ISession
Parameters:
pName - the property name
Returns:
the value of the property or null if the property is not available

getStartTime

public long getStartTime()
Gets the session start/create time.

Specified by:
getStartTime in interface ISession
Returns:
start time in millis

getLastAccessTime

public long getLastAccessTime()
Gets the time of the last session access.

Specified by:
getLastAccessTime in interface ISession
Returns:
access time in millis

setMaxInactiveInterval

public void setMaxInactiveInterval(int pMaxInactiveInterval)
Specifies the time, in minutes, between access before the session will be inactive. A zero or negative time indicates the session should never be inactive.

Specified by:
setMaxInactiveInterval in interface ISession
Parameters:
pMaxInactiveInterval - time in minutes

getMaxInactiveInterval

public int getMaxInactiveInterval()
Returns the maximum time interval, in minutes, that this session will be active. After this interval, the session is inactive. The maximum time interval can be set with the setMaxInactiveInterval method. A zero or negative time indicates the session should never be inactive.

Specified by:
getMaxInactiveInterval in interface ISession
Returns:
time in minutes
See Also:
ISession.setMaxInactiveInterval(int)

isInactive

public boolean isInactive(long pAccessTime)
Checks if the session is inactive.

Specified by:
isInactive in interface ISession
Parameters:
pAccessTime - current access time
Returns:
true if the session is inactive
See Also:
ISession.getMaxInactiveInterval(), ISession.getLastAccessTime()

getLastAliveTime

public long getLastAliveTime()
Gets the time of the last communication of the session.

Specified by:
getLastAliveTime in interface ISession
Returns:
the last communication/alive time

setAliveInterval

public void setAliveInterval(long pAliveInterval)
Sets the desired client-side communication interval for this session.

Specified by:
setAliveInterval in interface ISession
Parameters:
pAliveInterval - the alive interval (client-side)

getAliveInterval

public long getAliveInterval()
Gets the desired client-side communication interval for this session.

Specified by:
getAliveInterval in interface ISession
Returns:
the alive interval (client-side)

isAlive

public boolean isAlive(long pAccessTime)
Checks if the session is alive. That means the client sends alive messages. The session is not alive if the client doesn't send alive messages during 4 times of the desired alive interval.

Specified by:
isAlive in interface ISession
Parameters:
pAccessTime - current access time
Returns:
true if the session is alive
See Also:
ISession.getLastAliveTime(), ISession.getAliveInterval()

call

public Object call(String pObjectName,
                   String pMethod,
                   Object... pParams)
            throws Throwable
Executes a method from an object in the life-cycle object.

Specified by:
call in interface ISession
Parameters:
pObjectName - list of already mapped server object name/alias
pMethod - method name which should be called
pParams - parameters for the method call
Returns:
result of method call or null if it's an asynchronous method call
Throws:
Throwable - if the object identified by pObjectName was found but can not be created
SecurityException - if the method call is not allowed

callAction

public Object callAction(String pAction,
                         Object... pParams)
                  throws Throwable
Executes an action from the life-cycle object.

Specified by:
callAction in interface ISession
Parameters:
pAction - action which should be called
pParams - the parameters for the action call
Returns:
result from the action call
Throws:
Throwable - communication error, security checks, invalid action, ...

get

public Object get(String pObjectName)
           throws Throwable
Gets an object from the life-cycle object.

Specified by:
get in interface ISession
Parameters:
pObjectName - the object name
Returns:
the object
Throws:
Throwable - if the object was not found or an error occured during object creation

put

public Object put(String pObjectName,
                  Object pObject)
           throws Throwable
Puts an object to the life-cycle object.

Specified by:
put in interface ISession
Parameters:
pObjectName - the object name
pObject - the object
Returns:
the object if an object was already specified
Throws:
Throwable - if an unknown error occurs while putting the object

setUserName

public final void setUserName(String pUserName)
Sets the sessions user name.

Parameters:
pUserName - the user name

setPassword

public final void setPassword(String pPassword)
Sets the session password.

Parameters:
pPassword - the password

setLastAccessTime

public void setLastAccessTime(long pLastAccessTime)
Sets the time of the last session access.

Parameters:
pLastAccessTime - access time in millis

setLastAliveTime

public void setLastAliveTime(long pLastAliveTime)
Sets the time of the last communication of the session.

Parameters:
pLastAliveTime - the last communication/alive time

executeWithSessionContext

protected Object executeWithSessionContext(SessionContext pContext,
                                           com.sibvisions.rad.server.Call pCall)
                                    throws Throwable
Executes a remote method call. This method can be overwritten from sub classes.

Parameters:
pContext - the current session context
pCall - the call information
Returns:
result of method call or null if it's an asynchronous method call
Throws:
Throwable - if an exception occurs during call
SecurityException - if the call is not allowed

addCallBackResult

protected void addCallBackResult(ResultObject pResult)
Adds the result of an asynchronous call to the cache.

Parameters:
pResult - the result of an asynchronous call

setProperty

public void setProperty(String pName,
                        Object pValue)
Sets a property. The access time will be updated.

Specified by:
setProperty in interface ISession
Parameters:
pName - the property name
pValue - the value of the property or null to delete the property

setPropertyIntern

protected final void setPropertyIntern(String pName,
                                       Object pValue)
Sets internal members with property values. The alive time will be updated.

Parameters:
pName - the property name
pValue - the property value

getProperties

public ChangedHashtable<String,Object> getProperties()
Gets a reference to the internal properties.

Specified by:
getProperties in interface ISession
Returns:
the session properties

getSessionManager

protected DefaultSessionManager getSessionManager()
Gets the session manager for this session.

Returns:
the session manager

putObject

public InjectObject putObject(InjectObject pObject)
Puts an object to the cache. If an object with the same name is already added, it will be replaced.

Parameters:
pObject - the object to inject
Returns:
the previous object or null if there was no object with the same object name added

removeObject

public InjectObject removeObject(InjectObject pObject)
Removes an object from the cache.

Parameters:
pObject - the object to remove
Returns:
the removed object or null if an object with the same object name was not found

getObject

public InjectObject getObject(String pName)
Gets an object from the cache.

Parameters:
pName - the name of the object
Returns:
the object or null if an object with the given name was not found

isExecuting

protected boolean isExecuting()
Returns whether the session is execution at least one command.

Returns:
true if the session is executing a command, otherwise false

setExecuting

protected void setExecuting(boolean pExecuting)
Sets that the session is executiong a command. The method considers that sub exections will be made. It changes a counter per method call.

Parameters:
pExecuting - true to increase the execution counter; false to decrease the execution counter

checkAccess

protected void checkAccess()
Checks if it is allowed to create the session.



Copyright © 2009 SIB Visions GmbH. All Rights Reserved.