Hi,
I am looking at some interceptor samples, and after investigating some
failures, it looks to me that the issue is caused by two different method
level OVERLOADED_METHOD, EXACT_METHOD. Per the interceptor specification, it
only defines three level method. class and default (aka. package in OpenEJB
codes).   And it also writes that if both style is used to configure
interceptors, the invocation order is undefined.
Personally, I like these two method levels, and actually it looks more
nature, from the invocation order, first override method, then exact method.
While it brings some issues in my samples.
The first one is https://issues.apache.org/jira/browse/OPENEJB-1602 For this
one, I could have a solution for this, we just need to double check while
finding an EXPLICT_ORDERING, the codes below could solve the issue :
--->
if (type == Type.EXPLICIT_ORDERING && !excludes.contains(level)){

                //Both OVERLOADED_METHOD and EXACT_METHOD are actually
method level,
                //the first one is a convenient way to configure for all the
methods with the same name.
                //If an EXPLICIT_ORDERING is found on the OVERLOADED_METHOD,
those configurations on the
                //EXACT_METHOD should be override.
                /*if(level == Level.OVERLOADED_METHOD) {
                    methodBindings.clear();
                }*/

                methodBindings.add(info);
                // An explicit ordering trumps all other bindings of the
same level or below
                // (even other explicit order bindings).  Any bindings that
were higher than
                // this one still apply (and will have already been
applied).
                //
                // So we keep what we have, add this last binding and we're
done with this method.
                return methodBindings;
            }
<---
The second issue is that, the spec requires that the interceptor configured
in the deployment script must be invoked after those from annotations. With
the example below, the final result with current sorting codes will be
interceptor2, interceptor1, interceptor3, while the expect result
is interceptor1, interceptor2, interceptor3. I did not see a solution to
solve this if we still keep the two different method level. And if I just
use one method level, we will get the expected results.
So I plan to remove the two method levels, thoughts ? Thanks.

e.g. The interceptors annotation is used on the method1, like
...
@Interceptors{{interceptor1,class}}
public void method1(String str) {
}
...

In the deployment script, the configures are something like :

<interceptor-binding>
            <ejb-name>MyBean </ejb-name>
                <interceptor-class>Interceptor2</interceptor-class>
            </interceptor-order>
            <method>
                <method-name>method1</method-name>
            </method>
        </interceptor-binding>
<interceptor-binding>
            <ejb-name>MyBean </ejb-name>
            <interceptor>
                <interceptor-class>Interceptor3</interceptor-class>
            </interceptor-order>
            <method>
                <method-name>method1</method-name>
               <method-params>
                     <method-param>java.lang.String</method-param>
               </method-params>
            </method>
        </interceptor-binding>
-- 
Ivan

Reply via email to