This section describes how you import Enterprise JavaBeans. These are the usual methods you will use with EJB Server. See “Creating Enterprise JavaBeans” for directions for creating JavaBeans from scratch.
The Adaptive Server plug-in to Sybase Central supports two methods of importing Enterprise JavaBeans:
From an EJB-JAR file An EJB-JAR file contains the implementation classes, interface classes, and deployment descriptor for one or more Beans. You can use a Java development tool such as Sybase PowerJ to define and develop Beans and create an EJB-JAR file. You can import JAR files in the EJB 1.1 format. The Adaptive Server plug-in reads the JAR file and creates a package containing a component for each Bean in the JAR file.
From an EJB class file The Adaptive Server plug-in can import component and method information from Java class files. Use this method if you have created a Bean’s interfaces and implementation class, but have not created a deployment descriptor. You will need to manually configure properties that would otherwise be read from the deployment descriptor. You cannot import Java package files.
PowerJ deploys Enterprise JavaBeans directly to EJB Server If you are developing in PowerJ, use the Enterprise JavaBean Deployment Wizard to install EJB components in EJB Server. If using another IDE, use the Adaptive Server plug-in to import the Bean as described below.
Finder methods in an entity Bean’s home interface can return java.util.Collection or java.util.Enumeration. All EJB components defined in a package or an EJB-JAR file must use the same type for finder method return values.
Importing an EJB 1.1 JAR file is a two-step process:
Deploy the JAR file to the repository.
Install the package in the Installed Packages folder in the Adaptive Server plug-in.
Deploying an EJB 1.1 JAR file to the repository
Start the Adaptive Server plug-in if it is not already running, and connect to the EJB Server where you want to install the component.
Double-click the Installed EJB Packages folder.
Select File | Deploy | EJB 1.1 JAR
The Deploy wizard displays.
If a package exists in your repository with the same name as the EJB JAR display name, indicate whether the Adaptive Server plug-in should prompt you before overwriting existing packages with the new definition.
Enter the path to the JAR file and click Next.
The Adaptive Server plug-in creates a new package in the repository that contains a component for each Bean defined in the JAR file, printing status messages and warnings to the Deploy Wizard. The new package has the same name as the EJB JAR display name. If there is no display name, the new package has the same name as the JAR file. For each Bean in the EJB-JAR, EJB Server creates an EJB component with the same name as the ejb-name element in the EJB-JAR deployment descriptor.
Installing a package in the Adaptive Server plug-in
Double-click the Installed EJB Packages folder. Choose File | Install Existing Packages.
The Select dialog box displays.
Choose a package from the drop-down list of deployed packages in the repository.
Click OK.
Select View | Refresh All.
The package appears in the Installed EJB Packages folder.
Optionally generate stubs and skeletons for the component Beans. See “Generating stubs and skeletons”.
Use the status dialog as a to-do list In the deployment status dialog box, the Adaptive Server plug-in displays warnings for each setting that requires further attention before running the application. You can copy and paste this text to a text editor to use as a to-do list.
You may need to configure the following settings in the Component Properties dialog box before running EJBs:
For Beans that use container-managed persistence, the settings described in Persistence for entity components
Resource references, described in Configuring resource references
EJB references (to components that are not installed with the JAR file), described in Configuring EJB references
Environment properties, described in Configuring environment properties
You may need to configure the Role mapping settings in the Package Properties dialog box, described in “Role Mapping properties”.
The Adaptive Server plug-in can import component and method information from Java class files. Use this technique if you have created a Bean’s interfaces and implementation class, but have not created a deployment descriptor. You will need to manually configure properties that would otherwise be read from the deployment descriptor afterwards.
Importing EJB class files
Before importing class files Verify that the code base under which the class file is deployed is specified in the CLASSPATH environment variable, as inherited by the Adaptive Server plug-in process.
Create a package to contain the component if necessary.
Import EJB class files as follows:
Specify the package in which to install the component as follows:
Open the Installed EJB Packages folder.
Double-click the package to which the component will be added.
Double-click the Add new component icon in the right window.
The Component wizard displays.
In the Type of Component window, select Import an EJB Class File, and click Next.
Enter the component name and EJB class and interface names as follows:
Component name The name of the component to be created in the Adaptive Server plug-in, for example, FinanceBean.
Component type Choose one of the following to match your implementation:
Type |
Description |
---|---|
StatelessSessionBean |
A stateless session Bean |
StatefulSessionBean |
A stateful session Bean |
EntityBean |
An entity Bean with Bean-managed persistence |
Remote interface The full path to the Java class file that contains the Bean’s remote interface.
Home interface The full path to the Java class file that contains the Bean’s home interface.
Bean class name The full path to the Java class file that contains the Bean’s implementation class.
Primary key class If defining an entity Bean, enter the full path to the Java class file that contains the Bean’s remote interface. If defining a session Bean, leave blank.
Click Next.
The Adaptive Server plug-in displays the Component Properties dialog box. The Component’s type and Java classes have been filled in by the importer. Specify values for the remaining properties before running the Bean.