EAServer 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 JavaBeans component, you must specify the class that implements the JavaBeans component). The import process creates a corresponding IDL interface in the EAServer interface repository. This feature is primarily used to adapt existing Java classes to be run as Java components within EAServer. However, you can import a Java interface to define a component of any type.
Before using the importer for the first time, you should read this section to understand how Java methods are mapped to EAServer 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. EAServer Manager displays warning dialog boxes describing any methods that are not imported. The importer accepts methods that use the following datatypes:
Java equivalents for the predefined
EAServer datatypes “Choose implementation datatypes” describes
the Java equivalents for the predefined EAServer datatypes. If your
component uses the IDL/Java datatype mappings, the importer
sets the Component Type field to Java/IDL.
Otherwise, the Component Type field is set to Java/JDBC.
If you import a class that ran as an EAServer version 1.1 component,
it will be assigned the Java/JDBC component
type.
An inout parameter must use the holder classes as described in “Choose implementation datatypes”.
User-defined classes With restrictions, user-defined classes are allowed as parameters or return types. The importer creates an IDL definition to match the class. User-defined classes must contain only fields (no methods). Fields may use the Java equivalents for predefined EAServer datatypes, as described above.
For an inout parameter, the Java method definition must use a holder class that you have created, as described in “Holders for user-defined classes and arrays”.
Single-dimension arrays Single-dimension arrays are allowed as parameters or return types. The base type can be any Java equivalent for the predefined EAServer types or a user-defined class. (User-defined classes are subject to the restrictions noted above.)
For an inout parameter, the Java method definition must use a holder class that you have created as described in “Holders for user-defined classes and arrays”.
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);
}
where
comp-package is the same package that contains the class or interface that you are importing.
Type is the user-defined class name.
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);
}
where:
comp-package is the same package that contains the class or interface that you are importing.
Typename is a legal Java identifier. The importer will create an IDL typedef statement for the array type using this declaration.
BaseType is the base type for the array.
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 “Component properties: General”). Make sure that the class has a default constructor (that is, a constructor with no arguments). EAServer 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 EAServer.
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 JavaBeans component, you choose the Java Class option on the import screen, then specify the name of the class that implements the component.
Methods to be imported from a JavaBeans component 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 imported.
The add and remove methods for the JavaBeans event listeners are not imported.
Importing a Java class or interface in EAServer
Manager
If necessary, create the EAServer package that will contain the component. See “Creating a new package” for details.
Specify the package to install the component in as follows:
Double-click the Packages folder to expand it.
Highlight the package to which the component will be added.
Choose File | New Component from the menu.
In the Component Wizard dialog box, select Import from Java File, and click Next.
Verify that the displayed importer CLASSPATH contains the JAR files and directories required to instantiate the bean’s classes, specifically:
Verify that the code base under which the class files are deployed is included.
If the classes are in a JAR file, verify that the full path to the JAR file is included.
If the class definitions require other JAR files or directories not listed, list them as well.
If necessary, use the Add, Modify, Delete, Move Up, and Move Down buttons in the Component Wizard to modify the CLASSPATH. The displayed CLASSPATH affects only this importer session, not the EAServer process.
Enter the component name in the Import Java Class File dialog box.
Choose the type of file to be imported:
Java Class See “Importing Java classes”.
Java Interface See “Importing Java interfaces”.
If importing a Java interface, choose the type of component to be defined in the drop-down list.
Browse for the Java class file that contains the class or interface that is being imported.
The importer will read the specified file, define an IDL interface as described below, and define a component that implements the IDL interface.
| Copyright © 2005. Sybase Inc. All rights reserved. |
|
|