From: <kab...@jb...> - 2005-07-09 11:25:20
|
I am sure we have tests in our testsuite for this. In any case I gave it a go, and it worked for me. | public class ConstructorInterceptor implements Interceptor | { | public String getName() { return "ConstructorInterceptor"; } | | public Object invoke(Invocation invocation) throws Throwable | { | try | { | System.out.println("<<< Doing it"); | Object o = invocation.invokeNext(); | System.out.println("Got o " + (o != null)); | return o; | } | finally | { | System.out.println(">>> Leaving ConstructorInterceptor"); | } | } | } | | <aop> | | <bind pointcut="call(* java.lang.Class->newInstance(..))"> | <interceptor class="ConstructorInterceptor"/> | </bind> | | </aop> | | public class Driver | { | public static void main(String[] args) throws Exception | { | Class clazz = POJO.class; | System.out.println("--- new POJO(); ---"); | POJO pojo = (POJO)clazz.newInstance(); | System.out.println("Got pojo " + (pojo != null)); | } | } | | <?xml version="1.0" encoding="UTF-8"?> | <aop> | | <bind pointcut="call(* java.lang.Class->newInstance(..))"> | <interceptor class="ConstructorInterceptor"/> | </bind> | | </aop> | Output: | | [java] --- new POJO(); --- | [java] <<< Doing it | [java] empty constructor | [java] Got o true | [java] >>> Leaving ConstructorInterceptor | [java] Got pojo true | View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3884262#3884262 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3884262 |