Java J2EE Portal
Enterprise Java Station
J2EE curve
Java News / Articles
Java News / Articles
Demystifying Unicode Character Encoding
Building JBoss jBPM Business Process User Interface
Building Advanced Components For Tapestry Web Applications
Processing...
Buy Java, Deals On Software Technology Store
Click here for great deals on computers, laptops, software and books
A quick look at EJB 3.0 Stateless Session Beans PDF Print
Written by Harshad Oak   
Dec 14, 2005 at 02:06 AM

I have been with EJBs for a fairly long time but I have been very much part of the "reluctant EJB developers" community. Give me an option to EJBs and in all probability I will take it. The primary reason was that I did not find EJBs worth the effort. The develop and deploy cycles were unacceptably long, the development seemed unnecessarily confusing, machines crawled once you had a EJB server + IDE running and ofcourse finding skilled EJB developers was a very difficult task.

So I wasn't very excited or optimistic about EJB3 when I first heard about it somewhere around JavaOne 2004. Every EJB3 session at JavaOne 04 was full and I remember wondering if all these people were there because they have used and found EJB fun or because they were hoping that finally with EJB3 they will understand what's happening and why their managers were forcing them to use EJBs.

I did do a few experiments with EJB3, but I was essentially waiting for tools to catch on. Today, all major J2EE vendors have at least a EJB3 preview release of their server and IDE. So I think it's time to learn EJB3.

NetBeans and JDeveloper are my preferred tools. I don't think NetBeans supports EJB3 as yet, so I decided to try out EJB3 using the recent preview release of JDeveloper 10g. I wrote a book on JDeveloper 10g in early 2004 titled Oracle JDeveloper 10g: Empowering J2EE Development, but that version of JDeveloper supported EJB2.1. JDeveloper's EJB 3.0 preview release is still called 10g, but I suppose Oracle will rename it to 11z or something like that when the final release is out.

Lets look at a simple stateless session EJB and try to understand what's new in EJB3. With the JDeveloper wizards, it took me less than aminute to create this app.

Listing 1: DateEJBBean Class

package example.model;
import javax.ejb.Stateless;

@Stateless(name="DateEJB")
public class DateEJBBean implements DateEJB, DateEJBLocal {

public DateEJBBean() {

}

public String displayDate() {

return ""+new java.util.Date();

}

}

In the DateEJBBean class in Listing 1, note the following:

  1. It's a Plain Old Java Object (POJO).
  2. It's not abstract.
  3. It does not force me to implement any interface/s apart from the ones that I have created.
  4. The Java annotation that states that this is a stateless session bean.

Listing 2: DateEJBLocal Interface

package example.model;
import javax.ejb.Local;

@Local
public interface DateEJBLocal {

public String displayDate();

}

Listing 3: DateEJB Remote Interface

package example.model;
import javax.ejb.Remote;

@Remote
public interface DateEJB {

public String displayDate();

}




Add This Feed Button

Enter your Email


Java Expert Interviews
PatrickLightBodyWebWork
Struts Action Framework 2.0 should be released by August 2006
Pradeep Chopra Whizlabs
Certifying your way to success
Satish Talim
Java and J2EE Today: An interview with Satish Talim
Processing...
Go to top of page  Home |
SiteMap

Copyright 2004 to 2008 Rightrix Solutions. All rights reserved. All product names are trademarks of their respective companies. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. Rightrix Solutions and IndicThreads.com are independent of Sun Microsystems, Inc.

Views expressed at IndicThreads.com reflect the views of the authors alone, and do not necessarily reflect those of IndicThreads.com. IndicThreads.com and it's authors are not responsible for reader comments and opinions.

Enterprise Java J2EE JEE Portal >> IndicThreads.com