KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > db > jmx > JbpmService


1 package org.jbpm.db.jmx;
2
3 import javax.naming.InitialContext JavaDoc;
4 import javax.naming.Name JavaDoc;
5 import javax.naming.NamingException JavaDoc;
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 JavaDoc jndiName = null;
14
15   protected void startService() throws Exception JavaDoc {
16     log.debug("starting jbpmSessionFactory for '" + jndiName + "'...");
17     // Configuration configuration = JbpmSessionFactory.createConfiguration("hibernate.cfg.xml");
18
JbpmSessionFactory jbpmSessionFactory = JbpmSessionFactory.buildJbpmSessionFactory();
19     InitialContext JavaDoc rootCtx = new InitialContext JavaDoc();
20     Name JavaDoc 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 JavaDoc {
26     try {
27       InitialContext JavaDoc rootCtx = new InitialContext JavaDoc();
28       rootCtx.unbind(jndiName);
29       NonSerializableFactory.unbind(jndiName);
30     } catch (NamingException JavaDoc e) {
31       log.error("Failed to unbind jbpmSessionFactory", e);
32     }
33   }
34
35   public String JavaDoc getJndiName() {
36     return jndiName;
37   }
38   public void setJndiName(String JavaDoc jndiName) {
39     this.jndiName = jndiName;
40   }
41 }
42
Popular Tags