1 22 23 package org.jboss.spring.interceptor; 24 25 import org.jboss.aop.advice.Interceptor; 26 import org.jboss.aop.joinpoint.ConstructorInvocation; 27 import org.jboss.aop.joinpoint.Invocation; 28 import org.jboss.spring.support.SpringInjectionSupport; 29 30 38 public class SpringInjectionInterceptor extends SpringInjectionSupport implements Interceptor 39 { 40 41 public SpringInjectionInterceptor() 42 { 43 log.info("Instantiating " + getName()); 44 } 45 46 public String getName() 47 { 48 return "SpringInjectionInterceptor"; 49 } 50 51 public Object invoke(Invocation invocation) throws Throwable 52 { 53 if (!(invocation instanceof ConstructorInvocation)) 54 { 55 throw new IllegalArgumentException ("This interceptor is meant to be applied" + 56 " only on new instantiation of @Spring annotated objects"); 57 } 58 Object target = invocation.invokeNext(); 59 inject(target); 60 return target; 61 } 62 63 } 64 | Popular Tags |