JavaEEServiceEngineLifeCyclepublic class JavaEEServiceEngineLifeCycle extends Object implements javax.jbi.component.ComponentLifeCycleProvide initialization, start, stop, and shutdown processing. The JBI
implementation queries the component for the implementation of this
interface using the Component.getComponentLifeCycle() method.
The methods in this interface comprise the life cycle contract between the
JBI implementation and the component. The life cycle of a component begins
with a call to the init() method on an instance of the
component's implementation of this interface, and ends with the first call
to the shutDown() method on that instance. Between these two
calls, there can be any number of stop() and
start() calls. |
Fields Summary |
---|
private JavaEEServiceEngineContext | contextThis context provides access to data needed by all JBI components running in
the JBI environment. | private javax.jbi.component.ComponentContext | jbiContext | private Thread | managerThread | protected static final Logger | loggerInternal handle to the logger instance |
Constructors Summary |
---|
public JavaEEServiceEngineLifeCycle()Creates a new instance of JavaEEServiceEngineLifeCycle
|
Methods Summary |
---|
public javax.management.ObjectName | getExtensionMBeanName()Get the JMX ObjectName for any additional MBean for this
component. If there is none, return null .
return null;
| public void | init(javax.jbi.component.ComponentContext jbiContext)Initialize the component. This performs initialization required by the
component but does not make it ready to process messages. This method
is called once for each life cycle of the component.
this.jbiContext = jbiContext;
| public void | shutDown()Shut down the component. This performs cleanup before the component is
terminated. Once this method has been called, init() must
be called before the component can be started again with a call to
start() .
| public void | start()Start the component. This makes the component ready to process messages.
This method is called after init() completes when the JBI
implementation is starting up, and when the component is being restarted
after a previous call to shutDown() . If stop()
was called previously but shutDown() was not, then
start() can be called again without another call to
init() .
try {
if(ServiceEngineUtil.isServiceEngineEnabled()) {
logger.log(Level.FINE, "Service Engine starting");
context = JavaEEServiceEngineContext.getInstance();
context.setJBIContext(jbiContext);
context.initialize();
if(context.isSunESB()) {
jbiContext.getMBeanServer().registerMBean(
new JavaEEDeployer(),
jbiContext.getMBeanNames().createCustomComponentMBeanName("JavaEEDeployer"));
logger.log(Level.FINE, "Successfully registered JavaEEDeployer.");
}
// Starts all the threads such as thread accepting a message from
// DeliveryChannel and delivering it to WorkManager
managerThread = new Thread(context.getWorkManager());
managerThread.start();
logger.log(Level.INFO, "serviceengine.success_start");
} else {
logger.log(Level.INFO,
"Java EE Service Engine is not active as it is disabled " +
"by setting the JVM flag com.sun.enterprise.jbi.se.disable to true");
}
}catch(Exception e) {
logger.log(Level.SEVERE, "serviceengine.error_start",
new Object[]{e.getMessage()});
throw new JBIException(e.getMessage());
}
| public void | stop()Stop the component. This makes the component stop accepting messages for
processing. After a call to this method, start() can be
called again without first calling init() .
//Stop multiple threads involved in request processing by the
//JavaEEServiceEngine
try {
if(ServiceEngineUtil.isServiceEngineEnabled()) {
context.getDeliveryChannel().close();
context.getWorkManager().stop();
managerThread.join();
if(context.isSunESB()) {
jbiContext.getMBeanServer().unregisterMBean(
jbiContext.getMBeanNames().createCustomComponentMBeanName("JavaEEDeployer"));
}
logger.log(Level.INFO, "serviceengine.success_stop");
}
} catch(Exception e) {
e.printStackTrace();
throw new JBIException(e.getMessage());
}
|
|