fr.paris5.shaman.insight.component
Class AbstractExposedService

fr.paris5.shaman.insight.component.AbstractExposedService
All Implemented Interfaces:
ExposedService, InsightConfigurationConstants, java.rmi.Remote, java.io.Serializable, SystemConfigurationConstants
Direct Known Subclasses:
OperationServiceImpl, PingServiceImpl, ShutdownServiceImpl

public class AbstractExposedService
implements java.rmi.Remote, java.io.Serializable, ExposedService, SystemConfigurationConstants, InsightConfigurationConstants

The base class for all exposed services, which MUST derive of it. This class manages RMI export, but does not derive from UnicastRemoteObject in order to avoid RMI registration when using standalone.

How this is done :
JDK doc says that it's not mandatory to derive from UnicastRemoteObject if the exported Object does provide implementations of hashCode, equals, and toString, which are compatible with remote object behavior. Since this behavior relies on the knowledge of remote reference, some methods have been copied to provide a consistent handling of this reference.

Note about support of Serializable interface :
A RMI server object must be serializable, but the intend is not to serialize the whole server object, only its remote reference. Derived classes should not take care of serialization.

Note about support of Avalon-Framework lifecycle-related interface :
Those methods are declared final.

Version:
$Id: AbstractExposedService.java,v 1.1 2002/06/18 12:23:12 caillette Exp $
Author:
Laurent Caillette
See Also:
Serialized Form

Fields inherited from interface fr.paris5.shaman.system.SystemConfigurationConstants
BASEDIRURL_ATTRIBUTE, DEFAULTHOSTNAME, EMPTYSYSTEM_RESOURCE, HOSTNAME_ATTRIBUTE, PORT_ATTRIBUTE, RUNSTYLE_ATTRIBUTE, SYSTEMCONFIGURATION_DEFAULT_RESOURCE
 
Fields inherited from interface fr.paris5.shaman.insight.component.InsightConfigurationConstants
CLASS_ATTRIBUTE, COMMANDLOGS_ELEMENT, DEFAULT_PREVALENCEBASE_DIR, DIR_ELEMENT, EXPOSEDAS_ATTRIBUTE, LOGKITCONFIGURATION_DEFAULT_RESOURCE, PERSISTING_ATTRIBUTE, ROLE_ATTRIBUTE, SNAPSHOTDIR_ELEMENT, SYSTEMCONFIGURATIONURL_ATTRIBUTE
 
Constructor Summary
  AbstractExposedService()
          Constructor for using service in an in-process context.
  AbstractExposedService(int port)
          Constructor for exporting service as accessible remotely.
protected AbstractExposedService(java.rmi.server.RemoteRef ref)
           
 
Method Summary
 java.lang.Object clone()
          Documentation copied from JDK 1.3.1_03 sources :
Returns a clone of the remote object that is distinct from the original.
 void compose(org.apache.avalon.framework.component.ComponentManager componentManager)
           
 void configure(org.apache.avalon.framework.configuration.Configuration configuration)
           
 void contextualize(org.apache.avalon.framework.context.Context context)
           
 void dispose()
           
protected  void doCompose()
          Subclasses may define their own behavior by overriding this method.
protected  void doConfigure(org.apache.avalon.framework.configuration.Configuration configuration)
          Subclasses may define their own behavior by overriding this method.
protected  void doContextualize(InsightContext context)
          Subclasses may define their own behavior by overriding this method.
protected  void doDispose()
          Subclasses may define their own behavior by overriding this method.
protected  void doInitialize()
          Subclasses may define their own behavior by overriding this method.
 boolean equals(java.lang.Object obj)
          Documentation copied from JDK 1.3.1_03 sources :
Compares two remote objects for equality.
static java.rmi.Remote exportObject(java.rmi.Remote obj, int port)
          Documentation copied from JDK 1.3.1_03 sources :
Export the remote object to make it available to receive incoming calls, using the particular supplied port.
static java.rmi.Remote exportObject(java.rmi.Remote obj, int port, java.rmi.server.RMIClientSocketFactory csf, java.rmi.server.RMIServerSocketFactory ssf)
          Documentation copied from JDK 1.3.1_03 sources :
Export the remote object to make it available to receive incoming calls, using a transport specified by the given socket factory.
protected  InsightManager getInsightManager()
           
protected  org.apache.avalon.excalibur.logger.LogKitManager getLogManager()
           
 java.rmi.server.RemoteRef getRef()
           
 int hashCode()
          Documentation copied from JDK 1.3.1_03 sources :
Returns a hashcode for a remote object.
 void initialize()
           
 void setLogKitManager(org.apache.avalon.excalibur.logger.LogKitManager logManager)
           
 java.lang.String toString()
          Documentation copied from JDK 1.3.1_03 sources :
Returns a String that represents the value of this remote object.
 

Constructor Detail

AbstractExposedService

public AbstractExposedService()
Constructor for using service in an in-process context.

AbstractExposedService

public AbstractExposedService(int port)
                       throws java.rmi.RemoteException
Constructor for exporting service as accessible remotely.
Parameters:
port - Use 0 if you don't know which port to use.

AbstractExposedService

protected AbstractExposedService(java.rmi.server.RemoteRef ref)
Method Detail

doContextualize

protected void doContextualize(InsightContext context)
                        throws org.apache.avalon.framework.context.ContextException
Subclasses may define their own behavior by overriding this method.

contextualize

public final void contextualize(org.apache.avalon.framework.context.Context context)
                         throws org.apache.avalon.framework.context.ContextException

doCompose

protected void doCompose()
Subclasses may define their own behavior by overriding this method. No parameter is passed, since the ServiceManager instance can be retrieved using getServiceManager().

compose

public final void compose(org.apache.avalon.framework.component.ComponentManager componentManager)
                   throws org.apache.avalon.framework.component.ComponentException

getInsightManager

protected final InsightManager getInsightManager()

doConfigure

protected void doConfigure(org.apache.avalon.framework.configuration.Configuration configuration)
                    throws org.apache.avalon.framework.configuration.ConfigurationException
Subclasses may define their own behavior by overriding this method.

configure

public final void configure(org.apache.avalon.framework.configuration.Configuration configuration)
                     throws org.apache.avalon.framework.configuration.ConfigurationException

doInitialize

protected final void doInitialize()
                           throws java.lang.Exception
Subclasses may define their own behavior by overriding this method.

initialize

public final void initialize()
                      throws java.lang.Exception

doDispose

protected void doDispose()
Subclasses may define their own behavior by overriding this method.

dispose

public final void dispose()

getLogManager

protected final org.apache.avalon.excalibur.logger.LogKitManager getLogManager()

setLogKitManager

public void setLogKitManager(org.apache.avalon.excalibur.logger.LogKitManager logManager)

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Documentation copied from JDK 1.3.1_03 sources :
Returns a clone of the remote object that is distinct from the original.
Returns:
the new remote object
Throws:
java.lang.CloneNotSupportedException - if clone failed due to a RemoteException.
Since:
JDK1.1

exportObject

public static java.rmi.Remote exportObject(java.rmi.Remote obj,
                                           int port)
                                    throws java.rmi.RemoteException
Documentation copied from JDK 1.3.1_03 sources :
Export the remote object to make it available to receive incoming calls, using the particular supplied port.
Parameters:
obj - the remote object to be exported
port - the port to export the object on
Returns:
remote object stub
Throws:
java.rmi.RemoteException - if export fails
Since:
1.2

exportObject

public static java.rmi.Remote exportObject(java.rmi.Remote obj,
                                           int port,
                                           java.rmi.server.RMIClientSocketFactory csf,
                                           java.rmi.server.RMIServerSocketFactory ssf)
                                    throws java.rmi.RemoteException
Documentation copied from JDK 1.3.1_03 sources :
Export the remote object to make it available to receive incoming calls, using a transport specified by the given socket factory.
Parameters:
obj - the remote object to be exported
port - the port to export the object on
csf - the client-side socket factory for making calls to the remote object
ssf - the server-side socket factory for receiving remote calls
Returns:
remote object stub
Throws:
java.rmi.RemoteException - if export fails
Since:
1.2

getRef

public java.rmi.server.RemoteRef getRef()

hashCode

public int hashCode()
Documentation copied from JDK 1.3.1_03 sources :
Returns a hashcode for a remote object. Two remote object stubs that refer to the same remote object will have the same hash code (in order to support remote objects as keys in hash tables).
Since:
JDK1.1
See Also:
Hashtable

equals

public boolean equals(java.lang.Object obj)
Documentation copied from JDK 1.3.1_03 sources :
Compares two remote objects for equality. Returns a boolean that indicates whether this remote object is equivalent to the specified Object. This method is used when a remote object is stored in a hashtable. If the specified Object is not itself an instance of RemoteObject, then this method delegates by returning the result of invoking the equals method of its parameter with this remote object as the argument.
Parameters:
obj - the Object to compare with
Returns:
true if these Objects are equal; false otherwise.
Since:
JDK1.1
See Also:
Hashtable

toString

public java.lang.String toString()
Documentation copied from JDK 1.3.1_03 sources :
Returns a String that represents the value of this remote object.
Since:
JDK1.1


Copyright © 2002 Laurent Caillette and l'Université René Descartes, Paris 5. All rights reserved.