Java Reference
In-Depth Information
. . .
public void addObserver(String observerURL,
String eventName)
throws java.rmi.RemoteException {
subscriptions.add( new DSubscription(observerURL,
eventName, this .getURL()));
// This method is invoked by subclasses of DActivity when
// state transitions occur
public void notifyEvent(DEvent event) {
for ( int i # 0; i < subscriptions.size(); i !! )
((DSubscription) subscriptions.get(i)).
// This method is invoked by remote observable activities
// to notify events
public void updateEvent( final DEvent event)
throws java.rmi.RemoteException {
Thread thread # new Thread() {
public void run() { update(event); }
// this is executed when an observed activity raises an
// event; it should be overridden in every subclass
public void update(DEvent event){}
Class Runner and class Animator must be extended in order to test the imple-
mentation of the distributed B
L paradigm described above. In particular,
method step() of class Runner invokes method notifyObservers() of class
DActivity to notify event NEXT whenever the runner changes position, while
method update() of class Animator wakes up the thread when event NEXT is
notified. Method init() of class Animator subscribes to event NEXT of the
remote Runner activity to be notified of any new position.
import mmi.*;
// public interface RunnerInterface extends java.rmi.Remote {
public interface RunnerInterface extends DObservable {
public void setSpeed( int percent)
throws java.rmi.RemoteException;
public int getPosition() throws java.rmi.RemoteException;
Search WWH ::

Custom Search