@ConditionalOnMissingBean(name = {DruidStatProperties.DRUID_STAT_INTERCEPTOR_NAME}) @Bean(DruidStatProperties.DRUID_STAT_INTERCEPTOR_NAME) public Interceptor druidStatInterceptor() { return new DruidStatInterceptor(); }
protected <T extends Executable, I extends Interceptor, F> List<I> getInterceptors( T interceptee, IterableProvider<? extends F> factoryProviders, Class<F> interceptorType, InterceptorFactory<F, T, Annotation, I> interceptorProvider ) { List<I> interceptors = Lists.newArrayList(); factoryProviders.handleIterator().forEach(handle -> { // Make sure descriptor is fully reified ActiveDescriptor<?> descriptor = handle.getActiveDescriptor(); if (!descriptor.isReified()) { descriptor = locator.reifyDescriptor(descriptor); } // Check the type of annotation supported by the factory for (Type contract : descriptor.getContractTypes()) { if (ReflectionHelper.getRawClass(contract) == interceptorType) { Class<? extends Annotation> annotationClass = (Class<? extends Annotation>) ReflectionHelper.getRawClass( ReflectionHelper.getFirstTypeArgument(contract)); // Might be Object.class if getRawClass found an unbound type variable or wildcard if (!Annotation.class.isAssignableFrom(annotationClass)) { log.warn("Unable to determine annotation binder from contract type {}", annotationClass); return; } Annotation ann = interceptee.getAnnotation(annotationClass); if (ann == null) { ann = interceptee.getDeclaringClass().getAnnotation(annotationClass); } if (ann != null) { // Create the factory and produce an interceptor F factory = handle.getService(); I interceptor = interceptorProvider.apply(factory, interceptee, ann); if (interceptor != null) { interceptors.add(interceptor); } } return; } } }); return interceptors; }
public Interceptor getInterceptor(int i) { return null; }
/** * Create a new ProxyFactory for the given interface and interceptor. * <p>Convenience method for creating a proxy for a single interceptor, * assuming that the interceptor handles all calls itself rather than * delegating to a target, like in the case of remoting proxies. * @param proxyInterface the interface that the proxy should implement * @param interceptor the interceptor that the proxy should invoke */ public ProxyFactory(Class<?> proxyInterface, Interceptor interceptor) { addInterface(proxyInterface); addAdvice(interceptor); }
/** * Create a new proxy for the given interface and interceptor. * <p>Convenience method for creating a proxy for a single interceptor, * assuming that the interceptor handles all calls itself rather than * delegating to a target, like in the case of remoting proxies. * @param proxyInterface the interface that the proxy should implement * @param interceptor the interceptor that the proxy should invoke * @return the proxy object * @see #ProxyFactory(Class, org.aopalliance.intercept.Interceptor) */ @SuppressWarnings("unchecked") public static <T> T getProxy(Class<T> proxyInterface, Interceptor interceptor) { return (T) new ProxyFactory(proxyInterface, interceptor).getProxy(); }