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 object space using a set of linda-like
You can use out operations to put objects into an object space and
in/read operations get objects from the object space
(in removes the object, read returns a copy of it).
in and read return an object (if any) from the object
space that matches a template object that is passed as parameter to them.
The matching used by Jada is very easy to understand: an object matches
another object if they are instance of the same class and the
Object.equal() method return true.
You can override this default behaviour implementing the JadaItem
interface in your objects.
The Class class is used with a special meaning: in matching an
instance of this class act as a "jolly" and matches all the istance of the
So, e.g., the object
Class interger_class=new Integer(0).getClass();
matches any instance of the Integer class.
While this matching mechanism can be customized changing the behaviour of
the equals method it can still result too less expressive. This is
why Jada defines a new container class that has a very interesting matching
mechanism: the Tuple class.
An object space can be either local (jada.ObjectSpace and can be
shader between threads) or remote (jada.net.ObjectClient and can be
shared between applications) in order to building a distributed application;
in the latter case an object space server (jada.net.ObjectServer)
must be running in a host of the network.
To test your installation you can try to run some of the programs in the
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:
If your compilation is succefull
you'll have three new class files: Ping.class, Pong.class and
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 object space and repeats tho three steps again.
The operation are performed on the object_space object 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 object space and runs
Ping and Pong as concurrent threads passing them the newly
created object space to be shared.
If you run the PingPong class:
you'll the the two Ping and Pong threads that coordinate
themselves using the object 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 object space server (I'm assuming you'll use a
different terminal window for each application):
(you can use the -v switch to see what
the object server is doing). Then we have to run the ping application:
and the pong one:
Now we can switch to a really distributed environment: say we have three
hosts: alpha, beta and gamma. We can run the
object 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
object 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:
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 3.0tm)
or the appletviewer to load the ping applet:
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:
- Object that can be removed from the object space after an amount of
- Think about an eval-like operation.