The Dictionary example
The Dictionary example illustrates the use of the Caffeine compiler.
From this example, you will learn how to:
-
Use java2iiop (Caffeine compiler) on interfaces written in Java
to generate client stubs and server skeletons
Directory Contents
-
Dictionary.java
The Dictionary interface written in Java.
-
DictionaryClient.java
This is the Dictionary client. It binds to the Dictionary Server and puts a variety of data types into the Dictionary. the client passes a string, a vector, creates a hash table and a vector, fills them in with words and passes the built in types into the CORBA Dictionary. This shows the mixing and matching of built-in Java types which are all passed using Java serialization.
-
DictionaryServer.java
This is the Dictionary Server. The dictionary is implemented using a Java hash table. The benefit of using the Java hash table is that each of the methods that the Dictionary supports can be simply implemented as a one-line call to the underlying hash table.
-
Makefile (vbmake.bat on Windows): Used to build all the test targets.
Building this example
Typing make(vbmake on Windows) in the Dictionary subdirectory will cause the Dictionary.java to be run through the javac compiler. The resulting Dictionary.class will then be run through the java2iiop tool which reads in java bytecode and generates DictionaryHelper.java. It will also build the following classes for the examples described above:
-
DictionaryServer.class
-
DictionaryClient.class
Compilation Errors and Warnings
You will see the following compilation errors when you type make(vbmake on Windows) in the Dictionary subdirectory or when you explicitly compile Dictionary using JDK1.0.2:
prompt>java2iiop Dictionary
java.lang.NoSuchMethodError: java.lang.Class: method
getDeclaredMethods()[Ljava/lang/reflect/Method; not found
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 Dictionary server using
the command:
prompt> vbj DictionaryServer &
(start vbj DictionaryServer on Windows)
// make the DictionaryServer run in the background
Next,
prompt> vbj DictionaryClient
Return to the Pass_by_value examples page.