com.sibvisions.rad.server
Class DefaultSessionManager

java.lang.Object
  extended by javax.rad.server.AbstractSessionManager
      extended by com.sibvisions.rad.server.DefaultSessionManager
All Implemented Interfaces:
IPushHandler

public class DefaultSessionManager
extends AbstractSessionManager
implements IPushHandler

The DefaultSessionManager handles the access to all sessions created through client connections.


Constructor Summary
protected DefaultSessionManager(Server pServer)
          Creates an instance of DefaultSessionManager for a special communication server.
 
Method Summary
 void addSessionListener(ISessionListener pListener)
          Adds an ISessionListener session listener to the list of known listeners.
protected  ISecurityManager createSecurityManager(java.lang.ClassLoader pLoader, ISession pSession)
          Creates a new security manager instance for the given session and class loader.
protected  ISecurityManager createSecurityManager(ISession pSession)
          Creates a new security manager instance for the given session.
 java.lang.Object createSession(IRequest pRequest, ISerializer pSerializer, ChangedHashtable<java.lang.String,java.lang.Object> pProperties)
          Creates an authenticated session for an application.
 java.lang.Object createSubSession(IRequest pRequest, AbstractSession pSession, ChangedHashtable<java.lang.String,java.lang.Object> pProperties)
          Creates a new SubSession for an already authenticated main session.
 void destroy(java.lang.Object pSessionOrId)
          Destroyes a session and dependent sub sessions.
 AbstractSession get(java.lang.Object pSessionId)
          Gets an existing session.
static long getControllerInterval()
          Gets the "validate session" controlleer check interval.
 ISessionListener[] getSessionListeners()
          Gets the list of known listeners.
 boolean isAvailable(java.lang.Object pSessionOrId)
          Gets whether a session is known from this session manager.
 boolean isInitializing(ISession pSession)
          Gets whether the given session is initializing.
 boolean isValid(java.lang.Object pSessionOrId)
          Gets whether a session is valid.
protected  void postCreateSession(ISession pSession)
          Configures a session after it is created.
protected  void postCreateSubSession(ISession pMaster, ISession pSession)
          Configures a sub session after it is created.
 void push(PushMessage pMessage)
          Pushes a message to the registered receiver.
 void registerPushReceiver(java.lang.Object pConnectionId, IPushReceiver pReceiver)
          Registers a push receiver.
protected  void releaseSecurityManager(ISecurityManager pManager)
          Releases the given security manager and catch all exceptions.
 void removeSessionListener(ISessionListener pListener)
          Removes an ISessionListener from the list of known listeners.
protected  void sessionCreationError(java.lang.Throwable pCause)
          Handles a session creation error.
static void setControllerInterval(long pMilliSeconds)
          Sets the "validate session" controller check interval.
protected  void subSessionCreationError(java.lang.Throwable pCause)
          Handles a sub session creation error.
 void unregisterPushReceiver(java.lang.Object pConnectionId)
          Unregisters a push receiver.
 
Methods inherited from class javax.rad.server.AbstractSessionManager
getServer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSessionManager

protected DefaultSessionManager(Server pServer)
Creates an instance of DefaultSessionManager for a special communication server.

Parameters:
pServer - communication server
Method Detail

get

public final AbstractSession get(java.lang.Object pSessionId)
Gets an existing session.

Specified by:
get in class AbstractSessionManager
Parameters:
pSessionId - session identifier
Returns:
session object, guaranteed not null

addSessionListener

public final void addSessionListener(ISessionListener pListener)
Adds an ISessionListener session listener to the list of known listeners.

Specified by:
addSessionListener in class AbstractSessionManager
Parameters:
pListener - te session listener to add

removeSessionListener

public final void removeSessionListener(ISessionListener pListener)
Removes an ISessionListener from the list of known listeners.

Specified by:
removeSessionListener in class AbstractSessionManager
Parameters:
pListener - the session listener to remove

getSessionListeners

public final ISessionListener[] getSessionListeners()
Gets the list of known listeners.

Specified by:
getSessionListeners in class AbstractSessionManager
Returns:
a list of ISessionListener or an empty list

isAvailable

public boolean isAvailable(java.lang.Object pSessionOrId)
Gets whether a session is known from this session manager. This means whether the session is in the list of currently opened sessions.

Specified by:
isAvailable in class AbstractSessionManager
Parameters:
pSessionOrId - session identifier or session instance
Returns:
true if the session is available, false otherwise

registerPushReceiver

public void registerPushReceiver(java.lang.Object pConnectionId,
                                 IPushReceiver pReceiver)
Registers a push receiver.

Specified by:
registerPushReceiver in interface IPushHandler
Parameters:
pConnectionId - the connection identifier
pReceiver - the receiver

unregisterPushReceiver

public void unregisterPushReceiver(java.lang.Object pConnectionId)
Unregisters a push receiver.

Specified by:
unregisterPushReceiver in interface IPushHandler
Parameters:
pConnectionId - the connection identifier

push

public void push(PushMessage pMessage)
Pushes a message to the registered receiver.

Specified by:
push in interface IPushHandler
Parameters:
pMessage - the message

createSession

public final java.lang.Object createSession(IRequest pRequest,
                                            ISerializer pSerializer,
                                            ChangedHashtable<java.lang.String,java.lang.Object> pProperties)
                                     throws java.lang.Throwable
Creates an authenticated session for an application.

Parameters:
pRequest - the request which creates the session
pSerializer - the serializer for the session
pProperties - the initial session properties
Returns:
session identifier of newly created Session
Throws:
java.lang.Throwable - if the security manager detects a problem or the session properties can not be set

createSubSession

public final java.lang.Object createSubSession(IRequest pRequest,
                                               AbstractSession pSession,
                                               ChangedHashtable<java.lang.String,java.lang.Object> pProperties)
                                        throws java.lang.Throwable
Creates a new SubSession for an already authenticated main session. This method doesn't check if the session is valid.

Parameters:
pRequest - the request which creates the sub session
pSession - a valid session
pProperties - the initial session properties
Returns:
the new SubSession
Throws:
java.lang.Throwable - the session properties can not be set

destroy

public final void destroy(java.lang.Object pSessionOrId)
Destroyes a session and dependent sub sessions.

Parameters:
pSessionOrId - session identifier or session instance
Throws:
java.lang.SecurityException - if the session identifier is unknown

createSecurityManager

protected ISecurityManager createSecurityManager(ISession pSession)
                                          throws java.lang.Exception
Creates a new security manager instance for the given session.

Parameters:
pSession - the session which needs a security manager
Returns:
the security manager
Throws:
java.lang.Exception - if the class or default constructor was not found

createSecurityManager

protected ISecurityManager createSecurityManager(java.lang.ClassLoader pLoader,
                                                 ISession pSession)
                                          throws java.lang.Exception
Creates a new security manager instance for the given session and class loader.

Parameters:
pLoader - the class loader to load the security manager
pSession - the session which needs a security manager
Returns:
the security manager
Throws:
java.lang.Exception - if the class or default constructor was not found

releaseSecurityManager

protected void releaseSecurityManager(ISecurityManager pManager)
Releases the given security manager and catch all exceptions.

Parameters:
pManager - the security manager to release

postCreateSession

protected void postCreateSession(ISession pSession)
Configures a session after it is created.

Parameters:
pSession - the session

postCreateSubSession

protected void postCreateSubSession(ISession pMaster,
                                    ISession pSession)
Configures a sub session after it is created.

Parameters:
pMaster - the master session
pSession - the session

sessionCreationError

protected void sessionCreationError(java.lang.Throwable pCause)
Handles a session creation error.

Parameters:
pCause - the cause
See Also:
createSession(IRequest, ISerializer, ChangedHashtable)

subSessionCreationError

protected void subSessionCreationError(java.lang.Throwable pCause)
Handles a sub session creation error.

Parameters:
pCause - the cause
See Also:
createSubSession(IRequest, AbstractSession, ChangedHashtable)

isInitializing

public boolean isInitializing(ISession pSession)
Gets whether the given session is initializing.

Parameters:
pSession - the session
Returns:
whether the session is initializing

isValid

public boolean isValid(java.lang.Object pSessionOrId)
Gets whether a session is valid. This means that the session is in the list of currently opened sessions and is alive and not invalid.

Parameters:
pSessionOrId - session identifier or session instance
Returns:
true if the session is valid, false otherwise

setControllerInterval

public static void setControllerInterval(long pMilliSeconds)
Sets the "validate session" controller check interval.

Parameters:
pMilliSeconds - the milliseconds between two checks. If the value is <= 0, the default value will be used.

getControllerInterval

public static long getControllerInterval()
Gets the "validate session" controlleer check interval.

Returns:
the milliseconds between two checks


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.