• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Question in MDB 2

 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much, for both answer.
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic