aboutsummaryrefslogtreecommitdiff
path: root/doc/ivy-java.sgml
diff options
context:
space:
mode:
authorjestin2006-08-01 09:24:10 +0000
committerjestin2006-08-01 09:24:10 +0000
commitd0afba319f95f0059d201c6b7cbfbc3322f2c0f6 (patch)
tree8da823c48b5843bf7022db1f3c53b63e85b8c4f5 /doc/ivy-java.sgml
parentd23e26197c375071459bbd6c5aa3d09c27020c31 (diff)
downloadivy-java-d0afba319f95f0059d201c6b7cbfbc3322f2c0f6.zip
ivy-java-d0afba319f95f0059d201c6b7cbfbc3322f2c0f6.tar.gz
ivy-java-d0afba319f95f0059d201c6b7cbfbc3322f2c0f6.tar.bz2
ivy-java-d0afba319f95f0059d201c6b7cbfbc3322f2c0f6.tar.xz
Adding a correct example of translator in XML
documentation update cleanup of IvyClient for Ping Pong
Diffstat (limited to 'doc/ivy-java.sgml')
-rw-r--r--doc/ivy-java.sgml51
1 files changed, 51 insertions, 0 deletions
diff --git a/doc/ivy-java.sgml b/doc/ivy-java.sgml
index 0e4d233..a7791c5 100644
--- a/doc/ivy-java.sgml
+++ b/doc/ivy-java.sgml
@@ -837,7 +837,58 @@ unsubscription will take place.
bus.sendMsg("MyRequest ID="+id+" QUER=2+2");
</programlisting>
</para>
+</sect2>
+<sect2><title>how to quit the application ?</title>
+<para>
+If your application decides to quit or leave the bus, the safest way is to
+invoque <function>Ivy.stop()</function>. This will send a clean goodby message
+to the other agents, close the sockets, end the threads, etc. However, you can
+en the JVM performing a <function>System.exit(int)</function> and let the
+other agents realize that you've gone.
+</para>
+<para>
+If some other agents wants you to quit the bus, it will send you a die
+message. The protocol will first run you
+<function>IvyApplicationListener.die()</function>, if any, then
+perform some socket/thread clean up, and disconnect you from the bus. As a
+good citizen on the Ivy bus, you should take the appropriate measures top stop
+your application within the <function>IvyApplicationListener.die()</function>
+method, for instance run <function>System.exit()</function> or make all you
+thread stop, disposing your toplevel Swing Frames. Here is an example of how to do it:
+<programlisting>
+import fr.dgac.ivy.* ;
+import javax.swing.*;
+
+public class EndApp extends IvyApplicationAdapter {
+
+ public static void main(String[] args) throws IvyException {
+ Ivy bus=new Ivy("EndApp","EndApp ready",null);
+ EndApp e = new EndApp(bus); // a frame is opened, and the Swing Thread is started
+ bus.addApplicationListener(e);
+ bus.start(Ivy.getDomain(null)); // Ivy threads are up and running
+ // the control flow won't stop until the end of all above threads
+ }
+
+ private Ivy bus;
+ JFrame f;
+
+ public EndApp(Ivy b) {
+ this.bus=b;
+ f=new JFrame("test");
+ f.getContentPane().add(new JLabel("some label"),java.awt.BorderLayout.CENTER);
+ f.pack();
+ f.setVisible(true);
+ }
+
+ public void die(IvyClient client, int id,String msgarg) {
+ System.out.println("received die msg from " + client.getApplicationName());
+ f.dispose(); // closes the only window, thus quitting the swing thread
+ } // end of die callback, the Ivy threads are stopped
+
+}
+</programlisting>
+</para>
</sect2>
</sect1>