Polishing

This commit is contained in:
Juergen Hoeller
2015-11-14 23:32:36 +01:00
parent 48838d48d2
commit 71fc2ba174
20 changed files with 182 additions and 185 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 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.
@@ -243,6 +243,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
private String toString(boolean includeModifier, boolean includeReturnTypeAndArgs,
boolean useLongReturnAndArgumentTypeName, boolean useLongTypeName) {
StringBuilder sb = new StringBuilder();
if (includeModifier) {
sb.append(Modifier.toString(getModifiers()));
@@ -262,8 +263,9 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
return sb.toString();
}
private void appendTypes(StringBuilder sb, Class<?>[] types,
boolean includeArgs, boolean useLongReturnAndArgumentTypeName) {
private void appendTypes(StringBuilder sb, Class<?>[] types, boolean includeArgs,
boolean useLongReturnAndArgumentTypeName) {
if (includeArgs) {
for (int size = types.length, i = 0; i < size; i++) {
appendType(sb, types[i], useLongReturnAndArgumentTypeName);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 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.
@@ -48,8 +48,8 @@ public interface BeanPostProcessor {
* The returned bean instance may be a wrapper around the original.
* @param bean the new bean instance
* @param beanName the name of the bean
* @return the bean instance to use, either the original or a wrapped one; if
* {@code null}, no subsequent BeanPostProcessors will be invoked
* @return the bean instance to use, either the original or a wrapped one;
* if {@code null}, no subsequent BeanPostProcessors will be invoked
* @throws org.springframework.beans.BeansException in case of errors
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet
*/
@@ -69,8 +69,8 @@ public interface BeanPostProcessor {
* in contrast to all other BeanPostProcessor callbacks.
* @param bean the new bean instance
* @param beanName the name of the bean
* @return the bean instance to use, either the original or a wrapped one; if
* {@code null}, no subsequent BeanPostProcessors will be invoked
* @return the bean instance to use, either the original or a wrapped one;
* if {@code null}, no subsequent BeanPostProcessors will be invoked
* @throws org.springframework.beans.BeansException in case of errors
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet
* @see org.springframework.beans.factory.FactoryBean

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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.
@@ -37,11 +37,12 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ReflectionUtils;
/**
* Adapter that implements the {@link DisposableBean} and {@link Runnable} interfaces
* performing various destruction steps on a given bean instance:
* Adapter that implements the {@link DisposableBean} and {@link Runnable}
* interfaces performing various destruction steps on a given bean instance:
* <ul>
* <li>DestructionAwareBeanPostProcessors;
* <li>the bean implementing DisposableBean itself;
@@ -175,8 +176,8 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
/**
* If the current value of the given beanDefinition's "destroyMethodName" property is
* {@link AbstractBeanDefinition#INFER_METHOD}, then attempt to infer a destroy method.
* Candidate methods are currently limited to public, no-arg methods named "close"
* (whether declared locally or inherited). The given BeanDefinition's
* Candidate methods are currently limited to public, no-arg methods named "close" or
* "shutdown" (whether declared locally or inherited). The given BeanDefinition's
* "destroyMethodName" is updated to be null if no such method is found, otherwise set
* to the name of the inferred method. This constant serves as the default for the
* {@code @Bean#destroyMethod} attribute and the value of the constant may also be
@@ -215,7 +216,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
*/
private List<DestructionAwareBeanPostProcessor> filterPostProcessors(List<BeanPostProcessor> postProcessors) {
List<DestructionAwareBeanPostProcessor> filteredPostProcessors = null;
if (postProcessors != null && !postProcessors.isEmpty()) {
if (!CollectionUtils.isEmpty(postProcessors)) {
filteredPostProcessors = new ArrayList<DestructionAwareBeanPostProcessor>(postProcessors.size());
for (BeanPostProcessor postProcessor : postProcessors) {
if (postProcessor instanceof DestructionAwareBeanPostProcessor) {
@@ -234,7 +235,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
@Override
public void destroy() {
if (this.beanPostProcessors != null && !this.beanPostProcessors.isEmpty()) {
if (!CollectionUtils.isEmpty(this.beanPostProcessors)) {
for (DestructionAwareBeanPostProcessor processor : this.beanPostProcessors) {
processor.postProcessBeforeDestruction(this.bean, this.beanName);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 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.
@@ -25,6 +25,7 @@ import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation6.ComponentForScanning;
import org.springframework.context.annotation6.ConfigForScanning;
import org.springframework.context.annotation6.Jsr330NamedForScanning;
@@ -40,10 +41,10 @@ import static org.springframework.util.StringUtils.*;
*/
public class AnnotationConfigApplicationContextTests {
@Test(expected=IllegalArgumentException.class)
@Test(expected = IllegalArgumentException.class)
public void nullGetBeanParameterIsDisallowed() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
context.getBean((Class<?>)null);
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
context.getBean((Class<?>) null);
}
@Test
@@ -83,7 +84,7 @@ public class AnnotationConfigApplicationContextTests {
@Test
public void getBeanByType() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
TestBean testBean = context.getBean(TestBean.class);
assertNotNull("getBean() should not return null", testBean);
assertThat(testBean.name, equalTo("foo"));
@@ -95,7 +96,7 @@ public class AnnotationConfigApplicationContextTests {
*/
@Test
public void defaultConfigClassBeanNameIsGeneratedProperly() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
// attempt to retrieve the instance by its generated bean name
Config configObject = (Config) context.getBean("annotationConfigApplicationContextTests.Config");
@@ -108,18 +109,16 @@ public class AnnotationConfigApplicationContextTests {
*/
@Test
public void explicitConfigClassBeanNameIsRespected() {
AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(ConfigWithCustomName.class);
ApplicationContext context = new AnnotationConfigApplicationContext(ConfigWithCustomName.class);
// attempt to retrieve the instance by its specified name
ConfigWithCustomName configObject =
(ConfigWithCustomName) context.getBean("customConfigBeanName");
ConfigWithCustomName configObject = (ConfigWithCustomName) context.getBean("customConfigBeanName");
assertNotNull(configObject);
}
@Test
public void getBeanByTypeRaisesNoSuchBeanDefinitionException() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
// attempt to retrieve a bean that does not exist
Class<?> targetType = Pattern.class;
@@ -135,7 +134,7 @@ public class AnnotationConfigApplicationContextTests {
@Test
public void getBeanByTypeAmbiguityRaisesException() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TwoTestBeanConfig.class);
ApplicationContext context = new AnnotationConfigApplicationContext(TwoTestBeanConfig.class);
try {
context.getBean(TestBean.class);
@@ -153,7 +152,7 @@ public class AnnotationConfigApplicationContextTests {
@Test
public void autowiringIsEnabledByDefault() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AutowiredConfig.class);
ApplicationContext context = new AnnotationConfigApplicationContext(AutowiredConfig.class);
assertThat(context.getBean(TestBean.class).name, equalTo("foo"));
}
@@ -255,13 +254,14 @@ public class AnnotationConfigApplicationContextTests {
}
class TestBean {
String name;
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + (name == null ? 0 : name.hashCode());
return result;
}
@@ -277,7 +277,8 @@ class TestBean {
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
}
else if (!name.equals(other.name))
return false;
return true;
}

View File

@@ -102,7 +102,7 @@ public abstract class ReflectionUtils {
* <p>Thrown exceptions are handled via a call to {@link #handleReflectionException(Exception)}.
* @param field the field to set
* @param target the target object on which to set the field
* @param value the value to set; may be {@code null}
* @param value the value to set (may be {@code null})
*/
public static void setField(Field field, Object target, Object value) {
try {
@@ -284,12 +284,11 @@ public abstract class ReflectionUtils {
/**
* Rethrow the given {@link Throwable exception}, which is presumably the
* <em>target exception</em> of an {@link InvocationTargetException}. Should
* only be called if no checked exception is expected to be thrown by the
* target method.
* <em>target exception</em> of an {@link InvocationTargetException}.
* Should only be called if no checked exception is expected to be thrown
* by the target method.
* <p>Rethrows the underlying exception cast to an {@link RuntimeException} or
* {@link Error} if appropriate; otherwise, throws an
* {@link IllegalStateException}.
* {@link Error} if appropriate; otherwise, throws an {@link IllegalStateException}.
* @param ex the exception to rethrow
* @throws RuntimeException the rethrown exception
*/
@@ -305,12 +304,11 @@ public abstract class ReflectionUtils {
/**
* Rethrow the given {@link Throwable exception}, which is presumably the
* <em>target exception</em> of an {@link InvocationTargetException}. Should
* only be called if no checked exception is expected to be thrown by the
* target method.
* <em>target exception</em> of an {@link InvocationTargetException}.
* Should only be called if no checked exception is expected to be thrown
* by the target method.
* <p>Rethrows the underlying exception cast to an {@link Exception} or
* {@link Error} if appropriate; otherwise, throws an
* {@link IllegalStateException}.
* {@link Error} if appropriate; otherwise, throws an {@link IllegalStateException}.
* @param ex the exception to rethrow
* @throws Exception the rethrown exception (in case of a checked exception)
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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,7 +43,6 @@ public class SqlParameter {
/** Used for types that are user-named like: STRUCT, DISTINCT, JAVA_OBJECT, named array types */
private String typeName;
/** The scale to apply in case of a NUMERIC or DECIMAL type, if any */
private Integer scale;
@@ -126,7 +125,7 @@ public class SqlParameter {
/**
* Return the name of the parameter.
* Return the name of the parameter, or {@code null} if anonymous.
*/
public String getName() {
return this.name;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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.
@@ -39,18 +39,19 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource;
* the JDBC driver. Since we rely on the JDBC driver, this "auto-detection"
* can only be used for databases that are known to provide accurate meta data.
* These currently include Derby, MySQL, Microsoft SQL Server, Oracle, DB2,
* Sybase and PostgreSQL. For any other databases you are required to declare all
* parameters explicitly. You can of course declare all parameters explicitly even
* if the database provides the necessary meta data. In that case your declared
* parameters will take precedence. You can also turn off any meta data processing
* if you want to use parameter names that do not match what is declared during
* the stored procedure compilation.
* Sybase and PostgreSQL. For any other databases you are required to declare
* all parameters explicitly. You can of course declare all parameters
* explicitly even if the database provides the necessary meta data. In that
* case your declared parameters will take precedence. You can also turn off
* any metadata processing if you want to use parameter names that do not
* match what is declared during the stored procedure compilation.
*
* <p>The actual insert is being handled using Spring's
* {@link org.springframework.jdbc.core.JdbcTemplate}.
*
* <p>Many of the configuration methods return the current instance of the SimpleJdbcCall
* to provide the ability to chain multiple ones together in a "fluent" interface style.
* <p>Many of the configuration methods return the current instance of the
* SimpleJdbcCall in order to provide the ability to chain multiple ones
* together in a "fluent" interface style.
*
* @author Thomas Risberg
* @since 2.5
@@ -60,8 +61,8 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource;
public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOperations {
/**
* Constructor that takes one parameter with the JDBC DataSource to use when creating the
* JdbcTemplate.
* Constructor that takes one parameter with the JDBC DataSource to use when
* creating the underlying JdbcTemplate.
* @param dataSource the {@code DataSource} to use
* @see org.springframework.jdbc.core.JdbcTemplate#setDataSource
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 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.
@@ -103,8 +103,7 @@ public class SimpleJdbcCallTests {
adder.declareParameters(
new SqlParameter("amount", Types.INTEGER),
new SqlParameter("custid", Types.INTEGER),
new SqlOutParameter("newid",
Types.INTEGER));
new SqlOutParameter("newid", Types.INTEGER));
Number newId = adder.executeObject(Number.class, new MapSqlParameterSource().
addValue("amount", 1103).
addValue("custid", 3));
@@ -120,8 +119,7 @@ public class SimpleJdbcCallTests {
adder.declareParameters(
new SqlParameter("amount", Types.INTEGER),
new SqlParameter("custid", Types.INTEGER),
new SqlOutParameter("newid",
Types.INTEGER));
new SqlOutParameter("newid", Types.INTEGER));
Number newId = adder.executeObject(Number.class, 1103, 3);
assertEquals(4, newId.intValue());
verifyAddInvoiceWithoutMetaData(false);
@@ -193,7 +191,8 @@ public class SimpleJdbcCallTests {
}
@Test public void testAddInvoiceFuncWithMetaDataUsingArrayParams() throws Exception {
@Test
public void testAddInvoiceFuncWithMetaDataUsingArrayParams() throws Exception {
initializeAddInvoiceWithMetaData(true);
SimpleJdbcCall adder = new SimpleJdbcCall(dataSource).withFunctionName("add_invoice");
Number newId = adder.executeFunction(Number.class, 1103, 3);
@@ -203,8 +202,7 @@ public class SimpleJdbcCallTests {
}
private void initializeAddInvoiceWithoutMetaData(boolean isFunction)
throws SQLException {
private void initializeAddInvoiceWithoutMetaData(boolean isFunction) throws SQLException {
given(databaseMetaData.getDatabaseProductName()).willReturn("MyDB");
given(databaseMetaData.getUserName()).willReturn("me");
given(databaseMetaData.storesLowerCaseIdentifiers()).willReturn(true);
@@ -281,6 +279,6 @@ public class SimpleJdbcCallTests {
verify(callableStatement).close();
verify(proceduresResultSet).close();
verify(procedureColumnsResultSet).close();
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 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.
@@ -37,8 +37,8 @@ import org.springframework.util.ReflectionUtils.MethodFilter;
public abstract class HandlerMethodSelector {
/**
* Selects handler methods for the given handler type. Callers of this method define handler methods
* of interest through the {@link MethodFilter} parameter.
* Select handler methods for the given handler type.
* <p>Callers define handler methods of interest through the {@link MethodFilter} parameter.
* @param handlerType the handler type to search handler methods on
* @param handlerMethodFilter a {@link MethodFilter} to help recognize handler methods of interest
* @return the selected methods, or an empty set

View File

@@ -29,8 +29,8 @@ import org.springframework.messaging.handler.HandlerMethod;
import org.springframework.util.ReflectionUtils;
/**
* Invokes the handler method for a given message after resolving its method argument
* values through registered {@link HandlerMethodArgumentResolver}s.
* Provides a method for invoking the handler method for a given message after resolving its
* method argument values through registered {@link HandlerMethodArgumentResolver}s.
*
* <p>Use {@link #setMessageMethodArgumentResolvers(HandlerMethodArgumentResolver)}
* to customize the list of argument resolvers.
@@ -92,18 +92,28 @@ public class InvocableHandlerMethod extends HandlerMethod {
/**
* Invoke the method with the given message.
* @throws Exception raised if no suitable argument resolver can be found,
* or the method raised an exception
* Invoke the method after resolving its argument values in the context of the given message.
* <p>Argument values are commonly resolved through {@link HandlerMethodArgumentResolver}s.
* The {@code providedArgs} parameter however may supply argument values to be used directly,
* i.e. without argument resolution.
* @param message the current message being processed
* @param providedArgs "given" arguments matched by type, not resolved
* @return the raw value returned by the invoked method
* @exception Exception raised if no suitable argument resolver can be found,
* or if the method raised an exception
*/
public Object invoke(Message<?> message, Object... providedArgs) throws Exception {
Object[] args = getMethodArgumentValues(message, providedArgs);
if (logger.isTraceEnabled()) {
logger.trace("Resolved arguments: " + Arrays.asList(args));
StringBuilder sb = new StringBuilder("Invoking [");
sb.append(getBeanType().getSimpleName()).append(".");
sb.append(getMethod().getName()).append("] method with arguments ");
sb.append(Arrays.asList(args));
logger.trace(sb.toString());
}
Object returnValue = doInvoke(args);
if (logger.isTraceEnabled()) {
logger.trace("Returned value: " + returnValue);
logger.trace("Method [" + getMethod().getName() + "] returned [" + returnValue + "]");
}
return returnValue;
}
@@ -135,8 +145,8 @@ public class InvocableHandlerMethod extends HandlerMethod {
}
}
if (args[i] == null) {
String error = getArgumentResolutionErrorMessage("No suitable resolver for argument", i);
throw new IllegalStateException(error);
String msg = getArgumentResolutionErrorMessage("No suitable resolver for argument", i);
throw new IllegalStateException(msg);
}
}
return args;
@@ -149,7 +159,8 @@ public class InvocableHandlerMethod extends HandlerMethod {
}
/**
* Adds HandlerMethod details such as the controller type and method signature to the given error message.
* Adds HandlerMethod details such as the controller type and method
* signature to the given error message.
* @param message error message to append the HandlerMethod details to
*/
protected String getDetailedErrorMessage(String message) {
@@ -219,7 +230,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
Class<?> targetBeanClass = targetBean.getClass();
if (!methodDeclaringClass.isAssignableFrom(targetBeanClass)) {
String msg = "The mapped controller method class '" + methodDeclaringClass.getName() +
"' is not an instance of the actual controller bean instance '" +
"' is not an instance of the actual controller bean class '" +
targetBeanClass.getName() + "'. If the controller requires proxying " +
"(e.g. due to @Transactional), please use class-based proxying.";
throw new IllegalStateException(getInvocationErrorMessage(msg, args));
@@ -229,7 +240,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
private String getInvocationErrorMessage(String message, Object[] resolvedArgs) {
StringBuilder sb = new StringBuilder(getDetailedErrorMessage(message));
sb.append("Resolved arguments: \n");
for (int i=0; i < resolvedArgs.length; i++) {
for (int i = 0; i < resolvedArgs.length; i++) {
sb.append("[").append(i).append("] ");
if (resolvedArgs[i] == null) {
sb.append("[null] \n");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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,10 +23,10 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation that indicates the return value of a message-handling method should
* be sent as a {@link org.springframework.messaging.Message} to the specified
* destination(s) prepended with {@code "/user/{username}"} where the user
* name is extracted from the headers of the input message being handled.
* Annotation that indicates that the return value of a message-handling method
* should be sent as a {@link org.springframework.messaging.Message} to the specified
* destination(s) prepended with <code>"/user/{username}"</code> where the user name
* is extracted from the headers of the input message being handled.
*
* @author Rossen Stoyanchev
* @since 4.0
@@ -40,9 +40,9 @@ import java.lang.annotation.Target;
public @interface SendToUser {
/**
* One or more destinations to send a message to. If left unspecified, a
* default destination is selected based on the destination of the input
* message being handled.
* One or more destinations to send a message to.
* <p>If left unspecified, a default destination is selected based on the
* destination of the input message being handled.
* @see org.springframework.messaging.simp.annotation.support.SendToMethodReturnValueHandler
*/
String[] value() default {};
@@ -50,8 +50,7 @@ public @interface SendToUser {
/**
* Whether messages should be sent to all sessions associated with the user
* or only to the session of the input message being handled.
*
* <p>By default this is set to {@code true} in which case messages are
* <p>By default, this is set to {@code true} in which case messages are
* broadcast to all sessions.
*/
boolean broadcast() default true;

View File

@@ -55,13 +55,6 @@ public class InvocableHandlerMethod extends HandlerMethod {
private ParameterNameDiscoverer parameterNameDiscoverer = new DefaultParameterNameDiscoverer();
/**
* Create an instance from the given handler and method.
*/
public InvocableHandlerMethod(Object bean, Method method) {
super(bean, method);
}
/**
* Create an instance from a {@code HandlerMethod}.
*/
@@ -69,6 +62,13 @@ public class InvocableHandlerMethod extends HandlerMethod {
super(handlerMethod);
}
/**
* Create an instance from a bean instance and a method.
*/
public InvocableHandlerMethod(Object bean, Method method) {
super(bean, method);
}
/**
* Construct a new handler method with the given bean instance, method name and parameters.
* @param bean the object bean
@@ -112,7 +112,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
/**
* Invoke the method after resolving its argument values in the context of the given request.
* <p>Argument values are commonly resolved through {@link HandlerMethodArgumentResolver}s.
* The {@code provideArgs} parameter however may supply argument values to be used directly,
* The {@code providedArgs} parameter however may supply argument values to be used directly,
* i.e. without argument resolution. Examples of provided argument values include a
* {@link WebDataBinder}, a {@link SessionStatus}, or a thrown exception instance.
* Provided argument values are checked before argument resolvers.
@@ -185,7 +185,8 @@ public class InvocableHandlerMethod extends HandlerMethod {
}
/**
* Adds HandlerMethod details such as the controller type and method signature to the given error message.
* Adds HandlerMethod details such as the controller type and method
* signature to the given error message.
* @param message error message to append the HandlerMethod details to
*/
protected String getDetailedErrorMessage(String message) {
@@ -255,7 +256,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
Class<?> targetBeanClass = targetBean.getClass();
if (!methodDeclaringClass.isAssignableFrom(targetBeanClass)) {
String msg = "The mapped controller method class '" + methodDeclaringClass.getName() +
"' is not an instance of the actual controller bean instance '" +
"' is not an instance of the actual controller bean class '" +
targetBeanClass.getName() + "'. If the controller requires proxying " +
"(e.g. due to @Transactional), please use class-based proxying.";
throw new IllegalStateException(getInvocationErrorMessage(msg, args));
@@ -265,7 +266,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
private String getInvocationErrorMessage(String message, Object[] resolvedArgs) {
StringBuilder sb = new StringBuilder(getDetailedErrorMessage(message));
sb.append("Resolved arguments: \n");
for (int i=0; i < resolvedArgs.length; i++) {
for (int i = 0; i < resolvedArgs.length; i++) {
sb.append("[").append(i).append("] ");
if (resolvedArgs[i] == null) {
sb.append("[null] \n");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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.
@@ -29,10 +29,11 @@ import java.util.regex.Pattern;
import org.springframework.util.Assert;
/**
* Represents a URI template. A URI template is a URI-like String that contains variables enclosed
* by braces ({@code {}}), which can be expanded to produce an actual URI.
* Represents a URI template. A URI template is a URI-like String that contains variables
* enclosed by braces ({@code {}}), which can be expanded to produce an actual URI.
*
* <p>See {@link #expand(Map)}, {@link #expand(Object[])}, and {@link #match(String)} for example usages.
* <p>See {@link #expand(Map)}, {@link #expand(Object[])}, and {@link #match(String)}
* for example usages.
*
* @author Arjen Poutsma
* @author Juergen Hoeller
@@ -48,6 +49,7 @@ public class UriTemplate implements Serializable {
/** Replaces template variables in the URI template. */
private static final String DEFAULT_VARIABLE_PATTERN = "(.*)";
private final UriComponents uriComponents;
private final List<String> variableNames;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 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,4 +33,5 @@ public interface ArgumentAware {
* @param argument the result of the nested {@code spring:argument} tag
*/
void addArgument(Object argument) throws JspTagException;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 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.
@@ -20,8 +20,8 @@ import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
/**
* JSP tag for collecting arguments and passing them to an {@link ArgumentAware} ancestor
* in the tag hierarchy.
* JSP tag for collecting arguments and passing them to an {@link ArgumentAware}
* ancestor in the tag hierarchy.
*
* <p>This tag must be nested under an argument aware tag.
*
@@ -37,7 +37,17 @@ public class ArgumentTag extends BodyTagSupport {
private boolean valueSet;
// tag lifecycle
/**
* Set the value of the argument (optional).
* <pIf not set, the tag's body content will get evaluated.
* @param value the parameter value
*/
public void setValue(Object value) {
this.value = value;
this.valueSet = true;
}
@Override
public int doEndTag() throws JspException {
@@ -46,38 +56,20 @@ public class ArgumentTag extends BodyTagSupport {
argument = this.value;
}
else if (getBodyContent() != null) {
// get the value from the tag body
// Get the value from the tag body
argument = getBodyContent().getString().trim();
}
// find a param aware ancestor
ArgumentAware argumentAwareTag = (ArgumentAware) findAncestorWithClass(this,
ArgumentAware.class);
// Find a param-aware ancestor
ArgumentAware argumentAwareTag = (ArgumentAware) findAncestorWithClass(this, ArgumentAware.class);
if (argumentAwareTag == null) {
throw new JspException(
"The argument tag must be a descendant of a tag that supports arguments");
throw new JspException("The argument tag must be a descendant of a tag that supports arguments");
}
argumentAwareTag.addArgument(argument);
return EVAL_PAGE;
}
// tag attribute mutators
/**
* Sets the value of the argument
*
* <p>
* Optional. If not set, the tag's body content is evaluated.
*
* @param value the parameter value
*/
public void setValue(Object value) {
this.value = value;
this.valueSet = true;
}
@Override
public void release() {
super.release();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 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,7 +40,22 @@ public class ParamTag extends BodyTagSupport {
private boolean valueSet;
// tag lifecycle
/**
* Set the name of the parameter (required).
*/
public void setName(String name) {
this.name = name;
}
/**
* Set the value of the parameter (optional).
*/
public void setValue(String value) {
this.value = value;
this.valueSet = true;
}
@Override
public int doEndTag() throws JspException {
@@ -50,16 +65,14 @@ public class ParamTag extends BodyTagSupport {
param.setValue(this.value);
}
else if (getBodyContent() != null) {
// get the value from the tag body
// Get the value from the tag body
param.setValue(getBodyContent().getString().trim());
}
// find a param aware ancestor
ParamAware paramAwareTag = (ParamAware) findAncestorWithClass(this,
ParamAware.class);
// Find a param aware ancestor
ParamAware paramAwareTag = (ParamAware) findAncestorWithClass(this, ParamAware.class);
if (paramAwareTag == null) {
throw new JspException(
"The param tag must be a descendant of a tag that supports parameters");
throw new JspException("The param tag must be a descendant of a tag that supports parameters");
}
paramAwareTag.addParam(param);
@@ -67,33 +80,6 @@ public class ParamTag extends BodyTagSupport {
return EVAL_PAGE;
}
// tag attribute accessors
/**
* Sets the name of the parameter
*
* <p>
* Required
*
* @param name the parameter name
*/
public void setName(String name) {
this.name = name;
}
/**
* Sets the value of the parameter
*
* <p>
* Optional. If not set, the tag's body content is evaluated
*
* @param value the parameter value
*/
public void setValue(String value) {
this.value = value;
this.valueSet = true;
}
@Override
public void release() {
super.release();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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.
@@ -194,15 +194,18 @@ public class FormTag extends AbstractHtmlElementTag {
}
/**
* Set the value of the '{@code action}' attribute.
* Set the value of the '{@code action}' attribute through a value
* that is to be appended to the current servlet path.
* <p>May be a runtime expression.
* @since 3.2.3
*/
public void setServletRelativeAction(String servletRelativeaction) {
this.servletRelativeAction = (servletRelativeaction != null ? servletRelativeaction : "");
public void setServletRelativeAction(String servletRelativeAction) {
this.servletRelativeAction = (servletRelativeAction != null ? servletRelativeAction : "");
}
/**
* Get the value of the '{@code action}' attribute.
* Get the servlet-relative value of the '{@code action}' attribute.
* @since 3.2.3
*/
protected String getServletRelativeAction() {
return this.servletRelativeAction;
@@ -334,6 +337,7 @@ public class FormTag extends AbstractHtmlElementTag {
return ("get".equalsIgnoreCase(method) || "post".equalsIgnoreCase(method));
}
/**
* Writes the opening part of the block '{@code form}' tag and exposes
* the form object name in the {@link javax.servlet.jsp.PageContext}.

View File

@@ -30,9 +30,6 @@ import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.OrderComparator;
@@ -124,6 +121,10 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport
this.contentNegotiationManager = contentNegotiationManager;
}
/**
* Return the {@link ContentNegotiationManager} to use to determine requested media types.
* @since 4.1.9
*/
public ContentNegotiationManager getContentNegotiationManager() {
return this.contentNegotiationManager;
}
@@ -295,6 +296,7 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport
}
}
@Override
public View resolveViewName(String viewName, Locale locale) throws Exception {
RequestAttributes attrs = RequestContextHolder.getRequestAttributes();

View File

@@ -265,7 +265,7 @@
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Optional Attribute. Setting the value of this attribute to 'true' (without the quotes) will disable the HTML element.</description>
<description>HTML Optional Attribute. Setting the value of this attribute to 'true' will disable the HTML element.</description>
<name>disabled</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -379,7 +379,7 @@
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Optional Attribute. Setting the value of this attribute to 'true' (without the quotes) will make the HTML element readonly.</description>
<description>HTML Optional Attribute. Setting the value of this attribute to 'true' will make the HTML element readonly.</description>
<name>readonly</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -459,7 +459,7 @@
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Optional Attribute. Setting the value of this attribute to 'true' (without the quotes) will disable the HTML element.</description>
<description>HTML Optional Attribute. Setting the value of this attribute to 'true' will disable the HTML element.</description>
<name>disabled</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -573,7 +573,7 @@
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Optional Attribute. Setting the value of this attribute to 'true' (without the quotes) will make the HTML element readonly.</description>
<description>HTML Optional Attribute. Setting the value of this attribute to 'true' will make the HTML element readonly.</description>
<name>readonly</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -659,7 +659,7 @@
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Optional Attribute. Setting the value of this attribute to 'true' (without the quotes) will disable the HTML element.</description>
<description>HTML Optional Attribute. Setting the value of this attribute to 'true' will disable the HTML element.</description>
<name>disabled</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -793,7 +793,7 @@
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Optional Attribute. Setting the value of this attribute to 'true' (without the quotes) will disable the HTML element.</description>
<description>HTML Optional Attribute. Setting the value of this attribute to 'true' will disable the HTML element.</description>
<name>disabled</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -998,7 +998,7 @@
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Optional Attribute. Setting the value of this attribute to 'true' (without the quotes) will disable the HTML element.</description>
<description>HTML Optional Attribute. Setting the value of this attribute to 'true' (will disable the HTML element.</description>
<name>disabled</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -1144,7 +1144,7 @@
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<description>HTML Optional Attribute. Setting the value of this attribute to 'true' (without the quotes) will disable the HTML element.</description>
<description>HTML Optional Attribute. Setting the value of this attribute to 'true' will disable the HTML element.</description>
<name>disabled</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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.
@@ -30,7 +30,6 @@ import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.WebSocketMessage;
import org.springframework.web.socket.WebSocketSession;
/**
* Wraps a {@link org.springframework.web.socket.WebSocketSession} and guarantees
* only one thread can send messages at a time.
@@ -45,7 +44,7 @@ import org.springframework.web.socket.WebSocketSession;
*/
public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorator {
private static final Log logger = LogFactory.getLog("_" + ConcurrentWebSocketSessionDecorator.class.getName());
private static final Log logger = LogFactory.getLog(ConcurrentWebSocketSessionDecorator.class);
private final Queue<WebSocketMessage<?>> buffer = new LinkedBlockingQueue<WebSocketMessage<?>>();