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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Question in MDB 2" Watch "Question in MDB 2" New topic
Author

Question in MDB 2

somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
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.


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Balaji Akella
Ranch Hand

Joined: Oct 29, 2003
Posts: 35
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.
Kathy Sierra
Cowgirl and Author
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
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
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Thank you very much, for both answer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question in MDB 2
 
Similar Threads
Explain the ouput
Shuffling poker chips
Including static content
SCJP 5: Question on Generics