• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

operations allowed in the methods of stateful session bean

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, everybody,

On page 80 of the specification, resource manager access and enterprise bean access are allowed in the bean methods ejbCreate, ejbRemove, ejbPassivate, ejbActivate. Why? IMO, since there is no meaningful transactin context( unspecified) in these bean methods, the accesses to resource manager and enterprice bean should not be allowed, just as that specifed in the afterCompletion. Can somebody help?
dennis
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the question I have, so if anyone can answer, that will be help.
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anyone can answer?
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even though accessing Resource Managers and EJBs is permitted in unspecified transaction contexts, its behavior is unpredictable in case of failure. Do so at your own risk. It is not guaranteed by the EJB spec.
Your question gets answered after the table, in page 81 as below:
The ejbCreate<METHOD>, ejbRemove, ejbPassivate, and ejbActivate methods of a session bean with container-managed transaction demarcation execute with an unspecified transaction context. Refer to Subsection 17.6.5 for how the Container executes methods with an unspecified transaction context.
Excerpts from 17.6.5:
The EJB specification does not prescribe how the Container should manage the execution of a method
with an unspecified transaction context�the transaction semantics are left to the Container implementation.
Some techniques for how the Container may choose to implement the execution of a method
with an unspecified transaction context are as follows (the list is not inclusive of all possible strategies):
� The Container may execute the method and access the underlying resource managers without a
transaction context.
� The Container may treat each call of an instance to a resource manager as a single transaction
(e.g. the Container may set the auto-commit option on a JDBC connection).
� The Container may merge multiple calls of an instance to a resource manager into a single
transaction.
� The Container may merge multiple calls of an instance to multiple resource managers into a
single transaction.
� If an instance invokes methods on other enterprise beans, and the invoked methods are also designated to run with an unspecified transaction context, the Container may merge the
resource manager calls from the multiple instances into a single transaction.
� Any combination of the above.
Since the enterprise bean does not know which technique the Container implements, the enterprise bean must be written conservatively not to rely on any particular Container behavior.
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic