com.sibvisions.rad.server
Class DirectServerSession

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

public class DirectServerSession
extends Object
implements ISession

The DirectServerSession is a wrapper for server-side sessions. It is fully attached and forwards every method call to the server-side session. To create a new instance of DirectServerSession use

DirectServerSession session = DirectServerSession.createMasterSession(...);

or

session.createSubSession(...);


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.
static DirectServerSession createMasterSession(String pApplicationName, String pUserName, String pPassword)
          Creates a new instance of DirectServerSession for the given application and credentials.
 DirectServerSession createSubSession(String pLifeCycleName)
          Creates a new instance of DirectServerSession as sub session for the given life-cycle object name.
 void destroy()
          Closes the session.
 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.
 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 setProperty(String pName, Object pValue)
          Sets the value of a property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

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

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

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

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

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

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

getProperties

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

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

getStartTime

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

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

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

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

destroy

public void destroy()
Closes the session.


createMasterSession

public static DirectServerSession createMasterSession(String pApplicationName,
                                                      String pUserName,
                                                      String pPassword)
                                               throws Throwable
Creates a new instance of DirectServerSession for the given application and credentials.

Parameters:
pApplicationName - the name of the application
pUserName - the user name
pPassword - the password
Returns:
the newly created session
Throws:
Throwable - if session creation fails

createSubSession

public DirectServerSession createSubSession(String pLifeCycleName)
                                     throws Throwable
Creates a new instance of DirectServerSession as sub session for the given life-cycle object name.

Parameters:
pLifeCycleName - the full qualified class name of the life-cycle object
Returns:
the newly created session
Throws:
Throwable - if session creation fails


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.