javax.rad.remote
Class MasterConnection

java.lang.Object
  extended by javax.rad.remote.AbstractConnection
      extended by javax.rad.remote.MasterConnection
All Implemented Interfaces:
ICloseable

public class MasterConnection
extends AbstractConnection

The MasterConnection provides sub connections and an alive check for all known connections.

See Also:
IConnection

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.rad.remote.AbstractConnection
AbstractConnection.CallBackResultDelegate, AbstractConnection.ListenerDelegate<K>, AbstractConnection.PropertyChangedDelegate
 
Field Summary
 
Fields inherited from class javax.rad.remote.AbstractConnection
coninf, connection
 
Constructor Summary
MasterConnection(IConnection pConnection)
          Creates a new instance of AppliationConnection with an IConnection implementation.
 
Method Summary
protected  void addSubConnection(SubConnection pSubConnection)
          Adds a sub connection to the internal list of sub connections.
 void close()
          Close the connection.
protected  ChangedHashtable<java.lang.String,java.lang.Object> createConnectionProperties()
          Gets the properties which will be sent to the server when opening a new connection.
 SubConnection createSubConnection(java.lang.String pLifeCycleName)
          Returns a new sub connection.
 long getAliveInterval()
          Gets the current alive interval.
 java.util.List<SubConnection> getSubConnections()
          Returns a cloned list of sub connections.
protected  UIInvoker getUIInvoker()
          Gets the UI invoker.
 void openConnection()
          Opens the connection without event handling.
protected  void removeSubConnection(SubConnection pSubConnection)
          Removes a sub connection from the internal list of sub connections.
 void reopen()
          Reopens this and all sub connections.
 void reopen(boolean pCloseSubConnections)
          Reopens this connection.
 void setAliveInterval(long pInterval)
          Sets the interval of the alive thread.
 void setAndCheckAlive()
          Sends the alive information to the server and checks all sub connections if they are still valid.
 void setNewPassword(java.lang.String pOldPassword, java.lang.String pNewPassword)
          Sets the new password for the current connection.
 
Methods inherited from class javax.rad.remote.AbstractConnection
addCallBackResultListener, addCallBackResultListener, addConnectionListener, addPropertyChangedListener, addPropertyChangedListener, call, call, call, call, call, call, call, callAction, callAction, callAction, callAction, callAction, callAction, callAction, callBack, callBack, callBack, callBackAction, callBackAction, callBackAction, close, finalize, fireCall, fireCallAction, fireCallBackResult, fireCallError, fireClose, fireOpen, fireReOpen, getApplicationName, getConnection, getConnectionId, getConnectionListener, getLifeCycleName, getPassword, getProperties, getProperty, getTimeout, getUserName, handleCallError, isOpen, logCommunication, open, removeCallBackResultListener, removeCallBackResultListener, removeCallBackResultListener, removeConnectionListener, removePropertyChangedListener, removePropertyChangedListener, removePropertyChangedListener, setApplicationName, setConnection, setLifeCycleName, setPassword, setProperty, setTimeout, setUserName
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MasterConnection

public MasterConnection(IConnection pConnection)
Creates a new instance of AppliationConnection with an IConnection implementation.

Parameters:
pConnection - the IConnection implementation
Method Detail

openConnection

public void openConnection()
                    throws java.lang.Throwable
Opens the connection without event handling.

Specified by:
openConnection in class AbstractConnection
Throws:
java.lang.Throwable - if the connection can not be or is already opened

getUIInvoker

protected UIInvoker getUIInvoker()
Gets the UI invoker.

Specified by:
getUIInvoker in class AbstractConnection
Returns:
the UI invoker
See Also:
UIInvoker

close

public void close()
           throws java.lang.Throwable
Close the connection.

Specified by:
close in interface ICloseable
Overrides:
close in class AbstractConnection
Throws:
java.lang.Throwable - if it is not possible to close the connection

reopen

public void reopen()
            throws java.lang.Throwable
Reopens this and all sub connections.

Overrides:
reopen in class AbstractConnection
Throws:
java.lang.Throwable - if an error occurs while opening this or any sub connection

createConnectionProperties

protected ChangedHashtable<java.lang.String,java.lang.Object> createConnectionProperties()
Gets the properties which will be sent to the server when opening a new connection.

Overrides:
createConnectionProperties in class AbstractConnection
Returns:
the properties as list with key/value pairs

reopen

public void reopen(boolean pCloseSubConnections)
            throws java.lang.Throwable
Reopens this connection.

Parameters:
pCloseSubConnections - true to close sub connections and don't reopen them, false if sub connections should be reopened
Throws:
java.lang.Throwable - if an error occurs while reopening this or any sub connection

createSubConnection

public SubConnection createSubConnection(java.lang.String pLifeCycleName)
                                  throws java.lang.Throwable
Returns a new sub connection.

Parameters:
pLifeCycleName - the name of the life-cycle object for the sub connection
Returns:
the new SubConnection for the sub connection
Throws:
java.lang.Throwable - if it is not possible to create the new sub connection

addSubConnection

protected void addSubConnection(SubConnection pSubConnection)
Adds a sub connection to the internal list of sub connections.

Parameters:
pSubConnection - the sub connection

removeSubConnection

protected void removeSubConnection(SubConnection pSubConnection)
Removes a sub connection from the internal list of sub connections.

Parameters:
pSubConnection - the sub connection

getSubConnections

public java.util.List<SubConnection> getSubConnections()
Returns a cloned list of sub connections. Don't reference to the connections to avoid problems with memory and gc.

Returns:
all known sub connections or null if there is no sub connection

setAliveInterval

public void setAliveInterval(long pInterval)
Sets the interval of the alive thread. The default value is ALIVECHECK_DELAY.

Parameters:
pInterval - interval in millis. If the value is smaller or equal than one second, the default value will be set. An interval with a negative value will disable the alive check

getAliveInterval

public long getAliveInterval()
Gets the current alive interval.

Returns:
the interval

setNewPassword

public void setNewPassword(java.lang.String pOldPassword,
                           java.lang.String pNewPassword)
                    throws java.lang.Throwable
Sets the new password for the current connection.

Parameters:
pOldPassword - the old password
pNewPassword - the new password
Throws:
java.lang.Throwable - if the password can not be changed

setAndCheckAlive

public void setAndCheckAlive()
                      throws java.lang.Throwable
Sends the alive information to the server and checks all sub connections if they are still valid.

Throws:
java.lang.Throwable - if the alive check fails


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.