View Javadoc
1 /* 2 * Created on 07.jun.2003 3 * 4 */ 5 package net.sf.panoptes.module.jmx; 6 7 import javax.management.MBeanServer; 8 import javax.management.MBeanServerFactory; 9 import javax.management.Notification; 10 import javax.management.NotificationListener; 11 import javax.management.ObjectName; 12 13 import net.sf.panoptes.model.component.Component; 14 import net.sf.panoptes.model.component.ComponentUtil; 15 import net.sf.panoptes.model.component.registry.ComponentAlreadyExistsException; 16 import net.sf.panoptes.model.component.registry.MalformedComponentNameException; 17 import net.sf.panoptes.model.node.NodeDescriptor; 18 19 import org.eclipse.swt.graphics.Image; 20 import org.jboss.mx.remote.MBeanServerConnection; 21 import org.jboss.mx.remote.connector.ConnectorFactory; 22 import org.jboss.mx.remote.discovery.multicast.MulticastDetector; 23 import org.jboss.mx.remote.server.CascadingAgent; 24 25 /*** 26 * 27 * 28 * @author Dag Liodden 29 * @version 0.1 30 */ 31 public class JMXDiscoveryComponent 32 extends Component 33 implements NotificationListener, ConnectorFactory.Listener { 34 35 public JMXDiscoveryComponent() { 36 } 37 38 public void init() { 39 try { 40 ConnectorFactory.addListener(this); 41 MBeanServer server = MBeanServerFactory.createMBeanServer(); 42 43 /* SocketConnector sc = new SocketConnector(); 44 HashMap props = new HashMap(); 45 props.put("port", "1901"); 46 props.put("ipaddress", "127.0.0.1"); 47 sc.setTransportProperties(props); 48 server.registerMBean(sc, new ObjectName("jmx:type=SocketConnector")); 49 sc.start(); */ 50 51 CascadingAgent agent = new CascadingAgent(); 52 server.registerMBean(agent, new ObjectName("jmx:type=CascadingAgent")); 53 agent.addNotificationListener(this, null, null); 54 55 MulticastDetector detector = new MulticastDetector(); 56 detector.setIP(MulticastDetector.DEFAULT_IP); 57 detector.setPort(MulticastDetector.DEFAULT_PORT); 58 detector.setDetectionDomain("JBOSS"); 59 60 server.registerMBean(detector, new ObjectName("jmx:type=MultiCastDetector")); 61 62 detector.start(); 63 64 agent.start(); 65 66 } catch (Exception e) { 67 e.printStackTrace(); 68 } 69 70 } 71 72 /* (non-Javadoc) 73 * @see net.sf.panoptes.model.node.Node#getConfigDescriptor() 74 */ 75 public NodeDescriptor getConfigDescriptor() { 76 return new NodeDescriptor("Discovered JMX Servers", ""); 77 } 78 79 /* (non-Javadoc) 80 * @see net.sf.panoptes.model.node.Node#getIcon() 81 */ 82 public Image getIcon() { 83 // TODO Auto-generated method stub 84 return null; 85 } 86 87 /* (non-Javadoc) 88 * @see javax.management.NotificationListener#handleNotification(javax.management.Notification, java.lang.Object) 89 */ 90 public void handleNotification(Notification arg0, Object arg1) { 91 // TODO Auto-generated method stub 92 93 } 94 95 /* (non-Javadoc) 96 * @see org.jboss.mx.remote.connector.ConnectorFactory.Listener#connectorCreated(javax.management.MBeanServer, org.jboss.mx.remote.MBeanServerConnection) 97 */ 98 public void connectorCreated(MBeanServer server, MBeanServerConnection conn) { 99 100 MBeanServerComponent newComp = new MBeanServerComponent(null); 101 newComp.setHostName(conn.getIPAddress().toString()); 102 newComp.setName("JBoss ID " + conn.getServerId()); 103 104 try { 105 getComponentRegistry().registerComponent(newComp, ComponentUtil.createMBeanServerName(newComp)); 106 newComp.setServer(server); 107 } catch (ComponentAlreadyExistsException e) { 108 // TODO Auto-generated catch block 109 e.printStackTrace(); 110 } catch (MalformedComponentNameException e) { 111 // TODO Auto-generated catch block 112 e.printStackTrace(); 113 } 114 } 115 116 /* (non-Javadoc) 117 * @see org.jboss.mx.remote.connector.ConnectorFactory.Listener#connectorDestroyed(javax.management.MBeanServer, org.jboss.mx.remote.MBeanServerConnection) 118 */ 119 public void connectorDestroyed(MBeanServer server, MBeanServerConnection conn) { 120 // TODO Auto-generated method stub 121 122 } 123 124 }

This page was automatically generated by Maven