0
我需要在RMI服務中運行一個任務,並且需要爲它實現一個事件監聽器。現在,當我通過RMI傳遞EventListener時,它會執行調用,但是偵聽器的回調方法沒有被調用,並且它仍然處於等待狀態。我應該如何得到這個工作?通過RMI傳遞EventListener
public class MyEventListener implements Serializable, ABCEventListener {
private static final long serialVersionUID = -4686421592620210489L;
private boolean registrationCompleted = false;
public boolean getRegistrationCompleted(){
return registrationCompleted;
}
@Override
public void onSomethingDiscovered(Agent agent) {
System.out.println("Added agent "+agent.toString()+" to the set \n");
}
@Override
public void onDiscoveryComplete() {
this.registrationCompleted = true;
System.out.println("Discovery process completed. \n");
}
}
這裏就是我通過事件監聽到RMI服務「DS」
MyEventListener myEL = new MyEventListener();
ds.discoverAsync(val, myEL);
waitForRegistration();
.
.
private void waitForRegistration() {
try{
while(!dcev.getRegistrationCompleted()){
System.out.println("Please wait...");
Thread.sleep(15000);
}
}catch(InterruptedException e){
logger.error("InterruptedException raised while waiting for registration",e);
e.printStackTrace();
}
}
傳遞遠程對象鏈接已經死亡 – ZbyszekKr