Book Home Enterprise JavaBeans Search this book

Chapter 4. Developing Your First Enterprise Beans

Contents:

Choosing and Setting Up an EJB Server
Developing an Entity Bean
Developing a Session Bean

4.1. Choosing and Setting Up an EJB Server

One of the most important features of EJB is that beans should work with containers from different vendors. That doesn't mean that selecting a server and installing your beans on that server are trivial processes. We'll start this chapter with a general discussion of how you select and set up a server.

The EJB server you choose should be compliant with the EJB 1.0 or EJB 1.1 specification. However, in the EJB 1.0 version of the specification, support for entity beans and container-managed persistence is optional. In EJB 1.1, support for entity beans is required. The first example in this chapter--and most of the examples in this book--assume that your EJB server supports entity beans and container-managed persistence.[1] The EJB server you choose should also provide a utility for deploying an enterprise bean. It doesn't matter whether the utility is command-line oriented or graphical, as long as it does the job. The deployment utility should allow you to work with prepackaged enterprise beans, i.e., beans that have already been developed and archived in a JAR file. Finally, the EJB server should support an SQL-standard relational database that is accessible using JDBC. For the database, you should have privileges sufficient for creating and modifying a few simple tables in addition to normal read, update, and delete capabilities. If you have chosen an EJB server that does not support an SQL standard relational database, you may need to modify the examples to work with the product you are using.

[1]Chapter 9, "Design Strategies" discusses how to work with servers that don't support entity beans. Chapter 6, "Entity Beans" includes a discussion of bean-managed persistence, which you can use if your server doesn't support container-managed persistence.

4.1.1. Setting Up Your Java IDE

To get the most from this chapter, it helps to have an IDE that has a debugger and allows you to add Java files to its environment. Several Java IDEs, like Symantec's Visual Cafe, IBM's VisualAge, Inprise's JBuilder, and Sun's Forte, fulfill this simple requirement. The debugger is especially important because it allows you to walk slowly through your client code and observe how the EJB client API is used.

Once you have an IDE set up, you need to include the Enterprise JavaBeans packages. These packages include javax.ejb and for EJB 1.0 javax.ejb.deployment. You also need the JNDI packages, including javax.naming, javax.naming.directory, and javax.naming.spi. In addition, you will need the javax.rmi package for EJB 1.1. All these packages can be downloaded from Sun's Java site (http://www.javasoft.com) in the form of ZIP or JAR files. They may also be accessible in the subdirectories of your EJB server, normally under the lib directory.



Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.