• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

whizlabs question.

 
mallika shah
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello ,

here is one question:

A client send a message to a queue.The MDB calls the MessageDrivenContext.getCallerPrincipal() upon receiving the message.what will be the return value of this method execution?
1. It will return the principal object associated with the client sending the message
2.It will return the value of security role defied for the method.
3. It will throw a runtime Exception
4. It will return a null value.

Whats the correct ans..please explain
I answered 1.
But whizlabs says its 3.

mallika
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as MDB are concerned, there's no client. An MDB does not know who really sent the message first, so all client related methods cannot be used. Please refer to 15.4.3 The MessageDrivenContext interface in the specification. Also, this method never returns null, so you can also discard number 4.
 
mallika shah
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Christophe..

Got your point...

mallika
 
Napu Sun
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Invoking the getCallerPrincipal and isCallerInRole methods is disallowed in
the message-driven bean methods because the Container does not have a client security context.
The Container must throw and log the java.lang.IllegalStateException if
either of these methods is invoked.

Please refer to Specification 15.5.1
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic