|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--org.openorb.util.service.ServiceBase
This abstract class is the base class for all Service classes. It provides the lifecycle framework for initializing, contextualizing, starting, stopping, and disposing a service.
The Avalon lifecyle startup phase consists of:
Writing a Service with an additional command line argument would look like this:
public class Service
extends ServiceBase
{
private POA m_poa = null;
public void initializeService()
{
try
{
ORB orb = getORB();
if ( orb != null )
{
m_poa = POAHelper.narrow( ( POA ) createPOA() );
MyServiceServant ms = new MyServiceServant();
org.omg.CORBA.Object obj = ms._this( orb );
registerObject( "MyService", obj );
}
}
catch ( Exception ex )
{
// handle errors
}
}
public void startService()
{
try
{
if ( m_poa != null )
{
m_poa.the_POAManager().activate();
}
}
catch ( AdapterInactive ex )
{
// handle errors
}
}
public void stopService()
{
try
{
if ( m_poa != null )
{
m_poa.the_POAManager().deactivate( false, true );
}
}
catch ( AdapterInactive ex )
{
// handle errors
}
}
}
The POA handling can't be moved into the ServiceBase class because JDK1.3.x does not have POA support and because OpenORB still supports JDK 1.3.x compilation under JDK 1.3.x would not be possible (This will eventually be changed when support for JDK 1.3.x will be dropped).
The protected xxxService() mehods are callback methods that are called by the actual methods from the Avalon lifecycle interfaces. The actual methods do some consistency checking before the callback methods are invoked. The callback methods can be overridden to adapt the behaviour of the service in the corresponding state of the Avalon lifecycle.
The registerObject() method tries to register an object at the NamingService and at the OpenORB CorbalocService. This method must be used because all the bootstrapping issues are hidden behind this method. When the NamingService can't be found the file-system fallback will be used instead. Also the registerObject() method keeps track of registered objects and will deregister them automatically when the service is taken down, i.e. disposed.
| Constructor Summary | |
ServiceBase()
|
|
| Method Summary | |
protected boolean |
bindToNamingService(String name,
Object obj,
ORB orb)
Bind into the Naming Service |
protected void |
consolePrintln(String msg)
Ensures the message is displayed on System.out |
void |
contextualize(org.apache.avalon.framework.context.Context context)
This is the actual contextualize operation that calls the contextualizeService method. |
protected void |
contextualizeService(org.apache.avalon.framework.context.Context context)
This callback method is called from contextualize() and may be overridden by the actual Service class. |
protected Object |
createPOA()
This method is used to get the parent POA. |
void |
dispose()
This is the actual dispose operation which calls disposeService. |
protected void |
disposeService()
This callback method is called from dispose() and may be overridden by the actual Service class. |
void |
enableLogging(org.apache.avalon.framework.logger.Logger logger)
Provide the service with a logger. |
protected org.apache.avalon.framework.context.Context |
getContext()
Return the context of this instance. |
org.apache.avalon.framework.logger.Logger |
getLogger()
Return the logger instance associated with this service. |
String |
getLongName()
Return the long name for the service. |
ORB |
getORB()
Returns the ORB used by the Service |
protected org.apache.avalon.framework.parameters.Parameters |
getParameters()
Return the parameters of this instance. |
String |
getShortName()
Return the short name for the service. |
String |
getVersion()
Return the version for the service. |
void |
initialize()
This is the actual initialize operation which calls initializeService. |
protected void |
initializeService()
This callback method is called from initialize() and may be overridden by the actual Service class. |
boolean |
isContextualized()
Indicates whether the Service has been contextualized. |
boolean |
isInitialized()
Indicates whether the Service has been initialized. |
boolean |
isLogEnabled()
Indicates whether the Service has been logEnabled. |
boolean |
isParameterized()
Indicates whether the Service has been parameterized. |
boolean |
isStarted()
Indicates whether the Service has been started. |
void |
parameterize(org.apache.avalon.framework.parameters.Parameters params)
This is the actual parameterize operation which calls parameterizeService. |
protected void |
parameterizeService(org.apache.avalon.framework.parameters.Parameters params)
This callback method is called from parameterize() and may be overridden by the actual Service class. |
protected void |
registerObject(String name,
Object obj)
Register the object at the NamingService and/or at the CorbalocService. |
void |
start()
This is the actual start operation which calls startService. |
protected void |
startService()
This callback method is called from start() and may be overridden by the actual Service class. |
void |
stop()
This is the actual stop operation which calls stopService. |
protected void |
stopService()
This callback method is called from stop() and may be overridden by the actual Service class. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String OPT_HELP
public static final String OPT_HELP_LONG
public static final String OPT_HELP_DESCRIP
public static final String OPT_DEBUG
public static final String OPT_DEBUG_ARG
public static final String OPT_DEBUG_LONG
public static final String OPT_DEBUG_DESCRIP
public static final String OPT_BIND_CORBALOC
public static final String OPT_BIND_NS
public static final String OPT_NOBIND
public static final String OPT_NOBIND_ARG
public static final String OPT_NOBIND_LONG
public static final String OPT_NOBIND_DESCRIP
public static final String OPT_DEFAULT_CS
public static final String OPT_DEFAULT_CS_LONG
public static final String OPT_DEFAULT_CS_DESCRIP
public static final String OPT_VERSION
public static final String OPT_VERSION_LONG
public static final String OPT_VERSION_DESCRIP
public static final String OPT_PRINT_URL
public static final String OPT_PRINT_URL_LONG
public static final String OPT_PRINT_URL_DESCRIP
public static final String OPT_WRITE_URL_FILE
public static final String OPT_WRITE_URL_FILE_ARG
public static final String OPT_WRITE_URL_FILE_LONG
public static final String OPT_WRITE_URL_FILE_DESCRIP
public static final String OPT_PRINT_IOR
public static final String OPT_PRINT_IOR_LONG
public static final String OPT_PRINT_IOR_DESCRIP
public static final String OPT_WRITE_IOR_FILE
public static final String OPT_WRITE_IOR_FILE_ARG
public static final String OPT_WRITE_IOR_FILE_LONG
public static final String OPT_WRITE_IOR_FILE_DESCRIP
public static final String OPT_LOG_FILE
public static final String OPT_LOG_FILE_ARG
public static final String OPT_LOG_FILE_LONG
public static final String OPT_LOG_FILE_DESCRIP
| Constructor Detail |
public ServiceBase()
| Method Detail |
public void enableLogging(org.apache.avalon.framework.logger.Logger logger)
enableLogging in interface org.apache.avalon.framework.logger.LogEnabledlogger - The logger instance for this service.public org.apache.avalon.framework.logger.Logger getLogger()
protected void contextualizeService(org.apache.avalon.framework.context.Context context)
throws org.apache.avalon.framework.context.ContextException
context - The context for the service.org.apache.avalon.framework.context.ContextException - When an error accessing the context occurs.
public final void contextualize(org.apache.avalon.framework.context.Context context)
throws org.apache.avalon.framework.context.ContextException
contextualize in interface org.apache.avalon.framework.context.Contextualizablecontext - The context for the service.org.apache.avalon.framework.context.ContextException - When an error accessing the context occurs.protected org.apache.avalon.framework.context.Context getContext()
protected void parameterizeService(org.apache.avalon.framework.parameters.Parameters params)
params - configuration parameterspublic final void parameterize(org.apache.avalon.framework.parameters.Parameters params)
parameterize in interface org.apache.avalon.framework.parameters.Parameterizableparams - Parametersprotected org.apache.avalon.framework.parameters.Parameters getParameters()
protected void initializeService()
public final void initialize()
initialize in interface org.apache.avalon.framework.activity.Initializableprotected void startService()
public final void start()
start in interface org.apache.avalon.framework.activity.Startableprotected void stopService()
public final void stop()
stop in interface org.apache.avalon.framework.activity.Startableprotected void disposeService()
public final void dispose()
dispose in interface org.apache.avalon.framework.activity.Disposablepublic boolean isLogEnabled()
public boolean isContextualized()
public boolean isParameterized()
public boolean isInitialized()
public boolean isStarted()
public ORB getORB()
public final String getLongName()
public final String getShortName()
public final String getVersion()
protected Object createPOA()
This method may be overridden to create a special POA.
The return type is java.lang.Object because the POA class is not available in JDK 1.3.x. Using the POA class in the method signature would introduce a dependency to JDK 1.4.x.
protected final void registerObject(String name,
Object obj)
name - The name of the object.obj - The object itself.
protected boolean bindToNamingService(String name,
Object obj,
ORB orb)
name - name to bindobj - object to bindorb - ORBprotected void consolePrintln(String msg)
msg - message to print
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||