Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is this correct ??

 
Gotan itain Lasgo
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A message-driven bean can have an instance of a MessageDrivenContext injected.
Which method can be successfully invoked on this interface from a message-driven bean?
A getEJBHome
B getCallerPrincipal
C isCallerInRole
D getEJBLocalHome

They said that the correct one is "B", but I think that calling all will throw RuntimeException.
 
Fofa He
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think so. All 4 methods are illegal to be invoked for MDB.
 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer B is correct. Quoting from the core spec 5.4.4

The MessageDrivenContext Interface

The getCallerPrincipal method returns the java.security.Principal that is
associated with the invocation
 
Gotan itain Lasgo
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now Im really confused !!


Only the transactional methods the MessageDrivenContext inherits from EJBContext are available to message-driven beans. The home methods--getEJBHome() and getEJBLocalHome()--throw a RuntimeException if invoked, because MDBs do not have home interfaces or EJB home objects. The security methods--getCallerPrincipal() and isCallerInRole()--also throw a RuntimeException if invoked on a MessageDrivenContext. When an MDB services a JMS message there is no "caller," so there is no security context to be obtained from the caller. Remember that JMS is asynchronous and doesn't propagate the sender's security context to the receiver--that wouldn't make sense, since senders and receivers tend to operate in different environments.

extracted from Ejb 3 (Oreilly)
 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think better to go by spec in such a scenario. Maybe you could try thid out practically and see what happens. :roll:
 
waleed zedan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

According to core specs page 117 , in CMT , getCallerPrincipal is a valid call , i think it will returns the Prinicipal of the AS

BR,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic