beanEJBAnnotation.setClassInject(new ClassInjectAnnotationWrapper(annotation));
isKeep = true;
}
if (annotation instanceof Interceptors) {
InterceptorsAnnotationWrapper interceptorsAnnotationWrapper = new InterceptorsAnnotationWrapper();
Interceptors interceptorsAnnotation = (Interceptors) annotation;
Class<?>[] interceptorClasses = interceptorsAnnotation.value();
InterceptorsAnnotationEntry[] interceptors = new InterceptorsAnnotationEntry[interceptorClasses.length];
for (int i = 0; i < interceptors.length; i++) {
interceptors[i] = new InterceptorsAnnotationEntry(ObjectUtils.createObject(interceptorClasses[i]),
findInterceptorMethod(interceptorClasses[i]));
}
interceptorsAnnotationWrapper.setInterceptors(interceptors);
if (clazz.isAnnotationPresent(ExcludeDefaultInterceptors.class)) {
// 排除默认拦截
interceptorsAnnotationWrapper.setExcludeDefaultInterceptors(true);
}
beanEJBAnnotation.setClassInterceptors(interceptorsAnnotationWrapper);
}
}
// 字段注解
Field[] fields = ObjectUtils.getAllField(clazz);
for (Field field : fields) {
for (Annotation annotation : field.getAnnotations()) {
if (annotation instanceof Resource) {
beanEJBAnnotation.addFieldInject(field.getName(), new FieldInjectAnnotationWrapper(field, annotation));
break;
}
if (annotation instanceof EJB) {
beanEJBAnnotation.addFieldInject(field.getName(), new FieldInjectAnnotationWrapper(field, annotation));
break;
}
if (annotation.getClass().isAnnotationPresent(ResourceComponent.class)) {
beanEJBAnnotation.addFieldInject(field.getName(), new FieldInjectAnnotationWrapper(field, annotation));
break;
}
if (annotation.getClass().isAnnotationPresent(EJBComponent.class)) {
beanEJBAnnotation.addFieldInject(field.getName(), new FieldInjectAnnotationWrapper(field, annotation));
break;
}
}
}
// 方法注解
Method[] methods = clazz.getMethods();
for (Method method : methods) {
String methodName = method.getName();
isKeep = false;
for (Annotation annotation : method.getAnnotations()) {
if (!isKeep && annotation instanceof Resource) {
beanEJBAnnotation.addMethodInject(methodName, new MethodInjectAnnotationWrapper(method, annotation));
isKeep = true;
}
if (!isKeep && annotation instanceof EJB) {
beanEJBAnnotation.addMethodInject(methodName, new MethodInjectAnnotationWrapper(method, annotation));
isKeep = true;
}
if (!isKeep && annotation.getClass().isAnnotationPresent(ResourceComponent.class)) {
beanEJBAnnotation.addMethodInject(methodName, new MethodInjectAnnotationWrapper(method, annotation));
isKeep = true;
}
if (!isKeep && annotation.getClass().isAnnotationPresent(EJBComponent.class)) {
beanEJBAnnotation.addMethodInject(methodName, new MethodInjectAnnotationWrapper(method, annotation));
isKeep = true;
}
if (annotation instanceof Interceptors) {
InterceptorsAnnotationWrapper interceptorsAnnotationWrapper = new InterceptorsAnnotationWrapper();
Interceptors interceptorsAnnotation = (Interceptors) annotation;
Class<?>[] interceptorClasses = interceptorsAnnotation.value();
InterceptorsAnnotationEntry[] interceptors = new InterceptorsAnnotationEntry[interceptorClasses.length];
for (int i = 0; i < interceptors.length; i++) {
interceptors[i] = new InterceptorsAnnotationEntry(ObjectUtils.createObject(interceptorClasses[i]),
findInterceptorMethod(interceptorClasses[i]));
}