|
| Foundation |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
com.sas.services.discovery.ServiceComponentAttribute
public final class ServiceComponentAttribute
A foundation service discovery attribute which represents an foundation service.
When a service is deployed, a ServiceComponentAttribute
will be added to its service discovery configuration representing the
the service.
A service is represented by a metadata ServiceComponent.
| Attribute | Description |
|---|---|
| id | the fully-qualified metadata ID of the
ServiceComponent that represents a foundation service
(i.e. ServiceComponent.Id) |
| name | the name of the
ServiceComponent that represents a foundation service
(i.e. ServiceComponent.Name) |
Any values that are not specified should be null to
indicate a "don't care".
Examples are provided to find a service by its:
The following example shows how to define a service template that can be used to discover an Authentication service that is named "Authentication Service".
import com.sas.services.discovery.DiscoveryService;
import com.sas.services.discovery.ServiceAttributeInterface;
import com.sas.services.discovery.ServiceComponentAttribute;
import com.sas.services.discovery.ServiceTemplate;
import com.sas.services.security.AuthenticationServiceInterface;
...
// specify the desired service type(s)
Class[] desiredServiceTypes = new Class[] {
AuthenticationServiceInterface.class};
// the name of desired service
String serviceName = "Authentication Service";
// specify the optional attributes to be used to qualify a discovery lookup
// to include only those services with the specified name.
ServiceAttributeInterface[] serviceAttributes =
new ServiceAttributeInterface[] {
new ServiceDeploymentAttribute(
serviceName,
null)};// don't care about the service's metadata ID
// create a service lookup template specifying the required
// service interface(s) and a service attribute for a
// the desired service
ServiceTemplate serviceTemplate = new ServiceTemplate(
desiredServiceTypes,
serviceAttributes);
// discover a service satisfying the service template
AuthenticationServiceInterface authenticationService = (AuthenticationServiceInterface)
DiscoveryService.defaultInstance().findService(serviceTemplate);
The following example shows how to define a service template that can be used to discover an Authentication service whose metadata ID is "A0000001.12341234".
import com.sas.metadata.remote.ServiceComponent;
import com.sas.services.discovery.DiscoveryService;
import com.sas.services.discovery.ServiceAttributeInterface;
import com.sas.services.discovery.ServiceComponentAttribute;
import com.sas.services.discovery.ServiceTemplate;
import com.sas.services.security.AuthenticationServiceInterface;
...
// specify the desired service type(s)
final Class[] desiredServiceTypes = new Class[] {
AuthenticationServiceInterface.class};
// The ServiceComponent.Id for the metadata service component
// that represents the desired service
String serviceMetadataID = "A0000001.12341234";
// specify the optional attributes to be used to qualify a discovery lookup
// to include only those services which belong to an application service
// deployment with the specified metadata ID.
ServiceAttributeInterface[] serviceAttributes =
new ServiceAttributeInterface[] {
new ServiceComponentAttribute(
null,// don't care about the service's name
serviceMetadataID)};
// create a service lookup template specifying the required
// service interface(s) and a service attribute for a
// service whose metadata ID matches the specified attribute
ServiceTemplate serviceTemplate = new ServiceTemplate(
desiredServiceTypes,
serviceAttributes);
// discover a service satisfying the service template
AuthenticationServiceInterface authenticationService = (AuthenticationServiceInterface)
DiscoveryService.defaultInstance().findService(serviceTemplate);
The following example shows how to define a service template that can be used to discover an Authentication service that whose name and ID are obtained from the metadata ServiceComponent that represents the desired service.
import com.sas.metadata.remote.ServiceComponent;
import com.sas.services.discovery.DiscoveryService;
import com.sas.services.discovery.ServiceAttributeInterface;
import com.sas.services.discovery.ServiceComponentAttribute;
import com.sas.services.discovery.ServiceTemplate;
import com.sas.services.security.AuthenticationServiceInterface;
...
// specify the desired service type(s)
final Class[] desiredServiceTypes = new Class[] {
AuthenticationServiceInterface.class};
// given the metadata ServiceComponent metadata object
// representing a foundation service, determine
// the service's name and metadata ID
ServiceComponent serviceComponent = ...
String serviceName = serviceComponent.getName();
String serviceMetadataID = serviceComponent.getFQID();
// specify the optional attributes to be used to qualify a discovery lookup
// to include only those services which match the specified name and metadata ID.
ServiceAttributeInterface[] serviceAttributes =
new ServiceAttributeInterface[] {
new ServiceDeploymentAttribute(
serviceName,
serviceMetadataID)};
// create a service lookup template specifying the required
// service interface(s) and a service attribute for a
// service that belongs to a particular application service deployment
ServiceTemplate serviceTemplate = new ServiceTemplate(
desiredServiceTypes,
serviceAttributes);
// discover a service satisfying the service template
AuthenticationServiceInterface authenticationService = (AuthenticationServiceInterface)
DiscoveryService.defaultInstance().findService(serviceTemplate);
| Field Summary | |
|---|---|
java.lang.String |
runtimeId
The service's runtime ID. |
| Fields inherited from class com.sas.services.discovery.MetadataAttribute |
|---|
classIdentifier, elementType, id, name |
| Constructor Summary | |
|---|---|
ServiceComponentAttribute()
Constructs a default instance with the application service deployment ID and name initialized to null. |
|
ServiceComponentAttribute(com.sas.metadata.remote.ServiceComponent serviceComponent)
Constructs a service discovery attribute which may be used to lookup a service represented by the specified by a remote JOMA ServiceComponent. |
|
ServiceComponentAttribute(java.lang.String attributeName,
java.lang.String attributeId)
Constructs a service discovery attribute which may be used to lookup a service which belongs to the specified application service deployment. |
|
ServiceComponentAttribute(java.lang.String attributeName,
java.lang.String attributeId,
java.lang.String runtimeServiceId)
Constructs a service discovery attribute which may be used to lookup a service which belongs to the specified application service deployment. |
|
| Method Summary | |
|---|---|
java.util.Map<java.lang.String,java.lang.String> |
getFieldNameToValueMap()
Gets a map of this attribute's fields and their values which includes the runtimeId plus fields defined in the superclass. |
| Methods inherited from class com.sas.services.AbstractServiceAttribute |
|---|
equals, hashCode, toString |
| Field Detail |
|---|
public java.lang.String runtimeId
| Constructor Detail |
|---|
public ServiceComponentAttribute()
null.
public ServiceComponentAttribute(java.lang.String attributeName,
java.lang.String attributeId)
Use this constructor if you don't have a SoftwareComponent that
represents an application's service deployment and you want to initialize
a service discovery attribute that can be used to lookup a service that
belongs to a particular service deployment using its ID and/or name.
attributeName - The metadata element's name or null if unspecified.attributeId - The metadata element's id (i.e. "A5K2EL3N.B000000B") or
null if unspecified.ServiceComponentAttribute(ServiceComponent)
public ServiceComponentAttribute(java.lang.String attributeName,
java.lang.String attributeId,
java.lang.String runtimeServiceId)
Use this constructor if you don't have a SoftwareComponent that
represents an application's service deployment and you want to initialize
a service discovery attribute that can be used to lookup a service that
belongs to a particular service deployment using its ID and/or name.
attributeName - The metadata element's name or null if unspecified.attributeId - The metadata element's id (i.e. "A5K2EL3N.B000000B") or
null if unspecified.runtimeServiceId - The service's runtime id or null if unspecified.ServiceComponentAttribute(ServiceComponent)
public ServiceComponentAttribute(com.sas.metadata.remote.ServiceComponent serviceComponent)
throws java.lang.IllegalArgumentException
ServiceComponent.
Use this constructor if you have a
ServiceComponent that
represents a foundation service and you want to initialize
a service discovery attribute that can be used to lookup this service
by its ID and/or name.
serviceComponent - A remote JOMA metadata element that represents a foundation service.
java.lang.IllegalArgumentException - if a null parameter is specified
or if the ServiceComponent does not represent a foundation service.ServiceComponentAttribute(String, String, String)| Method Detail |
|---|
public java.util.Map<java.lang.String,java.lang.String> getFieldNameToValueMap()
getFieldNameToValueMap in class MetadataAttributeMetadataAttribute.getFieldNameToValueMap()
|
| Foundation |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||