***  This class provides Binary Compatibility only, not Source Compatibility  ***

com.sas.services.discovery
Class ServiceComponentAttribute

com.sas.services.discovery.ServiceComponentAttribute
All Implemented Interfaces:
ServiceAttributeInterface, java.io.Serializable

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.

AttributeDescription
idthe fully-qualified metadata ID of the ServiceComponent that represents a foundation service (i.e. ServiceComponent.Id)
namethe 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

Examples are provided to find a service by its:

Example 1: Find a service using its name

To find a service using its name, define a service template that specifies one or more interfaces that the desired service must implement and this attribute initialized to the service's name.

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);

Example 2: Find a service using its metadata ID

To find a service using its metadata ID define a service template that specifies one or more interfaces that the desired service must implement and this attribute initialized to the desired service's ID.

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.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);

Example 3: Find a service using its name and metadata ID

To find a service using the service's name and metadata ID define a service template that specifies the desired service interface(s) and this attribute initialized to the desired service's name and ID.

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.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);

Since:
1.2
See Also:
Serialized Form

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.ServiceComponent serviceComponent)
          Constructs a service discovery attribute which may be used to lookup a service represented by the specified by a local JOMA ServiceComponent.
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 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

runtimeId

public java.lang.String runtimeId
The service's runtime ID.

Constructor Detail

ServiceComponentAttribute

public ServiceComponentAttribute()
Constructs a default instance with the application service deployment ID and name initialized to null.


ServiceComponentAttribute

public 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.

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.

Parameters:
attributeName - The metadata element's name or null if unspecified.
attributeId - The metadata element's id (i.e. "A5K2EL3N.B000000B") or null if unspecified.
See Also:
ServiceComponentAttribute(com.sas.metadata.ServiceComponent), ServiceComponentAttribute(com.sas.metadata.remote.ServiceComponent)

ServiceComponentAttribute

public 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.

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.

Parameters:
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.
See Also:
ServiceComponentAttribute(com.sas.metadata.ServiceComponent), ServiceComponentAttribute(com.sas.metadata.remote.ServiceComponent)

ServiceComponentAttribute

public ServiceComponentAttribute(com.sas.metadata.ServiceComponent serviceComponent)
                          throws java.lang.IllegalArgumentException
Constructs a service discovery attribute which may be used to lookup a service represented by the specified by a local JOMA 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.

Parameters:
serviceComponent - A metadata element that represents a foundation service.
Throws:
java.lang.IllegalArgumentException - if a null parameter is specified or if the ServiceComponent does not represent a foundation service.
See Also:
ServiceComponentAttribute(String, String, String), ServiceComponentAttribute(com.sas.metadata.remote.ServiceComponent)

ServiceComponentAttribute

public ServiceComponentAttribute(com.sas.metadata.remote.ServiceComponent serviceComponent)
                          throws java.lang.IllegalArgumentException
Constructs a service discovery attribute which may be used to lookup a service represented by the specified by a remote JOMA 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.

Parameters:
serviceComponent - A remote JOMA metadata element that represents a foundation service.
Throws:
java.lang.IllegalArgumentException - if a null parameter is specified or if the ServiceComponent does not represent a foundation service.
See Also:
ServiceComponentAttribute(String, String, String), ServiceComponentAttribute(com.sas.metadata.ServiceComponent)
Method Detail

getFieldNameToValueMap

public java.util.Map getFieldNameToValueMap()
Gets a map of this attribute's fields and their values which includes the runtimeId plus fields defined in the superclass.

Overrides:
getFieldNameToValueMap in class MetadataAttribute
Returns:
String summarizing the state of this attribute.
See Also:
MetadataAttribute.getFieldNameToValueMap()

***  This class provides Binary Compatibility only, not Source Compatibility  ***




Copyright © 2009 SAS Institute Inc. All Rights Reserved.