[spring-extensions] 03/03: IDP-1047 turn on use of AnnotationParameterNameDiscoverer

Rod Widdowson rdw at steadingsoftware.com
Tue Oct 4 09:00:16 EDT 2016


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch master
in repository spring-extensions.

View the commit online:
http://git.shibboleth.net/view/?p=spring-extensions.git;a=commit;h=67fced3ad7edd3218411a1d2d248e3778fea1c1a

commit 67fced3ad7edd3218411a1d2d248e3778fea1c1a
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Tue Oct 4 13:55:26 2016 +0100

    IDP-1047 turn on use of AnnotationParameterNameDiscoverer
    
    https://issues.shibboleth.net/jira/browse/IDP-1047
---
 .../FileSystemXmlWebApplicationContext.java        | 13 +++++++----
 .../FilesystemGenericApplicationContext.java       | 26 +++++++++++++---------
 2 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/src/main/java/net/shibboleth/ext/spring/context/FileSystemXmlWebApplicationContext.java b/src/main/java/net/shibboleth/ext/spring/context/FileSystemXmlWebApplicationContext.java
index 0c1c99a..a642b26 100644
--- a/src/main/java/net/shibboleth/ext/spring/context/FileSystemXmlWebApplicationContext.java
+++ b/src/main/java/net/shibboleth/ext/spring/context/FileSystemXmlWebApplicationContext.java
@@ -17,6 +17,9 @@
 
 package net.shibboleth.ext.spring.context;
 
+import net.shibboleth.ext.spring.util.AnnotationParameterNameDiscoverer;
+
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.FileSystemResource;
 import org.springframework.core.io.Resource;
@@ -31,10 +34,6 @@ import org.springframework.web.context.support.XmlWebApplicationContext;
  */
 public class FileSystemXmlWebApplicationContext extends XmlWebApplicationContext {
 
-    /** Constructor. */
-    public FileSystemXmlWebApplicationContext() {
-    }
-
     /**
      * {@inheritDoc}
      * 
@@ -68,4 +67,10 @@ public class FileSystemXmlWebApplicationContext extends XmlWebApplicationContext
         return super.getResource(location);
     }
 
+    /** {@inheritDoc} */
+    @Override protected DefaultListableBeanFactory createBeanFactory() {
+        final DefaultListableBeanFactory result = super.createBeanFactory();
+        result.setParameterNameDiscoverer(new AnnotationParameterNameDiscoverer());
+        return result;
+    }
 }
diff --git a/src/main/java/net/shibboleth/ext/spring/context/FilesystemGenericApplicationContext.java b/src/main/java/net/shibboleth/ext/spring/context/FilesystemGenericApplicationContext.java
index 9619d14..5594dca 100644
--- a/src/main/java/net/shibboleth/ext/spring/context/FilesystemGenericApplicationContext.java
+++ b/src/main/java/net/shibboleth/ext/spring/context/FilesystemGenericApplicationContext.java
@@ -17,6 +17,8 @@
 
 package net.shibboleth.ext.spring.context;
 
+import net.shibboleth.ext.spring.util.AnnotationParameterNameDiscoverer;
+
 import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.GenericApplicationContext;
@@ -24,14 +26,15 @@ import org.springframework.core.io.FileSystemResource;
 import org.springframework.core.io.Resource;
 
 /**
- * An extension of {@link GenericApplicationContext} that is biased in favor of the filesystem
- * such that bare resource paths are assumed to be files rather than classpath resources.
+ * An extension of {@link GenericApplicationContext} that is biased in favor of the filesystem such that bare resource
+ * paths are assumed to be files rather than classpath resources.
  */
 public class FilesystemGenericApplicationContext extends GenericApplicationContext {
 
     /** Constructor. */
     public FilesystemGenericApplicationContext() {
-        
+        super();
+        getDefaultListableBeanFactory().setParameterNameDiscoverer(new AnnotationParameterNameDiscoverer());
     }
 
     /**
@@ -41,6 +44,7 @@ public class FilesystemGenericApplicationContext extends GenericApplicationConte
      */
     public FilesystemGenericApplicationContext(final DefaultListableBeanFactory beanFactory) {
         super(beanFactory);
+        beanFactory.setParameterNameDiscoverer(new AnnotationParameterNameDiscoverer());
     }
 
     /**
@@ -50,6 +54,7 @@ public class FilesystemGenericApplicationContext extends GenericApplicationConte
      */
     public FilesystemGenericApplicationContext(final ApplicationContext parent) {
         super(parent);
+        getDefaultListableBeanFactory().setParameterNameDiscoverer(new AnnotationParameterNameDiscoverer());
     }
 
     /**
@@ -58,25 +63,26 @@ public class FilesystemGenericApplicationContext extends GenericApplicationConte
      * @param beanFactory bean factory
      * @param parent parent context
      */
-    public FilesystemGenericApplicationContext(final DefaultListableBeanFactory beanFactory, 
+    public FilesystemGenericApplicationContext(final DefaultListableBeanFactory beanFactory,
             final ApplicationContext parent) {
         super(beanFactory, parent);
+        beanFactory.setParameterNameDiscoverer(new AnnotationParameterNameDiscoverer());
     }
 
     /**
      * {@inheritDoc}
      * 
-     * <p>Overrides the standard behavior of path-only resources and treats them as file paths if the path
-     * exists. Note that this differs from the ordinary Spring contexts that default to file paths because
-     * paths are treated as absolute if they are in fact absolute.</p>
+     * <p>
+     * Overrides the standard behavior of path-only resources and treats them as file paths if the path exists. Note
+     * that this differs from the ordinary Spring contexts that default to file paths because paths are treated as
+     * absolute if they are in fact absolute.
+     * </p>
      */
-    @Override
-    protected Resource getResourceByPath(final String path) {
+    @Override protected Resource getResourceByPath(final String path) {
         final Resource r = new FileSystemResource(path);
         if (r.exists()) {
             return r;
         }
-        
         return super.getResourceByPath(path);
     }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list