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

Class NameValueAttribute

java.lang.Object
com.sas.services.AbstractServiceAttribute
com.sas.services.discovery.NameValueAttribute
All Implemented Interfaces:
ServiceAttributeInterface, Serializable

@SASScope("ALL") @BinaryCompatibilityOnly public class NameValueAttribute extends AbstractServiceAttribute
A foundation service discovery attribute which may be used to find a service based upon a name/value.

When a service is deployed, a NameValueAttribute will be added to its service discovery configuration for each Keyword that is associated to the service, its deployment group, or its application service deployment.

Defining Name/Value Keywords

Arbitrary user-defined name/value keywords may be associated with a service using the Foundation Services Manager plug-in to the SAS Management Console. The plug-in provides the capability to define zero or more Keyword metadata objects whose Name and Description attributes correspond to the desired name/value.

Examples

Examples are provided to find a service using a user-defined name/value attribute:

Example 1: A name/value keyword

To find a service that has a name/value, define a service template that specifies one or more interfaces that the desired service must implement and this attribute initialized to the desired name/value.

The following example shows how to define a service template that can be used to discover an Authentication Service which is associated with a Name/Value of "sas.application.name"/"Solutions".


import com.sas.services.discovery.DiscoveryService;
import com.sas.services.discovery.NameValueAttribute;
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[] desiredServiceInterface = new Class[] {
   AuthenticationServiceInterface.class };

// look for a service with the desired name/value 
ServiceAttributeInterface serviceAttributes = new ServiceAttributeInterface[] {
   new NameValueAttribute(
      "sas.application.name",
      "Solutions") };

// create a service lookup template specifying the required
// service interface(s) and a service attribute for a
// service that is associated with the desired name/value
ServiceTemplate serviceTemplate = new ServiceTemplate(
   desiredServiceInterface,
   serviceAttributes);

// discover a service satisfying the service template
AuthenticationServiceInterface authenticationService = (AuthenticationServiceInterface)
   DiscoveryService.defaultInstance().findService(serviceTemplate);

 

Example 2: Two name/value keywords

To find a service that has desired name/value keywords define a service template that specifies one or more interfaces that the desired service must implement and two instances of this attribute initialized to the desired name/value.

The following example shows how to define a service template that can be used to discover an Authentication Service which is associated with the following Name/Value keywords "sas.application.name"/"Solutions" and "sas.application.name"/"Web Report Studio".


import com.sas.services.discovery.DiscoveryService;
import com.sas.services.discovery.NameValueAttribute;
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[] desiredServiceInterface = new Class[] {
   AuthenticationServiceInterface.class };

// look for a service with the desired name/value keywords
ServiceAttributeInterface serviceAttributes = new ServiceAttributeInterface[] {
   new NameValueAttribute(
      "sas.application.name",
      "Solutions"),
   new NameValueAttribute(
      "sas.application.name",
      "Web Report Studio") };

// create a service lookup template specifying the required
// service interface(s) and a service attribute for a
// service that is associated with the desired name/value
ServiceTemplate serviceTemplate = new ServiceTemplate(
   desiredServiceInterface,
   serviceAttributes);

// discover a service satisfying the service template
AuthenticationServiceInterface authenticationService = (AuthenticationServiceInterface)
   DiscoveryService.defaultInstance().findService(serviceTemplate);

 
Since:
9.2
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    String
    A name describing an arbitrary type of attribute.
    String
    The value of the named attribute.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a default instance with a null name and null value.
    NameValueAttribute(String attributeName)
    Constructs an instance initialized with the specified name that is associated with a null value.
    NameValueAttribute(String attributeName, String attributeValue)
    Constructs an instance initialized with the specified named attribute and its associated value.
  • Method Summary

    Modifier and Type
    Method
    Description
    Map<String,String>
    Gets a map keyed by the String names of the following attributes to their values.

    Methods inherited from class com.sas.services.AbstractServiceAttribute

    equals, hashCode, toString

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • name

      public String name
      A name describing an arbitrary type of attribute.
    • value

      public String value
      The value of the named attribute.
  • Constructor Details

    • NameValueAttribute

      public NameValueAttribute()
      Constructs a default instance with a null name and null value.
    • NameValueAttribute

      public NameValueAttribute(String attributeName)
      Constructs an instance initialized with the specified name that is associated with a null value.
      Parameters:
      attributeName - The name of the attribute.
    • NameValueAttribute

      public NameValueAttribute(String attributeName, String attributeValue)
      Constructs an instance initialized with the specified named attribute and its associated value.
      Parameters:
      attributeName - The name of the attribute.
      attributeValue - The value associated with this named attribute.
  • Method Details

    • getFieldNameToValueMap

      public Map<String,String> getFieldNameToValueMap()
      Gets a map keyed by the String names of the following attributes to their values.
      • name
      • value
      Overrides:
      getFieldNameToValueMap in class AbstractServiceAttribute
      Returns:
      Map keyed by the String names of a field to their values.