com.sas.services
Class AbstractRemoteService

java.lang.Object
  |
  +--com.sas.services.AbstractRemoteService
All Implemented Interfaces:
RemoteServiceInterface, ServiceNotificationBroadcasterInterface
Direct Known Subclasses:
AbstractService, ActivatableDiscoveryService, AuthenticationService, EventBrokerDiscoveryService, EventBrokerService, InformationService, SessionService, UserService

public abstract class AbstractRemoteService
extends Object
implements RemoteServiceInterface, ServiceNotificationBroadcasterInterface

Abstract implementation of a remoteable service. A service may extend this implementation if it is remoteable and is intended to be deployed in a distributed environment.

Note that this class is extended by com.sas.services.AbstractService which provides a version that may be used locally within a JVM process. Methods specified in the local version do not throw RemoteException.

Since:
1.0
See Also:
RemoteServiceInterface, ServiceConfigurationInterface

Fields inherited from interface com.sas.services.RemoteServiceInterface
CLASS_IDENTIFIER
 
Constructor Summary
AbstractRemoteService()
          Constructs a default instance.
 
Method Summary
 void addServiceObserver(ServiceRemoteObserverInterface serviceObserver)
          Adds a service observer.
 void configure(ServiceConfigurationInterface serviceConfiguration)
          Configures the service.
 void destroy()
          Handles the destruction of this service.
 long getCreationTime()
          Gets the time at which this configuration was created.
 String getEntityKey()
          Gets this service's entity key.
 ServiceConfigurationInterface getServiceConfiguration()
          Gets this service's configuration.
 ServiceConfigurationInterface getServiceConfiguration(Object key)
          Gets the service configuration associated with the specified lookup key.
 RemoteServiceInterface getServiceProxy()
          Gets the service proxy.
 short getServiceState()
          Gets the service's state.
 boolean isAccessibleToRemoteClients()
          Determines whether or not the service is intended to be accessible to remote clients.
 boolean isExported()
          Determines whether or not the service has been exported to the RMI system.
 void notifyServiceObservers(ServiceEvent serviceEvent)
          Notify all registered service observers of the specified service event.
 void removeAllServiceObservers()
          Removes all service observers.
 void removeServiceObserver(ServiceRemoteObserverInterface serviceObserver)
          Removes a service observer.
 boolean sameEntity(EntityKeyInterface entity)
          Determines whether or not this service entity is the same as the specified entity.
 void setEntityKey(String entityKey)
          Set the unique entity key for the service.
 void setRemoteableExporter(RemoteObjectExporterInterface remoteableExporter)
          Sets the remoteable exporter.
 void setServiceState(ServiceState serviceState)
          Sets the service's state.
 String toString()
          Returns a String representation of this service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractRemoteService

public AbstractRemoteService()
Constructs a default instance.
Method Detail

setRemoteableExporter

public final void setRemoteableExporter(RemoteObjectExporterInterface remoteableExporter)
Sets the remoteable exporter.
Parameters:
remoteableExporter - Utility to export/unexport a remoteable object.

getServiceConfiguration

public ServiceConfigurationInterface getServiceConfiguration()
                                                      throws RemoteException
Gets this service's configuration. The service configuration may contain ancillary sub-configurations which are available via a hash map lookup.

The service's configuration can always be retrieved irregardless of the service's state.

Specified by:
getServiceConfiguration in interface RemoteServiceInterface
Returns:
Service's configuration.
Throws:
RemoteException - if a network anomaly occurs.

getServiceConfiguration

public ServiceConfigurationInterface getServiceConfiguration(Object key)
                                                      throws RemoteException
Gets the service configuration associated with the specified lookup key. For example, if the base service configuration contained an ancillary configuration keyed by a value like ServiceConfigurationInterface.CONFIGURATION_SERVICE_DISCOVERY then this configuration would be returned if defined. If a null lookup key is specified, then the base service configuration is returned.
Specified by:
getServiceConfiguration in interface RemoteServiceInterface
Parameters:
key - Key designating an ancillary configuration.
Returns:
Service configuration associated with the specified key or null if no configuration is defined for the specified key.
Throws:
RemoteException - if a network anomaly occurs.

configure

public void configure(ServiceConfigurationInterface serviceConfiguration)
               throws InitializationException,
                      RemoteException,
                      ServiceException
Configures the service.
Specified by:
configure in interface RemoteServiceInterface
Parameters:
serviceConfiguration - Service's configuration.
Throws:
InitializationException - in unable to configure the service.
ServiceException - if a service exception is encountered.
RemoteException - if a network anomaly occurs.

getEntityKey

public String getEntityKey()
                    throws RemoteException
Gets this service's entity key.
Specified by:
getEntityKey in interface EntityKeyInterface
Returns:
Service's entity key.
Throws:
RemoteException - if a network anomaly occurs.

setEntityKey

public void setEntityKey(String entityKey)
                  throws RemoteException,
                         IllegalStateException
Set the unique entity key for the service. The entity key for the services cannot be changed. This method will throw an IllegalStateException.
Specified by:
setEntityKey in interface EntityKeyInterface
Parameters:
entityKey - Unique entity key.
Throws:
RemoteException - if a network anomaly occurs.
IllegalStateException - The unique entity key for a service cannot be changed.

sameEntity

public boolean sameEntity(EntityKeyInterface entity)
                   throws RemoteException
Determines whether or not this service entity is the same as the specified entity.
Specified by:
sameEntity in interface EntityKeyInterface
Parameters:
entity - Entity to be compared to this service entity.
Returns:
true if the service entities are the same or false if they aren't.
Throws:
RemoteException - if a network anomaly occurs.

getServiceState

public short getServiceState()
                      throws RemoteException
Gets the service's state.
Specified by:
getServiceState in interface RemoteServiceInterface
Returns:
Service's state.
Throws:
RemoteException - if a network anomaly occurs.

setServiceState

public void setServiceState(ServiceState serviceState)
                     throws ServiceException,
                            RemoteException
Sets the service's state.
Specified by:
setServiceState in interface RemoteServiceInterface
Parameters:
serviceState - Service's new state.
Throws:
ServiceException - if unable to process the request.
RemoteException - if a network anomaly occurs.

isExported

public boolean isExported()
                   throws ServiceException,
                          RemoteException
Determines whether or not the service has been exported to the RMI system.
Specified by:
isExported in interface RemoteServiceInterface
Returns:
true if the service has been exported or false if it hasn't.
Throws:
ServiceException - if unable to process the request.
RemoteException - if a network anomaly occurs.

isAccessibleToRemoteClients

public boolean isAccessibleToRemoteClients()
                                    throws ServiceException,
                                           RemoteException
Determines whether or not the service is intended to be accessible to remote clients.
Specified by:
isAccessibleToRemoteClients in interface RemoteServiceInterface
Returns:
true if the service is intended to be accessible to remote clients or false if it isn't.
Throws:
ServiceException - if unable to process the request.
RemoteException - if a network anomaly is encountered.

destroy

public void destroy()
             throws ServiceException,
                    RemoteException
Handles the destruction of this service. If this service previously exported to make it accessible to remote clients, then it will be unexported.

Once a service has been destroyed it should never be used again. The service's state is set to ServiceState.SERVICE_STATE_DEACTIVATED.

This method is synchronized to ensure that service destruction only occurs once.

Specified by:
destroy in interface RemoteServiceInterface
Throws:
ServiceException - if a service exception is encountered.
RemoteException - if a network anomaly occurs.

addServiceObserver

public final void addServiceObserver(ServiceRemoteObserverInterface serviceObserver)
                              throws RemoteException
Adds a service observer.
Specified by:
addServiceObserver in interface ServiceNotificationBroadcasterInterface
Parameters:
serviceObserver - An observer interested in receiving service notifications.
Throws:
RemoteException - if a network anomaly is encountered.

removeServiceObserver

public final void removeServiceObserver(ServiceRemoteObserverInterface serviceObserver)
                                 throws RemoteException
Removes a service observer.
Specified by:
removeServiceObserver in interface ServiceNotificationBroadcasterInterface
Parameters:
serviceObserver - An observer no longer interested in receiving service notifications.
Throws:
RemoteException - if a network anomaly is encountered.

removeAllServiceObservers

public final void removeAllServiceObservers()
                                     throws RemoteException
Removes all service observers.
Specified by:
removeAllServiceObservers in interface ServiceNotificationBroadcasterInterface
Throws:
RemoteException - if a network anomaly is encountered.

notifyServiceObservers

public final void notifyServiceObservers(ServiceEvent serviceEvent)
                                  throws RemoteException,
                                         IllegalArgumentException
Notify all registered service observers of the specified service event.
Specified by:
notifyServiceObservers in interface ServiceNotificationBroadcasterInterface
Parameters:
serviceEvent - Service event to be broadcast to all registered service observers.
Throws:
RemoteException - if a network anomaly is encountered.
IllegalArgumentException - if a null service event is specified.

getCreationTime

public long getCreationTime()
                     throws RemoteException
Gets the time at which this configuration was created. Can be used to order services based upon their creation times. Originally specified using currentTimeMillis().
Specified by:
getCreationTime in interface RemoteServiceInterface
Returns:
Time at which this configuration was created.
Throws:
RemoteException - if a network anomaly is encountered.

getServiceProxy

public RemoteServiceInterface getServiceProxy()
                                       throws RemoteException
Gets the service proxy.
Specified by:
getServiceProxy in interface RemoteServiceInterface
Returns:
A proxy to this service or null if a proxy is not available.
Throws:
RemoteException - if a network anomaly is encountered.

toString

public String toString()
Returns a String representation of this service.
Overrides:
toString in class Object
Returns:
String representation of this service.




Copyright © 2006 SAS Institute Inc. All Rights Reserved.
javadoc generated Fri, 10 Feb 2006 17:28:52