AbstractModule.java 文件源码

java
阅读 31 收藏 0 点赞 0 评论 0

项目:dwr 作者:
/**
 * Variant of {@link #bindInterceptor(Class, Class...) bindInterceptor} that
 * allows constructor-injection of interceptors described by class, each
 * wrapped by a method interceptor wrapper.
 * @param classMatcher matches classes the interception should apply to.
 *   For example: {@code only(Runnable.class)}.
 * @param methodMatcher matches methods the interception should apply to.
 *   For example: {@code annotatedWith(Transactional.class)}.
 * @param methodInterceptorWrapper a wrapper applied to each of the specified interceptors.
 * @param methodInterceptorClasses chain of
 *   {@link org.aopalliance.intercept.MethodInterceptor MethodInterceptor}s
 *   used to intercept calls, specified by class.
 */
public void bindInterceptor(Matcher<? super Class<?>> classMatcher,
                            Matcher<? super Method> methodMatcher,
                            MethodInterceptorWrapper methodInterceptorWrapper,
                            Class<?>... methodInterceptorClasses)
{
    if (methodInterceptorClasses != null)
    {
        MethodInterceptor[] interceptors = new MethodInterceptor[methodInterceptorClasses.length];
        int i = 0;
        for (Class<?> cls : methodInterceptorClasses)
        {
            if (!MethodInterceptor.class.isAssignableFrom(cls))
            {
                addError("bindInterceptor: %s does not implement MethodInterceptor", cls.getName());
            }
            else
            {
                @SuppressWarnings("unchecked")
                Class<? extends MethodInterceptor> c = (Class<? extends MethodInterceptor>) cls;
                interceptors[i++] = wrap(methodInterceptorWrapper, c);
            }
        }
        bindInterceptor(classMatcher, methodMatcher, interceptors);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号