65
65
import org .springframework .core .MethodParameter ;
66
66
import org .springframework .core .Ordered ;
67
67
import org .springframework .core .annotation .AnnotationUtils ;
68
+ import org .springframework .core .annotation .MergedAnnotations ;
68
69
import org .springframework .jndi .support .SimpleJndiBeanFactory ;
69
70
import org .springframework .lang .Nullable ;
70
71
import org .springframework .util .Assert ;
@@ -379,19 +380,20 @@ private InjectionMetadata buildResourceMetadata(final Class<?> clazz) {
379
380
final List <InjectionMetadata .InjectedElement > currElements = new ArrayList <>();
380
381
381
382
ReflectionUtils .doWithLocalFields (targetClass , field -> {
382
- if (webServiceRefClass != null && field .isAnnotationPresent (webServiceRefClass )) {
383
+ MergedAnnotations annotations = MergedAnnotations .from (field );
384
+ if (webServiceRefClass != null && annotations .isDirectlyPresent (webServiceRefClass )) {
383
385
if (Modifier .isStatic (field .getModifiers ())) {
384
386
throw new IllegalStateException ("@WebServiceRef annotation is not supported on static fields" );
385
387
}
386
388
currElements .add (new WebServiceRefElement (field , field , null ));
387
389
}
388
- else if (ejbRefClass != null && field . isAnnotationPresent (ejbRefClass )) {
390
+ else if (ejbRefClass != null && annotations . isDirectlyPresent (ejbRefClass )) {
389
391
if (Modifier .isStatic (field .getModifiers ())) {
390
392
throw new IllegalStateException ("@EJB annotation is not supported on static fields" );
391
393
}
392
394
currElements .add (new EjbRefElement (field , field , null ));
393
395
}
394
- else if (field . isAnnotationPresent (Resource .class )) {
396
+ else if (annotations . isDirectlyPresent (Resource .class )) {
395
397
if (Modifier .isStatic (field .getModifiers ())) {
396
398
throw new IllegalStateException ("@Resource annotation is not supported on static fields" );
397
399
}
@@ -407,7 +409,8 @@ else if (field.isAnnotationPresent(Resource.class)) {
407
409
return ;
408
410
}
409
411
if (method .equals (ClassUtils .getMostSpecificMethod (method , clazz ))) {
410
- if (webServiceRefClass != null && bridgedMethod .isAnnotationPresent (webServiceRefClass )) {
412
+ MergedAnnotations annotations = MergedAnnotations .from (bridgedMethod );
413
+ if (webServiceRefClass != null && annotations .isDirectlyPresent (webServiceRefClass )) {
411
414
if (Modifier .isStatic (method .getModifiers ())) {
412
415
throw new IllegalStateException ("@WebServiceRef annotation is not supported on static methods" );
413
416
}
@@ -417,7 +420,7 @@ else if (field.isAnnotationPresent(Resource.class)) {
417
420
PropertyDescriptor pd = BeanUtils .findPropertyForMethod (bridgedMethod , clazz );
418
421
currElements .add (new WebServiceRefElement (method , bridgedMethod , pd ));
419
422
}
420
- else if (ejbRefClass != null && bridgedMethod . isAnnotationPresent (ejbRefClass )) {
423
+ else if (ejbRefClass != null && annotations . isDirectlyPresent (ejbRefClass )) {
421
424
if (Modifier .isStatic (method .getModifiers ())) {
422
425
throw new IllegalStateException ("@EJB annotation is not supported on static methods" );
423
426
}
@@ -427,7 +430,7 @@ else if (ejbRefClass != null && bridgedMethod.isAnnotationPresent(ejbRefClass))
427
430
PropertyDescriptor pd = BeanUtils .findPropertyForMethod (bridgedMethod , clazz );
428
431
currElements .add (new EjbRefElement (method , bridgedMethod , pd ));
429
432
}
430
- else if (bridgedMethod . isAnnotationPresent (Resource .class )) {
433
+ else if (annotations . isDirectlyPresent (Resource .class )) {
431
434
if (Modifier .isStatic (method .getModifiers ())) {
432
435
throw new IllegalStateException ("@Resource annotation is not supported on static methods" );
433
436
}
0 commit comments