InfoQ

News

OpenEJB 3.1 Supports EJB Singletons, Constructor Injection and Spring Integration

Posted by Srini Penchikala on Nov 14, 2008 02:00 PM

Community
Java
Topics
OpenEJB
Tags
EJB ,
Java EE

The latest release of OpenEJB, an open source lightweight EJB 3.0 implementation framework, supports EJB 3.1 Singletons, Constructor Injection and integration with Spring framework. Apache OpenEJB development team announced last week the release of OpenEJB 3.1 version. The latest version has support for some of the EJB 3.1 features that can be used not only as a standalone server, but as an embedded server in Tomcat, JUnit, Eclipse, Maven, Ant, or any other IDE or application. EJB 3.1 specification will be released as part of Java EE 6 (scheduled to be out early next year).

EJB Singletons:
EJB 3.1 Singleton support adds new functionality to EJB such as application startup/shutdown hooks and multi-threaded capabilities. Much of what Stateless beans are used for now can be replaced by a multi-threaded Singleton. In addition to the embeddable EJB container and Collapsed EAR (ejbs in .war files) functionality, which will be part of EJB 3.1 release, this release contains support for the new EJB 3.1 Singleton Session bean type.

The Singleton feature ensures that there is exactly one instance of Stateless Session bean in the application which can be invoked concurrently by multiple threads, like a servlet. It can do everything a traditional session bean can do such as support local and remote business interfaces, web services, and concerns like security and transactions. Additionally, custom initialization and resource cleanup logic in the Singleton can be managed using its @PostConstruct (called when the application starts up) and @PreDestroy (called when the application shuts down) methods. This allows it to serve as an application lifecycle listener which is something only Servlets could do before. It has an @Startup annotation which is similar in concept to the servlet , but unlike servlets it doesn't take a number as an argument. Instead, @DependsOn annotation can be used to define which other Singletons the main session bean class needs and the container will ensure the dependent classes are started before the main class.

Constructor Injection:
The constructor injection feature allows Java EE resources like servlet, filter, listener or a JSF managed bean to be injected using the annotations at the constructor level. This way, the developers can still use final fields and plan old java constructors and avoid the setters and private field injection for managing the dependencies on the Java EE components.

Spring Integration:
Spring Integration feature allows the developers to embed Spring beans into OpenEJB or OpenEJB components into Spring applications. This can be done by injecting Spring beans into EJBs using @Resource annotation and EJBs can be injected into Spring via the standard Spring dependency injection (DI) mechanisms. This feature in OpenEJB 3.1 release is still an experimental feature and is subject to change based on user feedback.

OpenEJB 3.1 release also includes several enhancements to the existing features. Some of these enhancements are:

  • Multicast Client-Server Discovery and grouping
  • Injection Support for JSF 1.2 ManagedBeans
  • EAR-style aggregation of modules discovered in the classpath
  • ConnectorModule and PersistenceModule discoverable via the classpath
  • Improved JavaAgent/JPA enhancement for Unit Tests
  • EJBd protocol over SSL
  • JDBC/DataSource based login module

OpenEJB project team has included documentation on Singleton API and some examples for the users to learn more about the new features like Singleton and Spring Integration.

Cool ! by vijay sasi Posted Nov 18, 2008 10:42 AM
  1. Back to top

    Cool !

    Nov 18, 2008 10:42 AM by vijay sasi

    That was really nice ! Now I get more confidence on EJB 3. Big hassle removed. Thanks to Apache OpenEJB community ! www.itspice.com

Educational Content

Bindings, Platforms, and Innovation

This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.

Orchestrating Long Running Activities with JBoss / JBPM

This article explores the use of JBoss and jBPM to implement design solutions that effectively address the issue of orchestrating long running activities.

Neo4j - The Benefits of Graph Databases

This presentation covers the use of graph databases as an optimal solution for data that is difficult to fit in static tables, rapidly evolving data or data that has a lot of optional attributes.

Realistic about Risk: Software development with Real Options

This session introduces Real Options and shows how it can help in running your project. Real Options is a decision-making process that can be used to manage risk.

Communication Flexibility Using Bindings

This article discusses the use of bindings on services and references (including the instance of non-configured bindings) as the means to implement SCA communications in a Web and SOA environment.

Writing DSLs in Groovy

After a short introduction to DSLs, Scott Davis plays with the keyboard showing how to approach the creation of a DSL by typing working snippets of Groovy code that get executed.

Scaling Agile with C/ALM (Collaborative Application Lifecycle Management)

IBM Rational and InfoQ present, Scaling Agile with C/ALM, an eBook showing organizations how to become “finely tuned software delivery machines” by enabling team integration and scaling.

Concurrent Programming with Microsoft F#

Amanda Laucher presents a real life enterprise application written in F#. She shows actual code snippets, explaining design decisions and suggesting how to use some of the F# constructs.