com.sibvisions.rad.server
Class DirectServerConnection

java.lang.Object
  extended by com.sibvisions.rad.server.DirectServerConnection
All Implemented Interfaces:
IConnection

public class DirectServerConnection
extends Object
implements IConnection

The DirectServerConnection is an IConnection implementation for a direct server communication. The calls will be sent to the server without serialization.


Field Summary
 
Fields inherited from interface javax.rad.remote.IConnection
COMPRESSION_BYTES, FLAG_ACKNOWLEDGE, FLAG_BROKEN, FLAG_ESTABLISHED, MET_SESSION_CREATE, MET_SESSION_DESTROY, MET_SESSION_GET_PROPERTIES, MET_SESSION_GET_PROPERTY, MET_SESSION_SET_NEW_PASSWORD, MET_SESSION_SET_PROPERTY, MET_SESSION_SETCHECKALIVE, MET_SESSION_SUBSESSION_CREATE, MODE_COMPRESSED, MODE_UNCOMPRESSED, OBJ_SESSION, TYPE_CALL_ERROR, TYPE_CALL_RESULT, TYPE_CALLBACK_ERROR, TYPE_CALLBACK_RESULT, TYPE_PROPERTY_RESULT
 
Constructor Summary
DirectServerConnection()
          Creates a new instance of DirectServerConnection with a new Server instance.
DirectServerConnection(IDirectServer pServer)
          Creates a new instance of DirectServerConnection for a IDirectServer implementation.
 
Method Summary
 Object[] call(ConnectionInfo pConnectionInfo, String[] pObjectName, String[] pMethod, Object[][] pParams, ICallBackListener[] pCallBack)
          Calls desired methods from a remote server object.
 void close(ConnectionInfo pConnectionInfo)
          Close the connection to the server.
 Hashtable<String,Object> getProperties(ConnectionInfo pConnectionInfo)
          Gets a clone of all connection properties.
 Object getProperty(ConnectionInfo pConnectionInfo, String pName)
          Gets a connection property.
 boolean isCalling()
          Gets whether a call is active.
 boolean isOpen(ConnectionInfo pConnectionInfo)
          Checks if the connection to the server is opened.
 void open(ConnectionInfo pConnectionInfo)
          Opens the connection to the server.
 void openSub(ConnectionInfo pConnectionInfo, ConnectionInfo pConnectionInfoSub)
          Opens a new sub connection.
 void reopen(ConnectionInfo pConnectionInfo)
          Closes and opens the connection to the server.
 ConnectionInfo[] setAndCheckAlive(ConnectionInfo pConnectionInfo, ConnectionInfo[] pSubConnections)
          Sets the alive state for a connection, on the server, and validates the alive state of subconnections.
 void setNewPassword(ConnectionInfo pConnectionInfo, String pOldPassword, String pNewPassword)
          Sets a new password for the connected user.
 void setProperty(ConnectionInfo pConnectionInfo, String pName, Object pValue)
          Sets a connection property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectServerConnection

public DirectServerConnection()
Creates a new instance of DirectServerConnection with a new Server instance.


DirectServerConnection

public DirectServerConnection(IDirectServer pServer)
Creates a new instance of DirectServerConnection for a IDirectServer implementation.

Parameters:
pServer - the server
Method Detail

open

public void open(ConnectionInfo pConnectionInfo)
          throws Throwable
Opens the connection to the server. The credentials have to be a key/value mapping in the connection information.

Specified by:
open in interface IConnection
Parameters:
pConnectionInfo - the connection information
Throws:
Throwable - if the connection can not be established

openSub

public void openSub(ConnectionInfo pConnectionInfo,
                    ConnectionInfo pConnectionInfoSub)
             throws Throwable
Opens a new sub connection. The name of the sub connection has to be a key/value mapping in the sub connection information.

Specified by:
openSub in interface IConnection
Parameters:
pConnectionInfo - the connection information of the master connection
pConnectionInfoSub - the connection information of the sub connection
Throws:
Throwable - communication error, security checks, invalid method, ...

isOpen

public boolean isOpen(ConnectionInfo pConnectionInfo)
Checks if the connection to the server is opened.

Specified by:
isOpen in interface IConnection
Parameters:
pConnectionInfo - the connection information
Returns:
true if the connection is open

close

public void close(ConnectionInfo pConnectionInfo)
           throws Throwable
Close the connection to the server.

Specified by:
close in interface IConnection
Parameters:
pConnectionInfo - the connection information
Throws:
Throwable - if the connection can not be established

reopen

public void reopen(ConnectionInfo pConnectionInfo)
            throws Throwable
Closes and opens the connection to the server. This might be useful if the connection was timed out.

Specified by:
reopen in interface IConnection
Parameters:
pConnectionInfo - the connection information
Throws:
Throwable - if the connection can not be established

call

public Object[] call(ConnectionInfo pConnectionInfo,
                     String[] pObjectName,
                     String[] pMethod,
                     Object[][] pParams,
                     ICallBackListener[] pCallBack)
              throws Throwable
Calls desired methods from a remote server object.

Specified by:
call in interface IConnection
Parameters:
pConnectionInfo - the connection information
pObjectName - list of server object names/aliases
pMethod - method names which should be called
pParams - parameters for the method calls
pCallBack - callback listeners for asynchronous or null for synchronous calls
Returns:
result list from the remote method calls
Throws:
Throwable - communication error, security checks, invalid method, ...

isCalling

public boolean isCalling()
Gets whether a call is active.

Specified by:
isCalling in interface IConnection
Returns:
true if a call is active, false otherwise

setAndCheckAlive

public ConnectionInfo[] setAndCheckAlive(ConnectionInfo pConnectionInfo,
                                         ConnectionInfo[] pSubConnections)
                                  throws Throwable
Sets the alive state for a connection, on the server, and validates the alive state of subconnections.

Specified by:
setAndCheckAlive in interface IConnection
Parameters:
pConnectionInfo - the connection information
pSubConnections - the connection information of the sub connections, for the alive validation
Returns:
the invalid/expired sub connections
Throws:
Throwable - communication error, security checks, invalid method, ...

setProperty

public void setProperty(ConnectionInfo pConnectionInfo,
                        String pName,
                        Object pValue)
                 throws Throwable
Sets a connection property.

Specified by:
setProperty in interface IConnection
Parameters:
pConnectionInfo - the connection information
pName - the property name
pValue - the value of the property or null to delete the property
Throws:
Throwable - communication error, security checks, invalid method, ...
SecurityException - if it's not allowed to set the property

getProperty

public Object getProperty(ConnectionInfo pConnectionInfo,
                          String pName)
                   throws Throwable
Gets a connection property.

Specified by:
getProperty in interface IConnection
Parameters:
pConnectionInfo - the connection information
pName - the property name
Returns:
the value of the property or null if the property is not set
Throws:
Throwable - communication error, security checks, invalid method, ...

getProperties

public Hashtable<String,Object> getProperties(ConnectionInfo pConnectionInfo)
                                       throws Throwable
Gets a clone of all connection properties.

Specified by:
getProperties in interface IConnection
Parameters:
pConnectionInfo - the connection information
Returns:
a Hashtable with property names and values
Throws:
Throwable - communication error, security checks, invalid method, ...

setNewPassword

public void setNewPassword(ConnectionInfo pConnectionInfo,
                           String pOldPassword,
                           String pNewPassword)
                    throws Throwable
Sets a new password for the connected user.

Specified by:
setNewPassword in interface IConnection
Parameters:
pConnectionInfo - the connection information
pOldPassword - the old password
pNewPassword - the new password
Throws:
Throwable - communication error, security checks, invalid method, ...


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.