|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--org.openorb.util.service.ServerBase
A server controls the start-up of a servce. This abstract class must be overridden to handle specific command line arguments, or to create a special logger.
The default command line switches are:
-d,--debugA server class without any customization would look like this:enable debugging output. (Optional) Level values: debug, info, warn, error. Default is debug. -e,--default try to use the DefaultCorbalocService (IIOP port 683.) -f,--writeIORFile write the ior of the service to a file in the current working folder -h,--help print this message and exit -i,--printIOR print the ior of the service -l,--logfile log to a file in the current working folder. Default file is .log -n,--noBind do not bind to the specified service. Services: Naming, Corbaloc. -u,--printCorbalocURL print the corbaloc url for the service -v,--version print the version information and exit
public class Server
extends ServerBase
{
public static void main( String[] args )
{
Server srv = new Server();
srv.init( args );
srv.run();
}
}
Adding further command line arguments is not complicated:
public class Server
extends ServerBase
{
public void handleArguments( CommandLine cmdline, Parameters params )
{
params.setParameter( Service.OPT_MY_SPECIAL,
Boolean.toString( cmdline.hasOption( Service.OPT_MY_SPECIAL ) ) );
}
public static void main( String[] args )
{
Server srv = new Server();
Options options = new Options();
options.addOption( new Option( Service.MY_SPECIAL,
Service.OPT_MY_SPECIAL_LONG, false,
Service.OPT_MY_SPECIAL_DESCRIP ) );
srv.init( args, options );
srv.run();
}
}
A custom logger can be created by overriding the createLogger method.
| Field Summary | |
static String |
DEFAULT_FILE_FORMAT
The default logger file format. |
static String |
DEFAULT_FORMAT
The default logger format. |
| Constructor Summary | |
ServerBase()
|
|
| Method Summary | |
protected void |
configureLogger(Object logger,
org.apache.avalon.framework.parameters.Parameters svc_params)
Configure the logger. |
protected void |
consolePrintln(String msg)
Ensures the message is displayed on System.out |
protected org.apache.avalon.framework.logger.Logger |
createLogger(String name,
org.apache.avalon.framework.parameters.Parameters svc_params)
Create the service's root logger. |
protected ServiceContext |
createServiceContext()
Create the ServiceContext. |
org.apache.avalon.framework.logger.Logger |
getLogger()
Return the process' logger instance. |
ORB |
getORB()
Returns the ORB used by the Service. |
ServiceContext |
getServiceContext()
Returns the ServiceContext. |
org.apache.avalon.framework.parameters.Parameters |
getServiceParameters()
Returns the Parameters used by the Service. |
protected void |
handleArguments(org.apache.commons.cli.CommandLine cmdline,
org.apache.avalon.framework.parameters.Parameters params)
Handle service specific command line options. |
org.apache.commons.cli.CommandLine |
init(String[] args)
Initialize the server. |
org.apache.commons.cli.CommandLine |
init(String[] args,
org.apache.commons.cli.Options options)
Initialize the server. |
org.apache.commons.cli.CommandLine |
init(String[] args,
org.apache.commons.cli.Options options,
Properties props)
Initialize the server. |
org.apache.commons.cli.CommandLine |
init(String[] args,
org.apache.commons.cli.Options options,
Properties props,
org.apache.avalon.framework.parameters.Parameters params)
Initialize the server. |
org.apache.commons.cli.CommandLine |
init(String[] args,
Properties props)
Initialize the server. |
protected void |
preInitService(ServiceContext context,
org.apache.avalon.framework.parameters.Parameters params)
Service pre-initialization hook. |
void |
run()
Install the shutdown hook for shuttding down the ORB and start the ORB's dispatch loop. |
void |
setServiceClassName(String classNameStr)
Specifies the name of the service class to be used. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String DEFAULT_FORMAT
public static final String DEFAULT_FILE_FORMAT
| Constructor Detail |
public ServerBase()
| Method Detail |
public final org.apache.commons.cli.CommandLine init(String[] args)
args - The command line arguments for parsing.
public final org.apache.commons.cli.CommandLine init(String[] args,
org.apache.commons.cli.Options options)
args - The command line arguments for parsing.options - Service specific options.
public final org.apache.commons.cli.CommandLine init(String[] args,
Properties props)
args - The command line arguments for parsing.props - Properties for the orb init call.
public final org.apache.commons.cli.CommandLine init(String[] args,
org.apache.commons.cli.Options options,
Properties props)
args - The command line arguments for parsing.options - Service specific options.props - Properties for the orb init call.
public final org.apache.commons.cli.CommandLine init(String[] args,
org.apache.commons.cli.Options options,
Properties props,
org.apache.avalon.framework.parameters.Parameters params)
args - The command line arguments for parsing.options - Service specific options.props - Properties for the orb init call.params - an initial set of service parameters.public org.apache.avalon.framework.logger.Logger getLogger()
protected org.apache.avalon.framework.logger.Logger createLogger(String name,
org.apache.avalon.framework.parameters.Parameters svc_params)
name - The name of the logger.svc_params - service parameters
protected void configureLogger(Object logger,
org.apache.avalon.framework.parameters.Parameters svc_params)
By default, the cmdline option (--debug) is checked to set the default logging priority.
logger - real logger instance.
The class depends on the actual logging package
being used, e.g.
LogKit (org.apache.log.Logger),
log4J (org.apache.log4j.Logger)
JDK1.4 (java.util.logging.Logger)svc_params - service parameters.
Passed here since getServiceParameters() will not workprotected ServiceContext createServiceContext()
protected void handleArguments(org.apache.commons.cli.CommandLine cmdline,
org.apache.avalon.framework.parameters.Parameters params)
params.setParameter( Service.OPT_MY_SPECIAL,
Boolean.toString( cmdline.hasOption( Service.OPT_MY_SPECIAL ) ) );
cmdline - The parsed command line options.params - The Parameters object of the service.public final void run()
public ORB getORB()
public ServiceContext getServiceContext()
public org.apache.avalon.framework.parameters.Parameters getServiceParameters()
public void setServiceClassName(String classNameStr)
classNameStr - the name of the service class to use.
protected void preInitService(ServiceContext context,
org.apache.avalon.framework.parameters.Parameters params)
context - service contextparams - parametersprotected void consolePrintln(String msg)
msg - message to print
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||