OpenEJB 3.0 Supports DI of Enums and Collections, OSGi and EJB 3.0 features
The latest version of OpenEJB, an open source lightweight EJB implementation framework, supports Dependency Injection (DI) of Enums, Collections and Maps, OSGi, and EJB 3.0 specification. After going through a year and a half of development, OpenEJB 3.0 final was released recently. This version also supports @EJB references to local interfaces in other EAR files, Transaction Logging and EJBd over HTTP protocol as well as the new features in EJB 3.0 like Business Interfaces, Java Persistence API (JPA), and JAX-WS Web Services.
The new release includes several code improvements and bug fixes which are listed in the release notes documentation on OpenEJB web site. Alexander Saint Croix recently wrote a blog entry with the list of new features, improvements, and bug fixes in this release.
OpenEJB uses several other open source frameworks such as OpenJPA to provide JPA and CMP persistence, ActiveMQ for JMS/MDB, and Apache CXF for JAX-WS features. Some of the features in OpenEJB are the major focus of EJB 3.1 specification such as the Collapsed EAR (ejbs and servlets side-by-side in the same archive and classloader) and embeddable EJB container for unit testing. Also, EJB 3.1 Lite profile which will be part of JavaEE 6 release, is very similar to OpenEJB.Integration with Java EE containers:
OpenEJB 3.0 can be plugged into Tomcat 6 server, adding support for EJBs in Web Apps. Adding OpenEJB to Tomcat gives Servlets new Java EE 5 capabilities such as JPA, JAX-WS, JMS, J2EE Connectors and Transactions. OpenEJB natively supports the full Glassfish descriptors, Geronimo, and some of WebLogic descriptors.OSGi Support:
OpenEJB framework was released as an OSGi bundle which means all OpenEJB 3.0 binaries come with OSGi metadata and are usable as a bundle in any OSGi platform. Open source ESB framework ServiceMix 4 release, which is OSGi-based (built on Apache Felix), will include OpenEJB as part of ServiceMix release.
David Blevins, a co-founder of OpenEJB project, blogged about the latest release and the revival of the project. InfoQ spoke with David to learn more about OpenEJB 3.0 features and the future roadmap of the project especially in how it will support EJB 3.1 specification.
What does the support for DI of Enums and Collections objects into EJB's really mean to enterprise Java developers? How does this help in the design and development of EJB components?
The point is to allow EJB developers (or Servlet developers using OpenEJB in Tomcat) to really dig into the EE DI functionality and make it their own. Enum, Class, and Collections are additional built-in types we've added -- look for some of these in Java EE 6. Additionally, we allow for the injection of any object of your creation via including a java.beans.PropertyEditor in your app. These additions give you the leverage to expand injection to include your objects and resources and make Java EE far more usable as a general purpose DI framework.
Responding to a question on what type of Test Driven Development OpenEJB framework provides to unit test EJB classes outside Java EE container, David talked about the embedded testing capabilities in OpenEJB.
These allow you to write a plain unit test that consumes EJBs like any other EJB client would. The difference is that the container and EJBs are running right there in your VM. We will scrape your classpath for applications you've included and make them available for lookup to your test case via JNDI. You simply use a different InitialContextFactory for a local container vs a remote container and works identically to an embedded database. It's possible to test any aspect of your EJBs, no limitations. Imagine being able to test a webservice, Stateful bean and extended EntityManager, or Stateless bean with JTA EntitManager and a test case run in a transaction. This is also a feature we expect to see in EJB 3.1.
Can you elaborate on OSGi support provided in OpenEJB 3.0 release and what it means to use OpenEJB product as an OSGi bundle?
Currently the OSGi support is geared towards people with an OSGi platform wishing to add OpenEJB as a bundle to gain EJB support and is being driven by projects like Apache ServiceMix who are doing exactly that, primarily for the EJB WebServices support. All bundles containing EJB jars made available to the OpenEJB bundle will be deployed.
OpenEJB 3.0 version includes the feature of invoking EJB's over HTTP protocol which sounds really interesting. Can you give us more details on how this feature works and what was the motivation behind it?
The motivation is to allow people to bypass firewall constraints and to allow Tomcat/OpenEJB users to run both ejbs and servlets through a single port. It's driven by a Servlet which you can add/remove to any app, setup with SSL, etc. The ultimate goal is to provide RESTful ejb invocations. Look for that in future 3.x releases.
Java EE 6 will include EJB 3.1 spec as part of the JEE release. What are the plans for OpenEJB team to support EJB 3.1 after it's released?
OpenEJB is already a good source of EJB 3.1 sneak previews such as the ones mentioned here and things like EJBs in WARs which we came out with 1.0. I participate quite heavily on the EJB 3.1 Expert Group and have been very excited about the progress being made and the ability to contribute back things we've been doing in OpenEJB for a while now. We hope to keep going on these lines and get out other proposed features like Singletons and Async beans long before the spec goes final.
What is the road map for OpenEJB project in terms of new features and future enhancements?
Expect to see a lot more EJB 3.1 related features show up as previews, such as @Singleton and @Asynchronous, the no-interface view, and schedules now that those are public. The embedded support and Tomcat integration are always getting tweaked and expanded. There's also been a lot of activity on clustering, further refinement of the CMP/JPA adapter, an Eclipse plugin to convert your EJB 2.x applications to EJB 3.0 (actually adds annotations based on your descriptor), and some major WebServices performance boosts via an alternate JAXB implementation that generates optimized parsing code.
OpenEJB 3.0 version can be downloaded from OpenEJB web site. OpenEJB developer team have also provided a catalog of EJB examples to help the developers how to use the framework in a variety of use cases.
Sarah Howe Jul 06, 2015