@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -23,7 +23,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* {@link DatabasePopulator} implementation that delegates to a list of other
|
||||
* Composite {@link DatabasePopulator} that delegates to a list of given
|
||||
* {@code DatabasePopulator} implementations, executing all scripts.
|
||||
*
|
||||
* @author Dave Syer
|
||||
@@ -33,11 +33,11 @@ import java.util.List;
|
||||
*/
|
||||
public class CompositeDatabasePopulator implements DatabasePopulator {
|
||||
|
||||
private List<DatabasePopulator> populators = new ArrayList<DatabasePopulator>();
|
||||
private final List<DatabasePopulator> populators = new ArrayList<DatabasePopulator>(4);
|
||||
|
||||
|
||||
/**
|
||||
* Specify a list of populators to delegate to.
|
||||
* Specify one or more populators to delegate to.
|
||||
*/
|
||||
public void setPopulators(DatabasePopulator... populators) {
|
||||
this.populators.clear();
|
||||
@@ -51,9 +51,7 @@ public class CompositeDatabasePopulator implements DatabasePopulator {
|
||||
this.populators.addAll(Arrays.asList(populators));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void populate(Connection connection) throws SQLException, ScriptException {
|
||||
for (DatabasePopulator populator : this.populators) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -43,11 +43,9 @@ import org.springframework.web.context.request.NativeWebRequest;
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.2
|
||||
*/
|
||||
public abstract class AbstractMappingContentNegotiationStrategy
|
||||
extends MappingMediaTypeFileExtensionResolver
|
||||
public abstract class AbstractMappingContentNegotiationStrategy extends MappingMediaTypeFileExtensionResolver
|
||||
implements ContentNegotiationStrategy {
|
||||
|
||||
|
||||
/**
|
||||
* Create an instance with the given map of file extensions and media types.
|
||||
*/
|
||||
@@ -86,6 +84,7 @@ public abstract class AbstractMappingContentNegotiationStrategy
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a key from the request to use to look up media types.
|
||||
* @return the lookup key or {@code null}.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -41,18 +41,14 @@ import org.springframework.web.context.request.NativeWebRequest;
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.2
|
||||
*/
|
||||
public class ContentNegotiationManager implements ContentNegotiationStrategy,
|
||||
MediaTypeFileExtensionResolver {
|
||||
public class ContentNegotiationManager implements ContentNegotiationStrategy, MediaTypeFileExtensionResolver {
|
||||
|
||||
private static final List<MediaType> MEDIA_TYPE_ALL =
|
||||
Collections.<MediaType>singletonList(MediaType.ALL);
|
||||
private static final List<MediaType> MEDIA_TYPE_ALL = Collections.<MediaType>singletonList(MediaType.ALL);
|
||||
|
||||
|
||||
private final List<ContentNegotiationStrategy> strategies =
|
||||
new ArrayList<ContentNegotiationStrategy>();
|
||||
private final List<ContentNegotiationStrategy> strategies = new ArrayList<ContentNegotiationStrategy>();
|
||||
|
||||
private final Set<MediaTypeFileExtensionResolver> resolvers =
|
||||
new LinkedHashSet<MediaTypeFileExtensionResolver>();
|
||||
private final Set<MediaTypeFileExtensionResolver> resolvers = new LinkedHashSet<MediaTypeFileExtensionResolver>();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -40,34 +40,34 @@ import org.springframework.web.context.ServletContextAware;
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <th>Property Setter</th>
|
||||
* <th>Underlying Strategy</th>
|
||||
* <th>Default Setting</th>
|
||||
* <th>Property Setter</th>
|
||||
* <th>Underlying Strategy</th>
|
||||
* <th>Default Setting</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link #setFavorPathExtension}</td>
|
||||
* <td>{@link PathExtensionContentNegotiationStrategy Path Extension strategy}</td>
|
||||
* <td>On</td>
|
||||
* <td>{@link #setFavorPathExtension}</td>
|
||||
* <td>{@link PathExtensionContentNegotiationStrategy Path Extension strategy}</td>
|
||||
* <td>On</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link #setFavorParameter favorParameter}</td>
|
||||
* <td>{@link ParameterContentNegotiationStrategy Parameter strategy}</td>
|
||||
* <td>Off</td>
|
||||
* <td>{@link #setFavorParameter favorParameter}</td>
|
||||
* <td>{@link ParameterContentNegotiationStrategy Parameter strategy}</td>
|
||||
* <td>Off</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link #setIgnoreAcceptHeader ignoreAcceptHeader}</td>
|
||||
* <td>{@link HeaderContentNegotiationStrategy Header strategy}</td>
|
||||
* <td>On</td>
|
||||
* <td>{@link #setIgnoreAcceptHeader ignoreAcceptHeader}</td>
|
||||
* <td>{@link HeaderContentNegotiationStrategy Header strategy}</td>
|
||||
* <td>On</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link #setDefaultContentType defaultContentType}</td>
|
||||
* <td>{@link FixedContentNegotiationStrategy Fixed content strategy}</td>
|
||||
* <td>Not set</td>
|
||||
* <td>{@link #setDefaultContentType defaultContentType}</td>
|
||||
* <td>{@link FixedContentNegotiationStrategy Fixed content strategy}</td>
|
||||
* <td>Not set</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link #setDefaultContentTypeStrategy defaultContentTypeStrategy}</td>
|
||||
* <td>{@link ContentNegotiationStrategy}</td>
|
||||
* <td>Not set</td>
|
||||
* <td>{@link #setDefaultContentTypeStrategy defaultContentTypeStrategy}</td>
|
||||
* <td>{@link ContentNegotiationStrategy}</td>
|
||||
* <td>Not set</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -33,10 +33,8 @@ public interface ContentNegotiationStrategy {
|
||||
/**
|
||||
* Resolve the given request to a list of media types. The returned list is
|
||||
* ordered by specificity first and by quality parameter second.
|
||||
*
|
||||
* @param webRequest the current request
|
||||
* @return the requested media types or an empty list, never {@code null}
|
||||
*
|
||||
* @return the requested media types or an empty list (never {@code null})
|
||||
* @throws HttpMediaTypeNotAcceptableException if the requested media
|
||||
* types cannot be parsed
|
||||
*/
|
||||
|
||||
@@ -33,8 +33,7 @@ import org.springframework.web.context.request.NativeWebRequest;
|
||||
*/
|
||||
public class FixedContentNegotiationStrategy implements ContentNegotiationStrategy {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(
|
||||
FixedContentNegotiationStrategy.class);
|
||||
private static final Log logger = LogFactory.getLog(FixedContentNegotiationStrategy.class);
|
||||
|
||||
private final List<MediaType> contentType;
|
||||
|
||||
@@ -50,7 +49,7 @@ public class FixedContentNegotiationStrategy implements ContentNegotiationStrate
|
||||
@Override
|
||||
public List<MediaType> resolveMediaTypes(NativeWebRequest request) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Requested media types is " + this.contentType + ".");
|
||||
logger.debug("Requested media types: " + this.contentType);
|
||||
}
|
||||
return this.contentType;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -34,11 +34,9 @@ import org.springframework.web.context.request.NativeWebRequest;
|
||||
*/
|
||||
public class HeaderContentNegotiationStrategy implements ContentNegotiationStrategy {
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @throws HttpMediaTypeNotAcceptableException if the 'Accept' header
|
||||
* cannot be parsed.
|
||||
* @throws HttpMediaTypeNotAcceptableException if the 'Accept' header cannot be parsed
|
||||
*/
|
||||
@Override
|
||||
public List<MediaType> resolveMediaTypes(NativeWebRequest request)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -35,7 +35,7 @@ import org.springframework.util.MultiValueMap;
|
||||
* lookups between file extensions and MediaTypes in both directions.
|
||||
*
|
||||
* <p>Initially created with a map of file extensions and media types.
|
||||
* Subsequently sub-classes can use {@link #addMapping} to add more mappings.
|
||||
* Subsequently subclasses can use {@link #addMapping} to add more mappings.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.2
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -31,15 +31,14 @@ public interface MediaTypeFileExtensionResolver {
|
||||
|
||||
/**
|
||||
* Resolve the given media type to a list of path extensions.
|
||||
*
|
||||
* @param mediaType the media type to resolve
|
||||
* @return a list of extensions or an empty list, never {@code null}
|
||||
* @return a list of extensions or an empty list (never {@code null})
|
||||
*/
|
||||
List<String> resolveFileExtensions(MediaType mediaType);
|
||||
|
||||
/**
|
||||
* Return all registered file extensions.
|
||||
* @return a list of extensions or an empty list, never {@code null}
|
||||
* @return a list of extensions or an empty list (never {@code null})
|
||||
*/
|
||||
List<String> getAllFileExtensions();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -27,18 +27,15 @@ import org.springframework.web.HttpMediaTypeNotAcceptableException;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
|
||||
/**
|
||||
* A {@code ContentNegotiationStrategy} that resolves a query parameter to a
|
||||
* key to be used to look up a media type. The default parameter name is
|
||||
* {@code format}.
|
||||
*s
|
||||
* A {@code ContentNegotiationStrategy} that resolves a query parameter to a key
|
||||
* to be used to look up a media type. The default parameter name is {@code format}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.2
|
||||
*/
|
||||
public class ParameterContentNegotiationStrategy
|
||||
extends AbstractMappingContentNegotiationStrategy {
|
||||
public class ParameterContentNegotiationStrategy extends AbstractMappingContentNegotiationStrategy {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(
|
||||
ParameterContentNegotiationStrategy.class);
|
||||
private static final Log logger = LogFactory.getLog(ParameterContentNegotiationStrategy.class);
|
||||
|
||||
private String parameterName = "format";
|
||||
|
||||
@@ -56,7 +53,7 @@ public class ParameterContentNegotiationStrategy
|
||||
* <p>By default this is set to {@code "format"}.
|
||||
*/
|
||||
public void setParameterName(String parameterName) {
|
||||
Assert.notNull(parameterName, "parameterName is required");
|
||||
Assert.notNull(parameterName, "'parameterName' is required");
|
||||
this.parameterName = parameterName;
|
||||
}
|
||||
|
||||
@@ -64,6 +61,7 @@ public class ParameterContentNegotiationStrategy
|
||||
return this.parameterName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getMediaTypeKey(NativeWebRequest request) {
|
||||
return request.getParameter(getParameterName());
|
||||
@@ -72,8 +70,8 @@ public class ParameterContentNegotiationStrategy
|
||||
@Override
|
||||
protected void handleMatch(String mediaTypeKey, MediaType mediaType) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Requested media type is '" + mediaType +
|
||||
"' based on '" + getParameterName() + "'='" + mediaTypeKey + "'.");
|
||||
logger.debug("Requested media type: '" + mediaType + "' based on '" +
|
||||
getParameterName() + "'='" + mediaTypeKey + "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -56,8 +56,7 @@ public class PathExtensionContentNegotiationStrategy
|
||||
|
||||
private static final Log logger = LogFactory.getLog(PathExtensionContentNegotiationStrategy.class);
|
||||
|
||||
private static final boolean JAF_PRESENT = ClassUtils.isPresent(
|
||||
"javax.activation.FileTypeMap",
|
||||
private static final boolean JAF_PRESENT = ClassUtils.isPresent("javax.activation.FileTypeMap",
|
||||
PathExtensionContentNegotiationStrategy.class.getClassLoader());
|
||||
|
||||
private static final UrlPathHelper PATH_HELPER = new UrlPathHelper();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.accept;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -31,8 +32,7 @@ import org.springframework.web.context.request.NativeWebRequest;
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 3.2
|
||||
*/
|
||||
public class ServletPathExtensionContentNegotiationStrategy
|
||||
extends PathExtensionContentNegotiationStrategy {
|
||||
public class ServletPathExtensionContentNegotiationStrategy extends PathExtensionContentNegotiationStrategy {
|
||||
|
||||
private final ServletContext servletContext;
|
||||
|
||||
@@ -40,12 +40,12 @@ public class ServletPathExtensionContentNegotiationStrategy
|
||||
/**
|
||||
* Create an instance with the given extension-to-MediaType lookup.
|
||||
*/
|
||||
public ServletPathExtensionContentNegotiationStrategy(ServletContext context,
|
||||
Map<String, MediaType> mediaTypes) {
|
||||
public ServletPathExtensionContentNegotiationStrategy(
|
||||
ServletContext servletContext, Map<String, MediaType> mediaTypes) {
|
||||
|
||||
super(mediaTypes);
|
||||
Assert.notNull(context, "ServletContext is required!");
|
||||
this.servletContext = context;
|
||||
Assert.notNull(servletContext, "ServletContext is required");
|
||||
this.servletContext = servletContext;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -288,7 +288,7 @@ public abstract class WebApplicationContextUtils {
|
||||
public static void initServletPropertySources(
|
||||
MutablePropertySources propertySources, ServletContext servletContext, ServletConfig servletConfig) {
|
||||
|
||||
Assert.notNull(propertySources, "propertySources must not be null");
|
||||
Assert.notNull(propertySources, "'propertySources' must not be null");
|
||||
if (servletContext != null && propertySources.contains(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME) &&
|
||||
propertySources.get(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME) instanceof StubPropertySource) {
|
||||
propertySources.replace(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME,
|
||||
|
||||
@@ -46,7 +46,7 @@ import org.springframework.web.util.WebUtils;
|
||||
*
|
||||
* <p>Prefixes and suffixes for the before and after messages can be configured using the
|
||||
* {@code beforeMessagePrefix}, {@code afterMessagePrefix}, {@code beforeMessageSuffix} and
|
||||
* {@code afterMessageSuffix} properties,
|
||||
* {@code afterMessageSuffix} properties.
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
@@ -124,7 +124,6 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
|
||||
* <p>Should be configured using an {@code <init-param>} for parameter name
|
||||
* "includePayload" in the filter definition in {@code web.xml}.
|
||||
*/
|
||||
|
||||
public void setIncludePayload(boolean includePayload) {
|
||||
this.includePayload = includePayload;
|
||||
}
|
||||
@@ -254,12 +253,14 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append(prefix);
|
||||
msg.append("uri=").append(request.getRequestURI());
|
||||
|
||||
if (isIncludeQueryString()) {
|
||||
String queryString = request.getQueryString();
|
||||
if (queryString != null) {
|
||||
msg.append('?').append(queryString);
|
||||
}
|
||||
}
|
||||
|
||||
if (isIncludeClientInfo()) {
|
||||
String client = request.getRemoteAddr();
|
||||
if (StringUtils.hasLength(client)) {
|
||||
@@ -274,6 +275,7 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
|
||||
msg.append(";user=").append(user);
|
||||
}
|
||||
}
|
||||
|
||||
if (isIncludePayload()) {
|
||||
ContentCachingRequestWrapper wrapper =
|
||||
WebUtils.getNativeRequest(request, ContentCachingRequestWrapper.class);
|
||||
@@ -292,6 +294,7 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
msg.append(suffix);
|
||||
return msg.toString();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -211,7 +211,7 @@ public abstract class PortletApplicationContextUtils {
|
||||
public static void initPortletPropertySources(MutablePropertySources propertySources, ServletContext servletContext,
|
||||
PortletContext portletContext, PortletConfig portletConfig) {
|
||||
|
||||
Assert.notNull(propertySources, "propertySources must not be null");
|
||||
Assert.notNull(propertySources, "'propertySources' must not be null");
|
||||
WebApplicationContextUtils.initServletPropertySources(propertySources, servletContext);
|
||||
|
||||
if (portletContext != null && propertySources.contains(StandardPortletEnvironment.PORTLET_CONTEXT_PROPERTY_SOURCE_NAME)) {
|
||||
|
||||
Reference in New Issue
Block a user