users@ejb-spec.java.net

[ejb-spec users] Re: Question about <interceptor-order> and @Priority

From: Marina Vatkina <marina.vatkina_at_oracle.com>
Date: Fri, 21 Jun 2013 10:42:14 -0700

On 6/21/13 5:42 AM, mjremijan_at_yahoo.com wrote:
> I'm trying to understand the behavior if all of the interceptors on a
> bean are not listed in the <interceptor-order>
>
> So, for example, suppose I have the following 8 interceptors which will
> be called before the bean method is executed...
>
> - 3 default-level interceptors
> - 2 class-level interceptors (using the @Interceptors tag)
> - 3 method-level interceptors (again using the @Interceptors tag)
>
> Now suppose I have only the 3 default-level interceptors in my
> ejb-jar.xml <interceptor-order> tag. What will the ejb container do:
>
> Will it only execute the 3 I have in the ejb-jar.xml and ignore the
> other 5?
>
> Will it execute the 3 default-level interceptors in the order I
> specified in ejb-jar.xml the proceed with the others in the order they
> appear in the @Interceptors tag?
According to the EJB 3.2, "The interceptor-order element is used as an
optional alternative to specify a total ordering over the interceptors
defined for the given level and above."

So you can order default interceptors in the deployment descriptor and
use annotation to order class- and method-level interceptors. But the
<interceptor-order> must be specified inside default-level
<interceptor-binding> element.
>
> Can the <interceptor-order> tag reorder interceptors specified by
> @Interceptors?
Yes. That's it is for.
> Finally, when you through in global-level interceptors with the
> @Priority tag, where are they in the order? I'm assuming @Priority
> interceptors are all executed before default-, class-, and method-level
> interceptors?

@Priority ordering applies only to the interceptors bound using
@InterceptorBinding.

According to the Interceptors 1.2 spec, "For the same interceptor method
type, interceptors declared using interceptor bindings are called after
interceptors declared using the Interceptors annotation (or using the
corresponding element of a deployment descriptor) and before an
interceptor method of the same interceptor type declared on the target
class or any superclass of the target class."

-marina
>
> thanks!
> Mike