What does the @EJBs annotation do?

前端 未结 4 1056
生来不讨喜
生来不讨喜 2020-12-07 18:04

I know roughly what this construction does: it creates a SomeType EJB and injects the object into another EJB.

 @EJB(name=\"name1\")
 SomeType someVariable
         


        
4条回答
  •  青春惊慌失措
    2020-12-07 18:27

    As for the bonus question: Yes, the two annotations regarding transactions are repeating defaults: The default TransactionManagementType is CONTAINER (vs BEAN) and the - default - TransactionAttributeType REQUIRED simply states that if the bean is called within a transactional context the transaction is continued, otherwise a new transaction will be initiated (as opposed to, for example REQUIRES_NEW which will always create a new tx). This is actually in detail not as trivial as it sounds Cf. the EJB 3.1 spec:

    "13.3.7 Specification of the Transaction Attributes for a Bean’s Methods

    The Bean Provider of an enterprise bean with container-managed transaction demarcation may specify the transaction attributes for the enterprise bean’s methods. By default, the value of the transaction attribute for a method of a bean with container-managed transaction demarcation is the REQUIRED transaction attribute, and the transaction attribute does not need to be explicitly specified in this case.[...]"

提交回复
热议问题