ist.palcom.contingency.manager
Class ResourceDirectory

java.lang.Object
  extended by ist.palcom.services.AbstractService
      extended by ist.palcom.contingency.manager.ResourceDirectory
All Implemented Interfaces:
IResourceDirectory, Service, IHgraphNode

public class ResourceDirectory
extends AbstractService
implements IResourceDirectory

ResourceDirectory is an entity that caches the resources currently visible from the device where the resource directory resides. Further it can be queried for the available resources or requested to listen for the pop up or disappearance of the resource or its alternate.


Field Summary
 
Fields inherited from class ist.palcom.services.AbstractService
_node, connectionsMonitor, context, info, siid
 
Fields inherited from interface ist.palcom.contingency.manager.IResourceDirectory
SERVICE_NAME, URN_SUFFIX
 
Fields inherited from interface ist.palcom.hgraph.IHgraphNode
CHILD_NAME_CLASH, CIRCULARITY_CLASH, COMMAND_OR_NODE_MISSING, ERROR, HANDLER_MISSING, INVOKATOR_MISSING, LISTENER_MISSING, NODE_NOT_CHILD, PATH_MISSING, SIBLING_ALREADY_EXISTS, SIBLING_NONEXISTENT, SIBLING_REFERENCE_ALREADY_EXISTS, SIBLING_REFERENCE_NONEXISTENT, STATUS_OK, VALUE_ALREADY_EXISTS, VALUE_NOT_PRESENT
 
Constructor Summary
ResourceDirectory(DeviceContext context, java.lang.String serviceName)
           
 
Method Summary
 java.util.List<Device> getAlternateDevices(SameResourceTypeRelation deviceEquivRelation, java.lang.Object deviceDesc)
          Return the list of devices that are equivalent to the given device according to the specified equivalence relation.
 java.util.List<Service> getAlternateServices(SameResourceTypeRelation serviceEquivRelation, SingleServiceDecl decl)
          Return the list of services that are equivalent to the given service according to the specified equivalence relation.
 java.util.List<Device> getDevices()
          Get available devices cached in the Resource Directory.
 PalcomThread getResourceDirectoryThread()
          Returns a thread for receiving resource queries and requests for resource monitoring.
 ServiceID getServiceID()
           
 java.util.List<Service> getServices()
          Get available services cached in the Resource Directory
 void registerResourceListener(ResourceEventType eventType, ResourceQuery query, PalcomThread listener)
          Register a listener for the occurence of a particular event type (resource pop up/resource disappearance) on the given resource.
 void start()
          Start the service.
 void stop()
           
 void unregisterResourceListener(ResourceEventType eventType, URN urn)
          Unregister a listener for the occurence of a particular event type (resource pop up/resource disappearance) on the given resource.
 
Methods inherited from class ist.palcom.services.AbstractService
addNodeChild, addServiceProxyListener, connectionClosed, connectionCreated, connectTo, disconnectFrom, getChildIterator, getConnections, getFuncFunc, getNodeName, getNodeParent, getPath, getRemoteServiceProxy, getSelector, getServiceInfo, getServiceInstanceID, getServiceProxy, getSiblingFunc, getValueFunc, hasChildNamed, isAncestorOf, remoteServiceProxyIterator, removeNodeChild, removeServiceProxyListener, sendToAll, setGroupID, setLocalSID, setName, setNodeName, setNodeParent, setServiceInstanceID, setServiceProxy, setStatus, setTopic, toXML, toXMLFull, toXMLFullRecursively, toXMLRecursively, updatePath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceDirectory

public ResourceDirectory(DeviceContext context,
                         java.lang.String serviceName)
                  throws java.io.IOException
Throws:
java.io.IOException
Method Detail

getServiceID

public ServiceID getServiceID()
Specified by:
getServiceID in class AbstractService
Returns:
the ServiceID of the service.

registerResourceListener

public void registerResourceListener(ResourceEventType eventType,
                                     ResourceQuery query,
                                     PalcomThread listener)
Description copied from interface: IResourceDirectory
Register a listener for the occurence of a particular event type (resource pop up/resource disappearance) on the given resource.

Specified by:
registerResourceListener in interface IResourceDirectory

unregisterResourceListener

public void unregisterResourceListener(ResourceEventType eventType,
                                       URN urn)
Description copied from interface: IResourceDirectory
Unregister a listener for the occurence of a particular event type (resource pop up/resource disappearance) on the given resource.

Specified by:
unregisterResourceListener in interface IResourceDirectory

getDevices

public java.util.List<Device> getDevices()
Description copied from interface: IResourceDirectory
Get available devices cached in the Resource Directory.

Specified by:
getDevices in interface IResourceDirectory

getServices

public java.util.List<Service> getServices()
Description copied from interface: IResourceDirectory
Get available services cached in the Resource Directory

Specified by:
getServices in interface IResourceDirectory

getAlternateDevices

public java.util.List<Device> getAlternateDevices(SameResourceTypeRelation deviceEquivRelation,
                                                  java.lang.Object deviceDesc)
Description copied from interface: IResourceDirectory
Return the list of devices that are equivalent to the given device according to the specified equivalence relation. This includes the device itself (when it is available). The device description to pass to this method depends on the used equivalence relation.

Specified by:
getAlternateDevices in interface IResourceDirectory
Parameters:
deviceEquivRelation - - equivalence relation to compare the devices
deviceDesc - - description of the requested device
Returns:
List of devices equivalent to the given device.

getAlternateServices

public java.util.List<Service> getAlternateServices(SameResourceTypeRelation serviceEquivRelation,
                                                    SingleServiceDecl decl)
Description copied from interface: IResourceDirectory
Return the list of services that are equivalent to the given service according to the specified equivalence relation. This includes the service itself (when it is available).

Specified by:
getAlternateServices in interface IResourceDirectory
Parameters:
serviceEquivRelation - - equivalence relation to compare the devices
decl - - description of the requested service
Returns:
List of services equivalent to the given device.

getResourceDirectoryThread

public PalcomThread getResourceDirectoryThread()
Returns a thread for receiving resource queries and requests for resource monitoring.

Specified by:
getResourceDirectoryThread in interface IResourceDirectory
Returns:
The resource directory thread.

start

public void start()
           throws java.io.IOException
Description copied from class: AbstractService
Start the service. The LocalSID must be set before calling this method (through a constructor, or through a call to the setLocalSID method). If the service is started already, nothing happens. The DiscoveryManager will be updated with info about the service.

Specified by:
start in interface IResourceDirectory
Overrides:
start in class AbstractService
Throws:
java.io.IOException

stop

public void stop()
          throws java.io.IOException
Specified by:
stop in interface IResourceDirectory
Overrides:
stop in class AbstractService
Throws:
java.io.IOException