Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

Overview

...

In EJB 3.0, your bean's interfaces are not required to extend any specific set of interfaces and generally have no requirements on them at all. These are referred to in EJB spec lingo as Business Interfaces.

In EJB 2.1 and prior, however, there were some pretty strict requirements on interfaces. Namely, you had to have a "home" interface that extended javax.ejb.EJBHome or javax.ejb.EJBLocalHome. This interface served as a sort of factory to create your bean's interface which itself had to extend either javax.ejb.EJBObject or javax.ejb.EJBLocalObject. These legacy styles of interfaces in EJB spec lingo are referred to as Component Interfaces.

In this example we see how one can support both business interfaces and component interfaces on the same bean. You may choose to do this for backwards compatibility with older clients or to maintain an older EJB 2.x API still being used. The advantage is that you can turn EJB 2.1 beans into EJB 3.0 beans without having to update any code consuming that EJB.

The source for this example is in the "component-interfaces" directory located in the openejb-examples.zip available on the download page.

The Code

Annotated Bean Class

...

...

EJB 2.1 Home And Remote views

...

...

Test Case

...

Running it

Running the example is fairly simple. In the "component-interfaces" directory of the examples zip, just run:

...

$ mvn clean install

Which should create output like the following.

...