mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-18 00:49:02 +00:00
Compare commits
135
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
952ebf8ce1 | ||
|
|
7d126d3288 | ||
|
|
e9dc5160b9 | ||
|
|
3616e96792 | ||
|
|
357beb24bc | ||
|
|
17c423f5af | ||
|
|
b1ed0511f7 | ||
|
|
bb6f9bb6d4 | ||
|
|
0519a2ff3c | ||
|
|
6a08bfdff7 | ||
|
|
da44a247cb | ||
|
|
20fc7e178a | ||
|
|
31c881468c | ||
|
|
955000699a | ||
|
|
99d9dacc4f | ||
|
|
2794264480 | ||
|
|
4edc7196fb | ||
|
|
8f6846827d | ||
|
|
b2aad1c3b1 | ||
|
|
ca2b2f5533 | ||
|
|
b65984a078 | ||
|
|
b1b25fab00 | ||
|
|
e9454b8b11 | ||
|
|
d945ae9191 | ||
|
|
d09f537699 | ||
|
|
c8f20815ef | ||
|
|
60976e4116 | ||
|
|
bd28bb1f56 | ||
|
|
aa69703f3b | ||
|
|
a871f609ea | ||
|
|
f259fda8eb | ||
|
|
23be5dfb0e | ||
|
|
b7eaab4c5d | ||
|
|
07b0fa132e | ||
|
|
6eb0e9e44b | ||
|
|
9db4118180 | ||
|
|
b159ef6019 | ||
|
|
961010055e | ||
|
|
a7aecbb4dc | ||
|
|
d036b5a283 | ||
|
|
3a132f8c3c | ||
|
|
1187fea65c | ||
|
|
e26cdfe21e | ||
|
|
f37ec90f2f | ||
|
|
f748b1e68d | ||
|
|
9729b460f1 | ||
|
|
a496353770 | ||
|
|
d709a69ff1 | ||
|
|
2c5958e191 | ||
|
|
4f4b9f6b1b | ||
|
|
4e4ec266b2 | ||
|
|
bd8f94ad7b | ||
|
|
c2d71922d7 | ||
|
|
88e9dcef0c | ||
|
|
4a4edeb97f | ||
|
|
dd22b8fd39 | ||
|
|
8189c90741 | ||
|
|
9d2a874e3f | ||
|
|
a7bb5ca473 | ||
|
|
6d8bf3466c | ||
|
|
b86c11cc9b | ||
|
|
122e2ca2ac | ||
|
|
806fcb3839 | ||
|
|
30ebc3b8e2 | ||
|
|
a092dc055e | ||
|
|
70be7117f3 | ||
|
|
f13a6d4f32 | ||
|
|
7c2e2d40af | ||
|
|
d8e624e97e | ||
|
|
762ea3ea90 | ||
|
|
871bb57e02 | ||
|
|
aebc485eda | ||
|
|
ea4f7d365f | ||
|
|
438b40f6d7 | ||
|
|
59064f0780 | ||
|
|
960079e5f5 | ||
|
|
29ef985411 | ||
|
|
b2c56590dd | ||
|
|
c4622dbebc | ||
|
|
9a36027ae1 | ||
|
|
6cb4b8bd43 | ||
|
|
7b697266be | ||
|
|
1d92755cc7 | ||
|
|
50a909908c | ||
|
|
da54121ee0 | ||
|
|
5034d1e7b3 | ||
|
|
0f9c7934bb | ||
|
|
946fc39d42 | ||
|
|
78802d4277 | ||
|
|
92890232df | ||
|
|
b1e8ed182e | ||
|
|
0d37209b78 | ||
|
|
4a09b323b6 | ||
|
|
209c8505e6 | ||
|
|
e5bef10d85 | ||
|
|
f92b60c08f | ||
|
|
a244675630 | ||
|
|
153ac82380 | ||
|
|
4973e110ee | ||
|
|
2b94205ba9 | ||
|
|
46e5b6f7af | ||
|
|
f5daa657f4 | ||
|
|
9ffdf05d77 | ||
|
|
18bfa6b003 | ||
|
|
74ddf1bee5 | ||
|
|
99c4a9eeba | ||
|
|
235858e4e5 | ||
|
|
5089824245 | ||
|
|
81eb911c09 | ||
|
|
99758b56d3 | ||
|
|
db8be50161 | ||
|
|
efab6eb55d | ||
|
|
7a7d4109ac | ||
|
|
53ebbb20f9 | ||
|
|
16deb3c50f | ||
|
|
a1eae42fd0 | ||
|
|
56cc0d02e9 | ||
|
|
aeef95938e | ||
|
|
2aec175ccc | ||
|
|
2088a3d57b | ||
|
|
4e6e47b726 | ||
|
|
5af9a8edae | ||
|
|
6e79dcdc8e | ||
|
|
29b7659094 | ||
|
|
27b5d2b288 | ||
|
|
ac29e9de6a | ||
|
|
dda4dfb44b | ||
|
|
29dcd19971 | ||
|
|
594c5806a6 | ||
|
|
97bfb75fbc | ||
|
|
ad915f4a26 | ||
|
|
bcad276adb | ||
|
|
bd568ea2f1 | ||
|
|
d18d4d865e | ||
|
|
108ce58025 |
+15
-15
@@ -17,7 +17,7 @@ plugins {
|
||||
}
|
||||
|
||||
ext {
|
||||
linkHomepage = "https://projects.spring.io/spring-framework"
|
||||
linkHomepage = "https://spring.io/projects/spring-framework"
|
||||
linkCi = "https://build.spring.io/browse/SPR"
|
||||
linkIssue = "https://github.com/spring-projects/spring-framework/issues"
|
||||
linkScmUrl = "https://github.com/spring-projects/spring-framework"
|
||||
@@ -28,27 +28,27 @@ ext {
|
||||
!it.name.equals("spring-build-src") && !it.name.equals("spring-framework-bom")
|
||||
}
|
||||
|
||||
aspectjVersion = "1.9.3"
|
||||
aspectjVersion = "1.9.4"
|
||||
freemarkerVersion = "2.3.28"
|
||||
groovyVersion = "2.5.7"
|
||||
groovyVersion = "2.5.8"
|
||||
hsqldbVersion = "2.4.1"
|
||||
jackson2Version = "2.9.9"
|
||||
jettyVersion = "9.4.18.v20190429"
|
||||
jettyVersion = "9.4.20.v20190813"
|
||||
junit5Version = "5.3.2"
|
||||
kotlinVersion = "1.2.71"
|
||||
log4jVersion = "2.11.2"
|
||||
nettyVersion = "4.1.36.Final"
|
||||
reactorVersion = "Californium-SR9"
|
||||
nettyVersion = "4.1.39.Final"
|
||||
reactorVersion = "Californium-SR12"
|
||||
rxjavaVersion = "1.3.8"
|
||||
rxjavaAdapterVersion = "1.2.1"
|
||||
rxjava2Version = "2.2.9"
|
||||
slf4jVersion = "1.7.26" // spring-jcl + consistent 3rd party deps
|
||||
rxjava2Version = "2.2.12"
|
||||
slf4jVersion = "1.7.28" // spring-jcl + consistent 3rd party deps
|
||||
tiles3Version = "3.0.8"
|
||||
tomcatVersion = "9.0.21"
|
||||
undertowVersion = "2.0.21.Final"
|
||||
tomcatVersion = "9.0.26"
|
||||
undertowVersion = "2.0.26.Final"
|
||||
|
||||
gradleScriptDir = "${rootProject.projectDir}/gradle"
|
||||
withoutJclOverSlf4J = {
|
||||
withoutJclOverSlf4j = {
|
||||
exclude group: "org.slf4j", module: "jcl-over-slf4j"
|
||||
}
|
||||
}
|
||||
@@ -139,11 +139,10 @@ configure(allprojects) { project ->
|
||||
// classes with the "$" pattern; otherwise, using -Dtest.single=MyTests to
|
||||
// run MyTests by itself will fail if MyTests contains any inner classes.
|
||||
exclude(["**/Abstract*.class", '**/*$*'])
|
||||
reports.junitXml.setDestination(file("$buildDir/test-results"))
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "8.21"
|
||||
toolVersion = "8.24"
|
||||
configDir = rootProject.file("src/checkstyle")
|
||||
}
|
||||
|
||||
@@ -156,7 +155,7 @@ configure(allprojects) { project ->
|
||||
testCompile("junit:junit:4.12") {
|
||||
exclude group: "org.hamcrest", module: "hamcrest-core"
|
||||
}
|
||||
testCompile("org.mockito:mockito-core:2.27.0") {
|
||||
testCompile("org.mockito:mockito-core:2.28.2") {
|
||||
exclude group: "org.hamcrest", module: "hamcrest-core"
|
||||
}
|
||||
testCompile("com.nhaarman:mockito-kotlin:1.6.0") {
|
||||
@@ -178,7 +177,7 @@ configure(allprojects) { project ->
|
||||
"https://docs.oracle.com/javase/8/docs/api/",
|
||||
"https://docs.oracle.com/javaee/7/api/",
|
||||
"https://docs.oracle.com/cd/E13222_01/wls/docs90/javadocs/", // CommonJ
|
||||
"https://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/topic/com.ibm.websphere.javadoc.doc/web/apidocs/",
|
||||
"https://www.ibm.com/support/knowledgecenter/SS7JFU_8.5.5/com.ibm.websphere.javadoc.doc/web/apidocs/",
|
||||
"https://glassfish.java.net/nonav/docs/v3/api/",
|
||||
"https://docs.jboss.org/jbossas/javadoc/4.0.5/connector/",
|
||||
"https://docs.jboss.org/jbossas/javadoc/7.1.2.Final/",
|
||||
@@ -217,6 +216,7 @@ configure(subprojects - project(":spring-build-src")) { subproject ->
|
||||
javadoc {
|
||||
description = "Generates project-level javadoc for use in -javadoc jar"
|
||||
|
||||
options.encoding = "UTF-8"
|
||||
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
|
||||
options.author = true
|
||||
options.header = project.name
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
version=5.1.8.BUILD-SNAPSHOT
|
||||
version=5.1.10.RELEASE
|
||||
|
||||
+2
-1
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,6 +24,7 @@ task api(type: Javadoc) {
|
||||
it.tasks.getByName("jar")
|
||||
}
|
||||
}
|
||||
options.encoding = "UTF-8"
|
||||
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
|
||||
options.author = true
|
||||
options.header = rootProject.description
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,11 @@ package org.springframework.aop;
|
||||
* <p>Can be used as part of a {@link Pointcut} or for the entire
|
||||
* targeting of an {@link IntroductionAdvisor}.
|
||||
*
|
||||
* <p>Concrete implementations of this interface typically should provide proper
|
||||
* implementations of {@link Object#equals(Object)} and {@link Object#hashCode()}
|
||||
* in order to allow the filter to be used in caching scenarios — for
|
||||
* example, in proxies generated by CGLIB.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @see Pointcut
|
||||
* @see MethodMatcher
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,6 +40,11 @@ import java.lang.reflect.Method;
|
||||
* in an interceptor chain, will have run, so any state changes they have produced in
|
||||
* parameters or ThreadLocal state will be available at the time of evaluation.
|
||||
*
|
||||
* <p>Concrete implementations of this interface typically should provide proper
|
||||
* implementations of {@link Object#equals(Object)} and {@link Object#hashCode()}
|
||||
* in order to allow the matcher to be used in caching scenarios — for
|
||||
* example, in proxies generated by CGLIB.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @since 11.11.2003
|
||||
* @see Pointcut
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -735,6 +735,11 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
public int hashCode() {
|
||||
return this.adviceMethod.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + ": " + this.adviceMethod;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+20
-1
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ import org.aspectj.weaver.tools.TypePatternMatcher;
|
||||
import org.springframework.aop.ClassFilter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -29,6 +30,7 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
* @since 2.0
|
||||
*/
|
||||
public class TypePatternClassFilter implements ClassFilter {
|
||||
@@ -113,4 +115,21 @@ public class TypePatternClassFilter implements ClassFilter {
|
||||
result = StringUtils.replace(result, " or ", " || ");
|
||||
return StringUtils.replace(result, " not ", " ! ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof TypePatternClassFilter &&
|
||||
ObjectUtils.nullSafeEquals(this.typePattern, ((TypePatternClassFilter) other).typePattern)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ObjectUtils.nullSafeHashCode(this.typePattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + ": " + this.typePattern;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -327,10 +327,11 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||
|
||||
// TODO: small memory optimization here (can skip creation for methods with no advice)
|
||||
for (int x = 0; x < methods.length; x++) {
|
||||
List<Object> chain = this.advised.getInterceptorsAndDynamicInterceptionAdvice(methods[x], rootClass);
|
||||
Method method = methods[x];
|
||||
List<Object> chain = this.advised.getInterceptorsAndDynamicInterceptionAdvice(method, rootClass);
|
||||
fixedCallbacks[x] = new FixedChainStaticTargetInterceptor(
|
||||
chain, this.advised.getTargetSource().getTarget(), this.advised.getTargetClass());
|
||||
this.fixedInterceptorMap.put(methods[x].toString(), x);
|
||||
this.fixedInterceptorMap.put(methods.toString(), x);
|
||||
}
|
||||
|
||||
// Now copy both the callbacks from mainCallbacks
|
||||
@@ -633,8 +634,8 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||
@Override
|
||||
@Nullable
|
||||
public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
|
||||
MethodInvocation invocation = new CglibMethodInvocation(proxy, this.target, method, args,
|
||||
this.targetClass, this.adviceChain, methodProxy);
|
||||
MethodInvocation invocation = new CglibMethodInvocation(
|
||||
proxy, this.target, method, args, this.targetClass, this.adviceChain, methodProxy);
|
||||
// If we get here, we need to create a MethodInvocation.
|
||||
Object retVal = invocation.proceed();
|
||||
retVal = processReturnType(proxy, this.target, method, retVal);
|
||||
|
||||
+3
-3
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -68,7 +68,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
|
||||
|
||||
protected final Method method;
|
||||
|
||||
protected Object[] arguments = new Object[0];
|
||||
protected Object[] arguments;
|
||||
|
||||
@Nullable
|
||||
private final Class<?> targetClass;
|
||||
@@ -158,7 +158,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
|
||||
@Override
|
||||
@Nullable
|
||||
public Object proceed() throws Throwable {
|
||||
// We start with an index of -1 and increment early.
|
||||
// We start with an index of -1 and increment early.
|
||||
if (this.currentInterceptorIndex == this.interceptorsAndDynamicMethodMatchers.size() - 1) {
|
||||
return invokeJoinpoint();
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,20 +23,25 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Utility class for creating a scoped proxy.
|
||||
* Used by ScopedProxyBeanDefinitionDecorator and ClassPathBeanDefinitionScanner.
|
||||
*
|
||||
* <p>Used by ScopedProxyBeanDefinitionDecorator and ClassPathBeanDefinitionScanner.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Juergen Hoeller
|
||||
* @author Rob Harrop
|
||||
* @author Sam Brannen
|
||||
* @since 2.5
|
||||
*/
|
||||
public abstract class ScopedProxyUtils {
|
||||
|
||||
private static final String TARGET_NAME_PREFIX = "scopedTarget.";
|
||||
|
||||
private static final int TARGET_NAME_PREFIX_LENGTH = TARGET_NAME_PREFIX.length();
|
||||
|
||||
|
||||
/**
|
||||
* Generate a scoped proxy for the supplied target bean, registering the target
|
||||
@@ -45,6 +50,8 @@ public abstract class ScopedProxyUtils {
|
||||
* @param registry the bean definition registry
|
||||
* @param proxyTargetClass whether to create a target class proxy
|
||||
* @return the scoped proxy definition
|
||||
* @see #getTargetBeanName(String)
|
||||
* @see #getOriginalBeanName(String)
|
||||
*/
|
||||
public static BeanDefinitionHolder createScopedProxy(BeanDefinitionHolder definition,
|
||||
BeanDefinitionRegistry registry, boolean proxyTargetClass) {
|
||||
@@ -93,11 +100,29 @@ public abstract class ScopedProxyUtils {
|
||||
* 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
|
||||
* @see #getOriginalBeanName(String)
|
||||
*/
|
||||
public static String getTargetBeanName(String originalBeanName) {
|
||||
return TARGET_NAME_PREFIX + originalBeanName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the original bean name for the provided {@linkplain #getTargetBeanName
|
||||
* target bean name}.
|
||||
* @param targetBeanName the target bean name for the scoped proxy
|
||||
* @return the original bean name
|
||||
* @throws IllegalArgumentException if the supplied bean name does not refer
|
||||
* to the target of a scoped proxy
|
||||
* @since 5.1.10
|
||||
* @see #getTargetBeanName(String)
|
||||
* @see #isScopedTarget(String)
|
||||
*/
|
||||
public static String getOriginalBeanName(String targetBeanName) {
|
||||
Assert.isTrue(isScopedTarget(targetBeanName), () -> "bean name '" +
|
||||
targetBeanName + "' does not refer to the target of a scoped proxy");
|
||||
return targetBeanName.substring(TARGET_NAME_PREFIX_LENGTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify if the {@code beanName} is the name of a bean that references the target
|
||||
* bean within a scoped proxy.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2019 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.aop.support;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.springframework.aop.ClassFilter;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -28,6 +29,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* @author Rod Johnson
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
* @since 11.11.2003
|
||||
* @see MethodMatchers
|
||||
* @see Pointcuts
|
||||
@@ -89,9 +91,9 @@ public abstract class ClassFilters {
|
||||
@SuppressWarnings("serial")
|
||||
private static class UnionClassFilter implements ClassFilter, Serializable {
|
||||
|
||||
private ClassFilter[] filters;
|
||||
private final ClassFilter[] filters;
|
||||
|
||||
public UnionClassFilter(ClassFilter[] filters) {
|
||||
UnionClassFilter(ClassFilter[] filters) {
|
||||
this.filters = filters;
|
||||
}
|
||||
|
||||
@@ -115,6 +117,12 @@ public abstract class ClassFilters {
|
||||
public int hashCode() {
|
||||
return ObjectUtils.nullSafeHashCode(this.filters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + ": " + Arrays.toString(this.filters);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -124,9 +132,9 @@ public abstract class ClassFilters {
|
||||
@SuppressWarnings("serial")
|
||||
private static class IntersectionClassFilter implements ClassFilter, Serializable {
|
||||
|
||||
private ClassFilter[] filters;
|
||||
private final ClassFilter[] filters;
|
||||
|
||||
public IntersectionClassFilter(ClassFilter[] filters) {
|
||||
IntersectionClassFilter(ClassFilter[] filters) {
|
||||
this.filters = filters;
|
||||
}
|
||||
|
||||
@@ -150,6 +158,12 @@ public abstract class ClassFilters {
|
||||
public int hashCode() {
|
||||
return ObjectUtils.nullSafeHashCode(this.filters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + ": " + Arrays.toString(this.filters);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,12 +24,15 @@ import org.springframework.aop.Pointcut;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Convenient class for building up pointcuts. All methods return
|
||||
* ComposablePointcut, so we can use a concise idiom like:
|
||||
* Convenient class for building up pointcuts.
|
||||
*
|
||||
* {@code
|
||||
* Pointcut pc = new ComposablePointcut().union(classFilter).intersection(methodMatcher).intersection(pointcut);
|
||||
* }
|
||||
* <p>All methods return {@code ComposablePointcut}, so we can use concise idioms
|
||||
* like in the following example.
|
||||
*
|
||||
* <pre class="code">Pointcut pc = new ComposablePointcut()
|
||||
* .union(classFilter)
|
||||
* .intersection(methodMatcher)
|
||||
* .intersection(pointcut);</pre>
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
@@ -199,7 +202,7 @@ public class ComposablePointcut implements Pointcut, Serializable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ComposablePointcut: " + this.classFilter + ", " +this.methodMatcher;
|
||||
return getClass().getName() + ": " + this.classFilter + ", " + this.methodMatcher;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,14 +34,15 @@ import org.springframework.util.ObjectUtils;
|
||||
* @author Rod Johnson
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher, Serializable {
|
||||
|
||||
private Class<?> clazz;
|
||||
private final Class<?> clazz;
|
||||
|
||||
@Nullable
|
||||
private String methodName;
|
||||
private final String methodName;
|
||||
|
||||
private volatile int evaluations;
|
||||
|
||||
@@ -142,4 +143,9 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + ": class = " + this.clazz.getName() + "; methodName = " + methodName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+14
-14
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,7 +39,7 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Juergen Hoeller
|
||||
* @since 11.11.2003
|
||||
*/
|
||||
@SuppressWarnings({"serial" })
|
||||
@SuppressWarnings("serial")
|
||||
public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFilter, Ordered, Serializable {
|
||||
|
||||
private final Advice advice;
|
||||
@@ -82,25 +82,25 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||
/**
|
||||
* Create a DefaultIntroductionAdvisor for the given advice.
|
||||
* @param advice the Advice to apply
|
||||
* @param intf the interface to introduce
|
||||
* @param ifc the interface to introduce
|
||||
*/
|
||||
public DefaultIntroductionAdvisor(DynamicIntroductionAdvice advice, Class<?> intf) {
|
||||
public DefaultIntroductionAdvisor(DynamicIntroductionAdvice advice, Class<?> ifc) {
|
||||
Assert.notNull(advice, "Advice must not be null");
|
||||
this.advice = advice;
|
||||
addInterface(intf);
|
||||
addInterface(ifc);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add the specified interface to the list of interfaces to introduce.
|
||||
* @param intf the interface to introduce
|
||||
* @param ifc the interface to introduce
|
||||
*/
|
||||
public void addInterface(Class<?> intf) {
|
||||
Assert.notNull(intf, "Interface must not be null");
|
||||
if (!intf.isInterface()) {
|
||||
throw new IllegalArgumentException("Specified class [" + intf.getName() + "] must be an interface");
|
||||
public void addInterface(Class<?> ifc) {
|
||||
Assert.notNull(ifc, "Interface must not be null");
|
||||
if (!ifc.isInterface()) {
|
||||
throw new IllegalArgumentException("Specified class [" + ifc.getName() + "] must be an interface");
|
||||
}
|
||||
this.interfaces.add(intf);
|
||||
this.interfaces.add(ifc);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -113,8 +113,8 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||
for (Class<?> ifc : this.interfaces) {
|
||||
if (this.advice instanceof DynamicIntroductionAdvice &&
|
||||
!((DynamicIntroductionAdvice) this.advice).implementsInterface(ifc)) {
|
||||
throw new IllegalArgumentException("DynamicIntroductionAdvice [" + this.advice + "] " +
|
||||
"does not implement interface [" + ifc.getName() + "] specified for introduction");
|
||||
throw new IllegalArgumentException("DynamicIntroductionAdvice [" + this.advice + "] " +
|
||||
"does not implement interface [" + ifc.getName() + "] specified for introduction");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ClassUtils.getShortName(getClass()) + ": advice [" + this.advice + "]; interfaces " +
|
||||
return getClass().getName() + ": advice [" + this.advice + "]; interfaces " +
|
||||
ClassUtils.classNamesToString(this.interfaces);
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,6 +34,7 @@ import org.springframework.util.Assert;
|
||||
* @author Rod Johnson
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
* @since 11.11.2003
|
||||
* @see ClassFilters
|
||||
* @see Pointcuts
|
||||
@@ -155,6 +156,11 @@ public abstract class MethodMatchers {
|
||||
public int hashCode() {
|
||||
return 37 * this.mm1.hashCode() + this.mm2.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + ": " + this.mm1 + ", " + this.mm2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -229,6 +235,11 @@ public abstract class MethodMatchers {
|
||||
// Allow for matching with regular UnionMethodMatcher by providing same hash...
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + ": " + this.cf1 + ", " + this.mm1 + ", " + this.cf2 + ", " + this.mm2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -311,6 +322,11 @@ public abstract class MethodMatchers {
|
||||
public int hashCode() {
|
||||
return 37 * this.mm1.hashCode() + this.mm2.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + ": " + this.mm1 + ", " + this.mm2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+9
-3
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,8 +25,9 @@ import java.util.List;
|
||||
import org.springframework.util.PatternMatchUtils;
|
||||
|
||||
/**
|
||||
* Pointcut bean for simple method name matches, as alternative to regexp patterns.
|
||||
* Does not handle overloaded methods: all methods with a given name will be eligible.
|
||||
* Pointcut bean for simple method name matches, as an alternative to regexp patterns.
|
||||
*
|
||||
* <p>Does not handle overloaded methods: all methods with a given name will be eligible.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Rod Johnson
|
||||
@@ -108,4 +109,9 @@ public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut impleme
|
||||
return this.mappedNames.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + ": " + this.mappedNames;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,7 +26,8 @@ import org.springframework.util.Assert;
|
||||
/**
|
||||
* Pointcut constants for matching getters and setters,
|
||||
* and static methods useful for manipulating and evaluating pointcuts.
|
||||
* These methods are particularly useful for composing pointcuts
|
||||
*
|
||||
* <p>These methods are particularly useful for composing pointcuts
|
||||
* using the union and intersection methods.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
@@ -106,6 +107,11 @@ public abstract class Pointcuts {
|
||||
private Object readResolve() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Pointcuts.SETTERS";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -126,6 +132,11 @@ public abstract class Pointcuts {
|
||||
private Object readResolve() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Pointcuts.GETTERS";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,19 +19,22 @@ package org.springframework.aop.support;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.springframework.aop.ClassFilter;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Simple ClassFilter implementation that passes classes (and optionally subclasses).
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class RootClassFilter implements ClassFilter, Serializable {
|
||||
|
||||
private Class<?> clazz;
|
||||
private final Class<?> clazz;
|
||||
|
||||
|
||||
public RootClassFilter(Class<?> clazz) {
|
||||
Assert.notNull(clazz, "Class must not be null");
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
@@ -41,4 +44,20 @@ public class RootClassFilter implements ClassFilter, Serializable {
|
||||
return this.clazz.isAssignableFrom(candidate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof RootClassFilter &&
|
||||
this.clazz.equals(((RootClassFilter) other).clazz)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.clazz.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + ": " + this.clazz.getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-4
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -62,7 +62,7 @@ public class AnnotationMatchingPointcut implements Pointcut {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new AnnotationMatchingPointcut for the given annotation type.
|
||||
* Create a new AnnotationMatchingPointcut for the given annotation types.
|
||||
* @param classAnnotationType the annotation type to look for at the class level
|
||||
* (can be {@code null})
|
||||
* @param methodAnnotationType the annotation type to look for at the method level
|
||||
@@ -75,7 +75,7 @@ public class AnnotationMatchingPointcut implements Pointcut {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new AnnotationMatchingPointcut for the given annotation type.
|
||||
* Create a new AnnotationMatchingPointcut for the given annotation types.
|
||||
* @param classAnnotationType the annotation type to look for at the class level
|
||||
* (can be {@code null})
|
||||
* @param methodAnnotationType the annotation type to look for at the method level
|
||||
@@ -138,7 +138,7 @@ public class AnnotationMatchingPointcut implements Pointcut {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AnnotationMatchingPointcut: " + this.classFilter + ", " +this.methodMatcher;
|
||||
return "AnnotationMatchingPointcut: " + this.classFilter + ", " + this.methodMatcher;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-2
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,6 +31,7 @@ import org.springframework.util.Assert;
|
||||
* interface, if any, and the corresponding method on the target class).
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
* @since 2.0
|
||||
* @see AnnotationMatchingPointcut
|
||||
*/
|
||||
@@ -94,7 +95,7 @@ public class AnnotationMethodMatcher extends StaticMethodMatcher {
|
||||
return false;
|
||||
}
|
||||
AnnotationMethodMatcher otherMm = (AnnotationMethodMatcher) other;
|
||||
return this.annotationType.equals(otherMm.annotationType);
|
||||
return (this.annotationType.equals(otherMm.annotationType) && this.checkInherited == otherMm.checkInherited);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+32
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2019 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,6 +34,7 @@ import static org.junit.Assert.*;
|
||||
* @author Rod Johnson
|
||||
* @author Rick Evans
|
||||
* @author Chris Beams
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class TypePatternClassFilterTests {
|
||||
|
||||
@@ -88,4 +89,34 @@ public class TypePatternClassFilterTests {
|
||||
new TypePatternClassFilter().matches(String.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
|
||||
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
|
||||
TypePatternClassFilter filter3 = new TypePatternClassFilter("org.springframework.tests.*");
|
||||
|
||||
assertEquals(filter1, filter2);
|
||||
assertNotEquals(filter1, filter3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashCode() {
|
||||
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
|
||||
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
|
||||
TypePatternClassFilter filter3 = new TypePatternClassFilter("org.springframework.tests.*");
|
||||
|
||||
assertEquals(filter1.hashCode(), filter2.hashCode());
|
||||
assertNotEquals(filter1.hashCode(), filter3.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
|
||||
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
|
||||
|
||||
assertEquals("org.springframework.aop.aspectj.TypePatternClassFilter: org.springframework.tests.sample.beans.*",
|
||||
filter1.toString());
|
||||
assertEquals(filter1.toString(), filter2.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.aop.framework;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.accessibility.Accessible;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.RootPaneContainer;
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2002-2019 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.aop.scope;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ScopedProxyUtils}.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 5.1.10
|
||||
*/
|
||||
public class ScopedProxyUtilsTests {
|
||||
|
||||
@Rule
|
||||
public final ExpectedException exception = ExpectedException.none();
|
||||
|
||||
|
||||
@Test
|
||||
public void getTargetBeanNameAndIsScopedTarget() {
|
||||
String originalBeanName = "myBean";
|
||||
String targetBeanName = ScopedProxyUtils.getTargetBeanName(originalBeanName);
|
||||
|
||||
assertNotEquals(originalBeanName, targetBeanName);
|
||||
assertTrue(targetBeanName.endsWith(originalBeanName));
|
||||
assertTrue(ScopedProxyUtils.isScopedTarget(targetBeanName));
|
||||
assertFalse(ScopedProxyUtils.isScopedTarget(originalBeanName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getOriginalBeanNameAndIsScopedTarget() {
|
||||
String originalBeanName = "myBean";
|
||||
String targetBeanName = ScopedProxyUtils.getTargetBeanName(originalBeanName);
|
||||
String parsedOriginalBeanName = ScopedProxyUtils.getOriginalBeanName(targetBeanName);
|
||||
|
||||
assertNotEquals(targetBeanName, parsedOriginalBeanName);
|
||||
assertEquals(originalBeanName, parsedOriginalBeanName);
|
||||
assertTrue(ScopedProxyUtils.isScopedTarget(targetBeanName));
|
||||
assertFalse(ScopedProxyUtils.isScopedTarget(parsedOriginalBeanName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getOriginalBeanNameForNullTargetBean() {
|
||||
exception.expect(IllegalArgumentException.class);
|
||||
exception.expectMessage("bean name 'null' does not refer to the target of a scoped proxy");
|
||||
ScopedProxyUtils.getOriginalBeanName(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getOriginalBeanNameForNonScopedTarget() {
|
||||
exception.expect(IllegalArgumentException.class);
|
||||
exception.expectMessage("bean name 'myBean' does not refer to the target of a scoped proxy");
|
||||
ScopedProxyUtils.getOriginalBeanName("myBean");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2019 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,39 +23,46 @@ import org.springframework.core.NestedRuntimeException;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ClassFilters}.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Chris Beams
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class ClassFiltersTests {
|
||||
|
||||
private ClassFilter exceptionFilter = new RootClassFilter(Exception.class);
|
||||
private final ClassFilter exceptionFilter = new RootClassFilter(Exception.class);
|
||||
|
||||
private ClassFilter itbFilter = new RootClassFilter(ITestBean.class);
|
||||
private final ClassFilter interfaceFilter = new RootClassFilter(ITestBean.class);
|
||||
|
||||
private final ClassFilter hasRootCauseFilter = new RootClassFilter(NestedRuntimeException.class);
|
||||
|
||||
private ClassFilter hasRootCauseFilter = new RootClassFilter(NestedRuntimeException.class);
|
||||
|
||||
@Test
|
||||
public void testUnion() {
|
||||
public void union() {
|
||||
assertTrue(exceptionFilter.matches(RuntimeException.class));
|
||||
assertFalse(exceptionFilter.matches(TestBean.class));
|
||||
assertFalse(itbFilter.matches(Exception.class));
|
||||
assertTrue(itbFilter.matches(TestBean.class));
|
||||
ClassFilter union = ClassFilters.union(exceptionFilter, itbFilter);
|
||||
assertFalse(interfaceFilter.matches(Exception.class));
|
||||
assertTrue(interfaceFilter.matches(TestBean.class));
|
||||
ClassFilter union = ClassFilters.union(exceptionFilter, interfaceFilter);
|
||||
assertTrue(union.matches(RuntimeException.class));
|
||||
assertTrue(union.matches(TestBean.class));
|
||||
assertTrue(union.toString().matches("^.+UnionClassFilter: \\[.+RootClassFilter: .+Exception, .+RootClassFilter: .+TestBean\\]$"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntersection() {
|
||||
public void intersection() {
|
||||
assertTrue(exceptionFilter.matches(RuntimeException.class));
|
||||
assertTrue(hasRootCauseFilter.matches(NestedRuntimeException.class));
|
||||
ClassFilter intersection = ClassFilters.intersection(exceptionFilter, hasRootCauseFilter);
|
||||
assertFalse(intersection.matches(RuntimeException.class));
|
||||
assertFalse(intersection.matches(TestBean.class));
|
||||
assertTrue(intersection.matches(NestedRuntimeException.class));
|
||||
assertTrue(intersection.toString().matches("^.+IntersectionClassFilter: \\[.+RootClassFilter: .+Exception, .+RootClassFilter: .+NestedRuntimeException\\]$"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,6 +100,14 @@ public class ControlFlowPointcutTests {
|
||||
assertFalse(new ControlFlowPointcut(One.class, "getAge").hashCode() == new ControlFlowPointcut(One.class).hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
assertEquals(ControlFlowPointcut.class.getName() + ": class = " + One.class.getName() + "; methodName = null",
|
||||
new ControlFlowPointcut(One.class).toString());
|
||||
assertEquals(ControlFlowPointcut.class.getName() + ": class = " + One.class.getName() + "; methodName = getAge",
|
||||
new ControlFlowPointcut(One.class, "getAge").toString());
|
||||
}
|
||||
|
||||
public class One {
|
||||
int getAge(ITestBean proxied) {
|
||||
return proxied.getAge();
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2002-2019 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.aop.support;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.aop.ClassFilter;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link RootClassFilter}.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 5.1.10
|
||||
*/
|
||||
public class RootClassFilterTests {
|
||||
|
||||
private final ClassFilter filter1 = new RootClassFilter(Exception.class);
|
||||
private final ClassFilter filter2 = new RootClassFilter(Exception.class);
|
||||
private final ClassFilter filter3 = new RootClassFilter(ITestBean.class);
|
||||
|
||||
@Test
|
||||
public void matches() {
|
||||
assertTrue(filter1.matches(Exception.class));
|
||||
assertTrue(filter1.matches(RuntimeException.class));
|
||||
assertFalse(filter1.matches(Error.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
assertEquals(filter1, filter2);
|
||||
assertNotEquals(filter1, filter3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashCode() {
|
||||
assertEquals(filter1.hashCode(), filter2.hashCode());
|
||||
assertNotEquals(filter1.hashCode(), filter3.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
assertEquals("org.springframework.aop.support.RootClassFilter: java.lang.Exception", filter1.toString());
|
||||
assertEquals(filter1.toString(), filter2.toString());
|
||||
}
|
||||
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright 2002-2019 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.aop.support.annotation;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.aop.ClassFilter;
|
||||
import org.springframework.aop.MethodMatcher;
|
||||
import org.springframework.aop.Pointcut;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link AnnotationMatchingPointcut}.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 5.1.10
|
||||
*/
|
||||
public class AnnotationMatchingPointcutTests {
|
||||
|
||||
@Test
|
||||
public void classLevelPointcuts() {
|
||||
Pointcut pointcut1 = new AnnotationMatchingPointcut(Qualifier.class, true);
|
||||
Pointcut pointcut2 = new AnnotationMatchingPointcut(Qualifier.class, true);
|
||||
Pointcut pointcut3 = new AnnotationMatchingPointcut(Qualifier.class);
|
||||
|
||||
assertEquals(AnnotationClassFilter.class, pointcut1.getClassFilter().getClass());
|
||||
assertEquals(AnnotationClassFilter.class, pointcut2.getClassFilter().getClass());
|
||||
assertEquals(AnnotationClassFilter.class, pointcut3.getClassFilter().getClass());
|
||||
assertTrue(pointcut1.getClassFilter().toString().contains(Qualifier.class.getName()));
|
||||
|
||||
assertEquals(MethodMatcher.TRUE, pointcut1.getMethodMatcher());
|
||||
assertEquals(MethodMatcher.TRUE, pointcut2.getMethodMatcher());
|
||||
assertEquals(MethodMatcher.TRUE, pointcut3.getMethodMatcher());
|
||||
|
||||
assertEquals(pointcut1, pointcut2);
|
||||
assertNotEquals(pointcut1, pointcut3);
|
||||
assertEquals(pointcut1.hashCode(), pointcut2.hashCode());
|
||||
// #1 and #3 have equivalent hash codes even though equals() returns false.
|
||||
assertEquals(pointcut1.hashCode(), pointcut3.hashCode());
|
||||
assertEquals(pointcut1.toString(), pointcut2.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodLevelPointcuts() {
|
||||
Pointcut pointcut1 = new AnnotationMatchingPointcut(null, Qualifier.class, true);
|
||||
Pointcut pointcut2 = new AnnotationMatchingPointcut(null, Qualifier.class, true);
|
||||
Pointcut pointcut3 = new AnnotationMatchingPointcut(null, Qualifier.class);
|
||||
|
||||
assertEquals(ClassFilter.TRUE, pointcut1.getClassFilter());
|
||||
assertEquals(ClassFilter.TRUE, pointcut2.getClassFilter());
|
||||
assertEquals(ClassFilter.TRUE, pointcut3.getClassFilter());
|
||||
assertEquals("ClassFilter.TRUE", pointcut1.getClassFilter().toString());
|
||||
|
||||
assertEquals(AnnotationMethodMatcher.class, pointcut1.getMethodMatcher().getClass());
|
||||
assertEquals(AnnotationMethodMatcher.class, pointcut2.getMethodMatcher().getClass());
|
||||
assertEquals(AnnotationMethodMatcher.class, pointcut3.getMethodMatcher().getClass());
|
||||
|
||||
assertEquals(pointcut1, pointcut2);
|
||||
assertNotEquals(pointcut1, pointcut3);
|
||||
assertEquals(pointcut1.hashCode(), pointcut2.hashCode());
|
||||
// #1 and #3 have equivalent hash codes even though equals() returns false.
|
||||
assertEquals(pointcut1.hashCode(), pointcut3.hashCode());
|
||||
assertEquals(pointcut1.toString(), pointcut2.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classLevelAndMethodLevelPointcuts() {
|
||||
Pointcut pointcut1 = new AnnotationMatchingPointcut(Qualifier.class, Qualifier.class, true);
|
||||
Pointcut pointcut2 = new AnnotationMatchingPointcut(Qualifier.class, Qualifier.class, true);
|
||||
Pointcut pointcut3 = new AnnotationMatchingPointcut(Qualifier.class, Qualifier.class);
|
||||
|
||||
assertEquals(AnnotationClassFilter.class, pointcut1.getClassFilter().getClass());
|
||||
assertEquals(AnnotationClassFilter.class, pointcut2.getClassFilter().getClass());
|
||||
assertEquals(AnnotationClassFilter.class, pointcut3.getClassFilter().getClass());
|
||||
assertTrue(pointcut1.getClassFilter().toString().contains(Qualifier.class.getName()));
|
||||
|
||||
assertEquals(AnnotationMethodMatcher.class, pointcut1.getMethodMatcher().getClass());
|
||||
assertEquals(AnnotationMethodMatcher.class, pointcut2.getMethodMatcher().getClass());
|
||||
assertEquals(AnnotationMethodMatcher.class, pointcut3.getMethodMatcher().getClass());
|
||||
assertTrue(pointcut1.getMethodMatcher().toString().contains(Qualifier.class.getName()));
|
||||
|
||||
assertEquals(pointcut1, pointcut2);
|
||||
assertNotEquals(pointcut1, pointcut3);
|
||||
assertEquals(pointcut1.hashCode(), pointcut2.hashCode());
|
||||
// #1 and #3 have equivalent hash codes even though equals() returns false.
|
||||
assertEquals(pointcut1.hashCode(), pointcut3.hashCode());
|
||||
assertEquals(pointcut1.toString(), pointcut2.toString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -89,7 +89,7 @@ dependencies {
|
||||
optional(project(":spring-context-support")) // for JavaMail and JSR-107 support
|
||||
optional(project(":spring-orm")) // for JPA exception translation support
|
||||
optional(project(":spring-tx")) // for JPA, @Transactional support
|
||||
optional("javax.cache:cache-api:1.1.0") // for JCache aspect
|
||||
optional("javax.cache:cache-api:1.1.0") // for JCache aspect
|
||||
optional("javax.transaction:javax.transaction-api:1.3") // for @javax.transaction.Transactional support
|
||||
testCompile(project(":spring-core")) // for CodeStyleAspect
|
||||
testCompile(project(":spring-test"))
|
||||
|
||||
Vendored
+1
@@ -19,6 +19,7 @@ package org.springframework.cache.config;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import javax.cache.annotation.CacheDefaults;
|
||||
import javax.cache.annotation.CacheKey;
|
||||
import javax.cache.annotation.CachePut;
|
||||
|
||||
+1
@@ -17,6 +17,7 @@
|
||||
package org.springframework.transaction.aspectj;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -554,35 +554,42 @@ public abstract class BeanUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given type represents a "simple" property:
|
||||
* a primitive, a String or other CharSequence, a Number, a Date,
|
||||
* a URI, a URL, a Locale, a Class, or a corresponding array.
|
||||
* Check if the given type represents a "simple" property: a simple value
|
||||
* type or an array of simple value types.
|
||||
* <p>See {@link #isSimpleValueType(Class)} for the definition of <em>simple
|
||||
* value type</em>.
|
||||
* <p>Used to determine properties to check for a "simple" dependency-check.
|
||||
* @param clazz the type to check
|
||||
* @param type the type to check
|
||||
* @return whether the given type represents a "simple" property
|
||||
* @see org.springframework.beans.factory.support.RootBeanDefinition#DEPENDENCY_CHECK_SIMPLE
|
||||
* @see org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#checkDependencies
|
||||
* @see #isSimpleValueType(Class)
|
||||
*/
|
||||
public static boolean isSimpleProperty(Class<?> clazz) {
|
||||
Assert.notNull(clazz, "Class must not be null");
|
||||
return isSimpleValueType(clazz) || (clazz.isArray() && isSimpleValueType(clazz.getComponentType()));
|
||||
public static boolean isSimpleProperty(Class<?> type) {
|
||||
Assert.notNull(type, "'type' must not be null");
|
||||
return isSimpleValueType(type) || (type.isArray() && isSimpleValueType(type.getComponentType()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given type represents a "simple" value type:
|
||||
* a primitive, an enum, a String or other CharSequence, a Number, a Date,
|
||||
* a URI, a URL, a Locale or a Class.
|
||||
* @param clazz the type to check
|
||||
* Check if the given type represents a "simple" value type: a primitive or
|
||||
* primitive wrapper, an enum, a String or other CharSequence, a Number, a
|
||||
* Date, a URI, a URL, a Locale, or a Class.
|
||||
* <p>{@code Void} and {@code void} are not considered simple value types.
|
||||
* @param type the type to check
|
||||
* @return whether the given type represents a "simple" value type
|
||||
* @see #isSimpleProperty(Class)
|
||||
*/
|
||||
public static boolean isSimpleValueType(Class<?> clazz) {
|
||||
return (ClassUtils.isPrimitiveOrWrapper(clazz) ||
|
||||
Enum.class.isAssignableFrom(clazz) ||
|
||||
CharSequence.class.isAssignableFrom(clazz) ||
|
||||
Number.class.isAssignableFrom(clazz) ||
|
||||
Date.class.isAssignableFrom(clazz) ||
|
||||
URI.class == clazz || URL.class == clazz ||
|
||||
Locale.class == clazz || Class.class == clazz);
|
||||
public static boolean isSimpleValueType(Class<?> type) {
|
||||
return (type != void.class && type != Void.class &&
|
||||
(ClassUtils.isPrimitiveOrWrapper(type) ||
|
||||
Enum.class.isAssignableFrom(type) ||
|
||||
CharSequence.class.isAssignableFrom(type) ||
|
||||
Number.class.isAssignableFrom(type) ||
|
||||
Date.class.isAssignableFrom(type) ||
|
||||
URI.class == type ||
|
||||
URL.class == type ||
|
||||
Locale.class == type ||
|
||||
Class.class == type));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+14
-12
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,19 +23,21 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Marks a constructor, field, setter method or config method as to be autowired by
|
||||
* Marks a constructor, field, setter method, or config method as to be autowired by
|
||||
* Spring's dependency injection facilities. This is an alternative to the JSR-330
|
||||
* {@link javax.inject.Inject} annotation, adding required-vs-optional semantics.
|
||||
*
|
||||
* <p>Only one constructor (at max) of any given bean class may declare this annotation
|
||||
* with the 'required' parameter set to {@code true}, indicating <i>the</i> constructor
|
||||
* to autowire when used as a Spring bean. If multiple <i>non-required</i> constructors
|
||||
* declare the annotation, they will be considered as candidates for autowiring.
|
||||
* The constructor with the greatest number of dependencies that can be satisfied by
|
||||
* matching beans in the Spring container will be chosen. If none of the candidates
|
||||
* can be satisfied, then a primary/default constructor (if present) will be used.
|
||||
* If a class only declares a single constructor to begin with, it will always be used,
|
||||
* even if not annotated. An annotated constructor does not have to be public.
|
||||
* <p>Only one constructor of any given bean class may declare this annotation with
|
||||
* the 'required' attribute set to {@code true}, indicating <i>the</i> constructor
|
||||
* to autowire when used as a Spring bean. Furthermore, if the 'required' attribute
|
||||
* is set to {@code true}, only a single constructor may be annotated with
|
||||
* {@code @Autowired}. If multiple <i>non-required</i> constructors declare the
|
||||
* annotation, they will be considered as candidates for autowiring. The constructor
|
||||
* with the greatest number of dependencies that can be satisfied by matching beans
|
||||
* in the Spring container will be chosen. If none of the candidates can be satisfied,
|
||||
* then a primary/default constructor (if present) will be used. If a class only
|
||||
* declares a single constructor to begin with, it will always be used, even if not
|
||||
* annotated. An annotated constructor does not have to be public.
|
||||
*
|
||||
* <p>Fields are injected right after construction of a bean, before any config methods
|
||||
* are invoked. Such a config field does not have to be public.
|
||||
@@ -45,7 +47,7 @@ import java.lang.annotation.Target;
|
||||
* Bean property setter methods are effectively just a special case of such a general
|
||||
* config method. Such config methods do not have to be public.
|
||||
*
|
||||
* <p>In the case of a multi-arg constructor or method, the 'required' parameter is
|
||||
* <p>In the case of a multi-arg constructor or method, the 'required' attribute is
|
||||
* applicable to all arguments. Individual parameters may be declared as Java-8-style
|
||||
* {@link java.util.Optional} or, as of Spring Framework 5.0, also as {@code @Nullable}
|
||||
* or a not-null parameter type in Kotlin, overriding the base required semantics.
|
||||
|
||||
+8
-6
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -139,9 +139,10 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
|
||||
|
||||
/**
|
||||
* Create a new AutowiredAnnotationBeanPostProcessor
|
||||
* for Spring's standard {@link Autowired} annotation.
|
||||
* <p>Also supports JSR-330's {@link javax.inject.Inject} annotation, if available.
|
||||
* Create a new {@code AutowiredAnnotationBeanPostProcessor} for Spring's
|
||||
* standard {@link Autowired @Autowired} annotation.
|
||||
* <p>Also supports JSR-330's {@link javax.inject.Inject @Inject} annotation,
|
||||
* if available.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public AutowiredAnnotationBeanPostProcessor() {
|
||||
@@ -242,7 +243,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, final String beanName)
|
||||
throws BeanCreationException {
|
||||
|
||||
// Let's check for lookup methods here..
|
||||
// Let's check for lookup methods here...
|
||||
if (!this.lookupMethodsChecked.contains(beanName)) {
|
||||
try {
|
||||
ReflectionUtils.doWithMethods(beanClass, method -> {
|
||||
@@ -251,7 +252,8 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
Assert.state(this.beanFactory != null, "No BeanFactory available");
|
||||
LookupOverride override = new LookupOverride(method, lookup.value());
|
||||
try {
|
||||
RootBeanDefinition mbd = (RootBeanDefinition) this.beanFactory.getMergedBeanDefinition(beanName);
|
||||
RootBeanDefinition mbd = (RootBeanDefinition)
|
||||
this.beanFactory.getMergedBeanDefinition(beanName);
|
||||
mbd.getMethodOverrides().addOverride(override);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
|
||||
+2
-2
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -408,7 +408,7 @@ public class ConstructorArgumentValues {
|
||||
for (Map.Entry<Integer, ValueHolder> entry : this.indexedArgumentValues.entrySet()) {
|
||||
ValueHolder vh1 = entry.getValue();
|
||||
ValueHolder vh2 = that.indexedArgumentValues.get(entry.getKey());
|
||||
if (!vh1.contentEquals(vh2)) {
|
||||
if (vh2 == null || !vh1.contentEquals(vh2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -430,7 +430,7 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.containingClass);
|
||||
return (31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.containingClass));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
@@ -17,6 +17,7 @@
|
||||
package org.springframework.beans.factory.config;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.inject.Provider;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
|
||||
+2
-2
@@ -1900,8 +1900,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
}
|
||||
else {
|
||||
try {
|
||||
ReflectionUtils.makeAccessible(initMethod);
|
||||
initMethod.invoke(bean);
|
||||
ReflectionUtils.makeAccessible(methodToInvoke);
|
||||
methodToInvoke.invoke(bean);
|
||||
}
|
||||
catch (InvocationTargetException ex) {
|
||||
throw ex.getTargetException();
|
||||
|
||||
+6
-16
@@ -179,8 +179,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
@Nullable
|
||||
private MutablePropertyValues propertyValues;
|
||||
|
||||
@Nullable
|
||||
private MethodOverrides methodOverrides;
|
||||
private MethodOverrides methodOverrides = new MethodOverrides();
|
||||
|
||||
@Nullable
|
||||
private String initMethodName;
|
||||
@@ -869,9 +868,6 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
* <p>Never returns {@code null}.
|
||||
*/
|
||||
public MethodOverrides getMethodOverrides() {
|
||||
if (this.methodOverrides == null) {
|
||||
this.methodOverrides = new MethodOverrides();
|
||||
}
|
||||
return this.methodOverrides;
|
||||
}
|
||||
|
||||
@@ -880,7 +876,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public boolean hasMethodOverrides() {
|
||||
return (this.methodOverrides != null && !this.methodOverrides.isEmpty());
|
||||
return !this.methodOverrides.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1064,10 +1060,9 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
public void validate() throws BeanDefinitionValidationException {
|
||||
if (hasMethodOverrides() && getFactoryMethodName() != null) {
|
||||
throw new BeanDefinitionValidationException(
|
||||
"Cannot combine static factory method with method overrides: " +
|
||||
"the static factory method must create the instance");
|
||||
"Cannot combine factory method with container-generated method overrides: " +
|
||||
"the factory method must create the concrete bean instance.");
|
||||
}
|
||||
|
||||
if (hasBeanClass()) {
|
||||
prepareMethodOverrides();
|
||||
}
|
||||
@@ -1079,14 +1074,9 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
* @throws BeanDefinitionValidationException in case of validation failure
|
||||
*/
|
||||
public void prepareMethodOverrides() throws BeanDefinitionValidationException {
|
||||
// Check that lookup methods exists.
|
||||
// Check that lookup methods exist and determine their overloaded status.
|
||||
if (hasMethodOverrides()) {
|
||||
Set<MethodOverride> overrides = getMethodOverrides().getOverrides();
|
||||
synchronized (overrides) {
|
||||
for (MethodOverride mo : overrides) {
|
||||
prepareMethodOverride(mo);
|
||||
}
|
||||
}
|
||||
getMethodOverrides().getOverrides().forEach(this::prepareMethodOverride);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -249,7 +249,7 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt
|
||||
public int accept(Method method) {
|
||||
MethodOverride methodOverride = getBeanDefinition().getMethodOverrides().getOverride(method);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Override for '" + method.getName() + "' is [" + methodOverride + "]");
|
||||
logger.trace("MethodOverride for " + method + ": " + methodOverride);
|
||||
}
|
||||
if (methodOverride == null) {
|
||||
return PASSTHROUGH;
|
||||
|
||||
+6
-2
@@ -43,6 +43,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.inject.Provider;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -321,7 +322,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
this.allowEagerClassLoading = otherListableFactory.allowEagerClassLoading;
|
||||
this.dependencyComparator = otherListableFactory.dependencyComparator;
|
||||
// A clone of the AutowireCandidateResolver since it is potentially BeanFactoryAware...
|
||||
setAutowireCandidateResolver(BeanUtils.instantiateClass(getAutowireCandidateResolver().getClass()));
|
||||
setAutowireCandidateResolver(
|
||||
BeanUtils.instantiateClass(otherListableFactory.getAutowireCandidateResolver().getClass()));
|
||||
// Make resolvable dependencies (e.g. ResourceLoader) available here as well...
|
||||
this.resolvableDependencies.putAll(otherListableFactory.resolvableDependencies);
|
||||
}
|
||||
@@ -1002,7 +1004,9 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
for (String bdName : this.beanDefinitionNames) {
|
||||
if (!beanName.equals(bdName)) {
|
||||
BeanDefinition bd = this.beanDefinitionMap.get(bdName);
|
||||
if (beanName.equals(bd.getParentName())) {
|
||||
// Ensure bd is non-null due to potential concurrent modification
|
||||
// of the beanDefinitionMap.
|
||||
if (bd != null && beanName.equals(bd.getParentName())) {
|
||||
resetBeanDefinition(bdName);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -571,8 +571,8 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
|
||||
bean.destroy();
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Destroy method on bean with name '" + beanName + "' threw an exception", ex);
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Destruction of bean with name '" + beanName + "' threw an exception", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -261,10 +261,10 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
catch (Throwable ex) {
|
||||
String msg = "Invocation of destroy method failed on bean with name '" + this.beanName + "'";
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.info(msg, ex);
|
||||
logger.warn(msg, ex);
|
||||
}
|
||||
else {
|
||||
logger.info(msg + ": " + ex);
|
||||
logger.warn(msg + ": " + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -343,14 +343,14 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
String msg = "Destroy method '" + this.destroyMethodName + "' on bean with name '" +
|
||||
this.beanName + "' threw an exception";
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.info(msg, ex.getTargetException());
|
||||
logger.warn(msg, ex.getTargetException());
|
||||
}
|
||||
else {
|
||||
logger.info(msg + ": " + ex.getTargetException());
|
||||
logger.warn(msg + ": " + ex.getTargetException());
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
logger.info("Failed to invoke destroy method '" + this.destroyMethodName +
|
||||
logger.warn("Failed to invoke destroy method '" + this.destroyMethodName +
|
||||
"' on bean with name '" + this.beanName + "'", ex);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-2
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ package org.springframework.beans.factory.support;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* GenericBeanDefinition is a one-stop shop for standard bean definition purposes.
|
||||
@@ -84,7 +85,14 @@ public class GenericBeanDefinition extends AbstractBeanDefinition {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return (this == other || (other instanceof GenericBeanDefinition && super.equals(other)));
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof GenericBeanDefinition)) {
|
||||
return false;
|
||||
}
|
||||
GenericBeanDefinition that = (GenericBeanDefinition) other;
|
||||
return (ObjectUtils.nullSafeEquals(this.parentName, that.parentName) && super.equals(other));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+9
-21
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,9 +17,8 @@
|
||||
package org.springframework.beans.factory.support;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -37,9 +36,7 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public class MethodOverrides {
|
||||
|
||||
private final Set<MethodOverride> overrides = Collections.synchronizedSet(new LinkedHashSet<>(2));
|
||||
|
||||
private volatile boolean modified = false;
|
||||
private final Set<MethodOverride> overrides = new CopyOnWriteArraySet<>();
|
||||
|
||||
|
||||
/**
|
||||
@@ -61,7 +58,6 @@ public class MethodOverrides {
|
||||
*/
|
||||
public void addOverrides(@Nullable MethodOverrides other) {
|
||||
if (other != null) {
|
||||
this.modified = true;
|
||||
this.overrides.addAll(other.overrides);
|
||||
}
|
||||
}
|
||||
@@ -70,7 +66,6 @@ public class MethodOverrides {
|
||||
* Add the given method override.
|
||||
*/
|
||||
public void addOverride(MethodOverride override) {
|
||||
this.modified = true;
|
||||
this.overrides.add(override);
|
||||
}
|
||||
|
||||
@@ -80,7 +75,6 @@ public class MethodOverrides {
|
||||
* @see MethodOverride
|
||||
*/
|
||||
public Set<MethodOverride> getOverrides() {
|
||||
this.modified = true;
|
||||
return this.overrides;
|
||||
}
|
||||
|
||||
@@ -88,7 +82,7 @@ public class MethodOverrides {
|
||||
* Return whether the set of method overrides is empty.
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return (!this.modified || this.overrides.isEmpty());
|
||||
return this.overrides.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,18 +92,13 @@ public class MethodOverrides {
|
||||
*/
|
||||
@Nullable
|
||||
public MethodOverride getOverride(Method method) {
|
||||
if (!this.modified) {
|
||||
return null;
|
||||
}
|
||||
synchronized (this.overrides) {
|
||||
MethodOverride match = null;
|
||||
for (MethodOverride candidate : this.overrides) {
|
||||
if (candidate.matches(method)) {
|
||||
match = candidate;
|
||||
}
|
||||
MethodOverride match = null;
|
||||
for (MethodOverride candidate : this.overrides) {
|
||||
if (candidate.matches(method)) {
|
||||
match = candidate;
|
||||
}
|
||||
return match;
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +112,6 @@ public class MethodOverrides {
|
||||
}
|
||||
MethodOverrides that = (MethodOverrides) other;
|
||||
return this.overrides.equals(that.overrides);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+64
-12
@@ -643,6 +643,9 @@ public class BeanDefinitionParserDelegate {
|
||||
parentName, className, this.readerContext.getBeanClassLoader());
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the meta elements underneath the given element, if any.
|
||||
*/
|
||||
public void parseMetaElements(Element ele, BeanMetadataAttributeAccessor attributeAccessor) {
|
||||
NodeList nl = ele.getChildNodes();
|
||||
for (int i = 0; i < nl.getLength(); i++) {
|
||||
@@ -658,23 +661,27 @@ public class BeanDefinitionParserDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the given autowire attribute value into
|
||||
* {@link AbstractBeanDefinition} autowire constants.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getAutowireMode(String attValue) {
|
||||
String att = attValue;
|
||||
if (isDefaultValue(att)) {
|
||||
att = this.defaults.getAutowire();
|
||||
public int getAutowireMode(String attrValue) {
|
||||
String attr = attrValue;
|
||||
if (isDefaultValue(attr)) {
|
||||
attr = this.defaults.getAutowire();
|
||||
}
|
||||
int autowire = AbstractBeanDefinition.AUTOWIRE_NO;
|
||||
if (AUTOWIRE_BY_NAME_VALUE.equals(att)) {
|
||||
if (AUTOWIRE_BY_NAME_VALUE.equals(attr)) {
|
||||
autowire = AbstractBeanDefinition.AUTOWIRE_BY_NAME;
|
||||
}
|
||||
else if (AUTOWIRE_BY_TYPE_VALUE.equals(att)) {
|
||||
else if (AUTOWIRE_BY_TYPE_VALUE.equals(attr)) {
|
||||
autowire = AbstractBeanDefinition.AUTOWIRE_BY_TYPE;
|
||||
}
|
||||
else if (AUTOWIRE_CONSTRUCTOR_VALUE.equals(att)) {
|
||||
else if (AUTOWIRE_CONSTRUCTOR_VALUE.equals(attr)) {
|
||||
autowire = AbstractBeanDefinition.AUTOWIRE_CONSTRUCTOR;
|
||||
}
|
||||
else if (AUTOWIRE_AUTODETECT_VALUE.equals(att)) {
|
||||
else if (AUTOWIRE_AUTODETECT_VALUE.equals(attr)) {
|
||||
autowire = AbstractBeanDefinition.AUTOWIRE_AUTODETECT;
|
||||
}
|
||||
// Else leave default value.
|
||||
@@ -953,6 +960,12 @@ public class BeanDefinitionParserDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a value, ref or collection sub-element of a property or
|
||||
* constructor-arg element.
|
||||
* @param ele subelement of property element; we don't know which yet
|
||||
* @param bd the current bean definition (if any)
|
||||
*/
|
||||
@Nullable
|
||||
public Object parsePropertySubElement(Element ele, @Nullable BeanDefinition bd) {
|
||||
return parsePropertySubElement(ele, bd, null);
|
||||
@@ -962,6 +975,7 @@ public class BeanDefinitionParserDelegate {
|
||||
* Parse a value, ref or collection sub-element of a property or
|
||||
* constructor-arg element.
|
||||
* @param ele subelement of property element; we don't know which yet
|
||||
* @param bd the current bean definition (if any)
|
||||
* @param defaultValueType the default type (class name) for any
|
||||
* {@code <value>} tag that might be created
|
||||
*/
|
||||
@@ -1347,11 +1361,22 @@ public class BeanDefinitionParserDelegate {
|
||||
return TRUE_VALUE.equals(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a custom element (outside of the default namespace).
|
||||
* @param ele the element to parse
|
||||
* @return the resulting bean definition
|
||||
*/
|
||||
@Nullable
|
||||
public BeanDefinition parseCustomElement(Element ele) {
|
||||
return parseCustomElement(ele, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a custom element (outside of the default namespace).
|
||||
* @param ele the element to parse
|
||||
* @param containingBd the containing bean definition (if any)
|
||||
* @return the resulting bean definition
|
||||
*/
|
||||
@Nullable
|
||||
public BeanDefinition parseCustomElement(Element ele, @Nullable BeanDefinition containingBd) {
|
||||
String namespaceUri = getNamespaceURI(ele);
|
||||
@@ -1366,14 +1391,27 @@ public class BeanDefinitionParserDelegate {
|
||||
return handler.parse(ele, new ParserContext(this.readerContext, this, containingBd));
|
||||
}
|
||||
|
||||
public BeanDefinitionHolder decorateBeanDefinitionIfRequired(Element ele, BeanDefinitionHolder definitionHolder) {
|
||||
return decorateBeanDefinitionIfRequired(ele, definitionHolder, null);
|
||||
/**
|
||||
* Decorate the given bean definition through a namespace handler, if applicable.
|
||||
* @param ele the current element
|
||||
* @param originalDef the current bean definition
|
||||
* @return the decorated bean definition
|
||||
*/
|
||||
public BeanDefinitionHolder decorateBeanDefinitionIfRequired(Element ele, BeanDefinitionHolder originalDef) {
|
||||
return decorateBeanDefinitionIfRequired(ele, originalDef, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorate the given bean definition through a namespace handler, if applicable.
|
||||
* @param ele the current element
|
||||
* @param originalDef the current bean definition
|
||||
* @param containingBd the containing bean definition (if any)
|
||||
* @return the decorated bean definition
|
||||
*/
|
||||
public BeanDefinitionHolder decorateBeanDefinitionIfRequired(
|
||||
Element ele, BeanDefinitionHolder definitionHolder, @Nullable BeanDefinition containingBd) {
|
||||
Element ele, BeanDefinitionHolder originalDef, @Nullable BeanDefinition containingBd) {
|
||||
|
||||
BeanDefinitionHolder finalDefinition = definitionHolder;
|
||||
BeanDefinitionHolder finalDefinition = originalDef;
|
||||
|
||||
// Decorate based on custom attributes first.
|
||||
NamedNodeMap attributes = ele.getAttributes();
|
||||
@@ -1393,6 +1431,14 @@ public class BeanDefinitionParserDelegate {
|
||||
return finalDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorate the given bean definition through a namespace handler,
|
||||
* if applicable.
|
||||
* @param node the current child node
|
||||
* @param originalDef the current bean definition
|
||||
* @param containingBd the containing bean definition (if any)
|
||||
* @return the decorated bean definition
|
||||
*/
|
||||
public BeanDefinitionHolder decorateIfRequired(
|
||||
Node node, BeanDefinitionHolder originalDef, @Nullable BeanDefinition containingBd) {
|
||||
|
||||
@@ -1473,10 +1519,16 @@ public class BeanDefinitionParserDelegate {
|
||||
return desiredName.equals(node.getNodeName()) || desiredName.equals(getLocalName(node));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the given URI indicates the default namespace.
|
||||
*/
|
||||
public boolean isDefaultNamespace(@Nullable String namespaceUri) {
|
||||
return (!StringUtils.hasLength(namespaceUri) || BEANS_NAMESPACE_URI.equals(namespaceUri));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the given node indicates the default namespace.
|
||||
*/
|
||||
public boolean isDefaultNamespace(Node node) {
|
||||
return isDefaultNamespace(getNamespaceURI(node));
|
||||
}
|
||||
|
||||
+1
@@ -20,6 +20,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,8 +19,14 @@ package org.springframework.beans;
|
||||
import java.beans.Introspector;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.time.DayOfWeek;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -32,7 +38,12 @@ import org.springframework.tests.sample.beans.DerivedTestBean;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link BeanUtils}.
|
||||
@@ -40,6 +51,7 @@ import static org.junit.Assert.*;
|
||||
* @author Juergen Hoeller
|
||||
* @author Rob Harrop
|
||||
* @author Chris Beams
|
||||
* @author Sam Brannen
|
||||
* @since 19.05.2003
|
||||
*/
|
||||
public class BeanUtilsTests {
|
||||
@@ -275,6 +287,60 @@ public class BeanUtilsTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSimpleValueType() {
|
||||
Stream.of(
|
||||
|
||||
boolean.class, char.class, byte.class, short.class, int.class,
|
||||
long.class, float.class, double.class,
|
||||
|
||||
Boolean.class, Character.class, Byte.class, Short.class, Integer.class,
|
||||
Long.class, Float.class, Double.class,
|
||||
|
||||
DayOfWeek.class, String.class, Date.class, URI.class, URL.class, Locale.class, Class.class
|
||||
|
||||
).forEach(this::assertIsSimpleValueType);
|
||||
|
||||
Stream.of(int[].class, Object.class, List.class, void.class, Void.class)
|
||||
.forEach(this::assertIsNotSimpleValueType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSimpleProperty() {
|
||||
Stream.of(
|
||||
|
||||
boolean.class, char.class, byte.class, short.class, int.class,
|
||||
long.class, float.class, double.class,
|
||||
|
||||
Boolean.class, Character.class, Byte.class, Short.class, Integer.class,
|
||||
Long.class, Float.class, Double.class,
|
||||
|
||||
DayOfWeek.class, String.class, Date.class, URI.class, URL.class, Locale.class, Class.class,
|
||||
|
||||
boolean[].class, Boolean[].class, Date[].class
|
||||
|
||||
).forEach(this::assertIsSimpleProperty);
|
||||
|
||||
Stream.of(Object.class, List.class, void.class, Void.class)
|
||||
.forEach(this::assertIsNotSimpleProperty);
|
||||
}
|
||||
|
||||
private void assertIsSimpleValueType(Class<?> type) {
|
||||
assertTrue("Type [" + type.getName() + "] should be a simple value type", BeanUtils.isSimpleValueType(type));
|
||||
}
|
||||
|
||||
private void assertIsNotSimpleValueType(Class<?> type) {
|
||||
assertFalse("Type [" + type.getName() + "] should not be a simple value type", BeanUtils.isSimpleValueType(type));
|
||||
}
|
||||
|
||||
private void assertIsSimpleProperty(Class<?> type) {
|
||||
assertTrue("Type [" + type.getName() + "] should be a simple property", BeanUtils.isSimpleProperty(type));
|
||||
}
|
||||
|
||||
private void assertIsNotSimpleProperty(Class<?> type) {
|
||||
assertFalse("Type [" + type.getName() + "] should not be a simple property", BeanUtils.isSimpleProperty(type));
|
||||
}
|
||||
|
||||
private void assertSignatureEquals(Method desiredMethod, String signature) {
|
||||
assertEquals(desiredMethod, BeanUtils.resolveSignature(signature, MethodSignatureBean.class));
|
||||
}
|
||||
@@ -445,6 +511,7 @@ public class BeanUtilsTests {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class BeanWithSingleNonDefaultConstructor {
|
||||
|
||||
private final String name;
|
||||
|
||||
+62
-22
@@ -38,6 +38,8 @@ import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import javax.annotation.Priority;
|
||||
import javax.security.auth.Subject;
|
||||
|
||||
@@ -792,6 +794,18 @@ public class DefaultListableBeanFactoryTests {
|
||||
lbf.registerAlias("test", "test3");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAliasChaining() {
|
||||
lbf.registerBeanDefinition("test", new RootBeanDefinition(NestedTestBean.class));
|
||||
lbf.registerAlias("test", "testAlias");
|
||||
lbf.registerAlias("testAlias", "testAlias2");
|
||||
lbf.registerAlias("testAlias2", "testAlias3");
|
||||
Object bean = lbf.getBean("test");
|
||||
assertSame(bean, lbf.getBean("testAlias"));
|
||||
assertSame(bean, lbf.getBean("testAlias2"));
|
||||
assertSame(bean, lbf.getBean("testAlias3"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBeanDefinitionOverriding() {
|
||||
lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class));
|
||||
@@ -802,20 +816,6 @@ public class DefaultListableBeanFactoryTests {
|
||||
assertTrue(lbf.getBean("test2") instanceof NestedTestBean);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBeanDefinitionRemoval() {
|
||||
lbf.setAllowBeanDefinitionOverriding(false);
|
||||
lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class));
|
||||
lbf.registerAlias("test", "test2");
|
||||
lbf.preInstantiateSingletons();
|
||||
lbf.removeBeanDefinition("test");
|
||||
lbf.removeAlias("test2");
|
||||
lbf.registerBeanDefinition("test", new RootBeanDefinition(NestedTestBean.class));
|
||||
lbf.registerAlias("test", "test2");
|
||||
assertTrue(lbf.getBean("test") instanceof NestedTestBean);
|
||||
assertTrue(lbf.getBean("test2") instanceof NestedTestBean);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBeanDefinitionOverridingNotAllowed() {
|
||||
lbf.setAllowBeanDefinitionOverriding(false);
|
||||
@@ -844,15 +844,55 @@ public class DefaultListableBeanFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAliasChaining() {
|
||||
public void beanDefinitionOverridingWithConstructorArgumentMismatch() {
|
||||
RootBeanDefinition bd1 = new RootBeanDefinition(NestedTestBean.class);
|
||||
bd1.getConstructorArgumentValues().addIndexedArgumentValue(1, "value1");
|
||||
lbf.registerBeanDefinition("test", bd1);
|
||||
RootBeanDefinition bd2 = new RootBeanDefinition(NestedTestBean.class);
|
||||
bd2.getConstructorArgumentValues().addIndexedArgumentValue(0, "value0");
|
||||
lbf.registerBeanDefinition("test", bd2);
|
||||
assertTrue(lbf.getBean("test") instanceof NestedTestBean);
|
||||
assertEquals("value0", lbf.getBean("test", NestedTestBean.class).getCompany());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBeanDefinitionRemoval() {
|
||||
lbf.setAllowBeanDefinitionOverriding(false);
|
||||
lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class));
|
||||
lbf.registerAlias("test", "test2");
|
||||
lbf.preInstantiateSingletons();
|
||||
lbf.removeBeanDefinition("test");
|
||||
lbf.removeAlias("test2");
|
||||
lbf.registerBeanDefinition("test", new RootBeanDefinition(NestedTestBean.class));
|
||||
lbf.registerAlias("test", "testAlias");
|
||||
lbf.registerAlias("testAlias", "testAlias2");
|
||||
lbf.registerAlias("testAlias2", "testAlias3");
|
||||
Object bean = lbf.getBean("test");
|
||||
assertSame(bean, lbf.getBean("testAlias"));
|
||||
assertSame(bean, lbf.getBean("testAlias2"));
|
||||
assertSame(bean, lbf.getBean("testAlias3"));
|
||||
lbf.registerAlias("test", "test2");
|
||||
assertTrue(lbf.getBean("test") instanceof NestedTestBean);
|
||||
assertTrue(lbf.getBean("test2") instanceof NestedTestBean);
|
||||
}
|
||||
|
||||
@Test // gh-23542
|
||||
public void concurrentBeanDefinitionRemoval() {
|
||||
final int MAX = 200;
|
||||
lbf.setAllowBeanDefinitionOverriding(false);
|
||||
|
||||
// Register the bean definitions before invoking preInstantiateSingletons()
|
||||
// to simulate realistic usage of an ApplicationContext; otherwise, the bean
|
||||
// factory thinks it's an "empty" factory which causes this test to fail in
|
||||
// an unrealistic manner.
|
||||
IntStream.range(0, MAX).forEach(this::registerTestBean);
|
||||
lbf.preInstantiateSingletons();
|
||||
|
||||
// This test is considered successful if the following does not result in an exception.
|
||||
IntStream.range(0, MAX).parallel().forEach(this::removeTestBean);
|
||||
}
|
||||
|
||||
private void registerTestBean(int i) {
|
||||
String name = "test" + i;
|
||||
lbf.registerBeanDefinition(name, new RootBeanDefinition(TestBean.class));
|
||||
}
|
||||
|
||||
private void removeTestBean(int i) {
|
||||
String name = "test" + i;
|
||||
lbf.removeBeanDefinition(name);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+1
@@ -22,6 +22,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Provider;
|
||||
|
||||
+1
@@ -17,6 +17,7 @@
|
||||
package org.springframework.beans.factory.config;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.inject.Provider;
|
||||
|
||||
import org.junit.After;
|
||||
|
||||
+1
@@ -18,6 +18,7 @@ package org.springframework.beans.factory.serviceloader;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
+22
-1
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -100,6 +100,27 @@ public class BeanDefinitionTests {
|
||||
assertTrue(bd.hashCode() == otherBd.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void genericBeanDefinitionEquality() {
|
||||
GenericBeanDefinition bd = new GenericBeanDefinition();
|
||||
bd.setParentName("parent");
|
||||
bd.setScope("request");
|
||||
bd.setAbstract(true);
|
||||
bd.setLazyInit(true);
|
||||
GenericBeanDefinition otherBd = new GenericBeanDefinition();
|
||||
otherBd.setScope("request");
|
||||
otherBd.setAbstract(true);
|
||||
otherBd.setLazyInit(true);
|
||||
boolean condition1 = !bd.equals(otherBd);
|
||||
assertTrue(condition1);
|
||||
boolean condition = !otherBd.equals(bd);
|
||||
assertTrue(condition);
|
||||
otherBd.setParentName("parent");
|
||||
assertTrue(bd.equals(otherBd));
|
||||
assertTrue(otherBd.equals(bd));
|
||||
assertTrue(bd.hashCode() == otherBd.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void beanDefinitionHolderEquality() {
|
||||
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
|
||||
|
||||
+1
@@ -28,6 +28,7 @@ import java.security.PrivilegedExceptionAction;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.PropertyPermission;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.security.auth.AuthPermission;
|
||||
import javax.security.auth.Subject;
|
||||
|
||||
|
||||
+1
@@ -23,6 +23,7 @@ import java.util.EnumSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.processing.Completion;
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
import javax.annotation.processing.Processor;
|
||||
|
||||
+1
@@ -19,6 +19,7 @@ package org.springframework.context.index.processor;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.lang.model.element.AnnotationMirror;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ElementKind;
|
||||
|
||||
+1
@@ -20,6 +20,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.lang.model.element.Element;
|
||||
|
||||
+1
@@ -19,6 +19,7 @@ package org.springframework.context.index.processor;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
import javax.tools.FileObject;
|
||||
import javax.tools.StandardLocation;
|
||||
|
||||
+1
@@ -18,6 +18,7 @@ package org.springframework.context.index.processor;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ElementKind;
|
||||
|
||||
|
||||
+1
@@ -18,6 +18,7 @@ package org.springframework.context.index.processor;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.lang.model.element.AnnotationMirror;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ElementKind;
|
||||
|
||||
+1
@@ -17,6 +17,7 @@
|
||||
package org.springframework.context.index.processor;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
|
||||
/**
|
||||
|
||||
+1
@@ -19,6 +19,7 @@ package org.springframework.context.index.processor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
import javax.lang.model.element.AnnotationMirror;
|
||||
import javax.lang.model.element.Element;
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@ package org.springframework.context.index.processor;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.ManagedBean;
|
||||
import javax.inject.Named;
|
||||
import javax.persistence.Converter;
|
||||
@@ -37,6 +38,7 @@ import org.springframework.context.index.sample.AbstractController;
|
||||
import org.springframework.context.index.sample.MetaControllerIndexed;
|
||||
import org.springframework.context.index.sample.SampleComponent;
|
||||
import org.springframework.context.index.sample.SampleController;
|
||||
import org.springframework.context.index.sample.SampleEmbedded;
|
||||
import org.springframework.context.index.sample.SampleMetaController;
|
||||
import org.springframework.context.index.sample.SampleMetaIndexedController;
|
||||
import org.springframework.context.index.sample.SampleNonStaticEmbedded;
|
||||
@@ -48,7 +50,6 @@ import org.springframework.context.index.sample.cdi.SampleNamed;
|
||||
import org.springframework.context.index.sample.cdi.SampleTransactional;
|
||||
import org.springframework.context.index.sample.jpa.SampleConverter;
|
||||
import org.springframework.context.index.sample.jpa.SampleEmbeddable;
|
||||
import org.springframework.context.index.sample.SampleEmbedded;
|
||||
import org.springframework.context.index.sample.jpa.SampleEntity;
|
||||
import org.springframework.context.index.sample.jpa.SampleMappedSuperClass;
|
||||
import org.springframework.context.index.sample.type.Repo;
|
||||
|
||||
+1
@@ -22,6 +22,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.processing.Processor;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaFileObject;
|
||||
|
||||
@@ -16,7 +16,7 @@ dependencies {
|
||||
optional("org.freemarker:freemarker:${freemarkerVersion}")
|
||||
testCompile(project(":spring-context"))
|
||||
testCompile("org.hsqldb:hsqldb:${hsqldbVersion}")
|
||||
testCompile("org.hibernate:hibernate-validator:6.0.16.Final")
|
||||
testCompile("org.hibernate:hibernate-validator:6.0.17.Final")
|
||||
testCompile("javax.annotation:javax.annotation-api:1.3.2")
|
||||
testRuntime("org.ehcache:jcache:1.0.1")
|
||||
testRuntime("org.ehcache:ehcache:3.4.0")
|
||||
|
||||
+1
@@ -17,6 +17,7 @@
|
||||
package org.springframework.cache.jcache;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import javax.cache.Cache;
|
||||
import javax.cache.processor.EntryProcessor;
|
||||
import javax.cache.processor.EntryProcessorException;
|
||||
|
||||
Vendored
+1
@@ -18,6 +18,7 @@ package org.springframework.cache.jcache;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
import javax.cache.CacheManager;
|
||||
import javax.cache.Caching;
|
||||
|
||||
|
||||
Vendored
+1
@@ -18,6 +18,7 @@ package org.springframework.cache.jcache;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.cache.CacheManager;
|
||||
import javax.cache.Caching;
|
||||
|
||||
|
||||
+3
-3
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -59,7 +59,7 @@ abstract class AbstractCacheInterceptor<O extends AbstractJCacheOperation<A>, A
|
||||
/**
|
||||
* Resolve the cache to use.
|
||||
* @param context the invocation context
|
||||
* @return the cache to use (never null)
|
||||
* @return the cache to use (never {@code null})
|
||||
*/
|
||||
protected Cache resolveCache(CacheOperationInvocationContext<O> context) {
|
||||
Collection<? extends Cache> caches = context.getOperation().getCacheResolver().resolveCaches(context);
|
||||
@@ -73,7 +73,7 @@ abstract class AbstractCacheInterceptor<O extends AbstractJCacheOperation<A>, A
|
||||
/**
|
||||
* Convert the collection of caches in a single expected element.
|
||||
* <p>Throw an {@link IllegalStateException} if the collection holds more than one element
|
||||
* @return the single element or {@code null} if the collection is empty
|
||||
* @return the single element, or {@code null} if the collection is empty
|
||||
*/
|
||||
@Nullable
|
||||
static Cache extractFrom(Collection<? extends Cache> caches) {
|
||||
|
||||
+1
@@ -19,6 +19,7 @@ package org.springframework.cache.jcache.interceptor;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.cache.annotation.CacheInvocationParameter;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
|
||||
|
||||
+1
@@ -24,6 +24,7 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.cache.annotation.CacheInvocationParameter;
|
||||
import javax.cache.annotation.CacheKey;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
|
||||
+1
@@ -17,6 +17,7 @@
|
||||
package org.springframework.cache.jcache.interceptor;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
import javax.cache.annotation.CacheKeyInvocationContext;
|
||||
|
||||
import org.springframework.cache.interceptor.CacheErrorHandler;
|
||||
|
||||
+1
@@ -20,6 +20,7 @@ import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.cache.annotation.CacheDefaults;
|
||||
import javax.cache.annotation.CacheKeyGenerator;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
|
||||
+1
@@ -18,6 +18,7 @@ package org.springframework.cache.jcache.interceptor;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
import javax.cache.annotation.CacheInvocationParameter;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
import javax.cache.annotation.CachePut;
|
||||
|
||||
+3
-4
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,7 +42,6 @@ class CacheRemoveAllInterceptor extends AbstractCacheInterceptor<CacheRemoveAllO
|
||||
CacheOperationInvocationContext<CacheRemoveAllOperation> context, CacheOperationInvoker invoker) {
|
||||
|
||||
CacheRemoveAllOperation operation = context.getOperation();
|
||||
|
||||
boolean earlyRemove = operation.isEarlyRemove();
|
||||
if (earlyRemove) {
|
||||
removeAll(context);
|
||||
@@ -67,8 +66,8 @@ class CacheRemoveAllInterceptor extends AbstractCacheInterceptor<CacheRemoveAllO
|
||||
protected void removeAll(CacheOperationInvocationContext<CacheRemoveAllOperation> context) {
|
||||
Cache cache = resolveCache(context);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Invalidating entire cache '" + cache.getName() + "' for operation "
|
||||
+ context.getOperation());
|
||||
logger.trace("Invalidating entire cache '" + cache.getName() + "' for operation " +
|
||||
context.getOperation());
|
||||
}
|
||||
doClear(cache);
|
||||
}
|
||||
|
||||
+3
-4
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,7 +42,6 @@ class CacheRemoveEntryInterceptor extends AbstractKeyCacheInterceptor<CacheRemov
|
||||
CacheOperationInvocationContext<CacheRemoveOperation> context, CacheOperationInvoker invoker) {
|
||||
|
||||
CacheRemoveOperation operation = context.getOperation();
|
||||
|
||||
boolean earlyRemove = operation.isEarlyRemove();
|
||||
if (earlyRemove) {
|
||||
removeValue(context);
|
||||
@@ -68,8 +67,8 @@ class CacheRemoveEntryInterceptor extends AbstractKeyCacheInterceptor<CacheRemov
|
||||
Object key = generateKey(context);
|
||||
Cache cache = resolveCache(context);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Invalidating key [" + key + "] on cache '" + cache.getName()
|
||||
+ "' for operation " + context.getOperation());
|
||||
logger.trace("Invalidating key [" + key + "] on cache '" + cache.getName() +
|
||||
"' for operation " + context.getOperation());
|
||||
}
|
||||
doEvict(cache, key);
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2019 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,8 +50,8 @@ class CacheRemoveOperation extends AbstractJCacheKeyOperation<CacheRemove> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify if the cache entry should be remove before invoking the method. By default, the
|
||||
* cache entry is removed after the method invocation.
|
||||
* Specify if the cache entry should be removed before invoking the method.
|
||||
* <p>By default, the cache entry is removed after the method invocation.
|
||||
* @see javax.cache.annotation.CacheRemove#afterInvocation()
|
||||
*/
|
||||
public boolean isEarlyRemove() {
|
||||
|
||||
+1
@@ -18,6 +18,7 @@ package org.springframework.cache.jcache.interceptor;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.cache.annotation.CacheInvocationContext;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
|
||||
+1
@@ -20,6 +20,7 @@ import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.cache.annotation.CacheInvocationContext;
|
||||
import javax.cache.annotation.CacheInvocationParameter;
|
||||
|
||||
|
||||
+1
@@ -17,6 +17,7 @@
|
||||
package org.springframework.cache.jcache.interceptor;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
import javax.cache.annotation.CacheInvocationParameter;
|
||||
import javax.cache.annotation.CacheKeyInvocationContext;
|
||||
|
||||
|
||||
+1
@@ -22,6 +22,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
|
||||
/**
|
||||
|
||||
+1
@@ -17,6 +17,7 @@
|
||||
package org.springframework.cache.jcache.interceptor;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
import javax.cache.annotation.CacheInvocationParameter;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
|
||||
|
||||
+1
@@ -20,6 +20,7 @@ import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.cache.annotation.CacheInvocationParameter;
|
||||
import javax.cache.annotation.CacheKeyGenerator;
|
||||
import javax.cache.annotation.CacheKeyInvocationContext;
|
||||
|
||||
+10
-7
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,14 +25,16 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Cache decorator which synchronizes its {@link #put}, {@link #evict} and {@link #clear}
|
||||
* operations with Spring-managed transactions (through Spring's {@link TransactionSynchronizationManager},
|
||||
* performing the actual cache put/evict/clear operation only in the after-commit phase of a
|
||||
* successful transaction. If no transaction is active, {@link #put}, {@link #evict} and
|
||||
* Cache decorator which synchronizes its {@link #put}, {@link #evict} and
|
||||
* {@link #clear} operations with Spring-managed transactions (through Spring's
|
||||
* {@link TransactionSynchronizationManager}, performing the actual cache
|
||||
* put/evict/clear operation only in the after-commit phase of a successful
|
||||
* transaction. If no transaction is active, {@link #put}, {@link #evict} and
|
||||
* {@link #clear} operations will be performed immediately, as usual.
|
||||
*
|
||||
* <p>Use of more aggressive operations such as {@link #putIfAbsent} cannot be deferred
|
||||
* to the after-commit phase of a running transaction. Use these with care.
|
||||
* <p><b>Note:</b> Use of immediate operations such as {@link #putIfAbsent}
|
||||
* cannot be deferred to the after-commit phase of a running transaction.
|
||||
* Use these with care in a transactional environment.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Stephane Nicoll
|
||||
@@ -54,6 +56,7 @@ public class TransactionAwareCacheDecorator implements Cache {
|
||||
this.targetCache = targetCache;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the target Cache that this Cache should delegate to.
|
||||
*/
|
||||
|
||||
+1
@@ -19,6 +19,7 @@ package org.springframework.mail.javamail;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.activation.FileTypeMap;
|
||||
import javax.activation.MimetypesFileTypeMap;
|
||||
|
||||
|
||||
+1
@@ -17,6 +17,7 @@
|
||||
package org.springframework.mail.javamail;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
|
||||
import javax.mail.internet.AddressException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
|
||||
|
||||
+1
@@ -17,6 +17,7 @@
|
||||
package org.springframework.mail.javamail;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
import org.springframework.mail.MailException;
|
||||
|
||||
+1
@@ -23,6 +23,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.activation.FileTypeMap;
|
||||
import javax.mail.Address;
|
||||
import javax.mail.AuthenticationFailedException;
|
||||
|
||||
+1
@@ -17,6 +17,7 @@
|
||||
package org.springframework.mail.javamail;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
|
||||
+1
@@ -22,6 +22,7 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import javax.activation.DataSource;
|
||||
import javax.activation.FileDataSource;
|
||||
|
||||
+1
@@ -18,6 +18,7 @@ package org.springframework.scheduling.commonj;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
|
||||
import commonj.timers.Timer;
|
||||
|
||||
+1
@@ -20,6 +20,7 @@ import java.util.Collection;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
|
||||
import commonj.work.Work;
|
||||
|
||||
+1
@@ -18,6 +18,7 @@ package org.springframework.scheduling.quartz;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.quartz.SchedulerConfigException;
|
||||
|
||||
+1
@@ -21,6 +21,7 @@ import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.quartz.Scheduler;
|
||||
|
||||
Vendored
+1
@@ -18,6 +18,7 @@ package org.springframework.cache.jcache;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.cache.Cache;
|
||||
import javax.cache.CacheManager;
|
||||
|
||||
|
||||
+1
@@ -18,6 +18,7 @@ package org.springframework.cache.jcache.interceptor;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import javax.cache.annotation.CacheInvocationParameter;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
|
||||
|
||||
+1
@@ -19,6 +19,7 @@ package org.springframework.cache.jcache.interceptor;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import javax.cache.annotation.CacheDefaults;
|
||||
import javax.cache.annotation.CacheKey;
|
||||
import javax.cache.annotation.CachePut;
|
||||
|
||||
+1
@@ -18,6 +18,7 @@ package org.springframework.cache.jcache.interceptor;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Comparator;
|
||||
|
||||
import javax.cache.annotation.CacheDefaults;
|
||||
import javax.cache.annotation.CacheKeyGenerator;
|
||||
import javax.cache.annotation.CacheRemove;
|
||||
|
||||
+1
@@ -17,6 +17,7 @@
|
||||
package org.springframework.cache.jcache.interceptor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.cache.annotation.CacheInvocationParameter;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
import javax.cache.annotation.CachePut;
|
||||
|
||||
+1
@@ -19,6 +19,7 @@ package org.springframework.cache.jcache.interceptor;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.cache.annotation.CacheInvocationContext;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
import javax.cache.annotation.CacheResolver;
|
||||
|
||||
+1
@@ -19,6 +19,7 @@ package org.springframework.cache.jcache.interceptor;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.cache.annotation.CacheInvocationParameter;
|
||||
import javax.cache.annotation.CacheKey;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user