CORBA – VisiBroker
VisiBroker 3.x
Here are some additional details for the VisiBroker 3.x implementation of CORBA. See the product documentation for more details.
VisiBroker Tools
VisiBroker for Java ships with a number of tools. Some are replacements or wrappers for the standard Java compiler and interpreter. Others are specific to the VisiBroker product. The important ones are:
vbjis a wrapper forjavawhich sets some properties and adds to your classpathvbjcis a wrapper forjavacwhich sets some properties and adds to your classpathidl2javais an IDL compiler that can produce proprietary or portable stubs and skeletonsosagentlaunches the proprietary Smart Agent binding service
Using VisiBroker with Java 2
To make VisiBroker for Java 3.4 work with the Java 2 platform, a number of changes are necessary, involving both code and configuration.
The Java 2 platform ships with a standard implementation of CORBA classes in the org.omg.CORBA.* package. These classes are somewhat different from the CORBA classes included with VisiBroker. The VisiBroker classes have several nonstandard extensions to CORBA; some of these nonstandard extensions are required for successful operation. To access these functions, you must change your source code to cast the JavaIDL ORB to a VisiBroker ORB. For example:
org.omg.CORBA.ORB orb =
org.omg.CORBA.ORB.init(args, null);
org.omg.CORBA.BOA boa =
((com.visigenic.vbroker.orb.ORB)orb).BOA_init(
);
|
This example applies to the server code.
For this cast to work, you must also guarantee that the ORB returned by the ORB.init() call is indeed a VisiBroker ORB, and not the standard JavaIDL ORB from Sun. For that, you need to define two Java system properties before you launch the JVM. These properties are automatically set if you use vbj instead of java to launch your programs. But if you use java, you must set these properties as follows (where each lists the property name first and value second):
org.omg.CORBA.ORBClass-
com.visigenic.vbroker.orb.ORBorg.omg.CORBA.ORBSingletonClass-
com.visigenic.vbroker.orb.ORB
Portable Stubs and Skeletons
By default, VisiBroker for Java creates stub and skeleton code that is interoperable but not portable. This makes sense in the VisiBroker world, since the non-portable code is more efficient and slightly smaller. However, if your code needs to run on several different ORBs, you can use the command
idl2java -portable -no_bind Foo.idl
and the stubs and skeletons will be portable.
There are a few reasons for this. One is if you’re writing an applet that will run inside a remote web browser environment, such as Netscape Communicator or the Java Plug-in. The latter uses JavaIDL; the former may be running an older version of VisiBroker.
What’s the difference between portable and proprietary versions? A portable stub uses DII (Dynamic Invocation Interface) to marshal the object request; a portable skeleton uses DSI (Dynamic Skeleton Interface). The proprietary versions make direct calls (to the ORB or the implementation), and hence do not have to go through the overhead of creating and parsing the various DII and DSI objects.
Note that your code doesn’t need to change–this all happens behind the scenes with idl2java. The only difference in the portable code is that _FooImplBase extends org.omg.CORBA.DynamicImplementation instead of com.inprise.vbroker.CORBA.portable.Skeleton, and that the stub class is named _portable_stub_Foo.java instead of _st_Foo.java. (Note also that if you really want to, you can switch stubs on the fly by using FooHelper.setProxyClass(_portable_stub_Foo.class) — though that would be kind of weird).
Using the BOA with VisiBroker
The VisiBroker BOA uses a slightly modified version of the standard BOA initialization sequence. For VisiBroker, follow the following boilerplate code.
// create and initialize the ORB ORB orb = ORB.init(args, null);
The VisiBroker BOA is a customized, proprietary implementation of the CORBA.BOA interface. It has several methods that are not part of the standard interface. In order to use these proprietary methods, you must cast the ORB to a VisiBroker class, as follows.
// Initialize the BOA. // Must cast to VBJ ORB for //Java 2 compatibility org.omg.CORBA.BOA boa = ((com.inprise.vbroker.CORBA.ORB)orb).BOA_init(); |
VisiBroker objects are usually persistent. In VisiBroker terms, this means that they are initialized with a name. This is not needed with a portable, non-VisiBroker object implementation.
// create object and register it //with the ORB Stock theStock = new StockImpl(name);
The VisiBroker BOA skips the boa.create() phase and jumps straight to obj_is_ready().
// Export the newly created object. boa.obj_is_ready(theStock);
The impl_is_ready() method waits indefinitely.
// Wait for incoming requests boa.impl_is_ready();
Using the VisiBroker Smart Agent
VisiBroker for Java ships with its own location service, called the smart agent. The smart agent is a distributed location service. It collaborates with other smart agents running on the network to locate a suitable implementation of an object. If there is more than one implementation available; the smart agent selects one. This provides a degree of fault tolerance and load balancing. If a machine goes down, the smart agent will automatically find another implementation on another machine to service the request. The client is unaware of this.
If you create a persistent object, by passing in a name when you call its constructor, then the BOA will automatically inform the smart agent. The name you passed in the constructor will become the name it is known by on the smart agent network.
On the client side, the proprietary Helper object defines a method bind() that fetches an object reference for you, bypassing the need to convert a string into an object reference. The bind() method is not part of the standard CORBA-Java mapping.
// "bind" (actually lookup) the //object reference Stock theStock = StockHelper.bind(orb, "GII");