[spring-extensions] branch master updated: Overlooked need for InitializingBean interface/method.

Scott Cantor cantor.2 at osu.edu
Tue Nov 6 14:08:21 EST 2018


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=f9997b87700f26a39b737fc6dfa0fb8370ef366a

The following commit(s) were added to refs/heads/master by this push:
       new  f9997b8   Overlooked need for InitializingBean interface/method.
f9997b8 is described below

commit f9997b87700f26a39b737fc6dfa0fb8370ef366a
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Nov 6 14:08:19 2018 -0500

    Overlooked need for InitializingBean interface/method.
---
 .../ext/spring/velocity/VelocityConfigurer.java    | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/main/java/net/shibboleth/ext/spring/velocity/VelocityConfigurer.java b/src/main/java/net/shibboleth/ext/spring/velocity/VelocityConfigurer.java
index a0a6b02..4ce0469 100644
--- a/src/main/java/net/shibboleth/ext/spring/velocity/VelocityConfigurer.java
+++ b/src/main/java/net/shibboleth/ext/spring/velocity/VelocityConfigurer.java
@@ -17,13 +17,16 @@
 
 package net.shibboleth.ext.spring.velocity;
 
+import java.io.IOException;
+
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import javax.servlet.ServletContext;
 
 import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
-
+import org.springframework.beans.factory.InitializingBean;
 import org.springframework.context.ResourceLoaderAware;
 import org.springframework.web.context.ServletContextAware;
 
@@ -67,7 +70,7 @@ import org.springframework.web.context.ServletContextAware;
  * @since 6.0.0
  */
 public class VelocityConfigurer extends VelocityEngineFactory
-        implements VelocityConfig, ResourceLoaderAware, ServletContextAware {
+        implements VelocityConfig, InitializingBean, ResourceLoaderAware, ServletContextAware {
 
     /** Name of the resource loader for Spring's bind macros. */
     private static final String SPRING_MACRO_RESOURCE_LOADER_NAME = "springMacro";
@@ -88,7 +91,20 @@ public class VelocityConfigurer extends VelocityEngineFactory
     public void setServletContext(final ServletContext context) {
         servletContext = context;
     }
-
+    
+    /**
+     * Initialize VelocityEngineFactory's VelocityEngine
+     * if not overridden by a pre-configured VelocityEngine.
+     * @see #createVelocityEngine
+     * @see #setVelocityEngine
+     */
+    @Override
+    public void afterPropertiesSet() throws IOException, VelocityException {
+        if (this.velocityEngine == null) {
+            this.velocityEngine = createVelocityEngine();
+        }
+    }
+    
     /**
      * Provides a ClasspathResourceLoader in addition to any default or user-defined
      * loader in order to load the spring Velocity macros from the class path.

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


More information about the commits mailing list