Polishing

This commit is contained in:
Juergen Hoeller 2017-07-19 23:55:47 +02:00
parent 12978b8185
commit c752ba5b38
28 changed files with 228 additions and 233 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 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.
@ -22,7 +22,6 @@ import org.springframework.aop.Pointcut;
import org.springframework.aop.PointcutAdvisor;
import org.springframework.core.Ordered;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
/**
* AspectJPointcutAdvisor that adapts an {@link AbstractAspectJAdvice}
@ -51,11 +50,11 @@ public class AspectJPointcutAdvisor implements PointcutAdvisor, Ordered {
this.pointcut = advice.buildSafePointcut();
}
public void setOrder(int order) {
this.order = order;
}
@Override
public boolean isPerInstance() {
return true;
@ -91,12 +90,12 @@ public class AspectJPointcutAdvisor implements PointcutAdvisor, Ordered {
return false;
}
AspectJPointcutAdvisor otherAdvisor = (AspectJPointcutAdvisor) other;
return (ObjectUtils.nullSafeEquals(this.advice, otherAdvisor.advice));
return this.advice.equals(otherAdvisor.advice);
}
@Override
public int hashCode() {
return AspectJPointcutAdvisor.class.hashCode();
return AspectJPointcutAdvisor.class.hashCode() * 29 + this.advice.hashCode();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 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.
@ -21,8 +21,8 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.core.Ordered;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
/**
* Implementation of {@link AspectInstanceFactory} that locates the aspect from the
@ -50,9 +50,7 @@ public class SimpleBeanFactoryAwareAspectInstanceFactory implements AspectInstan
@Override
public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = beanFactory;
if (!StringUtils.hasText(this.aspectBeanName)) {
throw new IllegalArgumentException("'aspectBeanName' is required");
}
Assert.notNull(this.aspectBeanName, "'aspectBeanName' is required");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2017 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.
@ -89,7 +89,7 @@ public abstract class ScopedProxyUtils {
}
/**
* Generates the bean name that is used within the scoped proxy to reference the target bean.
* Generate the bean name that is used within the scoped proxy to reference the target bean.
* @param originalBeanName the original name of bean
* @return the generated bean to be used to reference the target bean
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 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.
@ -76,8 +76,7 @@ public class BeanComponentDefinition extends BeanDefinitionHolder implements Com
List<BeanDefinition> innerBeans = new ArrayList<BeanDefinition>();
List<BeanReference> references = new ArrayList<BeanReference>();
PropertyValues propertyValues = beanDefinition.getPropertyValues();
for (int i = 0; i < propertyValues.getPropertyValues().length; i++) {
PropertyValue propertyValue = propertyValues.getPropertyValues()[i];
for (PropertyValue propertyValue : propertyValues.getPropertyValues()) {
Object value = propertyValue.getValue();
if (value instanceof BeanDefinitionHolder) {
innerBeans.add(((BeanDefinitionHolder) value).getBeanDefinition());

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2017 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.
@ -54,7 +54,7 @@ public abstract class AbstractCacheResolver implements CacheResolver, Initializi
}
/**
* Return the {@link CacheManager} that this instance use.
* Return the {@link CacheManager} that this instance uses.
*/
public CacheManager getCacheManager() {
return this.cacheManager;
@ -62,7 +62,7 @@ public abstract class AbstractCacheResolver implements CacheResolver, Initializi
@Override
public void afterPropertiesSet() {
Assert.notNull(this.cacheManager, "CacheManager must not be null");
Assert.notNull(this.cacheManager, "CacheManager is required");
}
@ -75,7 +75,7 @@ public abstract class AbstractCacheResolver implements CacheResolver, Initializi
else {
Collection<Cache> result = new ArrayList<Cache>();
for (String cacheName : cacheNames) {
Cache cache = this.cacheManager.getCache(cacheName);
Cache cache = getCacheManager().getCache(cacheName);
if (cache == null) {
throw new IllegalArgumentException("Cannot find cache named '" +
cacheName + "' for " + context.getOperation());
@ -91,7 +91,7 @@ public abstract class AbstractCacheResolver implements CacheResolver, Initializi
* <p>It is acceptable to return {@code null} to indicate that no cache could
* be resolved for this invocation.
* @param context the context of the particular invocation
* @return the cache name(s) to resolve or {@code null} if no cache should be resolved
* @return the cache name(s) to resolve, or {@code null} if no cache should be resolved
*/
protected abstract Collection<String> getCacheNames(CacheOperationInvocationContext<?> context);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@ -16,7 +16,6 @@
package org.springframework.cache.interceptor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -34,13 +33,15 @@ public class NamedCacheResolver extends AbstractCacheResolver {
private Collection<String> cacheNames;
public NamedCacheResolver() {
}
public NamedCacheResolver(CacheManager cacheManager, String... cacheNames) {
super(cacheManager);
this.cacheNames = new ArrayList<String>(Arrays.asList(cacheNames));
}
public NamedCacheResolver() {
}
/**
* Set the cache name(s) that this resolver should use.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2017 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.
@ -17,6 +17,7 @@
package org.springframework.cache.support;
import java.util.Collection;
import java.util.Collections;
import org.springframework.cache.Cache;
@ -29,7 +30,7 @@ import org.springframework.cache.Cache;
*/
public class SimpleCacheManager extends AbstractCacheManager {
private Collection<? extends Cache> caches;
private Collection<? extends Cache> caches = Collections.emptySet();
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 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.
@ -51,7 +51,9 @@ public class TypeMismatchNamingException extends NamingException {
/**
* Construct a new TypeMismatchNamingException.
* @param explanation the explanation text
* @deprecated as of Spring Framework 4.3.10
*/
@Deprecated
public TypeMismatchNamingException(String explanation) {
super(explanation);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2017 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.
@ -49,8 +49,8 @@ public class ScopedProxyTests {
private static final ClassPathResource OVERRIDE_CONTEXT = new ClassPathResource(CLASSNAME + "-override.xml", CLASS);
private static final ClassPathResource TESTBEAN_CONTEXT = new ClassPathResource(CLASSNAME + "-testbean.xml", CLASS);
/* SPR-2108 */
@Test
@Test // SPR-2108
public void testProxyAssignable() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(MAP_CONTEXT);

View File

@ -6,16 +6,16 @@
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean" scope="request">
<aop:scoped-proxy proxy-target-class="false"/>
<property name="age" value="99"/>
</bean>
<aop:scoped-proxy proxy-target-class="false"/>
<property name="age" value="99"/>
</bean>
<bean class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
<property name="properties">
<map>
<entry key="testBean.sex" value="male"/>
</map>
</property>
</bean>
<bean class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
<property name="properties">
<map>
<entry key="testBean.sex" value="male"/>
</map>
</property>
</bean>
</beans>

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@ -51,8 +51,7 @@ public class PathResource extends AbstractResource implements WritableResource {
* Create a new PathResource from a Path handle.
* <p>Note: Unlike {@link FileSystemResource}, when building relative resources
* via {@link #createRelative}, the relative path will be built <i>underneath</i>
* the given root:
* e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
* the given root: e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
* @param path a Path handle
*/
public PathResource(Path path) {
@ -64,8 +63,7 @@ public class PathResource extends AbstractResource implements WritableResource {
* Create a new PathResource from a Path handle.
* <p>Note: Unlike {@link FileSystemResource}, when building relative resources
* via {@link #createRelative}, the relative path will be built <i>underneath</i>
* the given root:
* e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
* the given root: e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
* @param path a path
* @see java.nio.file.Paths#get(String, String...)
*/
@ -78,8 +76,7 @@ public class PathResource extends AbstractResource implements WritableResource {
* Create a new PathResource from a Path handle.
* <p>Note: Unlike {@link FileSystemResource}, when building relative resources
* via {@link #createRelative}, the relative path will be built <i>underneath</i>
* the given root:
* e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
* the given root: e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
* @see java.nio.file.Paths#get(URI)
* @param uri a path URI
*/
@ -184,7 +181,7 @@ public class PathResource extends AbstractResource implements WritableResource {
catch (UnsupportedOperationException ex) {
// Only paths on the default file system can be converted to a File:
// Do exception translation for cases where conversion is not possible.
throw new FileNotFoundException(this.path + " cannot be resolved to " + "absolute file path");
throw new FileNotFoundException(this.path + " cannot be resolved to absolute file path");
}
}
@ -204,11 +201,11 @@ public class PathResource extends AbstractResource implements WritableResource {
public long lastModified() throws IOException {
// We can not use the superclass method since it uses conversion to a File and
// only a Path on the default file system can be converted to a File...
return Files.getLastModifiedTime(path).toMillis();
return Files.getLastModifiedTime(this.path).toMillis();
}
/**
* This implementation creates a FileResource, applying the given path
* This implementation creates a PathResource, applying the given path
* relative to the path of the underlying file of this resource descriptor.
* @see java.nio.file.Path#resolve(String)
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2017 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.
@ -51,17 +51,6 @@ class StaxResult extends SAXResult {
private XMLStreamWriter streamWriter;
/**
* Construct a new instance of the {@code StaxResult} with the specified {@code XMLStreamWriter}.
* @param streamWriter the {@code XMLStreamWriter} to write to
*/
public StaxResult(XMLStreamWriter streamWriter) {
StaxStreamHandler handler = new StaxStreamHandler(streamWriter);
super.setHandler(handler);
super.setLexicalHandler(handler);
this.streamWriter = streamWriter;
}
/**
* Construct a new instance of the {@code StaxResult} with the specified {@code XMLEventWriter}.
* @param eventWriter the {@code XMLEventWriter} to write to
@ -73,10 +62,22 @@ class StaxResult extends SAXResult {
this.eventWriter = eventWriter;
}
/**
* Construct a new instance of the {@code StaxResult} with the specified {@code XMLStreamWriter}.
* @param streamWriter the {@code XMLStreamWriter} to write to
*/
public StaxResult(XMLStreamWriter streamWriter) {
StaxStreamHandler handler = new StaxStreamHandler(streamWriter);
super.setHandler(handler);
super.setLexicalHandler(handler);
this.streamWriter = streamWriter;
}
/**
* Return the {@code XMLEventWriter} used by this {@code StaxResult}. If this {@code StaxResult}
* was created with an {@code XMLStreamWriter}, the result will be {@code null}.
* Return the {@code XMLEventWriter} used by this {@code StaxResult}.
* <p>If this {@code StaxResult} was created with an {@code XMLStreamWriter},
* the result will be {@code null}.
* @return the StAX event writer used by this result
* @see #StaxResult(javax.xml.stream.XMLEventWriter)
*/
@ -85,8 +86,9 @@ class StaxResult extends SAXResult {
}
/**
* Return the {@code XMLStreamWriter} used by this {@code StaxResult}. If this {@code StaxResult}
* was created with an {@code XMLEventConsumer}, the result will be {@code null}.
* Return the {@code XMLStreamWriter} used by this {@code StaxResult}.
* <p>If this {@code StaxResult} was created with an {@code XMLEventConsumer},
* the result will be {@code null}.
* @return the StAX stream writer used by this result
* @see #StaxResult(javax.xml.stream.XMLStreamWriter)
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2017 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.
@ -50,18 +50,6 @@ class StaxSource extends SAXSource {
private XMLStreamReader streamReader;
/**
* Construct a new instance of the {@code StaxSource} with the specified {@code XMLStreamReader}.
* The supplied stream reader must be in {@code XMLStreamConstants.START_DOCUMENT} or
* {@code XMLStreamConstants.START_ELEMENT} state.
* @param streamReader the {@code XMLStreamReader} to read from
* @throws IllegalStateException if the reader is not at the start of a document or element
*/
StaxSource(XMLStreamReader streamReader) {
super(new StaxStreamXMLReader(streamReader), new InputSource());
this.streamReader = streamReader;
}
/**
* Construct a new instance of the {@code StaxSource} with the specified {@code XMLEventReader}.
* The supplied event reader must be in {@code XMLStreamConstants.START_DOCUMENT} or
@ -74,10 +62,23 @@ class StaxSource extends SAXSource {
this.eventReader = eventReader;
}
/**
* Construct a new instance of the {@code StaxSource} with the specified {@code XMLStreamReader}.
* The supplied stream reader must be in {@code XMLStreamConstants.START_DOCUMENT} or
* {@code XMLStreamConstants.START_ELEMENT} state.
* @param streamReader the {@code XMLStreamReader} to read from
* @throws IllegalStateException if the reader is not at the start of a document or element
*/
StaxSource(XMLStreamReader streamReader) {
super(new StaxStreamXMLReader(streamReader), new InputSource());
this.streamReader = streamReader;
}
/**
* Return the {@code XMLEventReader} used by this {@code StaxSource}. If this {@code StaxSource}
* was created with an {@code XMLStreamReader}, the result will be {@code null}.
* Return the {@code XMLEventReader} used by this {@code StaxSource}.
* <p>If this {@code StaxSource} was created with an {@code XMLStreamReader},
* the result will be {@code null}.
* @return the StAX event reader used by this source
* @see StaxSource#StaxSource(javax.xml.stream.XMLEventReader)
*/
@ -86,8 +87,9 @@ class StaxSource extends SAXSource {
}
/**
* Return the {@code XMLStreamReader} used by this {@code StaxSource}. If this {@code StaxSource}
* was created with an {@code XMLEventReader}, the result will be {@code null}.
* Return the {@code XMLStreamReader} used by this {@code StaxSource}.
* <p>If this {@code StaxSource} was created with an {@code XMLEventReader},
* the result will be {@code null}.
* @return the StAX event reader used by this source
* @see StaxSource#StaxSource(javax.xml.stream.XMLEventReader)
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@ -26,7 +26,6 @@ import org.springframework.expression.spel.SpelEvaluationException;
import org.springframework.expression.spel.SpelMessage;
import org.springframework.expression.spel.support.BooleanTypedValue;
/**
* The operator 'instanceof' checks if an object is of the class specified in the right
* hand operand, in the same way that {@code instanceof} does in Java.
@ -38,6 +37,7 @@ public class OperatorInstanceof extends Operator {
private Class<?> type;
public OperatorInstanceof(int pos, SpelNodeImpl... operands) {
super("instanceof", pos, operands);
}
@ -47,8 +47,8 @@ public class OperatorInstanceof extends Operator {
* Compare the left operand to see it is an instance of the type specified as the
* right operand. The right operand must be a class.
* @param state the expression state
* @return true if the left operand is an instanceof of the right operand, otherwise
* false
* @return {@code true} if the left operand is an instanceof of the right operand,
* otherwise {@code false}
* @throws EvaluationException if there is a problem evaluating the expression
*/
@Override
@ -58,7 +58,7 @@ public class OperatorInstanceof extends Operator {
TypedValue right = rightOperand.getValueInternal(state);
Object leftValue = left.getValue();
Object rightValue = right.getValue();
BooleanTypedValue result = null;
BooleanTypedValue result;
if (rightValue == null || !(rightValue instanceof Class)) {
throw new SpelEvaluationException(getRightOperand().getStartPosition(),
SpelMessage.INSTANCEOF_OPERATOR_NEEDS_CLASS_OPERAND,
@ -96,7 +96,7 @@ public class OperatorInstanceof extends Operator {
mv.visitInsn(ICONST_0); // value of false
}
else {
mv.visitTypeInsn(INSTANCEOF,Type.getInternalName(this.type));
mv.visitTypeInsn(INSTANCEOF, Type.getInternalName(this.type));
}
cf.pushDescriptor(this.exitTypeDescriptor);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2017 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.
@ -38,11 +38,11 @@ public class TypeReference extends SpelNodeImpl {
public TypeReference(int pos, SpelNodeImpl qualifiedId) {
this(pos,qualifiedId,0);
this(pos, qualifiedId, 0);
}
public TypeReference(int pos, SpelNodeImpl qualifiedId, int dims) {
super(pos,qualifiedId);
super(pos, qualifiedId);
this.dimensions = dims;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 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,21 +23,22 @@ import java.sql.SQLException;
import org.springframework.jdbc.support.JdbcUtils;
/**
* Implementation of RowCallbackHandler. Convenient superclass for callback handlers.
* An instance can only be used once.
* Implementation of {@link RowCallbackHandler}. An instance can only be used once.
*
* <p>We can either use this on its own (for example, in a test case, to ensure
* that our result sets have valid dimensions), or use it as a superclass
* for callback handlers that actually do something, and will benefit
* from the dimension information it provides.
* that our result sets have valid dimensions), or use it as a superclass for
* callback handlers that actually do something, and will benefit from the
* dimension information it provides.
*
* <p>A usage example with JdbcTemplate:
* <p>A usage example with {@link JdbcTemplate}:
*
* <pre class="code">JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); // reusable object
* <pre class="code">
* JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); // reusable object
*
* RowCountCallbackHandler countCallback = new RowCountCallbackHandler(); // not reusable
* jdbcTemplate.query("select * from user", countCallback);
* int rowCount = countCallback.getRowCount();</pre>
* int rowCount = countCallback.getRowCount();
* </pre>
*
* @author Rod Johnson
* @since May 3, 2001
@ -63,7 +64,6 @@ public class RowCountCallbackHandler implements RowCallbackHandler {
/**
* Implementation of ResultSetCallbackHandler.
* Work out column size if this is the first row, otherwise just count rows.
* <p>Subclasses can perform custom extraction or processing
* by overriding the {@code processRow(ResultSet, int)} method.
@ -103,7 +103,7 @@ public class RowCountCallbackHandler implements RowCallbackHandler {
* <b>Indexed from 0 to n-1.</b>
*/
public final int[] getColumnTypes() {
return columnTypes;
return this.columnTypes;
}
/**
@ -113,7 +113,7 @@ public class RowCountCallbackHandler implements RowCallbackHandler {
* <b>Indexed from 0 to n-1.</b>
*/
public final String[] getColumnNames() {
return columnNames;
return this.columnNames;
}
/**
@ -122,7 +122,7 @@ public class RowCountCallbackHandler implements RowCallbackHandler {
* @return the number of rows in this ResultSet
*/
public final int getRowCount() {
return rowCount;
return this.rowCount;
}
/**
@ -132,7 +132,7 @@ public class RowCountCallbackHandler implements RowCallbackHandler {
* @return the number of columns in this result set
*/
public final int getColumnCount() {
return columnCount;
return this.columnCount;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2017 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.
@ -47,13 +47,13 @@ public class TableMetaDataContext {
/** Logger available to subclasses */
protected final Log logger = LogFactory.getLog(getClass());
/** name of table for this context **/
/** Name of table for this context */
private String tableName;
/** name of catalog for this context **/
/** Name of catalog for this context */
private String catalogName;
/** name of schema for this context **/
/** Name of schema for this context */
private String schemaName;
/** List of columns objects to be used in this context */
@ -153,40 +153,6 @@ public class TableMetaDataContext {
return this.tableColumns;
}
/**
* Does this database support the JDBC 3.0 feature of retrieving generated keys
* {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}?
*/
public boolean isGetGeneratedKeysSupported() {
return this.metaDataProvider.isGetGeneratedKeysSupported();
}
/**
* Does this database support simple query to retrieve generated keys
* when the JDBC 3.0 feature is not supported.
* {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}?
*/
public boolean isGetGeneratedKeysSimulated() {
return this.metaDataProvider.isGetGeneratedKeysSimulated();
}
/**
* Does this database support simple query to retrieve generated keys
* when the JDBC 3.0 feature is not supported.
* {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}?
*/
public String getSimulationQueryForGetGeneratedKey(String tableName, String keyColumnName) {
return this.metaDataProvider.getSimpleQueryForGetGeneratedKey(tableName, keyColumnName);
}
/**
* Is a column name String array for retrieving generated keys supported?
* {@link java.sql.Connection#createStruct(String, Object[])}?
*/
public boolean isGeneratedKeysColumnNameArraySupported() {
return this.metaDataProvider.isGeneratedKeysColumnNameArraySupported();
}
/**
* Set {@link NativeJdbcExtractor} to be used to retrieve the native connection.
*/
@ -224,7 +190,7 @@ public class TableMetaDataContext {
keys.add(key.toUpperCase());
}
List<String> columns = new ArrayList<String>();
for (TableParameterMetaData meta : metaDataProvider.getTableParameterMetaData()) {
for (TableParameterMetaData meta : this.metaDataProvider.getTableParameterMetaData()) {
if (!keys.contains(meta.getParameterName().toUpperCase())) {
columns.add(meta.getParameterName());
}
@ -368,4 +334,39 @@ public class TableMetaDataContext {
return types;
}
/**
* Does this database support the JDBC 3.0 feature of retrieving generated keys
* {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}?
*/
public boolean isGetGeneratedKeysSupported() {
return this.metaDataProvider.isGetGeneratedKeysSupported();
}
/**
* Does this database support simple query to retrieve generated keys
* when the JDBC 3.0 feature is not supported.
* {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}?
*/
public boolean isGetGeneratedKeysSimulated() {
return this.metaDataProvider.isGetGeneratedKeysSimulated();
}
/**
* Does this database support simple query to retrieve generated keys
* when the JDBC 3.0 feature is not supported.
* {@link java.sql.DatabaseMetaData#supportsGetGeneratedKeys()}?
*/
public String getSimulationQueryForGetGeneratedKey(String tableName, String keyColumnName) {
return this.metaDataProvider.getSimpleQueryForGetGeneratedKey(tableName, keyColumnName);
}
/**
* Is a column name String array for retrieving generated keys supported?
* {@link java.sql.Connection#createStruct(String, Object[])}?
*/
public boolean isGeneratedKeysColumnNameArraySupported() {
return this.metaDataProvider.isGeneratedKeysColumnNameArraySupported();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -34,12 +34,12 @@ import org.springframework.util.Assert;
* connection pool, implementing the same standard interface, but creating new
* Connections on every call.
*
* <p>In a J2EE container, it is recommended to use a JNDI DataSource provided by
* <p>In a Java EE container, it is recommended to use a JNDI DataSource provided by
* the container. Such a DataSource can be exposed as a DataSource bean in a Spring
* ApplicationContext via {@link org.springframework.jndi.JndiObjectFactoryBean},
* for seamless switching to and from a local DataSource bean like this class.
*
* <p>If you need a "real" connection pool outside of a J2EE container, consider
* <p>If you need a "real" connection pool outside of a Java EE container, consider
* <a href="http://commons.apache.org/proper/commons-dbcp">Apache Commons DBCP</a>
* or <a href="http://sourceforge.net/projects/c3p0">C3P0</a>.
* Commons DBCP's BasicDataSource and C3P0's ComboPooledDataSource are full

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@ -77,10 +77,10 @@ import org.springframework.util.Assert;
public class TransactionAwareConnectionFactoryProxy
implements ConnectionFactory, QueueConnectionFactory, TopicConnectionFactory {
private boolean synchedLocalTransactionAllowed = false;
private ConnectionFactory targetConnectionFactory;
private boolean synchedLocalTransactionAllowed = false;
/**
* Create a new TransactionAwareConnectionFactoryProxy.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2017 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,20 +40,12 @@ public class IdTimestampMessageHeaderInitializer implements MessageHeaderInitial
* instances with.
* <p>By default this property is set to {@code null} in which case the default
* IdGenerator of {@link org.springframework.messaging.MessageHeaders} is used.
* <p>To have no id's generated at all, see {@link #setDisableIdGeneration()}.
* <p>To have no ids generated at all, see {@link #setDisableIdGeneration()}.
*/
public void setIdGenerator(IdGenerator idGenerator) {
this.idGenerator = idGenerator;
}
/**
* A shortcut for calling {@link #setIdGenerator(org.springframework.util.IdGenerator)}
* with an id generation strategy to disable id generation completely.
*/
public void setDisableIdGeneration() {
this.idGenerator = ID_VALUE_NONE_GENERATOR;
}
/**
* Return the configured {@code IdGenerator}, if any.
*/
@ -61,6 +53,14 @@ public class IdTimestampMessageHeaderInitializer implements MessageHeaderInitial
return this.idGenerator;
}
/**
* A shortcut for calling {@link #setIdGenerator} with an id generation strategy
* to disable id generation completely.
*/
public void setDisableIdGeneration() {
this.idGenerator = ID_VALUE_NONE_GENERATOR;
}
/**
* Whether to enable the automatic addition of the
* {@link org.springframework.messaging.MessageHeaders#TIMESTAMP} header on

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 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.
@ -60,22 +60,22 @@ public class CommAreaRecord implements Record, Streamable {
@Override
public void setRecordName(String recordName) {
this.recordName=recordName;
this.recordName = recordName;
}
@Override
public String getRecordName() {
return recordName;
return this.recordName;
}
@Override
public void setRecordShortDescription(String recordShortDescription) {
this.recordShortDescription=recordShortDescription;
this.recordShortDescription = recordShortDescription;
}
@Override
public String getRecordShortDescription() {
return recordShortDescription;
return this.recordShortDescription;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2017 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.
@ -46,12 +46,13 @@ public class AsyncHttpAccessor {
private AsyncClientHttpRequestFactory asyncRequestFactory;
/**
* Set the request factory that this accessor uses for obtaining {@link
* org.springframework.http.client.ClientHttpRequest HttpRequests}.
*/
public void setAsyncRequestFactory(AsyncClientHttpRequestFactory asyncRequestFactory) {
Assert.notNull(asyncRequestFactory, "'asyncRequestFactory' must not be null");
Assert.notNull(asyncRequestFactory, "AsyncClientHttpRequestFactory must not be null");
this.asyncRequestFactory = asyncRequestFactory;
}
@ -64,15 +65,14 @@ public class AsyncHttpAccessor {
}
/**
* Create a new {@link AsyncClientHttpRequest} via this template's {@link
* AsyncClientHttpRequestFactory}.
* Create a new {@link AsyncClientHttpRequest} via this template's
* {@link AsyncClientHttpRequestFactory}.
* @param url the URL to connect to
* @param method the HTTP method to execute (GET, POST, etc.)
* @return the created request
* @throws IOException in case of I/O errors
*/
protected AsyncClientHttpRequest createAsyncRequest(URI url, HttpMethod method)
throws IOException {
protected AsyncClientHttpRequest createAsyncRequest(URI url, HttpMethod method) throws IOException {
AsyncClientHttpRequest request = getAsyncRequestFactory().createAsyncRequest(url, method);
if (logger.isDebugEnabled()) {
logger.debug("Created asynchronous " + method.name() + " request for \"" + url + "\"");

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 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,6 +39,7 @@ public class LiveBeansViewServlet extends HttpServlet {
private LiveBeansView liveBeansView;
@Override
public void init() throws ServletException {
this.liveBeansView = buildLiveBeansView();
@ -49,7 +50,9 @@ public class LiveBeansViewServlet extends HttpServlet {
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String content = this.liveBeansView.getSnapshotAsJson();
response.setContentType("application/json");
response.setContentLength(content.length());

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 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.
@ -65,16 +65,18 @@ public class ServletContextAttributeExporter implements ServletContextAware {
@Override
public void setServletContext(ServletContext servletContext) {
for (Map.Entry<String, Object> entry : attributes.entrySet()) {
String attributeName = entry.getKey();
if (logger.isWarnEnabled()) {
if (servletContext.getAttribute(attributeName) != null) {
logger.warn("Replacing existing ServletContext attribute with name '" + attributeName + "'");
if (this.attributes != null) {
for (Map.Entry<String, Object> entry : this.attributes.entrySet()) {
String attributeName = entry.getKey();
if (logger.isWarnEnabled()) {
if (servletContext.getAttribute(attributeName) != null) {
logger.warn("Replacing existing ServletContext attribute with name '" + attributeName + "'");
}
}
servletContext.setAttribute(attributeName, entry.getValue());
if (logger.isInfoEnabled()) {
logger.info("Exported ServletContext attribute with name '" + attributeName + "'");
}
}
servletContext.setAttribute(attributeName, entry.getValue());
if (logger.isInfoEnabled()) {
logger.info("Exported ServletContext attribute with name '" + attributeName + "'");
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@ -85,19 +85,17 @@ public class SessionAttributesHandler {
* session attributes through an {@link SessionAttributes} annotation.
*/
public boolean hasSessionAttributes() {
return (this.attributeNames.size() > 0 || this.attributeTypes.size() > 0);
return (!this.attributeNames.isEmpty() || !this.attributeTypes.isEmpty());
}
/**
* Whether the attribute name or type match the names and types specified
* via {@code @SessionAttributes} in underlying controller.
*
* <p>Attributes successfully resolved through this method are "remembered"
* and subsequently used in {@link #retrieveAttributes(WebRequest)} and
* {@link #cleanupAttributes(WebRequest)}.
*
* @param attributeName the attribute name to check, never {@code null}
* @param attributeType the type for the attribute, possibly {@code null}
* @param attributeName the attribute name to check
* @param attributeType the type for the attribute
*/
public boolean isHandlerSessionAttribute(String attributeName, Class<?> attributeType) {
Assert.notNull(attributeName, "Attribute name must not be null");
@ -120,7 +118,6 @@ public class SessionAttributesHandler {
for (String name : attributes.keySet()) {
Object value = attributes.get(name);
Class<?> attrType = (value != null) ? value.getClass() : null;
if (isHandlerSessionAttribute(name, attrType)) {
this.sessionAttributeStore.storeAttribute(request, name, value);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2017 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.
@ -49,12 +49,11 @@ public class RedirectViewControllerRegistration {
/**
* Set the specific redirect 3xx status code to use.
*
* <p>If not set, {@link org.springframework.web.servlet.view.RedirectView}
* will select {@code HttpStatus.MOVED_TEMPORARILY (302)} by default.
*/
public RedirectViewControllerRegistration setStatusCode(HttpStatus statusCode) {
Assert.isTrue(statusCode.is3xxRedirection(), "Not a redirect status code.");
Assert.isTrue(statusCode.is3xxRedirection(), "Not a redirect status code");
this.redirectView.setStatusCode(statusCode);
return this;
}
@ -63,7 +62,6 @@ public class RedirectViewControllerRegistration {
* Whether to interpret a given redirect URL that starts with a slash ("/")
* as relative to the current ServletContext, i.e. as relative to the web
* application root.
*
* <p>Default is {@code true}.
*/
public RedirectViewControllerRegistration setContextRelative(boolean contextRelative) {
@ -74,7 +72,6 @@ public class RedirectViewControllerRegistration {
/**
* Whether to propagate the query parameters of the current request through
* to the target redirect URL.
*
* <p>Default is {@code false}.
*/
public RedirectViewControllerRegistration setKeepQueryParams(boolean propagate) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2017 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.
@ -19,6 +19,7 @@ package org.springframework.web.servlet.handler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.util.ObjectUtils;
import org.springframework.util.PathMatcher;
import org.springframework.web.context.request.WebRequestInterceptor;
import org.springframework.web.servlet.HandlerInterceptor;
@ -99,15 +100,13 @@ public final class MappedInterceptor implements HandlerInterceptor {
* method. This is an advanced property that is only required when using custom
* PathMatcher implementations that support mapping metadata other than the
* Ant-style path patterns supported by default.
*
* @param pathMatcher the path matcher to use
*/
public void setPathMatcher(PathMatcher pathMatcher) {
this.pathMatcher = pathMatcher;
}
/**
* The configured PathMatcher, or {@code null}.
* The configured PathMatcher, or {@code null} if none.
*/
public PathMatcher getPathMatcher() {
return this.pathMatcher;
@ -127,21 +126,6 @@ public final class MappedInterceptor implements HandlerInterceptor {
return this.interceptor;
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
return this.interceptor.preHandle(request, response, handler);
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
this.interceptor.postHandle(request, response, handler, modelAndView);
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
this.interceptor.afterCompletion(request, response, handler, ex);
}
/**
* Returns {@code true} if the interceptor applies to the given request path.
* @param lookupPath the current request path
@ -156,7 +140,7 @@ public final class MappedInterceptor implements HandlerInterceptor {
}
}
}
if (this.includePatterns == null) {
if (ObjectUtils.isEmpty(this.includePatterns)) {
return true;
}
else {
@ -168,4 +152,26 @@ public final class MappedInterceptor implements HandlerInterceptor {
return false;
}
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
return this.interceptor.preHandle(request, response, handler);
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
this.interceptor.postHandle(request, response, handler, modelAndView);
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler,
Exception ex) throws Exception {
this.interceptor.afterCompletion(request, response, handler, ex);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.socket.config.annotation;
package org.springframework.web.socket.config.annotation;
import java.util.ArrayList;
import java.util.Arrays;
@ -44,16 +44,13 @@ public class WebSocketTransportRegistration {
* Configure the maximum size for an incoming sub-protocol message.
* For example a STOMP message may be received as multiple WebSocket messages
* or multiple HTTP POST requests when SockJS fallback options are in use.
*
* <p>In theory a WebSocket message can be almost unlimited in size.
* In practice WebSocket servers impose limits on incoming message size.
* STOMP clients for example tend to split large messages around 16K
* boundaries. Therefore a server must be able to buffer partial content
* and decode when enough data is received. Use this property to configure
* the max size of the buffer to use.
*
* <p>The default value is 64K (i.e. 64 * 1024).
*
* <p><strong>NOTE</strong> that the current version 1.2 of the STOMP spec
* does not specifically discuss how to send STOMP messages over WebSocket.
* Version 2 of the spec will but in the mean time existing client libraries
@ -75,7 +72,6 @@ public class WebSocketTransportRegistration {
* Configure a time limit (in milliseconds) for the maximum amount of a time
* allowed when sending messages to a WebSocket session or writing to an
* HTTP response when SockJS fallback option are in use.
*
* <p>In general WebSocket servers expect that messages to a single WebSocket
* session are sent from a single thread at a time. This is automatically
* guaranteed when using {@code @EnableWebSocketMessageBroker} configuration.
@ -83,14 +79,12 @@ public class WebSocketTransportRegistration {
* subsequent messages are buffered until either the {@code sendTimeLimit}
* or the {@code sendBufferSizeLimit} are reached at which point the session
* state is cleared and an attempt is made to close the session.
*
* <p><strong>NOTE</strong> that the session time limit is checked only
* on attempts to send additional messages. So if only a single message is
* sent and it hangs, the session will not time out until another message is
* sent or the underlying physical socket times out. So this is not a
* replacement for WebSocket server or HTTP connection timeout but is rather
* intended to control the extent of buffering of unsent messages.
*
* <p><strong>NOTE</strong> that closing the session may not succeed in
* actually closing the physical socket and may also hang. This is true
* especially when using blocking IO such as the BIO connector in Tomcat
@ -99,11 +93,9 @@ public class WebSocketTransportRegistration {
* is used by default on Tomcat 8. If you must use blocking IO consider
* customizing OS-level TCP settings, for example
* {@code /proc/sys/net/ipv4/tcp_retries2} on Linux.
*
* <p>The default value is 10 seconds (i.e. 10 * 10000).
*
* @param timeLimit the timeout value in milliseconds; the value must be
* greater than 0, otherwise it is ignored.
* greater than 0, otherwise it is ignored.
*/
public WebSocketTransportRegistration setSendTimeLimit(int timeLimit) {
this.sendTimeLimit = timeLimit;
@ -121,7 +113,6 @@ public class WebSocketTransportRegistration {
* Configure the maximum amount of data to buffer when sending messages
* to a WebSocket session, or an HTTP response when SockJS fallback
* option are in use.
*
* <p>In general WebSocket servers expect that messages to a single WebSocket
* session are sent from a single thread at a time. This is automatically
* guaranteed when using {@code @EnableWebSocketMessageBroker} configuration.
@ -129,7 +120,6 @@ public class WebSocketTransportRegistration {
* subsequent messages are buffered until either the {@code sendTimeLimit}
* or the {@code sendBufferSizeLimit} are reached at which point the session
* state is cleared and an attempt is made to close the session.
*
* <p><strong>NOTE</strong> that closing the session may not succeed in
* actually closing the physical socket and may also hang. This is true
* especially when using blocking IO such as the BIO connector in Tomcat
@ -138,12 +128,10 @@ public class WebSocketTransportRegistration {
* by default on Tomcat 8. If you must use blocking IO consider customizing
* OS-level TCP settings, for example {@code /proc/sys/net/ipv4/tcp_retries2}
* on Linux.
*
* <p>The default value is 512K (i.e. 512 * 1024).
*
* @param sendBufferSizeLimit the maximum number of bytes to buffer when
* sending messages; if the value is less than or equal to 0 then buffering
* is effectively disabled.
* sending messages; if the value is less than or equal to 0 then buffering
* is effectively disabled.
*/
public WebSocketTransportRegistration setSendBufferSizeLimit(int sendBufferSizeLimit) {
this.sendBufferSizeLimit = sendBufferSizeLimit;