diff --git a/spring-context-support/src/main/java/org/springframework/ui/velocity/CommonsLoggingLogSystem.java b/spring-context-support/src/main/java/org/springframework/ui/velocity/CommonsLoggingLogSystem.java index 5c49db1efe..b845d6c6ae 100644 --- a/spring-context-support/src/main/java/org/springframework/ui/velocity/CommonsLoggingLogSystem.java +++ b/spring-context-support/src/main/java/org/springframework/ui/velocity/CommonsLoggingLogSystem.java @@ -1,12 +1,12 @@ /* - * Copyright 2002-2005 the original author or authors. - * + * Copyright 2002-2012 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,10 +26,16 @@ import org.apache.velocity.runtime.log.LogSystem; * Velocity LogSystem implementation for Jakarta Commons Logging. * Used by VelocityConfigurer to redirect log output. * + *
NOTE: To be replaced by Velocity 1.5's When using this method to prepare a text for a mail to be sent with Spring's
* mail support, consider wrapping VelocityException in MailPreparationException.
* @param velocityEngine VelocityEngine to work with
- * @param templateLocation the location of template, relative to Velocity's
- * resource loader path
- * @param model the Map that contains model names as keys and model objects
- * as values
+ * @param templateLocation the location of template, relative to Velocity's resource loader path
+ * @param model the Map that contains model names as keys and model objects as values
* @return the result as String
* @throws VelocityException if the template wasn't found or rendering failed
* @see org.springframework.mail.MailPreparationException
+ * @deprecated Use {@link #mergeTemplateIntoString(VelocityEngine, String, String, Map)}
+ * instead, following Velocity 1.6's corresponding deprecation in its own API.
*/
- public static String mergeTemplateIntoString(
- VelocityEngine velocityEngine, String templateLocation, Map model)
- throws VelocityException {
+ @Deprecated
+ public static String mergeTemplateIntoString(VelocityEngine velocityEngine, String templateLocation,
+ Map When using this method to prepare a text for a mail to be sent with Spring's
* mail support, consider wrapping VelocityException in MailPreparationException.
* @param velocityEngine VelocityEngine to work with
- * @param templateLocation the location of template, relative to Velocity's
- * resource loader path
+ * @param templateLocation the location of template, relative to Velocity's resource loader path
* @param encoding the encoding of the template file
- * @param model the Map that contains model names as keys and model objects
- * as values
+ * @param model the Map that contains model names as keys and model objects as values
* @return the result as String
* @throws VelocityException if the template wasn't found or rendering failed
* @see org.springframework.mail.MailPreparationException
*/
- public static String mergeTemplateIntoString(
- VelocityEngine velocityEngine, String templateLocation, String encoding, Map model)
- throws VelocityException {
+ public static String mergeTemplateIntoString(VelocityEngine velocityEngine, String templateLocation,
+ String encoding, MapLogChute mechanism
+ * and Velocity 1.6's CommonsLogLogChute implementation once we
+ * upgrade to Velocity 1.6+ (likely Velocity 1.7+) in a future version of Spring.
+ *
* @author Juergen Hoeller
* @since 07.08.2003
* @see VelocityEngineFactoryBean
+ * @deprecated as of Spring 3.2, in favor of Velocity 1.6's CommonsLogLogChute
*/
+@Deprecated
public class CommonsLoggingLogSystem implements LogSystem {
private static final Log logger = LogFactory.getLog(VelocityEngine.class);
diff --git a/spring-context-support/src/main/java/org/springframework/ui/velocity/SpringResourceLoader.java b/spring-context-support/src/main/java/org/springframework/ui/velocity/SpringResourceLoader.java
index 33e74440b4..e93ed15530 100644
--- a/spring-context-support/src/main/java/org/springframework/ui/velocity/SpringResourceLoader.java
+++ b/spring-context-support/src/main/java/org/springframework/ui/velocity/SpringResourceLoader.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2006 the original author or authors.
+ * Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -99,9 +99,9 @@ public class SpringResourceLoader extends ResourceLoader {
if (logger.isDebugEnabled()) {
logger.debug("Looking for Velocity resource with name [" + source + "]");
}
- for (int i = 0; i < this.resourceLoaderPaths.length; i++) {
+ for (String resourceLoaderPath : this.resourceLoaderPaths) {
org.springframework.core.io.Resource resource =
- this.resourceLoader.getResource(this.resourceLoaderPaths[i] + source);
+ this.resourceLoader.getResource(resourceLoaderPath + source);
try {
return resource.getInputStream();
}
diff --git a/spring-context-support/src/main/java/org/springframework/ui/velocity/VelocityEngineUtils.java b/spring-context-support/src/main/java/org/springframework/ui/velocity/VelocityEngineUtils.java
index c888482fd4..edee342be2 100644
--- a/spring-context-support/src/main/java/org/springframework/ui/velocity/VelocityEngineUtils.java
+++ b/spring-context-support/src/main/java/org/springframework/ui/velocity/VelocityEngineUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2006 the original author or authors.
+ * Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,15 +42,16 @@ public abstract class VelocityEngineUtils {
* Merge the specified Velocity template with the given model and write
* the result to the given Writer.
* @param velocityEngine VelocityEngine to work with
- * @param templateLocation the location of template, relative to Velocity's
- * resource loader path
- * @param model the Map that contains model names as keys and model objects
- * as values
+ * @param templateLocation the location of template, relative to Velocity's resource loader path
+ * @param model the Map that contains model names as keys and model objects as values
* @param writer the Writer to write the result to
* @throws VelocityException if the template wasn't found or rendering failed
+ * @deprecated Use {@link #mergeTemplate(VelocityEngine, String, String, Map, Writer)}
+ * instead, following Velocity 1.6's corresponding deprecation in its own API.
*/
+ @Deprecated
public static void mergeTemplate(
- VelocityEngine velocityEngine, String templateLocation, Map model, Writer writer)
+ VelocityEngine velocityEngine, String templateLocation, Map