| org.cougaar.core.plugin.ComponentPlugin org.cougaar.servicediscovery.plugin.SimpleSDClientPlugin
All known Subclasses: org.cougaar.pizza.plugin.SDClientPlugin,
SimpleSDClientPlugin | public class SimpleSDClientPlugin extends ComponentPlugin (Code) | | Simple ServiceDiscovery ClientPlugin, responsible for initiating queries for services,
taking the resulting service pointer, and sending a Relay to the Provider requesting service.
Service Discovery is initiated by receiving a Find Providers task, and looking for the single Role
indicated on the AS Prepositional Phrase.
Sends a Disposition on the FindProviders Task when it gets a Relationship
with a provider for the service.
This Plugin is written to be extended (or copied). See the pizza module for an example of doing this.
Limitations: not quiescent aware, doesn't handle time-phased relationships,
not guaranteed to work with persistence and restarts, and assumes that providers
will not revoke relationships or otherwise change their mind.
|
Method Summary | |
protected void | execute() Issue MMQueries for FindProviders Tasks, ServiceContractRelays for responses to MMQueries,
and Dispositions on the FindProviders Tasks when those Relays are filled in with a Contract. | protected DomainService | getDomainService() Get the DomainService set by reflection, for getting pointers to Factories. | protected UnaryPredicate | getFindProvidersPredicate() Predicate to get the FindProviders Tasks. | protected Entity | getLocalEntity() Get the local (self) Entity - from a local cache, or by querying the Blackboard. | protected PlanningFactory | getPlanningFactory() | protected Role | getRole(Task findProvidersTask) Return the Role (indirect object) on the Constants.Prepositions.AS Prep Phrase in the given
FindProviders Task, if any -- this is the Provider Role we will look for. | protected Role | getRole(ServiceDescription serviceDescription) Retrieve the Role that the Provider is offering out of the ServiceDescription. | protected SDFactory | getSDFactory() Get the SDFactory. | protected ServiceInfoScorer | getServiceInfoScorer(Role role, Task fpTask) Create a scoring function to weigh different services registered in the YP, for use
by the Matchmaker. | public void | load() Load other services, particularly those not essential to operations. | protected void | queryServices(Role role, Task findProvidersTask) Send an
MMQueryRequest to the Matchmaker, requesting a provider
with the given
Role , satisfying the given Task. | protected void | requestServiceContract(ServiceDescription serviceDescription) Create and publish a relay with a service request for the specified Role, to the Provider
specified in the serviceDescription. | public void | setDomainService(DomainService domainService) | protected void | setupSubscriptions() Subscribe to MMRequests (requests to the Matchmaker),
ServiceContractRelays (where we'll get responses from the Providers),
and FindProviders Tasks (requests to us to do ServiceDiscovery). | public void | unload() | protected void | updateFindProvidersTaskDispositions(Collection changedServiceContractRelays) For each ServiceContractRelay that changes and has a ServiceContract, find the
un-disposed FindProviders Task that requested a Provider with the given Role, and
dispose it as succesful. |
execute | protected void execute()(Code) | | Issue MMQueries for FindProviders Tasks, ServiceContractRelays for responses to MMQueries,
and Dispositions on the FindProviders Tasks when those Relays are filled in with a Contract.
For each new FindProviders Task, issue an MMQuery to the Matchmaker, looking for the
specified Role.
If an MMQuery changes, issue a new ServiceContractRelay to the first named Provider
that was found.
If a ServiceContractRelay changes, update the Disposition on the original FindProviders
Task if we've now found a Provider for the needed Service.
|
getDomainService | protected DomainService getDomainService()(Code) | | Get the DomainService set by reflection, for getting pointers to Factories.
|
getFindProvidersPredicate | protected UnaryPredicate getFindProvidersPredicate()(Code) | | Predicate to get the FindProviders Tasks. In the off-chance that your verb is
slightly different, you can over-ride this method to point to your
domain-specific Verb Constant.
Note that it is not a constant, just so it can be over-ridden.
|
getLocalEntity | protected Entity getLocalEntity()(Code) | | Get the local (self) Entity - from a local cache, or by querying the Blackboard.
the local (self) Entity |
getRole | protected Role getRole(Task findProvidersTask)(Code) | | Return the Role (indirect object) on the Constants.Prepositions.AS Prep Phrase in the given
FindProviders Task, if any -- this is the Provider Role we will look for.
Parameters: findProvidersTask - Task which should contain an AS Prepositional Phrase Role on AS Phrase, indicate Role desired from ServiceDiscovery -- may be null |
getRole | protected Role getRole(ServiceDescription serviceDescription)(Code) | | Retrieve the Role that the Provider is offering out of the ServiceDescription.
Note that this assumes the role is under the CommercialServiceScheme, using the
Domain's Constants file. Extenders will over-ride this method.
Parameters: serviceDescription - The Description of the Service as advertised in the YP. the Role advertised by the Provider, or null if none found. |
getSDFactory | protected SDFactory getSDFactory()(Code) | | Get the SDFactory. Factory for service discovery domain
|
getServiceInfoScorer | protected ServiceInfoScorer getServiceInfoScorer(Role role, Task fpTask)(Code) | | Create a scoring function to weigh different services registered in the YP, for use
by the Matchmaker.
In this case, create a function that requires the given (Commercial) role.
Extenders of this plugin may over-ride this method to use a different function.
Parameters: role - the Role to look for Parameters: fpTask - The FindProviders task this will satisfy the scoring function to hand the Matchmaker |
load | public void load()(Code) | | Load other services, particularly those not essential to operations.
In this case, use the DomainService to get Factories and release it.
Also get the Logging Service.
|
queryServices | protected void queryServices(Role role, Task findProvidersTask)(Code) | | Send an
MMQueryRequest to the Matchmaker, requesting a provider
with the given
Role , satisfying the given Task.
Extenders of this plugin might choose to over-ride this method, though it usually will
not be necessary.
Parameters: role - The Role to request Parameters: findProvidersTask - The Task whose request this will satisfy |
requestServiceContract | protected void requestServiceContract(ServiceDescription serviceDescription)(Code) | | Create and publish a relay with a service request for the specified Role, to the Provider
specified in the serviceDescription.
Parameters: serviceDescription - the Matchmaker tells us about the possible service provider in this Service Description |
setDomainService | public void setDomainService(DomainService domainService)(Code) | | Used by the binding utility through reflection to set my DomainService
|
setupSubscriptions | protected void setupSubscriptions()(Code) | | Subscribe to MMRequests (requests to the Matchmaker),
ServiceContractRelays (where we'll get responses from the Providers),
and FindProviders Tasks (requests to us to do ServiceDiscovery).
|
unload | public void unload()(Code) | | Release any services retrieved during load() -- in this case, the LoggingService and DomainService
|
updateFindProvidersTaskDispositions | protected void updateFindProvidersTaskDispositions(Collection changedServiceContractRelays)(Code) | | For each ServiceContractRelay that changes and has a ServiceContract, find the
un-disposed FindProviders Task that requested a Provider with the given Role, and
dispose it as succesful.
Assumes there will be one un-disposed FindProviders Task per Role.
|
|
|