org.mbari.siam.registry
Class InstrumentRegistry

java.lang.Object
  extended by org.mbari.siam.registry.InstrumentRegistry
All Implemented Interfaces:
java.util.EventListener, ServiceListener

public class InstrumentRegistry
extends java.lang.Object
implements ServiceListener

InstrumentRegistry is a facility that allows you to register DeviceServices, and to look them up by registry name. You can also register to get callbacks when registrants are added or deleted, and through those registrants, you can get callbacks when their instruments have new data.

The core class DeviceService contains the ServiceAttributes. These ServiceAttributes contain, in particular, an attribute named registryName, which by default is declared as null.

The registryName attribute is used by InstrumentRegistry as a lookup key. The system integrator can use any of the normal facilities to set this attribute for any DeviceService. These facilities include building it into the service driver, setting the attribute in make/Makefile, or setting it on the fly with the utility setProperty.

Other services may look up the desired DeviceService using the find() method. They can also register to get a callback when that service acquires data by implementing the InstrumentDataListener interface, and registering with the registerDataCallback() method.

Author:
Bob Herlien

Field Summary
protected  java.util.Vector _deferredListeners
           
protected  java.util.Vector _entries
           
protected  java.util.Vector _listeners
           
protected static org.apache.log4j.Logger _log4j
           
 
Method Summary
 void add(DeviceService service)
          If the DeviceService contains a non-null Service Attribute String named registryName, then create a RegistryEntry for it and add it to the InstrumentRegistry.
 void add(RegistryEntry entry)
          Add a RegistryEntry
 void addListener(RegistryListener listener)
          Add a RegisryListener
 DeviceService find(java.lang.String registryName)
          Find a DeviceService by registryName String
 RegistryEntry findEntry(long id)
          Find a RegistryEntry by instrument ID
 RegistryEntry findEntry(java.lang.String registryName)
          Find a RegistryEntry by registryName String
static InstrumentRegistry getInstance()
          Get the singleton InstrumentRegistry
 RegistryEntry registerDataCallback(InstrumentDataListener listener, java.lang.String registryName)
          Register for a Data Callback This function will either register a DataListener for the instrument that matches the registryName, or, if none exists yet, will retain the information and register when such an instrument becomes available.
 java.lang.String registryStatus()
           
 void remove(RegistryEntry entry)
          Remove a RegistryEntry and call the removeRegistrantCallbacks.
 void serviceInstalled(ServiceEvent e)
          serviceInstalled() method for ServiceListener interface
 void serviceRemoved(ServiceEvent e)
          serviceRemoved method for the ServiceListener interface.
 void serviceRequestComplete(ServiceEvent e)
          serviceRequestComplete() method for ServiceListener interface
 
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

_entries

protected java.util.Vector _entries

_listeners

protected java.util.Vector _listeners

_deferredListeners

protected java.util.Vector _deferredListeners
Method Detail

getInstance

public static InstrumentRegistry getInstance()
Get the singleton InstrumentRegistry


addListener

public void addListener(RegistryListener listener)
Add a RegisryListener


findEntry

public RegistryEntry findEntry(java.lang.String registryName)
Find a RegistryEntry by registryName String


findEntry

public RegistryEntry findEntry(long id)
Find a RegistryEntry by instrument ID


find

public DeviceService find(java.lang.String registryName)
Find a DeviceService by registryName String


add

public void add(RegistryEntry entry)
         throws DuplicateIdException
Add a RegistryEntry

Throws:
DuplicateIdException

add

public void add(DeviceService service)
         throws DuplicateIdException
If the DeviceService contains a non-null Service Attribute String named registryName, then create a RegistryEntry for it and add it to the InstrumentRegistry.

Parameters:
service - - The DeviceService to (conditionally) add to the InstrumentRegistry
Throws:
DuplicateIdException

registerDataCallback

public RegistryEntry registerDataCallback(InstrumentDataListener listener,
                                          java.lang.String registryName)
Register for a Data Callback This function will either register a DataListener for the instrument that matches the registryName, or, if none exists yet, will retain the information and register when such an instrument becomes available.

Parameters:
listener - - The InstrumentDataListener to register.
registryName - - String identifying the DeviceService to look up. Required.
Returns:
- RegistryEntry matching the registryName specification. Null if not found; in this case, when the DeviceService comes online, you'll be registered and will get a serviceRegisteredCallback.

remove

public void remove(RegistryEntry entry)
Remove a RegistryEntry and call the removeRegistrantCallbacks.


serviceInstalled

public void serviceInstalled(ServiceEvent e)
serviceInstalled() method for ServiceListener interface

Specified by:
serviceInstalled in interface ServiceListener

serviceRemoved

public void serviceRemoved(ServiceEvent e)
serviceRemoved method for the ServiceListener interface. We look to see if there's a RegistryEntry matching this event, and if so, remove it and call the removeRegistrantCallbacks.

Specified by:
serviceRemoved in interface ServiceListener

serviceRequestComplete

public void serviceRequestComplete(ServiceEvent e)
serviceRequestComplete() method for ServiceListener interface

Specified by:
serviceRequestComplete in interface ServiceListener

registryStatus

public java.lang.String registryStatus()


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.