• 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

Business method interceptor methods (AroundInvoke methods) invocation order

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

Regarding Business method interceptor methods (AroundInvoke methods) invocation order, is this correct?

* Invocation rules:
  - If a method is overridden it will not be invoked.
  - Default order is as specified on annotation or DD element.
  - For a given level, annotated interceptors precede DD interceptors.
  - For a given class, invocation is hierarchical from most general superclass.

* Invocation order:
  - Default interceptors.
  - Class-level interceptors.
  - Method-level interceptors.
  - Bean interceptor method.

* Full order with rules applied (always non overridden AroundInvoke methods):
  - Default interceptors as specified in the DD. For each, invocation is hierarchical from most general superclass.
  - Annotated class-level interceptor classes as specified in annotation. For each, invocation is hierarchical from most general superclass.
  - DD class-level interceptor classes as specified in DD. For each, invocation is hierarchical from most general superclass.
  - Annotated method-level interceptor classes as specified in annotation. For each, invocation is hierarchical from most general superclass.
  - DD method-level interceptor classes as specified in DD. For each, invocation is hierarchical from most general superclass.
  - Bean’s superclasses AroundInvoke methods, most general superclass first.
  - Bean’s AroundInvoke method.

Hope that I have explained...

Thank you in advance.
 
Xavi Sanchez
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.

I'm taking the exam this week.

Could anyone confirm my deductions please?

Thanks.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about super-class annotated interceptors are they inherited?
 
Marcin Faryna
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think i figured it out:
1.Default interceptors with order in DD (method level default interceptors can be invoked first if they are defined in such order in DD)
2.Bean class level annotated interceptors with order declared in annotation (if such interceptor has parent, this parent will be invoked first)
3.Bean parent class level annotated interceptors with order declared in annotation
4.DD class level interceptors order defined in DD
5.Bean method level annotated interceptors with order declared in annotation (if such interceptor has parent, this parent will be invoked first)
6.DD method level interceptors with order declared in annotation (if such interceptor has parent, this parent will be invoked first)
7.Bean class parent (if any) defined interceptor
8.Bean class itself defined interceptor

Hope that's all

 
Marcin Faryna
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This order is valid for jboss.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marcin Faryna wrote:What about super-class annotated interceptors are they inherited?



see 12.3.1
If an interceptor class itself has superclasses, the interceptor methods defined by the interceptor
class’s superclasses are invoked before the interceptor method defined by the interceptor class,
most general superclass first.

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

Below is what I prepared for my exam. The > sign denotes the order of invocation. Hope it help.

- Invocation order:
+ Default interceptors > Class interceptors > Method interceptors > Bean’s interceptor methods
+ Within same group, invocation order is the same as order of specification. If DD is used to augment annotation, annotation > DD
+ Within same class (bean or interceptor class), super-classes' interceptor > current class’ interceptor. If an interceptor method is overridden by another method (regardless of whether that method is itself an interceptor method), it will not be invoked.

- DD interceptor-order element can be used to override the default order specified in annotation. However, when used, developer must specify the total ordering of interceptors

(https://sites.google.com/site/mostlyjava/scbcd/02-general-ejb-3-0-enterprise-bean-knowledge)
 
Marcin Faryna
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes but there is specific situation which i cannot find in JSR220:



In this case in glassfish 3.0.1 we got:
ClassAInterceptor:perform
ClassBInterceptor:perform

but in jboss 5.1.0GA:
ClassBInterceptor:perform
ClassAInterceptor:perform

I presume that this is gap in specification and vendors implement this on their own.

 
T. Huy Nguyen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tend to agree with the result of Glassfish: If B extends A then whatever declared on A should execute first.

What do you think?
 
seb tetris
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marcin Faryna wrote:Yes but there is specific situation which i cannot find in JSR220:



In this case in glassfish 3.0.1 we got:
ClassAInterceptor:perform
ClassBInterceptor:perform

but in jboss 5.1.0GA:
ClassBInterceptor:perform
ClassAInterceptor:perform

I presume that this is gap in specification and vendors implement this on their own.



I agree that its a gap in the specification.
I can imagine that for a method in A that is not overridden by B only the AInterceptor is invoked. ( assuming the runttime type is B )
and if overridden first the A then the B interceptor.
and if B doesnt overrides only the BInterceptor.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic