1 51 52 package org.objectweb.jass.as.jboss; 53 54 import javax.naming.Context ; 55 import javax.naming.InitialContext ; 56 57 import org.jboss.system.ServiceMBeanSupport; 58 import org.objectweb.jass.as.ActivityIdGenerator; 59 60 67 public class JBOSSActivityIdGeneratorService 68 extends ServiceMBeanSupport 69 implements JBOSSActivityIdGeneratorServiceMBean { 70 71 73 public static String JNDI_NAME = "ActivityIdGeneratorService"; 74 75 77 private static ActivityIdGenerator activityIdGenerator = 79 ActivityIdGenerator.getSingleton(); 80 81 83 85 88 public void startService() throws Exception { 89 Context ctx = new InitialContext (); 90 ctx.bind(JNDI_NAME, activityIdGenerator); 92 } 93 94 97 public void stopService() { 98 try { 99 Context ctx = new InitialContext (); 100 ctx.unbind(JNDI_NAME); 101 } catch (Exception e) { 102 log.error("Failed to unbind", e); 103 } 104 } 105 106 108 113 public String newActivityId() { 114 return activityIdGenerator.newActivityId().print(); 115 } 116 117 public String getLastGeneratedId() { 118 return activityIdGenerator.getLastId().print(); 119 } 120 } 121 | Popular Tags |