EJB Tutorial

Now let’s look at the generic steps that you take to implement an Enterprise JavaBeans component. In all of the examples that follow, we’re showing you the “traditional” approach to writing EJBs: you create the client and home interfaces (where needed), the implementation classes, and the deployment descriptor by hand. A number of tools are available to simplify EJB development by creating these elements for you. Chapter 21 discusses XDoclet annotations that can be used to automatically generate interfaces and deployment descriptors for EJBs using special Javadoc comments in your code. At the end of this chapter we also give a preview of similar features being integrated into the EJB 3.0 specification. But even with current and upcoming development aids, it’s important to understand the underlying EJB programming model so that you can apply the tools effectively.

As we discussed earlier, every type of EJB (session, entity, message-driven) must include a bean implementation class. This class houses the bean’s business logic—it’s the heart of the component. All the other trappings of the EJB either give clients ways to access the bean or help the container manage the bean.

If you are creating either an entity or a session bean, you also need to provide:

Home interfaces

A home interface is used by clients to create or find EJB objects of a specific type. An EJB can have both local and remote home interfaces , though in most cases only one or the other is needed, based on the ...

Get Java Enterprise in a Nutshell, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.