1 12 13 package org.ejtools.jmx.browser.model.connector; 14 15 16 17 import java.lang.reflect.Method ; 18 19 import java.util.Hashtable ; 20 21 22 23 import javax.management.MBeanServer ; 24 25 import javax.naming.Context ; 26 27 import javax.naming.InitialContext ; 28 29 import javax.rmi.PortableRemoteObject ; 30 31 32 33 import org.ejtools.jmx.MBeanServerProxy; 34 35 import org.ejtools.jmx.browser.model.service.ConnectionMetaData; 36 37 38 39 40 41 56 57 public class JBoss30EJBConnectionService extends AbstractConnectionService 58 59 { 60 61 62 63 protected Object adaptor = null; 64 65 66 67 68 69 70 71 public void disconnect() 72 73 { 74 75 super.disconnect(); 76 77 try 78 79 { 80 81 83 Method m = this.adaptor.getClass().getMethod("remove", new Class [0]); 84 85 m.invoke(this.adaptor, new Object [0]); 86 87 } 88 89 catch (Exception e) 90 91 { 92 93 95 } 96 97 this.setConnected(false); 98 99 } 100 101 102 103 104 105 114 115 protected void createMBeanServer() 116 117 throws Exception 118 119 { 120 121 System.setProperty("jmx.serial.form", "1.1"); 122 123 124 125 Hashtable props = new Hashtable (); 126 127 props.put(Context.INITIAL_CONTEXT_FACTORY, this.profile.getProperty(ConnectionMetaData.FACTORY)); 128 129 props.put(Context.URL_PKG_PREFIXES, this.profile.getProperty(ConnectionMetaData.PACKAGES)); 130 131 props.put(Context.PROVIDER_URL, this.profile.getProperty(ConnectionMetaData.URL)); 132 133 props.put(Context.SECURITY_PRINCIPAL, this.profile.getProperty(ConnectionMetaData.PRINCIPAL)); 134 135 props.put(Context.SECURITY_CREDENTIALS, this.profile.getProperty(ConnectionMetaData.CREDENTIALS)); 136 137 138 139 InitialContext context = new InitialContext (props); 140 141 Object ref = context.lookup(this.profile.getProperty(ConnectionMetaData.CONTEXT)); 142 143 144 145 Class clazzAdaptorHome = Thread.currentThread().getContextClassLoader().loadClass("org.jboss.jmx.adaptor.interfaces.AdaptorHome"); 146 147 Object home = PortableRemoteObject.narrow(ref, clazzAdaptorHome); 148 149 Method createMethod = clazzAdaptorHome.getMethod("create", new Class [0]); 150 151 this.adaptor = createMethod.invoke(home, new Object [0]); 152 153 154 155 MBeanServer server = MBeanServerProxy.createMBeanProxy(this.adaptor); 156 157 this.setMBeanServer(server); 158 159 } 160 161 } 162 163 | Popular Tags |