Appendix C Creating Jaguar 1.1 Java Clients


Generate Jaguar 1.1 Java stubs

The Jaguar Manager creates a Java stub class and Java interface for each component. A Java stub class allows a Java client to create instances of a component on the server and to execute the component's methods as though the component were a local Java object. The Java stub class hides the details of remote method execution from the Java client. A Java stub method remotely executes a like-named method in the component.

For example, for a component named "Stock," the Jaguar Manager creates the Java files Stock.java and StockIntf.java. StockIntf.java defines a Java interface that defines Java stub methods, and Stock.java implements the Java interface. The Java interface contains the following elements:

The stub class implements the stub interface, and contains additional methods that are required for retrieving row results.

Note   Stubs for different client models If you are generating stubs for multiple client models, such as Jaguar 1.1and CORBA, stubs for each model must be generated to a different codebase or Java package.

Note   Component interface restriction For compatibility with the Jaguar 1.1 stub model, a component's IDL interfaces may not contain create and destroy methods.

Generating stub source files

Generate stub source files in Jaguar Manager, as described below:

  1. Select the component or, to generate stubs for all components in a package, select the package.
  2. Select File | Generate Stub/Skeleton. The Generate Stubs & Skeletons dialog is displayed.
  3. Select the Generate Stubs and Generate Java Stubs options. Enter values in the Stubs fields as follows:
  4. Unselect the Generate C++ Stubs and Generate Skeletons options unless you wish to also create Skeletons and C++ stubs, respectively.
  5. Click the Generate button.

Avoiding name collisions with Java component files

When generating Java stubs for a Java component, you must ensure that the generated stubs will not collide with 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 if 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:

Generate Java stubs for all components

To generate Java stubs for all components on a single Jaguar server or all servers, start the Jaguar Manager and complete these steps:

Fill in the required properties and click Generate. Required properties are:

Generated package directories and source files

Jaguar Manager creates Java package subdirectories for the generated stubs based on the code base and package name, as follows:

code_base/stub_package_name

where

code_base is the value from the Code Base field in Jaguar Manager. If you leave the field blank, stubs are generated in your home directory.

stub_package_name is the package name for the generated stubs. Jaguar Manager creates stubs in a package subdirectory below the directory specified as the Code Base field 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. If a component implements interfaces from more than one module, Jaguar 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 stub source files".

For example, the following UNIX directory structure is created if the code base is user, and the package name is com.sybase.samples. The code base is appended to the working directory, which is /opt/Jaguar/html/classes.

/opt/Jaguar/html/classes/user/com/sybase/samples

In each package directory, Jaguar Manager generates stubs for each interface and type that is defined in the module associated with the Java package. For each interface, the following files are created:

Jaguar Manager generates stubs for each interface and type that is defined in a module, and stubs are generated for all modules that are referenced by the component. Consequently, you may see additional generated files besides those that represent interfaces that are implemented by your component.

 


Copyright © 2000 Sybase, Inc. All rights reserved.