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

afterBegin() method

 
Will Hunt
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which method can be invoked when a stateful session bean is in the method ready state but not in a transaction?

A ejbCreate()
B afterBegin()
C ejbActivate()
D afterCompletion()
E beforeCompletion()


This is one of the question in the sun's practice exam. Accroding to them the answer is B.

But isn't the afterBegin() method invoked by the container method after it starts a transaction ?

Or is there a better explanation for the answer
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Will Hunt:
Which method can be invoked when a stateful session bean is in the method ready state but not in a transaction?

A ejbCreate()
B afterBegin()
C ejbActivate()
D afterCompletion()
E beforeCompletion()


This is one of the question in the sun's practice exam. Accroding to them the answer is B.

But isn't the afterBegin() method invoked by the container method after it starts a transaction ?

Or is there a better explanation for the answer


The question is tricky. However, I would go by exclusion. It cannot be A & C because the bean is already in the method-ready state. It cannot be D & E because a transaction is supposed to be already started...By exclusion it bust be B, because it is the only method that remains, and it's likely that for a CMT SB, the method will run in a transaction.

HTH,

Marco
 
Dan T
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Mastering Entriprise Javabeans: " Called by the container directly after a transaction begins"

From HF-EJB: "At the beginning of a stateful bean's transaction, BEFORE the business methods that's going to run in the trasnaction is called"

From EJB spec: The afterBegin notification signals a session bean that a new transaction has begun. The container invokes this method before the first business method within a transaction (not nec. the beginning)

When the container invokes afterCompletion(boolean committed), is the ready state?
[ July 31, 2004: Message edited by: Ryan Wong ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic