Appendix A. FirstEJB Example

Description

In this exercise, we’ll model an extremely simple business process: addition. The core logic is the same as one would write in a CS100-level undergraduate class, and we’ll create real EJBs from these small classes using a few annotations. In addition, this example shows how we may expose our EJBs through a variety of “views”: as business interfaces, as EJB 2.x legacy components, and as the new EJB 3.1 no-interface view.

The tests for this section come in both unit and integration flavors. The unit tests simply instantiate our classes as POJO objects and invoke their business methods directly, while the integration tests use a real backing container to make EJBs and invoke upon their proxy references. This shows the versatility of the EJB POJO programming model.

Source Listing

Following is a full listing of all source code used in this runnable example.

Implementation Resources

CalculatorBeanBase.java

package org.jboss.ejb3.examples.ch04.firstejb; import org.jboss.logging.Logger; /** * Base for bean implementation classes of the CalculatorEJB, * provides business logic for required contracts * * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a> */ public class CalculatorBeanBase implements CalculatorCommonBusiness { // ---------------------------------------------------------------------------|| ...

Get Enterprise JavaBeans 3.1, 6th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.