All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zodiac.template.velocity.spring.view.servlet.ServletVelocityConfigurer Maven / Gradle / Ivy

package org.zodiac.template.velocity.spring.view.servlet;

import javax.servlet.ServletContext;

import org.apache.velocity.app.VelocityEngine;
import org.springframework.web.context.ServletContextAware;
import org.zodiac.template.velocity.spring.view.VelocityConfigurer;

public class ServletVelocityConfigurer extends VelocityConfigurer implements ServletContextAware {

    private ServletContext servletContext;

    @Override
    public void setServletContext(ServletContext servletContext) {
        this.servletContext = servletContext;
    }

    /**
     * Provides a ClasspathResourceLoader in addition to any default or user-defined loader in order to load the spring
     * Velocity macros from the class path.
     * 
     * @see org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
     */
    @Override
    protected void postProcessVelocityEngine(VelocityEngine velocityEngine) {
        super.postProcessVelocityEngine(velocityEngine);
        velocityEngine.setApplicationAttribute(ServletContext.class.getName(), this.servletContext);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy