ejb@glassfish.java.net

method-level interceptor binding and overloaded methods

From: Cheng Fang <Cheng.Fang_at_Sun.COM>
Date: Thu, 08 Jun 2006 16:46:57 -0400

Hi,

For the following method:

@Interceptors(ArgumentsVerifier.class)
    public void emptyArgs() {
    }

The generated ejb-jar.xml after deployment has this (note no
<method-params> element is used)

<interceptor-binding>
<ejb-name>SlessEJB</ejb-name>
<interceptor-order>
<interceptor-class>com.sun.s1asdev.ejb.ejb30.interceptors.session.ArgumentsVerifier</interceptor-class>
</interceptor-order>
<method>
<method-name>emptyArgs</method-name>
</method>
</interceptor-binding>

But this is not consistence with EJB 3 spec 12.8.2 Style 3, which says
the above xml <interceptor-binding> applies to all overloaded methods
with the method-name. So it will also apply the ArgumentsVerifier
interceptor to other methods like:

public void emptyArgs(int i);
public void emptyArgs(String s);

even though they are not annotated with any method-level interceptors.

On the other side, at runtime, if my intention is to apply such a
catch-all binding to all overloaded methods, it doesn't work as
expected; it only applies to the one with no param.

Maybe we need to change the no-param binding to something like this?

<method>
  <method-name>foo</method-name>
  <method-params/>
</method>

-- 
Cheng