Is it safe to introduce @Resource UserTransaction in EJB Singleton bean

Q1: I am writing an EJB Singleton bean that use BMT, so I need to use UserTransaction in my bean. I was wondering what IS IT SAFE is for embedding @Resource UserTransaction in my EJB singleton bean. I do not know if the container will introduce UserTransaction or NOT proxies. Can someone give me some ideas? Thanks!

Q2:

What is the difference between @Resource UserTransaction and sessionContext.getUserTransaction (). Are they equivalent?

+4
source share
1 answer

, IS IT SAFE @Resource UserTransaction EJB singleton bean.

A Singleton session bean beans, ejb3.1: Stateless, Stateful Singleton.   Singleton , beans.

:

4.3.3 SessionContext. bean SessionContext.., bean SessionContext. bean , .

.

@Resource UserTransaction sessionContext.getUserTransaction(). ?

, . :

4.3.2 . API EJB 3.1 bean SessionContext SessionBean. bean s SessionContext ( -env-ref).

, , Singleton , SessionContext. . . , , , , , . 117 , UserTransaction

3

, Singleton Bean:

Bean :

SessionContext: UserTransaction

+2

Source: https://habr.com/ru/post/1524112/


All Articles