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.

無狀態會話 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)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章