Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

bean things in setSessionContext

 
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
 
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....?
 
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 ]
 
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.
 
No, tomorrow we rule the world! With this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic