Procedure for creating CORBA-compatible Java clients  Instantiating proxy instances

Chapter 12: Creating CORBA Java Clients

Generating Java stubs

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 EAServer 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.

NoteStubs 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 EAServer Manager or by using the command line IDL compiler (see Appendix D, “Using the Command Line IDL Compiler”).

StepsGenerating Java stubs in EAServer Manager

  1. Highlight a component, package, or module as follows:

    1. Highlight a component to generate stubs for all interfaces and types required by a component,

    2. Highlight a package to generate all stubs needed by components in the package, or

    3. Highlight a module to generate stubs for IDL interfaces and types defined within that module.

  2. Select File | Generate Stub/Skeleton. The Generate Stubs & Skeletons wizard displays. Follow the instructions on each page to generate Java/CORBA stubs. See the online help for descriptions of any input fields that you do not understand.

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:

Compiling stubs

For each IDL interface that is assigned to a component, EAServer 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, EAServer Manager creates the source files listed in the following table:

Table 12-1: IIOP Java stub source files for example component calc

File Name


Defines an interface with methods equivalent to the component’s methods.

Class that implements the interface.

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.

Used when interface references are passed as an inout or output parameter.

EAServer 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.

EAServer 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, EAServer 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 EAServer Manager”.

If you did not elect to compile the stubs in EAServer 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 © 2005. Sybase Inc. All rights reserved. Instantiating proxy instances