Win a copy of AWS Security this week in the Cloud/Virtualization 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

afterBegin() method

 
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
 
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
 
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 ]
 
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic