On Sun, May 27, 2012 at 8:19 PM, Laird Nelson <ljnelson_at_gmail.com> wrote:
> The problem is either with my understanding of the <ejb-name> element or
> Glassfish's resolution of it.
>
Must have been my understanding (not surprised); an <ejb-name> of
PersonBean works just fine.
It's when I add the <method> stanza. I am using style #3 on page 563 of
the EJB 3.1 specification. Here is the specification's example of the
style:
<interceptor-binding>
<ejb-name>EJBNAME</ejb-name>
<interceptor-class>INTERCEPTOR</interceptor-class>
<method>
<method-name>METHOD</method-name>
</method>
</interceptor-binding>
Note the <method> stanza.
Mine works if I use style #2--that is, if I omit the <method> stanza
altogether. My interceptor is fired on all methods of PersonBean,
including the one I want:
<interceptor-binding>
<ejb-name>EJBNAME</ejb-name>
<interceptor-class>INTERCEPTOR</interceptor-class>
</interceptor-binding>
...but my interceptor is not created or fired if I put in the name of the
method that I would like intercepted. It is as though the method is
silently ignored.
When I use style #2, I made sure my interceptor outputs the name of the
method ("persist", in my case). I used that value for the <method-name>
element in style #3. No luck.
I'm wondering if inheritance is an issue here.
My stateless EJB (PersonBean) inherits from an abstract class (non-EJB;
AbstractDAO) that implements DAO, an interface.
My EJB also directly implements PersonManager, another interface.
So:
@Stateless
public class PersonBean extends AbstractDAO implements PersonManager...
The persist method signature is defined in DAO and implemented in
AbstractDAO.
I figured that the proper way to refer to this was:
<interceptor-binding>
<ejb-name>PersonBean</ejb-name>
<interceptor-class>com.foobar.NewPersonInterceptor</interceptor-class>
<method>
<method-name>persist</method-name>
</method>
</interceptor-binding>
...although strictly speaking PersonBean does not override or otherwise
directly declare the "persist" method (that is declared in his superclass).
Soldiering onwards!
Best,
Laird
--
http://about.me/lairdnelson