-
1. Re: Doubt with CDI Interceptors in AS 7
alesj Jul 22, 2011 7:57 AM (in response to wilsonguimaraes)Seems that, on AS 7, the beans.xml inside cdijar is being ignored. Is that the correct behaviour?
It's not ignored.
AS7 Weld integration is different from AS6, wrt CDI archives.
AS6 is more flat ~ CDI / (sub)deployment, whereas AS7 is CDI / bean archive.
In order for the interceptor to kick in, you would need to define it in .war' beans.xml.
-
2. Re: Doubt with CDI Interceptors in AS 7
wilsonguimaraes Jul 22, 2011 2:41 PM (in response to alesj)Ales,
We didn't get the point of that. For example, if my app depends on a .jar that defines an interceptor in its beans.xml I need to redefine it in the war's beans.xml in order to use it?
As an additional test we've deployed the same app (https://github.com/zyc/jboss-as7-lab/tree/master/interceptors/scenario1) on tomcat7. To achieve that we've created a Maven profile, added the Weld listener (org.jboss.weld.environment.servlet.Listener) in web.xml and added a dependency to the newest Weld lib (1.1.2.AS7). That works just fine.
Thanks in advance,
Wilson Guimarães
Cleverson Sacramento
-
3. Re: Doubt with CDI Interceptors in AS 7
cleverson.sacramento Jul 22, 2011 3:19 PM (in response to alesj)Ales,
According to section 12.1 (Bean archives) of CDI specification, "When searching for beans, the container considers: (...) any interceptor or decorator class declared in the beans.xml file of any bean archive".
Additionally at top of section 12: "Bean discovery is the process of determining: The bean archives that exist in the application, and the beans they contain; Which alternatives, interceptors and decorators are enabled for each bean archive; (...)"
Would the correct behavior considers beans.xml into the library jar (cdijar) in the way that Wilson referred?
-
4. Re: Doubt with CDI Interceptors in AS 7
swd847 Jul 24, 2011 4:25 PM (in response to cleverson.sacramento)The two relevant sections are:
9.4 - "By default, a bean archive has no enabled interceptors bound via interceptor bindings. An interceptor must be explicitly
enabled by listing its class under the <interceptors> element of the beans.xml file of the bean archive."
9.5 - "An interceptor is bound to the method if: .....
The interceptor is enabled in the bean archive containing the bean."
I agree that this behaviour is not ideal, but we have to follow the spec.
-
5. Re: Doubt with CDI Interceptors in AS 7
cleverson.sacramento Jul 25, 2011 8:33 AM (in response to swd847)Thanks for complementation, Stuart. This is exactily what we mean on the first post: "Seems that, on AS 7, the beans.xml inside cdijar is being ignored. Is that the correct behaviour?".
According to specification, the beans.xml inside "cdijar" which defines the interceptor should be considered... or not? If you run the example app you will notice that AS7 apparently does not follow the spec at this point.
-
6. Re: Doubt with CDI Interceptors in AS 7
swd847 Jul 26, 2011 12:34 AM (in response to cleverson.sacramento)The beans.xml if cdijar is only considered for beans deployed inside cdijar. If the beans.xml in cdijar defines enables an interceptor, it is only applied to beans that are packaged inside cdijar.
Beans in WEB-INF/classes will not be intercepted unless the interceptors are enabled again in META-INF/beans.xml of the war archive.
-
7. Re: Doubt with CDI Interceptors in AS 7
cleverson.sacramento Nov 11, 2011 7:53 AM (in response to swd847)In META-INF/beans.xml or WEB-INF/beans.xml ????
-
8. Re: Doubt with CDI Interceptors in AS 7
alesj Nov 11, 2011 8:26 AM (in response to cleverson.sacramento)WEB-INF
-
9. Re: Doubt with CDI Interceptors in AS 7
dzcs Jun 8, 2012 2:53 AM (in response to swd847)Hi Guys, I am pretty late with my note, but....
Say I have tree jars in a war archive. One of jars provides interceptor bindings and interceptors themselfs. Two other jars uses binding annotations and want to use interceptor. If I follow you, I would have to define interceptors in each of two jar. It would work probably in AS7 (haven't try it). But it does not work in other containers, when weld is deployed together with web application. The exception would be double interceptor registration.