• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

bean things in setSessionContext

 
srinija kosaraju
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which must NOT be invoked on a bean's EJBContext until AFTER
the execution of the setSessionContext
method in a stateless session bean using CMT?

A) getEJBLocalHome
B) getEJBObject
C) getUserTransaction
D) getCallerPrincipal
E) isCallerInRole
F) setRollbackOnly
G) getRollbackOnly
H) getEJBLocalObject

For me except option A all others appear to be correct.But Given Correct answers are:C,F,G.

can any one give me the correct answers.

thanks in advance
srinija

SCJP 1.4,SCWCD 1.4
 
Nileesha Bojjawar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I agree with you.
According to the lifecycle for the STATELESS session beans, Constructor, setSessionContext() and ejbCreate() are executed by the container and not as a direct call from the client and you dont get any details other than a reference to the home interface in setSessionContext(), after which is the call for ejbCreate() in which you can get EJBObject as well, but the rest of them can be used only in the business method.

So yes Other than A .. rest all are the answers, depends on how many you need to check but again .. none of them ca nbe eleiminates.. they are all the answers.

May be somebody else can help us out with this....?
 
Paulus Maessen
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I see it:

not A since it can be called from setSessionContext
not C since you are using CMT.
not B,H since they are not defined on *EJBContext* but on the subinterfaces

so I think the answer should be D,E,F,G
 
Nileesha Bojjawar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused now.
Is not beans EJBContext for a session bean its SessionContext?
I agree with the elimination of getUserTransaction b/c we are using CMT.
But how about getEJBObject and getEJBLocalObject,
So that would mean again all the others except A must NOT be invoked until after setSessionContext.
[ October 13, 2004: Message edited by: Nileesha Bojjawar ]
 
Paul Maessen
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't be. You are right. You CAN call the getEJB(Local)Object methods on the beans context after setSessionContext.

But since the supposedly correct answer to the question C,F,G excludes getEJBObject/getEJBLocalObject I suppose that the author wanted you to take the question quite literally:

getEJB(Local)Object CANNOT and hence MUST not be invoked on *EJBContext*, because they are not defined there, they are methods of SessionContext and EnityContext.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic