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?
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
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.