Friday, March 02, 2007

JAVA 認證心得 -- SCBCD (11)



  • When using BMT demarcation, message-driven beans and stateless session beans must commit a transaction before the method that initiated the transaction returns

  • Only Session and Message driven bean can implement bean managed transactions

  • javax.transaction.UserTransaction

  • container-transaction element specifies a list of methods and their transaction attributes.

  • transaction-typeContainer/Bean/transaction-type is used only in session and message-driven beans because it is mandatory for entity beans to use container-managed transaction demarcation.

  • trans-attributeRequired/RequiresNew/Mandatory/Never/Supports/NotSupported/trans-attribute

  • Container throws java.lang.IllegalStateException if the enterprise bean using container-managed transaction demarcation invokes setRollbackOnly or getRollbackOnly of EJBContext interface from its methods with transaction attribute NotSupported, Supports or Never.

  • These are the methods you must mark with an attribute

    1. Session beans: ONLY business methods in the component interface

    2. Entity beans: business methods in the component interface. Remove(), remove(Object pk), remove(Handle h)

    3. Message-driven beans: onMessage()

  • Providing the transaction attributes for an enterprise bean is an optional requirement for the Application Assembler, because, for a given enterprise bean, the Application Assembler must either specify a value of the transaction attribute for all the methods for which a transaction attribute must be specified, or the Assembler must specify none. If the transaction attributes are not specified for the methods of an enterprise bean, the Deployer will have to specify them.

  • Only a stateful session bean is permitted to start a transaction in a method and not commit or rollback the transaction before returning.

  • CMT session beans and CMT message-driven beans will the different ejbCreate methods run within an unspecified transaction context.

  • A transaction may span multiple method calls on entity bean instance, CMT stateful session instance, BMT stateful session bean instance.

Read more!

No comments: