The List example
The List example illustrates the use of the Caffeine compiler and pass_by_value of complex types.
From this example, you will learn how to:
-
use java2iiop (Caffeine compiler) on interfaces written in Java
to generate the client stubs and server skeletons
-
Pass complex types by value
Directory Contents
-
List.java
The List interface written in Java. Note that this interface could both have been written using standard IDL.
-
ListUtility.java
This is the ListUtility interface. It has methods to manipulate the linked list defined above in List.java.
-
ListClient.java
This is the ListClient program which binds to the ListServer, creates lists, and calls operations on them.
-
ListServer.java
This is the ListServer, implementing the length, reverse(), sort methods.
-
Makefile (vbmake.bat on Windows): Used to build all the test targets.
Building this example
Typing make(vbmake on Windows) in the List subdirectory will cause the Listutility.java to be run through the javac compiler. The resulting ListUtility.class will then be run through the java2iiop tool which then generates ListUtilityHelper.java. It will also build the following classes for the examples described above:
-
ListServer.class
-
ListClient.class
Compilation Errors and Warnings
You will see the following compilation errors when you type make(vbmake on Windows) in the List subdirectory or when you explicitly compile List.java using JDK1.0.2:
prompt>javac List.java
javac List.java
List.java:3: Interface java.io.Serializable of class List not found.
public class List implements java.io.Serializable {
^
1 error
*** Error code 1
The above error occurs because the class that is being used by this example is not part of JDK1.0.2. The solution to this problem is to upgrade to JDK1.1.0 or higher.
Running this example
To run this example, first make sure that the VisiBroker Smart Agent (osagent
executable) is running on your network. Then start the ListServer using
the command:
prompt> vbj ListServer &
(start vbj ListServer on Windows)
// make the server run in the background
Next,
prompt> vbj ListClient
Return to the Pass by Value examples page.