users@glassfish.java.net

Re: Interceptors question: partial annotation, partial dd possible?

From: Cheng Fang <cheng.fang_at_oracle.com>
Date: Sun, 27 May 2012 22:40:45 -0400

On 5/27/12 4:53 PM, Laird Nelson wrote:
> I have a situation that I'm not clear about the specification's
> position on.
>
> I have an interceptor class. It is packaged up in a jar in my ear
> file's lib directory. It is annotated with the @Interceptor
> annotation. It also features an @AroundInvoke annotation on one of
> its (conformant) methods.
>
> Meanwhile, in another area of the .ear :-) I have an EJB jar file. It
> has an ejb-jar.xml file in META-INF. The ejb-jar.xml file has an
> <assembly-descriptor> section that refers by classname to the class
> name of the interceptor packaged in that other jar.
>
> When I deploy this particular configuration of things, Glassfish 3.1.2
> tells me it can't deploy it because the assembly-descriptor binding
> refers to a class that has not been marked as an interceptor.
>
> But that class HAS been marked as an interceptor (via the @Interceptor
> annotation).
>
> Is it required that if I use the DD to bind an interceptor, I must
> also identify the interceptor in the DD?

Yes, I think so, unless you also have @Interceptors in EJB bean classes
to include these interceptor classes. <interceptors> element is a peer
element of <enterprise-beans> and <assembly-descriptor>.

@Interceptor is usually used along with @InterceptorBinding.

...
</enterprise-beans>

<interceptors>
<interceptor>
<interceptor-class>a.b.MyInterceptor</interceptor-class>
</interceptor>
</interceptors>

<assembly-descriptor>
<interceptor-binding>
....
>
> Best,
> Laird
>
> --
> http://about.me/lairdnelson
>