Check out the new USENIX Web site. next up previous
Next: Performance Up: Subscribing Previous: Episode I

Episode II

Suppose now that Bob is only more interested in what Alice says about him. For this second condition, the text carried by each chat message must be checked for the occurrence of Bob's name. Remember that in JAVA a string s1 can be checked for the occurrence of a substring s2 by asking s1 through a call to indexOf() for the index of its first occurrence of s2. If s2 is not contained in s1, the call returns -1. The resulting second condition in the figure represents all messages which do not contain Bob's name, and must therefore be negated.

This example shown in Figure 16 illustrates how to easily combine basic conditions with the SimpleCondition interface, and how the application can specify the type of the message objects with implicit accessor creation, as required for the performance optimizations we propose in the next section.



...
/* connect */
DASet myChat = new DAStrongSet("/Chat/Insomnia");

/* create first condition, with type specification */
SimpleCondition onlyAlice = 
  new Equals("ChatMsg:/getSender", null, "Alice");

/* create args list and corresp. second condition */
Object[][] args = {{null}, {"Bob"}};
SimpleCondition notAboutMe = 
  new Equals("ChatMsg:/getText/indexOf", args, 
             new Integer(-1));

/* combine conditions */
SimpleCondition pattern = 
  onlyAlice.and(notAboutMe.not());

/* create callback object and subscribe */
Notifiable n = new ChatNotifiable();
myChat.contains(n, pattern);
...




Figure 16: Content-Based Subscribing (II)
  



Patrick Eugster
12/10/2000