1 12 13 package org.ejtools.jmx.browser.model.connector; 14 15 16 17 import java.util.Hashtable ; 18 19 20 21 import javax.management.MBeanServer ; 22 23 import javax.management.MBeanServerConnection ; 24 25 import javax.management.remote.JMXConnector ; 26 27 import javax.management.remote.JMXConnectorFactory ; 28 29 import javax.management.remote.JMXServiceURL ; 30 31 import javax.naming.Context ; 32 33 34 35 import org.ejtools.jmx.MBeanServerProxy; 36 37 import org.ejtools.jmx.browser.model.service.ConnectionMetaData; 38 39 40 41 42 43 52 53 public class RemotingConnectionService extends AbstractConnectionService 54 55 { 56 57 58 59 protected JMXConnector connector = null; 60 61 62 63 64 65 66 67 public void disconnect() 68 69 { 70 71 super.disconnect(); 72 73 try 74 75 { 76 77 this.connector.close(); 78 79 } 80 81 catch (Exception e) 82 83 { 84 85 87 } 88 89 this.setConnected(false); 90 91 } 92 93 94 95 96 97 102 103 protected void createMBeanServer() 104 105 throws Exception 106 107 { 108 109 System.setProperty("jmx.serial.form", "1.2"); 110 111 112 113 Hashtable props = new Hashtable (); 114 115 props.put(Context.INITIAL_CONTEXT_FACTORY, this.profile.getProperty(ConnectionMetaData.FACTORY)); 116 117 props.put(Context.URL_PKG_PREFIXES, this.profile.getProperty(ConnectionMetaData.PACKAGES)); 118 119 props.put(Context.PROVIDER_URL, this.profile.getProperty(ConnectionMetaData.URL)); 120 121 props.put(Context.SECURITY_PRINCIPAL, this.profile.getProperty(ConnectionMetaData.PRINCIPAL)); 122 123 props.put(Context.SECURITY_CREDENTIALS, this.profile.getProperty(ConnectionMetaData.CREDENTIALS)); 124 125 126 127 JMXServiceURL url = new JMXServiceURL (this.profile.getProperty(ConnectionMetaData.SERVICE)); 128 129 this.connector = JMXConnectorFactory.connect(url, props); 130 131 MBeanServerConnection connection = connector.getMBeanServerConnection(); 132 133 134 135 MBeanServer mbeanServer = MBeanServerProxy.createMBeanProxy(connection); 136 137 this.setMBeanServer(mbeanServer); 138 139 } 140 141 } 142 143 | Popular Tags |