ibspan.tss.messaging
Class ServiceFinder

java.lang.Object
  extended by ibspan.tss.messaging.ServiceFinder

public class ServiceFinder
extends Object

This class provides the agent with finding service providers registered in Directory Facilitator. It:

  1. searches for already registered service providers and
  2. subscribes for the providers which will register in the future.
Any time the service appears in the system the agent is woken up.

Author:
Maciej Gawinecki

Constructor Summary
ServiceFinder(Agent a, ServiceDescription sd)
          Constructs ServiceFinder to search and subscribe for the given service
 
Method Summary
protected  Object createKey(DFAgentDescription dfd)
          Creates the key, which will be used for selecting particular agent(s) from list of agent providing the service, e.g. personal agent representing user with particular userID.
 AID getOne()
          Returns agent providing the service.
 AID getOne(Object key)
          Returns agent providing the service matching the given key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceFinder

public ServiceFinder(Agent a,
                     ServiceDescription sd)
              throws ServiceFinderException
Constructs ServiceFinder to search and subscribe for the given service

Parameters:
a - is owning agent
myService - is description of service this finder will look for.
Throws:
ServiceFinderException - throw when the finder have problems with finding the service.
Method Detail

getOne

public AID getOne()
Returns agent providing the service. In current implementation returns first agent from list.

Returns:
agent providing the service or null if no service has been found.

getOne

public AID getOne(Object key)
Returns agent providing the service matching the given key. The for service description is created by createKey() method.

Parameters:
key - is key describing particular agent(s).
Returns:
agent identifier
See Also:
createKey(DFAgentDescription)

createKey

protected Object createKey(DFAgentDescription dfd)
Creates the key, which will be used for selecting particular agent(s) from list of agent providing the service, e.g. personal agent representing user with particular userID.

Parameters:
dfd - agent description
Returns:
the key for the given agent description