Chapter 8 Creating Enterprise JavaBeans Clients


Generating EJB stubs

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

Note   Before generating stubs If you are generating stubs for a component that is not an EJB component, 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 Generating EJB stubs

  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.

IDL and Java timestamping

EAServer uses IDL timestamps and a database of generation times for generated Java files. IDL timestamps are stored in the IDL file, as a doc comment in the form:

<!-- crc number -->

Where number is an integer CRC code. Java generation times are stored in the file Repository/deployclasstable.db in your EAServer installation.

In some cases, you may need to clear the Java timestamp database. For example, you may have installed new versions of EAServer IDL files with a patch release. To clear the timestamp database:

  1. Delete the file Repository/deployclasstable.db in your EAServer installation directory.
  2. Delete the EAServer gen subdirectory and all of its contents, including subdirectories.

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

If you did not elect to compile the stubs in Jaguar Manager, compile the stub classes. Make sure that the CLASSPATH setting contains the code base directory and the following JAR files in the EAServer installation directory:

 


Copyright © 2002 Sybase, Inc. All rights reserved.