|
PreCache NetInjector Documentation Center : PreCache NetInjector Application Development Common Cases, Publication Java |
|
|
|
Common Cases, publication code Java the full code sample for the Common Cases tutorial The sample for this tutorial presented more examples of setting attributes. While the process of publication is the same as in Basic Case, Publication Java, we have added statements for import com.precache.event.*; import java.io.*; public class pub2 { static { System.loadLibrary("event-j"); } public static void main(String argv[]) { Proxy p; Notification n1,n2; try { //Create a proxy for the channel and client. p = new Proxy(40,3002); //Create a notification. n1 = new Notification(p,"Sample.Chat"); //Set the values for the predefined attributes. n1.setPredefinedAttr("Message", n1.setPredefinedAttr("UserName","Jane"); n1.setPredefinedAttr("Age",10); n1.setPredefinedAttr("Gender",'F'); //Publish the notification. p.publish(n1); //Create a second notification. n2 = new Notification(p,"Sample.Chat"); //Set the values for the predefined attributes. n2.setPredefinedAttr("Message", n2.setPredefinedAttr("UserName", n2.setPredefinedAttr("Age",12); n2.setPredefinedAttr("Gender",'f'); //Set the value of a discretionary attribute. n2.addDiscretionaryAttr("Interest",
//Publish the second notification. p.publish(n2); } catch (Exception e) { e.printStackTrace(); } } } In the final tutorial chapter, Common Cases, Subscription Java, we will build the participating subscriber's application. |
|