本文整理汇总了Java中javax.interceptor.Interceptors.value方法的典型用法代码示例。如果您正苦于以下问题:Java Interceptors.value方法的具体用法?Java Interceptors.value怎么用?Java Interceptors.value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.interceptor.Interceptors
的用法示例。
在下文中一共展示了Interceptors.value方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasInterceptor
import javax.interceptor.Interceptors; //导入方法依赖的package包/类
private static boolean hasInterceptor(Class<?> clazz,
Class<?> interceptorClass) {
Interceptors annotation = clazz.getAnnotation(Interceptors.class);
if (annotation != null) {
for (Class<?> currentInterceptorClazz : annotation.value()) {
if (interceptorClass.equals(currentInterceptorClazz)) {
return true;
}
}
}
return false;
}
示例2: containsInterceptor
import javax.interceptor.Interceptors; //导入方法依赖的package包/类
public static Matcher<Class<?>> containsInterceptor(final Class<?> beanClass) {
return new BaseMatcher<Class<?>>() {
private Class<?> testClass;
@Override
public boolean matches(Object object) {
testClass = (Class<?>) object;
Interceptors interceptors = testClass
.getAnnotation(Interceptors.class);
boolean interceptorSet = false;
if (interceptors != null) {
for (Class<?> definedInterceptorClass : interceptors
.value()) {
if (definedInterceptorClass == beanClass) {
interceptorSet = true;
}
}
}
assertTrue(interceptorSet);
return true;
}
@Override
public void describeTo(Description description) {
description.appendText("Class " + testClass.getName()
+ " has no interceptor " + beanClass.getName());
}
};
}
示例3: cacheInterceptors
import javax.interceptor.Interceptors; //导入方法依赖的package包/类
/**
* Caches {@link Interceptor}, bean {@link Class} and {@link Method}s
* parameters
*
* @param interceptors
* @param beanClass
* @param beanMethods
* @throws IOException
*/
private void cacheInterceptors(Interceptors interceptors, Class<?> beanClass, Method... beanMethods)
throws IOException {
Class<?>[] interceptorClasses = interceptors.value();
if (CollectionUtils.valid(interceptorClasses)) {
Method beanMethod = CollectionUtils.getFirst(beanMethods);
cacheInterceptors(beanClass, interceptorClasses, beanMethod);
}
}