Developing an EJB client  Instantiating home interface proxies

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.

NoteBefore 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 code base or Java package.

StepsGenerating EJB stubs

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

    NoteSpecifying 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. When generating stubs for a module, you can override the default package name.

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

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

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.

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