Tools for developing and deploying enterprise beans in the EJB server (AE) environment

There are two basic approaches to developing and deploying enterprise beans in the EJB server (AE) environment:
Note:
Deployment and use of enterprise beans for the EJB server (AE) environment must take place on the Microsoft Windows NT(R) operating system, the IBM AIX(R) operating systems, or the Sun Microsystems Solaris operating system.

For information on developing enterprise beans in the EJB server (CB) environment, see Tools for developing and deploying enterprise beans in the EJB server (CB) environment.


Using VisualAge for Java

Before you can develop enterprise beans in VisualAge for Java, you must set up the EJB development environment. You need to perform this setup task only once. This setup procedure directs VisualAge for Java to import all of the classes and interfaces required to develop enterprise beans.

After generating an enterprise bean, you complete its development by following these general steps:

  1. Implement the enterprise bean class.

  2. Create the required abstract methods in the bean's home and remote interfaces by promoting the corresponding methods in the bean class to the appropriate interface.

  3. For entity beans, do the following:

    1. Create any additional finder methods in the home interface by using the appropriate menu items.

    2. Create a finder helper interface, if required.

  4. Create the EJB module and corresponding deployment descriptor.

  5. Generate the deployment code for the bean.

VisualAge for Java contains a complete WebSphere Application Server run time environment and a mechanism to generate a test client to test your enterprise beans. For much more detailed information on developing enterprise beans in VisualAge for Java, refer to the VisualAge for Java documentation.


Developing and deploying enterprise beans with EJB server (AE) tools

If you have decided to develop enterprise beans without an IDE, you need at minimum the following tools: This section describes steps you can follow to develop enterprise beans by using these tools. The following tasks are involved in the development of enterprise beans:

  1. Ensure that you have installed and configured the prerequisite software to develop, deploy, and run enterprise beans in the EJB server (AE) environment. For more information, see Installing and configuring the software for the EJB server (AE).

  2. Set the CLASSPATH environment variable required by different components of the EJB server (AE) environment. For more information, see Setting the CLASSPATH environment variable in the EJB server (AE) environment.

  3. Write and compile the components of the enterprise bean. For more information, see Creating the components of an enterprise bean.

  4. (Entity beans with CMP only) Create a finder helper interface for each entity bean with CMP that contains specialized finder methods (other than the findByPrimaryKey method). For more information, see Creating finder logic in the EJB server (AE).

  5. Create an EJB module and corresponding deployment descriptor by using the Application Assembly Tool. For more information, see Creating an EJB module.

  6. (Entity beans only) Create a database schema to enable storage of the entity bean's persistent data in a database. For more information, see Creating a database for use by entity beans.

  7. Deploy the EJB module by using the Application Assembly Tool or the WebSphere Administrative Console. For more information, see the WebSphere InfoCenter and the online help available with the WebSphere Administrative Console.

  8. Install the EJB module into an EJB server (AE) and start the server by using the WebSphere Administrative Console.

Installing and configuring the software for the EJB server (AE)
You must ensure that you have installed and configured the following prerequisite software products before you can begin developing enterprise beans and EJB clients with the EJB server (AE):

For information on the appropriate version numbers of these products and instructions for setting up the environment, see the WebSphere InfoCenter.

Setting the CLASSPATH environment variable in the EJB server (AE) environment
In addition to the classes.zip file contained in the SDK, the following WebSphere JAR files must be appended to the CLASSPATH environment variable for developing enterprise beans:

For developing and running an EJB client, the following WebSphere JAR files must be appended to the CLASSPATH environment variable:

Creating the components of an enterprise bean

If you use an ASCII text editor or a Java development tool that does not support enterprise bean development, you must create each of the components that compose the enterprise bean you are creating. You must ensure that these components match the requirements described in Developing enterprise beans.

To manually develop a session bean, you must write the bean class, the bean's home interface, and the bean's remote interface. To manually develop an entity bean, you must write the bean class, the bean's primary key class, the bean's home interface, the bean's remote interface, and if necessary, the bean's finderHelper interface. After you have properly coded these components, use the Java compiler to create the corresponding Java class files. For example, because the components of the example Account bean are stored in a specific directory, the bean components can be compiled by issuing the following command:

C:\MYBEANS\COM\IBM\EJS\DOC\ACCOUNT> javac *.java

This command assumes that the CLASSPATH environment variable contains all of the packages used by the Account bean.

Creating finder logic in the EJB server (AE)
For the EJB server (AE) environment, the following finder logic is required for each finder method (other than the findByPrimaryKey method) contained in the home interface of an entity bean with CMP:
Note:
Encapsulating the logic in a String constant named findMethodNameQueryString has been deprecated.

If you define the findLargeAccounts method shown in Figure 24, you must also create the AccountBeanFinderHelper interface shown in Figure 7.

Figure 7. Code example: AccountBeanFinderHelper interface for the EJB server (AE)


...
public interface AccountBeanFinderHelper{
     String findLargeAccountsWhereClause = "balance > ?";
}

Creating an EJB module
The WebSphere Application Server Application Assembly Tool can be used to create an EJB module. One or more enterprise beans can be placed in an EJB module. The tool automatically creates the required deployment descriptor for the module based on information specified by the user.
Note:
Before using the Application Assembly Tool, the WebSphere Common Configuration Model (WCCM) MetaObject Facility (MOF) JAR files must be added to your CLASSPATH environment variable.

Using the Application Assembly Tool

To create an EJB module and corresponding deployment descriptor, use the Create an EJB JAR wizard in the Application Assembly Tool. This wizard prompts you to specify the following information for each enterprise bean to be included in the module:

The wizard also prompts you to specify the following application assembly information for the module itself:

Both bean and module information are used to create the deployment descriptor. See the WebSphere InfoCenter and the online help for details on how to use the Application Assembly Tool.

Creating a database for use by entity beans
For entity beans with container-managed persistence (CMP), you must store the bean's persistent data in one of the supported databases. The Application Assembly Tool automatically generates SQL code for creating database tables for CMP entity beans. The tool names the database schema and table ejb.beanNamebeantbl, where beanName is the name of the enterprise bean (for example, ejb.accountbeantbl). If your CMP entity beans require complex database mappings, it is recommended that you use VisualAge for Java to generate code for the database tables. At run time, the WebSphere Administrative Console displays a prompt asking whether you want to execute the generated SQL code that creates the database table.

For entity beans with bean-managed persistence (BMP), you can create the database and database table by using the database tools or use an existing database and database table. Because entity beans with BMP handle the database interaction, any database or database table name is acceptable.

For more information on creating databases and database tables, consult your database documentation and the online help for the WebSphere Administrative Console.