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.1 Supports EJB Singletons, Constructor Injection and Spring Integration

Posted by Srini Penchikala on Nov 14, 2008

Sections
Development
Topics
Java ,
OpenEJB
Tags
Java EE ,
EJB

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.

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

Cool ! by vijay sasi Posted
  1. Back to top

    Cool !

    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

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.