The following is a brief list of the new features of EJB3.1
1. no interface required
2. singleton EJB: @Singleton
3. timer based services: @Schedule
4. Asynchronous EJB: @Asynchronous
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.
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的一些新特性,包括无接口的@Stateless注解使用、@Singleton注解创建单例EJB、定时服务通过@Schedule实现、异步EJB的@Asynchronous注解应用以及将EJB打包为war文件的方法。
143

被折叠的 条评论
为什么被折叠?



