Apply an Interceptor to a Contructor Execution
How do I apply an Interceptor to a constructor execution? To bind an interceptor to a constructor, you must create an XML file. Open up jboss-aop.xml and take a look. Let's apply ConstructorInterceptor.java to the public POJO(int i) constructor. To apply the interceptor you must create a binding and a pointcut that specifies where in your Java code you want the interceptor applied. execution(constructor expression) defines whenever the constructor is executed. A constructor expression requires a class expression followed by '->' followed by 'new' followed by a list of parameters. You can optionally provide constructor attributes like 'public', 'static', etc. if so desired. You do not have to specify the entire signature of the constructor. It works in much the same way method expressions work.