Chapter 9 Creating Enterprise JavaBean Clients


Generating EJB stubs

Stub classes act as proxies for an instance of the Jaguar component. You can generate EJB 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.

Note   Before generating stubs If you are generating stubs for a component that is not an EJB Enterprise Bean, make sure the component has a home interface defined. See "Invoking non-EJB components from EJB clients" for more information.If you are generating stubs for multiple client models, stubs for each model must be generated to a different codebase or Java package.

Steps You can generate Java source files for stub classes from Jaguar Manager as follows:

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

    Note   Specifying a different Java package If stub classes must be generated using a Java package other than the default, generate stubs by highlighting the IDL module that contains the interfaces and datatypes of interest. See "Java packages" for more information.

  2. Select File | Generate Stub/Skeleton. The Generate Stubs & Skeletons dialog is displayed.

  3. Select the Generate Stubs option and the Generate Java Stubs option. Enter values in the Stubs fields as follows:

  4. Unselect the Generate C++ Stubs and Generate Skeletons options unless you wish to also create C++ stubs and skeletons, respectively.

  5. Click Generate.


Java packages

For each IDL module, Java equivalents for all interfaces, types, and exceptions that are defined in the module are generated to a single Java package. The default Java package name is specified by the module's name or the configured Java package mappings described in "Specifying Java package mappings for IDL modules".

Compiling stubs

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:

Table 9-1: Java stub source files for example interface calc

File Name

Purpose

Calc.java

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

Calc_Stub.java

Class that implements the interface.

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.

Compile the stub classes with a JDK 1.1 compiler. Make sure that the CLASSPATH setting contains the code base directory and the Jaguar html/classes subdirectory. For example:

set CLASSPATH=%JAGUAR%\html\classes;%JAGUAR%\java\classes;%CLASSPATH%
javac *.java

 


Copyright © 2000 Sybase, Inc. All rights reserved.