com.sibvisions.rad.server
Class DetachedSession

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

public class DetachedSession
extends Object
implements ISession

The DetachedSession is an ISession. It allows access to a specific application with all its properties but has no connection to the server or other server objects. It has no builtin support for the SessionContext. The DetachedSession is not bound to a DefaultSessionManager and does not fire session created or destroyed events. It is also not validated against the configured security manager.


Constructor Summary
DetachedSession(String pApplicationName)
          Creates a new instance of DetachedSession for a specific application.
 
Method Summary
 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 finalize()
          
 Object get(String pObjectName)
          Gets an object from the life-cycle object.
 long getAliveInterval()
          Gets the desired client-side communication interval for this session.
 String getApplicationName()
          Gets the associated application name of the session.
 IConfiguration getConfig()
          Gets the IConfiguration of the session.
 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.
 String getPassword()
          Gets the sessions password.
 Hashtable<String,Object> getProperties()
          Gets all properties.
 Object getProperty(String pName)
          Gets the value of a property.
 ISecurityManager getSecurityManager()
          Gets the security 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.
 boolean isInactive(long pAccessTime)
          Checks if the session is inactive.
 Object put(String pObjectName, Object pObject)
          Puts an object to the life-cycle object.
 void setAliveInterval(long pAliveInterval)
          Sets the desired client-side communication interval for this session.
 void setMaxInactiveInterval(int pMaxInactiveInterval)
          Specifies the time, in minutes, between access before the session will be inactive.
 void setPassword(String pPassword)
          Sets the password.
 void setProperty(String pName, Object pValue)
          Sets the value of a property.
 void setUserName(String pUserName)
          Sets the username.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DetachedSession

public DetachedSession(String pApplicationName)
                throws Exception
Creates a new instance of DetachedSession for a specific application.

Parameters:
pApplicationName - the application
Throws:
Exception - if session creation fails because of security manager validation or if the application is invalid/unknown
Method Detail

getId

public Object getId()
Gets the session identifier.

Specified by:
getId in interface ISession
Returns:
session id

getApplicationName

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

Specified by:
getApplicationName in interface ISession
Returns:
service name

getUserName

public String getUserName()
Gets the sessions user name.

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

getPassword

public String getPassword()
Gets the sessions password.

Specified by:
getPassword in interface ISession
Returns:
the password

put

public Object put(String pObjectName,
                  Object pObject)
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

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

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

getConfig

public IConfiguration getConfig()
Gets the IConfiguration of the session.

Specified by:
getConfig in interface ISession
Returns:
the sessions configuration

getLastAccessTime

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

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

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

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

getProperties

public Hashtable<String,Object> getProperties()
Gets all properties.

Specified by:
getProperties in interface ISession
Returns:
a Hashtable with property names and values

getProperty

public Object getProperty(String pName)
Gets the value of a property.

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

setProperty

public void setProperty(String pName,
                        Object pValue)
Sets the value of a property.

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

getStartTime

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

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

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)

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)

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)

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

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.

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

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

finalize

protected void finalize()
                 throws Throwable

Overrides:
finalize in class Object
Throws:
Throwable

setUserName

public void setUserName(String pUserName)
Sets the username.

Parameters:
pUserName - the user name

setPassword

public void setPassword(String pPassword)
Sets the password.

Parameters:
pPassword - the password

getSecurityManager

public ISecurityManager getSecurityManager()
                                    throws Exception
Gets the security manager for this session.

Returns:
the security manager
Throws:
Exception - if creation fails


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.