1 /*
2 * Created on 11.jul.2003
3 *
4 */
5 package net.sf.panoptes.module.jmx.connector;
6
7 import java.net.InetAddress;
8 import java.util.Properties;
9
10 import javax.management.MBeanServerConnection;
11 import javax.naming.Context;
12
13 import org.jboss.jmx.connector.rmi.RMIConnectorImpl;
14
15 /***
16 *
17 *
18 * @author Dag Liodden
19 * @version 0.1
20 */
21 public class JBossRMIConnector implements MBeanServerConnector {
22
23 private String hostName;
24 private int port;
25
26 public void setProperties(Properties properties) {
27 hostName = (String) properties.get("hostname");
28 port = Integer.parseInt((String) properties.get("port"));
29 }
30
31 public MBeanServerConnection connect() throws Exception {
32
33
34 if (hostName.equals("localhost")) {
35 hostName = InetAddress.getLocalHost().getHostName();
36 }
37
38 // Is it possible to use a user-provided props table in JBoss?
39 System.setProperty(Context.PROVIDER_URL, "jnp://" + hostName + ":" + port);
40 System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
41 System.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
42
43
44 return new RMIConnectorImpl(RMIConnectorImpl.NOTIFICATION_TYPE_RMI, null, hostName);
45 }
46
47
48 }
This page was automatically generated by Maven