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

com.sas.services.discovery
Class NameValueAttribute

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

public class NameValueAttribute

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:
Serialized Form

Field Summary
 java.lang.String name
          A name describing an arbitrary type of attribute.
 java.lang.String value
          The value of the named attribute.
 
Constructor Summary
NameValueAttribute()
          Constructs a default instance with a null name and null value.
NameValueAttribute(java.lang.String attributeName)
          Constructs an instance initialized with the specified name that is associated with a null value.
NameValueAttribute(java.lang.String attributeName, java.lang.String attributeValue)
          Constructs an instance initialized with the specified named attribute and its associated value.
 
Method Summary
 java.util.Map getFieldNameToValueMap()
          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
 

Field Detail

name

public java.lang.String name
A name describing an arbitrary type of attribute.


value

public java.lang.String value
The value of the named attribute.

Constructor Detail

NameValueAttribute

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


NameValueAttribute

public NameValueAttribute(java.lang.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(java.lang.String attributeName,
                          java.lang.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 Detail

getFieldNameToValueMap

public java.util.Map getFieldNameToValueMap()
Gets a map keyed by the String names of the following attributes to their values.

Overrides:
getFieldNameToValueMap in class AbstractServiceAttribute
Returns:
Map keyed by the String names of a field to their values.

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




Copyright © 2009 SAS Institute Inc. All Rights Reserved.