javax.rad.remote
Class MasterConnection

java.lang.Object
  extended by javax.rad.remote.AbstractConnection
      extended by javax.rad.remote.MasterConnection

public class MasterConnection
extends AbstractConnection

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

See Also:
IConnection

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<String,Object> createConnectionProperties()
          Gets the properties which will be sent to the server when opening a new connection.
 SubConnection createSubConnection(String pLifeCycleName)
          Returns a new sub connection.
 long getAliveInterval()
          Gets the current alive interval.
 List<SubConnection> getSubConnections()
          Returns a cloned list of sub connections.
static boolean isAliveCheckEnabled()
          Gets whether the alive check should be used.
 void open()
          Opens the connection.
protected  void removeSubConnection(SubConnection pSubConnection)
          Removes a sub connection from the internal list of sub connections.
 void reopen()
          Reopens this and all sub connections.
static void setAliveCheckEnabled(boolean pEnabled)
          Sets whether alive check should be used.
 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(String pOldPassword, String pNewPassword)
          Sets the new password for the current connection.
 
Methods inherited from class javax.rad.remote.AbstractConnection
addConnectionListener, call, call, call, call, call, call, call, callAction, callAction, callAction, callAction, callAction, callAction, callAction, finalize, fireCall, fireCallAction, fireCallError, fireClose, fireOpen, firePropertyChanged, fireReOpen, getApplicationName, getConnection, getConnectionId, getConnectionListener, getLifeCycleName, getPassword, getProperties, getProperty, getTimeout, getUserName, isOpen, removeConnectionListener, setApplicationName, 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

open

public void open()
          throws Throwable
Opens the connection.

Specified by:
open in class AbstractConnection
Throws:
Throwable - if the connection can not be or is already opened

close

public void close()
           throws Throwable
Close the connection.

Overrides:
close in class AbstractConnection
Throws:
Throwable - if it is not possible to close the connection

reopen

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

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

createConnectionProperties

protected ChangedHashtable<String,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

createSubConnection

public SubConnection createSubConnection(String pLifeCycleName)
                                  throws 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:
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 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

setAliveCheckEnabled

public static void setAliveCheckEnabled(boolean pEnabled)
Sets whether alive check should be used. If the check was disable and will be enabled, the alive check does not start immediate. It starts with next SubConnection creation or this connection will be opened.

Parameters:
pEnabled - true to enable the alive check, false to disable the check

isAliveCheckEnabled

public static boolean isAliveCheckEnabled()
Gets whether the alive check should be used.

Returns:
true if the alive check is enabled, false if it's disabled
See Also:
setAliveCheckEnabled(boolean)

setNewPassword

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

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

setAndCheckAlive

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

Throws:
Throwable - if the alive check fails


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.