1 16 17 package org.springframework.jmx.access; 18 19 import java.net.MalformedURLException ; 20 21 import javax.management.MBeanServerConnection ; 22 import javax.management.remote.JMXConnector ; 23 import javax.management.remote.JMXConnectorFactory ; 24 import javax.management.remote.JMXConnectorServer ; 25 import javax.management.remote.JMXConnectorServerFactory ; 26 import javax.management.remote.JMXServiceURL ; 27 28 import org.springframework.core.JdkVersion; 29 30 33 public class RemoteMBeanClientInterceptorTests extends MBeanClientInterceptorTests { 34 35 private static final String SERVICE_URL = "service:jmx:jmxmp://localhost:9876"; 36 37 private JMXConnectorServer connectorServer; 38 39 private JMXConnector connector; 40 41 public void setUp() throws Exception { 42 super.setUp(); 43 this.connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(getServiceUrl(), null, server); 44 this.connectorServer.start(); 45 } 46 47 private JMXServiceURL getServiceUrl() throws MalformedURLException { 48 return new JMXServiceURL (SERVICE_URL); 49 } 50 51 protected MBeanServerConnection getServerConnection() throws Exception { 52 if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_14) { 53 return super.getServerConnection(); 55 } 56 57 this.connector = JMXConnectorFactory.connect(getServiceUrl()); 58 return this.connector.getMBeanServerConnection(); 59 } 60 61 public void tearDown() throws Exception { 62 if (this.connector != null) { 63 this.connector.close(); 64 } 65 this.connectorServer.stop(); 66 super.tearDown(); 67 } 68 69 } 70 | Popular Tags |