1 package org.jbpm.db.jmx; 2 3 import javax.naming.InitialContext ; 4 import javax.naming.Name ; 5 import javax.naming.NamingException ; 6 7 import org.jboss.naming.NonSerializableFactory; 8 import org.jboss.system.ServiceMBeanSupport; 9 import org.jbpm.db.JbpmSessionFactory; 10 11 public class JbpmService extends ServiceMBeanSupport implements JbpmServiceMBean { 12 13 String jndiName = null; 14 15 protected void startService() throws Exception { 16 log.debug("starting jbpmSessionFactory for '" + jndiName + "'..."); 17 JbpmSessionFactory jbpmSessionFactory = JbpmSessionFactory.buildJbpmSessionFactory(); 19 InitialContext rootCtx = new InitialContext (); 20 Name fullName = rootCtx.getNameParser("").parse(jndiName); 21 log.info("binding JbpmSessionFactory '" + jndiName + "' into JNDI..."); 22 NonSerializableFactory.rebind(fullName, jbpmSessionFactory, true); 23 } 24 25 protected void stopService() throws Exception { 26 try { 27 InitialContext rootCtx = new InitialContext (); 28 rootCtx.unbind(jndiName); 29 NonSerializableFactory.unbind(jndiName); 30 } catch (NamingException e) { 31 log.error("Failed to unbind jbpmSessionFactory", e); 32 } 33 } 34 35 public String getJndiName() { 36 return jndiName; 37 } 38 public void setJndiName(String jndiName) { 39 this.jndiName = jndiName; 40 } 41 } 42 | Popular Tags |