com.sibvisions.rad.util
Class DirectObjectConnection

java.lang.Object
  extended by com.sibvisions.rad.util.DirectObjectConnection
All Implemented Interfaces:
IConnection

public class DirectObjectConnection
extends Object
implements IConnection

The DirectObjectConnection enables direct object calls without the need of a server. It's possible to use the original client implementation and pass server and lifecycle objects. But it is important to specify all needed server objects by name (manual lifecycle handling).


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
DirectObjectConnection()
          Creates a new instance of DirectObjectConnection without any object.
DirectObjectConnection(Map<String,Object> pObjects)
          Creates a new instance of DirectObjectConnection with predefined objects.
 
Method Summary
 Object[] call(ConnectionInfo pConnectionInfo, String[] pObjectName, String[] pMethod, Object[][] pParams, ICallBackListener[] pCallBack)
          Calls a list of methods from objects identified by name(s).
 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)
          The connection is always open.
 void open(ConnectionInfo pConnectionInfo)
          Sets a random connection ID.
 void openSub(ConnectionInfo pConnectionInfo, ConnectionInfo pConnectionInfoSub)
          Sets a random connection ID for the sub connection.
 Object put(String pName, Object pObject)
          Puts an object to the list of known objects.
 Object remove(String pName)
          Removes an object from the list of known objects.
 void reopen(ConnectionInfo pConnectionInfo)
          Not supported.
 ConnectionInfo[] setAndCheckAlive(ConnectionInfo pConnectionInfo, ConnectionInfo[] pSubConnections)
          Returns null.
 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

DirectObjectConnection

public DirectObjectConnection()
Creates a new instance of DirectObjectConnection without any object.


DirectObjectConnection

public DirectObjectConnection(Map<String,Object> pObjects)
Creates a new instance of DirectObjectConnection with predefined objects.

Parameters:
pObjects - the initial objects.
Method Detail

call

public Object[] call(ConnectionInfo pConnectionInfo,
                     String[] pObjectName,
                     String[] pMethod,
                     Object[][] pParams,
                     ICallBackListener[] pCallBack)
              throws Throwable
Calls a list of methods from objects identified by name(s). The object is searched in the known map of objects. It's not possible to use callback listeners and it's also not possible to call actions. Only specific object calls are implemented.

Specified by:
call in interface IConnection
Parameters:
pConnectionInfo - the connection info
pObjectName - the object names
pMethod - the method names
pParams - the method params
pCallBack - the callback listeners
Returns:
the result of the method calls
Throws:
Throwable - if an exception occurs

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

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

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

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

isOpen

public boolean isOpen(ConnectionInfo pConnectionInfo)
The connection is always open.

Specified by:
isOpen in interface IConnection
Parameters:
pConnectionInfo - the connection info
Returns:
true

open

public void open(ConnectionInfo pConnectionInfo)
Sets a random connection ID.

Specified by:
open in interface IConnection
Parameters:
pConnectionInfo - the connection info

openSub

public void openSub(ConnectionInfo pConnectionInfo,
                    ConnectionInfo pConnectionInfoSub)
Sets a random connection ID for the sub connection.

Specified by:
openSub in interface IConnection
Parameters:
pConnectionInfo - the connection info
pConnectionInfoSub - the sub connection info

reopen

public void reopen(ConnectionInfo pConnectionInfo)
Not supported.

Specified by:
reopen in interface IConnection
Parameters:
pConnectionInfo - the connection info

setAndCheckAlive

public ConnectionInfo[] setAndCheckAlive(ConnectionInfo pConnectionInfo,
                                         ConnectionInfo[] pSubConnections)
Returns null.

Specified by:
setAndCheckAlive in interface IConnection
Parameters:
pConnectionInfo - the connection info
pSubConnections - the current sub connection infos
Returns:
null

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

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

put

public Object put(String pName,
                  Object pObject)
Puts an object to the list of known objects.

Parameters:
pName - the object name
pObject - the object or null to remove the object with the specified name
Returns:
the previous object if the key is present

remove

public Object remove(String pName)
Removes an object from the list of known objects.

Parameters:
pName - the object name
Returns:
the object for the object name


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.