Cajo

from Wikipedia, the free encyclopedia

The cajo project is a small, free Java class library. It enables cooperation between several virtual machines . The goal is to simplify the use of RMI .

The simplification compared to RMI is to be achieved as follows.

  1. In contrast to RMI, no explicit interfaces are defined.
  2. No RMI compiler is required, instead of generating code, calls are made at runtime via reflection .

Since no RMI compiler is required with the introduction of Java 5.0, this API should increasingly lose its importance.

Code example

The following example shows a simple server that simply transmits the character string "Hello Client " to the client, with the name of the client being transferred via parameters. The method mainstarts the server.

import gnu.cajo.invoke.Remote;
import gnu.cajo.utils.ItemServer;

public class MyServer {

    public String hallo(String client) {
        return "Hallo " + client;
    }

    public static void main(String args[]) {
        try {
            Remote.config(null, 1198, null, 0);
            ItemServer.bind(new MyServer(), "einName");
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

}

The matching client could look like this, where is serverHostthe name of the machine on which the server is running:

import gnu.cajo.invoke.Remote;

public class SomeClient {

    public static void main(String args[]) {
        try {
            Object server = Remote.getItem("//serverHost:1198/einName");
            String s = (String)Remote.invoke(server, "hallo", "Wiki");
            System.out.println(s);
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
}

This client program would output "Hello Wiki".

properties

As can be seen from the example, the lack of an explicit interface has the disadvantage that the client's code is somewhat more difficult to read. Instead of writing as when using an RMI interface, server.hallo("Wiki")it is written Remote.invoke(server, "hallo", "Wiki").

Since Java 5, it has also been possible to dispense with the generation of client-side stub code and server-side skeleton code when using RMI, so that the second advantage is no longer significant.

The source code is available under the LGPL (v3 or later).

On August 5, 2005, after more than a year and extensive control, the IANA assigned the official port number 1198 to the cajo project .

See also

Web links

Individual evidence

  1. cajo.dev.java.net  ( page no longer available , search in web archivesInfo: The link was automatically marked as defective. Please check the link according to the instructions and then remove this notice.@1@ 2Template: Dead Link / cajo.dev.java.net  
  2. iana.org IANA port number