1 package org.jboss.mx.remoting.rmi; 2 3 import java.io.IOException ; 4 import javax.management.NotificationBroadcasterSupport ; 5 import javax.management.remote.JMXConnectionNotification ; 6 import javax.management.remote.JMXConnector ; 7 8 import EDU.oswego.cs.dl.util.concurrent.SynchronizedLong; 9 10 16 public class ConnectionNotifier extends NotificationBroadcasterSupport 17 { 18 private JMXConnector connector; 19 20 private static SynchronizedLong sequenceNumber = new SynchronizedLong(0); 21 22 public ConnectionNotifier(JMXConnector connector) 23 { 24 this.connector = connector; 25 } 26 27 public void fireConnectedNotification() 28 { 29 JMXConnectionNotification notification = new JMXConnectionNotification (JMXConnectionNotification.OPENED, 30 connector, 31 getConnectionId(), 32 sequenceNumber.increment(), 33 "JMXConnector connected", 34 null); 35 sendNotification(notification); 36 } 37 38 private String getConnectionId() 39 { 40 String id = null; 41 try 42 { 43 id = connector.getConnectionId(); 44 } 45 catch(IOException e) 46 { 47 } 48 return id; 49 } 50 51 public void fireClosedNotification() 52 { 53 JMXConnectionNotification notification = new JMXConnectionNotification (JMXConnectionNotification.CLOSED, 54 connector, 55 getConnectionId(), 56 sequenceNumber.increment(), 57 "JMXConnector closed", 58 null); 59 sendNotification(notification); 60 } 61 } 62 | Popular Tags |