Java Reference
In-Depth Information
this .value # value;
}
}
class DSubscription {
private String eventName;
// the name of the observed event
private String observableURL;
// the URL of the observable activity
private String observerURL;
// the URL of the observer activity
private DObserver observer;
// a reference to the observer activity
public DSubscription(String observerURL, String eventName,
String observableURL){
this .observerURL # observerURL;
this .eventName # eventName;
this .observableURL # observableURL;
try { // gets a reference to the remote observer
this .observer # (DObserver) Naming.lookup(observerURL);
} catch (Exception e) { e.printStackTrace(); }
}
// notifies the remote observer
public void notifyObservers(DEvent event) {
if ( (eventName.equals(event.name) ||
eventName.equals("any")) &&
observableURL.equals(event.ownerURL) )
try {
observer.updateEvent(event);
} catch (RemoteException re) { re.printStackTrace(); }
}
}
public interface DObservable extends java.rmi.Remote {
public void addObserver
(String observerURL, String eventName)
throws java.rmi.RemoteException;
}
public interface DObserver extends java.rmi.Remote {
public void updateEvent(DEvent event)
t hrows java.rmi.RemoteException;
}
public abstract class DActivity extends UnicastRemoteObject
implements Runnable, DObservable, DObserver {
. . .
// the list of subscriptions
private ArrayList subscriptions # new ArrayList();
Search WWH ::




Custom Search