From 7bc3e3b3f843fb50bb0f08a4dc5a0b432be24c8d Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 25 Sep 2013 12:27:17 +0200 Subject: [PATCH] Fixed handling of @Resource's shareable value Issue: SPR-10931 --- .../CommonAnnotationBeanPostProcessor.java | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) 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 3fa88f5328..f75cae4809 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 @@ -473,11 +473,8 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean public LookupElement(Member member, PropertyDescriptor pd) { super(member, pd); - initAnnotation((AnnotatedElement) member); } - protected abstract void initAnnotation(AnnotatedElement ae); - /** * Return the resource name for the lookup. */ @@ -512,14 +509,11 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean */ private class ResourceElement extends LookupElement { - protected boolean shareable = true; + protected final boolean shareable; public ResourceElement(Member member, PropertyDescriptor pd) { super(member, pd); - } - - @Override - protected void initAnnotation(AnnotatedElement ae) { + AnnotatedElement ae = (AnnotatedElement) member; Resource resource = ae.getAnnotation(Resource.class); String resourceName = resource.name(); Class resourceType = resource.type(); @@ -559,16 +553,13 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean */ private class WebServiceRefElement extends LookupElement { - private Class elementType; + private final Class elementType; - private String wsdlLocation; + private final String wsdlLocation; public WebServiceRefElement(Member member, PropertyDescriptor pd) { super(member, pd); - } - - @Override - protected void initAnnotation(AnnotatedElement ae) { + AnnotatedElement ae = (AnnotatedElement) member; WebServiceRef resource = ae.getAnnotation(WebServiceRef.class); String resourceName = resource.name(); Class resourceType = resource.type(); @@ -648,14 +639,11 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean */ private class EjbRefElement extends LookupElement { - private String beanName; + private final String beanName; public EjbRefElement(Member member, PropertyDescriptor pd) { super(member, pd); - } - - @Override - protected void initAnnotation(AnnotatedElement ae) { + AnnotatedElement ae = (AnnotatedElement) member; EJB resource = ae.getAnnotation(EJB.class); String resourceBeanName = resource.beanName(); String resourceName = resource.name();