Using EJB default interceptor to match on parameters
I'd like to create an EJB default interceptor that acts on any business method that contains a certain set of parameters, but doesn't need to match exactly. There's the classic method of matching by parameter set, i.e:
<assembly-descriptor>.
<!-- Method interceptor will apply to sendBookingCancellationMessage for EmailSystemBean -->
<interceptor-binding>
<ejb-name>MyBean</ejb-name>
<interceptor-class>SomeIntercep开发者_Go百科tor</interceptor-class>
<method>
<method-name>overLoadedMethod</method-name>
<method-params>
<method-param>int</method-param>
<method-param>java.lang.String[][]</method-param>
</method-params>
</method>
</interceptor-binding>
</assembly-descriptor>
But I'd instead like to match on any method that takes an int and a String[][] and whatever else, instead of those exact two. Does anybody know if this can be done?
On Glassfish v3, using the wildcard value '*' for the method name seems to work at the individual bean level:
<interceptor-binding>
<ejb-name>MyBean</ejb-name>
<interceptor-class>SomeInterceptor</interceptor-class>
<method>
<method-name>*</method-name>
<method-params>
<method-param>int</method-param>
<method-param>java.lang.String[][]</method-param>
</method-params>
</method>
</interceptor-binding>
However, this behavior isn't called out in the Interceptors specification so far as I can see, so it probably shouldn't be relied upon.
It couldn't be done in a standard-defined way.
However, you can simply intercept every call and check for the parameter types yourself.
精彩评论