1 22 package org.jboss.test.jmx.invoker; 23 24 import java.rmi.RemoteException ; 25 import java.rmi.server.UnicastRemoteObject ; 26 import javax.management.Notification ; 27 import org.jboss.jmx.adaptor.rmi.RMINotificationListener; 28 29 33 public class RMIListener implements RMINotificationListener 34 { 35 private int expectedCount; 36 private int count; 37 38 public RMIListener(int expectedCount) 39 { 40 this.expectedCount = expectedCount; 41 } 42 public int getCount() 43 { 44 return count; 45 } 46 public void export() throws RemoteException 47 { 48 UnicastRemoteObject.exportObject(this); 49 } 50 public void unexport() throws RemoteException 51 { 52 UnicastRemoteObject.unexportObject(this, true); 53 } 54 public void handleNotification(Notification event, Object handback) 55 { 56 System.out.println("handleNotification, event: "+event+", count="+count); 57 count ++; 58 synchronized( this ) 59 { 60 if( count == expectedCount ) 61 notifyAll(); 62 } 63 } 64 } 65 | Popular Tags |