|
|
@ -8,6 +8,7 @@ import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.beans.BeansException;
|
|
|
|
import org.springframework.beans.BeansException;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
import org.springframework.context.ApplicationContextAware;
|
|
|
|
import org.springframework.context.ApplicationContextAware;
|
|
|
|
import org.springframework.core.annotation.AnnotationUtils;
|
|
|
|
import org.springframework.core.annotation.AnnotationUtils;
|
|
|
@ -76,15 +77,25 @@ public class GlueFactory implements ApplicationContextAware {
|
|
|
|
// with bean-id, bean could be found by both @Resource and @Autowired, or bean could only be found by @Autowired
|
|
|
|
// with bean-id, bean could be found by both @Resource and @Autowired, or bean could only be found by @Autowired
|
|
|
|
if (AnnotationUtils.getAnnotation(field, Resource.class) != null) {
|
|
|
|
if (AnnotationUtils.getAnnotation(field, Resource.class) != null) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
Resource resource = AnnotationUtils.getAnnotation(field, Resource.class);
|
|
|
|
|
|
|
|
if (resource.name()!=null && resource.name().length()>0){
|
|
|
|
|
|
|
|
fieldBean = applicationContext.getBean(resource.name());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
fieldBean = applicationContext.getBean(field.getName());
|
|
|
|
fieldBean = applicationContext.getBean(field.getName());
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fieldBean==null ) {
|
|
|
|
if (fieldBean==null ) {
|
|
|
|
fieldBean = applicationContext.getBean(field.getType());
|
|
|
|
fieldBean = applicationContext.getBean(field.getType());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (AnnotationUtils.getAnnotation(field, Autowired.class) != null) {
|
|
|
|
} else if (AnnotationUtils.getAnnotation(field, Autowired.class) != null) {
|
|
|
|
|
|
|
|
Qualifier qualifier = AnnotationUtils.getAnnotation(field, Qualifier.class);
|
|
|
|
|
|
|
|
if (qualifier!=null && qualifier.value()!=null && qualifier.value().length()>0) {
|
|
|
|
|
|
|
|
fieldBean = applicationContext.getBean(qualifier.value());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
fieldBean = applicationContext.getBean(field.getType());
|
|
|
|
fieldBean = applicationContext.getBean(field.getType());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (fieldBean!=null) {
|
|
|
|
if (fieldBean!=null) {
|
|
|
|
field.setAccessible(true);
|
|
|
|
field.setAccessible(true);
|
|
|
|