I have found out that the behaviour of weld in JBoss AS7 differs from weld for older containers. The point of my question is the following. For older containers I use weld 1.1.8.Final and as it says in reference documentation I register interceptors in the same jar where I define them by naming them in beans.xml, which is under META-INF. For weld servlet it was enough to register them and to enable them for whole war package. Example:
|- beans.xml -> just <beans></beans>
|- web.xml -> listener registration
|- jbsoss-web.xml -> context path, realm name, ds mappings
| ...... jars
|- somename1.jar -> defines interceptors, binding annotations, producers
| \- META-INF
| \- beans.xml -> lists all interceptors in interceptors section
\- somename2.jar -> uses Injections (from producers above), annotations interceptor bindings defined in jar above.
\- beans.xml -> just <beans></beans> to show that it must be controlled.
Now I tried to do the same trick with AS7 (of course removing weld from war and removing weld listener in web.xml). So what - AS7 Weld was totally ignoring my registration of interceptors. As I found out it wants to have registration in the same jar where I use them - my interceptors. In my example it would be "somename2.jar". That means I have to remove list of interceptors from beans.xml in somename1.jar and insert this list of interceptors in beans.xml file in somename2.jar. Fine. It works. More over it is still working with my older container with weld listener enabled.
Now. I have somename3 and somename4 jars, which are using my interceptors. If I follow the logic of AS7 I will have to register my interceptors in beans.xml of both jar archives. Only in this case it would work in AS7. But it would not work in older container, because weld will fail with exception that the interceptors enabled twice. - This is the issue number one.
The second issue is that actually I dont whant that my application developer even know something about the interceptors which needs to be enabled in their jars. What they need to know, that if they annotate some class or some method with some special annotation the system will do something. I thought it was the main idea of the CDI to separate that concerns.
Please correct me if I misunderstood anything. Any advices? Thank you in advance.