ListenerRegistrypublic class ListenerRegistry extends Object implements ListenerRegistrationListenerRegistry provides an implementation of ListenerRegistration
This implementation creates instances of RemoteListenerConnectors which
are registered on the MEJB on behalf of the local listener. |
Fields Summary |
---|
private Hashtable | listenerConnectors | private String | OMG_ORB_INIT_PORT_PROPERTY | private String | serverAddress | private Management | server | private boolean | debug |
Constructors Summary |
---|
public ListenerRegistry(String ip)
serverAddress = ip;
|
Methods Summary |
---|
public void | addNotificationListener(javax.management.ObjectName name, javax.management.NotificationListener listener, javax.management.NotificationFilter filter, java.lang.Object handback)Add a listener to a registered managed object.
String proxyAddress = EventListenerProxy.getEventListenerProxy().getProxyAddress();
try {
if(debug)System.out.println("ListenerRegistry:addNotificationListener(" + listener + ") to " + name);
RemoteListenerConnector connector = new RemoteListenerConnector(proxyAddress);
getMEJBUtility().addNotificationListener(name, connector, filter, connector.getId());
EventListenerProxy.getEventListenerProxy().addListener(connector.getId(), listener, handback);
listenerConnectors.put(listener, connector);
} catch (javax.management.InstanceNotFoundException inf) {
throw new java.rmi.RemoteException(inf.getMessage(), inf);
}
| Management | getMEJB()
if(server == null) {
try {
Context ic = new InitialContext();
String ejbName = System.getProperty("mejb.name","ejb/mgmt/MEJB");
java.lang.Object objref = ic.lookup(ejbName);
ManagementHome home = (ManagementHome)PortableRemoteObject.narrow(objref, ManagementHome.class);
server = (Management)home.create();
} catch (Exception ex) {
ex.printStackTrace();
}
}
/*if (server == null) {
try {
Context ic = new InitialContext();
String mejbJNDIName = System.getProperty("mejb.name","ejb/mgmt/MEJB");
String initialPort = System.getProperty(OMG_ORB_INIT_PORT_PROPERTY);
if (initialPort == null)
initialPort = String.valueOf(ORBManager.getORBInitialPort());
String corbaName = "corbaname:iiop:" + serverAddress + ":" + initialPort + "#" + mejbJNDIName;
java.lang.Object objref = ic.lookup(corbaName);
ManagementHome home = (ManagementHome)PortableRemoteObject.narrow(objref, ManagementHome.class);
server = (MEJB)home.create();
if (debug) System.out.println("ListenerRegistry connected to: " + corbaName);
} catch (RemoteException re) {
throw re;
} catch (Exception e) {
throw new RemoteException(e.getMessage(), e);
}
}*/
return server;
| MEJBUtility | getMEJBUtility()
return MEJBUtility.getMEJBUtility();
| public void | removeNotificationListener(javax.management.ObjectName name, javax.management.NotificationListener listener)Remove a listener from a registered managed object.
EventListenerProxy proxy = EventListenerProxy.getEventListenerProxy();
try {
if(debug) {
System.out.println("removeNotificationListener: " + listener);
System.out.println("listenerProxy = " + listenerConnectors.get(((RemoteListenerConnector)listener).getId()));
}
RemoteListenerConnector connector = ((RemoteListenerConnector)listenerConnectors.get(listener));
getMEJBUtility().removeNotificationListener(name, connector);
proxy.removeListener(connector.getId());
listenerConnectors.remove(listener);
} catch (javax.management.InstanceNotFoundException inf) {
throw new java.rmi.RemoteException(inf.getMessage(), inf);
} catch (javax.management.ListenerNotFoundException lnf) {
throw new java.rmi.RemoteException(lnf.getMessage(), lnf);
}
|
|