Java – EJB and CDI and entity boundary control mode

I try to understand CDI and EJB and entity boundary control (ECB) patterns My understanding of ECB mode is that boundary is the starting point and end point of transaction boundary In addition, CDI does not provide transaction support like EJB

Therefore, if I want to successfully implement the ECB mode, the following is correct;

>I can use EJB (i.e. @ stateless, @ stateful, @ SortOn) and control layer with CDI or EJB to implement boundary part. > I can use CDI to implement boundaries and control parts, but implementing transaction support in boundaries is similar to( http://smokeandice.blogspot.com/2009/12/cdi-and-declarative-transactions.html )> I can't use CDI to implement boundary, and then start using EJB in the control layer

thank you

Solution

I successfully implemented the ECB pattern in Java EE 6, using EJB only for boundaries and CDI for controllers Typical stack usage in my architecture

>Stateless EJBs are annotated with jax-rs annotations to implement rest services as business logic beans in the range of boundary > CDI managed @ dependent as beans in the range of controller > CDI managed data access object @ dependent. It uses JPA's entitymanager to interact with the database > JPA entity beans

Stateless EJBs that form boundaries are always annotated with @ transactionattribute (required), which is the default I do not use other transaction attributes By doing so, you can ensure that each interaction with boundary occurs in only one transaction

By using only the @ dependent scope of CDI managed beans, you can ensure that each thread has its own bean instance Therefore, you will never have multiple threads accessing CDI managed beans at the same time This prevents you from having typical concurrency problems

Using a heavier combination of pooled EJBs for boundary and lightweight CDI managed beans for the rest of the applications is very good for me

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>