Chapter 9: EAServer EJB Interoperability
To invoke a non-EJB component from an EJB client, you must first create a home interface for the component, then generate EJB stubs for the component’s interfaces. Then you can instantiate proxies for the non-EJB component using the standard EJB client design pattern.
Non-EJB components can implement several remote interfaces. To instantiate proxies for any remote interface from EJB clients, you must use a corresponding home interface. Use EAServer Manager to create a home interface for each IDL interface that the component implements. The home interface must have a single create method that takes no parameters and returns the remote interface.
Even with a home interface defined, EAServer creates component instances using the standard method for the component’s lifecycle model. A non-EJB component does not need to implement any additional methods to support the home interface.
Creating the home interface
Expand the component’s icon, then highlight the Interfaces folder beneath the component. Choose File | Set Home Interface.
In the Home Interface dialog box, enter the home interface name as:
where module is the IDL module where the remote interface is defined, and component_interface is the base (non-nested) name of the remote interface. For example, MyPackage::MyComponentHome.
Click Add New. EAServer creates the interface and an icon for the interface appears in the component’s Interfaces folder.
Highlight the home interface icon, and choose File | New Method.
Enter “create” as the method name and click Create New Method.
Change the following in the Method Properties dialog, leaving other fields at their default settings:
Click OK to close the Method Properties dialog box.
Use EAServer Manager to generate EJB stubs for the component, specifying a different package or code base for the EJB stubs than used by the existing CORBA stubs.
CORBA and EJB stubs share class names but do not share the same implementation. Therefore, each type must be in a different Java package or use a different code base.
“Generating EJB stubs” describes how to generate the stub files.
After defining a home interface and generating EJB stubs, you can instantiate a home interface for the component using the standard EJB technique, as described in Chapter 8, “Creating Enterprise JavaBeans Clients”.
The component’s home interface name matches the value of the com.sybase.jaguar.component.bind.naming property. For non-EJB components, you must view the value of this property using the Advanced tab in the Component Properties dialog box. If the property is not set, the default is initial-context/package/component, where initial-context is the server’s initial naming context, package is the EAServer Manager package where the component is installed, and component is the component name as displayed in EAServer Manager.
The methods in the Java remote interface follow the standard CORBA IDL-to-Java datatype mappings. To allow increased interoperability between EJB clients and non-EJB components, EAServer allows use of out and inout parameters in the remote interface. In the Java remote interface, these are represented by the same holder classes as used in CORBA stubs. See “Holder classes” for more information on using holder classes.
In EJB component code, you can make intercomponent calls using EJB stubs and the EJB client interface as described above. You can also use the CORBA client interface as described in “Issue intercomponent calls”.
|Copyright © 2005. Sybase Inc. All rights reserved.|