Skip to content

Commit

Permalink
Migrate CommonAnnotationBeanPostProcessor to MergedAnnotations
Browse files Browse the repository at this point in the history
Closes gh-22585
  • Loading branch information
philwebb authored and jhoeller committed Mar 22, 2019
1 parent 50c2577 commit 75b5230
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import org.springframework.core.MethodParameter;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.annotation.MergedAnnotations;
import org.springframework.jndi.support.SimpleJndiBeanFactory;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
Expand Down Expand Up @@ -379,19 +380,20 @@ private InjectionMetadata buildResourceMetadata(final Class<?> clazz) {
final List<InjectionMetadata.InjectedElement> currElements = new ArrayList<>();

ReflectionUtils.doWithLocalFields(targetClass, field -> {
if (webServiceRefClass != null && field.isAnnotationPresent(webServiceRefClass)) {
MergedAnnotations annotations = MergedAnnotations.from(field);
if (webServiceRefClass != null && annotations.isDirectlyPresent(webServiceRefClass)) {
if (Modifier.isStatic(field.getModifiers())) {
throw new IllegalStateException("@WebServiceRef annotation is not supported on static fields");
}
currElements.add(new WebServiceRefElement(field, field, null));
}
else if (ejbRefClass != null && field.isAnnotationPresent(ejbRefClass)) {
else if (ejbRefClass != null && annotations.isDirectlyPresent(ejbRefClass)) {
if (Modifier.isStatic(field.getModifiers())) {
throw new IllegalStateException("@EJB annotation is not supported on static fields");
}
currElements.add(new EjbRefElement(field, field, null));
}
else if (field.isAnnotationPresent(Resource.class)) {
else if (annotations.isDirectlyPresent(Resource.class)) {
if (Modifier.isStatic(field.getModifiers())) {
throw new IllegalStateException("@Resource annotation is not supported on static fields");
}
Expand All @@ -407,7 +409,8 @@ else if (field.isAnnotationPresent(Resource.class)) {
return;
}
if (method.equals(ClassUtils.getMostSpecificMethod(method, clazz))) {
if (webServiceRefClass != null && bridgedMethod.isAnnotationPresent(webServiceRefClass)) {
MergedAnnotations annotations = MergedAnnotations.from(bridgedMethod);
if (webServiceRefClass != null && annotations.isDirectlyPresent(webServiceRefClass)) {
if (Modifier.isStatic(method.getModifiers())) {
throw new IllegalStateException("@WebServiceRef annotation is not supported on static methods");
}
Expand All @@ -417,7 +420,7 @@ else if (field.isAnnotationPresent(Resource.class)) {
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz);
currElements.add(new WebServiceRefElement(method, bridgedMethod, pd));
}
else if (ejbRefClass != null && bridgedMethod.isAnnotationPresent(ejbRefClass)) {
else if (ejbRefClass != null && annotations.isDirectlyPresent(ejbRefClass)) {
if (Modifier.isStatic(method.getModifiers())) {
throw new IllegalStateException("@EJB annotation is not supported on static methods");
}
Expand All @@ -427,7 +430,7 @@ else if (ejbRefClass != null && bridgedMethod.isAnnotationPresent(ejbRefClass))
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, clazz);
currElements.add(new EjbRefElement(method, bridgedMethod, pd));
}
else if (bridgedMethod.isAnnotationPresent(Resource.class)) {
else if (annotations.isDirectlyPresent(Resource.class)) {
if (Modifier.isStatic(method.getModifiers())) {
throw new IllegalStateException("@Resource annotation is not supported on static methods");
}
Expand Down

0 comments on commit 75b5230

Please sign in to comment.