1 // xmlBlaster/demo/HelloWorld.java
2 import org.xmlBlaster.client.I_XmlBlasterAccess;
3 import org.xmlBlaster.client.XmlBlasterAccess;
4 import org.xmlBlaster.util.MsgUnit;
5
6
7 /**
8 * This client connects to xmlBlaster and gets synchronous a message and disconnects.
9 * <p />
10 * Invoke:
11 * <pre>
12 * cd xmlBlaster // Change to xmlBlaster distribution directory
13 * java -jar lib/xmlBlaster.jar // Start the server
14 * java -cp lib/xmlBlaster.jar HelloWorld // Start this demo
15 * </pre>
16 * @see <a href="http://www.xmlBlaster.org/xmlBlaster/doc/requirements/interface.html" target="others">xmlBlaster interface</a>
17 */
18 public class HelloWorld
19 {
20 public HelloWorld(String[] args) {
21 try {
22 I_XmlBlasterAccess con = new XmlBlasterAccess(args);
23
24 con.connect(null, null); // Login to xmlBlaster as "guest"
25
26 MsgUnit[] msgs = con.get("<key oid='__cmd:?freeMem'/>", null);
27
28 System.out.println("\nHelloWorld: xmlBlaster has currently " +
29 new String(msgs[0].getContent()) + " bytes of free memory\n");
30
31 con.disconnect(null);
32 }
33 catch (Exception e) {
34 System.err.println("HelloWorld: We have a problem: " + e.toString());
35 }
36 }
37
38 public static void main(String args[]) {
39 new HelloWorld(args);
40 }
41 }
syntax highlighted by Code2HTML, v. 0.9.1