org.mbari.siam.utils
Class ManagedRemoteService

java.lang.Object
  extended by org.mbari.siam.utils.ManagedRemoteService

public class ManagedRemoteService
extends java.lang.Object

ManagedRemoteService creates and manages an RMI SIAM 'RemoteService' proxy associated with the specified name, and periodically checks that the service is still available.


Nested Class Summary
static interface ManagedRemoteService.StatusListener
          Interface for components that wish to respond to connection status
 
Field Summary
protected  long _lastRefreshTime
           
protected  java.lang.Object _lock
           
protected static org.apache.log4j.Logger _log4j
           
protected  NodeProbe _nodeProbe
           
protected  RemoteService _service
           
protected  java.net.InetAddress _serviceAddr
           
protected  java.lang.String _serviceMnemonic
           
protected  java.lang.String _serviceURL
           
protected  java.util.Vector _statusListeners
           
protected static int PROBE_TIMEOUT_MSEC
           
protected static int REFRESH_INTERVAL_MSEC
           
protected static int RMIREGISTRY_PORT
           
 
Constructor Summary
ManagedRemoteService(java.lang.String serviceURL, java.lang.String serviceMnemonic, int pingIntervalMsec)
           
 
Method Summary
 void addListener(ManagedRemoteService.StatusListener listener)
          Add a status listener
 RemoteService connect()
          Reconnect service
 boolean connected()
          Return true if connected to remote service
static java.lang.String getHostName(java.lang.String nodeURL)
          Return the 'hostname' portion of the remote service's URL.
 RemoteService getProxy()
          Get service proxy
protected  void notifyListeners(boolean connected)
          Notify listeners of connection status
 void resetConnection()
          Set service reference to 'null', so that next access attempt will result in reconnection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_log4j

protected static org.apache.log4j.Logger _log4j

REFRESH_INTERVAL_MSEC

protected static final int REFRESH_INTERVAL_MSEC
See Also:
Constant Field Values

_lastRefreshTime

protected long _lastRefreshTime

_service

protected RemoteService _service

_serviceURL

protected java.lang.String _serviceURL

_serviceMnemonic

protected java.lang.String _serviceMnemonic

_statusListeners

protected java.util.Vector _statusListeners

_serviceAddr

protected java.net.InetAddress _serviceAddr

_nodeProbe

protected NodeProbe _nodeProbe

PROBE_TIMEOUT_MSEC

protected static final int PROBE_TIMEOUT_MSEC
See Also:
Constant Field Values

RMIREGISTRY_PORT

protected static final int RMIREGISTRY_PORT
See Also:
Constant Field Values

_lock

protected java.lang.Object _lock
Constructor Detail

ManagedRemoteService

public ManagedRemoteService(java.lang.String serviceURL,
                            java.lang.String serviceMnemonic,
                            int pingIntervalMsec)
                     throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

resetConnection

public void resetConnection()
Set service reference to 'null', so that next access attempt will result in reconnection


notifyListeners

protected void notifyListeners(boolean connected)
Notify listeners of connection status


connect

public RemoteService connect()
                      throws java.lang.Exception
Reconnect service

Throws:
java.lang.Exception

connected

public boolean connected()
Return true if connected to remote service


getProxy

public RemoteService getProxy()
                       throws java.lang.Exception
Get service proxy

Throws:
java.lang.Exception

addListener

public void addListener(ManagedRemoteService.StatusListener listener)
Add a status listener


getHostName

public static java.lang.String getHostName(java.lang.String nodeURL)
Return the 'hostname' portion of the remote service's URL. Note that this is a TOTAL hack, since Java's URL class does not support "rmi" as a valid protocol!!!



Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.