diff --git a/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerTemplateUtils.java b/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerTemplateUtils.java index b2e7a85214..751ee13dc2 100644 --- a/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerTemplateUtils.java +++ b/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerTemplateUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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. @@ -45,6 +45,7 @@ public abstract class FreeMarkerTemplateUtils { */ public static String processTemplateIntoString(Template template, Object model) throws IOException, TemplateException { + StringWriter result = new StringWriter(); template.process(model, result); return result.toString(); diff --git a/spring-context-support/src/main/java/org/springframework/ui/freemarker/SpringTemplateLoader.java b/spring-context-support/src/main/java/org/springframework/ui/freemarker/SpringTemplateLoader.java index 7ed965ddb5..d2509aa87f 100644 --- a/spring-context-support/src/main/java/org/springframework/ui/freemarker/SpringTemplateLoader.java +++ b/spring-context-support/src/main/java/org/springframework/ui/freemarker/SpringTemplateLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2014 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. @@ -28,9 +28,9 @@ import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; /** - * FreeMarker TemplateLoader adapter that loads via a Spring ResourceLoader. - * Used by FreeMarkerConfigurationFactory for any resource loader path that - * cannot be resolved to a java.io.File. + * FreeMarker {@link TemplateLoader} adapter that loads via a Spring {@link ResourceLoader}. + * Used by {@link FreeMarkerConfigurationFactory} for any resource loader path that cannot + * be resolved to a {@link java.io.File}. * * @author Juergen Hoeller * @since 14.03.2004 @@ -63,6 +63,7 @@ public class SpringTemplateLoader implements TemplateLoader { } } + public Object findTemplateSource(String name) throws IOException { if (logger.isDebugEnabled()) { logger.debug("Looking for FreeMarker template with name [" + name + "]"); @@ -84,7 +85,6 @@ public class SpringTemplateLoader implements TemplateLoader { } } - public long getLastModified(Object templateSource) { Resource resource = (Resource) templateSource; try { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/AbstractHandlerMethodAdapter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/AbstractHandlerMethodAdapter.java index 9824b80e0e..342ad958f1 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/AbstractHandlerMethodAdapter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/AbstractHandlerMethodAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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. @@ -36,11 +36,13 @@ public abstract class AbstractHandlerMethodAdapter extends WebContentGenerator i private int order = Ordered.LOWEST_PRECEDENCE; + public AbstractHandlerMethodAdapter() { // no restriction of HTTP methods by default super(false); } + /** * Specify the order value for this HandlerAdapter bean. *
Default value is {@code Integer.MAX_VALUE}, meaning that it's non-ordered. @@ -54,49 +56,47 @@ public abstract class AbstractHandlerMethodAdapter extends WebContentGenerator i return this.order; } + /** - * {@inheritDoc}
This implementation expects the handler to be an {@link HandlerMethod}. - * + * This implementation expects the handler to be an {@link HandlerMethod}. * @param handler the handler instance to check * @return whether or not this adapter can adapt the given handler */ public final boolean supports(Object handler) { - return handler instanceof HandlerMethod && supportsInternal((HandlerMethod) handler); + return (handler instanceof HandlerMethod && supportsInternal((HandlerMethod) handler)); } /** * Given a handler method, return whether or not this adapter can support it. - * * @param handlerMethod the handler method to check * @return whether or not this adapter can adapt the given method */ protected abstract boolean supportsInternal(HandlerMethod handlerMethod); /** - * {@inheritDoc}
This implementation expects the handler to be an {@link HandlerMethod}. + * This implementation expects the handler to be an {@link HandlerMethod}. */ public final ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + return handleInternal(request, response, (HandlerMethod) handler); } /** * Use the given handler method to handle the request. - * * @param request current HTTP request * @param response current HTTP response * @param handlerMethod handler method to use. This object must have previously been passed to the * {@link #supportsInternal(HandlerMethod)} this interface, which must have returned {@code true}. - * @return ModelAndView object with the name of the view and the required model data, or {@code null} if - * the request has been handled directly + * @return ModelAndView object with the name of the view and the required model data, + * or {@code null} if the request has been handled directly * @throws Exception in case of errors */ protected abstract ModelAndView handleInternal(HttpServletRequest request, - HttpServletResponse response, - HandlerMethod handlerMethod) throws Exception; + HttpServletResponse response, HandlerMethod handlerMethod) throws Exception; /** - * {@inheritDoc}
This implementation expects the handler to be an {@link HandlerMethod}.
+ * This implementation expects the handler to be an {@link HandlerMethod}.
*/
public final long getLastModified(HttpServletRequest request, Object handler) {
return getLastModifiedInternal(request, (HandlerMethod) handler);
@@ -104,10 +104,10 @@ public abstract class AbstractHandlerMethodAdapter extends WebContentGenerator i
/**
* Same contract as for {@link javax.servlet.http.HttpServlet#getLastModified(HttpServletRequest)}.
- *
* @param request current HTTP request
* @param handlerMethod handler method to use
* @return the lastModified value for the given handler
*/
protected abstract long getLastModifiedInternal(HttpServletRequest request, HandlerMethod handlerMethod);
+
}
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java
index f77b724f69..38b593bd62 100644
--- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java
@@ -137,9 +137,9 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
private Long asyncRequestTimeout;
- private CallableProcessingInterceptor[] callableInterceptors = new CallableProcessingInterceptor[] {};
+ private CallableProcessingInterceptor[] callableInterceptors = new CallableProcessingInterceptor[0];
- private DeferredResultProcessingInterceptor[] deferredResultInterceptors = new DeferredResultProcessingInterceptor[] {};
+ private DeferredResultProcessingInterceptor[] deferredResultInterceptors = new DeferredResultProcessingInterceptor[0];
private boolean ignoreDefaultModelOnRedirect = false;
@@ -168,21 +168,18 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
new LinkedHashMap A {@link ConfigurableBeanFactory} is expected for resolving
- * expressions in method argument default values.
+ * A {@link ConfigurableBeanFactory} is expected for resolving expressions
+ * in method argument default values.
*/
public void setBeanFactory(BeanFactory beanFactory) {
if (beanFactory instanceof ConfigurableBeanFactory) {
@@ -471,12 +467,13 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
}
/**
- * Return the owning factory of this bean instance, or {@code null}.
+ * Return the owning factory of this bean instance, or {@code null} if none.
*/
protected ConfigurableBeanFactory getBeanFactory() {
return this.beanFactory;
}
+
public void afterPropertiesSet() {
if (this.argumentResolvers == null) {
List