*** This class is subject to change. ***
Package com.sas.services.discovery
Class ActivatableDiscoveryService
java.lang.Object
com.sas.services.AbstractRemoteService
com.sas.services.discovery.ActivatableDiscoveryService
- All Implemented Interfaces:
com.sas.entities.EntityKeyInterface,DiscoveryAdminInterface,DiscoveryServiceInterface,FindServiceInterface,ServiceNotificationBroadcasterInterface,RemoteServiceInterface,Remote
@SASScope("ALL")
@SubjectToChange
public final class ActivatableDiscoveryService
extends AbstractRemoteService
implements DiscoveryServiceInterface
Remotely accessible discovery service.
This implementation of the discovery service supports a remote deployment whereby services registered with this service can be made accessible to clients running in other JVM processes.
- Since:
- 1.0
-
Field Summary
Fields inherited from interface com.sas.services.discovery.FindServiceInterface
FIND_ALL_MATCHES, FIND_ONE_MATCHFields inherited from interface com.sas.services.RemoteServiceInterface
CLASS_IDENTIFIER, CLASS_IDENTIFIER_1_1, CLASS_IDENTIFIER_1_2, CLASS_IDENTIFIER_SERVICE_TYPE, CLASS_IDENTIFIER_SERVICE_TYPE_1_1, CLASS_IDENTIFIER_SERVICE_TYPE_1_2 -
Constructor Summary
ConstructorsConstructorDescriptionActivatableDiscoveryService(ServiceConfigurationInterface serviceConfiguration, DiscoveryServiceInterface discoveryService) Constructs a default instance of a remote discovery service. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDiscoveryDelegate(FindServiceInterface serviceFinder) Adds an delegate that is capable of discovering implementations.voidaddService(RemoteServiceInterface service) Adds a service to the registry.voidconfigure(ServiceConfigurationInterface serviceConfiguration) Configures service.voiddestroy()Destroys the service.findService(ServiceTemplate serviceTemplate) Finds a service using a discovery mechanism.findServices(ServiceTemplate serviceTemplate, int maxNumMatches, Services discoveredServices) Finds a collection of objects via a discovery mechanism.findServiceUsingId(String runtimeServiceId) Re-acquires a previously discovered service via its service discovery ID.Iterator<FindServiceInterface> Gets an iterator of the discovery services.Gets the discovery service.Iterator<RemoteServiceInterface> Gets an iterator of local objects that implement theRemoteServiceInterfaceinterface.Iterator<RemoteServiceInterface> Gets an iterator of registered services.StringGets the service's name.Gets a new proxy to this service.voidremoveDiscoveryDelegate(FindServiceInterface serviceFinder) Removes an agent previously added as a discovery agent.voidremoveService(RemoteServiceInterface service) Removes a service from the registry.StringtoString()Gets a string representation of this instance.Methods inherited from class com.sas.services.AbstractRemoteService
addServiceObserver, bindToDiscoveryService, getCreationTime, getDetails, getEntityKey, getEnvironment, getServiceConfiguration, getServiceConfiguration, getServiceState, handleJVMShutdown, isAccessibleToRemoteClients, isExported, isHandlingJVMShutdown, notifyServiceObservers, reconfigure, removeAllServiceObservers, removeServiceObserver, sameEntity, setDiscoveryService, setEntityKey, setRemoteableExporter, setServiceState, unbindFromDiscoveryServiceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.sas.entities.EntityKeyInterface
getEntityKey, sameEntity, setEntityKeyMethods inherited from interface com.sas.services.RemoteServiceInterface
getCreationTime, getServiceConfiguration, getServiceConfiguration, getServiceState, isAccessibleToRemoteClients, isExported, reconfigure, setServiceStateMethods inherited from interface com.sas.services.mgmt.ServiceNotificationBroadcasterInterface
addServiceObserver, notifyServiceObservers, removeAllServiceObservers, removeServiceObserver
-
Constructor Details
-
ActivatableDiscoveryService
public ActivatableDiscoveryService(ServiceConfigurationInterface serviceConfiguration, DiscoveryServiceInterface discoveryService) throws ServiceException, IllegalArgumentException Constructs a default instance of a remote discovery service.- Parameters:
serviceConfiguration- Service's configuration.discoveryService- A discovery service which may be used to locate other services and to which a service must bind in order to be located by other services.- Throws:
IllegalArgumentException- if unable to configure the service.ServiceException- if unable to export this service. The service exception's cause may be a RemoteException.
-
-
Method Details
-
configure
public void configure(ServiceConfigurationInterface serviceConfiguration) throws InitializationException, RemoteException, ServiceException, IllegalArgumentException Configures service. Note that this method may used to initialize a service or to re-configure a previously initialized service.- Specified by:
configurein interfaceRemoteServiceInterface- Overrides:
configurein classAbstractRemoteService- Parameters:
serviceConfiguration- An object containing configuration data necessary to initialize or re-configure a service. Note that the service provider must verify that the object type is supported. AnInitializationExceptionshould be thrown if the initialization was not completed successfully to indicate that the instance should not be used.- Throws:
InitializationException- if unable to configure the service.RemoteException- if a network anomaly is encountered.ServiceException- if unable to configure the service.IllegalArgumentException- if anullservice configuration is specified.
-
getServiceProxy
Gets a new proxy to this service.- Specified by:
getServiceProxyin interfaceRemoteServiceInterface- Overrides:
getServiceProxyin classAbstractRemoteService- Returns:
- A proxy to this service or
nullif a proxy is not available. - Throws:
IllegalStateException- if this service has been destroyed.
-
destroy
Destroys the service. The service should release any resources it holds in preparation for termination of use of this service.- Specified by:
destroyin interfaceRemoteServiceInterface- Overrides:
destroyin classAbstractRemoteService- Throws:
RemoteException- if a network anomaly is encountered.ServiceException- if the service is unable to prepare itself for destruction.
-
getDiscoveryService
Gets the discovery service. A default service will be created if one is not currently specified.- Overrides:
getDiscoveryServicein classAbstractRemoteService- Returns:
- A discovery service.
- Throws:
IllegalStateException- if this service has been destroyed.
-
findServiceUsingId
public RemoteServiceInterface findServiceUsingId(String runtimeServiceId) throws ServiceException, ServiceNotAvailableException, IllegalStateException, RemoteException Re-acquires a previously discovered service via its service discovery ID. The service discovery ID is runtime ID that is unique across JVMs and only used in the context of discovering a service.- Specified by:
findServiceUsingIdin interfaceFindServiceInterface- Parameters:
runtimeServiceId- Service's discovery ID.- Returns:
RemoteServiceInterfaceimplementation that satisfies the discovery parameters. Note thatRemoteServiceInterfaceis the base interface implemented by all services.- Throws:
ServiceException- if an unanticipated exception occurs while processing the discovery. Note thatServiceNotAvailableExceptionextendsServiceException.ServiceNotAvailableException- if no service satisfies the requested service template.RemoteException- if a network anomaly is encountered.IllegalStateException
-
findService
public RemoteServiceInterface findService(ServiceTemplate serviceTemplate) throws ServiceException, ServiceNotAvailableException, IllegalArgumentException, RemoteException Finds a service using a discovery mechanism.To be considered a successful match, the service must satisfy the requested service template which may be used to specify:
- class(es) the service is, extends, or implements
- additional filtering criteria expressed in terms of
ServiceAttributeInterface
- Specified by:
findServicein interfaceFindServiceInterface- Parameters:
serviceTemplate- Service capability template that specifies the desired class(es) that define a service. The template may also specify criteria to provide additional filtering.- Returns:
RemoteServiceInterfaceimplementation that satisfies the requested service template. Note thatRemoteServiceInterfaceis the base interface implemented by all services.- Throws:
ServiceException- if an unanticipated exception occurs while processing the discovery.ServiceNotAvailableException- if no service satisfies the requested service template. Note thatServiceNotAvailableExceptionextendsServiceException.RemoteException- if a network anomaly is encountered.IllegalArgumentException- See Also:
-
findServices
public Services findServices(ServiceTemplate serviceTemplate, int maxNumMatches, Services discoveredServices) throws ServiceException, ServiceNotAvailableException, IllegalStateException, RemoteException Finds a collection of objects via a discovery mechanism.To be considered a successful match, the service must satisfy the requested service template which may be used to specify:
- a service ID
- classes the service is, extends, or implements
- additional filtering criteria
- Specified by:
findServicesin interfaceFindServiceInterface- Parameters:
serviceTemplate- Service capability template that specifies either- a service ID to retrieve a particular service
- the desired classes that define a service. One may also specify additional criteria to provide additional filtering.
maxNumMatches- Maximum number of services.discoveredServices- A collection containing services that have already been found. Set this parameter tonullif no services have been found yet.- Returns:
- A collection containing search results. Each collection element will either be, implement, or extend the requested classes.
- Throws:
RemoteException- if a network anomaly is encountered.ServiceException- if an unanticipated exception occurs while processing the discovery.ServiceNotAvailableException- if no service satisfies the requested service template.IllegalStateException- if this service has been destroyed.- See Also:
-
getRemoteServices
Gets an iterator of registered services.- Specified by:
getRemoteServicesin interfaceDiscoveryAdminInterface- Returns:
- Iterator of remotely available services that
implement the
RemoteServiceInterfaceinterface. - Throws:
RemoteException- if a network anomaly is encountered.
-
getLocalServices
Gets an iterator of local objects that implement theRemoteServiceInterfaceinterface.- Specified by:
getLocalServicesin interfaceDiscoveryAdminInterface- Returns:
- Iterator of locally available services that
implement the
RemoteServiceInterfaceinterface. - Throws:
RemoteException- if a network anomaly is encountered.
-
addDiscoveryDelegate
Adds an delegate that is capable of discovering implementations.- Specified by:
addDiscoveryDelegatein interfaceDiscoveryAdminInterface- Parameters:
serviceFinder- Discovery service implementation.- Throws:
RemoteException- if a network anomaly is encountered.
-
removeDiscoveryDelegate
Removes an agent previously added as a discovery agent.- Specified by:
removeDiscoveryDelegatein interfaceDiscoveryAdminInterface- Parameters:
serviceFinder- Discovery service implementation to remove.- Throws:
RemoteException- if a network anomaly is encountered.
-
getDiscoverers
Gets an iterator of the discovery services.- Specified by:
getDiscoverersin interfaceDiscoveryAdminInterface- Returns:
- Iterator of discovery delegates.
- Throws:
RemoteException- if a network anomaly is encountered.
-
addService
Adds a service to the registry.- Specified by:
addServicein interfaceDiscoveryAdminInterface- Parameters:
service- Service that can be discovered via its service capabilities.- Throws:
ServiceException- if unable to cache the service.RemoteException- if a network anomaly is encountered.
-
removeService
Removes a service from the registry.- Specified by:
removeServicein interfaceDiscoveryAdminInterface- Parameters:
service- Service that is to be removed.- Throws:
RemoteException- if a network anomaly is encountered.
-
getServiceName
public String getServiceName()Gets the service's name.- Returns:
- Service's name.
-
toString
public String toString()Gets a string representation of this instance. Intended for debugging purposes.- Overrides:
toStringin classAbstractRemoteService- Returns:
- Debug statement describing this instance.
-