/** * Create a DefaultIntroductionAdvisor for the given advice. * @param advice the Advice to apply * @param intf the interface to introduce */ public DefaultIntroductionAdvisor(DynamicIntroductionAdvice advice, Class<?> intf) { Assert.notNull(advice, "Advice must not be null"); this.advice = advice; addInterface(intf); }
/** * Create a DefaultIntroductionAdvisor for the given advice. * @param advice the Advice to apply * @param introductionInfo the IntroductionInfo that describes * the interface to introduce (may be {@code null}) */ public DefaultIntroductionAdvisor(Advice advice, @Nullable IntroductionInfo introductionInfo) { Assert.notNull(advice, "Advice must not be null"); this.advice = advice; if (introductionInfo != null) { Class<?>[] introducedInterfaces = introductionInfo.getInterfaces(); if (introducedInterfaces.length == 0) { throw new IllegalArgumentException("IntroductionAdviceSupport implements no interfaces"); } for (Class<?> ifc : introducedInterfaces) { addInterface(ifc); } } }
public DynamicAsyncInterfaceBean() { ProxyFactory pf = new ProxyFactory(new HashMap<>()); DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(new MethodInterceptor() { @Override public Object invoke(MethodInvocation invocation) throws Throwable { assertTrue(!Thread.currentThread().getName().equals(originalThreadName)); if (Future.class.equals(invocation.getMethod().getReturnType())) { return new AsyncResult<>(invocation.getArguments()[0].toString()); } return null; } }); advisor.addInterface(AsyncInterface.class); pf.addAdvisor(advisor); this.proxy = (AsyncInterface) pf.getProxy(); }
public DynamicAsyncMethodsInterfaceBean() { ProxyFactory pf = new ProxyFactory(new HashMap<>()); DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(new MethodInterceptor() { @Override public Object invoke(MethodInvocation invocation) throws Throwable { assertTrue(!Thread.currentThread().getName().equals(originalThreadName)); if (Future.class.equals(invocation.getMethod().getReturnType())) { return new AsyncResult<>(invocation.getArguments()[0].toString()); } return null; } }); advisor.addInterface(AsyncMethodsInterface.class); pf.addAdvisor(advisor); this.proxy = (AsyncMethodsInterface) pf.getProxy(); }
public DefaultIntroductionAdvisor(DynamicIntroductionAdvice advice, Class clazz) { this.advice = advice; addInterface(clazz); }
/** * Create a DefaultIntroductionAdvisor for the given advice. * @param advice the Advice to apply * @param intf the interface to introduce */ public DefaultIntroductionAdvisor(DynamicIntroductionAdvice advice, Class<?> intf) { Assert.notNull(advice, "Advice must not be null"); this.advice = advice; addInterface(intf); }
/** * Create a DefaultIntroductionAdvisor for the given advice. * @param advice the Advice to apply * @param intf the interface to introduce */ public DefaultIntroductionAdvisor(DynamicIntroductionAdvice advice, Class<?> intf) { Assert.notNull(advice, "Advice must not be null"); this.advice = advice; addInterface(intf); }
private void init(Advice advice, IntroductionInfo introductionInfo) { this.advice = advice; Class[] introducedInterfaces = introductionInfo.getInterfaces(); if (introducedInterfaces.length == 0) { throw new IllegalArgumentException("IntroductionAdviceSupport implements no interfaces"); } for (int i = 0; i < introducedInterfaces.length; i++) { addInterface(introducedInterfaces[i]); } }
/** * Create a DefaultIntroductionAdvisor for the given advice. * @param advice the Advice to apply * @param introductionInfo the IntroductionInfo that describes * the interface to introduce (may be {@code null}) */ public DefaultIntroductionAdvisor(Advice advice, @Nullable IntroductionInfo introductionInfo) { Assert.notNull(advice, "Advice must not be null"); this.advice = advice; if (introductionInfo != null) { Class<?>[] introducedInterfaces = introductionInfo.getInterfaces(); if (introducedInterfaces.length == 0) { throw new IllegalArgumentException("IntroductionAdviceSupport implements no interfaces"); } for (Class<?> ifc : introducedInterfaces) { addInterface(ifc); } } }
/** * Create a DefaultIntroductionAdvisor for the given advice. * @param advice the Advice to apply * @param introductionInfo the IntroductionInfo that describes * the interface to introduce (may be {@code null}) */ public DefaultIntroductionAdvisor(Advice advice, IntroductionInfo introductionInfo) { Assert.notNull(advice, "Advice must not be null"); this.advice = advice; if (introductionInfo != null) { Class<?>[] introducedInterfaces = introductionInfo.getInterfaces(); if (introducedInterfaces.length == 0) { throw new IllegalArgumentException("IntroductionAdviceSupport implements no interfaces"); } for (Class<?> ifc : introducedInterfaces) { addInterface(ifc); } } }