Wednesday, April 14, 2010

OpenWebBeans Integration with OpenEJB and Tomcat


As you have already know The Apache Software Foundation provides lots of implementation of the Java EE specifications and includes products related with them.

Recently I have been working on updating Apache OpenEJB+Tomcat integration code to support Apache OpenWebBeans in a collapsed ear applications. The motivation was that you could use OpenWebBeans in a module without adding its libraries and configuration files. Whenever your modules contain WEB-INF/beans.xml marker file, it is automatically configured over integration code. This was an amazing, nifty and interesting work for me, digging into the details of OpenEJB, Tomcat and Java EE.

Main "The Apache Software Foundation"  projects to create a Java EE Web Profile Server like functionality are followings
  • Apache  OpenEJB
  • Apache  Tomcat
  • Apache  MyFaces
  • Apache  OpenJPA
  • Apache  OpenWebBeans
  • Apache  ActiveMQ
Currently there is no release of this integration. Basically, you can follow the below steps to get running web profile server
Now, you have a running web profile server like in your hands. Deploy any web module with WEB-INF/beans.xml and use EJBs via OpenWebBeans injecting functionality. Moreover, you can use OpenWebBeans decroators and interceptors with EJBs. That is great startup!

For example, lets says that you have a JSF managed bean, PaymentBean and EJB stateless bean  that  handles payments. It is easy to write the following code to inject EJB into a managed bean via OWB using @Inject

public PaymentBean
    private @Inject Payment payment;
    public String pay{;

public Payment{
      public String pay(){.....}

You can also inject "UserTransaction" and "Principal" into any managed bean to inject transaction and current principal object as follows

@Inject UserTransaction userTransaction.
@Inject Principal principal

You will also inject ValidatorFactory and Validators (coming soon...)

As you see, the Java EE 6 promises on simplifying the development of enterprise applications and The Apache Software Foundation provides open source powerful implementation of Java EE specifications.