@Test public void testInterceptor() throws Exception { ApplicationContext applicationContext = new ClassPathXmlApplicationContext("tinyioc.xml"); HelloWorldService helloWorldService = (HelloWorldService) applicationContext.getBean("helloWorldService"); helloWorldService.helloWorld(); AdvisedSupport advisedSupport = new AdvisedSupport(); TargetSource targetSource = new TargetSource(helloWorldService, HelloWorldServiceImpl.class, HelloWorldService.class); advisedSupport.setTargetSource(targetSource); TimerInterceptor timerInterceptor = new TimerInterceptor(); advisedSupport.setMethodInterceptor(timerInterceptor); Cglib2AopProxy cglib2AopProxy = new Cglib2AopProxy(advisedSupport); HelloWorldService helloWorldServiceProxy = (HelloWorldService) cglib2AopProxy.getProxy(); helloWorldServiceProxy.helloWorld(); }
@Override public Object getProxy() { Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(advised.getTargetSource().getTargetClass()); enhancer.setInterfaces(advised.getTargetSource().getInterfaces()); enhancer.setCallback(new DynamicAdvisedInterceptor(advised)); Object enhanced = enhancer.create(); return enhanced; }
Cglib2AopProxy extends AbstractAopProxy { @Override public Object getProxy() { Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(advised.getTargetSource().getTargetClass()); enhancer.setInterfaces(advised.getTargetSource().getInterfaces()); enhancer.setCallback(new DynamicAdvisedInterceptor(advised)); Object enhanced = enhancer.create(); return enhanced; } }
Cglib2AopProxy extends AbstractAopProxy { @Override public Object getProxy() { Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(advised.getTargetSource().getTargetClass()); enhancer.setInterfaces(advised.getTargetSource().getInterfaces()); enhancer.setCallback(new DynamicAdvisedInterceptor(advised)); Object enhanced = enhancer.create(); return enhanced; } Cglib2AopProxy(AdvisedSupport advised); }
Cglib2AopProxy extends AbstractAopProxy { @Override public Object getProxy() { Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(advised.getTargetSource().getTargetClass()); enhancer.setInterfaces(advised.getTargetSource().getInterfaces()); enhancer.setCallback(new DynamicAdvisedInterceptor(advised)); Object enhanced = enhancer.create(); return enhanced; } Cglib2AopProxy(AdvisedSupport advised); @Override Object getProxy(); }
Cglib2AopProxy extends AbstractAopProxy { @Override public Object getProxy() { Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(advised.getTargetSource().getTargetClass()); enhancer.setInterfaces(advised.getTargetSource().getInterfaces()); enhancer.setCallback(new DynamicAdvisedInterceptor(advised)); Object enhanced = enhancer.create(); return enhanced; } Cglib2AopProxy(AdvisedSupport advised); @Override Object getProxy();  }