|
Foundation |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.services.discovery.ServiceTemplate
public class ServiceTemplate
A service request template that describes the type(s) of services expressed in terms of Java classes/interfaces representing the business interfaces and optional service attributes. Service attributes may be used to filter services that satisfy the same service type(s).
A service discovery passport is used to track the discovery services that
process this service request template. This passport is used to ensure that
a request is not processed multiple times by the same discovery service.
Note that if one wishes to resubmit a service discovery request using a
previously submitted service template that one must invoke the
clearPassport()
method to clear the passport for the
service request's new journey.
import com.sas.services.discovery.DiscoveryService; import com.sas.services.discovery.ServiceTemplate; import com.sas.services.security.AuthenticationServiceInterface; ... // define a service template that can be used to // lookup an Authentication Service Class[] desiredServiceTypes = new Class[] { AuthenticationServiceInterface.class}; // create a service lookup template specifying the required // service interface(s) ServiceTemplate serviceTemplate = new ServiceTemplate( desiredServiceTypes); // discover a service satisfying the service template AuthenticationServiceInterface authenticationService = (AuthenticationServiceInterface) DiscoveryService.defaultInstance().findService(serviceTemplate);
An application may desire to find a service that not only satisfies a particular business interface, but also attributes which may be used to differentiate a service from other services satisfying the same interface. When a service is deployed, attributes are added to its service discovery configuration that enable one to locate it based upon the following considerations:
service discovery attribute | 9.1.3 | 9.2 |
---|---|---|
ID | yes | yes |
accessibility to remote clients | yes | yes |
metadata (CMetadata) | yes | yes |
service's component (ServiceComponent) | yes | yes |
host on which a service was deployed | no | yes |
name/value attributes which
a user may have associated to a service deployment, service deployment group, or service | no | yes |
JVM in which a service was deployed | no | yes |
application's service deployment (SoftwareComponent) | no | yes |
service group (Tree) | no | yes |
Note that if multiple service discovery attributes are specified that all attributes must be satisfied in order to satisfy the service request template.
Constructor Summary | |
---|---|
ServiceTemplate()
Constructs a default instance. |
|
ServiceTemplate(java.lang.Class[] serviceTypeClasses)
Constructs an instance of a service template which defines the type of service that's desired an optional attributes that may be used to distinguish among services that satisfy the same service type. |
|
ServiceTemplate(java.lang.Class[] serviceTypeClasses,
ServiceAttributeInterface[] serviceAttributes)
Constructs an instance of a service template which defines the type of service that's desired an optional attributes that may be used to distinguish among services that satisfy the same service type. |
Method Summary | |
---|---|
void |
clearPassport()
Clears the discovery service IDs from the passport. |
void |
defineServiceTemplate(java.lang.Class[] serviceTypeClasses,
ServiceAttributeInterface[] serviceAttributes)
Specifies the service type(s) and optional service attribute(s) that define this service request template. |
ServiceAttributeInterface[] |
getServiceAttributes()
Gets service attributes that are used to distinguish among services that satisfy the same service type(s). |
ServiceTypes |
getServiceTypes()
Gets service capabilities. |
boolean |
isOkToProcess(java.lang.String discoveryServiceId,
boolean stampPassport)
Stamps the discovery passport with the ID of a discovery service which has processed this service request template. |
boolean |
isSatisfiedBy(RemoteServiceInterface service)
Determines whether or not the service satisfies this service template. |
java.lang.String |
toString()
Gets a string representation of this instance. |
Constructor Detail |
---|
public ServiceTemplate() throws InitializationException
InitializationException
- if unable to construct the instance.public ServiceTemplate(java.lang.Class[] serviceTypeClasses) throws InitializationException
serviceTypeClasses
- Java classes that the service should be,
extend, or implement.
InitializationException
- if unable to construct the instance.public ServiceTemplate(java.lang.Class[] serviceTypeClasses, ServiceAttributeInterface[] serviceAttributes) throws InitializationException
serviceTypeClasses
- Java class(es) that the service should be,
extend, or implement.serviceAttributes
- Filter criteria that may be used to qualify
matches.
This parameter should be set to null
if no additional filter criteria is required to
refine requested service types.
InitializationException
- if unable to construct the instance.Method Detail |
---|
public final void defineServiceTemplate(java.lang.Class[] serviceTypeClasses, ServiceAttributeInterface[] serviceAttributes) throws InitializationException
serviceTypeClasses
- Java class(es) that the service should be, extend, or
implement.serviceAttributes
- Filter criteria that may be used to qualify matches.
This parameter should be set to null
if no additional filter criteria is required to
refine requested service types.
InitializationException
- if unable to construct the instance.public final ServiceTypes getServiceTypes()
public final ServiceAttributeInterface[] getServiceAttributes()
public final boolean isSatisfiedBy(RemoteServiceInterface service)
service
- A candidate service which will be checked to determine
if it satisfies all required service types and optional
attributes.
true
if the service satisfies the requested
service template,
false
if it doesn't.public final boolean isOkToProcess(java.lang.String discoveryServiceId, boolean stampPassport)
discoveryServiceId
- Discovery service ID which has processed a
service request using this template.stampPassport
- true
if the passport should be
stamped with the ID if its not currently in
in the passport.
true
if the discovery service has already
processed this request.public final void clearPassport()
The passport maintains a set of IDs for each discovery service which processes the service request.
public final java.lang.String toString()
toString
in class java.lang.Object
|
Foundation |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |