Chapter 6 Defining Component Interfaces
Jaguar Manager provides a Java import feature that creates a component definition by reading method definitions from a compiled Java class or interface file (to import a JavaBean, you must specify the class that implements the JavaBean). The import process creates a corresponding IDL interface in the Jaguar interface repository. This feature is primarily used to adapt existing Java classes to be run as Java components within Jaguar. However, you can import a Java interface to define a component of any type.
PowerJ uses the Java class importer Jaguar components defined with the PowerJ Jaguar Component Wizard use the type mappings described here.
Before using the importer for the first time, you should read this section to understand how Java methods are mapped to Jaguar component methods.
Each method in a class or interface (including those inherited from a base class or interface) is inspected to see if they use allowable parameter and return types. Suitable methods are added to the component's IDL interface. Jaguar Manager displays warning dialog boxes describing any methods that are not imported. The importer accepts methods that use the following datatypes:
Java/IDL
.
Otherwise, the Component Type field is set to Java/JDBC
.
If you import a class that ran as a Jaguar version 1.1 component,
it will be assigned the Java/JDBC component
type. The method can throw any exception, but only exceptions that extend org.omg.CORBA.UserException are added to the IDL method's raises clause.
Holders for user-defined classes and arrays For an inout parameter declared as a user-defined class or a single-dimension array, the Java method definition must use a holder class that you have created. For a user-defined class, the template for the holder class is as follows:
package comp-package;
class TypeHolder {
Type value;
// Default constructor:
TypeHolder();
// Initial-value constructor:
TypeHolder(Type value);
}
For an array, the template for the holder class is as follows:
package comp-package;
class TypenameHolder {
BaseType value;
// Default constructor:
TypenameHolder();
// Initial-value constructor:
TypnameHolder(BaseType[] value);
}
Methods to be imported from a Java interface must adhere to the restrictions described in "Determining eligible methods". In addition, the interface cannot contain any fields.
You must specify a class that implements the interface before you can run the component. Specify the implementation class name in the Component Properties window (see "General component properties"). Make sure that the class has a default constructor (that is, a constructor with no arguments). Jaguar calls the default constructor to create new component instances.
Methods to be imported from a Java class must adhere to the restrictions described in "Determining eligible methods". In addition, the class must have a constructor method with zero parameters. Other constructors are not called by Jaguar.
Classes that implement the ServerBean interface can be imported. The ServerBean methods are not added to the component's IDL interface.
To import method definitions from a JavaBean, you choose the Java Class option on the import screen, then specify the name of the class that implements the JavaBean.
Methods to be imported from a JavaBean must adhere to the restrictions described in "Determining eligible methods". In addition, the JavaBean must have a constructor method with zero parameters. Other constructors are not imported. If the JavaBean is packaged in a Java Archive (JAR) file, make sure that the full path name of the JAR file is in the CLASSPATH environment variable setting. If necessary, edit CLASSPATH and restart Jaguar Manager.
The add and remove methods for the JavaBean's event listeners are not imported.
You can import a Java class or interface in Jaguar Manager as follows:
The importer will read the specified file, define an IDL interface as described below, and define a component that implements the IDL interface.
Copyright © 2000 Sybase, Inc. All rights reserved. |