Polishing
This commit is contained in:
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -49,11 +49,12 @@ public class BeanInstantiationException extends FatalBeanException {
|
|||||||
this.beanClass = beanClass;
|
this.beanClass = beanClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the offending bean class.
|
* Return the offending bean class.
|
||||||
*/
|
*/
|
||||||
public Class<?> getBeanClass() {
|
public Class<?> getBeanClass() {
|
||||||
return beanClass;
|
return this.beanClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -399,8 +399,7 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
|
|||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kick off bean registration automatically when deployed in an
|
* Kick off bean registration automatically when deployed in an {@code ApplicationContext}.
|
||||||
* {@code ApplicationContext}.
|
|
||||||
* @see #registerBeans()
|
* @see #registerBeans()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class MimeType implements Comparable<MimeType>, Serializable {
|
|||||||
static {
|
static {
|
||||||
// variable names refer to RFC 2616, section 2.2
|
// variable names refer to RFC 2616, section 2.2
|
||||||
BitSet ctl = new BitSet(128);
|
BitSet ctl = new BitSet(128);
|
||||||
for (int i=0; i <= 31; i++) {
|
for (int i = 0; i <= 31; i++) {
|
||||||
ctl.set(i);
|
ctl.set(i);
|
||||||
}
|
}
|
||||||
ctl.set(127);
|
ctl.set(127);
|
||||||
@@ -155,14 +155,14 @@ public class MimeType implements Comparable<MimeType>, Serializable {
|
|||||||
this.type = type.toLowerCase(Locale.ENGLISH);
|
this.type = type.toLowerCase(Locale.ENGLISH);
|
||||||
this.subtype = subtype.toLowerCase(Locale.ENGLISH);
|
this.subtype = subtype.toLowerCase(Locale.ENGLISH);
|
||||||
if (!CollectionUtils.isEmpty(parameters)) {
|
if (!CollectionUtils.isEmpty(parameters)) {
|
||||||
Map<String, String> m = new LinkedCaseInsensitiveMap<String>(parameters.size(), Locale.ENGLISH);
|
Map<String, String> map = new LinkedCaseInsensitiveMap<String>(parameters.size(), Locale.ENGLISH);
|
||||||
for (Map.Entry<String, String> entry : parameters.entrySet()) {
|
for (Map.Entry<String, String> entry : parameters.entrySet()) {
|
||||||
String attribute = entry.getKey();
|
String attribute = entry.getKey();
|
||||||
String value = entry.getValue();
|
String value = entry.getValue();
|
||||||
checkParameters(attribute, value);
|
checkParameters(attribute, value);
|
||||||
m.put(attribute, value);
|
map.put(attribute, value);
|
||||||
}
|
}
|
||||||
this.parameters = Collections.unmodifiableMap(m);
|
this.parameters = Collections.unmodifiableMap(map);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.parameters = Collections.emptyMap();
|
this.parameters = Collections.emptyMap();
|
||||||
@@ -256,7 +256,7 @@ public class MimeType implements Comparable<MimeType>, Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the character set, as indicated by a {@code charset} parameter, if any.
|
* Return the character set, as indicated by a {@code charset} parameter, if any.
|
||||||
* @return the character set; or {@code null} if not available
|
* @return the character set, or {@code null} if not available
|
||||||
*/
|
*/
|
||||||
public Charset getCharSet() {
|
public Charset getCharSet() {
|
||||||
String charSet = getParameter(PARAM_CHARSET);
|
String charSet = getParameter(PARAM_CHARSET);
|
||||||
@@ -266,7 +266,7 @@ public class MimeType implements Comparable<MimeType>, Serializable {
|
|||||||
/**
|
/**
|
||||||
* Return a generic parameter value, given a parameter name.
|
* Return a generic parameter value, given a parameter name.
|
||||||
* @param name the parameter name
|
* @param name the parameter name
|
||||||
* @return the parameter value; or {@code null} if not present
|
* @return the parameter value, or {@code null} if not present
|
||||||
*/
|
*/
|
||||||
public String getParameter(String name) {
|
public String getParameter(String name) {
|
||||||
return this.parameters.get(name);
|
return this.parameters.get(name);
|
||||||
@@ -274,10 +274,10 @@ public class MimeType implements Comparable<MimeType>, Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all generic parameter values.
|
* Return all generic parameter values.
|
||||||
* @return a read-only map, possibly empty, never {@code null}
|
* @return a read-only map (possibly empty, never {@code null})
|
||||||
*/
|
*/
|
||||||
public Map<String, String> getParameters() {
|
public Map<String, String> getParameters() {
|
||||||
return parameters;
|
return this.parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class AnnotationUtilsTests {
|
|||||||
@Test
|
@Test
|
||||||
public void findAnnotationFavorsInterfacesOverLocalMetaAnnotations() {
|
public void findAnnotationFavorsInterfacesOverLocalMetaAnnotations() {
|
||||||
Component component = AnnotationUtils.findAnnotation(
|
Component component = AnnotationUtils.findAnnotation(
|
||||||
ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface.class, Component.class);
|
ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface.class, Component.class);
|
||||||
assertNotNull(component);
|
assertNotNull(component);
|
||||||
|
|
||||||
// By inspecting ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface, one
|
// By inspecting ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface, one
|
||||||
@@ -116,8 +116,8 @@ public class AnnotationUtilsTests {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void findAnnotationFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() {
|
public void findAnnotationFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() {
|
||||||
Transactional transactional = AnnotationUtils.findAnnotation(SubSubClassWithInheritedAnnotation.class,
|
Transactional transactional = AnnotationUtils.findAnnotation(
|
||||||
Transactional.class);
|
SubSubClassWithInheritedAnnotation.class, Transactional.class);
|
||||||
assertNotNull(transactional);
|
assertNotNull(transactional);
|
||||||
assertTrue("readOnly flag for SubSubClassWithInheritedAnnotation", transactional.readOnly());
|
assertTrue("readOnly flag for SubSubClassWithInheritedAnnotation", transactional.readOnly());
|
||||||
}
|
}
|
||||||
@@ -127,8 +127,8 @@ public class AnnotationUtilsTests {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void findAnnotationFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() {
|
public void findAnnotationFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() {
|
||||||
Component component = AnnotationUtils.findAnnotation(SubSubClassWithInheritedMetaAnnotation.class,
|
Component component = AnnotationUtils.findAnnotation(
|
||||||
Component.class);
|
SubSubClassWithInheritedMetaAnnotation.class, Component.class);
|
||||||
assertNotNull(component);
|
assertNotNull(component);
|
||||||
assertEquals("meta2", component.value());
|
assertEquals("meta2", component.value());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2005 the original author or authors.
|
* Copyright 2002-2014 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -20,12 +20,13 @@ import java.sql.Connection;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple interface to be implemented by handles for a JDBC Connection.
|
* Simple interface to be implemented by handles for a JDBC Connection.
|
||||||
* Used by JdoDialect, for example.
|
* Used by JpaDialect and JdoDialect, for example.
|
||||||
*
|
*
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @since 1.1
|
* @since 1.1
|
||||||
* @see SimpleConnectionHandle
|
* @see SimpleConnectionHandle
|
||||||
* @see ConnectionHolder
|
* @see ConnectionHolder
|
||||||
|
* @see org.springframework.orm.jdo.JpaDialect#getJdbcConnection
|
||||||
* @see org.springframework.orm.jdo.JdoDialect#getJdbcConnection
|
* @see org.springframework.orm.jdo.JdoDialect#getJdbcConnection
|
||||||
*/
|
*/
|
||||||
public interface ConnectionHandle {
|
public interface ConnectionHandle {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2014 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -23,7 +23,7 @@ import org.springframework.util.Assert;
|
|||||||
/**
|
/**
|
||||||
* Abstract base class for {@link DataFieldMaxValueIncrementer} implementations that use
|
* Abstract base class for {@link DataFieldMaxValueIncrementer} implementations that use
|
||||||
* a column in a custom sequence table. Subclasses need to provide the specific handling
|
* a column in a custom sequence table. Subclasses need to provide the specific handling
|
||||||
* of that table in their {@link #getNextKey()} implementation..
|
* of that table in their {@link #getNextKey()} implementation.
|
||||||
*
|
*
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @since 2.5.3
|
* @since 2.5.3
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Support package for the Hibernate 3 Annotation add-on,
|
||||||
* Support package for the Hibernate3 Annotation add-on,
|
* which supports JPA-compliant Java 5+ annotations for mappings.
|
||||||
* which supports EJB3-compliant JDK 1.5+ annotations for mappings.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package org.springframework.orm.hibernate3.annotation;
|
package org.springframework.orm.hibernate3.annotation;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2014 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -244,8 +244,8 @@ public class HibernateJpaDialect extends DefaultJpaDialect {
|
|||||||
return new JpaSystemException(ex);
|
return new JpaSystemException(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Session getSession(EntityManager em) {
|
protected Session getSession(EntityManager entityManager) {
|
||||||
return em.unwrap(Session.class);
|
return entityManager.unwrap(Session.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -270,14 +270,14 @@ public class HibernateJpaDialect extends DefaultJpaDialect {
|
|||||||
|
|
||||||
private static class HibernateConnectionHandle implements ConnectionHandle {
|
private static class HibernateConnectionHandle implements ConnectionHandle {
|
||||||
|
|
||||||
private final Session session;
|
|
||||||
|
|
||||||
// This will find a corresponding method on Hibernate 3.x but not on 4.x
|
// This will find a corresponding method on Hibernate 3.x but not on 4.x
|
||||||
private static final Method sessionConnectionMethod =
|
private static final Method sessionConnectionMethod =
|
||||||
ClassUtils.getMethodIfAvailable(Session.class, "connection");
|
ClassUtils.getMethodIfAvailable(Session.class, "connection");
|
||||||
|
|
||||||
private static volatile Method connectionMethodToUse = sessionConnectionMethod;
|
private static volatile Method connectionMethodToUse = sessionConnectionMethod;
|
||||||
|
|
||||||
|
private final Session session;
|
||||||
|
|
||||||
public HibernateConnectionHandle(Session session) {
|
public HibernateConnectionHandle(Session session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
}
|
}
|
||||||
@@ -286,7 +286,7 @@ public class HibernateJpaDialect extends DefaultJpaDialect {
|
|||||||
public Connection getConnection() {
|
public Connection getConnection() {
|
||||||
try {
|
try {
|
||||||
if (connectionMethodToUse == null) {
|
if (connectionMethodToUse == null) {
|
||||||
// Reflective lookup trying to find SessionImpl's connection() on Hibernate 4.x
|
// Reflective lookup to find SessionImpl's connection() method on Hibernate 4.x
|
||||||
connectionMethodToUse = this.session.getClass().getMethod("connection");
|
connectionMethodToUse = this.session.getClass().getMethod("connection");
|
||||||
}
|
}
|
||||||
return (Connection) ReflectionUtils.invokeMethod(connectionMethodToUse, this.session);
|
return (Connection) ReflectionUtils.invokeMethod(connectionMethodToUse, this.session);
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Contains (un)marshallers optimized to store binary data in MIME attachments.
|
* Contains (un)marshallers optimized to store binary data in MIME attachments.
|
||||||
* </htm
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package org.springframework.oxm.mime;
|
package org.springframework.oxm.mime;
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Provides generic support classes for using Spring's O/X Mapping integration
|
||||||
* Provides generic support classes for using Spring's O/X Mapping integration within various scenario's. Includes the
|
* within various scenario's. Includes the MarshallingSource for compatibility
|
||||||
* MarshallingSource for compatibility with TrAX, MarshallingView for use withing Spring Web MVC, and the
|
* with TrAX, MarshallingView for use withing Spring Web MVC, and the
|
||||||
* MarshallingMessageConverter for use within Spring's JMS support.
|
* MarshallingMessageConverter for use within Spring's JMS support.
|
||||||
* </htm
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package org.springframework.oxm.support;
|
package org.springframework.oxm.support;
|
||||||
|
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ public abstract class AbstractPlatformTransactionManager implements PlatformTran
|
|||||||
}
|
}
|
||||||
else if (definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_REQUIRED ||
|
else if (definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_REQUIRED ||
|
||||||
definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_REQUIRES_NEW ||
|
definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_REQUIRES_NEW ||
|
||||||
definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_NESTED) {
|
definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_NESTED) {
|
||||||
SuspendedResourcesHolder suspendedResources = suspend(null);
|
SuspendedResourcesHolder suspendedResources = suspend(null);
|
||||||
if (debugEnabled) {
|
if (debugEnabled) {
|
||||||
logger.debug("Creating new transaction with name [" + definition.getName() + "]: " + definition);
|
logger.debug("Creating new transaction with name [" + definition.getName() + "]: " + definition);
|
||||||
@@ -531,7 +531,7 @@ public abstract class AbstractPlatformTransactionManager implements PlatformTran
|
|||||||
if (status.isNewSynchronization()) {
|
if (status.isNewSynchronization()) {
|
||||||
TransactionSynchronizationManager.setActualTransactionActive(status.hasTransaction());
|
TransactionSynchronizationManager.setActualTransactionActive(status.hasTransaction());
|
||||||
TransactionSynchronizationManager.setCurrentTransactionIsolationLevel(
|
TransactionSynchronizationManager.setCurrentTransactionIsolationLevel(
|
||||||
(definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT) ?
|
definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT ?
|
||||||
definition.getIsolationLevel() : null);
|
definition.getIsolationLevel() : null);
|
||||||
TransactionSynchronizationManager.setCurrentTransactionReadOnly(definition.isReadOnly());
|
TransactionSynchronizationManager.setCurrentTransactionReadOnly(definition.isReadOnly());
|
||||||
TransactionSynchronizationManager.setCurrentTransactionName(definition.getName());
|
TransactionSynchronizationManager.setCurrentTransactionName(definition.getName());
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ import org.springframework.util.StringUtils;
|
|||||||
/**
|
/**
|
||||||
* Represents HTTP request and response headers, mapping string header names to list of string values.
|
* Represents HTTP request and response headers, mapping string header names to list of string values.
|
||||||
*
|
*
|
||||||
* <p>In addition to the normal methods defined by {@link Map}, this class offers the following convenience methods:
|
* <p>In addition to the normal methods defined by {@link Map}, this class offers the following
|
||||||
|
* convenience methods:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@link #getFirst(String)} returns the first value associated with a given header name</li>
|
* <li>{@link #getFirst(String)} returns the first value associated with a given header name</li>
|
||||||
* <li>{@link #add(String, String)} adds a header value to the list of values for a header name</li>
|
* <li>{@link #add(String, String)} adds a header value to the list of values for a header name</li>
|
||||||
@@ -104,9 +105,17 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
|
|
||||||
private static TimeZone GMT = TimeZone.getTimeZone("GMT");
|
private static TimeZone GMT = TimeZone.getTimeZone("GMT");
|
||||||
|
|
||||||
|
|
||||||
private final Map<String, List<String>> headers;
|
private final Map<String, List<String>> headers;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new, empty instance of the {@code HttpHeaders} object.
|
||||||
|
*/
|
||||||
|
public HttpHeaders() {
|
||||||
|
this(new LinkedCaseInsensitiveMap<List<String>>(8, Locale.ENGLISH), false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private constructor that can create read-only {@code HttpHeader} instances.
|
* Private constructor that can create read-only {@code HttpHeader} instances.
|
||||||
*/
|
*/
|
||||||
@@ -126,32 +135,19 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new, empty instance of the {@code HttpHeaders} object.
|
|
||||||
*/
|
|
||||||
public HttpHeaders() {
|
|
||||||
this(new LinkedCaseInsensitiveMap<List<String>>(8, Locale.ENGLISH), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code HttpHeaders} object that can only be read, not written to.
|
* Set the list of acceptable {@linkplain MediaType media types},
|
||||||
*/
|
* as specified by the {@code Accept} header.
|
||||||
public static HttpHeaders readOnlyHttpHeaders(HttpHeaders headers) {
|
|
||||||
return new HttpHeaders(headers, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the list of acceptable {@linkplain MediaType media types}, as specified by the {@code Accept} header.
|
|
||||||
* @param acceptableMediaTypes the acceptable media types
|
|
||||||
*/
|
*/
|
||||||
public void setAccept(List<MediaType> acceptableMediaTypes) {
|
public void setAccept(List<MediaType> acceptableMediaTypes) {
|
||||||
set(ACCEPT, MediaType.toString(acceptableMediaTypes));
|
set(ACCEPT, MediaType.toString(acceptableMediaTypes));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the list of acceptable {@linkplain MediaType media types}, as specified by the {@code Accept} header.
|
* Return the list of acceptable {@linkplain MediaType media types},
|
||||||
|
* as specified by the {@code Accept} header.
|
||||||
* <p>Returns an empty list when the acceptable media types are unspecified.
|
* <p>Returns an empty list when the acceptable media types are unspecified.
|
||||||
* @return the acceptable media types
|
|
||||||
*/
|
*/
|
||||||
public List<MediaType> getAccept() {
|
public List<MediaType> getAccept() {
|
||||||
String value = getFirst(ACCEPT);
|
String value = getFirst(ACCEPT);
|
||||||
@@ -170,8 +166,8 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the list of acceptable {@linkplain Charset charsets}, as specified by the {@code Accept-Charset} header.
|
* Set the list of acceptable {@linkplain Charset charsets},
|
||||||
* @param acceptableCharsets the acceptable charsets
|
* as specified by the {@code Accept-Charset} header.
|
||||||
*/
|
*/
|
||||||
public void setAcceptCharset(List<Charset> acceptableCharsets) {
|
public void setAcceptCharset(List<Charset> acceptableCharsets) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
@@ -186,9 +182,8 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the list of acceptable {@linkplain Charset charsets}, as specified by the {@code Accept-Charset}
|
* Return the list of acceptable {@linkplain Charset charsets},
|
||||||
* header.
|
* as specified by the {@code Accept-Charset} header.
|
||||||
* @return the acceptable charsets
|
|
||||||
*/
|
*/
|
||||||
public List<Charset> getAcceptCharset() {
|
public List<Charset> getAcceptCharset() {
|
||||||
List<Charset> result = new ArrayList<Charset>();
|
List<Charset> result = new ArrayList<Charset>();
|
||||||
@@ -213,17 +208,17 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the set of allowed {@link HttpMethod HTTP methods}, as specified by the {@code Allow} header.
|
* Set the set of allowed {@link HttpMethod HTTP methods},
|
||||||
* @param allowedMethods the allowed methods
|
* as specified by the {@code Allow} header.
|
||||||
*/
|
*/
|
||||||
public void setAllow(Set<HttpMethod> allowedMethods) {
|
public void setAllow(Set<HttpMethod> allowedMethods) {
|
||||||
set(ALLOW, StringUtils.collectionToCommaDelimitedString(allowedMethods));
|
set(ALLOW, StringUtils.collectionToCommaDelimitedString(allowedMethods));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the set of allowed {@link HttpMethod HTTP methods}, as specified by the {@code Allow} header.
|
* Return the set of allowed {@link HttpMethod HTTP methods},
|
||||||
|
* as specified by the {@code Allow} header.
|
||||||
* <p>Returns an empty set when the allowed methods are unspecified.
|
* <p>Returns an empty set when the allowed methods are unspecified.
|
||||||
* @return the allowed methods
|
|
||||||
*/
|
*/
|
||||||
public Set<HttpMethod> getAllow() {
|
public Set<HttpMethod> getAllow() {
|
||||||
String value = getFirst(ALLOW);
|
String value = getFirst(ALLOW);
|
||||||
@@ -241,8 +236,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code Cache-Control} header.
|
* Set the (new) value of the {@code Cache-Control} header.
|
||||||
* @param cacheControl the value of the header
|
|
||||||
*/
|
*/
|
||||||
public void setCacheControl(String cacheControl) {
|
public void setCacheControl(String cacheControl) {
|
||||||
set(CACHE_CONTROL, cacheControl);
|
set(CACHE_CONTROL, cacheControl);
|
||||||
@@ -250,23 +244,20 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the {@code Cache-Control} header.
|
* Returns the value of the {@code Cache-Control} header.
|
||||||
* @return the value of the header
|
|
||||||
*/
|
*/
|
||||||
public String getCacheControl() {
|
public String getCacheControl() {
|
||||||
return getFirst(CACHE_CONTROL);
|
return getFirst(CACHE_CONTROL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code Connection} header.
|
* Set the (new) value of the {@code Connection} header.
|
||||||
* @param connection the value of the header
|
|
||||||
*/
|
*/
|
||||||
public void setConnection(String connection) {
|
public void setConnection(String connection) {
|
||||||
set(CONNECTION, connection);
|
set(CONNECTION, connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code Connection} header.
|
* Set the (new) value of the {@code Connection} header.
|
||||||
* @param connection the value of the header
|
|
||||||
*/
|
*/
|
||||||
public void setConnection(List<String> connection) {
|
public void setConnection(List<String> connection) {
|
||||||
set(CONNECTION, toCommaDelimitedString(connection));
|
set(CONNECTION, toCommaDelimitedString(connection));
|
||||||
@@ -274,16 +265,16 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the {@code Connection} header.
|
* Returns the value of the {@code Connection} header.
|
||||||
* @return the value of the header
|
|
||||||
*/
|
*/
|
||||||
public List<String> getConnection() {
|
public List<String> getConnection() {
|
||||||
return getFirstValueAsList(CONNECTION);
|
return getFirstValueAsList(CONNECTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code Content-Disposition} header for {@code form-data}.
|
* Set the (new) value of the {@code Content-Disposition} header
|
||||||
|
* for {@code form-data}.
|
||||||
* @param name the control name
|
* @param name the control name
|
||||||
* @param filename the filename, may be {@code null}
|
* @param filename the filename (may be {@code null})
|
||||||
*/
|
*/
|
||||||
public void setContentDispositionFormData(String name, String filename) {
|
public void setContentDispositionFormData(String name, String filename) {
|
||||||
Assert.notNull(name, "'name' must not be null");
|
Assert.notNull(name, "'name' must not be null");
|
||||||
@@ -297,17 +288,17 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the length of the body in bytes, as specified by the {@code Content-Length} header.
|
* Set the length of the body in bytes, as specified by the
|
||||||
* @param contentLength the content length
|
* {@code Content-Length} header.
|
||||||
*/
|
*/
|
||||||
public void setContentLength(long contentLength) {
|
public void setContentLength(long contentLength) {
|
||||||
set(CONTENT_LENGTH, Long.toString(contentLength));
|
set(CONTENT_LENGTH, Long.toString(contentLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the length of the body in bytes, as specified by the {@code Content-Length} header.
|
* Return the length of the body in bytes, as specified by the
|
||||||
|
* {@code Content-Length} header.
|
||||||
* <p>Returns -1 when the content-length is unknown.
|
* <p>Returns -1 when the content-length is unknown.
|
||||||
* @return the content length
|
|
||||||
*/
|
*/
|
||||||
public long getContentLength() {
|
public long getContentLength() {
|
||||||
String value = getFirst(CONTENT_LENGTH);
|
String value = getFirst(CONTENT_LENGTH);
|
||||||
@@ -315,8 +306,8 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the {@linkplain MediaType media type} of the body, as specified by the {@code Content-Type} header.
|
* Set the {@linkplain MediaType media type} of the body,
|
||||||
* @param mediaType the media type
|
* as specified by the {@code Content-Type} header.
|
||||||
*/
|
*/
|
||||||
public void setContentType(MediaType mediaType) {
|
public void setContentType(MediaType mediaType) {
|
||||||
Assert.isTrue(!mediaType.isWildcardType(), "'Content-Type' cannot contain wildcard type '*'");
|
Assert.isTrue(!mediaType.isWildcardType(), "'Content-Type' cannot contain wildcard type '*'");
|
||||||
@@ -325,9 +316,9 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the {@linkplain MediaType media type} of the body, as specified by the {@code Content-Type} header.
|
* Return the {@linkplain MediaType media type} of the body, as specified
|
||||||
|
* by the {@code Content-Type} header.
|
||||||
* <p>Returns {@code null} when the content-type is unknown.
|
* <p>Returns {@code null} when the content-type is unknown.
|
||||||
* @return the content type
|
|
||||||
*/
|
*/
|
||||||
public MediaType getContentType() {
|
public MediaType getContentType() {
|
||||||
String value = getFirst(CONTENT_TYPE);
|
String value = getFirst(CONTENT_TYPE);
|
||||||
@@ -335,18 +326,20 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the date and time at which the message was created, as specified by the {@code Date} header.
|
* Set the date and time at which the message was created, as specified
|
||||||
* <p>The date should be specified as the number of milliseconds since January 1, 1970 GMT.
|
* by the {@code Date} header.
|
||||||
* @param date the date
|
* <p>The date should be specified as the number of milliseconds since
|
||||||
|
* January 1, 1970 GMT.
|
||||||
*/
|
*/
|
||||||
public void setDate(long date) {
|
public void setDate(long date) {
|
||||||
setDate(DATE, date);
|
setDate(DATE, date);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the date and time at which the message was created, as specified by the {@code Date} header.
|
* Return the date and time at which the message was created, as specified
|
||||||
* <p>The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
|
* by the {@code Date} header.
|
||||||
* @return the creation date/time
|
* <p>The date is returned as the number of milliseconds since
|
||||||
|
* January 1, 1970 GMT. Returns -1 when the date is unknown.
|
||||||
* @throws IllegalArgumentException if the value can't be converted to a date
|
* @throws IllegalArgumentException if the value can't be converted to a date
|
||||||
*/
|
*/
|
||||||
public long getDate() {
|
public long getDate() {
|
||||||
@@ -354,41 +347,39 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) entity tag of the body, as specified by the {@code ETag} header.
|
* Set the (new) entity tag of the body, as specified by the {@code ETag} header.
|
||||||
* @param eTag the new entity tag
|
|
||||||
*/
|
*/
|
||||||
public void setETag(String eTag) {
|
public void setETag(String eTag) {
|
||||||
if (eTag != null) {
|
if (eTag != null) {
|
||||||
Assert.isTrue(eTag.startsWith("\"") || eTag.startsWith("W/"), "Invalid eTag, does not start with W/ or \"");
|
Assert.isTrue(eTag.startsWith("\"") || eTag.startsWith("W/"),
|
||||||
|
"Invalid eTag, does not start with W/ or \"");
|
||||||
Assert.isTrue(eTag.endsWith("\""), "Invalid eTag, does not end with \"");
|
Assert.isTrue(eTag.endsWith("\""), "Invalid eTag, does not end with \"");
|
||||||
}
|
}
|
||||||
set(ETAG, eTag);
|
set(ETAG, eTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the entity tag of the body, as specified by the {@code ETag} header.
|
* Return the entity tag of the body, as specified by the {@code ETag} header.
|
||||||
* @return the entity tag
|
|
||||||
*/
|
*/
|
||||||
public String getETag() {
|
public String getETag() {
|
||||||
return getFirst(ETAG);
|
return getFirst(ETAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the date and time at which the message is no longer valid, as specified by the {@code Expires} header.
|
* Set the date and time at which the message is no longer valid,
|
||||||
* <p>The date should be specified as the number of milliseconds since January 1, 1970 GMT.
|
* as specified by the {@code Expires} header.
|
||||||
* @param expires the new expires header value
|
* <p>The date should be specified as the number of milliseconds since
|
||||||
|
* January 1, 1970 GMT.
|
||||||
*/
|
*/
|
||||||
public void setExpires(long expires) {
|
public void setExpires(long expires) {
|
||||||
setDate(EXPIRES, expires);
|
setDate(EXPIRES, expires);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the date and time at which the message is no longer valid, as specified by
|
* Return the date and time at which the message is no longer valid,
|
||||||
* the {@code Expires} header.
|
* as specified by the {@code Expires} header.
|
||||||
* <p>The date is returned as the number of milliseconds since January 1, 1970 GMT.
|
* <p>The date is returned as the number of milliseconds since
|
||||||
* Returns -1 when the date is unknown.
|
* January 1, 1970 GMT. Returns -1 when the date is unknown.
|
||||||
*
|
|
||||||
* @return the expires value
|
|
||||||
*/
|
*/
|
||||||
public long getExpires() {
|
public long getExpires() {
|
||||||
try {
|
try {
|
||||||
@@ -400,18 +391,18 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code If-Modified-Since} header.
|
* Set the (new) value of the {@code If-Modified-Since} header.
|
||||||
* <p>The date should be specified as the number of milliseconds since January 1, 1970 GMT.
|
* <p>The date should be specified as the number of milliseconds since
|
||||||
* @param ifModifiedSince the new value of the header
|
* January 1, 1970 GMT.
|
||||||
*/
|
*/
|
||||||
public void setIfModifiedSince(long ifModifiedSince) {
|
public void setIfModifiedSince(long ifModifiedSince) {
|
||||||
setDate(IF_MODIFIED_SINCE, ifModifiedSince);
|
setDate(IF_MODIFIED_SINCE, ifModifiedSince);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the {@code IfModifiedSince} header.
|
* Return the value of the {@code IfModifiedSince} header.
|
||||||
* <p>The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
|
* <p>The date is returned as the number of milliseconds since
|
||||||
* @return the header value
|
* January 1, 1970 GMT. Returns -1 when the date is unknown.
|
||||||
* @deprecated use {@link #getIfModifiedSince()}
|
* @deprecated use {@link #getIfModifiedSince()}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@@ -420,25 +411,23 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the {@code If-Modified-Since} header.
|
* Return the value of the {@code If-Modified-Since} header.
|
||||||
* <p>The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
|
* <p>The date is returned as the number of milliseconds since
|
||||||
* @return the header value
|
* January 1, 1970 GMT. Returns -1 when the date is unknown.
|
||||||
*/
|
*/
|
||||||
public long getIfModifiedSince() {
|
public long getIfModifiedSince() {
|
||||||
return getFirstDate(IF_MODIFIED_SINCE);
|
return getFirstDate(IF_MODIFIED_SINCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code If-None-Match} header.
|
* Set the (new) value of the {@code If-None-Match} header.
|
||||||
* @param ifNoneMatch the new value of the header
|
|
||||||
*/
|
*/
|
||||||
public void setIfNoneMatch(String ifNoneMatch) {
|
public void setIfNoneMatch(String ifNoneMatch) {
|
||||||
set(IF_NONE_MATCH, ifNoneMatch);
|
set(IF_NONE_MATCH, ifNoneMatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) values of the {@code If-None-Match} header.
|
* Set the (new) values of the {@code If-None-Match} header.
|
||||||
* @param ifNoneMatchList the new value of the header
|
|
||||||
*/
|
*/
|
||||||
public void setIfNoneMatch(List<String> ifNoneMatchList) {
|
public void setIfNoneMatch(List<String> ifNoneMatchList) {
|
||||||
set(IF_NONE_MATCH, toCommaDelimitedString(ifNoneMatchList));
|
set(IF_NONE_MATCH, toCommaDelimitedString(ifNoneMatchList));
|
||||||
@@ -457,8 +446,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the {@code If-None-Match} header.
|
* Return the value of the {@code If-None-Match} header.
|
||||||
* @return the header value
|
|
||||||
*/
|
*/
|
||||||
public List<String> getIfNoneMatch() {
|
public List<String> getIfNoneMatch() {
|
||||||
return getFirstValueAsList(IF_NONE_MATCH);
|
return getFirstValueAsList(IF_NONE_MATCH);
|
||||||
@@ -466,7 +454,6 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
|
|
||||||
protected List<String> getFirstValueAsList(String header) {
|
protected List<String> getFirstValueAsList(String header) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<String>();
|
||||||
|
|
||||||
String value = getFirst(header);
|
String value = getFirst(header);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
String[] tokens = value.split(",\\s*");
|
String[] tokens = value.split(",\\s*");
|
||||||
@@ -478,35 +465,37 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the time the resource was last changed, as specified by the {@code Last-Modified} header.
|
* Set the time the resource was last changed, as specified by the
|
||||||
* <p>The date should be specified as the number of milliseconds since January 1, 1970 GMT.
|
* {@code Last-Modified} header.
|
||||||
* @param lastModified the last modified date
|
* <p>The date should be specified as the number of milliseconds since
|
||||||
|
* January 1, 1970 GMT.
|
||||||
*/
|
*/
|
||||||
public void setLastModified(long lastModified) {
|
public void setLastModified(long lastModified) {
|
||||||
setDate(LAST_MODIFIED, lastModified);
|
setDate(LAST_MODIFIED, lastModified);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the time the resource was last changed, as specified by the {@code Last-Modified} header.
|
* Return the time the resource was last changed, as specified by the
|
||||||
* <p>The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
|
* {@code Last-Modified} header.
|
||||||
* @return the last modified date
|
* <p>The date is returned as the number of milliseconds since
|
||||||
|
* January 1, 1970 GMT. Returns -1 when the date is unknown.
|
||||||
*/
|
*/
|
||||||
public long getLastModified() {
|
public long getLastModified() {
|
||||||
return getFirstDate(LAST_MODIFIED);
|
return getFirstDate(LAST_MODIFIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the (new) location of a resource, as specified by the {@code Location} header.
|
* Set the (new) location of a resource,
|
||||||
* @param location the location
|
* as specified by the {@code Location} header.
|
||||||
*/
|
*/
|
||||||
public void setLocation(URI location) {
|
public void setLocation(URI location) {
|
||||||
set(LOCATION, location.toASCIIString());
|
set(LOCATION, location.toASCIIString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the (new) location of a resource, as specified by the {@code Location} header.
|
* Return the (new) location of a resource
|
||||||
|
* as specified by the {@code Location} header.
|
||||||
* <p>Returns {@code null} when the location is unknown.
|
* <p>Returns {@code null} when the location is unknown.
|
||||||
* @return the location
|
|
||||||
*/
|
*/
|
||||||
public URI getLocation() {
|
public URI getLocation() {
|
||||||
String value = getFirst(LOCATION);
|
String value = getFirst(LOCATION);
|
||||||
@@ -514,40 +503,35 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code Origin} header.
|
* Set the (new) value of the {@code Origin} header.
|
||||||
* @param origin the value of the header
|
|
||||||
*/
|
*/
|
||||||
public void setOrigin(String origin) {
|
public void setOrigin(String origin) {
|
||||||
set(ORIGIN, origin);
|
set(ORIGIN, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the {@code Origin} header.
|
* Return the value of the {@code Origin} header.
|
||||||
* @return the value of the header
|
|
||||||
*/
|
*/
|
||||||
public String getOrigin() {
|
public String getOrigin() {
|
||||||
return getFirst(ORIGIN);
|
return getFirst(ORIGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code Pragma} header.
|
* Set the (new) value of the {@code Pragma} header.
|
||||||
* @param pragma the value of the header
|
|
||||||
*/
|
*/
|
||||||
public void setPragma(String pragma) {
|
public void setPragma(String pragma) {
|
||||||
set(PRAGMA, pragma);
|
set(PRAGMA, pragma);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the {@code Pragma} header.
|
* Return the value of the {@code Pragma} header.
|
||||||
* @return the value of the header
|
|
||||||
*/
|
*/
|
||||||
public String getPragma() {
|
public String getPragma() {
|
||||||
return getFirst(PRAGMA);
|
return getFirst(PRAGMA);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the (new) value of the {@code Upgrade} header.
|
* Set the (new) value of the {@code Upgrade} header.
|
||||||
* @param upgrade the value of the header
|
|
||||||
*/
|
*/
|
||||||
public void setUpgrade(String upgrade) {
|
public void setUpgrade(String upgrade) {
|
||||||
set(UPGRADE, upgrade);
|
set(UPGRADE, upgrade);
|
||||||
@@ -555,18 +539,15 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the {@code Upgrade} header.
|
* Returns the value of the {@code Upgrade} header.
|
||||||
* @return the value of the header
|
|
||||||
*/
|
*/
|
||||||
public String getUpgrade() {
|
public String getUpgrade() {
|
||||||
return getFirst(UPGRADE);
|
return getFirst(UPGRADE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Date methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the first header value for the given header name as a date, return -1 if
|
* Parse the first header value for the given header name as a date,
|
||||||
* there is no value, or raise {@link IllegalArgumentException} if the value cannot be
|
* return -1 if there is no value, or raise {@link IllegalArgumentException}
|
||||||
* parsed as a date.
|
* if the value cannot be parsed as a date.
|
||||||
*/
|
*/
|
||||||
public long getFirstDate(String headerName) {
|
public long getFirstDate(String headerName) {
|
||||||
String headerValue = getFirst(headerName);
|
String headerValue = getFirst(headerName);
|
||||||
@@ -598,12 +579,10 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
set(headerName, dateFormat.format(new Date(date)));
|
set(headerName, dateFormat.format(new Date(date)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Single string methods
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the first header value for the given header name, if any.
|
* Return the first header value for the given header name, if any.
|
||||||
* @param headerName the header name
|
* @param headerName the header name
|
||||||
* @return the first header value; or {@code null}
|
* @return the first header value, or {@code null} if none
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getFirst(String headerName) {
|
public String getFirst(String headerName) {
|
||||||
@@ -613,7 +592,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the given, single header value under the given name.
|
* Add the given, single header value under the given name.
|
||||||
* @param headerName the header name
|
* @param headerName the header name
|
||||||
* @param headerValue the header value
|
* @param headerValue the header value
|
||||||
* @throws UnsupportedOperationException if adding headers is not supported
|
* @throws UnsupportedOperationException if adding headers is not supported
|
||||||
* @see #put(String, List)
|
* @see #put(String, List)
|
||||||
@@ -631,7 +610,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the given, single header value under the given name.
|
* Set the given, single header value under the given name.
|
||||||
* @param headerName the header name
|
* @param headerName the header name
|
||||||
* @param headerValue the header value
|
* @param headerValue the header value
|
||||||
* @throws UnsupportedOperationException if adding headers is not supported
|
* @throws UnsupportedOperationException if adding headers is not supported
|
||||||
* @see #put(String, List)
|
* @see #put(String, List)
|
||||||
@@ -660,6 +639,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
return singleValueMap;
|
return singleValueMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Map implementation
|
// Map implementation
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -698,8 +678,8 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putAll(Map<? extends String, ? extends List<String>> m) {
|
public void putAll(Map<? extends String, ? extends List<String>> map) {
|
||||||
this.headers.putAll(m);
|
this.headers.putAll(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -745,4 +725,12 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
|||||||
return this.headers.toString();
|
return this.headers.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a {@code HttpHeaders} object that can only be read, not written to.
|
||||||
|
*/
|
||||||
|
public static HttpHeaders readOnlyHttpHeaders(HttpHeaders headers) {
|
||||||
|
return new HttpHeaders(headers, true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1275,7 +1275,7 @@ public class DispatcherServlet extends FrameworkServlet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void triggerAfterCompletionWithError(HttpServletRequest request, HttpServletResponse response,
|
private void triggerAfterCompletionWithError(HttpServletRequest request, HttpServletResponse response,
|
||||||
HandlerExecutionChain mappedHandler, Error error) throws Exception, ServletException {
|
HandlerExecutionChain mappedHandler, Error error) throws Exception {
|
||||||
|
|
||||||
ServletException ex = new NestedServletException("Handler processing failed", error);
|
ServletException ex = new NestedServletException("Handler processing failed", error);
|
||||||
if (mappedHandler != null) {
|
if (mappedHandler != null) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2014 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -26,23 +26,24 @@ import org.springframework.util.Assert;
|
|||||||
import org.springframework.web.context.ServletContextAware;
|
import org.springframework.web.context.ServletContextAware;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A FactoryBean for configuring {@link javax.websocket.server.ServerContainer}. Since
|
* A {@link FactoryBean} for configuring {@link javax.websocket.server.ServerContainer}.
|
||||||
* there is only one {@code ServerContainer} instance accessible under a well-known
|
* Since there is usually only one {@code ServerContainer} instance accessible under a
|
||||||
* {@code javax.servlet.ServletContext} attribute, simply declaring this FactoryBean and
|
* well-known {@code javax.servlet.ServletContext} attribute, simply declaring this
|
||||||
* using its setters allows configuring the {@code ServerContainer} through Spring
|
* FactoryBean and using its setters allows for configuring the {@code ServerContainer}
|
||||||
* configuration.
|
* through Spring configuration.
|
||||||
*
|
*
|
||||||
* <p>This is useful even if the {@code ServerContainer} is not injected into any other
|
* <p>This is useful even if the {@code ServerContainer} is not injected into any other
|
||||||
* bean. For example, an application can configure a {@link org.springframework.web.socket.server.support.DefaultHandshakeHandler}, a
|
* bean within the Spring application context. For example, an application can configure
|
||||||
* {@link org.springframework.web.socket.sockjs.SockJsService}, or {@link ServerEndpointExporter},
|
* a {@link org.springframework.web.socket.server.support.DefaultHandshakeHandler},
|
||||||
* and separately declare this FactoryBean in order to customize the properties of the
|
* a {@link org.springframework.web.socket.sockjs.SockJsService}, or
|
||||||
* (one and only) {@code ServerContainer} instance.
|
* {@link ServerEndpointExporter}, and separately declare this FactoryBean in order
|
||||||
|
* to customize the properties of the (one and only) {@code ServerContainer} instance.
|
||||||
*
|
*
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class ServletServerContainerFactoryBean
|
public class ServletServerContainerFactoryBean
|
||||||
implements FactoryBean<WebSocketContainer>, InitializingBean, ServletContextAware {
|
implements FactoryBean<WebSocketContainer>, ServletContextAware, InitializingBean {
|
||||||
|
|
||||||
private Long asyncSendTimeout;
|
private Long asyncSendTimeout;
|
||||||
|
|
||||||
@@ -120,7 +121,7 @@ public class ServletServerContainerFactoryBean
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getObjectType() {
|
public Class<?> getObjectType() {
|
||||||
return ServerContainer.class;
|
return (this.serverContainer != null ? this.serverContainer.getClass() : ServerContainer.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.springframework.web.socket.server.standard;
|
package org.springframework.web.socket.server.standard;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import javax.websocket.server.ServerEndpoint;
|
import javax.websocket.server.ServerEndpoint;
|
||||||
@@ -114,7 +115,7 @@ public class SpringConfigurator extends Configurator {
|
|||||||
beanNamesByType.put(endpointClass, NO_VALUE);
|
beanNamesByType.put(endpointClass, NO_VALUE);
|
||||||
if (names.length > 1) {
|
if (names.length > 1) {
|
||||||
throw new IllegalStateException("Found multiple @ServerEndpoint's of type [" +
|
throw new IllegalStateException("Found multiple @ServerEndpoint's of type [" +
|
||||||
endpointClass.getName() + "]: bean names " + names);
|
endpointClass.getName() + "]: bean names " + Arrays.asList(names));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user