This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Which the follwing methods in MessageDrivenBeanContext interface can not be invoked by MDBs with CMT demarcation? 1.isCallerInRole 2.getUserTransaction 3.getRollbackOnly My answer : 2 , That all Right?
thank you for all answer.
Java Developer, Thailand
isCallerInRole() method of EJBContext interface (inherited to MessageDrivenContext) cannot be called from message driven beans irrespective of transaction demarcation and getUserTransaction() can only be called from instances with bean managed transaction demarcation. (more info in EJB spec., section 15.4.3, pg. 315). Hence, the correct answers should be both a and b. Swamy
In the morning there is hope; in the afternoon, fulfillment; in the evening, memory; at night, peace.
Yes, I agree with Swamy. Remember, getUserTransaction() is used to get the javax.transaction.UserTransaction object upon which you can call begin(), commit(), etc. -- for bean-managed transactions (BMT). So that means the only beans that can call this method are BMT session beans (both stateful and stateless) or BMT message-driven beans. As for isCallerInRole(), remember that message-driven beans do NOT have a client! So there is no point trying to get security information about the client. So message-driven beans are *heavily* restricted in what they can ask of their MessageDrivenContext. They have no home and no EJB object, so they can't call any of those methods, and since they have no client, they can't call isCallerInRole() and getCallerPrincipal() to get security info about the client. It is *true* that the Container calls the onMessage() method of the MDB, but we do NOT call the Container the 'client' to the MDB. The Container is the manager, not the client. And since a message is coming from a messaging service, and not directly from a client invocation on a business method, the security context of the client (the original message-sender) is not propogated into the onMessage() method. And the MDB has no reason to distrust the Container -- the actual caller of the method as far as the MDB is concerned. cheers, Kathy