diff --git a/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java b/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java index f621ea24be..66f2506f5d 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -140,6 +140,9 @@ import org.springframework.util.StringUtils; public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBeanPostProcessor implements InstantiationAwareBeanPostProcessor, BeanFactoryAware, Serializable { + // Common Annotations 1.1 Resource.lookup() available? Not present on JDK 6... + private static final Method lookupAttribute = ClassUtils.getMethodIfAvailable(Resource.class, "lookup"); + private static Class webServiceRefClass = null; private static Class ejbRefClass = null; @@ -604,7 +607,9 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean } this.name = resourceName; this.lookupType = resourceType; - this.mappedName = resource.mappedName(); + String lookupValue = (lookupAttribute != null ? + (String) ReflectionUtils.invokeMethod(lookupAttribute, resource) : null); + this.mappedName = (StringUtils.hasLength(lookupValue) ? lookupValue : resource.mappedName()); Lazy lazy = ae.getAnnotation(Lazy.class); this.lazyLookup = (lazy != null && lazy.value()); }