Check out the new USENIX Web site. next up previous
Next: Episode I Up: Programming Example Previous: Publishing

Subscribing

In order to subscribe to a DAC, a callback object implementing the Notifiable interface must be provided. Figure 14 shows how to implement a simple callback object for chat sessions.



public interface Notifiable {

  public void notify(Object m);
}

public class ChatNotifiable
  implements Notifiable
{
  public void notify(Object m) {
    /* elements are of type ChatMsg */ 
    ChatMsg cm = (ChatMsg)m;
    System.out.println("Message from " + 
                       cm.getSender());
    System.out.println(cm.getText());
  }
}




Figure 14: Callback Object
  



 

Patrick Eugster
12/10/2000