EJB 3.x常用注解

这里总结自己常用的,没用到的,或不常用以后再继续补充

 
 
1.Local

When used on the bean class, declares the local business interface(s) for a session bean.

用在 Bean 类上时,为会话 Bean 声明本地业务接口。用在接口上时,将该接口指定为本地业务接口。在这种情况下,不提供任何 value()。
如:@Local(LawsuitService.class)
 
  
2.Remote

Declares the remote business interface(s) for a session bean.

为会话 Bean 声明远程业务接口。用在接口上时,将该接口指定为远程业务接口。在这种情况下,不提供任何 value()。

 
 
3.Stateful

Component-defining annotation for a stateful session bean.

有状态会话 Bean 的组件定义注释。
 
 
4.Stateless

Component-defining annotation for a stateless session bean.

扫描二维码关注公众号,回复: 2466323 查看本文章
无状态会话 Bean 的组件定义注释。
 
  
5.Timeout

Designates a method on a stateless session bean class or message driven bean class that should receive EJB timer expirations for that bean.

指定无状态会话 Bean 类或消息驱动 Bean 类上接收该 Bean 的 EJB 计时器过期的方法。

 
    
6.TransactionAttribute

When applied at the TYPE-level, designates the default transaction attribute for all business methods of the session or message driven bean.

在 TYPE-level 应用时,为会话或消息驱动 Bean 的所有业务方法指定默认事务属性。在方法级应用时,仅为该方法指定事务属性。
如:@TransactionAttribute(TransactionAttributeType.SUPPORTS)、 @TransactionAttribute(TransactionAttributeType.REQUIRED)
 
    
7.Interceptors

Declares an ordered list of interceptors for a class or method.

声明类或方法的拦截器的有序列表
 
     
8.Lock

Declares a concurrency lock for a method of a singleton bean with container-managed concurrency.

方法声明一个并发锁的单例bean具有容器管理的并发。
如:@Lock(LockType.WRITE)

 
       
9.Schedule(排程器)

Schedule a timer for automatic creation with a timeout schedule based on a cron-like time expression.

计划时间为自动建立一个超时计划基于一个时间表达式
 
       
10.Startup

Mark a Singleton for eager loading during application initialization.

标记一个单例在应用初始化期间

 
 
11.ConcurrencyManagement 

Declares a Singleton or Stateful session bean's concurrency management type.

声明单例或有状态bean的并发管理类型

在config里用到的:
@Singleton
@Startup
@ConcurrencyManagement(ConcurrencyManagementType.CONTAINER)
@Lock(LockType.WRITE)
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
在service里用到的:

@Stateless
@Local(LawsuitService.class)
@TransactionAttribute(TransactionAttributeType.SUPPORTS)

猜你喜欢

转载自blog.csdn.net/u011038738/article/details/79403602
EJB
今日推荐