Chapter 13 Creating CORBA-Compatible Java Clients
Stub classes allow you to instantiate local Java objects that act as proxies for an instance of the Jaguar component. You can generate Java stubs for components that are implemented in any of Jaguar's supported component models. One stub interface is generated for each IDL interface that the component implements.
When using the Jaguar ORB runtime, you must generate stubs with Jaguar Manager and compile them with a Java compiler. If you are using another ORB implementation class to connect to Jaguar, you must export the IDL interface definitions, then use the vendor's IDL compiler to generate stubs. See "Connecting to Jaguar with a third-party client ORB" for more information.
Stubs for different client models If you are generating stubs for multiple client models, such as EJB and CORBA, stubs for each model must be generated to a different codebase or Java package. "Specifying Java package mappings for IDL modules" describes how to change the Java package for stubs associated with each IDL module.
You can generate stubs in Jaguar Manager or by using the command line IDL compiler (see Appendix E, "Using the Command Line IDL Compiler").
To generate Java stubs in Jaguar Manager:
%JAGUAR%\html\classes
Avoiding name collisions with existing Java files When you are generating Java stubs for a Java component, you must ensure that the generated stubs will not overwrite existing Java classes or interfaces.
Name collision occurs if an unscoped IDL interface name matches the name of an existing class in the package to which you are generating stubs. For example, collision would occur if you generate stubs into the com.yourco package when the class com.yourco.Stock exists and the component implements the IDL interface YourCo::Stock. You can avoid name collisions using either of the following strategies:
For each IDL interface that is assigned to a component, Jaguar Manager generates a Java interface with the same name as the IDL interface, a stub class that implements that interface, a helper class, and a holder class. For example, for an IDL interface named Calculator::Calc, Jaguar Manager creates the source files listed in the following table:
Jaguar Manager creates stubs for each interface and datatype defined in a module. If your component references a module that contains multiple interfaces, you will find that additional stub files are generated besides the stubs for the interfaces that are directly implemented by your component.
Jaguar Manager creates stubs in a package subdirectory below
the directory specified as the code base in the Generate Stubs & Skeletons
dialog. By default, the Java package directory has the same name
as the IDL module in which the interface is defined. For example,
if the interface is Calculator::Calc, and you
specify a code base of c:\classes
,
the stubs will be created in c:\classes\Calculator.
If a component implements interfaces from more than one module, Jaguar Manager creates stubs for each module in separate packages that match each module name. You can specify a single Java package for all stubs as described in "To generate Java stubs in Jaguar Manager:".
Compile the stub classes with a compiler that is compatible with the desired Java version for the stubs. Make sure that the CLASSPATH setting contains the code base directory and the Jaguar html/classes subdirectory. For example, the following commands will compile the stub source files assuming that the IDL-interface and code base values from the example above are valid:
cd c:\classes\calculator
set CLASSPATH=c:\classes;%JAGUAR%\html\classes;%CLASSPATH%
javac *.java
Copyright © 2000 Sybase, Inc. All rights reserved. |