FileDocCategorySizeDatePackage
JavaEEServiceEngineLifeCycle.javaAPI DocGlassfish v2 API8270Fri May 04 22:30:28 BST 2007com.sun.enterprise.jbi.serviceengine.core

JavaEEServiceEngineLifeCycle

public class JavaEEServiceEngineLifeCycle extends Object implements javax.jbi.component.ComponentLifeCycle
Provide 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.
author
Manisha Umbarje

Fields Summary
private JavaEEServiceEngineContext
context
This 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
logger
Internal handle to the logger instance
Constructors Summary
public JavaEEServiceEngineLifeCycle()
Creates a new instance of JavaEEServiceEngineLifeCycle

    
           
      
    
Methods Summary
public javax.management.ObjectNamegetExtensionMBeanName()
Get the JMX ObjectName for any additional MBean for this component. If there is none, return null.

return
the JMX object name of the additional MBean or null if there is no additional MBean.

        return null;
    
public voidinit(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.

param
context the component's context.
throws
javax.jbi.JBIException if the component is unable to initialize.

        this.jbiContext = jbiContext;
    
public voidshutDown()
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().

throws
javax.jbi.JBIException if the component is unable to shut down.

        
    
public voidstart()
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().

throws
javax.jbi.JBIException if the component is unable to start.

        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 voidstop()
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().

throws
javax.jbi.JBIException if the component is unable to stop.

        //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());
        }