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.
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.
You can generate Java source files for stub classes
from Jaguar Manager as follows:
-
Highlight a component, package, or module as
follows:
- Highlight a component to generate
stubs for all interfaces and types required by a component,
- Highlight a package to generate all stubs needed
by components in the package, or
- Highlight a module in the IDL folder to generate
stubs for IDL interfaces and types defined within that module.
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.
-
Select File | Generate Stub/Skeleton.
The Generate Stubs & Skeletons dialog is displayed.
-
Select the Generate Stubs option and the Generate Java
Stubs option. Enter values in the Stubs fields as follows:
- Java Types Choose EJB.
- Java Version Choose
JDK 1.2 if any home interface has finder methods that return java.util.Collection.
Otherwise choose JDK 1.1.
- Generate File Type Choose either:
- JAR File - enter
the fully-qualified name of the JAR file into which the generated
stubs should be compiled.
The JAR file is always created locally. The path must be a
valid UNIX or Windows NT path, including a drive.
- Java Code Base - enter the top-level directory
path where generated files should be created.
The default path is the Jaguar html/classes subdirectory,
which is where applet classes must be deployed to allow downloading from
the Jaguar server. You can type a different path or use the Browse
button to select a directory.
The path must be a valid UNIX or Windows NT path. It can include
a drive and as many directories as you want. You can use %JAGUAR% or $JAGUAR
to specify subdirectories within the Jaguar installation directory,
for example:%JAGUAR%\html\classes
Other variable substitutions or shell aliases such as "~" to indicate
your home directory are not allowed.
If you clear the field, the default is your home directory
(specified by $HOME for UNIX and %home% for
NT).
If you specify a relative path, such as myclasses,
the path is interpreted relative to the Jaguar html/classes directory.
- Java Package Available only when generating stubs for an IDL module. Enter
the name of the Java package for the generated stubs, or leave blank
to use the default stub package names described in "Java packages".
-
Unselect the Generate C++ Stubs and
Generate Skeletons options unless you wish to also create C++ stubs
and skeletons, respectively.
-
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.
|
|