jee6 学习笔记 6 - EJB3.1 What's New

The following is a brief list of the new features of EJB3.1

1. no interface required
@Stateless
public class MyEjb { ...}


2. singleton EJB: @Singleton
@Singleton
public class MySingleton { ... }


3. timer based services: @Schedule
@Stateless
public class MyTimerBean {
 @Schedule(dayOfWeek="Sun", hour="0")
 public void soSomething() { ... }
}


4. Asynchronous EJB: @Asynchronous
@Stateless
public class MyAsynchBean  {
  @Asynchronous
  public void doSomething(User u) {
    try {
      changeSomething(u);
      sendNotification(u);
   }
   catch (Exception e) {
     e.printStackTrace();
   } 
  }
}


5. As showed in the previous blogs, EJBs can now be packaged in a web archive .war

Next, i'll do simple experiments on these new features to make sure i really understand how they work, and possibly, how they can be used.

你可能感兴趣的:(EJB3.1,new features)