1 23 package com.sun.enterprise.jbi.serviceengine.core; 24 import com.sun.enterprise.jbi.serviceengine.ServiceEngineException; 25 import com.sun.enterprise.webservice.ServiceEngineUtil; 26 import com.sun.logging.LogDomains; 27 import java.util.logging.Level ; 28 import java.util.logging.Logger ; 29 import javax.management.ObjectName ; 30 import javax.jbi.JBIException; 31 import javax.jbi.component.ComponentContext; 32 import javax.jbi.component.ComponentLifeCycle; 33 34 35 48 public class JavaEEServiceEngineLifeCycle implements ComponentLifeCycle { 49 50 54 private JavaEEServiceEngineContext context; 55 private ComponentContext jbiContext; 56 private Thread managerThread; 57 58 61 protected static Logger logger = 62 LogDomains.getLogger(LogDomains.SERVER_LOGGER); 63 64 65 public JavaEEServiceEngineLifeCycle() { 66 } 67 68 74 public ObjectName getExtensionMBeanName(){ 75 return null; 76 } 77 78 85 public void init(ComponentContext jbiContext) throws JBIException { 86 this.jbiContext = jbiContext; 87 } 88 89 96 public void shutDown() throws JBIException { 97 98 } 99 100 110 public void start() throws JBIException{ 111 try { 112 if(ServiceEngineUtil.isServiceEngineEnabled()) { 113 logger.log(Level.FINE, "Service Engine starting"); 114 context = JavaEEServiceEngineContext.getInstance(); 115 context.setJBIContext(jbiContext); 116 context.initialize(); 117 118 managerThread = new Thread (context.getWorkManager()); 121 managerThread.start(); 122 logger.log(Level.INFO, "serviceengine.success_start"); 123 124 } else { 125 logger.log(Level.INFO, 126 "Java EE Service Engine is not active as it is disabled " + 127 "by setting the JVM flag com.sun.enterprise.jbi.se.disable to true"); 128 } 129 130 131 }catch(Exception e) { 132 logger.log(Level.SEVERE, "serviceengine.error_start", 133 new Object []{e.getMessage()}); 134 throw new JBIException(e.getMessage()); 135 } 136 } 137 138 144 public void stop() throws JBIException { 145 try { 148 if(ServiceEngineUtil.isServiceEngineEnabled()) { 149 context.getDeliveryChannel().close(); 150 context.getWorkManager().stop(); 151 managerThread.join(); 152 logger.log(Level.INFO, "serviceengine.success_stop"); 153 } 154 } catch(Exception e) { 155 e.printStackTrace(); 156 throw new JBIException(e.getMessage()); 157 } 158 } 159 160 } 161 | Popular Tags |