• 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

Regarding Tx and Security Context for Interceptor method

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

Consider we have a client with Transaction context T1 calling a Business method of a Bean with Transaction Context T2. There is one interceptor method associated with the business method.

I want to know in what Transaction Context Interceptor method would get called with T1 or T2? Since in the Books it is mentioned that Interceptor method executes in the same Transaction Context as of the Business method for which it is called.

Another think that i need to know is, in what Transaction Context the Interceptor method would get called with for a BMT Bean.
Since the Transaction Context is not marked outside the busniess method it is defined somewhere within the Bean. How do Container understand in what Transaction Context to perform the execution of Interceptor method in without touching the internals of the Business method. Since the Tx context detail is not marked as annotation above the method.

Please Guide.
 
Ranch Hand
Posts: 329
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Juggy Obhi:
I want to know in what Transaction Context Interceptor method would get called with T1 or T2? Since in the Books it is mentioned that Interceptor method executes in the same Transaction Context as of the Business method for which it is called.



It would be called in the context of the bean's business method transaction, T2

Originally posted by Juggy Obhi:
Another think that i need to know is, in what Transaction Context the Interceptor method would get called with for a BMT Bean.
Since the Transaction Context is not marked outside the busniess method it is defined somewhere within the Bean. How do Container understand in what Transaction Context to perform the execution of Interceptor method in without touching the internals of the Business method. Since the Tx context detail is not marked as annotation above the method.



It wil be called with no transaction.
 
Juggy Obhi
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does this mean that an interceptor method for BMT Bean always executes in an unspecified transaction and security context? Is there any case where this is not true?

The picture is quite clear to me now. Thank You

[ September 25, 2008: Message edited by: Juggy Obhi ]
[ September 25, 2008: Message edited by: Juggy Obhi ]
 
Sergio Tridente
Ranch Hand
Posts: 329
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Juggy Obhi:
Is there any case where this is not true?



Yes, you can begin and/or end your transaction in the interceptor method itself.
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Is this a nested transaction? EJB architecture does not support nested transaction.


Originally posted by Juggy Obhi:
Hi,

Consider we have a client with Transaction context T1 calling a Business method of a Bean with Transaction Context T2. There is one interceptor method associated with the business method.

I want to know in what Transaction Context Interceptor method would get called with T1 or T2? Since in the Books it is mentioned that Interceptor method executes in the same Transaction Context as of the Business method for which it is called.

Another think that i need to know is, in what Transaction Context the Interceptor method would get called with for a BMT Bean.
Since the Transaction Context is not marked outside the busniess method it is defined somewhere within the Bean. How do Container understand in what Transaction Context to perform the execution of Interceptor method in without touching the internals of the Business method. Since the Tx context detail is not marked as annotation above the method.

Please Guide.

 
Juggy Obhi
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Is this a nested transaction? EJB architecture does not support nested transaction.



EJB do not support Nested Transaction. EJB supports FLAT Transaction. You can't have more than one Active transaction at the same time.

Flat Transaction

This is not a nested Transaction because when a transaction context T1 is received from the client either is gets carried forward (@Support,@Required) or gets STOP/Suspended so that T2 can pe performed. You will not have any case where T1 and T2 are both Active.


Yes, you can begin and/or end your transaction in the interceptor method itself.



I want to clarify one doubt. It is said that for a Stateful Session bean method committing a transaction is optional while for Stateless it is mandatory.

Will this rule apply to Interceptor method also? Like for an Interceptor method of a stateful bean its is optional to commit/end a transaction at the end of the method and for an interceptor method to a stateless session bean method it is mandatory?
 
Sergio Tridente
Ranch Hand
Posts: 329
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Juggy Obhi:


I want to clarify one doubt. It is said that for a Stateful Session bean method committing a transaction is optional while for Stateless it is mandatory.

Will this rule apply to Interceptor method also? Like for an Interceptor method of a stateful bean its is optional to commit/end a transaction at the end of the method and for an interceptor method to a stateless session bean method it is mandatory?



Refer to section 13.6.1 of the ejb core specification:


In the case of a stateful session bean, it is possible that the business method that started a transaction completes without committing or rolling back the transaction. In such a case, the container must retain the association between the transaction and the instance across multiple client calls until the instance commits or rolls back the transaction. When the client invokes the next business method, the container must invoke the business method (and any applicable interceptor methods for the bean) in this transaction context.

If a stateless session bean instance starts a transaction in a business method or interceptor method, it must commit the transaction before the business method (or all its interceptor methods) returns.


[ September 26, 2008: Message edited by: Sergio Tridente ]
 
Juggy Obhi
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got the concept
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic