com.sibvisions.rad.server
Class Server

java.lang.Object
  extended by com.sibvisions.rad.server.Server
All Implemented Interfaces:
IDirectServer, IServer, IPushHandler

public class Server
extends java.lang.Object
implements IDirectServer

The Server is the general remote server implementation. It's independent of the communication protocol and handles client requests. The configuration of the server will be made in the

server.xml
file. It contains the database connect information.


Constructor Summary
Server()
          Creates a new instance of Server.
 
Method Summary
 void afterLastCall(java.lang.Object pSessionId, boolean pCallError)
          Notifies the server that all calls were executed.
 void beforeFirstCall(java.lang.Object pSessionId)
          Notifies the server that at least one call will follow.
 java.lang.Object createSession(ChangedHashtable<java.lang.String,java.lang.Object> pProperties)
          Creates a new session for an application.
 java.lang.Object createSubSession(java.lang.Object pSessionId, ChangedHashtable<java.lang.String,java.lang.Object> pProperties)
          Creates a sub session of an application.
 void destroySession(java.lang.Object pSessionId)
          Destroyes a session with given identifier.
 java.lang.Object execute(java.lang.Object pSessionId, java.lang.String pObjectName, java.lang.String pMethod, java.lang.Object... pParams)
          Executes a method call.
 java.lang.Object executeAction(java.lang.Object pSessionId, java.lang.String pAction, java.lang.Object... pParams)
          Executes an action call.
 void executeActionCallBack(java.lang.Object pSessionId, ICallBackListener pCallBackListener, java.lang.String pAction, java.lang.Object... pParams)
          Executes an asynchronous action call.
 void executeActionCallBack(java.lang.Object pSessionId, java.lang.Object pCallBackId, java.lang.String pAction, java.lang.Object... pParams)
          Executes an asynchronous action call.
 void executeCallBack(java.lang.Object pSessionId, ICallBackListener pCallBackListener, java.lang.String pObjectName, java.lang.String pMethod, java.lang.Object... pParams)
          Executes an asynchronous method call.
 void executeCallBack(java.lang.Object pSessionId, java.lang.Object pCallBackId, java.lang.String pObjectName, java.lang.String pMethod, java.lang.Object... pParams)
          Executes an asynchronous method call.
 java.util.List<ResultObject> getCallBackResults(java.lang.Object pSessionId)
          Returns all available objects of an asynchronous execution.
static Server getInstance()
          Gets the current server instance as singleton.
 java.lang.String getInstanceKey()
          Gets the instance key of this server instance.
 Monitoring getMonitoring()
          Returns the monitoring object for this server.
 AbstractObjectProvider getObjectProvider()
          Gets the AbstractObjectProvider.
 ChangedHashtable<java.lang.String,java.lang.Object> getProperties(java.lang.Object pSessionId)
          Gets all session properties.
 java.lang.Object getProperty(java.lang.Object pSessionId, java.lang.String pName)
          Gets the value of a session property.
 DefaultSessionManager getSessionManager()
          Gets the AbstractSessionManager.
 long getStartupTime()
          Gets the server startup time.
static void initLogging()
          Initializes LoggerFactory.
 ISession process(IRequest pRequest, IResponse pResponse)
          Processes client requests which uses the communication protocol.
 void push(PushMessage pMessage)
          Pushes a message to the registered receiver.
 void registerPushReceiver(java.lang.Object pSessionId, IPushReceiver pReceiver)
          Registers a push receiver.
 java.lang.Object[] setAndCheckAlive(java.lang.Object pSessionId, java.lang.Object... pSubSessionId)
          Sets the alive state for a session and validates the alive state of sub sessions.
 void setNewPassword(java.lang.Object pSessionId, java.lang.String pOldPassword, java.lang.String pNewPassword)
          Sets a new password for the user of a session.
 void setProperty(java.lang.Object pSessionId, java.lang.String pName, java.lang.Object pValue)
          Sets a session property.
 void unregisterPushReceiver(java.lang.Object pSessionId)
          Unregisters a push receiver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Server

public Server()
Creates a new instance of Server.

Method Detail

getInstance

public static Server getInstance()
Gets the current server instance as singleton.

Returns:
the singleton server instance

getSessionManager

public final DefaultSessionManager getSessionManager()
Gets the AbstractSessionManager.

Specified by:
getSessionManager in interface IServer
Returns:
the session manager.

getObjectProvider

public final AbstractObjectProvider getObjectProvider()
Gets the AbstractObjectProvider.

Specified by:
getObjectProvider in interface IServer
Returns:
the object provider.

createSession

public java.lang.Object createSession(ChangedHashtable<java.lang.String,java.lang.Object> pProperties)
                               throws java.lang.Throwable
Creates a new session for an application. The credentials are stored in the properties.

Specified by:
createSession in interface IServer
Parameters:
pProperties - the initial session properties
Returns:
session identifier of newly created Session
Throws:
java.lang.Throwable - if the session can not be created

createSubSession

public java.lang.Object createSubSession(java.lang.Object pSessionId,
                                         ChangedHashtable<java.lang.String,java.lang.Object> pProperties)
                                  throws java.lang.Throwable
Creates a sub session of an application. The name/alias of the sub session is stored in the properties.

Specified by:
createSubSession in interface IServer
Parameters:
pSessionId - session identifier
pProperties - the initial session properties
Returns:
session identifier of newly created SubSession
Throws:
java.lang.Throwable - if the session can not be created

destroySession

public void destroySession(java.lang.Object pSessionId)
Destroyes a session with given identifier.

Specified by:
destroySession in interface IServer
Parameters:
pSessionId - session identifier

execute

public java.lang.Object execute(java.lang.Object pSessionId,
                                java.lang.String pObjectName,
                                java.lang.String pMethod,
                                java.lang.Object... pParams)
                         throws java.lang.Throwable
Executes a method call.

Specified by:
execute in interface IServer
Parameters:
pSessionId - session identifier
pObjectName - server object name/alias
pMethod - method name which should be called
pParams - parameters for the method call
Returns:
result of method call
Throws:
java.lang.Throwable - if an error occurs during execution

executeCallBack

public void executeCallBack(java.lang.Object pSessionId,
                            java.lang.Object pCallBackId,
                            java.lang.String pObjectName,
                            java.lang.String pMethod,
                            java.lang.Object... pParams)
                     throws java.lang.Throwable
Executes an asynchronous method call.

Specified by:
executeCallBack in interface IServer
Parameters:
pSessionId - session identifier
pCallBackId - the callback identifier
pObjectName - server object name/alias
pMethod - method name which should be called
pParams - parameters for the method call
Throws:
java.lang.Throwable - if an error occurs during execution

executeCallBack

public void executeCallBack(java.lang.Object pSessionId,
                            ICallBackListener pCallBackListener,
                            java.lang.String pObjectName,
                            java.lang.String pMethod,
                            java.lang.Object... pParams)
                     throws java.lang.Throwable
Executes an asynchronous method call.

Specified by:
executeCallBack in interface IDirectServer
Parameters:
pSessionId - session identifier
pCallBackListener - the callback listener
pObjectName - server object name/alias
pMethod - method name which should be called
pParams - parameters for the method call
Throws:
java.lang.Throwable - if an error occurs during execution

executeAction

public java.lang.Object executeAction(java.lang.Object pSessionId,
                                      java.lang.String pAction,
                                      java.lang.Object... pParams)
                               throws java.lang.Throwable
Executes an action call.

Specified by:
executeAction in interface IServer
Parameters:
pSessionId - session identifier
pAction - action which should be called
pParams - parameters for the action call
Returns:
result of action call
Throws:
java.lang.Throwable - if an error occurs during execution

executeActionCallBack

public void executeActionCallBack(java.lang.Object pSessionId,
                                  java.lang.Object pCallBackId,
                                  java.lang.String pAction,
                                  java.lang.Object... pParams)
                           throws java.lang.Throwable
Executes an asynchronous action call.

Specified by:
executeActionCallBack in interface IServer
Parameters:
pSessionId - session identifier
pCallBackId - the callback identifier
pAction - action which should be called
pParams - parameters for the action call
Throws:
java.lang.Throwable - if an error occurs during execution

executeActionCallBack

public void executeActionCallBack(java.lang.Object pSessionId,
                                  ICallBackListener pCallBackListener,
                                  java.lang.String pAction,
                                  java.lang.Object... pParams)
                           throws java.lang.Throwable
Executes an asynchronous action call.

Specified by:
executeActionCallBack in interface IDirectServer
Parameters:
pSessionId - session identifier
pCallBackListener - the callback listener
pAction - action which should be called
pParams - parameters for the action call
Throws:
java.lang.Throwable - if an error occurs during execution

setProperty

public void setProperty(java.lang.Object pSessionId,
                        java.lang.String pName,
                        java.lang.Object pValue)
                 throws java.lang.Throwable
Sets a session property.

Specified by:
setProperty in interface IServer
Parameters:
pSessionId - the session identifier
pName - the property name
pValue - the value of the property or null to delete the property
Throws:
java.lang.Throwable - if an error occurs during execution

getProperty

public java.lang.Object getProperty(java.lang.Object pSessionId,
                                    java.lang.String pName)
                             throws java.lang.Throwable
Gets the value of a session property.

Specified by:
getProperty in interface IServer
Parameters:
pSessionId - the session identifier
pName - the property name
Returns:
the value of the property or null if the property is not available
Throws:
java.lang.Throwable - if an error occurs during execution

getProperties

public ChangedHashtable<java.lang.String,java.lang.Object> getProperties(java.lang.Object pSessionId)
                                                                  throws java.lang.Throwable
Gets all session properties.

Specified by:
getProperties in interface IServer
Parameters:
pSessionId - the session identifier
Returns:
a ChangedHashtable with property names and values
Throws:
java.lang.Throwable - if an error occurs during execution

getCallBackResults

public java.util.List<ResultObject> getCallBackResults(java.lang.Object pSessionId)
                                                throws java.lang.Throwable
Returns all available objects of an asynchronous execution.

Specified by:
getCallBackResults in interface IServer
Parameters:
pSessionId - session identifier
Returns:
result objects or null if there are no result objects
Throws:
java.lang.Throwable - if an error occurs during execution

setAndCheckAlive

public java.lang.Object[] setAndCheckAlive(java.lang.Object pSessionId,
                                           java.lang.Object... pSubSessionId)
                                    throws java.lang.Throwable
Sets the alive state for a session and validates the alive state of sub sessions.

Specified by:
setAndCheckAlive in interface IServer
Parameters:
pSessionId - the session id
pSubSessionId - the sub session ids
Returns:
the invalid/expired sub session ids
Throws:
java.lang.Throwable - if an error occurs during execution

setNewPassword

public void setNewPassword(java.lang.Object pSessionId,
                           java.lang.String pOldPassword,
                           java.lang.String pNewPassword)
                    throws java.lang.Throwable
Sets a new password for the user of a session.

Specified by:
setNewPassword in interface IServer
Parameters:
pSessionId - the session id
pOldPassword - the old password
pNewPassword - the new password
Throws:
java.lang.Throwable - if an error occurs during execution

beforeFirstCall

public void beforeFirstCall(java.lang.Object pSessionId)
Notifies the server that at least one call will follow. It's possible that multiple calls will be executed in batch mode.

Specified by:
beforeFirstCall in interface IDirectServer
Parameters:
pSessionId - the session id which will execute at least one call

afterLastCall

public void afterLastCall(java.lang.Object pSessionId,
                          boolean pCallError)
Notifies the server that all calls were executed. This method will be invoked even if one call throwed an exception.

Specified by:
afterLastCall in interface IDirectServer
Parameters:
pSessionId - the session id which executed at least one call
pCallError - true if at least one call throwed an exception

registerPushReceiver

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

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

unregisterPushReceiver

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

Specified by:
unregisterPushReceiver in interface IPushHandler
Parameters:
pSessionId - 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

getInstanceKey

public java.lang.String getInstanceKey()
Gets the instance key of this server instance. The key is unique in the same VM but it's not an UUID. It contains the current time in millis and an instance number.

Returns:
the instance key

getStartupTime

public long getStartupTime()
Gets the server startup time. This time is the time of instance creation.

Returns:
the startup time

process

public ISession process(IRequest pRequest,
                        IResponse pResponse)
                 throws java.lang.Exception
Processes client requests which uses the communication protocol.

Parameters:
pRequest - the request
pResponse - the response
Returns:
the accessed session or null if the session is not available
Throws:
java.lang.Exception - if a problem occurs while accessing the in- or output stream

getMonitoring

public final Monitoring getMonitoring()
Returns the monitoring object for this server.

Returns:
the monitoring object

initLogging

public static final void initLogging()
Initializes LoggerFactory.



Copyright © 2009 SIB Visions GmbH. All Rights Reserved.