List of usage examples for javax.management.remote JMXServiceURL JMXServiceURL
public JMXServiceURL(String protocol, String host, int port, String urlPath) throws MalformedURLException
Constructs a JMXServiceURL
with the given parts.
From source file:com.ibm.soatf.component.osb.ServiceManager.java
public static JMXConnector initConnection(String hostName, int port, String userName, String password) throws MalformedURLException, IOException { JMXServiceURL serviceUrl = new JMXServiceURL(DEFAULT_PROTO, hostName, port, JNDI_PREFIX + DomainRuntimeServiceMBean.MBEANSERVER_JNDI_NAME); HashMap<String, String> h = new HashMap<String, String>(); h.put(Context.SECURITY_PRINCIPAL, userName); h.put(Context.SECURITY_CREDENTIALS, password); h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, DEFAULT_PROTO_PROVIDER_PACKAGES); return JMXConnectorFactory.connect(serviceUrl, h); }
From source file:org.ngrinder.monitor.share.domain.MBeanClient.java
/** * Used to connect remote monitor JMX.// w w w .j a va 2s . c om * * @param hostName is the server name of target server * @param port is the JMX server's listener port of target monitor server * @throws IOException wraps JMX MalformedURLException exception */ public MBeanClient(String hostName, int port) throws IOException { this.jmxUrl = new JMXServiceURL("rmi", hostName, port, String.format(JMX_URI, hostName, port)); }
From source file:FullThreadDump.java
/** * Connect to a JMX agent of a given URL. */// w w w.j a v a 2 s . co m private void connect(String urlPath) { try { JMXServiceURL url = new JMXServiceURL("rmi", "", 0, urlPath); this.jmxc = JMXConnectorFactory.connect(url); this.server = jmxc.getMBeanServerConnection(); } catch (MalformedURLException e) { // should not reach here } catch (IOException e) { System.err.println("\nCommunication error: " + e.getMessage()); System.exit(1); } }
From source file:JTop.java
private static MBeanServerConnection connect(String hostname, int port) { // Create an RMI connector client and connect it to // the RMI connector server String urlPath = "/jndi/rmi://" + hostname + ":" + port + "/jmxrmi"; MBeanServerConnection server = null; try {/*from w w w . j a v a 2 s .c om*/ JMXServiceURL url = new JMXServiceURL("rmi", "", 0, urlPath); JMXConnector jmxc = JMXConnectorFactory.connect(url); server = jmxc.getMBeanServerConnection(); } catch (MalformedURLException e) { // should not reach here } catch (IOException e) { System.err.println("\nCommunication error: " + e.getMessage()); System.exit(1); } return server; }