Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Business method interceptor methods (AroundInvoke methods) invocation order

 
Xavi Sanchez
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hi.

I'm taking the exam this week.

Could anyone confirm my deductions please?

Thanks.
 
Marcin Faryna
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
This order is valid for jboss.
 
seb tetris
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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.

 
T. Huy Nguyen
Ranch Hand
Posts: 57
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic