Polishing

This commit is contained in:
Juergen Hoeller
2019-03-13 15:32:24 +01:00
parent d9bc3b7e38
commit 2afaaf270d
8 changed files with 36 additions and 33 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 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.
@@ -298,9 +298,9 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
* @param expectedType type for the bean * @param expectedType type for the bean
* @return the bean matching that name * @return the bean matching that name
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException if such bean does not exist * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException if such bean does not exist
* @see CacheOperation#keyGenerator * @see CacheOperation#getKeyGenerator()
* @see CacheOperation#cacheManager * @see CacheOperation#getCacheManager()
* @see CacheOperation#cacheResolver * @see CacheOperation#getCacheResolver()
*/ */
protected <T> T getBean(String beanName, Class<T> expectedType) { protected <T> T getBean(String beanName, Class<T> expectedType) {
return BeanFactoryAnnotationUtils.qualifiedBeanOfType(this.beanFactory, expectedType, beanName); return BeanFactoryAnnotationUtils.qualifiedBeanOfType(this.beanFactory, expectedType, beanName);
@@ -329,8 +329,8 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
/** /**
* Execute the underlying operation (typically in case of cache miss) and return * Execute the underlying operation (typically in case of cache miss) and return
* the result of the invocation. If an exception occurs it will be wrapped in * the result of the invocation. If an exception occurs it will be wrapped in a
* a {@link CacheOperationInvoker.ThrowableWrapper}: the exception can be handled * {@link CacheOperationInvoker.ThrowableWrapper}: the exception can be handled
* or modified but it <em>must</em> be wrapped in a * or modified but it <em>must</em> be wrapped in a
* {@link CacheOperationInvoker.ThrowableWrapper} as well. * {@link CacheOperationInvoker.ThrowableWrapper} as well.
* @param invoker the invoker handling the operation being cached * @param invoker the invoker handling the operation being cached

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2019 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.
@@ -25,13 +25,14 @@ import java.util.Collection;
* source level, or elsewhere. * source level, or elsewhere.
* *
* @author Costin Leau * @author Costin Leau
* @author Juergen Hoeller
* @since 3.1 * @since 3.1
*/ */
public interface CacheOperationSource { public interface CacheOperationSource {
/** /**
* Return the collection of cache operations for this method, or {@code null} * Return the collection of cache operations for this method,
* if the method contains no <em>cacheable</em> annotations. * or {@code null} if the method contains no <em>cacheable</em> annotations.
* @param method the method to introspect * @param method the method to introspect
* @param targetClass the target class (may be {@code null}, in which case * @param targetClass the target class (may be {@code null}, in which case
* the declaring class of the method must be used) * the declaring class of the method must be used)

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2019 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.
@@ -28,6 +28,7 @@ import org.springframework.util.Assert;
* over a given array of {@code CacheOperationSource} instances. * over a given array of {@code CacheOperationSource} instances.
* *
* @author Costin Leau * @author Costin Leau
* @author Juergen Hoeller
* @since 3.1 * @since 3.1
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -41,7 +42,7 @@ public class CompositeCacheOperationSource implements CacheOperationSource, Seri
* @param cacheOperationSources the CacheOperationSource instances to combine * @param cacheOperationSources the CacheOperationSource instances to combine
*/ */
public CompositeCacheOperationSource(CacheOperationSource... cacheOperationSources) { public CompositeCacheOperationSource(CacheOperationSource... cacheOperationSources) {
Assert.notEmpty(cacheOperationSources, "cacheOperationSources array must not be empty"); Assert.notEmpty(cacheOperationSources, "CacheOperationSource array must not be empty");
this.cacheOperationSources = cacheOperationSources; this.cacheOperationSources = cacheOperationSources;
} }
@@ -53,20 +54,20 @@ public class CompositeCacheOperationSource implements CacheOperationSource, Seri
return this.cacheOperationSources; return this.cacheOperationSources;
} }
@Override @Override
public Collection<CacheOperation> getCacheOperations(Method method, Class<?> targetClass) { public Collection<CacheOperation> getCacheOperations(Method method, Class<?> targetClass) {
Collection<CacheOperation> ops = null; Collection<CacheOperation> ops = null;
for (CacheOperationSource source : this.cacheOperationSources) { for (CacheOperationSource source : this.cacheOperationSources) {
Collection<CacheOperation> cacheOperations = source.getCacheOperations(method, targetClass); Collection<CacheOperation> cacheOperations = source.getCacheOperations(method, targetClass);
if (cacheOperations != null) { if (cacheOperations != null) {
if (ops == null) { if (ops == null) {
ops = new ArrayList<CacheOperation>(); ops = new ArrayList<CacheOperation>();
} }
ops.addAll(cacheOperations); ops.addAll(cacheOperations);
} }
} }
return ops; return ops;
} }
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2019 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.
@@ -33,7 +33,7 @@ import org.springframework.util.StringUtils;
/** /**
* {@link org.springframework.scripting.ScriptFactory} implementation based * {@link org.springframework.scripting.ScriptFactory} implementation based
* on the JSR-223 script engine abstraction (as included in Java 6+). * on the JSR-223 script engine abstraction (as included in Java 6+).
* Supports JavaScript, Groovy, JRuby and other JSR-223 compliant engines. * Supports JavaScript, Groovy, JRuby, and other JSR-223 compliant engines.
* *
* <p>Typically used in combination with a * <p>Typically used in combination with a
* {@link org.springframework.scripting.support.ScriptFactoryPostProcessor}; * {@link org.springframework.scripting.support.ScriptFactoryPostProcessor};
@@ -140,6 +140,7 @@ public class StandardScriptFactory implements ScriptFactory, BeanClassLoaderAwar
if (script instanceof Class ? !requestedIfc.isAssignableFrom((Class<?>) script) : if (script instanceof Class ? !requestedIfc.isAssignableFrom((Class<?>) script) :
!requestedIfc.isInstance(script)) { !requestedIfc.isInstance(script)) {
adaptationRequired = true; adaptationRequired = true;
break;
} }
} }
if (adaptationRequired) { if (adaptationRequired) {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 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.
@@ -116,7 +116,7 @@ public abstract class RdbmsOperation implements InitializingBean {
* large result sets: Setting this higher than the default value will increase * large result sets: Setting this higher than the default value will increase
* processing speed at the cost of memory consumption; setting this lower can * processing speed at the cost of memory consumption; setting this lower can
* avoid transferring row data that will never be read by the application. * avoid transferring row data that will never be read by the application.
* <p>Default is 0, indicating to use the driver's default. * <p>Default is -1, indicating to use the driver's default.
* @see org.springframework.jdbc.core.JdbcTemplate#setFetchSize * @see org.springframework.jdbc.core.JdbcTemplate#setFetchSize
*/ */
public void setFetchSize(int fetchSize) { public void setFetchSize(int fetchSize) {
@@ -127,7 +127,7 @@ public abstract class RdbmsOperation implements InitializingBean {
* Set the maximum number of rows for this RDBMS operation. This is important * Set the maximum number of rows for this RDBMS operation. This is important
* for processing subsets of large result sets, avoiding to read and hold * for processing subsets of large result sets, avoiding to read and hold
* the entire result set in the database or in the JDBC driver. * the entire result set in the database or in the JDBC driver.
* <p>Default is 0, indicating to use the driver's default. * <p>Default is -1, indicating to use the driver's default.
* @see org.springframework.jdbc.core.JdbcTemplate#setMaxRows * @see org.springframework.jdbc.core.JdbcTemplate#setMaxRows
*/ */
public void setMaxRows(int maxRows) { public void setMaxRows(int maxRows) {
@@ -136,7 +136,7 @@ public abstract class RdbmsOperation implements InitializingBean {
/** /**
* Set the query timeout for statements that this RDBMS operation executes. * Set the query timeout for statements that this RDBMS operation executes.
* <p>Default is 0, indicating to use the JDBC driver's default. * <p>Default is -1, indicating to use the JDBC driver's default.
* <p>Note: Any timeout specified here will be overridden by the remaining * <p>Note: Any timeout specified here will be overridden by the remaining
* transaction timeout when executing within a transaction that has a * transaction timeout when executing within a transaction that has a
* timeout specified at the transaction level. * timeout specified at the transaction level.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2019 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.
@@ -38,7 +38,7 @@ public class CompositeTransactionAttributeSource implements TransactionAttribute
* Create a new CompositeTransactionAttributeSource for the given sources. * Create a new CompositeTransactionAttributeSource for the given sources.
* @param transactionAttributeSources the TransactionAttributeSource instances to combine * @param transactionAttributeSources the TransactionAttributeSource instances to combine
*/ */
public CompositeTransactionAttributeSource(TransactionAttributeSource[] transactionAttributeSources) { public CompositeTransactionAttributeSource(TransactionAttributeSource... transactionAttributeSources) {
Assert.notNull(transactionAttributeSources, "TransactionAttributeSource array must not be null"); Assert.notNull(transactionAttributeSources, "TransactionAttributeSource array must not be null");
this.transactionAttributeSources = transactionAttributeSources; this.transactionAttributeSources = transactionAttributeSources;
} }
@@ -54,10 +54,10 @@ public class CompositeTransactionAttributeSource implements TransactionAttribute
@Override @Override
public TransactionAttribute getTransactionAttribute(Method method, Class<?> targetClass) { public TransactionAttribute getTransactionAttribute(Method method, Class<?> targetClass) {
for (TransactionAttributeSource tas : this.transactionAttributeSources) { for (TransactionAttributeSource source : this.transactionAttributeSources) {
TransactionAttribute ta = tas.getTransactionAttribute(method, targetClass); TransactionAttribute attr = source.getTransactionAttribute(method, targetClass);
if (ta != null) { if (attr != null) {
return ta; return attr;
} }
} }
return null; return null;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2019 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.
@@ -25,6 +25,7 @@ import java.lang.reflect.Method;
* metadata attributes at source level (such as Java 5 annotations), or anywhere else. * metadata attributes at source level (such as Java 5 annotations), or anywhere else.
* *
* @author Rod Johnson * @author Rod Johnson
* @author Juergen Hoeller
* @since 15.04.2003 * @since 15.04.2003
* @see TransactionInterceptor#setTransactionAttributeSource * @see TransactionInterceptor#setTransactionAttributeSource
* @see TransactionProxyFactoryBean#setTransactionAttributeSource * @see TransactionProxyFactoryBean#setTransactionAttributeSource
@@ -36,10 +37,9 @@ public interface TransactionAttributeSource {
* Return the transaction attribute for the given method, * Return the transaction attribute for the given method,
* or {@code null} if the method is non-transactional. * or {@code null} if the method is non-transactional.
* @param method the method to introspect * @param method the method to introspect
* @param targetClass the target class. May be {@code null}, * @param targetClass the target class (may be {@code null},
* in which case the declaring class of the method must be used. * in which case the declaring class of the method must be used)
* @return TransactionAttribute the matching transaction attribute, * @return the matching transaction attribute, or {@code null} if none found
* or {@code null} if none found
*/ */
TransactionAttribute getTransactionAttribute(Method method, Class<?> targetClass); TransactionAttribute getTransactionAttribute(Method method, Class<?> targetClass);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2011 the original author or authors. * Copyright 2002-2019 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.
@@ -33,8 +33,8 @@ public interface ServerHttpRequest extends HttpRequest, HttpInputMessage {
/** /**
* Return a {@link java.security.Principal} instance containing the name of the * Return a {@link java.security.Principal} instance containing the name of the
* authenticated user. If the user has not been authenticated, the method returns * authenticated user.
* <code>null</code>. * <p>If the user has not been authenticated, the method returns <code>null</code>.
*/ */
Principal getPrincipal(); Principal getPrincipal();