atg.nucleus
Class GenericRMIService

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by atg.nucleus.GenericRMIService
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.io.Serializable, java.rmi.Remote, java.util.EventListener
Direct Known Subclasses:
GSAInvalidatorService, IndexingOutputConfig

public class GenericRMIService
extends java.rmi.server.UnicastRemoteObject
implements NameContextBindingListener, ComponentNameResolver, NameContextElement, ServiceListener, Service, ApplicationLogging, AdminableService

This is a combination of GenericService and UnicastRemoteObject, thereby serving as a convenient base for objects that will be exported by the RMIServer.

See Also:
Serialized Form

Field Summary
static java.lang.String CLASS_VERSION
          Class version string
static java.lang.String SERVICE_INFO_KEY
          Should be used as a key to retrieve the serviceInfo property from ResourceBundles
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
GenericRMIService()
          Constructs a new GenericRMIService
 
Method Summary
 void addLogListener(LogListener pListener)
          Adds a listener to the list of log listeners
protected  javax.servlet.Servlet createAdminServlet()
          Creates and returns a new Servlet that will administer this service.
 void doStartService()
          This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values.
 void doStopService()
          This is called when a Service is required to shut down.
 java.lang.String getAbsoluteName()
          Returns the absolute name of this service, using Nucleus to get the absolute name.
 javax.servlet.Servlet getAdminServlet()
          Returns the Servlet that will handle requests directed at this service.
 int getLogListenerCount()
          Returns the number of log listeners
 LogListener[] getLogListeners()
          Returns the list of log listeners as an array property.
 java.lang.String getName()
          Returns the name by which this element is know within its enclosing NameContext.
 NameContext getNameContext()
          Returns the NameContext into which this element has been bound, or null if the element is not bound in a NameContext.
 Nucleus getNucleus()
          Returns the Nucleus managing this Service
 java.rmi.server.RemoteRef getRef()
          Override getRef() method so that ref property will not be serialized to UI client.
 NameContext getRoot()
          Searches up the tree until it finds the root NameContext
 Configuration getServiceConfiguration()
          Returns the Configuration that was used to create this Service, null if there was none.
 java.lang.String getServiceInfo()
          Returns the a descriptive string about this service
 boolean isLoggingDebug()
          This method returns whether or not an debug log event should be broadcast.
 boolean isLoggingError()
          This method returns whether or not an error log event should be broadcast.
 boolean isLoggingInfo()
          This method returns whether or not an info log event should be broadcast.
 boolean isLoggingWarning()
          This method returns whether or not an warning log event should be broadcast.
 boolean isRunning()
          Returns true if this Service is currently running.
 void logDebug(java.lang.String pMessage)
          Logs an debug event with the specified message
 void logDebug(java.lang.String pMessage, java.lang.Throwable pThrowable)
          Logs an debug event with the specified message and Throwable
 void logDebug(java.lang.Throwable pThrowable)
          Logs an debug event with the specified Throwable
 void logError(java.lang.String pMessage)
          Logs an error event with the specified message
 void logError(java.lang.String pMessage, java.lang.Throwable pThrowable)
          Logs an error event with the specified message and Throwable
 void logError(java.lang.Throwable pThrowable)
          Logs an error event with the specified Throwable
 void logInfo(java.lang.String pMessage)
          Logs an info event with the specified message
 void logInfo(java.lang.String pMessage, java.lang.Throwable pThrowable)
          Logs an info event with the specified message and Throwable
 void logInfo(java.lang.Throwable pThrowable)
          Logs an info event with the specified Throwable
 void logWarning(java.lang.String pMessage)
          Logs an warning event with the specified message
 void logWarning(java.lang.String pMessage, java.lang.Throwable pThrowable)
          Logs an warning event with the specified message and Throwable
 void logWarning(java.lang.Throwable pThrowable)
          Logs an warning event with the specified Throwable
 void nameContextElementBound(NameContextBindingEvent pEvent)
          This is called to notify this context that it is being bound into a NameContext.
 void nameContextElementUnbound(NameContextBindingEvent pEvent)
          This is called to notify this context that it is being unbound from a NameContext.
 void removeLogListener(LogListener pListener)
          Removes a listener from the list of log listeners
 java.lang.Object resolveName(ComponentName pName)
          Resolves the specified name, relative to this context's parent.
 java.lang.Object resolveName(ComponentName pName, boolean pCreate)
          Resolves the specified name, relative to this context's parent.
 java.lang.Object resolveName(java.lang.String pName)
          Resolves the specified name, relative to this context's parent.
 java.lang.Object resolveName(java.lang.String pName, boolean pCreate)
          Resolves the specified name, relative to this context's parent.
 void sendLogEvent(LogEvent pLogEvent)
          Sends a LogEvent to all of the listeners
 void setLoggingDebug(boolean pLogging)
          Sets whether or not error log events should be logged.
 void setLoggingError(boolean pLogging)
          Sets whether or not error log events should be logged.
 void setLoggingInfo(boolean pLogging)
          Sets whether or not info log events should be logged.
 void setLoggingWarning(boolean pLogging)
          Sets whether or not warning log events should be logged.
 void setServiceInfo(java.lang.String pServiceInfo)
          Sets the a descriptive string about this service
 void startService(ServiceEvent pEvent)
          Starts the service running.
 void stopService()
          Stops the service.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


SERVICE_INFO_KEY

public static final java.lang.String SERVICE_INFO_KEY
Should be used as a key to retrieve the serviceInfo property from ResourceBundles

See Also:
Constant Field Values
Constructor Detail

GenericRMIService

public GenericRMIService()
                  throws java.rmi.RemoteException
Constructs a new GenericRMIService

Throws:
java.rmi.RemoteException
Method Detail

getRef

public java.rmi.server.RemoteRef getRef()
Override getRef() method so that ref property will not be serialized to UI client.

Overrides:
getRef in class java.rmi.server.RemoteObject

getRoot

public NameContext getRoot()
Searches up the tree until it finds the root NameContext


doStartService

public void doStartService()
                    throws ServiceException
This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values. The Service should override this method to start any processes it requires.

Throws:
ServiceException - if the Service had a problem starting up

doStopService

public void doStopService()
                   throws ServiceException
This is called when a Service is required to shut down. The Service should respond by stopping any processes that it has started.

Throws:
ServiceException - if the Service had a problem shutting down

getServiceInfo

public java.lang.String getServiceInfo()
Returns the a descriptive string about this service


setServiceInfo

public void setServiceInfo(java.lang.String pServiceInfo)
Sets the a descriptive string about this service


addLogListener

public void addLogListener(LogListener pListener)
Adds a listener to the list of log listeners


removeLogListener

public void removeLogListener(LogListener pListener)
Removes a listener from the list of log listeners


getLogListeners

public LogListener[] getLogListeners()
Returns the list of log listeners as an array property.


getLogListenerCount

public int getLogListenerCount()
Returns the number of log listeners


sendLogEvent

public void sendLogEvent(LogEvent pLogEvent)
Sends a LogEvent to all of the listeners


resolveName

public java.lang.Object resolveName(ComponentName pName,
                                    boolean pCreate)
Resolves the specified name, relative to this context's parent.

Parameters:
pName - the name to be resolved
pCreate - flag indicating whether Nucleus should attempt to create the object if it does not already exist in the naming hierarchy.
Returns:
the Object to which the name resolves, or null if the name could not be resolved. Any errors that occur are directed to listeners of the Nucleus.

resolveName

public java.lang.Object resolveName(java.lang.String pName,
                                    boolean pCreate)
Resolves the specified name, relative to this context's parent.

Parameters:
pName - the name to be resolved
pCreate - flag indicating whether Nucleus should attempt to create the object if it does not already exist in the naming hierarchy.
Returns:
the Object to which the name resolves, or null if the name could not be resolved. Any errors that occur are directed to listeners of the Nucleus.

resolveName

public java.lang.Object resolveName(ComponentName pName)
Resolves the specified name, relative to this context's parent. This will attempt to create the service for the specified name if it does not already exist.

Specified by:
resolveName in interface ComponentNameResolver
Parameters:
pName - the name to be resolved
Returns:
the Object to which the name resolves, or null if the name could not be resolved. Any errors that occur are directed to listeners of the Nucleus.

resolveName

public java.lang.Object resolveName(java.lang.String pName)
Resolves the specified name, relative to this context's parent. This will attempt to create the service for the specified name if it does not already exist.

Specified by:
resolveName in interface NameResolver
Parameters:
pName - the name to be resolved
Returns:
the Object to which the name resolves, or null if the name could not be resolved. Any errors that occur are directed to listeners of the Nucleus.

getAbsoluteName

public java.lang.String getAbsoluteName()
Returns the absolute name of this service, using Nucleus to get the absolute name.


nameContextElementBound

public void nameContextElementBound(NameContextBindingEvent pEvent)
This is called to notify this context that it is being bound into a NameContext.

Specified by:
nameContextElementBound in interface NameContextBindingListener

nameContextElementUnbound

public void nameContextElementUnbound(NameContextBindingEvent pEvent)
This is called to notify this context that it is being unbound from a NameContext.

Specified by:
nameContextElementUnbound in interface NameContextBindingListener

getNameContext

public NameContext getNameContext()
Returns the NameContext into which this element has been bound, or null if the element is not bound in a NameContext.

Specified by:
getNameContext in interface NameContextElement

getName

public java.lang.String getName()
Returns the name by which this element is know within its enclosing NameContext.

Specified by:
getName in interface NameContextElement

startService

public void startService(ServiceEvent pEvent)
                  throws ServiceException
Starts the service running. This will be called after the service has been placed into the naming hierarchy, and all of its properties have been set.

Specified by:
startService in interface ServiceListener
Parameters:
pEvent - the ServiceEvent encapsulating information about the Service's environment and configuration
Throws:
ServiceException - if an error occurred while attempting to start the service.

stopService

public void stopService()
                 throws ServiceException
Stops the service. This will be called when the Service is being shut down, either by explicit instructions from the administrator, or for various other reasons. A Service should clean up any resources it is using, but should be prepared to restart itself. When asked to restart, its properties may have changed.

Specified by:
stopService in interface ServiceListener
Throws:
ServiceException - if an error occurred while attempting to stop the service.

getNucleus

public Nucleus getNucleus()
Returns the Nucleus managing this Service

Specified by:
getNucleus in interface Service

getServiceConfiguration

public Configuration getServiceConfiguration()
Returns the Configuration that was used to create this Service, null if there was none.

Specified by:
getServiceConfiguration in interface Service

isRunning

public boolean isRunning()
Returns true if this Service is currently running.

Specified by:
isRunning in interface Service

isLoggingInfo

public boolean isLoggingInfo()
This method returns whether or not an info log event should be broadcast.

Specified by:
isLoggingInfo in interface ApplicationLogging
Returns:
boolean true if info log events should be logged
false if info log events should not be logged

setLoggingInfo

public void setLoggingInfo(boolean pLogging)
Sets whether or not info log events should be logged.

Specified by:
setLoggingInfo in interface ApplicationLogging

isLoggingWarning

public boolean isLoggingWarning()
This method returns whether or not an warning log event should be broadcast.

Specified by:
isLoggingWarning in interface ApplicationLogging
Returns:
boolean true if warning log events should be logged
false if warning log events should not be logged

setLoggingWarning

public void setLoggingWarning(boolean pLogging)
Sets whether or not warning log events should be logged.

Specified by:
setLoggingWarning in interface ApplicationLogging

isLoggingError

public boolean isLoggingError()
This method returns whether or not an error log event should be broadcast.

Specified by:
isLoggingError in interface ApplicationLogging
Returns:
boolean true if error log events should be logged
false if error log events should not be logged

setLoggingError

public void setLoggingError(boolean pLogging)
Sets whether or not error log events should be logged.

Specified by:
setLoggingError in interface ApplicationLogging

isLoggingDebug

public boolean isLoggingDebug()
This method returns whether or not an debug log event should be broadcast.

Specified by:
isLoggingDebug in interface ApplicationLogging
Returns:
boolean true if debug log events should be logged
false if debug log events should not be logged

setLoggingDebug

public void setLoggingDebug(boolean pLogging)
Sets whether or not error log events should be logged.

Specified by:
setLoggingDebug in interface ApplicationLogging

logInfo

public void logInfo(java.lang.String pMessage)
Logs an info event with the specified message

Specified by:
logInfo in interface ApplicationLogging

logInfo

public void logInfo(java.lang.Throwable pThrowable)
Logs an info event with the specified Throwable

Specified by:
logInfo in interface ApplicationLogging

logInfo

public void logInfo(java.lang.String pMessage,
                    java.lang.Throwable pThrowable)
Logs an info event with the specified message and Throwable

Specified by:
logInfo in interface ApplicationLogging

logWarning

public void logWarning(java.lang.String pMessage)
Logs an warning event with the specified message

Specified by:
logWarning in interface ApplicationLogging

logWarning

public void logWarning(java.lang.Throwable pThrowable)
Logs an warning event with the specified Throwable

Specified by:
logWarning in interface ApplicationLogging

logWarning

public void logWarning(java.lang.String pMessage,
                       java.lang.Throwable pThrowable)
Logs an warning event with the specified message and Throwable

Specified by:
logWarning in interface ApplicationLogging

logError

public void logError(java.lang.String pMessage)
Logs an error event with the specified message

Specified by:
logError in interface ApplicationLogging

logError

public void logError(java.lang.Throwable pThrowable)
Logs an error event with the specified Throwable

Specified by:
logError in interface ApplicationLogging

logError

public void logError(java.lang.String pMessage,
                     java.lang.Throwable pThrowable)
Logs an error event with the specified message and Throwable

Specified by:
logError in interface ApplicationLogging

logDebug

public void logDebug(java.lang.String pMessage)
Logs an debug event with the specified message

Specified by:
logDebug in interface ApplicationLogging

logDebug

public void logDebug(java.lang.Throwable pThrowable)
Logs an debug event with the specified Throwable

Specified by:
logDebug in interface ApplicationLogging

logDebug

public void logDebug(java.lang.String pMessage,
                     java.lang.Throwable pThrowable)
Logs an debug event with the specified message and Throwable

Specified by:
logDebug in interface ApplicationLogging

getAdminServlet

public javax.servlet.Servlet getAdminServlet()
Returns the Servlet that will handle requests directed at this service. This will first check to see if the servlet is already created, and if not it will create it by calling createAdminServlet.

Specified by:
getAdminServlet in interface AdminableService
See Also:
createAdminServlet()

createAdminServlet

protected javax.servlet.Servlet createAdminServlet()
Creates and returns a new Servlet that will administer this service. By default, this creates a ServiceAdminServlet, but subclasses may create their own servlets.