1 51 52 package org.objectweb.jass.hls.ont.jboss; 53 54 55 import org.objectweb.jass.hls.ont.ONT; 56 57 import javax.naming.Context ; 58 import javax.naming.InitialContext ; 59 import javax.naming.Reference ; 60 import javax.naming.Name ; 61 import javax.naming.spi.ObjectFactory ; 62 63 import org.jboss.system.ServiceMBeanSupport; 64 65 import java.util.Hashtable ; 66 67 73 public class ONTService 74 extends ServiceMBeanSupport 75 implements ONTServiceMBean, 76 ObjectFactory { 77 78 80 public static final String ONT_JNDI_NAME = "UserOpenNested"; 82 private static ONT ont = null; 84 85 87 89 92 public void startService() throws Exception { 93 94 log.info("Binding the ONT Service..."); 95 ont = ONT.getSingleton(); 96 bindRef(ONT_JNDI_NAME, "org.objectweb.jass.hls.ont.ONT"); 97 log.info("Binding done!!!"); 98 } 99 100 103 public void stopService() { 104 105 try { 106 Context ctx = new InitialContext (); 107 ctx.unbind(ONT_JNDI_NAME); 108 } catch (Exception e) { 109 log.error("Failed to unbind", e); 110 } 111 } 112 113 115 118 public Object getObjectInstance(Object obj, Name name, Context nameCtx, 119 Hashtable environment) throws Exception { 120 log.info(Thread.currentThread() + " Obtaining the ONT singleton..."); 121 return ont; 122 } 123 124 126 129 public ONT getONT() { 130 return ont; 131 } 132 133 134 136 141 private void bindRef(String jndiName, String className) 142 throws Exception { 143 Reference ref = new Reference (className, getClass().getName(), null); 144 new InitialContext ().bind(jndiName, ref); 145 } 146 147 } | Popular Tags |