ODB
The odb example shows how an arbitrary number of Objects can be created
by a service. The Reference data used by each Object is stored as
part of the IOR. Only the service gets registered with an agent
and not individual Objects. This facilitates OODB integration - Can store
object keys as part of Object Reference. The BOA will call user defined
Activators if the appropriate object is not yet created (The application
can then load the object from persistent storage).
From this example, you will learn how to:
-
Use string_to_object() and object_to_string()
-
Use user defined activators to create objects in the server
Directory Contents
-
db.idl
IDL interface or DB and DBObject.
-
Server.java
Use the Service/Activators to create objects, return them and deletes
them.
-
Creator.java
Calls the DB interface to create 100 objects and stores the
"stringified object references" in a file.
-
Client.java
Reads the "stringified object references" from the file and makes
calls on them. This would have the effect of Activators getting
called on the server to create the objects.
-
Makefile (vbmake.bat on Windows)
Used to build client and server programs.
Building this example
Typing make(vbmake on Windows) in the odb subdirectory
will cause the following classes to be built:
-
Server.class: The DB server
-
Creator.class: Object creator
-
Client.class: Object client
Compilation Errors and Warnings
You will see the following compilation warnings when you type make(vbmake
on Windows) in the odb subdirectory or when you explicitly
compile Client.java and Creator.java
using:
prompt>javac Client.java
Note: Client.java uses a deprecated API. Recompile with
"-deprecation" for details.
1 warning
prompt>javac Creator.java
Note: Creator.java uses a deprecated API. Recompile with
"-deprecation" for details.
1 warning
These warnings occur because the example uses a Java API that has been
deprecated since JDK1.1. The calls to the deprecated Java API have not
been changed for the sake of JDK1.0.2 users.
You may also see the following compilation error when you compile this
example using either JDK1.0.2 or JDK1.1.1:
prompt>javac Server.java
Server.java:3: Package org.omg.CORBA not found in import.
import org.omg.CORBA.*;
^
Server.java:4: Package com.visigenic.vbroker.extension not found in import.
import com.visigenic.vbroker.extension.*;
^
2 errors
*** Error code 1
make: Fatal error: Command failed for target `Server.class'
The above error occurs because the javac compiler in JDK1.0.2 and JDK1.1.1
cannot locate packages imported from JAR files. The solution to this problem
is to either:
-
Unjar the vbjorb.jar file found in the VisiBroker for Java 3.2 installation/lib
directory using the following command:
prompt>jar xvf vbjorb.jar
Modify the example: delete the import statment and explicitly prefix each
occurrence of classes from the imported package with the complete package
name.
Upgrade to JDK1.1.2 or higher
Running this example
To run the examples, first make sure that the VisiBroker Smart Agent (osagent
executable) is running on your network. Then start the server using the
command:
prompt> vbj Server &
(start vbj Server on Windows)
// Run Server in the background
Next, run the creator:
prompt> vbj Creator
The creator program creates 100 objects, writes the object references to
a file and exits.
Kill the server that you started above. Then, restart it by typing
the command:
prompt> vbj Server &
(start vbj Server on Windows)
// Run Server in the background
Next, run the client.
prompt> vbj Client
The client reads the object references from the file and calls get_name
on them.
Return to the top-level examples page.