*** This class provides Binary Compatibility only, not Source Compatibility ***
Class ServiceDeploymentAttribute
- All Implemented Interfaces:
ServiceAttributeInterface,Serializable
When a service is deployed, a ServiceDeploymentAttribute
will be added to its service discovery configuration representing the
deployment that owns the service.
An application's service deployment is represented by a metadata
SoftwareComponent.
| Attribute | Description |
|---|---|
| id | the fully-qualified metadata ID of the
SoftwareComponent that represents the application's service deployment
(i.e. SoftwareComponent.Id) |
| name | the name of the
SoftwareComponent that represents the application's service deployment
(i.e. SoftwareComponent.Name) |
Any values that are not specified should be null to
indicate a "don't care".
Examples
Examples are provided to find a service that belongs a particular application's service deployment using the deployment's:
Example 1: Find a service using an application's service deployment's name
To find a service that belongs to an application's service deployment using the name of the service deployment, define a service template that specifies one or more interfaces that the desired service must implement and this attribute initialized to the desired service deployment name.The following example shows how to define a service template that can be used to discover an Authentication service that belongs to an application service deployment named "My Services".
import com.sas.services.discovery.DiscoveryService;
import com.sas.services.discovery.ServiceAttributeInterface;
import com.sas.services.discovery.ServiceDeploymentAttribute;
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 the application's service deployment
String serviceDeploymentName = "My Services";
// 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 name.
ServiceAttributeInterface[] serviceAttributes =
new ServiceAttributeInterface[] {
new ServiceDeploymentAttribute(
serviceDeploymentName,
null)};// don't care about the service deployment's metadata ID
// 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);
Example 2: Find a service using an application's service deployment's metadata ID
To find a service that belongs to an application's service deployment using the metadata ID of the service deployment, define a service template that specifies one or more interfaces that the desired service must implement and this attribute initialized to the desired service deployment's ID.The following example shows how to define a service template that can be used to discover an Authentication service that belongs to an application service deployment whose metadata ID is "A0000001.ABABABAB".
import com.sas.services.discovery.DiscoveryService;
import com.sas.services.discovery.ServiceAttributeInterface;
import com.sas.services.discovery.ServiceDeploymentAttribute;
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 SoftwareComponent.Id for the metadata software component
// that represents the application's service deployment
String serviceDeploymentId = "A0000001.ABABABAB";
// 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 ServiceDeploymentAttribute(
null,// don't care about the service deployment's name
serviceDeploymentId)};
// 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);
Example 3: Find a service using an application's service deployment's name and metadata ID
To find a service that belongs to an application's service deployment using the name and metadata ID of the service deployment, define a service template that specifies the desired service interface(s) and this attribute initialized to the desired service deployment's name and ID.The following example shows how to define a service template that can be used to discover an Authentication service that belongs to an application service deployment whose name is "My Services" and whose metadata ID is "A0000001.ABABABAB".
import com.sas.metadata.remote.SoftwareComponent;
import com.sas.services.discovery.DiscoveryService;
import com.sas.services.discovery.ServiceAttributeInterface;
import com.sas.services.discovery.ServiceDeploymentAttribute;
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 SoftwareComponent metadata object
// representing a application's service deployment, determine
// its name and metadata ID
String serviceDeploymentName = softwareComponent.getName();
String serviceDeploymentID = softwareComponent.getFQID();
// 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 name and metadata ID.
ServiceAttributeInterface[] serviceAttributes =
new ServiceAttributeInterface[] {
new ServiceDeploymentAttribute(
serviceDeploymentName,
serviceDeploymentID)};
// 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);
- Since:
- 9.2
- See Also:
-
Field Summary
Fields inherited from class com.sas.services.discovery.MetadataAttribute
classIdentifier, elementType, id, name -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a default instance with the application service deployment ID and name initialized tonull.ServiceDeploymentAttribute(com.sas.metadata.remote.SoftwareComponent serviceDeployment) Constructs a service discovery attribute which may be used to lookup a service which belongs to the specified application service deployment using the ID and name for the specified a remote JOMASoftwareComponent.ServiceDeploymentAttribute(String serviceDeploymentName, String serviceDeploymentId) Constructs a service discovery attribute which may be used to lookup a service which belongs to the specified application service deployment. -
Method Summary
Methods inherited from class com.sas.services.discovery.MetadataAttribute
getFieldNameToValueMapMethods inherited from class com.sas.services.AbstractServiceAttribute
equals, hashCode, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
ServiceDeploymentAttribute
public ServiceDeploymentAttribute()Constructs a default instance with the application service deployment ID and name initialized tonull. -
ServiceDeploymentAttribute
public ServiceDeploymentAttribute(String serviceDeploymentName, String serviceDeploymentId) Constructs a service discovery attribute which may be used to lookup a service which belongs to the specified application service deployment.Use this constructor if you don't have a
SoftwareComponentthat 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.- Parameters:
serviceDeploymentName- The metadata element's name ornullif unspecified.serviceDeploymentId- The metadata element's id (i.e. "A5K2EL3N.B000000B") ornullif unspecified.- See Also:
-
ServiceDeploymentAttribute
public ServiceDeploymentAttribute(com.sas.metadata.remote.SoftwareComponent serviceDeployment) throws IllegalArgumentException Constructs a service discovery attribute which may be used to lookup a service which belongs to the specified application service deployment using the ID and name for the specified a remote JOMASoftwareComponent.Use this constructor if you have a
SoftwareComponentthat 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.- Parameters:
serviceDeployment- A remote JOMA metadata element that represents an application's foundation service deployment.- Throws:
IllegalArgumentException- if anullparameter is specified or if theSoftwareComponentdoes not represent an application's foundation service deployment.- See Also:
-