*** This class provides Binary Compatibility only, not Source Compatibility ***
Class NameValueAttribute
- All Implemented Interfaces:
ServiceAttributeInterface,Serializable
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 moreKeyword 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 -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a default instance with anullname andnullvalue.NameValueAttribute(String attributeName) Constructs an instance initialized with the specified name that is associated with anullvalue.NameValueAttribute(String attributeName, String attributeValue) Constructs an instance initialized with the specified named attribute and its associated value. -
Method Summary
Modifier and TypeMethodDescriptionMap<String, String> Gets a map keyed by theStringnames of the following attributes to their values.Methods inherited from class com.sas.services.AbstractServiceAttribute
equals, hashCode, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
name
public String nameA name describing an arbitrary type of attribute. -
value
public String valueThe value of the named attribute.
-
-
Constructor Details
-
NameValueAttribute
public NameValueAttribute()Constructs a default instance with anullname andnullvalue. -
NameValueAttribute
public NameValueAttribute(String attributeName) Constructs an instance initialized with the specified name that is associated with anullvalue.- 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 theStringnames of the following attributes to their values.- name
- value
- Overrides:
getFieldNameToValueMapin classAbstractServiceAttribute- Returns:
- Map keyed by the
Stringnames of a field to their values.
-