InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

OpenEJB 3.0 Supports DI of Enums and Collections, OSGi and EJB 3.0 features

Posted by Srini Penchikala on May 05, 2008

Sections
Development
Topics
Java
Tags
EJB ,
Open source Java

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.

Srini Penchikala currently works as Security Architect and has 17 yrs of experience in software product management.

No comments

Watch Thread Reply

Educational Content

New-age Transactional Systems - Not Your Grandpa's OLTP

John Hugg discusses high volume transaction processing applications with high and low frequency profiles, and how VoltDB can be used for that purpose.

Cool Code

Kevlin Henney examines code samples to see what can be learned from them starting from the premise that one won’t write great code unless he knows how to read it.

Collaboration: At the Extremities of Extreme

Jason Ayers share the observations he made watching a team of developers collaborating in real time on the same code base, pushing XP, pair programming and continuous integration to their extremes.

Yesod Web Framework

Michael Snoyman presents Yesod, a web framework written in Haskell and containing a web server, templating, ORM, libraries (templating, gravatar, etc.).

Transactions without Transactions

Richard Kreuter and Kyle Banker on how to avoid classical RDBMS transactional systems by using compensation mechanisms, transactional messaging or transactional procedures.

Attila Szegedi on JVM and GC Performance Tuning at Twitter

Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.