|
Foundation |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.services.discovery.JVMAttribute
public final class JVMAttribute
A foundation service discovery attribute which may be used to locate a service which has been instantiated in the local JVM or the same JVM as another previously discovered service.
When a service is deployed, a JVMAttribute
will be added to its service discovery configuration. This will enable
one to find a service that is deployed in a particular JVM.
Examples are provided to find a service that was deployed in:
The following example shows how to define a service template that can be used to discover an Authentication service that was deployed in this JVM.
import com.sas.services.discovery.DiscoveryService; import com.sas.services.discovery.JVMAttribute; import com.sas.services.discovery.ServiceAttributeInterface; import com.sas.services.discovery.ServiceTemplate; import com.sas.services.security.AuthenticationServiceInterface; ... // specify the desired service type(s) Class[] desiredServiceTypes = new Class[] { AuthenticationServiceInterface.class}; // specify the optional attributes to be used to qualify a discovery lookup // to include only those services which were instantiated in this JVM ServiceAttributeInterface[] serviceAttributes = new ServiceAttributeInterface[] { new JVMAttribute()}; // create a service lookup template specifying the required // service interface(s) and a service attribute for a // service that was instantiated in this JVM ServiceTemplate serviceTemplate = new ServiceTemplate( desiredServiceTypes, serviceAttributes); // discover a service satisfying the service template AuthenticationServiceInterface authenticationService = (AuthenticationServiceInterface) DiscoveryService.defaultInstance().findService(serviceTemplate);
The following example shows how to define a service template that can be used to discover an Authentication Service that was instantiated in the same JVM as another service.
import com.sas.services.ServiceConfigurationInterface; import com.sas.services.discovery.DiscoveryService; import com.sas.services.discovery.JVMAttribute; import com.sas.services.discovery.ServiceAttributeInterface; import com.sas.services.discovery.ServiceDiscoveryConfigurationInterface; import com.sas.services.discovery.ServiceTemplate; import com.sas.services.security.AuthenticationServiceInterface; import com.sas.services.user.UserServiceInterface; ... // specify the desired service type(s) final Class[] desiredServiceTypes = new Class[] { AuthenticationServiceInterface.class}; // part 1: // find a foundation User service and determine its JVM ID // from its service discovery configuration, so that we // can lookup another service that was instantiated in the same JVM ServiceTemplate serviceTemplate = new ServiceTemplate( new Class[] {UserServiceInterface.class}); RemoteServiceInterface userService = DiscoveryService.defaultInstance().findService(serviceTemplate); ServiceDiscoveryConfigurationInterface serviceDiscoveryConfig = (ServiceDiscoveryConfigurationInterface) userService.getServiceConfiguration( ServiceConfigurationInterface.CONFIGURATION_SERVICE_DISCOVERY); String jvmId = serviceDiscoveryConfig.getJVMId(); if (jvmId != null) { // part 2: // find a Authentication service that was deployed in the same JVM as the // previously discovered User service // specify the optional attributes to be used to qualify a discovery lookup // to include only those services which are not accessible to remote clients ServiceAttributeInterface[] serviceAttributes = new ServiceAttributeInterface[] { new JVMAttribute(jvmId)}; // ID of the desired JVM // create a service lookup template specifying the required // service interface(s) and a service attribute for a // service that was instantiated in the same JVM as the previously // discovered User service ServiceTemplate serviceTemplate = new ServiceTemplate( desiredServiceTypes, serviceAttributes); // discover a service satisfying the service template AuthenticationServiceInterface authenticationService = (AuthenticationServiceInterface) DiscoveryService.defaultInstance().findService(serviceTemplate); }
Field Summary | |
---|---|
static java.lang.String |
JVM_ID
Identifier unique to this JVM that can be used to determine whether another service was instantiated in the same JVM. |
Fields inherited from class com.sas.services.discovery.IdAttribute |
---|
id, idType |
Constructor Summary | |
---|---|
JVMAttribute()
Constructs an instance of a service discovery attribute that is initialized with an identifier representing this JVM. |
|
JVMAttribute(java.lang.String id)
Constructs a service discovery attribute which may be used to lookup a service which has been instantiated in a JVM with the specified ID. |
Method Summary |
---|
Methods inherited from class com.sas.services.discovery.IdAttribute |
---|
getFieldNameToValueMap |
Methods inherited from class com.sas.services.AbstractServiceAttribute |
---|
equals, hashCode, toString |
Field Detail |
---|
public static final java.lang.String JVM_ID
Constructor Detail |
---|
public JVMAttribute()
Use this constructor to instantiate a service discovery attribute to be associated with a service that is being instantiated in this JVM.
A discovery service consumer can use this constructor to create a service discovery attribute which may be used to locate a service that has been instantiated in the same JVM.
This constructor initializes the value of the id
to
the value of this JVM's id
.
public JVMAttribute(java.lang.String id)
id
- The ID of the JVM attribute.
If you wish to locate a foundation service
that has been started in the same JVM use the default constructor
JVMAttribute()
instead.
|
Foundation |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |