org.openbp.guiclient.remote
Class ServerConnection

java.lang.Object
  extended by org.openbp.guiclient.remote.ServerConnection

public final class ServerConnection
extends java.lang.Object

The server manager manages the connection to the OpenBP server. It is especially used to lookup services of the server. The services are cached in a local table, so lookup of a retrieved service is fast.

Author:
Heiko Erhardt

Field Summary
static boolean disableTimersForDebug
          Debug flag: Disable the continously running timer (useful for profiling and memory leak detection)
 
Method Summary
 void connect(boolean throwError)
          Tries to connect to the server.
 void disconnect()
          Disconnects from the server.
 ClientConnectionInfo getConnectionInfo()
          Gets the connection info to the OpenBP server.
static ServerConnection getInstance()
          Gets the singleton instance of this class.
 ClientLoginInfo getLoginInfo()
          Gets the login info for the client session.
 ClientSession getSession()
          This method returns the session this model is maintaining, or null, if no session has been created yet.
 boolean isConnected()
          Checks if we are connected to the server.
 java.lang.Object lookupOptionalService(java.lang.Class serviceCls)
          Looks up a service of the server, ignoring errors silently.
 java.lang.Object lookupService(java.lang.Class serviceCls)
          Looks up a service of the server, throwing an exception on error.
 java.lang.Object obtainService(java.lang.Class serviceCls, boolean throwError)
          Looks up a service of the server.
 void setConnectionInfo(ClientConnectionInfo connectionInfo)
          Sets the connection info to the OpenBP server.
 void setLoginInfo(ClientLoginInfo loginInfo)
          Sets the login info for the client session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

disableTimersForDebug

public static boolean disableTimersForDebug
Debug flag: Disable the continously running timer (useful for profiling and memory leak detection)

Method Detail

getInstance

public static ServerConnection getInstance()
Gets the singleton instance of this class.


getSession

public ClientSession getSession()
This method returns the session this model is maintaining, or null, if no session has been created yet.

Returns:
The ClientSession object or null

getConnectionInfo

public ClientConnectionInfo getConnectionInfo()
Gets the connection info to the OpenBP server.


setConnectionInfo

public void setConnectionInfo(ClientConnectionInfo connectionInfo)
Sets the connection info to the OpenBP server.


getLoginInfo

public ClientLoginInfo getLoginInfo()
Gets the login info for the client session.


setLoginInfo

public void setLoginInfo(ClientLoginInfo loginInfo)
Sets the login info for the client session.


connect

public void connect(boolean throwError)
Tries to connect to the server. Also establishes a session and starts the server event polling if login information is present.

Parameters:
throwError - true Throws an exception in case of error.
false Silently ignores if no server is present. However, throws exceptions if other error occur.
Throws:
OpenBPException - On error

disconnect

public void disconnect()
Disconnects from the server.


isConnected

public boolean isConnected()
Checks if we are connected to the server.


lookupService

public java.lang.Object lookupService(java.lang.Class serviceCls)
Looks up a service of the server, throwing an exception on error.

Parameters:
serviceCls - Class of the service to lookup
Returns:
The service
Throws:
OpenBPException - If the service cannot be found on the server

lookupOptionalService

public java.lang.Object lookupOptionalService(java.lang.Class serviceCls)
Looks up a service of the server, ignoring errors silently.

Parameters:
serviceCls - Class of the service to lookup
Returns:
The service or null if not found

obtainService

public java.lang.Object obtainService(java.lang.Class serviceCls,
                                      boolean throwError)
Looks up a service of the server.

Parameters:
serviceCls - Service class
throwError - true Throws an exception in case of error.
false Silently ignores errors.
Returns:
The service
Throws:
OpenBPException - If the service cannot be found on the server


Copyright © 2011. All Rights Reserved.