Skip to main content

EJB 3.0 Spec is available for Early Draft Review

Posted by lancea on July 27, 2004 at 12:37 AM PDT

The plans for the next release of J2EE 5.0 (formally 1.5) are in full swing. One of the key initiatives is to reduce the complexity for the developers and focus on Ease of Development (EoD).

EJB has always been an area where we have had requests to try and simplify things for the developer. I believe the early draft of the EJB 3.0 is off to a great start in accomplishing this requirement.

One area that has been greatly simplified, is the amount of code that is required to create an EJB. For example, consider the following EJB 2.1 Stateless Session Bean. You would need to code the following (plus create a Deployment Descriptor):

 public interface Calculator extends EJBObject {
         int add (int a, int b) throws RemoteException;
         int subtract (int a, int b) throws RemoteException;

}

public interface CalculatorHome extends EJBHome {
        Calculator create() throws CreateException, RemoteException;
}

public class CalculatorBean implements SessionBean {
       private SessionContext ctx;
       public void setSessionContext(SessionContext ctx) {
          this.ctx = ctx;
       } 
       public void ejbCreate () {}
       public void ejbActivate () {}
       public void ejbPassivate () {}
       public void ejbRemove() {}
       public int add (int a, int b) {
          return a + b;
       } 
       public int subtract ( int a, int b) {
          return a  - b;
       }

}

With EJB 3.0, the above code could be written as:

@Stateless @Remote public class CalculatorBean {
         public int add (int a, int b) {
             return a + b;
         }
         public int subtract (int a, int b) {
            return a - b;
         }
}

That is it! You do not even have to create a Deployment Descriptor.

The Expert Group has been working very hard to address the needs of the EJB community. Please take the time to review the EJB 3.0 Early Draft and give us your feedback.

Related Topics >>