Polishing
This commit is contained in:
@@ -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.
|
||||||
@@ -29,7 +29,7 @@ import org.springframework.util.ReflectionUtils;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Objenesis-based extension of {@link CglibAopProxy} to create proxy instances
|
* Objenesis-based extension of {@link CglibAopProxy} to create proxy instances
|
||||||
* without invoking the constructor of the class.
|
* without invoking the constructor of the class. Used by default as of Spring 4.
|
||||||
*
|
*
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
@@ -53,7 +53,6 @@ class ObjenesisCglibAopProxy extends CglibAopProxy {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
protected Object createProxyClassAndInstance(Enhancer enhancer, Callback[] callbacks) {
|
protected Object createProxyClassAndInstance(Enhancer enhancer, Callback[] callbacks) {
|
||||||
Class<?> proxyClass = enhancer.createClass();
|
Class<?> proxyClass = enhancer.createClass();
|
||||||
Object proxyInstance = null;
|
Object proxyInstance = null;
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -62,12 +62,15 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
|
|||||||
this.allParameterDetails = initializeAllParameterDetails(methodDetails.getMethod());
|
this.allParameterDetails = initializeAllParameterDetails(methodDetails.getMethod());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<CacheParameterDetail> initializeAllParameterDetails(Method method) {
|
||||||
/**
|
int parameterCount = method.getParameterCount();
|
||||||
* Return the {@link ExceptionTypeFilter} to use to filter exceptions thrown while
|
List<CacheParameterDetail> result = new ArrayList<>(parameterCount);
|
||||||
* invoking the method.
|
for (int i = 0; i < parameterCount; i++) {
|
||||||
*/
|
CacheParameterDetail detail = new CacheParameterDetail(method, i);
|
||||||
public abstract ExceptionTypeFilter getExceptionTypeFilter();
|
result.add(detail);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -113,12 +116,25 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
|
|||||||
return result.toArray(new CacheInvocationParameter[0]);
|
return result.toArray(new CacheInvocationParameter[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the {@link ExceptionTypeFilter} to use to filter exceptions thrown while
|
||||||
|
* invoking the method.
|
||||||
|
* @see #createExceptionTypeFilter
|
||||||
|
*/
|
||||||
|
public abstract ExceptionTypeFilter getExceptionTypeFilter();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method for subclasses to create a specific {@code ExceptionTypeFilter}.
|
||||||
|
* @see #getExceptionTypeFilter()
|
||||||
|
*/
|
||||||
protected ExceptionTypeFilter createExceptionTypeFilter(
|
protected ExceptionTypeFilter createExceptionTypeFilter(
|
||||||
Class<? extends Throwable>[] includes, Class<? extends Throwable>[] excludes) {
|
Class<? extends Throwable>[] includes, Class<? extends Throwable>[] excludes) {
|
||||||
|
|
||||||
return new ExceptionTypeFilter(Arrays.asList(includes), Arrays.asList(excludes), true);
|
return new ExceptionTypeFilter(Arrays.asList(includes), Arrays.asList(excludes), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getOperationDescription().append("]").toString();
|
return getOperationDescription().append("]").toString();
|
||||||
@@ -137,16 +153,6 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static List<CacheParameterDetail> initializeAllParameterDetails(Method method) {
|
|
||||||
List<CacheParameterDetail> result = new ArrayList<>();
|
|
||||||
for (int i = 0; i < method.getParameterCount(); i++) {
|
|
||||||
CacheParameterDetail detail = new CacheParameterDetail(method, i);
|
|
||||||
result.add(detail);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Details for a single cache parameter.
|
* Details for a single cache parameter.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -24,9 +24,10 @@ import org.springframework.cache.interceptor.BasicOperation;
|
|||||||
import org.springframework.cache.interceptor.CacheResolver;
|
import org.springframework.cache.interceptor.CacheResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model the base of JSR-107 cache operation.
|
* Model the base of JSR-107 cache operation through an interface contract.
|
||||||
* <p>A cache operation can be statically cached as it does not contain
|
*
|
||||||
* any runtime operation of a specific cache invocation.
|
* <p>A cache operation can be statically cached as it does not contain any
|
||||||
|
* runtime operation of a specific cache invocation.
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -20,44 +20,44 @@ import org.springframework.beans.factory.Aware;
|
|||||||
import org.springframework.core.io.ResourceLoader;
|
import org.springframework.core.io.ResourceLoader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface to be implemented by any object that wishes to be notified of
|
* Interface to be implemented by any object that wishes to be notified of the
|
||||||
* the <b>ResourceLoader</b> (typically the ApplicationContext) that it runs in.
|
* {@link ResourceLoader} (typically the ApplicationContext) that it runs in.
|
||||||
* This is an alternative to a full ApplicationContext dependency via the
|
* This is an alternative to a full {@link ApplicationContext} dependency via
|
||||||
* ApplicationContextAware interface.
|
* the {@link org.springframework.context.ApplicationContextAware} interface.
|
||||||
*
|
*
|
||||||
* <p>Note that Resource dependencies can also be exposed as bean properties
|
* <p>Note that {@link org.springframework.core.io.Resource} dependencies can also
|
||||||
* of type Resource, populated via Strings with automatic type conversion by
|
* be exposed as bean properties of type {@code Resource}, populated via Strings
|
||||||
* the bean factory. This removes the need for implementing any callback
|
* with automatic type conversion by the bean factory. This removes the need for
|
||||||
* interface just for the purpose of accessing a specific file resource.
|
* implementing any callback interface just for the purpose of accessing a
|
||||||
|
* specific file resource.
|
||||||
*
|
*
|
||||||
* <p>You typically need a ResourceLoader when your application object has
|
* <p>You typically need a {@link ResourceLoader} when your application object has to
|
||||||
* to access a variety of file resources whose names are calculated. A good
|
* access a variety of file resources whose names are calculated. A good strategy is
|
||||||
* strategy is to make the object use a DefaultResourceLoader but still
|
* to make the object use a {@link org.springframework.core.io.DefaultResourceLoader}
|
||||||
* implement ResourceLoaderAware to allow for overriding when running in an
|
* but still implement {@code ResourceLoaderAware} to allow for overriding when
|
||||||
* ApplicationContext. See ReloadableResourceBundleMessageSource for an example.
|
* running in an {@code ApplicationContext}. See
|
||||||
|
* {@link org.springframework.context.support.ReloadableResourceBundleMessageSource}
|
||||||
|
* for an example.
|
||||||
*
|
*
|
||||||
* <p>A passed-in ResourceLoader can also be checked for the
|
* <p>A passed-in {@code ResourceLoader} can also be checked for the
|
||||||
* <b>ResourcePatternResolver</b> interface and cast accordingly, to be able
|
* {@link org.springframework.core.io.support.ResourcePatternResolver} interface
|
||||||
* to resolve resource patterns into arrays of Resource objects. This will always
|
* and cast accordingly, in order to resolve resource patterns into arrays of
|
||||||
* work when running in an ApplicationContext (the context interface extends
|
* {@code Resource} objects. This will always work when running in an ApplicationContext
|
||||||
* ResourcePatternResolver). Use a PathMatchingResourcePatternResolver as default.
|
* (since the context interface extends the ResourcePatternResolver interface). Use a
|
||||||
* See also the {@code ResourcePatternUtils.getResourcePatternResolver} method.
|
* {@link org.springframework.core.io.support.PathMatchingResourcePatternResolver} as
|
||||||
|
* default; see also the {@code ResourcePatternUtils.getResourcePatternResolver} method.
|
||||||
*
|
*
|
||||||
* <p>As alternative to a ResourcePatternResolver dependency, consider exposing
|
* <p>As an alternative to a {@code ResourcePatternResolver} dependency, consider
|
||||||
* bean properties of type Resource array, populated via pattern Strings with
|
* exposing bean properties of type {@code Resource} array, populated via pattern
|
||||||
* automatic type conversion by the bean factory.
|
* Strings with automatic type conversion by the bean factory at binding time.
|
||||||
*
|
*
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
* @since 10.03.2004
|
* @since 10.03.2004
|
||||||
* @see ApplicationContextAware
|
* @see ApplicationContextAware
|
||||||
* @see org.springframework.beans.factory.InitializingBean
|
|
||||||
* @see org.springframework.core.io.Resource
|
* @see org.springframework.core.io.Resource
|
||||||
|
* @see org.springframework.core.io.ResourceLoader
|
||||||
* @see org.springframework.core.io.support.ResourcePatternResolver
|
* @see org.springframework.core.io.support.ResourcePatternResolver
|
||||||
* @see org.springframework.core.io.support.ResourcePatternUtils#getResourcePatternResolver
|
|
||||||
* @see org.springframework.core.io.DefaultResourceLoader
|
|
||||||
* @see org.springframework.core.io.support.PathMatchingResourcePatternResolver
|
|
||||||
* @see org.springframework.context.support.ReloadableResourceBundleMessageSource
|
|
||||||
*/
|
*/
|
||||||
public interface ResourceLoaderAware extends Aware {
|
public interface ResourceLoaderAware extends Aware {
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 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.
|
||||||
@@ -49,10 +49,10 @@ public abstract class ResourcePatternUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a default ResourcePatternResolver for the given ResourceLoader.
|
* Return a default {@link ResourcePatternResolver} for the given {@link ResourceLoader}.
|
||||||
* <p>This might be the ResourceLoader itself, if it implements the
|
* <p>This might be the {@code ResourceLoader} itself, if it implements the
|
||||||
* ResourcePatternResolver extension, or a PathMatchingResourcePatternResolver
|
* {@code ResourcePatternResolver} extension, or a default
|
||||||
* built on the given ResourceLoader.
|
* {@link PathMatchingResourcePatternResolver} built on the given {@code ResourceLoader}.
|
||||||
* @param resourceLoader the ResourceLoader to build a pattern resolver for
|
* @param resourceLoader the ResourceLoader to build a pattern resolver for
|
||||||
* (may be {@code null} to indicate a default ResourceLoader)
|
* (may be {@code null} to indicate a default ResourceLoader)
|
||||||
* @return the ResourcePatternResolver
|
* @return the ResourcePatternResolver
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -126,8 +126,8 @@ public class CompoundExpression extends SpelNodeImpl {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateCode(MethodVisitor mv, CodeFlow cf) {
|
public void generateCode(MethodVisitor mv, CodeFlow cf) {
|
||||||
for (int i = 0; i < this.children.length;i++) {
|
for (SpelNodeImpl child : this.children) {
|
||||||
this.children[i].generateCode(mv, cf);
|
child.generateCode(mv, cf);
|
||||||
}
|
}
|
||||||
cf.pushDescriptor(this.exitTypeDescriptor);
|
cf.pushDescriptor(this.exitTypeDescriptor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 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.
|
||||||
@@ -21,8 +21,8 @@ import org.springframework.transaction.TransactionDefinition;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface adds a {@code rollbackOn} specification to {@link TransactionDefinition}.
|
* This interface adds a {@code rollbackOn} specification to {@link TransactionDefinition}.
|
||||||
* As custom {@code rollbackOn} is only possible with AOP, this class resides
|
* As custom {@code rollbackOn} is only possible with AOP, it resides in the AOP-related
|
||||||
* in the AOP transaction package.
|
* transaction subpackage.
|
||||||
*
|
*
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
@@ -36,6 +36,7 @@ public interface TransactionAttribute extends TransactionDefinition {
|
|||||||
* Return a qualifier value associated with this transaction attribute.
|
* Return a qualifier value associated with this transaction attribute.
|
||||||
* <p>This may be used for choosing a corresponding transaction manager
|
* <p>This may be used for choosing a corresponding transaction manager
|
||||||
* to process this specific transaction.
|
* to process this specific transaction.
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
String getQualifier();
|
String getQualifier();
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -45,7 +45,6 @@ public class TransactionAttributeEditor extends PropertyEditorSupport {
|
|||||||
/**
|
/**
|
||||||
* Format is PROPAGATION_NAME,ISOLATION_NAME,readOnly,timeout_NNNN,+Exception1,-Exception2.
|
* Format is PROPAGATION_NAME,ISOLATION_NAME,readOnly,timeout_NNNN,+Exception1,-Exception2.
|
||||||
* Null or the empty string means that the method is non transactional.
|
* Null or the empty string means that the method is non transactional.
|
||||||
* @see java.beans.PropertyEditor#setAsText(java.lang.String)
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setAsText(String text) throws IllegalArgumentException {
|
public void setAsText(String text) throws IllegalArgumentException {
|
||||||
@@ -53,36 +52,36 @@ public class TransactionAttributeEditor extends PropertyEditorSupport {
|
|||||||
// tokenize it with ","
|
// tokenize it with ","
|
||||||
String[] tokens = StringUtils.commaDelimitedListToStringArray(text);
|
String[] tokens = StringUtils.commaDelimitedListToStringArray(text);
|
||||||
RuleBasedTransactionAttribute attr = new RuleBasedTransactionAttribute();
|
RuleBasedTransactionAttribute attr = new RuleBasedTransactionAttribute();
|
||||||
for (int i = 0; i < tokens.length; i++) {
|
for (String token : tokens) {
|
||||||
// Trim leading and trailing whitespace.
|
// Trim leading and trailing whitespace.
|
||||||
String token = StringUtils.trimWhitespace(tokens[i].trim());
|
String trimmedToken = StringUtils.trimWhitespace(token.trim());
|
||||||
// Check whether token contains illegal whitespace within text.
|
// Check whether token contains illegal whitespace within text.
|
||||||
if (StringUtils.containsWhitespace(token)) {
|
if (StringUtils.containsWhitespace(trimmedToken)) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Transaction attribute token contains illegal whitespace: [" + token + "]");
|
"Transaction attribute token contains illegal whitespace: [" + trimmedToken + "]");
|
||||||
}
|
}
|
||||||
// Check token type.
|
// Check token type.
|
||||||
if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_PROPAGATION)) {
|
if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_PROPAGATION)) {
|
||||||
attr.setPropagationBehaviorName(token);
|
attr.setPropagationBehaviorName(trimmedToken);
|
||||||
}
|
}
|
||||||
else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_ISOLATION)) {
|
else if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_ISOLATION)) {
|
||||||
attr.setIsolationLevelName(token);
|
attr.setIsolationLevelName(trimmedToken);
|
||||||
}
|
}
|
||||||
else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_TIMEOUT)) {
|
else if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_TIMEOUT)) {
|
||||||
String value = token.substring(DefaultTransactionAttribute.PREFIX_TIMEOUT.length());
|
String value = trimmedToken.substring(DefaultTransactionAttribute.PREFIX_TIMEOUT.length());
|
||||||
attr.setTimeout(Integer.parseInt(value));
|
attr.setTimeout(Integer.parseInt(value));
|
||||||
}
|
}
|
||||||
else if (token.equals(RuleBasedTransactionAttribute.READ_ONLY_MARKER)) {
|
else if (trimmedToken.equals(RuleBasedTransactionAttribute.READ_ONLY_MARKER)) {
|
||||||
attr.setReadOnly(true);
|
attr.setReadOnly(true);
|
||||||
}
|
}
|
||||||
else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_COMMIT_RULE)) {
|
else if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_COMMIT_RULE)) {
|
||||||
attr.getRollbackRules().add(new NoRollbackRuleAttribute(token.substring(1)));
|
attr.getRollbackRules().add(new NoRollbackRuleAttribute(trimmedToken.substring(1)));
|
||||||
}
|
}
|
||||||
else if (token.startsWith(RuleBasedTransactionAttribute.PREFIX_ROLLBACK_RULE)) {
|
else if (trimmedToken.startsWith(RuleBasedTransactionAttribute.PREFIX_ROLLBACK_RULE)) {
|
||||||
attr.getRollbackRules().add(new RollbackRuleAttribute(token.substring(1)));
|
attr.getRollbackRules().add(new RollbackRuleAttribute(trimmedToken.substring(1)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new IllegalArgumentException("Invalid transaction attribute token: [" + token + "]");
|
throw new IllegalArgumentException("Invalid transaction attribute token: [" + trimmedToken + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setValue(attr);
|
setValue(attr);
|
||||||
|
|||||||
Reference in New Issue
Block a user