wood burning stoves*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes ejbcertificate.com - Session Bean Lifecycle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "ejbcertificate.com - Session Bean Lifecycle" Watch "ejbcertificate.com - Session Bean Lifecycle" New topic
Author

ejbcertificate.com - Session Bean Lifecycle

Kris Reid
Ranch Hand

Joined: Jan 05, 2005
Posts: 247
Can someone clarify this please? What do they mean by a consistent state?
I don't understand that if a method is not in a transaction why is it not in a consistent state?


Which method can access an enterprise bean in a consistent manner for a container managed stateful session bean that implements the SessionSynchronization interface?


1. constructor()

2. setSessionContext()

3. ejbCreate()

4. beforeCompletion()

5. afterCompletion()






Answer 4 is correct. beforeCompletion() informs a session bean instance that the current transaction is about to be committed. Since the bean instance has a transactional context, the behaviour of executing beforeCompletion() is guaranteed by the container.

Answers 1, 2, 3 and 5 are incorrect. The constructor(), setSessionContext(), ejbCreate(), and afterCompletion() methods are executed with an unspecified transaction context; hence, the behaviour of executing the methods cannot be relied on.

Note: The table 2 on page 80 on EJB specification states that an enterprise bean may be accessed in the ejbCreate method; however, since a transaction context is unspecified for this method, the behaviour of executing ejbCreate() is not guaranteed by the container
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
Please refer to the EJB 2.0 specifications, page 364 for more information.

"unspecified transaction context" refers to the cases in
which the EJB architecture does not fully define the transaction semantics of an enterprise bean method execution...


The specifications does not prescribe how the container manage the execution of methods that runs with unspecified transaction context. There are a couple of choices that the container can choose to use/implement. We do not know which is the implementation chosen.

This is perhaps what is meant by inconsistent.

More importantly perhaps is this:

A failure that occurs in the middle of the execution of a method that runs with an unspecified transaction context may leave the resource managers accessed from the method in an unpredictable state. The EJB architecture does not define how the application should recover the resource managers´┐Ż state after such a failure.


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
Kris Reid
Ranch Hand

Joined: Jan 05, 2005
Posts: 247
Thanks Chengwei

Excellent reply!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ejbcertificate.com - Session Bean Lifecycle