[spring-extensions] branch master updated: JPAR-128 - Upgrade Velocity to 2.0

Scott Cantor cantor.2 at osu.edu
Wed Jan 23 12:16:14 EST 2019


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

scantor 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=f6efb89ebdf724abe96cb1a36e1b6609ac598b40

The following commit(s) were added to refs/heads/master by this push:
       new  f6efb89   JPAR-128 - Upgrade Velocity to 2.0
f6efb89 is described below

commit f6efb89ebdf724abe96cb1a36e1b6609ac598b40
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Jan 23 12:16:12 2019 -0500

    JPAR-128 - Upgrade Velocity to 2.0
    
    https://issues.shibboleth.net/jira/browse/JPAR-128
---
 pom.xml                                            |  2 +-
 .../ext/spring/velocity/SpringResourceLoader.java  | 11 +++++-----
 .../ext/spring/velocity/VelocityEngineFactory.java | 24 ----------------------
 3 files changed, 7 insertions(+), 30 deletions(-)

diff --git a/pom.xml b/pom.xml
index 8337aeb..e67db9e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -108,7 +108,7 @@
         </dependency>
         <dependency>
             <groupId>org.apache.velocity</groupId>
-            <artifactId>velocity</artifactId>
+            <artifactId>velocity-engine-core</artifactId>
             <!-- Required if you're using classes from the velocity package -->
             <optional>true</optional>
         </dependency>
diff --git a/src/main/java/net/shibboleth/ext/spring/velocity/SpringResourceLoader.java b/src/main/java/net/shibboleth/ext/spring/velocity/SpringResourceLoader.java
index d1847d2..8d9cf12 100644
--- a/src/main/java/net/shibboleth/ext/spring/velocity/SpringResourceLoader.java
+++ b/src/main/java/net/shibboleth/ext/spring/velocity/SpringResourceLoader.java
@@ -18,16 +18,17 @@
 package net.shibboleth.ext.spring.velocity;
 
 import java.io.IOException;
-import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
 import java.util.Arrays;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
-import org.apache.commons.collections.ExtendedProperties;
 import org.apache.velocity.exception.ResourceNotFoundException;
 import org.apache.velocity.runtime.resource.Resource;
 import org.apache.velocity.runtime.resource.loader.ResourceLoader;
+import org.apache.velocity.util.ExtProperties;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.util.StringUtils;
@@ -82,7 +83,7 @@ public class SpringResourceLoader extends ResourceLoader {
 
     /** {@inheritDoc} */
     @Override
-    public void init(final ExtendedProperties configuration) {
+    public void init(final ExtProperties configuration) {
         resourceLoader =
                 (org.springframework.core.io.ResourceLoader) rsvc.getApplicationAttribute(SPRING_RESOURCE_LOADER);
         final String resourceLoaderPath = (String) rsvc.getApplicationAttribute(SPRING_RESOURCE_LOADER_PATH);
@@ -109,14 +110,14 @@ public class SpringResourceLoader extends ResourceLoader {
 
     /** {@inheritDoc} */
     @Override
-    public InputStream getResourceStream(final String source)
+    public Reader getResourceReader(final String source, final String encoding)
             throws ResourceNotFoundException {
         log.debug("Looking for Velocity resource with name '{}'", source);
         for (final String resourceLoaderPath : resourceLoaderPaths) {
             final org.springframework.core.io.Resource resource =
                     resourceLoader.getResource(resourceLoaderPath + source);
             try {
-                return resource.getInputStream();
+                return new InputStreamReader(resource.getInputStream(), encoding);
             } catch (final IOException ex) {
                 log.debug("Could not find Velocity resource: {}", resource);
             }
diff --git a/src/main/java/net/shibboleth/ext/spring/velocity/VelocityEngineFactory.java b/src/main/java/net/shibboleth/ext/spring/velocity/VelocityEngineFactory.java
index b850d16..aa5657a 100644
--- a/src/main/java/net/shibboleth/ext/spring/velocity/VelocityEngineFactory.java
+++ b/src/main/java/net/shibboleth/ext/spring/velocity/VelocityEngineFactory.java
@@ -29,7 +29,6 @@ import javax.annotation.Nullable;
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.RuntimeConstants;
-import org.apache.velocity.runtime.log.CommonsLogLogChute;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.core.io.DefaultResourceLoader;
@@ -39,8 +38,6 @@ import org.springframework.core.io.support.PropertiesLoaderUtils;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
-import net.shibboleth.utilities.java.support.velocity.SLF4JLogChute;
-
 /**
  * Factory that configures a VelocityEngine. Can be used standalone,
  * but typically you will either use {@link VelocityEngineFactoryBean}
@@ -96,16 +93,12 @@ public class VelocityEngineFactory {
 
     /** Whether to favor file system lookup first. */
     private boolean preferFileSystemAccess;
-
-    /** Override logging? */
-    private boolean overrideLogging;
     
     /** Constructor. */
     public VelocityEngineFactory() {
         velocityProperties = new HashMap<String, Object>();
         resourceLoader = new DefaultResourceLoader();
         preferFileSystemAccess = true;
-        overrideLogging = true;
     }
 
     /**
@@ -235,18 +228,6 @@ public class VelocityEngineFactory {
     }
 
     /**
-     * Set whether Velocity should log via SLF4J, i.e. whether Velocity's
-     * log system should be set to {@link SLF4JLogChute}.
-     * 
-     * <p>Default is "true".</p>
-     * 
-     * @param flag flag to set
-     */
-    public void setOverrideLogging(final boolean flag) {
-        overrideLogging = flag;
-    }
-
-    /**
      * Prepare the VelocityEngine instance and return it.
      * 
      * @return the VelocityEngine instance
@@ -275,11 +256,6 @@ public class VelocityEngineFactory {
         if (resourceLoaderPath != null) {
             initVelocityResourceLoader(velocityEngine, resourceLoaderPath);
         }
-        
-        // Log via SLF4J?
-        if (overrideLogging) {
-            velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, new SLF4JLogChute());
-        }
 
         // Apply properties to VelocityEngine.
         for (final Map.Entry<String,Object> entry : props.entrySet()) {

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


More information about the commits mailing list