Importing Enterprise JavaBeans

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:

NotePowerJ 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.

NoteFinder 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 EJBs from an EJB-JAR file

Importing an EJB 1.1 JAR file is a two-step process:

  1. Deploy the JAR file to the repository.

  2. Install the package in the Installed Packages folder in the Adaptive Server plug-in.

StepsDeploying an EJB 1.1 JAR file to the repository

  1. 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.

  2. Double-click the Installed EJB Packages folder.

  3. Select File | Deploy | EJB 1.1 JAR

    The Deploy wizard displays.

  4. 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.

  5. Enter the path to the JAR file and click Next.

  6. 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.

    NoteHome names for imported EJB components EJB Server sets an imported Bean’s home name to the EJB Server default, package/component, where package is the Adaptive Server plug-in package name, and component is the Adaptive Server plug-in component name.

StepsInstalling a package in the Adaptive Server plug-in

  1. Double-click the Installed EJB Packages folder. Choose File | Install Existing Packages.

    The Select dialog box displays.

  2. Choose a package from the drop-down list of deployed packages in the repository.

  3. Click OK.

  4. Select View | Refresh All.

    The package appears in the Installed EJB Packages folder.

  5. Optionally generate stubs and skeletons for the component Beans. See “Generating stubs and skeletons”.

NoteUse 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:

You may need to configure the Role mapping settings in the Package Properties dialog box, described in “Role Mapping properties”.

Importing EJBs from EJB class files

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.

StepsImporting EJB class files

NoteBefore 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:

  1. Specify the package in which to install the component as follows:

    1. Open the Installed EJB Packages folder.

    2. Double-click the package to which the component will be added.

  2. Double-click the Add new component icon in the right window.

    The Component wizard displays.

  3. In the Type of Component window, select Import an EJB Class File, and click Next.

  4. Enter the component name and EJB class and interface names as follows:

  5. Click Next.

  6. 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.