Mastering Java EE Development with WildFly
上QQ阅读APP看书,第一时间看更新

Interceptor classes

An interceptor class is a class that establishes a set of operations to carry out when a bean is invoked. It is marked with @Interceptor:

@Interceptor
public class AuditInterceptor {
...}

Or through the beans.xml file:

<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" bean-discovery-mode="none">
<interceptors>
<class> it.vige.businesscomponents.injection.Interceptor.AuditInterceptor
</class>
</interceptors>
</beans>

Look at the none in the bean-discovery-mode property. In WildFly, the file markup for the interceptors works only if set to none. It is done to encourage the use of annotations.