Chapter 12 Creating CORBA Java Clients
Stub classes allow you to instantiate local Java objects that act as proxies for an instance of the EAServer component. You can generate Java stubs for components that are implemented in any of EAServer's supported component models. One stub interface is generated for each IDL interface that the component implements.
When using the EAServer 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 EAServer, you must export the IDL interface definitions, then use the vendor's IDL compiler to generate stubs. See "Connecting to EAServer 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").
Generating
Java stubs in Jaguar Manager
%JAGUAR%\html\classes
Deployment strategy | Specifies |
---|---|
Full | Generates Java types for every IDL interface and type referenced by the component. |
Incremental | Compares IDL and Java timestamps to determine
whether a new version of the Java type must be generated. See "IDL and Java timestamping" for more information.
Choosing this option can save generation time if you have not changed many IDL interfaces, and have previously generated CORBA stubs for the component, package, or module. |
Optimistic | Similar to Incremental, except that the check for changed classes in each module ends if the first comparison indicates no change. |
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:
File Name | Purpose |
---|---|
Calc.java | Defines an interface with methods equivalent to the component's methods. |
_st_Calc.java | Class that implements the interface. |
CalcHelper.java | Contains methods that are required by the ORB and by the application; for example, the ORB calls helper-class methods to read and write object instances to the network. |
CalcHolder.java | Used when interface references are passed as an inout or output parameter. |
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 "Generating Java stubs in Jaguar Manager".
If you did not elect to compile the 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 following:
Copyright © 2002 Sybase, Inc. All rights reserved. |
![]() |