New in OpenEJB 3.0 has been created by David Blevins (Sep 05, 2007).

Content:

EJB 3.0

OpenEJB 3.0 supports the EJB 3.0 specification as well as the prior EJB 2.1, EJB 2.0, and EJB 1.1. New features in EJB 3.0 include:

  • Annotations instead of xml
  • No home interfaces
  • Business Interfaces
  • Dependency Injection
  • Intercpetors
  • Java Persistence API
  • Service Locator (ala SessionContext.lookup)
  • POJO-style beans

New EJB 2.x features not supported in OpenEJB 1.0 also include:

  • MessageDriven Beans
  • Container-Managed Persistence (CMP) 2.0
  • Timers

Two aspects of EJB that OpenEJB does not support include:

  • Web Services (JAX-WS, JAX-RPC)
  • CORBA

JAX-WS and CORBA support will be added in future releases. Support for the JAX-RPC API is not a planned feature.

Extensions to EJB 3.0

CMP via JPA

Our CMP implementation is a thin layer over the new Java Persistence API (JPA). This means when you deploy an old style CMP 1.1 or CMP 2.1 bean it is internally converted and ran as a JPA bean. This makes it possible to use both CMP and JPA in the same application without any coherence issues that can come from using two competing persistence technologies against the same data. Everything is ultimately JPA in the end.

Extended Dependency Injection

Dependency Injection in EJB 3.0 via @Resource is largely limited to objects provided by the container, such as DataSources, JMS Topics and Queues. It is possible for you to supply your own configuration information for injection, but standard rules allow for only data of type String, Character, Boolean, Integer, Short, Long, Double, Float and Byte. If you needed a URL, for example, you'd have to have it injected as a String then convert it yourself to a URL. This is just plain silly as the conversion of Strings to other basic data types has existed in JavaBeans long before Enterprise JavaBeans existed.

OpenEJB 3.0 supports injection of any data type for which you can supply a JavaBeans PropertyEditor. We include several built-in PropertyEditors already such as Date, InetAddress, Class, File, URL, URI, Map, List and more.

MyBean.java
import java.net.URI;
import java.io.File;
import java.util.Date;

@Stateful 
public class MyBean {
    @Resource URI blog;
    @Resource Date birthday;
    @Resource File homeDirectory;
}

The META-INF/env-entries.properties

Along the lines of injection, one of the last remaining things in EJB 3 that people need an ejb-jar.xml file for is to supply the value of env-entries. Env Entries are the source of data for all user supplied data injected into your bean; the afore mentioned String, Boolean, Integer, etc. This is a very big burden as each env-entry is going to cost you 5 lines of xml and the complication of having to figure out how to add you bean declaration in xml as an override of an existing bean and not accidentally as a new bean. All this can be very painful when all you want is to supply the value of a few @Resource String fields in you bean class.

To fix this, OpenEJB supports the idea of a META-INF/env-entries.properties file where we will look for the value of things that need injection that are not container controlled resources (i.e. datasources and things of that nature). You can configure you ejbs via a properties file and skip the need for an ejb-jar.xml and it's 5 lines per property madness.

META-INF/env-entries.properties
blog = http://acme.org/myblog
birthday = locale=en_US style=MEDIUM Mar 1, 1954
homeDirectory = /home/esmith/

Support for GlassFish descriptors

Unit testing EJBs with OpenEJB is a major feature and draw for people, even for people who may still use other app servers for final deployment such as Geronimo or GlassFish. The descriptor format for Geronimo is natively understood by OpenEJB as OpenEJB is the EJB Container provider for Geronimo. However, OpenEJB also supports the GlassFish descriptors so people using GlassFish as their final server can still use OpenEJB for testing EJBs via plain JUnit tests in their build and only have one set of vendor descriptors to maintain.

Reply via email to