aboutsummaryrefslogtreecommitdiff
path: root/doc/html/guide/first.html
diff options
context:
space:
mode:
authorjestin2000-08-16 18:08:19 +0000
committerjestin2000-08-16 18:08:19 +0000
commitbba0d7da93db5a33f5a5e16b476d4ac5b5a88be3 (patch)
tree800e6aa5fb9aea7487259e19d6cbdb9626b42b07 /doc/html/guide/first.html
parent32dd3ad48a8e63618db4ea17316bcc57cb778a30 (diff)
downloadivy-java-bba0d7da93db5a33f5a5e16b476d4ac5b5a88be3.zip
ivy-java-bba0d7da93db5a33f5a5e16b476d4ac5b5a88be3.tar.gz
ivy-java-bba0d7da93db5a33f5a5e16b476d4ac5b5a88be3.tar.bz2
ivy-java-bba0d7da93db5a33f5a5e16b476d4ac5b5a88be3.tar.xz
First version of java api guide.
Diffstat (limited to 'doc/html/guide/first.html')
-rw-r--r--doc/html/guide/first.html112
1 files changed, 112 insertions, 0 deletions
diff --git a/doc/html/guide/first.html b/doc/html/guide/first.html
new file mode 100644
index 0000000..97ab74c
--- /dev/null
+++ b/doc/html/guide/first.html
@@ -0,0 +1,112 @@
+<html>
+<head>
+ <title>your first Ivy java application </title>
+</head>
+<body>
+ <table width=100% border=0 cellpadding=0 cellspacing=0><tr><th colspan=3 align=center>
+ The Ivy java library guide</th></tr><tr>
+ <td width=10% align=left valign=bottom><a href="javalib.html">Prev</a></td>
+ <td width=80% align=center valign=bottom>
+ <td width=10% align=right valign=bottom><a href="basic.html">Next</a></td>
+ </tr></table><hr>
+
+ <h1>Your first Ivy java application</h1>
+
+ <p>We are going to write a "Hello world translater" for an Ivy bus. The
+ application will subscribe to all messages starting
+ with "Hello", and re-emit them after translating "Hello" into "Bonjour". In
+ addition, the application will quit when it receives any message containing
+ exactly "Bye".
+
+ <h2>The code</h2>
+ There is the code of <a href="ivyTranslater.java">ivyTranslater.java</a>:
+
+<TABLE cellpadding=0 cellspacing=0 width=100%>
+<tr BGcolor=#e0e0e0 TEXT=#000000><td>
+<PRE>
+<FONT color=#c000c0>import</FONT> fr.dgac.ivy.* ;
+
+<FONT color=#008000>class</FONT> ivyTranslater <FONT color=#008000>implements</FONT> IvyMessageListener {
+
+ <FONT color=#008000>private</FONT> Ivy bus;
+
+ ivyTranslater() {
+ <FONT color=#0000c0>// initialization</FONT>
+ bus = <FONT color=#804000>new</FONT> Ivy(<FONT color=#c00000>&quot;IvyTranslater&quot;</FONT>,<FONT color=#c00000>&quot;Hello le monde&quot;</FONT>,<FONT color=#c00000>null</FONT>);
+ bus.bindMsg(<FONT color=#c00000>&quot;^Hello(.*)&quot;</FONT>,<FONT color=#008000>this</FONT>);
+ bus.bindMsg(<FONT color=#c00000>&quot;^Bye$&quot;</FONT>,<FONT color=#804000>new</FONT> IvyMessageListener() {
+ <FONT color=#0000c0>// callback for </FONT><FONT color=#c00000>&quot;Bye&quot;</FONT><FONT color=#0000c0> message</FONT>
+ <FONT color=#008000>public</FONT> <FONT color=#008000>void</FONT> receive(IvyClient client, String[] args) {System.exit(<FONT color=#c00000>0</FONT>);}
+ });
+ <FONT color=#804000>try</FONT> {
+ <FONT color=#0000c0>// starts the bus on the default domain or IVY_DOMAIN property</FONT>
+ bus.start(<FONT color=#c00000>null</FONT>);
+ } <FONT color=#804000>catch</FONT> (IvyException ie) {
+ System.err.println(<FONT color=#c00000>&quot;can't run the Ivy bus&quot;</FONT> + ie.getMessage());
+ }
+ }
+
+ <FONT color=#0000c0>// callback associated to the </FONT><FONT color=#c00000>&quot;Hello&quot;</FONT><FONT color=#0000c0> messages</FONT><FONT color=#c00000>&quot;</FONT>
+ <FONT color=#008000>public</FONT> <FONT color=#008000>void</FONT> receive(IvyClient client, String[] args) {
+ bus.sendMsg(<FONT color=#c00000>&quot;Bonjour&quot;</FONT>+((args.length&gt;<FONT color=#c00000>0</FONT>)?args[<FONT color=#c00000>0</FONT>]:<FONT color=#c00000>&quot;&quot;</FONT>));
+ }
+
+ <FONT color=#008000>public</FONT> <FONT color=#008000>static</FONT> <FONT color=#008000>void</FONT> main(String args[]) { <FONT color=#804000>new</FONT> ivyTranslater(); }
+}
+</PRE>
+</td></tr></table>
+
+ <h2>Compiling</h2>
+ <p>On a Unix computer, you should be able to compile the application with the
+ following command :
+
+<table cellpadding=0 cellspacing=0 width=100%>
+<tr bgcolor=#e0e0e0 text=#000000><td>
+$ javac ivyTranslater.java
+<br>$
+</td></tr></table>
+
+ <h2>Testing</h2>
+ <p>We are going to test our application with Probe. In a terminal window,
+ launch ivyTranslater:
+
+<table cellpadding=0 cellspacing=0 width=100%>
+<tr bgcolor=#e0e0e0 text=#000000><td>
+$ java ivyTranslater
+<br>&nbsp;
+</td></tr></table>
+
+ <p>Then in another terminal window, launch Probe. You are then ready to
+ start, Type "Hello Paul", and you should get "Bonjour Paul". Then Type "Bye",
+ and your application should quit :
+
+<table cellpadding=0 cellspacing=0 width=100%>
+<tr bgcolor=#e0e0e0 text=#000000><td>
+$ java fr.dgac.ivy.Probe '(.*)'
+<br>you want to subscribe to (.*)
+<br>broadcasting on 127.255.255.255:2010
+<br>IvyTranslater connected
+<br>IvyTranslater subscribes to ^Bye$
+<br>IvyTranslater subscribes to ^Hello(.*)
+<br>IvyTranslater sent 'Hello le monde'
+<br><b>Hello Paul</b>
+<br>-&gt; Sent to 1 peers
+<br>IvyTranslater sent 'Bonjour Paul'
+<br><b>Bye</b>
+<br>-&gt; Sent to 1 peers
+<br>IvyTranslater disconnected
+<br>&lt;Ctrl-D&gt;
+<br>$
+</td></tr></table>
+
+ <p><hr><table width=100% border=0 cellpadding=0 cellspacing=0><tr>
+ <td width=33% align=left valign=top><a href="javalib.html">Prev</a></td>
+ <td width=34% align=center valign=top><a href="index.html">Home</a></td>
+ <td width=33% align=right valign=top><a href="basic.html">Next</a></td>
+ </tr><tr>
+ <td width=33% align=left valign=top>The Ivy java library</td>
+ <td width=34% align=center valign=top>&nbsp;</td>
+ <td width=33% align=right valign=top>Basic functions</a></td>
+ </tr></table>
+</body>
+</html>