From: Juergen H. <jho...@us...> - 2008-10-14 14:40:35
|
Update of /cvsroot/springframework/spring/src/org/springframework/web/servlet/view/velocity In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10509/src/org/springframework/web/servlet/view/velocity Modified Files: Tag: mbranch-2-0 VelocityConfigurer.java Log Message: VelocityConfigurer exposes ServletContext as VelocityEngine attribute (analogous to the standard VelocityViewServlet) Index: VelocityConfigurer.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/web/servlet/view/velocity/VelocityConfigurer.java,v retrieving revision 1.20.2.1 retrieving revision 1.20.2.2 diff -C2 -d -r1.20.2.1 -r1.20.2.2 *** VelocityConfigurer.java 27 Jun 2007 16:25:09 -0000 1.20.2.1 --- VelocityConfigurer.java 14 Oct 2008 14:40:30 -0000 1.20.2.2 *************** *** 1,4 **** /* ! * Copyright 2002-2007 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); --- 1,4 ---- /* ! * Copyright 2002-2008 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); *************** *** 19,22 **** --- 19,24 ---- import java.io.IOException; + import javax.servlet.ServletContext; + import org.apache.velocity.app.VelocityEngine; import org.apache.velocity.exception.VelocityException; *************** *** 26,29 **** --- 28,32 ---- import org.springframework.context.ResourceLoaderAware; import org.springframework.ui.velocity.VelocityEngineFactory; + import org.springframework.web.context.ServletContextAware; /** *************** *** 70,74 **** */ public class VelocityConfigurer extends VelocityEngineFactory ! implements VelocityConfig, InitializingBean, ResourceLoaderAware { /** the name of the resource loader for Spring's bind macros */ --- 73,77 ---- */ public class VelocityConfigurer extends VelocityEngineFactory ! implements VelocityConfig, InitializingBean, ResourceLoaderAware, ServletContextAware { /** the name of the resource loader for Spring's bind macros */ *************** *** 84,87 **** --- 87,92 ---- private VelocityEngine velocityEngine; + private ServletContext servletContext; + /** *************** *** 100,103 **** --- 105,112 ---- } + public void setServletContext(ServletContext servletContext) { + this.servletContext = servletContext; + } + /** * Initialize VelocityEngineFactory's VelocityEngine *************** *** 118,121 **** --- 127,131 ---- */ protected void postProcessVelocityEngine(VelocityEngine velocityEngine) { + velocityEngine.setApplicationAttribute(ServletContext.class.getName(), this.servletContext); velocityEngine.setProperty( SPRING_MACRO_RESOURCE_LOADER_CLASS, ClasspathResourceLoader.class.getName()); *************** *** 124,127 **** --- 134,138 ---- velocityEngine.addProperty( VelocityEngine.VM_LIBRARY, SPRING_MACRO_LIBRARY); + if (logger.isInfoEnabled()) { logger.info("ClasspathResourceLoader with name '" + SPRING_MACRO_RESOURCE_LOADER_NAME + |