1 23 24 package com.sun.enterprise.management.agent; 25 26 import java.rmi.Naming ; 27 import javax.management.*; 28 29 36 public class RemoteListenerConnector implements NotificationListener, java.io.Serializable { 37 38 private String proxyAddress; private RemoteEventListener listener = null; private MBeanServer server = null; private String id = hashCode() + ":" + System.currentTimeMillis(); 43 private boolean debug = false; 44 45 public RemoteListenerConnector(String address) { 46 proxyAddress = address; 47 } 48 49 public void handleNotification(Notification evt, Object h) { 50 try { 51 if (debug) System.out.println("RemoteListenerConnector.handleNotification()"); 52 if (listener == null) { 53 listener = (RemoteEventListener)Naming.lookup(proxyAddress); 54 } 55 listener.handleNotification(evt, h); 56 } catch (java.rmi.RemoteException ce) { 57 if (server != null) { 58 if (debug) System.out.println("RemoteListenerConnector.server.removeNotificationListener("+ (ObjectName)evt.getSource() + ", " + this + ")"); 59 try { 60 server.removeNotificationListener((ObjectName)evt.getSource(), this); 61 } catch (javax.management.ListenerNotFoundException e) { 62 if(debug) System.out.println(toString() + ": " + e); } catch (Exception e1) { 64 System.out.println(toString() + ": " + e1); 65 } 66 } 67 } catch (Exception e) { 68 System.out.println(toString() + ": " + e); 69 if (debug) { 70 try { 71 System.out.println("Naming.list(\"//localhost:1100\")"); 72 String [] names = Naming.list("//localhost:1100"); 73 for(int x=0;x<names.length;x++) { 74 System.out.println("names["+x+"] = " + names[x]); 75 } 76 } catch(Exception e1) { 77 e1.printStackTrace(); 78 } 79 } 80 } 81 } 82 83 public String getId() { 84 return id; 85 } 86 87 public void setMBeanServer(MBeanServer s) { 88 server = s; 89 } 90 } 91 | Popular Tags |