aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes deployment descriptor transaction attributes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "deployment descriptor transaction attributes" Watch "deployment descriptor transaction attributes" New topic
Author

deployment descriptor transaction attributes

Charles O'Leary
Greenhorn

Joined: Jul 10, 2014
Posts: 6
JSR:220
13.3.7.2 Specification of Transaction Attributes in the Deployment Descriptor states the following:

If the deployment descriptor is used to override annotations, and transaction attributes are not specified for some methods, the values specified in annotations (whether explicit or defaulted) will apply for those methods.



Is there ever a time when transaction attributes are not specified (and/or defaulted)? Annotated transaction attributes aren't overridden by transaction attributes in the deployment descriptor under what conditions exactly? If possible, could you please provide any (simple and) concrete examples to help clarify?

Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 775
On p.174 of EJB in Action (2nd edition), It says " REQUIRE is the default..." which means @TransactionAttribute.REQUIRED is the default.
Charles O'Leary
Greenhorn

Joined: Jul 10, 2014
Posts: 6
13.3.7.2 Specification of Transaction Attributes in the Deployment Descriptor

The following is the description of the rules for the specification of transaction attributes in the deployment
descriptor. (See Section 19.5 for the complete syntax of the deployment descriptor.)

Note that even in the absence of the use of annotations, it is not necessary to explicitly specify transaction
attributes for all of the methods listed in section 13.3.7. If a transaction attribute is not specified for
a method in an EJB 3.1 deployment descriptor, the transaction attribute defaults to Required.

If the deployment descriptor is used to override annotations, and transaction attributes are not specified
for some methods, the values specified in annotations (whether explicit or defaulted) will apply for
those methods.


In the context of the above, what's meant by the following:

If the deployment descriptor is used to override annotations, and transaction attributes are not specified
for some methods, the values specified in annotations (whether explicit or defaulted) will apply for
those methods.



More specifically:

Is there ever a time when transaction attributes are not specified (and/or defaulted)? Annotated transaction attributes aren't overridden by transaction attributes in the deployment descriptor under what conditions exactly? If possible, could you please provide any (simple and) concrete examples to help clarify?

Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 775
When transaction attribute is not specified, then, by default, it is @TransactionAttribute(TransactionAttributeType.REQUIRED).

On p.416 of EJB in Action(2nd),

You used @TransactionAttribute to specify that the transaction attribute for a bean method be REQUIRE_NEW. If you want to override it to use REQUIRED, then use the following descriptor:
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>BazaarAdmin</ejb-name>
<method-name>getUserWithItems</method-name>
<method-params></method-params>
</method>
<transaction-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>

Charles O'Leary
Greenhorn

Joined: Jul 10, 2014
Posts: 6
Himai Minh,

I agree with your answers for your specific example. I am NEVER a big fan of the specifications. Where's Head First? (Sorry, I digressed.) Since they are the standard by which these exams are judged and possibly because it's late, unfortunately, I'm not connecting your example with my specific questions. If you have the patience, please help me connect the dots.


Ranchers,

My (possibly erroneous) interpretation is that the values specified in annotations (whether explicit or defaulted) will apply for
those methods INSTEAD OF the values specified in the deployment descriptor under certain conditions?

AND there are numerous contradictions in MY understandings within this one sentence of the specification:

* Since when did annotations override deployment descriptor?
* Because of defaults (REQUIRED in this case), what does it mean for a transaction attribute to be simply "unspecified" (or not defaulted)?
* ".... specified in annotations (whether explicit or defaulted) will apply ..." But, in the same sentence it says that somehow "transaction attributes are not specified"?

Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1695
    
  25

Hi Charles,

I understand your confusion. The specifications are not always easy to read. Let me try to simplify things for you:

  • Transaction attributes in the deplyment descriptor always override the transaction attributes in annotations.
  • It is possible to override one method of a certain EJB in the deployment descriptor. If you do so, the other methods wil have the value of the annotation, or if not specified they will get the default: REQUIRED.
  • Charles O'Leary
    Greenhorn

    Joined: Jul 10, 2014
    Posts: 6
    Got it! Thanks Frits Walraven and Himai Minh!
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: deployment descriptor transaction attributes