The Jada Package

Welcome to the Jada package docs.
Jada is a set of classes that allow threads or applications to access associatively a shared tuple space using a set of linda-like operations.
In Jada a tuple is a set of objects (often referred as items) and it is represented by the tuple.Tuple class.
A tuple space can be either local (tuple.TupleSpace and can be shader between threads) or remote (client.tupleClient and can be shared between applications) in order to building a distributed application; in the latter case a tuple space server (server.TupleServer) must be running in a host of the network.
To test your installation you can try to run some of the programs in the demo directory.
First of all you need to set your CLASSPATH directory (if you still have to do that) to the directory that contains the jada directory. Then you can compile PingPong.java:
javac PingPong.java
If your compilation is succefull you'll have three new class files: Ping.class, Pong.class and PingPong.class.
The run method of Ping class gets a tuple of the form (ping, ?Integer) (where integer is any object instance of the Integer class), creates a new Integer object (say, cnt) which is obtained adding 1 from the second field of the got tuple, puts the tuple (pong, cnt) into the tuple space and repeats tho three steps again. The operation are performed on the tuple_space tuple space which can be either a local or a remote one.
The Pong is specular to the Ping one (gets (pong, ?Integer) and puts (ping, Integer)). The PingPong class creates a new local tuple space and runs Ping and Pong as concurrent threads passing them the newly created tuple space to be shared. If you run the PingPong class:
java PingPong
you'll the the two Ping and Pong threads that coordinate themselves using the tuple space.
Now we can use the same classes for a distributed ping-pong application. Let's start with different applications running of the same host. First of all we have to run a tuple space server (I'm assuming you'll use a different terminal window for each application):
java jada.server.TupleServer
(you can use the -v switch to see what the tuple server is doing). Then we have to run the ping application:
java Ping
and the pong one:
java Pong
Now we can switch to a really distributed environment: say we have three hosts: alpha, beta and gamma. We can run the tuple server as usual in the alpha host. Now we can run the ping application on the beta host, but we have to tell the application where the remote server is:
java Ping alpha
The same applies for pong on the gamma host:
java Pong alpha
Et voila': we have now a really distributed ping-pong application.
We can do even more: we can run our distributed application on the WWW. We will run now the ping application in an applet form. The PingApplet class in the PingApplet.java file is an applet that can be embedded within an HTML document (ping.html is provided as example). Due to applet's security restriction we will have to run the tuple space server on the same host from which the applet is loaded (this is usually the host that runs your httpd server). Let's say this host has name http. We have to run the server on http:
java jada.server.TupleServer
Now we can run the pong application on any other host (or even from http):
java Pong http
You can now use your favourite Java enabled browser (such as Netscape 2.0tm) or the appletviewer to load the ping applet:
appletviewer http://http.your.domain/path/to/jada/demos/directory/ping.html
You should now see a scrolling list in your browser wich report the ping activity of your applet. Note: in the distribution tarfile there is a link from the demos directory to where the jada package directory hierarchy is supposed to be. If you change the directory structure you have to change this link (or really copy the jada directory) so that the browser will know where to look for jada classes in the remote host.
The ping-pong application is of course a silly example but you can do something really powerfull using Jada. Have fun!
Jada package API: a reference to the classes of the Jada package.
Things to do: