mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Compare commits
235 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 29185a3d28 | |||
| 31a4c274b7 | |||
| d665977787 | |||
| 0b6a54dcc7 | |||
| 1885ab3e07 | |||
| de10bb69cb | |||
| c7642422c3 | |||
| 4c2e0ee5ff | |||
| 79804d92c2 | |||
| f191cf4eb3 | |||
| 0ebb1c5baa | |||
| 4b7d9b1f9c | |||
| ca84559588 | |||
| 1af21bb451 | |||
| ac581bed92 | |||
| 0802581aff | |||
| d7b9270672 | |||
| c44447f622 | |||
| 8b80d38c33 | |||
| b06d267232 | |||
| 8422d9d22f | |||
| c50a5096a0 | |||
| c25c550113 | |||
| 9e09d6cde4 | |||
| 31b8587ce6 | |||
| 00375df4e8 | |||
| b1352e1833 | |||
| b2e94f611f | |||
| ad7cdc5ce9 | |||
| 6cc9538ab9 | |||
| e9083d7d20 | |||
| 98ce171b30 | |||
| 57a5370eec | |||
| 99c7608ffe | |||
| c0f79ee00a | |||
| 9261766677 | |||
| 14f24f43d7 | |||
| d7e0eed8d2 | |||
| 7c834d98c2 | |||
| 70974e006e | |||
| 2f557d9583 | |||
| b84fe99d07 | |||
| 69df27a99f | |||
| 5649a6f8ef | |||
| be6eeafe78 | |||
| b77b45434f | |||
| 6582787678 | |||
| 8b89128c7b | |||
| 2a5713f389 | |||
| 40d2058b97 | |||
| 0d478ca8dd | |||
| 445c0def0c | |||
| ef696c787b | |||
| 27257fb82e | |||
| e209a460ca | |||
| d019c1f82b | |||
| 82d6e07090 | |||
| a1b2695c3a | |||
| 341f4882ed | |||
| 829bed03af | |||
| ce0aed216b | |||
| 0d7c562693 | |||
| 913cc079af | |||
| 3f7dec0b0d | |||
| 830cc3450f | |||
| 6f6d27f50f | |||
| 19a8b94b21 | |||
| 2c53e9e308 | |||
| 2271b6078e | |||
| e8eeb99ac8 | |||
| b67e97d388 | |||
| 656f0591c6 | |||
| 23babe27bb | |||
| bcb9f159ca | |||
| 8ca9187938 | |||
| 1e0bdf95d0 | |||
| 44da9451c4 | |||
| 544f357661 | |||
| ca4f338d75 | |||
| 8e8c88ea5c | |||
| 767299c6dd | |||
| 3290495222 | |||
| b4b3c2ead6 | |||
| dfd5374f02 | |||
| 722ab25f27 | |||
| c37d6c30a0 | |||
| 5fbdd6dcfe | |||
| 29572600dc | |||
| aaf626a537 | |||
| 9197f15a30 | |||
| 15a6373fed | |||
| 2a268701c4 | |||
| 11a0df3fd1 | |||
| b167e1a93f | |||
| 8d735e6e60 | |||
| 9bc09631d6 | |||
| 39be572a7a | |||
| 6ac780d595 | |||
| c6ce65ef56 | |||
| b5743966d6 | |||
| c5de5c9939 | |||
| ff1485fd8d | |||
| 1b4438caac | |||
| 0c7e000250 | |||
| 694db2273f | |||
| 47d3819eab | |||
| f295c8b2fb | |||
| 40d84c297b | |||
| 0416168d0e | |||
| c4c3d59d07 | |||
| 0268e76298 | |||
| 4ec8ae42f4 | |||
| 995aaa6159 | |||
| 2c89ff934d | |||
| c58853f5e5 | |||
| 66826ac960 | |||
| a603779f33 | |||
| e5475d698a | |||
| b728b4640b | |||
| bc657eb4d5 | |||
| 9b967775ed | |||
| 9af11ad5ce | |||
| 7a54ff2d21 | |||
| ec3f857bda | |||
| b3eb1a2ad7 | |||
| bce850aa12 | |||
| 3d6d8a947a | |||
| 6fa6bfe421 | |||
| 05ea991d62 | |||
| a248a52575 | |||
| 2a3c9e403f | |||
| bad87be306 | |||
| 346b755802 | |||
| 4978eeff7f | |||
| 052ed50f48 | |||
| 76c9306dda | |||
| 0853baaa3f | |||
| bf461ba0b2 | |||
| 0705454ce0 | |||
| a178bbe86f | |||
| fcf4315e02 | |||
| 89c7797ffb | |||
| 4dac8339ff | |||
| 0436dd04bf | |||
| 1e3996ea78 | |||
| 50b92118a9 | |||
| b1c7f7d127 | |||
| 0f36569d75 | |||
| 2cbba0923b | |||
| 800922266a | |||
| eda3ca5fbc | |||
| e4934a90eb | |||
| 715f300fa1 | |||
| b53275f2d2 | |||
| 1490d27d75 | |||
| a2c52a97ba | |||
| 5bd90538b3 | |||
| 50ccb1bfcd | |||
| 83eac9af18 | |||
| eb07dea795 | |||
| 114fa47171 | |||
| 63fac1b7c8 | |||
| e8f6cd10a5 | |||
| 47b8e8d528 | |||
| bdfd983bb4 | |||
| 87aaf5049b | |||
| 4b01370f54 | |||
| b6111d04a5 | |||
| 9bd989f1bb | |||
| d5597a75a6 | |||
| 90fdcf88d8 | |||
| 5d3b16cd3a | |||
| 41ae9632d1 | |||
| 47b0da6b25 | |||
| c99210c01f | |||
| 7b9848a352 | |||
| 0e83466023 | |||
| 48a507a993 | |||
| be3bc4c164 | |||
| e68219c1ac | |||
| 151852b164 | |||
| 49427b0c3c | |||
| bf373c5065 | |||
| 678fd8344e | |||
| f632165dec | |||
| fd11789db9 | |||
| d6ec6f0fe9 | |||
| 7311ae19be | |||
| f0aa4f4857 | |||
| f64f07049d | |||
| 24bcb52b2f | |||
| 4f44ae3f28 | |||
| a295a28e4b | |||
| bfa01b35df | |||
| 388c8e4aa5 | |||
| 96e4d3a530 | |||
| 040445612f | |||
| 86b010a6b2 | |||
| 2feedb98cc | |||
| 3be2b32e21 | |||
| 85bdea6f47 | |||
| bfdc99ab79 | |||
| 2567b20949 | |||
| 119c78b1c9 | |||
| d8e18f56e1 | |||
| 211f0bbf88 | |||
| b0c424b376 | |||
| 9ff0d717f2 | |||
| 93f8706dd3 | |||
| e29cfa3501 | |||
| 208fafa4a3 | |||
| 5cbc972a0d | |||
| 58898de542 | |||
| f9d63e7bb1 | |||
| 134c0e2916 | |||
| 1f8c233dfc | |||
| 0dc5d2794f | |||
| 49d003857d | |||
| eabe946a53 | |||
| 09a1b87d37 | |||
| 34abc8f577 | |||
| b0dceb484a | |||
| 65c1eac115 | |||
| a37dde9a1c | |||
| 28496059bc | |||
| 40c51efee8 | |||
| e439d6f64d | |||
| e29867b96e | |||
| 0b552a3534 | |||
| a50537fbaf | |||
| 0d6cc12274 | |||
| 008aa48d5c | |||
| 00eef79e5c | |||
| 7907478d36 | |||
| c7cca2e879 |
+1
-1
@@ -8,4 +8,4 @@ wiki page.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Please see https://pivotal.io/security.
|
||||
Please see https://spring.io/security-policy.
|
||||
|
||||
+60
-58
@@ -1,17 +1,17 @@
|
||||
plugins {
|
||||
id 'io.spring.dependency-management' version '1.0.11.RELEASE' apply false
|
||||
id 'io.spring.nohttp' version '0.0.10'
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false
|
||||
id "io.freefair.aspectj" version '6.2.0' apply false
|
||||
id 'org.jetbrains.dokka' version '1.5.0' apply false
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.5.32' apply false
|
||||
id "org.jetbrains.kotlin.plugin.serialization" version "1.5.32" apply false
|
||||
id 'org.asciidoctor.jvm.convert' version '3.3.2'
|
||||
id 'org.asciidoctor.jvm.pdf' version '3.3.2'
|
||||
id 'de.undercouch.download' version '4.1.2'
|
||||
id "io.freefair.aspectj" version '6.1.0' apply false
|
||||
id "org.unbroken-dome.xjc" version '2.0.0' apply false
|
||||
id "com.github.ben-manes.versions" version '0.39.0'
|
||||
id "com.github.johnrengelman.shadow" version '7.0.0' apply false
|
||||
id 'de.undercouch.download' version '4.1.2'
|
||||
id "me.champeau.jmh" version "0.6.6" apply false
|
||||
id "org.jetbrains.kotlin.plugin.serialization" version "1.5.30" apply false
|
||||
id "org.unbroken-dome.xjc" version '2.0.0' apply false
|
||||
}
|
||||
|
||||
ext {
|
||||
@@ -27,25 +27,25 @@ configure(allprojects) { project ->
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom "com.fasterxml.jackson:jackson-bom:2.12.5"
|
||||
mavenBom "io.netty:netty-bom:4.1.68.Final"
|
||||
mavenBom "io.projectreactor:reactor-bom:2020.0.11"
|
||||
mavenBom "io.r2dbc:r2dbc-bom:Arabba-SR10"
|
||||
mavenBom "com.fasterxml.jackson:jackson-bom:2.12.6"
|
||||
mavenBom "io.netty:netty-bom:4.1.72.Final"
|
||||
mavenBom "io.projectreactor:reactor-bom:2020.0.14"
|
||||
mavenBom "io.r2dbc:r2dbc-bom:Arabba-SR11"
|
||||
mavenBom "io.rsocket:rsocket-bom:1.1.1"
|
||||
mavenBom "org.eclipse.jetty:jetty-bom:9.4.43.v20210629"
|
||||
mavenBom "org.jetbrains.kotlin:kotlin-bom:1.5.30"
|
||||
mavenBom "org.eclipse.jetty:jetty-bom:9.4.44.v20210927"
|
||||
mavenBom "org.jetbrains.kotlin:kotlin-bom:1.5.32"
|
||||
mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.5.2"
|
||||
mavenBom "org.jetbrains.kotlinx:kotlinx-serialization-bom:1.2.2"
|
||||
mavenBom "org.junit:junit-bom:5.8.0"
|
||||
mavenBom "org.junit:junit-bom:5.8.2"
|
||||
}
|
||||
dependencies {
|
||||
dependencySet(group: 'org.apache.logging.log4j', version: '2.14.1') {
|
||||
dependencySet(group: 'org.apache.logging.log4j', version: '2.16.0') {
|
||||
entry 'log4j-api'
|
||||
entry 'log4j-core'
|
||||
entry 'log4j-jul'
|
||||
entry 'log4j-slf4j-impl'
|
||||
}
|
||||
dependency "org.slf4j:slf4j-api:1.7.30"
|
||||
dependency "org.slf4j:slf4j-api:1.7.32"
|
||||
dependency("com.google.code.findbugs:findbugs:3.0.1") {
|
||||
exclude group: "dom4j", name: "dom4j"
|
||||
}
|
||||
@@ -56,7 +56,7 @@ configure(allprojects) { project ->
|
||||
entry 'aspectjtools'
|
||||
entry 'aspectjweaver'
|
||||
}
|
||||
dependencySet(group: 'org.codehaus.groovy', version: '3.0.8') {
|
||||
dependencySet(group: 'org.codehaus.groovy', version: '3.0.9') {
|
||||
entry 'groovy'
|
||||
entry 'groovy-jsr223'
|
||||
entry 'groovy-templates' // requires findbugs for warning-free compilation
|
||||
@@ -67,23 +67,23 @@ configure(allprojects) { project ->
|
||||
dependency "io.reactivex:rxjava:1.3.8"
|
||||
dependency "io.reactivex:rxjava-reactive-streams:1.2.1"
|
||||
dependency "io.reactivex.rxjava2:rxjava:2.2.21"
|
||||
dependency "io.reactivex.rxjava3:rxjava:3.1.1"
|
||||
dependency "io.smallrye.reactive:mutiny:1.0.0"
|
||||
dependency "io.projectreactor.tools:blockhound:1.0.4.RELEASE"
|
||||
dependency "io.reactivex.rxjava3:rxjava:3.1.3"
|
||||
dependency "io.smallrye.reactive:mutiny:1.2.0"
|
||||
dependency "io.projectreactor.tools:blockhound:1.0.6.RELEASE"
|
||||
|
||||
dependency "com.caucho:hessian:4.0.63"
|
||||
dependency "com.fasterxml:aalto-xml:1.3.0"
|
||||
dependency("com.fasterxml.woodstox:woodstox-core:6.2.6") {
|
||||
dependency("com.fasterxml.woodstox:woodstox-core:6.2.7") {
|
||||
exclude group: "stax", name: "stax-api"
|
||||
}
|
||||
dependency "com.google.code.gson:gson:2.8.8"
|
||||
dependency "com.google.protobuf:protobuf-java-util:3.17.3"
|
||||
dependency "com.google.code.gson:gson:2.8.9"
|
||||
dependency "com.google.protobuf:protobuf-java-util:3.19.1"
|
||||
dependency "com.googlecode.protobuf-java-format:protobuf-java-format:1.4"
|
||||
dependency("com.thoughtworks.xstream:xstream:1.4.18") {
|
||||
exclude group: "xpp3", name: "xpp3_min"
|
||||
exclude group: "xmlpull", name: "xmlpull"
|
||||
}
|
||||
dependency "org.apache.johnzon:johnzon-jsonb:1.2.10"
|
||||
dependency "org.apache.johnzon:johnzon-jsonb:1.2.15"
|
||||
dependency("org.codehaus.jettison:jettison:1.3.8") {
|
||||
exclude group: "stax", name: "stax-api"
|
||||
}
|
||||
@@ -92,14 +92,14 @@ configure(allprojects) { project ->
|
||||
entry 'jibx-run'
|
||||
}
|
||||
dependency "org.ogce:xpp3:1.1.6"
|
||||
dependency "org.yaml:snakeyaml:1.29"
|
||||
dependency "org.yaml:snakeyaml:1.30"
|
||||
|
||||
dependency "com.h2database:h2:1.4.200"
|
||||
dependency "com.github.ben-manes.caffeine:caffeine:2.9.1"
|
||||
dependency "com.github.ben-manes.caffeine:caffeine:2.9.3"
|
||||
dependency "com.github.librepdf:openpdf:1.3.26"
|
||||
dependency "com.rometools:rome:1.15.0"
|
||||
dependency "com.rometools:rome:1.16.0"
|
||||
dependency "commons-io:commons-io:2.5"
|
||||
dependency "io.vavr:vavr:0.10.3"
|
||||
dependency "io.vavr:vavr:0.10.4"
|
||||
dependency "net.sf.jopt-simple:jopt-simple:5.0.4"
|
||||
dependencySet(group: 'org.apache.activemq', version: '5.16.2') {
|
||||
entry 'activemq-broker'
|
||||
@@ -125,46 +125,46 @@ configure(allprojects) { project ->
|
||||
dependency "org.ehcache:ehcache:3.4.0"
|
||||
dependency "org.hibernate:hibernate-core:5.4.32.Final"
|
||||
dependency "org.hibernate:hibernate-validator:6.2.0.Final"
|
||||
dependency "org.webjars:webjars-locator-core:0.47"
|
||||
dependency "org.webjars:webjars-locator-core:0.48"
|
||||
dependency "org.webjars:underscorejs:1.8.3"
|
||||
|
||||
dependencySet(group: 'org.apache.tomcat', version: '9.0.52') {
|
||||
dependencySet(group: 'org.apache.tomcat', version: '9.0.56') {
|
||||
entry 'tomcat-util'
|
||||
entry('tomcat-websocket') {
|
||||
exclude group: "org.apache.tomcat", name: "tomcat-websocket-api"
|
||||
exclude group: "org.apache.tomcat", name: "tomcat-servlet-api"
|
||||
exclude group: "org.apache.tomcat", name: "tomcat-websocket-api"
|
||||
}
|
||||
}
|
||||
dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.52') {
|
||||
dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.56') {
|
||||
entry 'tomcat-embed-core'
|
||||
entry 'tomcat-embed-websocket'
|
||||
}
|
||||
dependencySet(group: 'io.undertow', version: '2.2.10.Final') {
|
||||
dependencySet(group: 'io.undertow', version: '2.2.14.Final') {
|
||||
entry 'undertow-core'
|
||||
entry('undertow-servlet') {
|
||||
exclude group: "org.jboss.spec.javax.servlet", name: "jboss-servlet-api_4.0_spec"
|
||||
exclude group: "org.jboss.spec.javax.annotation", name: "jboss-annotations-api_1.3_spec"
|
||||
}
|
||||
entry('undertow-websockets-jsr') {
|
||||
exclude group: "org.jboss.spec.javax.websocket", name: "jboss-websocket-api_1.1_spec"
|
||||
}
|
||||
entry('undertow-servlet') {
|
||||
exclude group: "org.jboss.spec.javax.servlet", name: "jboss-servlet-api_3.1_spec"
|
||||
exclude group: "org.jboss.spec.javax.annotation", name: "jboss-annotations-api_1.2_spec"
|
||||
}
|
||||
}
|
||||
|
||||
dependency "org.eclipse.jetty:jetty-reactive-httpclient:1.1.10"
|
||||
dependency 'org.apache.httpcomponents.client5:httpclient5:5.1.2'
|
||||
dependency 'org.apache.httpcomponents.core5:httpcore5-reactive:5.1.2'
|
||||
dependency("org.apache.httpcomponents:httpclient:4.5.13") {
|
||||
exclude group: "commons-logging", name: "commons-logging"
|
||||
}
|
||||
dependency("org.apache.httpcomponents:httpasyncclient:4.1.5") {
|
||||
exclude group: "commons-logging", name: "commons-logging"
|
||||
}
|
||||
dependencySet(group: 'com.squareup.okhttp3', version: '3.14.9') {
|
||||
entry 'okhttp'
|
||||
entry 'mockwebserver'
|
||||
}
|
||||
dependency("org.apache.httpcomponents:httpclient:4.5.13") {
|
||||
exclude group: "commons-logging", name: "commons-logging"
|
||||
}
|
||||
dependency("org.apache.httpcomponents:httpasyncclient:4.1.4") {
|
||||
exclude group: "commons-logging", name: "commons-logging"
|
||||
}
|
||||
dependency 'org.apache.httpcomponents.client5:httpclient5:5.1'
|
||||
dependency 'org.apache.httpcomponents.core5:httpcore5-reactive:5.1.1'
|
||||
dependency "org.eclipse.jetty:jetty-reactive-httpclient:1.1.9"
|
||||
|
||||
dependency "org.jruby:jruby:9.2.19.0"
|
||||
dependency "org.jruby:jruby:9.2.20.1"
|
||||
dependency "org.python:jython-standalone:2.7.1"
|
||||
dependency "org.mozilla:rhino:1.7.11"
|
||||
|
||||
@@ -188,27 +188,28 @@ configure(allprojects) { project ->
|
||||
exclude group: "junit", name: "junit"
|
||||
}
|
||||
dependency "org.testng:testng:7.4.0"
|
||||
dependency "org.junit.support:testng-engine:1.0.1"
|
||||
dependency "org.hamcrest:hamcrest:2.1"
|
||||
dependency "org.awaitility:awaitility:3.1.6"
|
||||
dependency "org.assertj:assertj-core:3.20.2"
|
||||
dependencySet(group: 'org.xmlunit', version: '2.8.2') {
|
||||
dependency "org.assertj:assertj-core:3.21.0"
|
||||
dependencySet(group: 'org.xmlunit', version: '2.8.3') {
|
||||
entry 'xmlunit-assertj'
|
||||
entry('xmlunit-matchers') {
|
||||
exclude group: "org.hamcrest", name: "hamcrest-core"
|
||||
}
|
||||
}
|
||||
dependencySet(group: 'org.mockito', version: '3.12.4') {
|
||||
dependencySet(group: 'org.mockito', version: '4.1.0') {
|
||||
entry('mockito-core') {
|
||||
exclude group: "org.hamcrest", name: "hamcrest-core"
|
||||
}
|
||||
entry 'mockito-junit-jupiter'
|
||||
}
|
||||
dependency "io.mockk:mockk:1.12.0"
|
||||
dependency "io.mockk:mockk:1.12.1"
|
||||
|
||||
dependency("net.sourceforge.htmlunit:htmlunit:2.52.0") {
|
||||
dependency("net.sourceforge.htmlunit:htmlunit:2.55.0") {
|
||||
exclude group: "commons-logging", name: "commons-logging"
|
||||
}
|
||||
dependency("org.seleniumhq.selenium:htmlunit-driver:2.52.0") {
|
||||
dependency("org.seleniumhq.selenium:htmlunit-driver:2.55.0") {
|
||||
exclude group: "commons-logging", name: "commons-logging"
|
||||
}
|
||||
dependency("org.seleniumhq.selenium:selenium-java:3.141.59") {
|
||||
@@ -236,7 +237,7 @@ configure(allprojects) { project ->
|
||||
|
||||
dependency "com.ibm.websphere:uow:6.0.2.17"
|
||||
dependency "com.jamonapi:jamon:2.82"
|
||||
dependency "joda-time:joda-time:2.10.10"
|
||||
dependency "joda-time:joda-time:2.10.13"
|
||||
dependency "org.eclipse.persistence:org.eclipse.persistence.jpa:2.7.9"
|
||||
dependency "org.javamoney:moneta:1.3"
|
||||
|
||||
@@ -339,7 +340,7 @@ configure([rootProject] + javaProjects) { project ->
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "8.45.1"
|
||||
toolVersion = "9.2"
|
||||
configDirectory.set(rootProject.file("src/checkstyle"))
|
||||
}
|
||||
|
||||
@@ -352,16 +353,16 @@ configure([rootProject] + javaProjects) { project ->
|
||||
testImplementation("io.mockk:mockk")
|
||||
testImplementation("org.assertj:assertj-core")
|
||||
// Pull in the latest JUnit 5 Launcher API to ensure proper support in IDEs.
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-suite-engine")
|
||||
testRuntimeOnly("org.apache.logging.log4j:log4j-core")
|
||||
testRuntimeOnly("org.apache.logging.log4j:log4j-slf4j-impl")
|
||||
testRuntimeOnly("org.apache.logging.log4j:log4j-jul")
|
||||
testRuntimeOnly("org.apache.logging.log4j:log4j-slf4j-impl")
|
||||
// JSR-305 only used for non-required meta-annotations
|
||||
compileOnly("com.google.code.findbugs:jsr305")
|
||||
testCompileOnly("com.google.code.findbugs:jsr305")
|
||||
checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:0.0.15")
|
||||
checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:0.0.29")
|
||||
}
|
||||
|
||||
ext.javadocLinks = [
|
||||
@@ -369,7 +370,6 @@ configure([rootProject] + javaProjects) { project ->
|
||||
"https://docs.oracle.com/javaee/7/api/",
|
||||
"https://docs.oracle.com/cd/E13222_01/wls/docs90/javadocs/", // CommonJ
|
||||
"https://www.ibm.com/docs/api/v1/content/SSEQTP_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/",
|
||||
"https://tiles.apache.org/tiles-request/apidocs/",
|
||||
@@ -383,7 +383,9 @@ configure([rootProject] + javaProjects) { project ->
|
||||
"https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/",
|
||||
"https://projectreactor.io/docs/test/release/api/",
|
||||
"https://junit.org/junit4/javadoc/4.13.2/",
|
||||
"https://junit.org/junit5/docs/5.8.0/api/",
|
||||
// Disabling linking to JUnit 5.8.2, since the `package-list` file no longer exists due to
|
||||
// https://github.com/junit-team/junit5/commit/67ad4e545518b0ce2b0e7c96df31a669866d5003.
|
||||
// "https://junit.org/junit5/docs/5.8.2/api/",
|
||||
"https://www.reactive-streams.org/reactive-streams-1.0.3-javadoc/",
|
||||
"https://javadoc.io/static/io.rsocket/rsocket-core/1.1.1/",
|
||||
"https://r2dbc.io/spec/0.8.5.RELEASE/api/"
|
||||
|
||||
@@ -8,8 +8,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "me.champeau.gradle:japicmp-gradle-plugin:0.2.8"
|
||||
implementation "com.google.guava:guava:28.2-jre" // required by japicmp-gradle-plugin
|
||||
implementation "me.champeau.gradle:japicmp-gradle-plugin:0.3.0"
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ github-repo: "https://github.com/spring-projects/spring-framework.git"
|
||||
github-repo-name: "spring-projects/spring-framework"
|
||||
docker-hub-organization: "springci"
|
||||
artifactory-server: "https://repo.spring.io"
|
||||
branch: "main"
|
||||
branch: "5.3.x"
|
||||
milestone: "5.3.x"
|
||||
build-name: "spring-framework"
|
||||
pipeline-name: "spring-framework"
|
||||
|
||||
@@ -46,6 +46,11 @@ resource_types:
|
||||
source:
|
||||
repository: springio/artifactory-resource
|
||||
tag: 0.0.17
|
||||
- name: github-release
|
||||
type: registry-image
|
||||
source:
|
||||
repository: concourse/github-release-resource
|
||||
tag: 1.5.5
|
||||
- name: github-status-resource
|
||||
type: registry-image
|
||||
source:
|
||||
|
||||
@@ -4,7 +4,7 @@ image_resource:
|
||||
type: registry-image
|
||||
source:
|
||||
repository: springio/github-changelog-generator
|
||||
tag: '0.0.6'
|
||||
tag: '0.0.7'
|
||||
inputs:
|
||||
- name: git-repo
|
||||
- name: artifactory-repo
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
version=5.3.10-SNAPSHOT
|
||||
version=5.3.14
|
||||
org.gradle.jvmargs=-Xmx1536M
|
||||
org.gradle.caching=true
|
||||
org.gradle.parallel=true
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tasks.findByName("dokkaHtmlPartial")?.configure {
|
||||
outputDirectory.set(new File(buildDir, "docs/kdoc"))
|
||||
dokkaSourceSets {
|
||||
configureEach {
|
||||
outputDirectory.set(new File(buildDir, "docs/kdoc"))
|
||||
dokkaSourceSets {
|
||||
configureEach {
|
||||
sourceRoots.setFrom(file("src/main/kotlin"))
|
||||
classpath.from(sourceSets["main"].runtimeClasspath)
|
||||
externalDocumentationLink {
|
||||
@@ -17,7 +17,7 @@ tasks.findByName("dokkaHtmlPartial")?.configure {
|
||||
url.set(new URL("https://kotlin.github.io/kotlinx.coroutines/"))
|
||||
}
|
||||
externalDocumentationLink {
|
||||
url.set(new URL("https://hamcrest.org/JavaHamcrest/javadoc/2.1/"))
|
||||
url.set(new URL("https://javadoc.io/doc/org.hamcrest/hamcrest/2.1/"))
|
||||
}
|
||||
externalDocumentationLink {
|
||||
url.set(new URL("https://javadoc.io/doc/javax.servlet/javax.servlet-api/latest/"))
|
||||
@@ -26,5 +26,5 @@ tasks.findByName("dokkaHtmlPartial")?.configure {
|
||||
url.set(new URL("https://javadoc.io/static/io.rsocket/rsocket-core/1.1.1/"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -46,8 +46,9 @@ task api(type: Javadoc) {
|
||||
stylesheetFile = file("src/docs/api/stylesheet.css")
|
||||
splitIndex = true
|
||||
links(project.ext.javadocLinks)
|
||||
addStringOption('Xdoclint:none', '-quiet')
|
||||
if(JavaVersion.current().isJava9Compatible()) {
|
||||
addBooleanOption('Xdoclint:syntax', true) // only check syntax with doclint
|
||||
addBooleanOption('Xwerror', true) // fail build on Javadoc warnings
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
addBooleanOption('html5', true)
|
||||
}
|
||||
}
|
||||
|
||||
+4
-26
@@ -69,42 +69,20 @@ eclipse.classpath.file.whenMerged {
|
||||
}
|
||||
}
|
||||
|
||||
// Allow projects to be used as WTP modules
|
||||
eclipse.project.natures 'org.eclipse.wst.common.project.facet.core.nature'
|
||||
|
||||
// Include project specific settings
|
||||
task eclipseSettings(type: Copy) {
|
||||
from rootProject.files(
|
||||
'src/eclipse/org.eclipse.jdt.ui.prefs',
|
||||
'src/eclipse/org.eclipse.wst.common.project.facet.core.xml')
|
||||
'src/eclipse/org.eclipse.jdt.core.prefs',
|
||||
'src/eclipse/org.eclipse.jdt.ui.prefs')
|
||||
into project.file('.settings/')
|
||||
outputs.upToDateWhen { false }
|
||||
}
|
||||
|
||||
task eclipseJdtSettings(type: Copy) {
|
||||
from rootProject.file('src/eclipse/org.eclipse.jdt.core.prefs')
|
||||
into project.file('.settings/')
|
||||
outputs.upToDateWhen { false }
|
||||
}
|
||||
|
||||
task eclipseBuildship {
|
||||
dependsOn eclipseSettings, eclipseJdtSettings
|
||||
}
|
||||
|
||||
task eclipseWstComponentSettings(type: Copy) {
|
||||
from rootProject.files('src/eclipse/org.eclipse.wst.common.component')
|
||||
into project.file('.settings/')
|
||||
expand(deployname: project.name)
|
||||
outputs.upToDateWhen { false }
|
||||
}
|
||||
|
||||
task cleanEclipseSettings(type: Delete) {
|
||||
delete project.file('.settings/org.eclipse.jdt.core.prefs')
|
||||
delete project.file('.settings/org.eclipse.jdt.ui.prefs')
|
||||
delete project.file('.settings/org.eclipse.wst.common.component')
|
||||
delete project.file('.settings/org.eclipse.wst.common.project.facet.core.xml')
|
||||
}
|
||||
|
||||
tasks['eclipse'].dependsOn(eclipseSettings, eclipseJdtSettings, eclipseWstComponentSettings)
|
||||
tasks['eclipseJdt'].dependsOn(eclipseJdtSettings)
|
||||
tasks['eclipse'].dependsOn(eclipseSettings)
|
||||
tasks['eclipseJdt'].dependsOn(eclipseSettings)
|
||||
tasks['cleanEclipse'].dependsOn(cleanEclipseSettings)
|
||||
|
||||
+24
-20
@@ -3,11 +3,11 @@
|
||||
This document will guide you through the process of importing the Spring Framework
|
||||
projects into Eclipse or the Spring Tool Suite (_STS_). It is recommended that you
|
||||
have a recent version of Eclipse. As a bare minimum you will need Eclipse with full Java
|
||||
8 support, Eclipse Buildship, the Kotlin plugin, and the Groovy plugin.
|
||||
8 support, Eclipse Buildship, and the Groovy plugin.
|
||||
|
||||
The following instructions have been tested against [STS](https://spring.io/tools) 4.3.2
|
||||
([download](https://github.com/spring-projects/sts4/wiki/Previous-Versions#spring-tools-432-changelog))
|
||||
(based on Eclipse 4.12) with [Eclipse Buildship](https://projects.eclipse.org/projects/tools.buildship).
|
||||
The following instructions have been tested against [STS](https://spring.io/tools) 4.12.0
|
||||
([download](https://github.com/spring-projects/sts4/wiki/Previous-Versions#spring-tools-4120-changelog))
|
||||
(based on Eclipse 4.21) with [Eclipse Buildship](https://projects.eclipse.org/projects/tools.buildship).
|
||||
The instructions should work with the latest Eclipse distribution as long as you install
|
||||
[Buildship](https://marketplace.eclipse.org/content/buildship-gradle-integration). Note
|
||||
that STS 4 comes with Buildship preinstalled.
|
||||
@@ -16,28 +16,32 @@ that STS 4 comes with Buildship preinstalled.
|
||||
|
||||
_When instructed to execute `./gradlew` from the command line, be sure to execute it within your locally cloned `spring-framework` working directory._
|
||||
|
||||
1. Ensure that Eclipse launches with JDK 8.
|
||||
- For example, on Mac OS this can be configured in the `Info.plist` file located in the `Contents` folder of the installed Eclipse or STS application (e.g., the `Eclipse.app` file).
|
||||
1. Install the [Kotlin Plugin for Eclipse](https://marketplace.eclipse.org/content/kotlin-plugin-eclipse) in Eclipse.
|
||||
1. Install the [Eclipse Groovy Development Tools](https://github.com/groovy/groovy-eclipse/wiki) in Eclipse.
|
||||
1. Switch to Groovy 2.5 (Preferences -> Groovy -> Compiler -> Switch to 2.5...) in Eclipse.
|
||||
1. Change the _Forbidden reference (access rule)_ in Eclipse from Error to Warning
|
||||
(Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and restricted API -> Forbidden reference (access rule)).
|
||||
1. Optionally install the [AspectJ Development Tools](https://marketplace.eclipse.org/content/aspectj-development-tools) (_AJDT_) if you need to work with the `spring-aspects` project. The AspectJ Development Tools available in the Eclipse Marketplace have been tested with these instructions using STS 4.5 (Eclipse 4.14).
|
||||
1. Optionally install the [TestNG plugin](https://testng.org/doc/eclipse.html) in Eclipse if you need to execute TestNG tests in the `spring-test` module.
|
||||
1. Install the [Groovy Development Tools](https://marketplace.eclipse.org/content/groovy-development-tools).
|
||||
1. Switch to Groovy 3.0 in Eclipse (Preferences → Groovy → Compiler → Switch to 3.0...).
|
||||
- If you encounter build errors stating something similar to _"Groovy: compiler mismatch: project level is 2.5, workspace level is 3.0"_, change the Groovy compiler version to 3.0 for each affected project.
|
||||
1. Ensure that the _Forbidden reference (access rule)_ in Eclipse is set to `Info`
|
||||
(Preferences → Java → Compiler → Errors/Warnings → Deprecated and restricted API → Forbidden reference (access rule)).
|
||||
1. Optionally install the [Kotlin Plugin for Eclipse](https://marketplace.eclipse.org/content/kotlin-plugin-eclipse) if you need to execute Kotlin-based tests or develop Kotlin extensions.
|
||||
- **NOTE**: As of September 21, 2021, it appears that the Kotlin Plugin for Eclipse does not yet work with Eclipse 4.21.
|
||||
1. Optionally install the [AspectJ Development Tools](https://marketplace.eclipse.org/content/aspectj-development-tools) (_AJDT_) if you need to work with the `spring-aspects` project.
|
||||
- **NOTE**: As of September 21, 2021, it appears that the AspectJ Development Tools do not yet work with Eclipse 4.21.
|
||||
1. Optionally install the [TestNG plugin](https://testng.org/doc/eclipse.html) in Eclipse if you need to execute individual TestNG test classes or tests in the `spring-test` module.
|
||||
- As an alternative to installing the TestNG plugin, you can execute the `org.springframework.test.context.testng.TestNGTestSuite` class as a "JUnit 5" test class in Eclipse.
|
||||
1. Build `spring-oxm` from the command line with `./gradlew :spring-oxm:check`.
|
||||
1. To apply project specific settings, run `./gradlew eclipseBuildship` from the command line.
|
||||
1. Import into Eclipse (File -> Import -> Gradle -> Existing Gradle Project -> Navigate to the locally cloned `spring-framework` directory -> Select Finish).
|
||||
1. To apply Spring Framework specific settings, run `./gradlew cleanEclipse eclipse` from the command line.
|
||||
1. Import all projects into Eclipse (File → Import → Gradle → Existing Gradle Project → Navigate to the locally cloned `spring-framework` directory → Select Finish).
|
||||
- If you have not installed AJDT, exclude the `spring-aspects` project from the import, if prompted, or close it after the import.
|
||||
- If you run into errors during the import, you may need to set the _Java home_ for Gradle Buildship to the location of your JDK 8 installation in Eclipse (Preferences -> Gradle -> Java home).
|
||||
1. If you need to execute JAXB-related tests in the `spring-oxm` project and wish to have the generated sources available, add the `build/generated-sources/jaxb` folder to the build path (right click on the `jaxb` folder and select `Build Path -> Use as Source Folder`).
|
||||
- If you do not see the `build` folder in the `spring-oxm` project, ensure that the "Gradle build folder" is not filtered out from the view. This setting is available under "Filters" in the configuration of the Package Explorer (available by clicking on the small downward facing arrow in the upper right corner of the Package Explorer).
|
||||
- If you run into errors during the import, you may need to set the _Java home_ for Gradle Buildship to the location of your JDK 8 installation in Eclipse (Preferences → Gradle → Java home).
|
||||
1. If you need to execute JAXB-related tests in the `spring-oxm` project and wish to have the generated sources available, add the `build/generated-sources/jaxb` folder to the build path (right click on the `jaxb` folder and select "Build Path → Use as Source Folder").
|
||||
- If you do not see the `build` folder in the `spring-oxm` project, ensure that the "Gradle build folder" is not filtered out from the view. This setting is available under "Filters" in the configuration of the Package Explorer (available by clicking on the _three vertical dots_ in the upper right corner of the Package Explorer).
|
||||
1. Code away!
|
||||
|
||||
## Known Issues
|
||||
|
||||
1. `spring-core` and `spring-oxm` should be pre-compiled due to repackaged dependencies.
|
||||
- See `*RepackJar` tasks in the build.
|
||||
1. `spring-core` should be pre-compiled due to repackaged dependencies.
|
||||
- See `*RepackJar` tasks in the `spring-core.gradle` build file.
|
||||
1. `spring-oxm` should be pre-compiled due to JAXB types generated for tests.
|
||||
- Note that executing `./gradlew :spring-oxm:check` as explained in the _Steps_ above will compile `spring-core` and generate JAXB types for `spring-oxm`.
|
||||
1. `spring-aspects` does not compile due to references to aspect types unknown to Eclipse.
|
||||
- If you installed _AJDT_ into Eclipse it should work.
|
||||
1. While JUnit tests pass from the command line with Gradle, some may fail when run from
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "com.gradle.enterprise" version "3.6.1"
|
||||
id "com.gradle.enterprise" version "3.7.2"
|
||||
id "io.spring.ge.conventions" version "0.0.7"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -237,7 +237,7 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||
* validates it if not.
|
||||
*/
|
||||
private void validateClassIfNecessary(Class<?> proxySuperClass, @Nullable ClassLoader proxyClassLoader) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
if (!this.advised.isOptimize() && logger.isInfoEnabled()) {
|
||||
synchronized (validatedClasses) {
|
||||
if (!validatedClasses.containsKey(proxySuperClass)) {
|
||||
doValidateClass(proxySuperClass, proxyClassLoader,
|
||||
@@ -679,13 +679,19 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||
Object retVal;
|
||||
// Check whether we only have one InvokerInterceptor: that is,
|
||||
// no real advice, but just reflective invocation of the target.
|
||||
if (chain.isEmpty() && Modifier.isPublic(method.getModifiers())) {
|
||||
if (chain.isEmpty() && CglibMethodInvocation.isMethodProxyCompatible(method)) {
|
||||
// We can skip creating a MethodInvocation: just invoke the target directly.
|
||||
// Note that the final invoker must be an InvokerInterceptor, so we know
|
||||
// it does nothing but a reflective operation on the target, and no hot
|
||||
// swapping or fancy proxying.
|
||||
Object[] argsToUse = AopProxyUtils.adaptArgumentsIfNecessary(method, args);
|
||||
retVal = methodProxy.invoke(target, argsToUse);
|
||||
try {
|
||||
retVal = methodProxy.invoke(target, argsToUse);
|
||||
}
|
||||
catch (CodeGenerationException ex) {
|
||||
CglibMethodInvocation.logFastClassGenerationFailure(method);
|
||||
retVal = AopUtils.invokeJoinpointUsingReflection(target, method, argsToUse);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// We need to create a method invocation...
|
||||
@@ -737,10 +743,7 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||
super(proxy, target, method, arguments, targetClass, interceptorsAndDynamicMethodMatchers);
|
||||
|
||||
// Only use method proxy for public methods not derived from java.lang.Object
|
||||
this.methodProxy = (Modifier.isPublic(method.getModifiers()) &&
|
||||
method.getDeclaringClass() != Object.class && !AopUtils.isEqualsMethod(method) &&
|
||||
!AopUtils.isHashCodeMethod(method) && !AopUtils.isToStringMethod(method) ?
|
||||
methodProxy : null);
|
||||
this.methodProxy = (isMethodProxyCompatible(method) ? methodProxy : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -776,10 +779,25 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||
@Override
|
||||
protected Object invokeJoinpoint() throws Throwable {
|
||||
if (this.methodProxy != null) {
|
||||
return this.methodProxy.invoke(this.target, this.arguments);
|
||||
try {
|
||||
return this.methodProxy.invoke(this.target, this.arguments);
|
||||
}
|
||||
catch (CodeGenerationException ex) {
|
||||
logFastClassGenerationFailure(this.method);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return super.invokeJoinpoint();
|
||||
return super.invokeJoinpoint();
|
||||
}
|
||||
|
||||
static boolean isMethodProxyCompatible(Method method) {
|
||||
return (Modifier.isPublic(method.getModifiers()) &&
|
||||
method.getDeclaringClass() != Object.class && !AopUtils.isEqualsMethod(method) &&
|
||||
!AopUtils.isHashCodeMethod(method) && !AopUtils.isToStringMethod(method));
|
||||
}
|
||||
|
||||
static void logFastClassGenerationFailure(Method method) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Failed to generate CGLIB fast class for method: " + method);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -45,9 +45,10 @@ import org.springframework.core.NativeDetector;
|
||||
* @see AdvisedSupport#setProxyTargetClass
|
||||
* @see AdvisedSupport#setInterfaces
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class DefaultAopProxyFactory implements AopProxyFactory, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7930414337282325166L;
|
||||
|
||||
|
||||
@Override
|
||||
public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -73,11 +73,9 @@ public class ProxyConfig implements Serializable {
|
||||
* The exact meaning of "aggressive optimizations" will differ
|
||||
* between proxies, but there is usually some tradeoff.
|
||||
* Default is "false".
|
||||
* <p>For example, optimization will usually mean that advice changes won't
|
||||
* take effect after a proxy has been created. For this reason, optimization
|
||||
* is disabled by default. An optimize value of "true" may be ignored
|
||||
* if other settings preclude optimization: for example, if "exposeProxy"
|
||||
* is set to "true" and that's not compatible with the optimization.
|
||||
* <p>With Spring's current proxy options, this flag effectively
|
||||
* enforces CGLIB proxies (similar to {@link #setProxyTargetClass})
|
||||
* but without any class validation checks (for final methods etc).
|
||||
*/
|
||||
public void setOptimize(boolean optimize) {
|
||||
this.optimize = optimize;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -421,11 +421,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||
* are unaffected by such changes.
|
||||
*/
|
||||
private synchronized void initializeAdvisorChain() throws AopConfigException, BeansException {
|
||||
if (this.advisorChainInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ObjectUtils.isEmpty(this.interceptorNames)) {
|
||||
if (!this.advisorChainInitialized && !ObjectUtils.isEmpty(this.interceptorNames)) {
|
||||
if (this.beanFactory == null) {
|
||||
throw new IllegalStateException("No BeanFactory available anymore (probably due to serialization) " +
|
||||
"- cannot resolve interceptor names " + Arrays.asList(this.interceptorNames));
|
||||
@@ -464,9 +460,9 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||
addAdvisorOnChainCreation(advice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.advisorChainInitialized = true;
|
||||
this.advisorChainInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2021 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,8 @@ import org.springframework.aop.Advisor;
|
||||
import org.springframework.aop.ThrowsAdvice;
|
||||
|
||||
/**
|
||||
* Adapter to enable {@link org.springframework.aop.MethodBeforeAdvice}
|
||||
* to be used in the Spring AOP framework.
|
||||
* Adapter to enable {@link org.springframework.aop.ThrowsAdvice} to be used
|
||||
* in the Spring AOP framework.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ public class BeanNameAutoProxyCreator extends AbstractAutoProxyCreator {
|
||||
* FactoryBean will get proxied. This default behavior applies as of Spring 2.0.
|
||||
* If you intend to proxy a FactoryBean instance itself (a rare use case, but
|
||||
* Spring 1.2's default behavior), specify the bean name of the FactoryBean
|
||||
* including the factory-bean prefix "&": e.g. "&myFactoryBean".
|
||||
* including the factory-bean prefix "&": e.g. "&myFactoryBean".
|
||||
* @see org.springframework.beans.factory.FactoryBean
|
||||
* @see org.springframework.beans.factory.BeanFactory#FACTORY_BEAN_PREFIX
|
||||
*/
|
||||
|
||||
+5
-3
@@ -25,9 +25,11 @@ import org.springframework.lang.Nullable;
|
||||
/**
|
||||
* Convenient TargetSourceCreator using bean name prefixes to create one of three
|
||||
* well-known TargetSource types:
|
||||
* <li>: CommonsPool2TargetSource
|
||||
* <li>% ThreadLocalTargetSource
|
||||
* <li>! PrototypeTargetSource
|
||||
* <ul>
|
||||
* <li>: CommonsPool2TargetSource</li>
|
||||
* <li>% ThreadLocalTargetSource</li>
|
||||
* <li>! PrototypeTargetSource</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Stephane Nicoll
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -146,7 +146,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + ": class = " + this.clazz.getName() + "; methodName = " + methodName;
|
||||
return getClass().getName() + ": class = " + this.clazz.getName() + "; methodName = " + this.methodName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.aop.support;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -29,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Rob Harrop
|
||||
* @author Rick Evans
|
||||
*/
|
||||
public class ClassUtilsTests {
|
||||
class ClassUtilsTests {
|
||||
|
||||
@Test
|
||||
public void getShortNameForCglibClass() {
|
||||
void getShortNameForCglibClass() {
|
||||
TestBean tb = new TestBean();
|
||||
ProxyFactory pf = new ProxyFactory();
|
||||
pf.setTarget(tb);
|
||||
@@ -41,4 +42,5 @@ public class ClassUtilsTests {
|
||||
String className = ClassUtils.getShortName(proxy.getClass());
|
||||
assertThat(className).as("Class name did not match").isEqualTo("TestBean");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -16,9 +16,9 @@
|
||||
</aop:aspect>
|
||||
</aop:config>
|
||||
|
||||
<bean id="getNameCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
|
||||
<bean id="getNameCounter" class="org.springframework.aop.testfixture.advice.CountingBeforeAdvice"/>
|
||||
|
||||
<bean id="getAgeCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
|
||||
<bean id="getAgeCounter" class="org.springframework.aop.testfixture.advice.CountingBeforeAdvice"/>
|
||||
|
||||
<bean id="testBean" class="org.springframework.beans.testfixture.beans.TestBean"/>
|
||||
|
||||
|
||||
+1
-1
@@ -9,6 +9,6 @@
|
||||
<aop:advisor advice-ref="countingAdvice" pointcut="within(org.springframework..*)"/>
|
||||
</aop:config>
|
||||
|
||||
<bean id="countingAdvice" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
|
||||
<bean id="countingAdvice" class="org.springframework.aop.testfixture.advice.CountingBeforeAdvice"/>
|
||||
|
||||
</beans>
|
||||
|
||||
+1
-1
@@ -10,6 +10,6 @@
|
||||
<aop:advisor advice-ref="countingAdvice" pointcut-ref="pc"/>
|
||||
</aop:config>
|
||||
|
||||
<bean id="countingAdvice" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
|
||||
<bean id="countingAdvice" class="org.springframework.aop.testfixture.advice.CountingBeforeAdvice"/>
|
||||
|
||||
</beans>
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
</aop:aspect>
|
||||
</aop:config>
|
||||
|
||||
<bean id="getAgeCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
|
||||
<bean id="getAgeCounter" class="org.springframework.aop.testfixture.advice.CountingBeforeAdvice"/>
|
||||
|
||||
<bean id="testBean" class="org.springframework.beans.testfixture.beans.TestBean"/>
|
||||
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
</aop:aspect>
|
||||
</aop:config>
|
||||
|
||||
<bean id="getAgeCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
|
||||
<bean id="getAgeCounter" class="org.springframework.aop.testfixture.advice.CountingBeforeAdvice"/>
|
||||
|
||||
<bean id="testBean" class="org.springframework.beans.testfixture.beans.TestBean"/>
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,14 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.beans.factory.aspectj;
|
||||
|
||||
/**
|
||||
* Marker interface for domain object that need DI through aspects.
|
||||
* Marker interface for domain objects that need DI through aspects.
|
||||
*
|
||||
* @author Ramnivas Laddad
|
||||
* @since 2.5
|
||||
*/
|
||||
public interface ConfigurableObject {
|
||||
|
||||
}
|
||||
|
||||
+2
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,6 @@ import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
@@ -107,10 +106,7 @@ public class AspectJEnableCachingIsolatedTests {
|
||||
try {
|
||||
load(MultiCacheManagerConfigurer.class, EnableCachingConfig.class);
|
||||
}
|
||||
catch (BeanCreationException ex) {
|
||||
Throwable root = ex.getRootCause();
|
||||
boolean condition = root instanceof IllegalStateException;
|
||||
assertThat(condition).isTrue();
|
||||
catch (IllegalStateException ex) {
|
||||
assertThat(ex.getMessage().contains("implementations of CachingConfigurer")).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
+8
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2021 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,13 +22,18 @@ import org.springframework.contextsupport.testfixture.jcache.AbstractJCacheAnnot
|
||||
|
||||
/**
|
||||
* @author Stephane Nicoll
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public class JCacheAspectJNamespaceConfigTests extends AbstractJCacheAnnotationTests {
|
||||
|
||||
@Override
|
||||
protected ApplicationContext getApplicationContext() {
|
||||
return new GenericXmlApplicationContext(
|
||||
"/org/springframework/cache/config/annotation-jcache-aspectj.xml");
|
||||
GenericXmlApplicationContext context = new GenericXmlApplicationContext();
|
||||
// Disallow bean definition overriding to test https://github.com/spring-projects/spring-framework/pull/27499
|
||||
context.setAllowBeanDefinitionOverriding(false);
|
||||
context.load("/org/springframework/cache/config/annotation-jcache-aspectj.xml");
|
||||
context.refresh();
|
||||
return context;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.transaction.aspectj;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -29,4 +30,5 @@ public class ClassWithPrivateAnnotatedMember {
|
||||
|
||||
@Transactional
|
||||
private void doInTransaction() {}
|
||||
|
||||
}
|
||||
|
||||
+2
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.transaction.aspectj;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -29,4 +30,5 @@ public class ClassWithProtectedAnnotatedMember {
|
||||
|
||||
@Transactional
|
||||
protected void doInTransaction() {}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,9 +100,9 @@ public abstract class BeanUtils {
|
||||
* @param clazz class to instantiate
|
||||
* @return the new instance
|
||||
* @throws BeanInstantiationException if the bean cannot be instantiated
|
||||
* @see Class#newInstance()
|
||||
* @deprecated as of Spring 5.0, following the deprecation of
|
||||
* {@link Class#newInstance()} in JDK 9
|
||||
* @see Class#newInstance()
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T> T instantiate(Class<T> clazz) throws BeanInstantiationException {
|
||||
@@ -226,32 +226,45 @@ public abstract class BeanUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a resolvable constructor for the provided class, either a primary constructor
|
||||
* or single public constructor or simply a default constructor. Callers have to be
|
||||
* prepared to resolve arguments for the returned constructor's parameters, if any.
|
||||
* Return a resolvable constructor for the provided class, either a primary or single
|
||||
* public constructor with arguments, or a single non-public constructor with arguments,
|
||||
* or simply a default constructor. Callers have to be prepared to resolve arguments
|
||||
* for the returned constructor's parameters, if any.
|
||||
* @param clazz the class to check
|
||||
* @throws IllegalStateException in case of no unique constructor found at all
|
||||
* @since 5.3
|
||||
* @see #findPrimaryConstructor
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> Constructor<T> getResolvableConstructor(Class<T> clazz) {
|
||||
Constructor<T> ctor = findPrimaryConstructor(clazz);
|
||||
if (ctor == null) {
|
||||
Constructor<?>[] ctors = clazz.getConstructors();
|
||||
if (ctor != null) {
|
||||
return ctor;
|
||||
}
|
||||
|
||||
Constructor<?>[] ctors = clazz.getConstructors();
|
||||
if (ctors.length == 1) {
|
||||
// A single public constructor
|
||||
return (Constructor<T>) ctors[0];
|
||||
}
|
||||
else if (ctors.length == 0){
|
||||
ctors = clazz.getDeclaredConstructors();
|
||||
if (ctors.length == 1) {
|
||||
ctor = (Constructor<T>) ctors[0];
|
||||
}
|
||||
else {
|
||||
try {
|
||||
ctor = clazz.getDeclaredConstructor();
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
throw new IllegalStateException("No primary or single public constructor found for " +
|
||||
clazz + " - and no default constructor found either");
|
||||
}
|
||||
// A single non-public constructor, e.g. from a non-public record type
|
||||
return (Constructor<T>) ctors[0];
|
||||
}
|
||||
}
|
||||
return ctor;
|
||||
|
||||
// Several constructors -> let's try to take the default constructor
|
||||
try {
|
||||
return clazz.getDeclaredConstructor();
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
// Giving up...
|
||||
}
|
||||
|
||||
// No unique constructor at all
|
||||
throw new IllegalStateException("No primary or single unique constructor found for " + clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -527,7 +540,7 @@ public abstract class BeanUtils {
|
||||
|
||||
/**
|
||||
* Find a JavaBeans PropertyEditor following the 'Editor' suffix convention
|
||||
* (e.g. "mypackage.MyDomainClass" -> "mypackage.MyDomainClassEditor").
|
||||
* (e.g. "mypackage.MyDomainClass" → "mypackage.MyDomainClassEditor").
|
||||
* <p>Compatible to the standard JavaBeans convention as implemented by
|
||||
* {@link java.beans.PropertyEditorManager} but isolated from the latter's
|
||||
* registered default editors for primitive types.
|
||||
|
||||
@@ -134,8 +134,8 @@ public abstract class PropertyAccessorUtils {
|
||||
/**
|
||||
* Determine the canonical name for the given property path.
|
||||
* Removes surrounding quotes from map keys:<br>
|
||||
* {@code map['key']} -> {@code map[key]}<br>
|
||||
* {@code map["key"]} -> {@code map[key]}
|
||||
* {@code map['key']} → {@code map[key]}<br>
|
||||
* {@code map["key"]} → {@code map[key]}
|
||||
* @param propertyName the bean property path
|
||||
* @return the canonical representation of the property path
|
||||
*/
|
||||
|
||||
+7
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -422,10 +422,13 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
}
|
||||
if (editor == null) {
|
||||
// Find editor for superclass or interface.
|
||||
for (Iterator<Class<?>> it = this.customEditors.keySet().iterator(); it.hasNext() && editor == null;) {
|
||||
Class<?> key = it.next();
|
||||
for (Map.Entry<Class<?>, PropertyEditor> entry : this.customEditors.entrySet()) {
|
||||
if (editor != null) {
|
||||
break;
|
||||
}
|
||||
Class<?> key = entry.getKey();
|
||||
if (key.isAssignableFrom(requiredType)) {
|
||||
editor = this.customEditors.get(key);
|
||||
editor = entry.getValue();
|
||||
// Cache editor for search type, to avoid the overhead
|
||||
// of repeated assignable-from checks.
|
||||
if (this.customEditorCache == null) {
|
||||
|
||||
@@ -214,6 +214,7 @@ public interface BeanFactory {
|
||||
/**
|
||||
* Return a provider for the specified bean, allowing for lazy on-demand retrieval
|
||||
* of instances, including availability and uniqueness options.
|
||||
* <p>For matching a generic type, consider {@link #getBeanProvider(ResolvableType)}.
|
||||
* @param requiredType type the bean must match; can be an interface or superclass
|
||||
* @return a corresponding provider handle
|
||||
* @since 5.1
|
||||
@@ -223,13 +224,20 @@ public interface BeanFactory {
|
||||
|
||||
/**
|
||||
* Return a provider for the specified bean, allowing for lazy on-demand retrieval
|
||||
* of instances, including availability and uniqueness options.
|
||||
* @param requiredType type the bean must match; can be a generic type declaration.
|
||||
* Note that collection types are not supported here, in contrast to reflective
|
||||
* of instances, including availability and uniqueness options. This variant allows
|
||||
* for specifying a generic type to match, similar to reflective injection points
|
||||
* with generic type declarations in method/constructor parameters.
|
||||
* <p>Note that collections of beans are not supported here, in contrast to reflective
|
||||
* injection points. For programmatically retrieving a list of beans matching a
|
||||
* specific type, specify the actual bean type as an argument here and subsequently
|
||||
* use {@link ObjectProvider#orderedStream()} or its lazy streaming/iteration options.
|
||||
* <p>Also, generics matching is strict here, as per the Java assignment rules.
|
||||
* For lenient fallback matching with unchecked semantics (similar to the ´unchecked´
|
||||
* Java compiler warning), consider calling {@link #getBeanProvider(Class)} with the
|
||||
* raw type as a second step if no full generic match is
|
||||
* {@link ObjectProvider#getIfAvailable() available} with this variant.
|
||||
* @return a corresponding provider handle
|
||||
* @param requiredType type the bean must match; can be a generic type declaration
|
||||
* @since 5.1
|
||||
* @see ObjectProvider#iterator()
|
||||
* @see ObjectProvider#stream()
|
||||
|
||||
+23
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -353,9 +353,31 @@ public interface ListableBeanFactory extends BeanFactory {
|
||||
* @since 3.0
|
||||
* @see #getBeanNamesForAnnotation
|
||||
* @see #getBeansWithAnnotation
|
||||
* @see #getType(String)
|
||||
*/
|
||||
@Nullable
|
||||
<A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
|
||||
throws NoSuchBeanDefinitionException;
|
||||
|
||||
/**
|
||||
* Find an {@link Annotation} of {@code annotationType} on the specified bean,
|
||||
* traversing its interfaces and super classes if no annotation can be found on
|
||||
* the given class itself, as well as checking the bean's factory method (if any).
|
||||
* @param beanName the name of the bean to look for annotations on
|
||||
* @param annotationType the type of annotation to look for
|
||||
* (at class, interface or factory method level of the specified bean)
|
||||
* @param allowFactoryBeanInit whether a {@code FactoryBean} may get initialized
|
||||
* just for the purpose of determining its object type
|
||||
* @return the annotation of the given type if found, or {@code null} otherwise
|
||||
* @throws NoSuchBeanDefinitionException if there is no bean with the given name
|
||||
* @since 5.3.14
|
||||
* @see #getBeanNamesForAnnotation
|
||||
* @see #getBeansWithAnnotation
|
||||
* @see #getType(String, boolean)
|
||||
*/
|
||||
@Nullable
|
||||
<A extends Annotation> A findAnnotationOnBean(
|
||||
String beanName, Class<A> annotationType, boolean allowFactoryBeanInit)
|
||||
throws NoSuchBeanDefinitionException;
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -459,7 +459,7 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
|
||||
return metadata;
|
||||
}
|
||||
|
||||
private InjectionMetadata buildAutowiringMetadata(final Class<?> clazz) {
|
||||
private InjectionMetadata buildAutowiringMetadata(Class<?> clazz) {
|
||||
if (!AnnotationUtils.isCandidateClass(clazz, this.autowiredAnnotationTypes)) {
|
||||
return InjectionMetadata.EMPTY;
|
||||
}
|
||||
@@ -539,8 +539,7 @@ public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationA
|
||||
*/
|
||||
@SuppressWarnings({"deprecation", "cast"})
|
||||
protected boolean determineRequiredStatus(MergedAnnotation<?> ann) {
|
||||
// The following (AnnotationAttributes) cast is required on JDK 9+.
|
||||
return determineRequiredStatus((AnnotationAttributes)
|
||||
return determineRequiredStatus(
|
||||
ann.asMap(mergedAnnotation -> new AnnotationAttributes(mergedAnnotation.getType())));
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 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,9 +34,7 @@ import org.springframework.lang.Nullable;
|
||||
*
|
||||
* <p><b>NOTE:</b> This interface is a special purpose interface, mainly for
|
||||
* internal use within the framework. It is recommended to implement the plain
|
||||
* {@link BeanPostProcessor} interface as far as possible, or to derive from
|
||||
* {@link InstantiationAwareBeanPostProcessorAdapter} in order to be shielded
|
||||
* from extensions to this interface.
|
||||
* {@link BeanPostProcessor} interface as far as possible.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Rod Johnson
|
||||
|
||||
+7
-7
@@ -47,17 +47,17 @@ import org.springframework.util.ClassUtils;
|
||||
* which uses this class to call a static initialization method:
|
||||
*
|
||||
* <pre class="code">
|
||||
* <bean id="myObject" class="org.springframework.beans.factory.config.MethodInvokingBean">
|
||||
* <property name="staticMethod" value="com.whatever.MyClass.init"/>
|
||||
* </bean></pre>
|
||||
* <bean id="myObject" class="org.springframework.beans.factory.config.MethodInvokingBean">
|
||||
* <property name="staticMethod" value="com.whatever.MyClass.init"/>
|
||||
* </bean></pre>
|
||||
*
|
||||
* <p>An example of calling an instance method to start some server bean:
|
||||
*
|
||||
* <pre class="code">
|
||||
* <bean id="myStarter" class="org.springframework.beans.factory.config.MethodInvokingBean">
|
||||
* <property name="targetObject" ref="myServer"/>
|
||||
* <property name="targetMethod" value="start"/>
|
||||
* </bean></pre>
|
||||
* <bean id="myStarter" class="org.springframework.beans.factory.config.MethodInvokingBean">
|
||||
* <property name="targetObject" ref="myServer"/>
|
||||
* <property name="targetMethod" value="start"/>
|
||||
* </bean></pre>
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 4.0.3
|
||||
|
||||
+12
-12
@@ -56,24 +56,24 @@ import org.springframework.lang.Nullable;
|
||||
* which uses this class to call a static factory method:
|
||||
*
|
||||
* <pre class="code">
|
||||
* <bean id="myObject" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
* <property name="staticMethod" value="com.whatever.MyClassFactory.getInstance"/>
|
||||
* </bean></pre>
|
||||
* <bean id="myObject" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
* <property name="staticMethod" value="com.whatever.MyClassFactory.getInstance"/>
|
||||
* </bean></pre>
|
||||
*
|
||||
* <p>An example of calling a static method then an instance method to get at a
|
||||
* Java system property. Somewhat verbose, but it works.
|
||||
*
|
||||
* <pre class="code">
|
||||
* <bean id="sysProps" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
* <property name="targetClass" value="java.lang.System"/>
|
||||
* <property name="targetMethod" value="getProperties"/>
|
||||
* </bean>
|
||||
* <bean id="sysProps" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
* <property name="targetClass" value="java.lang.System"/>
|
||||
* <property name="targetMethod" value="getProperties"/>
|
||||
* </bean>
|
||||
*
|
||||
* <bean id="javaVersion" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
* <property name="targetObject" ref="sysProps"/>
|
||||
* <property name="targetMethod" value="getProperty"/>
|
||||
* <property name="arguments" value="java.version"/>
|
||||
* </bean></pre>
|
||||
* <bean id="javaVersion" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
* <property name="targetObject" ref="sysProps"/>
|
||||
* <property name="targetMethod" value="getProperty"/>
|
||||
* <property name="arguments" value="java.version"/>
|
||||
* </bean></pre>
|
||||
*
|
||||
* @author Colin Sampaleanu
|
||||
* @author Juergen Hoeller
|
||||
|
||||
+22
-22
@@ -83,22 +83,22 @@ import org.springframework.util.StringUtils;
|
||||
* <p>A sample config in an XML-based
|
||||
* {@link org.springframework.beans.factory.BeanFactory} might look as follows:
|
||||
*
|
||||
* <pre class="code"><beans>
|
||||
* <pre class="code"><beans>
|
||||
*
|
||||
* <!-- Prototype bean since we have state -->
|
||||
* <bean id="myService" class="a.b.c.MyService" singleton="false"/>
|
||||
* <!-- Prototype bean since we have state -->
|
||||
* <bean id="myService" class="a.b.c.MyService" singleton="false"/>
|
||||
*
|
||||
* <!-- will lookup the above 'myService' bean by *TYPE* -->
|
||||
* <!-- will lookup the above 'myService' bean by *TYPE* -->
|
||||
* <bean id="myServiceFactory"
|
||||
* class="org.springframework.beans.factory.config.ServiceLocatorFactoryBean">
|
||||
* <property name="serviceLocatorInterface" value="a.b.c.ServiceFactory"/>
|
||||
* </bean>
|
||||
* class="org.springframework.beans.factory.config.ServiceLocatorFactoryBean">
|
||||
* <property name="serviceLocatorInterface" value="a.b.c.ServiceFactory"/>
|
||||
* </bean>
|
||||
*
|
||||
* <bean id="clientBean" class="a.b.c.MyClientBean">
|
||||
* <property name="myServiceFactory" ref="myServiceFactory"/>
|
||||
* </bean>
|
||||
* <bean id="clientBean" class="a.b.c.MyClientBean">
|
||||
* <property name="myServiceFactory" ref="myServiceFactory"/>
|
||||
* </bean>
|
||||
*
|
||||
*</beans></pre>
|
||||
*</beans></pre>
|
||||
*
|
||||
* <p>The attendant {@code MyClientBean} class implementation might then
|
||||
* look something like this:
|
||||
@@ -135,22 +135,22 @@ import org.springframework.util.StringUtils;
|
||||
* <p>A sample config in an XML-based
|
||||
* {@link org.springframework.beans.factory.BeanFactory} might look as follows:
|
||||
*
|
||||
* <pre class="code"><beans>
|
||||
* <pre class="code"><beans>
|
||||
*
|
||||
* <!-- Prototype beans since we have state (both extend MyService) -->
|
||||
* <bean id="specialService" class="a.b.c.SpecialService" singleton="false"/>
|
||||
* <bean id="anotherService" class="a.b.c.AnotherService" singleton="false"/>
|
||||
* <!-- Prototype beans since we have state (both extend MyService) -->
|
||||
* <bean id="specialService" class="a.b.c.SpecialService" singleton="false"/>
|
||||
* <bean id="anotherService" class="a.b.c.AnotherService" singleton="false"/>
|
||||
*
|
||||
* <bean id="myServiceFactory"
|
||||
* class="org.springframework.beans.factory.config.ServiceLocatorFactoryBean">
|
||||
* <property name="serviceLocatorInterface" value="a.b.c.ServiceFactory"/>
|
||||
* </bean>
|
||||
* class="org.springframework.beans.factory.config.ServiceLocatorFactoryBean">
|
||||
* <property name="serviceLocatorInterface" value="a.b.c.ServiceFactory"/>
|
||||
* </bean>
|
||||
*
|
||||
* <bean id="clientBean" class="a.b.c.MyClientBean">
|
||||
* <property name="myServiceFactory" ref="myServiceFactory"/>
|
||||
* </bean>
|
||||
* <bean id="clientBean" class="a.b.c.MyClientBean">
|
||||
* <property name="myServiceFactory" ref="myServiceFactory"/>
|
||||
* </bean>
|
||||
*
|
||||
*</beans></pre>
|
||||
*</beans></pre>
|
||||
*
|
||||
* <p>The attendant {@code MyClientBean} class implementation might then
|
||||
* look something like this:
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ public abstract class YamlProcessor {
|
||||
* </pre>
|
||||
* when mapped with
|
||||
* <pre class="code">
|
||||
* setDocumentMatchers(properties ->
|
||||
* setDocumentMatchers(properties ->
|
||||
* ("prod".equals(properties.getProperty("environment")) ? MatchStatus.FOUND : MatchStatus.NOT_FOUND));
|
||||
* </pre>
|
||||
* would end up as
|
||||
|
||||
+5
-5
@@ -75,18 +75,18 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* def reader = new GroovyBeanDefinitionReader(myApplicationContext)
|
||||
* reader.beans {
|
||||
* dataSource(BasicDataSource) { // <--- invokeMethod
|
||||
* dataSource(BasicDataSource) { // <--- invokeMethod
|
||||
* driverClassName = "org.hsqldb.jdbcDriver"
|
||||
* url = "jdbc:hsqldb:mem:grailsDB"
|
||||
* username = "sa" // <-- setProperty
|
||||
* username = "sa" // <-- setProperty
|
||||
* password = ""
|
||||
* settings = [mynew:"setting"]
|
||||
* }
|
||||
* sessionFactory(SessionFactory) {
|
||||
* dataSource = dataSource // <-- getProperty for retrieving references
|
||||
* dataSource = dataSource // <-- getProperty for retrieving references
|
||||
* }
|
||||
* myService(MyService) {
|
||||
* nestedBean = { AnotherBean bean -> // <-- setProperty with closure for nested bean
|
||||
* nestedBean = { AnotherBean bean -> // <-- setProperty with closure for nested bean
|
||||
* dataSource = dataSource
|
||||
* }
|
||||
* }
|
||||
@@ -113,7 +113,7 @@ import org.springframework.util.StringUtils;
|
||||
* dataSource = dataSource
|
||||
* }
|
||||
* myService(MyService) {
|
||||
* nestedBean = { AnotherBean bean ->
|
||||
* nestedBean = { AnotherBean bean ->
|
||||
* dataSource = dataSource
|
||||
* }
|
||||
* }
|
||||
|
||||
+2
-2
@@ -1342,7 +1342,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
* @param beanName the name of the bean
|
||||
* @param mbd the bean definition for the bean
|
||||
* @param explicitArgs argument values passed in programmatically via the getBean method,
|
||||
* or {@code null} if none (-> use constructor argument values from bean definition)
|
||||
* or {@code null} if none (implying the use of constructor argument values from bean definition)
|
||||
* @return a BeanWrapper for the new instance
|
||||
* @see #getBean(String, Object[])
|
||||
*/
|
||||
@@ -1363,7 +1363,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
* @param mbd the bean definition for the bean
|
||||
* @param ctors the chosen candidate constructors
|
||||
* @param explicitArgs argument values passed in programmatically via the getBean method,
|
||||
* or {@code null} if none (-> use constructor argument values from bean definition)
|
||||
* or {@code null} if none (implying the use of constructor argument values from bean definition)
|
||||
* @return a BeanWrapper for the new instance
|
||||
*/
|
||||
protected BeanWrapper autowireConstructor(
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -361,7 +361,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
else {
|
||||
String scopeName = mbd.getScope();
|
||||
if (!StringUtils.hasLength(scopeName)) {
|
||||
throw new IllegalStateException("No scope name defined for bean ´" + beanName + "'");
|
||||
throw new IllegalStateException("No scope name defined for bean '" + beanName + "'");
|
||||
}
|
||||
Scope scope = this.scopes.get(scopeName);
|
||||
if (scope == null) {
|
||||
|
||||
+13
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -730,14 +730,23 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
|
||||
throws NoSuchBeanDefinitionException {
|
||||
|
||||
return findMergedAnnotationOnBean(beanName, annotationType)
|
||||
return findAnnotationOnBean(beanName, annotationType, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <A extends Annotation> A findAnnotationOnBean(
|
||||
String beanName, Class<A> annotationType, boolean allowFactoryBeanInit)
|
||||
throws NoSuchBeanDefinitionException {
|
||||
|
||||
return findMergedAnnotationOnBean(beanName, annotationType, allowFactoryBeanInit)
|
||||
.synthesize(MergedAnnotation::isPresent).orElse(null);
|
||||
}
|
||||
|
||||
private <A extends Annotation> MergedAnnotation<A> findMergedAnnotationOnBean(
|
||||
String beanName, Class<A> annotationType) {
|
||||
String beanName, Class<A> annotationType, boolean allowFactoryBeanInit) {
|
||||
|
||||
Class<?> beanType = getType(beanName);
|
||||
Class<?> beanType = getType(beanName, allowFactoryBeanInit);
|
||||
if (beanType != null) {
|
||||
MergedAnnotation<A> annotation =
|
||||
MergedAnnotations.from(beanType, SearchStrategy.TYPE_HIERARCHY).get(annotationType);
|
||||
|
||||
+94
-53
@@ -61,6 +61,8 @@ import org.springframework.util.StringUtils;
|
||||
@SuppressWarnings("serial")
|
||||
class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
|
||||
private static final String DESTROY_METHOD_NAME = "destroy";
|
||||
|
||||
private static final String CLOSE_METHOD_NAME = "close";
|
||||
|
||||
private static final String SHUTDOWN_METHOD_NAME = "shutdown";
|
||||
@@ -72,12 +74,11 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
|
||||
private final String beanName;
|
||||
|
||||
private final boolean invokeDisposableBean;
|
||||
|
||||
private final boolean nonPublicAccessAllowed;
|
||||
|
||||
@Nullable
|
||||
private final AccessControlContext acc;
|
||||
private final boolean invokeDisposableBean;
|
||||
|
||||
private boolean invokeAutoCloseable;
|
||||
|
||||
@Nullable
|
||||
private String destroyMethodName;
|
||||
@@ -88,6 +89,9 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
@Nullable
|
||||
private final List<DestructionAwareBeanPostProcessor> beanPostProcessors;
|
||||
|
||||
@Nullable
|
||||
private final AccessControlContext acc;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new DisposableBeanAdapter for the given bean.
|
||||
@@ -103,38 +107,45 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
Assert.notNull(bean, "Disposable bean must not be null");
|
||||
this.bean = bean;
|
||||
this.beanName = beanName;
|
||||
this.invokeDisposableBean =
|
||||
(this.bean instanceof DisposableBean && !beanDefinition.isExternallyManagedDestroyMethod("destroy"));
|
||||
this.nonPublicAccessAllowed = beanDefinition.isNonPublicAccessAllowed();
|
||||
this.acc = acc;
|
||||
this.invokeDisposableBean = (bean instanceof DisposableBean &&
|
||||
!beanDefinition.isExternallyManagedDestroyMethod(DESTROY_METHOD_NAME));
|
||||
|
||||
String destroyMethodName = inferDestroyMethodIfNecessary(bean, beanDefinition);
|
||||
if (destroyMethodName != null && !(this.invokeDisposableBean && "destroy".equals(destroyMethodName)) &&
|
||||
if (destroyMethodName != null &&
|
||||
!(this.invokeDisposableBean && DESTROY_METHOD_NAME.equals(destroyMethodName)) &&
|
||||
!beanDefinition.isExternallyManagedDestroyMethod(destroyMethodName)) {
|
||||
this.destroyMethodName = destroyMethodName;
|
||||
Method destroyMethod = determineDestroyMethod(destroyMethodName);
|
||||
if (destroyMethod == null) {
|
||||
if (beanDefinition.isEnforceDestroyMethod()) {
|
||||
throw new BeanDefinitionValidationException("Could not find a destroy method named '" +
|
||||
destroyMethodName + "' on bean with name '" + beanName + "'");
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (destroyMethod.getParameterCount() > 0) {
|
||||
Class<?>[] paramTypes = destroyMethod.getParameterTypes();
|
||||
if (paramTypes.length > 1) {
|
||||
throw new BeanDefinitionValidationException("Method '" + destroyMethodName + "' of bean '" +
|
||||
beanName + "' has more than one parameter - not supported as destroy method");
|
||||
}
|
||||
else if (paramTypes.length == 1 && boolean.class != paramTypes[0]) {
|
||||
throw new BeanDefinitionValidationException("Method '" + destroyMethodName + "' of bean '" +
|
||||
beanName + "' has a non-boolean parameter - not supported as destroy method");
|
||||
|
||||
this.invokeAutoCloseable = (bean instanceof AutoCloseable && CLOSE_METHOD_NAME.equals(destroyMethodName));
|
||||
if (!this.invokeAutoCloseable) {
|
||||
this.destroyMethodName = destroyMethodName;
|
||||
Method destroyMethod = determineDestroyMethod(destroyMethodName);
|
||||
if (destroyMethod == null) {
|
||||
if (beanDefinition.isEnforceDestroyMethod()) {
|
||||
throw new BeanDefinitionValidationException("Could not find a destroy method named '" +
|
||||
destroyMethodName + "' on bean with name '" + beanName + "'");
|
||||
}
|
||||
}
|
||||
destroyMethod = ClassUtils.getInterfaceMethodIfPossible(destroyMethod);
|
||||
else {
|
||||
if (destroyMethod.getParameterCount() > 0) {
|
||||
Class<?>[] paramTypes = destroyMethod.getParameterTypes();
|
||||
if (paramTypes.length > 1) {
|
||||
throw new BeanDefinitionValidationException("Method '" + destroyMethodName + "' of bean '" +
|
||||
beanName + "' has more than one parameter - not supported as destroy method");
|
||||
}
|
||||
else if (paramTypes.length == 1 && boolean.class != paramTypes[0]) {
|
||||
throw new BeanDefinitionValidationException("Method '" + destroyMethodName + "' of bean '" +
|
||||
beanName + "' has a non-boolean parameter - not supported as destroy method");
|
||||
}
|
||||
}
|
||||
destroyMethod = ClassUtils.getInterfaceMethodIfPossible(destroyMethod);
|
||||
}
|
||||
this.destroyMethod = destroyMethod;
|
||||
}
|
||||
this.destroyMethod = destroyMethod;
|
||||
}
|
||||
|
||||
this.beanPostProcessors = filterPostProcessors(postProcessors, bean);
|
||||
this.acc = acc;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,26 +160,27 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
Assert.notNull(bean, "Disposable bean must not be null");
|
||||
this.bean = bean;
|
||||
this.beanName = bean.getClass().getName();
|
||||
this.invokeDisposableBean = (this.bean instanceof DisposableBean);
|
||||
this.nonPublicAccessAllowed = true;
|
||||
this.acc = acc;
|
||||
this.invokeDisposableBean = (this.bean instanceof DisposableBean);
|
||||
this.beanPostProcessors = filterPostProcessors(postProcessors, bean);
|
||||
this.acc = acc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new DisposableBeanAdapter for the given bean.
|
||||
*/
|
||||
private DisposableBeanAdapter(Object bean, String beanName, boolean invokeDisposableBean,
|
||||
boolean nonPublicAccessAllowed, @Nullable String destroyMethodName,
|
||||
private DisposableBeanAdapter(Object bean, String beanName, boolean nonPublicAccessAllowed,
|
||||
boolean invokeDisposableBean, boolean invokeAutoCloseable, @Nullable String destroyMethodName,
|
||||
@Nullable List<DestructionAwareBeanPostProcessor> postProcessors) {
|
||||
|
||||
this.bean = bean;
|
||||
this.beanName = beanName;
|
||||
this.invokeDisposableBean = invokeDisposableBean;
|
||||
this.nonPublicAccessAllowed = nonPublicAccessAllowed;
|
||||
this.acc = null;
|
||||
this.invokeDisposableBean = invokeDisposableBean;
|
||||
this.invokeAutoCloseable = invokeAutoCloseable;
|
||||
this.destroyMethodName = destroyMethodName;
|
||||
this.beanPostProcessors = postProcessors;
|
||||
this.acc = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -211,7 +223,32 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.destroyMethod != null) {
|
||||
if (this.invokeAutoCloseable) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Invoking close() on bean with name '" + this.beanName + "'");
|
||||
}
|
||||
try {
|
||||
if (System.getSecurityManager() != null) {
|
||||
AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () -> {
|
||||
((AutoCloseable) this.bean).close();
|
||||
return null;
|
||||
}, this.acc);
|
||||
}
|
||||
else {
|
||||
((AutoCloseable) this.bean).close();
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
String msg = "Invocation of close method failed on bean with name '" + this.beanName + "'";
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.warn(msg, ex);
|
||||
}
|
||||
else {
|
||||
logger.warn(msg + ": " + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (this.destroyMethod != null) {
|
||||
invokeCustomDestroyMethod(this.destroyMethod);
|
||||
}
|
||||
else if (this.destroyMethodName != null) {
|
||||
@@ -259,7 +296,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
args[0] = Boolean.TRUE;
|
||||
}
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Invoking destroy method '" + this.destroyMethodName +
|
||||
logger.trace("Invoking custom destroy method '" + this.destroyMethodName +
|
||||
"' on bean with name '" + this.beanName + "'");
|
||||
}
|
||||
try {
|
||||
@@ -282,7 +319,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException ex) {
|
||||
String msg = "Destroy method '" + this.destroyMethodName + "' on bean with name '" +
|
||||
String msg = "Custom destroy method '" + this.destroyMethodName + "' on bean with name '" +
|
||||
this.beanName + "' threw an exception";
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.warn(msg, ex.getTargetException());
|
||||
@@ -292,7 +329,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
logger.warn("Failed to invoke destroy method '" + this.destroyMethodName +
|
||||
logger.warn("Failed to invoke custom destroy method '" + this.destroyMethodName +
|
||||
"' on bean with name '" + this.beanName + "'", ex);
|
||||
}
|
||||
}
|
||||
@@ -312,8 +349,9 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
}
|
||||
}
|
||||
}
|
||||
return new DisposableBeanAdapter(this.bean, this.beanName, this.invokeDisposableBean,
|
||||
this.nonPublicAccessAllowed, this.destroyMethodName, serializablePostProcessors);
|
||||
return new DisposableBeanAdapter(
|
||||
this.bean, this.beanName, this.nonPublicAccessAllowed, this.invokeDisposableBean,
|
||||
this.invokeAutoCloseable, this.destroyMethodName, serializablePostProcessors);
|
||||
}
|
||||
|
||||
|
||||
@@ -323,10 +361,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
* @param beanDefinition the corresponding bean definition
|
||||
*/
|
||||
public static boolean hasDestroyMethod(Object bean, RootBeanDefinition beanDefinition) {
|
||||
if (bean instanceof DisposableBean || bean instanceof AutoCloseable) {
|
||||
return true;
|
||||
}
|
||||
return inferDestroyMethodIfNecessary(bean, beanDefinition) != null;
|
||||
return (bean instanceof DisposableBean || inferDestroyMethodIfNecessary(bean, beanDefinition) != null);
|
||||
}
|
||||
|
||||
|
||||
@@ -348,21 +383,27 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
String destroyMethodName = beanDefinition.resolvedDestroyMethodName;
|
||||
if (destroyMethodName == null) {
|
||||
destroyMethodName = beanDefinition.getDestroyMethodName();
|
||||
boolean autoCloseable = (bean instanceof AutoCloseable);
|
||||
if (AbstractBeanDefinition.INFER_METHOD.equals(destroyMethodName) ||
|
||||
(destroyMethodName == null && bean instanceof AutoCloseable)) {
|
||||
// Only perform destroy method inference or Closeable detection
|
||||
// in case of the bean not explicitly implementing DisposableBean
|
||||
(destroyMethodName == null && autoCloseable)) {
|
||||
// Only perform destroy method inference in case of the bean
|
||||
// not explicitly implementing the DisposableBean interface
|
||||
destroyMethodName = null;
|
||||
if (!(bean instanceof DisposableBean)) {
|
||||
try {
|
||||
destroyMethodName = bean.getClass().getMethod(CLOSE_METHOD_NAME).getName();
|
||||
if (autoCloseable) {
|
||||
destroyMethodName = CLOSE_METHOD_NAME;
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
else {
|
||||
try {
|
||||
destroyMethodName = bean.getClass().getMethod(SHUTDOWN_METHOD_NAME).getName();
|
||||
destroyMethodName = bean.getClass().getMethod(CLOSE_METHOD_NAME).getName();
|
||||
}
|
||||
catch (NoSuchMethodException ex2) {
|
||||
// no candidate destroy method found
|
||||
catch (NoSuchMethodException ex) {
|
||||
try {
|
||||
destroyMethodName = bean.getClass().getMethod(SHUTDOWN_METHOD_NAME).getName();
|
||||
}
|
||||
catch (NoSuchMethodException ex2) {
|
||||
// no candidate destroy method found
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+59
-4
@@ -21,7 +21,8 @@ import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Executable;
|
||||
import java.lang.reflect.Member;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -422,15 +423,21 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
|
||||
return this.factoryMethodToIntrospect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an externally managed configuration method or field.
|
||||
*/
|
||||
public void registerExternallyManagedConfigMember(Member configMember) {
|
||||
synchronized (this.postProcessingLock) {
|
||||
if (this.externallyManagedConfigMembers == null) {
|
||||
this.externallyManagedConfigMembers = new HashSet<>(1);
|
||||
this.externallyManagedConfigMembers = new LinkedHashSet<>(1);
|
||||
}
|
||||
this.externallyManagedConfigMembers.add(configMember);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the given method or field is an externally managed configuration member.
|
||||
*/
|
||||
public boolean isExternallyManagedConfigMember(Member configMember) {
|
||||
synchronized (this.postProcessingLock) {
|
||||
return (this.externallyManagedConfigMembers != null &&
|
||||
@@ -438,15 +445,33 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all externally managed configuration methods and fields (as an immutable Set).
|
||||
* @since 5.3.11
|
||||
*/
|
||||
public Set<Member> getExternallyManagedConfigMembers() {
|
||||
synchronized (this.postProcessingLock) {
|
||||
return (this.externallyManagedConfigMembers != null ?
|
||||
Collections.unmodifiableSet(new LinkedHashSet<>(this.externallyManagedConfigMembers)) :
|
||||
Collections.emptySet());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an externally managed configuration initialization method.
|
||||
*/
|
||||
public void registerExternallyManagedInitMethod(String initMethod) {
|
||||
synchronized (this.postProcessingLock) {
|
||||
if (this.externallyManagedInitMethods == null) {
|
||||
this.externallyManagedInitMethods = new HashSet<>(1);
|
||||
this.externallyManagedInitMethods = new LinkedHashSet<>(1);
|
||||
}
|
||||
this.externallyManagedInitMethods.add(initMethod);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the given method name indicates an externally managed initialization method.
|
||||
*/
|
||||
public boolean isExternallyManagedInitMethod(String initMethod) {
|
||||
synchronized (this.postProcessingLock) {
|
||||
return (this.externallyManagedInitMethods != null &&
|
||||
@@ -454,15 +479,33 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all externally managed initialization methods (as an immutable Set).
|
||||
* @since 5.3.11
|
||||
*/
|
||||
public Set<String> getExternallyManagedInitMethods() {
|
||||
synchronized (this.postProcessingLock) {
|
||||
return (this.externallyManagedInitMethods != null ?
|
||||
Collections.unmodifiableSet(new LinkedHashSet<>(this.externallyManagedInitMethods)) :
|
||||
Collections.emptySet());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an externally managed configuration destruction method.
|
||||
*/
|
||||
public void registerExternallyManagedDestroyMethod(String destroyMethod) {
|
||||
synchronized (this.postProcessingLock) {
|
||||
if (this.externallyManagedDestroyMethods == null) {
|
||||
this.externallyManagedDestroyMethods = new HashSet<>(1);
|
||||
this.externallyManagedDestroyMethods = new LinkedHashSet<>(1);
|
||||
}
|
||||
this.externallyManagedDestroyMethods.add(destroyMethod);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the given method name indicates an externally managed destruction method.
|
||||
*/
|
||||
public boolean isExternallyManagedDestroyMethod(String destroyMethod) {
|
||||
synchronized (this.postProcessingLock) {
|
||||
return (this.externallyManagedDestroyMethods != null &&
|
||||
@@ -470,6 +513,18 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all externally managed destruction methods (as an immutable Set).
|
||||
* @since 5.3.11
|
||||
*/
|
||||
public Set<String> getExternallyManagedDestroyMethods() {
|
||||
synchronized (this.postProcessingLock) {
|
||||
return (this.externallyManagedDestroyMethods != null ?
|
||||
Collections.unmodifiableSet(new LinkedHashSet<>(this.externallyManagedDestroyMethods)) :
|
||||
Collections.emptySet());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RootBeanDefinition cloneBeanDefinition() {
|
||||
|
||||
+11
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -459,7 +459,16 @@ public class StaticListableBeanFactory implements ListableBeanFactory {
|
||||
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
|
||||
throws NoSuchBeanDefinitionException {
|
||||
|
||||
Class<?> beanType = getType(beanName);
|
||||
return findAnnotationOnBean(beanName, annotationType, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <A extends Annotation> A findAnnotationOnBean(
|
||||
String beanName, Class<A> annotationType, boolean allowFactoryBeanInit)
|
||||
throws NoSuchBeanDefinitionException {
|
||||
|
||||
Class<?> beanType = getType(beanName, allowFactoryBeanInit);
|
||||
return (beanType != null ? AnnotatedElementUtils.findMergedAnnotation(beanType, annotationType) : null);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ import org.springframework.util.xml.XmlValidationModeDetector;
|
||||
* when starting your JVM. For example, to use the Oracle {@link DocumentBuilder},
|
||||
* you might start your application like as follows:
|
||||
*
|
||||
* <pre code="class">java -Djavax.xml.parsers.DocumentBuilderFactory=oracle.xml.jaxp.JXDocumentBuilderFactory MyMainClass</pre>
|
||||
* <pre class="code">java -Djavax.xml.parsers.DocumentBuilderFactory=oracle.xml.jaxp.JXDocumentBuilderFactory MyMainClass</pre>
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -64,24 +64,24 @@ public final class ParserContext {
|
||||
}
|
||||
|
||||
|
||||
public final XmlReaderContext getReaderContext() {
|
||||
public XmlReaderContext getReaderContext() {
|
||||
return this.readerContext;
|
||||
}
|
||||
|
||||
public final BeanDefinitionRegistry getRegistry() {
|
||||
public BeanDefinitionRegistry getRegistry() {
|
||||
return this.readerContext.getRegistry();
|
||||
}
|
||||
|
||||
public final BeanDefinitionParserDelegate getDelegate() {
|
||||
public BeanDefinitionParserDelegate getDelegate() {
|
||||
return this.delegate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public final BeanDefinition getContainingBeanDefinition() {
|
||||
public BeanDefinition getContainingBeanDefinition() {
|
||||
return this.containingBeanDefinition;
|
||||
}
|
||||
|
||||
public final boolean isNested() {
|
||||
public boolean isNested() {
|
||||
return (this.containingBeanDefinition != null);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -71,13 +71,13 @@ public class PluggableSchemaResolver implements EntityResolver {
|
||||
|
||||
private final String schemaMappingsLocation;
|
||||
|
||||
/** Stores the mapping of schema URL -> local schema path. */
|
||||
/** Stores the mapping of schema URL → local schema path. */
|
||||
@Nullable
|
||||
private volatile Map<String, String> schemaMappings;
|
||||
|
||||
|
||||
/**
|
||||
* Loads the schema URL -> schema file location mappings using the default
|
||||
* Loads the schema URL → schema file location mappings using the default
|
||||
* mapping file pattern "META-INF/spring.schemas".
|
||||
* @param classLoader the ClassLoader to use for loading
|
||||
* (can be {@code null}) to use the default ClassLoader)
|
||||
@@ -89,7 +89,7 @@ public class PluggableSchemaResolver implements EntityResolver {
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the schema URL -> schema file location mappings using the given
|
||||
* Loads the schema URL → schema file location mappings using the given
|
||||
* mapping file pattern.
|
||||
* @param classLoader the ClassLoader to use for loading
|
||||
* (can be {@code null}) to use the default ClassLoader)
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.beans.factory.support.security.support;
|
||||
|
||||
/**
|
||||
@@ -27,4 +28,5 @@ public class CustomCallbackBean {
|
||||
public void destroy() {
|
||||
System.setProperty("security.destroy", "true");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.beans.factory.support.security.support;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
@@ -26,4 +27,5 @@ public class DestroyBean implements DisposableBean {
|
||||
public void destroy() throws Exception {
|
||||
System.setProperty("security.destroy", "true");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.beans.factory.support.security.support;
|
||||
|
||||
/**
|
||||
@@ -33,4 +34,5 @@ public class FactoryBean {
|
||||
System.getProperties();
|
||||
return new Object();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.beans.factory.support.security.support;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -26,4 +27,5 @@ public class InitBean implements InitializingBean {
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
System.getProperties();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.beans.factory.support.security.support;
|
||||
|
||||
/**
|
||||
@@ -27,4 +28,5 @@ public class PropertyBean {
|
||||
public void setProperty(Object property) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.beans.testfixture.beans;
|
||||
|
||||
/**
|
||||
@@ -65,4 +66,5 @@ public class DummyBean {
|
||||
public TestBean getSpouse() {
|
||||
return spouse;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,6 @@ import java.util.function.Supplier;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.cache.annotation.AbstractCachingConfiguration;
|
||||
import org.springframework.cache.annotation.CachingConfigurer;
|
||||
import org.springframework.cache.interceptor.CacheResolver;
|
||||
import org.springframework.cache.jcache.interceptor.DefaultJCacheOperationSource;
|
||||
import org.springframework.cache.jcache.interceptor.JCacheOperationSource;
|
||||
@@ -46,11 +45,14 @@ public abstract class AbstractJCacheConfiguration extends AbstractCachingConfigu
|
||||
|
||||
|
||||
@Override
|
||||
protected void useCachingConfigurer(CachingConfigurer config) {
|
||||
super.useCachingConfigurer(config);
|
||||
if (config instanceof JCacheConfigurer) {
|
||||
this.exceptionCacheResolver = ((JCacheConfigurer) config)::exceptionCacheResolver;
|
||||
}
|
||||
protected void useCachingConfigurer(CachingConfigurerSupplier cachingConfigurerSupplier) {
|
||||
super.useCachingConfigurer(cachingConfigurerSupplier);
|
||||
this.exceptionCacheResolver = cachingConfigurerSupplier.adapt(config -> {
|
||||
if (config instanceof JCacheConfigurer) {
|
||||
return ((JCacheConfigurer) config).exceptionCacheResolver();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Bean(name = "jCacheOperationSource")
|
||||
|
||||
Vendored
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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,8 +26,7 @@ import org.springframework.lang.Nullable;
|
||||
* <p>To be implemented by classes annotated with
|
||||
* {@link org.springframework.cache.annotation.EnableCaching} that wish
|
||||
* or need to specify explicitly how exception caches are resolved for
|
||||
* annotation-driven cache management. Consider extending {@link JCacheConfigurerSupport},
|
||||
* which provides a stub implementation of all interface methods.
|
||||
* annotation-driven cache management.
|
||||
*
|
||||
* <p>See {@link org.springframework.cache.annotation.EnableCaching} for
|
||||
* general examples and context; see {@link #exceptionCacheResolver()} for
|
||||
@@ -36,7 +35,6 @@ import org.springframework.lang.Nullable;
|
||||
* @author Stephane Nicoll
|
||||
* @since 4.1
|
||||
* @see CachingConfigurer
|
||||
* @see JCacheConfigurerSupport
|
||||
* @see org.springframework.cache.annotation.EnableCaching
|
||||
*/
|
||||
public interface JCacheConfigurer extends CachingConfigurer {
|
||||
@@ -60,6 +58,8 @@ public interface JCacheConfigurer extends CachingConfigurer {
|
||||
* See {@link org.springframework.cache.annotation.EnableCaching} for more complete examples.
|
||||
*/
|
||||
@Nullable
|
||||
CacheResolver exceptionCacheResolver();
|
||||
default CacheResolver exceptionCacheResolver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -79,7 +79,7 @@ public abstract class AbstractFallbackJCacheOperationSource implements JCacheOpe
|
||||
|
||||
@Nullable
|
||||
private JCacheOperation<?> computeCacheOperation(Method method, @Nullable Class<?> targetClass) {
|
||||
// Don't allow no-public methods as required.
|
||||
// Don't allow non-public methods, as configured.
|
||||
if (allowPublicMethodsOnly() && !Modifier.isPublic(method.getModifiers())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+4
-4
@@ -896,7 +896,7 @@ public class MimeMessageHelper {
|
||||
* <p><b>NOTE:</b> Invoke {@code addInline} <i>after</i> {@link #setText};
|
||||
* else, mail readers might not be able to resolve inline references correctly.
|
||||
* @param contentId the content ID to use. Will end up as "Content-ID" header
|
||||
* in the body part, surrounded by angle brackets: e.g. "myId" -> "<myId>".
|
||||
* in the body part, surrounded by angle brackets: e.g. "myId" → "<myId>".
|
||||
* Can be referenced in HTML source via src="cid:myId" expressions.
|
||||
* @param dataSource the {@code javax.activation.DataSource} to take
|
||||
* the content from, determining the InputStream and the content type
|
||||
@@ -923,7 +923,7 @@ public class MimeMessageHelper {
|
||||
* <p><b>NOTE:</b> Invoke {@code addInline} <i>after</i> {@link #setText};
|
||||
* else, mail readers might not be able to resolve inline references correctly.
|
||||
* @param contentId the content ID to use. Will end up as "Content-ID" header
|
||||
* in the body part, surrounded by angle brackets: e.g. "myId" -> "<myId>".
|
||||
* in the body part, surrounded by angle brackets: e.g. "myId" → "<myId>".
|
||||
* Can be referenced in HTML source via src="cid:myId" expressions.
|
||||
* @param file the File resource to take the content from
|
||||
* @throws MessagingException in case of errors
|
||||
@@ -950,7 +950,7 @@ public class MimeMessageHelper {
|
||||
* <p><b>NOTE:</b> Invoke {@code addInline} <i>after</i> {@link #setText};
|
||||
* else, mail readers might not be able to resolve inline references correctly.
|
||||
* @param contentId the content ID to use. Will end up as "Content-ID" header
|
||||
* in the body part, surrounded by angle brackets: e.g. "myId" -> "<myId>".
|
||||
* in the body part, surrounded by angle brackets: e.g. "myId" → "<myId>".
|
||||
* Can be referenced in HTML source via src="cid:myId" expressions.
|
||||
* @param resource the resource to take the content from
|
||||
* @throws MessagingException in case of errors
|
||||
@@ -976,7 +976,7 @@ public class MimeMessageHelper {
|
||||
* <p><b>NOTE:</b> Invoke {@code addInline} <i>after</i> {@code setText};
|
||||
* else, mail readers might not be able to resolve inline references correctly.
|
||||
* @param contentId the content ID to use. Will end up as "Content-ID" header
|
||||
* in the body part, surrounded by angle brackets: e.g. "myId" -> "<myId>".
|
||||
* in the body part, surrounded by angle brackets: e.g. "myId" → "<myId>".
|
||||
* Can be referenced in HTML source via src="cid:myId" expressions.
|
||||
* @param inputStreamSource the resource to take the content from
|
||||
* @param contentType the content type to use for the element
|
||||
|
||||
+5
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,6 +39,8 @@ import org.springframework.lang.Nullable;
|
||||
* Subclass of Quartz's {@link JobStoreCMT} class that delegates to a Spring-managed
|
||||
* {@link DataSource} instead of using a Quartz-managed JDBC connection pool.
|
||||
* This JobStore will be used if SchedulerFactoryBean's "dataSource" property is set.
|
||||
* You may also configure it explicitly, possibly as a custom subclass of this
|
||||
* {@code LocalDataSourceJobStore} or as an equivalent {@code JobStoreCMT} variant.
|
||||
*
|
||||
* <p>Supports both transactional and non-transactional DataSource access.
|
||||
* With a non-XA DataSource and local Spring transactions, a single DataSource
|
||||
@@ -58,6 +60,8 @@ import org.springframework.lang.Nullable;
|
||||
* @since 1.1
|
||||
* @see SchedulerFactoryBean#setDataSource
|
||||
* @see SchedulerFactoryBean#setNonTransactionalDataSource
|
||||
* @see SchedulerFactoryBean#getConfigTimeDataSource()
|
||||
* @see SchedulerFactoryBean#getConfigTimeNonTransactionalDataSource()
|
||||
* @see org.springframework.jdbc.datasource.DataSourceUtils#doGetConnection
|
||||
* @see org.springframework.jdbc.datasource.DataSourceUtils#releaseConnection
|
||||
*/
|
||||
|
||||
+5
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -310,9 +310,11 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
|
||||
|
||||
/**
|
||||
* Set the default {@link DataSource} to be used by the Scheduler.
|
||||
* If set, this will override corresponding settings in Quartz properties.
|
||||
* <p>Note: If this is set, the Quartz settings should not define
|
||||
* a job store "dataSource" to avoid meaningless double configuration.
|
||||
* Also, do not define a "org.quartz.jobStore.class" property at all.
|
||||
* (You may explicitly define Spring's {@link LocalDataSourceJobStore}
|
||||
* but that's the default when using this method anyway.)
|
||||
* <p>A Spring-specific subclass of Quartz' JobStoreCMT will be used.
|
||||
* It is therefore strongly recommended to perform all operations on
|
||||
* the Scheduler within Spring-managed (or plain JTA) transactions.
|
||||
@@ -570,7 +572,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
|
||||
|
||||
CollectionUtils.mergePropertiesIntoMap(this.quartzProperties, mergedProps);
|
||||
if (this.dataSource != null) {
|
||||
mergedProps.setProperty(StdSchedulerFactory.PROP_JOB_STORE_CLASS, LocalDataSourceJobStore.class.getName());
|
||||
mergedProps.putIfAbsent(StdSchedulerFactory.PROP_JOB_STORE_CLASS, LocalDataSourceJobStore.class.getName());
|
||||
}
|
||||
|
||||
// Determine scheduler name across local settings and Quartz properties...
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 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,7 @@ import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||
import org.springframework.cache.annotation.CachingConfigurer;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cache.interceptor.KeyGenerator;
|
||||
import org.springframework.cache.interceptor.SimpleKeyGenerator;
|
||||
@@ -104,7 +104,7 @@ public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests {
|
||||
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
static class EnableCachingConfig extends CachingConfigurerSupport {
|
||||
static class EnableCachingConfig implements CachingConfigurer {
|
||||
|
||||
@Autowired
|
||||
CachingProvider cachingProvider;
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -180,7 +180,7 @@ public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests {
|
||||
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
public static class EmptyConfigSupportConfig extends JCacheConfigurerSupport {
|
||||
public static class EmptyConfigSupportConfig implements JCacheConfigurer {
|
||||
@Bean
|
||||
public CacheManager cm() {
|
||||
return new NoOpCacheManager();
|
||||
@@ -190,7 +190,7 @@ public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests {
|
||||
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
static class FullCachingConfigSupport extends JCacheConfigurerSupport {
|
||||
static class FullCachingConfigSupport implements JCacheConfigurer {
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
@@ -220,7 +220,7 @@ public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests {
|
||||
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
static class NoExceptionCacheResolverConfig extends JCacheConfigurerSupport {
|
||||
static class NoExceptionCacheResolverConfig implements JCacheConfigurer {
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 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,7 +34,7 @@ import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cache.interceptor.CacheErrorHandler;
|
||||
import org.springframework.cache.interceptor.SimpleKeyGenerator;
|
||||
import org.springframework.cache.jcache.config.JCacheConfigurerSupport;
|
||||
import org.springframework.cache.jcache.config.JCacheConfigurer;
|
||||
import org.springframework.cache.support.SimpleCacheManager;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -141,7 +141,7 @@ public class JCacheErrorHandlerTests {
|
||||
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
static class Config extends JCacheConfigurerSupport {
|
||||
static class Config implements JCacheConfigurer {
|
||||
|
||||
@Bean
|
||||
@Override
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 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,7 +34,7 @@ import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
|
||||
import org.springframework.cache.interceptor.KeyGenerator;
|
||||
import org.springframework.cache.interceptor.SimpleKey;
|
||||
import org.springframework.cache.interceptor.SimpleKeyGenerator;
|
||||
import org.springframework.cache.jcache.config.JCacheConfigurerSupport;
|
||||
import org.springframework.cache.jcache.config.JCacheConfigurer;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -97,7 +97,7 @@ public class JCacheKeyGeneratorTests {
|
||||
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
static class Config extends JCacheConfigurerSupport {
|
||||
static class Config implements JCacheConfigurer {
|
||||
|
||||
@Bean
|
||||
@Override
|
||||
@@ -151,7 +151,7 @@ public class JCacheKeyGeneratorTests {
|
||||
@Override
|
||||
public Object generate(Object target, Method method, Object... params) {
|
||||
assertThat(Arrays.equals(expectedParams, params)).as("Unexpected parameters: expected: "
|
||||
+ Arrays.toString(this.expectedParams) + " but got: " + Arrays.toString(params)).isTrue();
|
||||
+ Arrays.toString(this.expectedParams) + " but got: " + Arrays.toString(params)).isTrue();
|
||||
return new SimpleKey(params);
|
||||
}
|
||||
}
|
||||
|
||||
+57
-24
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.scheduling.quartz;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@@ -30,6 +31,7 @@ import org.quartz.SchedulerContext;
|
||||
import org.quartz.SchedulerFactory;
|
||||
import org.quartz.impl.JobDetailImpl;
|
||||
import org.quartz.impl.SchedulerRepository;
|
||||
import org.quartz.impl.jdbcjobstore.JobStoreTX;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
@@ -40,6 +42,8 @@ import org.springframework.context.support.StaticApplicationContext;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.core.testfixture.EnabledForTestGroups;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
@@ -57,10 +61,10 @@ import static org.springframework.core.testfixture.TestGroup.LONG_RUNNING;
|
||||
* @author Sam Brannen
|
||||
* @since 20.02.2004
|
||||
*/
|
||||
public class QuartzSupportTests {
|
||||
class QuartzSupportTests {
|
||||
|
||||
@Test
|
||||
public void schedulerFactoryBeanWithApplicationContext() throws Exception {
|
||||
void schedulerFactoryBeanWithApplicationContext() throws Exception {
|
||||
TestBean tb = new TestBean("tb", 99);
|
||||
StaticApplicationContext ac = new StaticApplicationContext();
|
||||
|
||||
@@ -97,7 +101,7 @@ public class QuartzSupportTests {
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(LONG_RUNNING)
|
||||
public void schedulerWithTaskExecutor() throws Exception {
|
||||
void schedulerWithTaskExecutor() throws Exception {
|
||||
CountingTaskExecutor taskExecutor = new CountingTaskExecutor();
|
||||
DummyJob.count = 0;
|
||||
|
||||
@@ -130,7 +134,7 @@ public class QuartzSupportTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void jobDetailWithRunnableInsteadOfJob() {
|
||||
void jobDetailWithRunnableInsteadOfJob() {
|
||||
JobDetailImpl jobDetail = new JobDetailImpl();
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
jobDetail.setJobClass((Class) DummyRunnable.class));
|
||||
@@ -138,7 +142,7 @@ public class QuartzSupportTests {
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(LONG_RUNNING)
|
||||
public void schedulerWithQuartzJobBean() throws Exception {
|
||||
void schedulerWithQuartzJobBean() throws Exception {
|
||||
DummyJob.param = 0;
|
||||
DummyJob.count = 0;
|
||||
|
||||
@@ -171,7 +175,7 @@ public class QuartzSupportTests {
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(LONG_RUNNING)
|
||||
public void schedulerWithSpringBeanJobFactory() throws Exception {
|
||||
void schedulerWithSpringBeanJobFactory() throws Exception {
|
||||
DummyJob.param = 0;
|
||||
DummyJob.count = 0;
|
||||
|
||||
@@ -206,7 +210,7 @@ public class QuartzSupportTests {
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(LONG_RUNNING)
|
||||
public void schedulerWithSpringBeanJobFactoryAndParamMismatchNotIgnored() throws Exception {
|
||||
void schedulerWithSpringBeanJobFactoryAndParamMismatchNotIgnored() throws Exception {
|
||||
DummyJob.param = 0;
|
||||
DummyJob.count = 0;
|
||||
|
||||
@@ -242,7 +246,7 @@ public class QuartzSupportTests {
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(LONG_RUNNING)
|
||||
public void schedulerWithSpringBeanJobFactoryAndQuartzJobBean() throws Exception {
|
||||
void schedulerWithSpringBeanJobFactoryAndQuartzJobBean() throws Exception {
|
||||
DummyJobBean.param = 0;
|
||||
DummyJobBean.count = 0;
|
||||
|
||||
@@ -276,7 +280,7 @@ public class QuartzSupportTests {
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(LONG_RUNNING)
|
||||
public void schedulerWithSpringBeanJobFactoryAndJobSchedulingData() throws Exception {
|
||||
void schedulerWithSpringBeanJobFactoryAndJobSchedulingData() throws Exception {
|
||||
DummyJob.param = 0;
|
||||
DummyJob.count = 0;
|
||||
|
||||
@@ -294,7 +298,7 @@ public class QuartzSupportTests {
|
||||
}
|
||||
|
||||
@Test // SPR-772
|
||||
public void multipleSchedulers() throws Exception {
|
||||
void multipleSchedulers() throws Exception {
|
||||
try (ClassPathXmlApplicationContext ctx = context("multipleSchedulers.xml")) {
|
||||
Scheduler scheduler1 = (Scheduler) ctx.getBean("scheduler1");
|
||||
Scheduler scheduler2 = (Scheduler) ctx.getBean("scheduler2");
|
||||
@@ -305,7 +309,7 @@ public class QuartzSupportTests {
|
||||
}
|
||||
|
||||
@Test // SPR-16884
|
||||
public void multipleSchedulersWithQuartzProperties() throws Exception {
|
||||
void multipleSchedulersWithQuartzProperties() throws Exception {
|
||||
try (ClassPathXmlApplicationContext ctx = context("multipleSchedulersWithQuartzProperties.xml")) {
|
||||
Scheduler scheduler1 = (Scheduler) ctx.getBean("scheduler1");
|
||||
Scheduler scheduler2 = (Scheduler) ctx.getBean("scheduler2");
|
||||
@@ -317,12 +321,13 @@ public class QuartzSupportTests {
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(LONG_RUNNING)
|
||||
public void twoAnonymousMethodInvokingJobDetailFactoryBeans() throws Exception {
|
||||
Thread.sleep(3000);
|
||||
void twoAnonymousMethodInvokingJobDetailFactoryBeans() throws Exception {
|
||||
try (ClassPathXmlApplicationContext ctx = context("multipleAnonymousMethodInvokingJobDetailFB.xml")) {
|
||||
QuartzTestBean exportService = (QuartzTestBean) ctx.getBean("exportService");
|
||||
QuartzTestBean importService = (QuartzTestBean) ctx.getBean("importService");
|
||||
|
||||
Thread.sleep(400);
|
||||
|
||||
assertThat(exportService.getImportCount()).as("doImport called exportService").isEqualTo(0);
|
||||
assertThat(exportService.getExportCount()).as("doExport not called on exportService").isEqualTo(2);
|
||||
assertThat(importService.getImportCount()).as("doImport not called on importService").isEqualTo(2);
|
||||
@@ -332,12 +337,13 @@ public class QuartzSupportTests {
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(LONG_RUNNING)
|
||||
public void schedulerAccessorBean() throws Exception {
|
||||
Thread.sleep(3000);
|
||||
void schedulerAccessorBean() throws Exception {
|
||||
try (ClassPathXmlApplicationContext ctx = context("schedulerAccessorBean.xml")) {
|
||||
QuartzTestBean exportService = (QuartzTestBean) ctx.getBean("exportService");
|
||||
QuartzTestBean importService = (QuartzTestBean) ctx.getBean("importService");
|
||||
|
||||
Thread.sleep(400);
|
||||
|
||||
assertThat(exportService.getImportCount()).as("doImport called exportService").isEqualTo(0);
|
||||
assertThat(exportService.getExportCount()).as("doExport not called on exportService").isEqualTo(2);
|
||||
assertThat(importService.getImportCount()).as("doImport not called on importService").isEqualTo(2);
|
||||
@@ -347,7 +353,7 @@ public class QuartzSupportTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void schedulerAutoStartsOnContextRefreshedEventByDefault() throws Exception {
|
||||
void schedulerAutoStartsOnContextRefreshedEventByDefault() throws Exception {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
context.registerBeanDefinition("scheduler", new RootBeanDefinition(SchedulerFactoryBean.class));
|
||||
Scheduler bean = context.getBean("scheduler", Scheduler.class);
|
||||
@@ -358,7 +364,7 @@ public class QuartzSupportTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
public void schedulerAutoStartupFalse() throws Exception {
|
||||
void schedulerAutoStartupFalse() throws Exception {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
BeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(SchedulerFactoryBean.class)
|
||||
.addPropertyValue("autoStartup", false).getBeanDefinition();
|
||||
@@ -370,7 +376,7 @@ public class QuartzSupportTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void schedulerRepositoryExposure() throws Exception {
|
||||
void schedulerRepositoryExposure() throws Exception {
|
||||
try (ClassPathXmlApplicationContext ctx = context("schedulerRepositoryExposure.xml")) {
|
||||
assertThat(ctx.getBean("scheduler")).isSameAs(SchedulerRepository.getInstance().lookup("myScheduler"));
|
||||
}
|
||||
@@ -381,7 +387,7 @@ public class QuartzSupportTests {
|
||||
* TODO: Against Quartz 2.2, this test's job doesn't actually execute anymore...
|
||||
*/
|
||||
@Test
|
||||
public void schedulerWithHsqlDataSource() throws Exception {
|
||||
void schedulerWithHsqlDataSource() throws Exception {
|
||||
DummyJob.param = 0;
|
||||
DummyJob.count = 0;
|
||||
|
||||
@@ -396,12 +402,36 @@ public class QuartzSupportTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("resource")
|
||||
void schedulerFactoryBeanWithCustomJobStore() throws Exception {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
|
||||
String dbName = "mydb";
|
||||
EmbeddedDatabase database = new EmbeddedDatabaseBuilder().setName(dbName).build();
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("org.quartz.jobStore.class", JobStoreTX.class.getName());
|
||||
properties.setProperty("org.quartz.jobStore.dataSource", dbName);
|
||||
|
||||
BeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(SchedulerFactoryBean.class)
|
||||
.addPropertyValue("autoStartup", false)
|
||||
.addPropertyValue("dataSource", database)
|
||||
.addPropertyValue("quartzProperties", properties)
|
||||
.getBeanDefinition();
|
||||
context.registerBeanDefinition("scheduler", beanDefinition);
|
||||
|
||||
Scheduler scheduler = context.getBean(Scheduler.class);
|
||||
|
||||
assertThat(scheduler.getMetaData().getJobStoreClass()).isEqualTo(JobStoreTX.class);
|
||||
}
|
||||
|
||||
private ClassPathXmlApplicationContext context(String path) {
|
||||
return new ClassPathXmlApplicationContext(path, getClass());
|
||||
}
|
||||
|
||||
|
||||
public static class CountingTaskExecutor implements TaskExecutor {
|
||||
private static class CountingTaskExecutor implements TaskExecutor {
|
||||
|
||||
private int count;
|
||||
|
||||
@@ -413,12 +443,14 @@ public class QuartzSupportTests {
|
||||
}
|
||||
|
||||
|
||||
public static class DummyJob implements Job {
|
||||
private static class DummyJob implements Job {
|
||||
|
||||
private static int param;
|
||||
|
||||
private static int count;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
// Must be public
|
||||
public void setParam(int value) {
|
||||
if (param > 0) {
|
||||
throw new IllegalStateException("Param already set");
|
||||
@@ -433,12 +465,13 @@ public class QuartzSupportTests {
|
||||
}
|
||||
|
||||
|
||||
public static class DummyJobBean extends QuartzJobBean {
|
||||
private static class DummyJobBean extends QuartzJobBean {
|
||||
|
||||
private static int param;
|
||||
|
||||
private static int count;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void setParam(int value) {
|
||||
if (param > 0) {
|
||||
throw new IllegalStateException("Param already set");
|
||||
@@ -453,7 +486,7 @@ public class QuartzSupportTests {
|
||||
}
|
||||
|
||||
|
||||
public static class DummyRunnable implements Runnable {
|
||||
private static class DummyRunnable implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@
|
||||
<property name="targetMethod" value="doExport"/>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="repeatInterval" value="1000"/>
|
||||
<property name="repeatInterval" value="200"/>
|
||||
<property name="repeatCount" value="1"/>
|
||||
</bean>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<property name="targetMethod" value="doImport"/>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="repeatInterval" value="1000"/>
|
||||
<property name="repeatInterval" value="200"/>
|
||||
<property name="repeatCount" value="1"/>
|
||||
</bean>
|
||||
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@
|
||||
<property name="targetMethod" value="doExport"/>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="repeatInterval" value="1000"/>
|
||||
<property name="repeatInterval" value="200"/>
|
||||
<property name="repeatCount" value="1"/>
|
||||
</bean>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<property name="targetMethod" value="doImport"/>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="repeatInterval" value="1000"/>
|
||||
<property name="repeatInterval" value="200"/>
|
||||
<property name="repeatCount" value="1"/>
|
||||
</bean>
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ dependencies {
|
||||
testImplementation("org.codehaus.groovy:groovy-test")
|
||||
testImplementation("org.codehaus.groovy:groovy-xml")
|
||||
testImplementation("org.apache.commons:commons-pool2")
|
||||
testImplementation("javax.inject:javax.inject-tck")
|
||||
testImplementation("org.awaitility:awaitility")
|
||||
testImplementation("javax.inject:javax.inject-tck")
|
||||
testRuntimeOnly("javax.xml.bind:jaxb-api")
|
||||
testRuntimeOnly("org.glassfish:javax.el")
|
||||
// Substitute for javax.management:jmxremote_optional:1.0.1_04 (not available on Maven Central)
|
||||
|
||||
Vendored
+56
-21
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,9 +16,12 @@
|
||||
|
||||
package org.springframework.cache.annotation;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.interceptor.CacheErrorHandler;
|
||||
@@ -30,6 +33,7 @@ import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.function.SingletonSupplier;
|
||||
|
||||
/**
|
||||
* Abstract base {@code @Configuration} class providing common structure
|
||||
@@ -63,36 +67,67 @@ public abstract class AbstractCachingConfiguration implements ImportAware {
|
||||
@Override
|
||||
public void setImportMetadata(AnnotationMetadata importMetadata) {
|
||||
this.enableCaching = AnnotationAttributes.fromMap(
|
||||
importMetadata.getAnnotationAttributes(EnableCaching.class.getName(), false));
|
||||
importMetadata.getAnnotationAttributes(EnableCaching.class.getName()));
|
||||
if (this.enableCaching == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"@EnableCaching is not present on importing class " + importMetadata.getClassName());
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired(required = false)
|
||||
void setConfigurers(Collection<CachingConfigurer> configurers) {
|
||||
if (CollectionUtils.isEmpty(configurers)) {
|
||||
return;
|
||||
}
|
||||
if (configurers.size() > 1) {
|
||||
throw new IllegalStateException(configurers.size() + " implementations of " +
|
||||
"CachingConfigurer were found when only 1 was expected. " +
|
||||
"Refactor the configuration such that CachingConfigurer is " +
|
||||
"implemented only once or not at all.");
|
||||
}
|
||||
CachingConfigurer configurer = configurers.iterator().next();
|
||||
useCachingConfigurer(configurer);
|
||||
@Autowired
|
||||
void setConfigurers(ObjectProvider<CachingConfigurer> configurers) {
|
||||
Supplier<CachingConfigurer> configurer = () -> {
|
||||
List<CachingConfigurer> candidates = configurers.stream().collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(candidates)) {
|
||||
return null;
|
||||
}
|
||||
if (candidates.size() > 1) {
|
||||
throw new IllegalStateException(candidates.size() + " implementations of " +
|
||||
"CachingConfigurer were found when only 1 was expected. " +
|
||||
"Refactor the configuration such that CachingConfigurer is " +
|
||||
"implemented only once or not at all.");
|
||||
}
|
||||
return candidates.get(0);
|
||||
};
|
||||
useCachingConfigurer(new CachingConfigurerSupplier(configurer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the configuration from the nominated {@link CachingConfigurer}.
|
||||
*/
|
||||
protected void useCachingConfigurer(CachingConfigurer config) {
|
||||
this.cacheManager = config::cacheManager;
|
||||
this.cacheResolver = config::cacheResolver;
|
||||
this.keyGenerator = config::keyGenerator;
|
||||
this.errorHandler = config::errorHandler;
|
||||
protected void useCachingConfigurer(CachingConfigurerSupplier cachingConfigurerSupplier) {
|
||||
this.cacheManager = cachingConfigurerSupplier.adapt(CachingConfigurer::cacheManager);
|
||||
this.cacheResolver = cachingConfigurerSupplier.adapt(CachingConfigurer::cacheResolver);
|
||||
this.keyGenerator = cachingConfigurerSupplier.adapt(CachingConfigurer::keyGenerator);
|
||||
this.errorHandler = cachingConfigurerSupplier.adapt(CachingConfigurer::errorHandler);
|
||||
}
|
||||
|
||||
|
||||
protected static class CachingConfigurerSupplier {
|
||||
|
||||
private final Supplier<CachingConfigurer> supplier;
|
||||
|
||||
public CachingConfigurerSupplier(Supplier<CachingConfigurer> supplier) {
|
||||
this.supplier = SingletonSupplier.of(supplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapt the {@link CachingConfigurer} supplier to another supplier
|
||||
* provided by the specified mapping function. If the underlying
|
||||
* {@link CachingConfigurer} is {@code null}, {@code null} is returned
|
||||
* and the mapping function is not invoked.
|
||||
* @param provider the provider to use to adapt the supplier
|
||||
* @param <T> the type of the supplier
|
||||
* @return another supplier mapped by the specified function
|
||||
*/
|
||||
@Nullable
|
||||
public <T> Supplier<T> adapt(Function<CachingConfigurer, T> provider) {
|
||||
return () -> {
|
||||
CachingConfigurer cachingConfigurer = this.supplier.get();
|
||||
return (cachingConfigurer != null ? provider.apply(cachingConfigurer) : null);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+14
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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,8 +26,7 @@ import org.springframework.lang.Nullable;
|
||||
* Interface to be implemented by @{@link org.springframework.context.annotation.Configuration
|
||||
* Configuration} classes annotated with @{@link EnableCaching} that wish or need to
|
||||
* specify explicitly how caches are resolved and how keys are generated for annotation-driven
|
||||
* cache management. Consider extending {@link CachingConfigurerSupport}, which provides a
|
||||
* stub implementation of all interface methods.
|
||||
* cache management.
|
||||
*
|
||||
* <p>See @{@link EnableCaching} for general examples and context; see
|
||||
* {@link #cacheManager()}, {@link #cacheResolver()} and {@link #keyGenerator()}
|
||||
@@ -37,7 +36,6 @@ import org.springframework.lang.Nullable;
|
||||
* @author Stephane Nicoll
|
||||
* @since 3.1
|
||||
* @see EnableCaching
|
||||
* @see CachingConfigurerSupport
|
||||
*/
|
||||
public interface CachingConfigurer {
|
||||
|
||||
@@ -64,7 +62,9 @@ public interface CachingConfigurer {
|
||||
* See @{@link EnableCaching} for more complete examples.
|
||||
*/
|
||||
@Nullable
|
||||
CacheManager cacheManager();
|
||||
default CacheManager cacheManager() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link CacheResolver} bean to use to resolve regular caches for
|
||||
@@ -89,7 +89,9 @@ public interface CachingConfigurer {
|
||||
* See {@link EnableCaching} for more complete examples.
|
||||
*/
|
||||
@Nullable
|
||||
CacheResolver cacheResolver();
|
||||
default CacheResolver cacheResolver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the key generator bean to use for annotation-driven cache management.
|
||||
@@ -110,7 +112,9 @@ public interface CachingConfigurer {
|
||||
* See @{@link EnableCaching} for more complete examples.
|
||||
*/
|
||||
@Nullable
|
||||
KeyGenerator keyGenerator();
|
||||
default KeyGenerator keyGenerator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link CacheErrorHandler} to use to handle cache-related errors.
|
||||
@@ -133,6 +137,8 @@ public interface CachingConfigurer {
|
||||
* See @{@link EnableCaching} for more complete examples.
|
||||
*/
|
||||
@Nullable
|
||||
CacheErrorHandler errorHandler();
|
||||
default CacheErrorHandler errorHandler() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+15
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -244,17 +244,21 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser
|
||||
|
||||
private static void registerCacheAspect(Element element, ParserContext parserContext) {
|
||||
if (!parserContext.getRegistry().containsBeanDefinition(CacheManagementConfigUtils.JCACHE_ASPECT_BEAN_NAME)) {
|
||||
Object eleSource = parserContext.extractSource(element);
|
||||
RootBeanDefinition def = new RootBeanDefinition();
|
||||
def.setBeanClassName(JCACHE_ASPECT_CLASS_NAME);
|
||||
def.setFactoryMethodName("aspectOf");
|
||||
BeanDefinition sourceDef = createJCacheOperationSourceBeanDefinition(element, eleSource);
|
||||
String sourceName =
|
||||
parserContext.getReaderContext().registerWithGeneratedName(sourceDef);
|
||||
def.getPropertyValues().add("cacheOperationSource", new RuntimeBeanReference(sourceName));
|
||||
Object source = parserContext.extractSource(element);
|
||||
|
||||
parserContext.registerBeanComponent(new BeanComponentDefinition(sourceDef, sourceName));
|
||||
parserContext.registerBeanComponent(new BeanComponentDefinition(def, CacheManagementConfigUtils.JCACHE_ASPECT_BEAN_NAME));
|
||||
BeanDefinition cacheOperationSourceDef = createJCacheOperationSourceBeanDefinition(element, source);
|
||||
String cacheOperationSourceName = parserContext.getReaderContext().registerWithGeneratedName(cacheOperationSourceDef);
|
||||
|
||||
RootBeanDefinition jcacheAspectDef = new RootBeanDefinition();
|
||||
jcacheAspectDef.setBeanClassName(JCACHE_ASPECT_CLASS_NAME);
|
||||
jcacheAspectDef.setFactoryMethodName("aspectOf");
|
||||
jcacheAspectDef.getPropertyValues().add("cacheOperationSource", new RuntimeBeanReference(cacheOperationSourceName));
|
||||
parserContext.getRegistry().registerBeanDefinition(CacheManagementConfigUtils.JCACHE_ASPECT_BEAN_NAME, jcacheAspectDef);
|
||||
|
||||
CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), source);
|
||||
compositeDef.addNestedComponent(new BeanComponentDefinition(cacheOperationSourceDef, cacheOperationSourceName));
|
||||
compositeDef.addNestedComponent(new BeanComponentDefinition(jcacheAspectDef, CacheManagementConfigUtils.JCACHE_ASPECT_BEAN_NAME));
|
||||
parserContext.registerComponent(compositeDef);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -124,7 +124,7 @@ public abstract class AbstractFallbackCacheOperationSource implements CacheOpera
|
||||
|
||||
@Nullable
|
||||
private Collection<CacheOperation> computeCacheOperations(Method method, @Nullable Class<?> targetClass) {
|
||||
// Don't allow no-public methods as required.
|
||||
// Don't allow non-public methods, as configured.
|
||||
if (allowPublicMethodsOnly() && !Modifier.isPublic(method.getModifiers())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+4
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,9 +47,10 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* <p>If the annotation's value doesn't indicate a bean name, an appropriate
|
||||
* name will be built based on the short name of the class (with the first
|
||||
* letter lower-cased). For example:
|
||||
* letter lower-cased), unless the two first letters are uppercase. For example:
|
||||
*
|
||||
* <pre class="code">com.xyz.FooServiceImpl -> fooServiceImpl</pre>
|
||||
* <pre class="code">com.xyz.URLFooServiceImpl -> URLFooServiceImpl</pre>
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Mark Fisher
|
||||
@@ -156,7 +157,7 @@ public class AnnotationBeanNameGenerator implements BeanNameGenerator {
|
||||
/**
|
||||
* Derive a default bean name from the given bean definition.
|
||||
* <p>The default implementation simply builds a decapitalized version
|
||||
* of the short class name: e.g. "mypackage.MyJdbcDao" -> "myJdbcDao".
|
||||
* of the short class name: e.g. "mypackage.MyJdbcDao" → "myJdbcDao".
|
||||
* <p>Note that inner classes will thus have names of the form
|
||||
* "outerClassName.InnerClassName", which because of the period in the
|
||||
* name may be an issue if you are autowiring by name.
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -282,7 +282,7 @@ public abstract class AnnotationConfigUtils {
|
||||
|
||||
@Nullable
|
||||
static AnnotationAttributes attributesFor(AnnotatedTypeMetadata metadata, String annotationClassName) {
|
||||
return AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(annotationClassName, false));
|
||||
return AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(annotationClassName));
|
||||
}
|
||||
|
||||
static Set<AnnotationAttributes> attributesForRepeatable(AnnotationMetadata metadata,
|
||||
@@ -298,10 +298,10 @@ public abstract class AnnotationConfigUtils {
|
||||
Set<AnnotationAttributes> result = new LinkedHashSet<>();
|
||||
|
||||
// Direct annotation present?
|
||||
addAttributesIfNotNull(result, metadata.getAnnotationAttributes(annotationClassName, false));
|
||||
addAttributesIfNotNull(result, metadata.getAnnotationAttributes(annotationClassName));
|
||||
|
||||
// Container annotation present?
|
||||
Map<String, Object> container = metadata.getAnnotationAttributes(containerClassName, false);
|
||||
Map<String, Object> container = metadata.getAnnotationAttributes(containerClassName);
|
||||
if (container != null && container.containsKey("value")) {
|
||||
for (Map<String, Object> containedAttributes : (Map<String, Object>[]) container.get("value")) {
|
||||
addAttributesIfNotNull(result, containedAttributes);
|
||||
|
||||
+23
-24
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.context.annotation;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.ArrayList;
|
||||
@@ -424,40 +425,38 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC
|
||||
if (traceEnabled) {
|
||||
logger.trace("Scanning " + resource);
|
||||
}
|
||||
if (resource.isReadable()) {
|
||||
try {
|
||||
MetadataReader metadataReader = getMetadataReaderFactory().getMetadataReader(resource);
|
||||
if (isCandidateComponent(metadataReader)) {
|
||||
ScannedGenericBeanDefinition sbd = new ScannedGenericBeanDefinition(metadataReader);
|
||||
sbd.setSource(resource);
|
||||
if (isCandidateComponent(sbd)) {
|
||||
if (debugEnabled) {
|
||||
logger.debug("Identified candidate component class: " + resource);
|
||||
}
|
||||
candidates.add(sbd);
|
||||
}
|
||||
else {
|
||||
if (debugEnabled) {
|
||||
logger.debug("Ignored because not a concrete top-level class: " + resource);
|
||||
}
|
||||
try {
|
||||
MetadataReader metadataReader = getMetadataReaderFactory().getMetadataReader(resource);
|
||||
if (isCandidateComponent(metadataReader)) {
|
||||
ScannedGenericBeanDefinition sbd = new ScannedGenericBeanDefinition(metadataReader);
|
||||
sbd.setSource(resource);
|
||||
if (isCandidateComponent(sbd)) {
|
||||
if (debugEnabled) {
|
||||
logger.debug("Identified candidate component class: " + resource);
|
||||
}
|
||||
candidates.add(sbd);
|
||||
}
|
||||
else {
|
||||
if (traceEnabled) {
|
||||
logger.trace("Ignored because not matching any filter: " + resource);
|
||||
if (debugEnabled) {
|
||||
logger.debug("Ignored because not a concrete top-level class: " + resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
throw new BeanDefinitionStoreException(
|
||||
"Failed to read candidate component class: " + resource, ex);
|
||||
else {
|
||||
if (traceEnabled) {
|
||||
logger.trace("Ignored because not matching any filter: " + resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
catch (FileNotFoundException ex) {
|
||||
if (traceEnabled) {
|
||||
logger.trace("Ignored because not readable: " + resource);
|
||||
logger.trace("Ignored non-readable " + resource + ": " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
throw new BeanDefinitionStoreException(
|
||||
"Failed to read candidate component class: " + resource, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException ex) {
|
||||
|
||||
+35
-12
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -146,22 +146,27 @@ import org.springframework.util.StringValueResolver;
|
||||
public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBeanPostProcessor
|
||||
implements InstantiationAwareBeanPostProcessor, BeanFactoryAware, Serializable {
|
||||
|
||||
// Defensive reference to JNDI API for JDK 9+ (optional java.naming module)
|
||||
private static final boolean jndiPresent = ClassUtils.isPresent(
|
||||
"javax.naming.InitialContext", CommonAnnotationBeanPostProcessor.class.getClassLoader());
|
||||
|
||||
private static final Set<Class<? extends Annotation>> resourceAnnotationTypes = new LinkedHashSet<>(4);
|
||||
|
||||
@Nullable
|
||||
private static final Class<? extends Annotation> webServiceRefClass;
|
||||
|
||||
@Nullable
|
||||
private static final Class<? extends Annotation> ejbClass;
|
||||
|
||||
private static final Set<Class<? extends Annotation>> resourceAnnotationTypes = new LinkedHashSet<>(4);
|
||||
|
||||
static {
|
||||
webServiceRefClass = loadAnnotationType("javax.xml.ws.WebServiceRef");
|
||||
ejbClass = loadAnnotationType("javax.ejb.EJB");
|
||||
|
||||
resourceAnnotationTypes.add(Resource.class);
|
||||
|
||||
webServiceRefClass = loadAnnotationType("javax.xml.ws.WebServiceRef");
|
||||
if (webServiceRefClass != null) {
|
||||
resourceAnnotationTypes.add(webServiceRefClass);
|
||||
}
|
||||
|
||||
ejbClass = loadAnnotationType("javax.ejb.EJB");
|
||||
if (ejbClass != null) {
|
||||
resourceAnnotationTypes.add(ejbClass);
|
||||
}
|
||||
@@ -174,7 +179,8 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||
|
||||
private boolean alwaysUseJndiLookup = false;
|
||||
|
||||
private transient BeanFactory jndiFactory = new SimpleJndiBeanFactory();
|
||||
@Nullable
|
||||
private transient BeanFactory jndiFactory;
|
||||
|
||||
@Nullable
|
||||
private transient BeanFactory resourceFactory;
|
||||
@@ -199,6 +205,11 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||
setInitAnnotationType(PostConstruct.class);
|
||||
setDestroyAnnotationType(PreDestroy.class);
|
||||
ignoreResourceType("javax.xml.ws.WebServiceContext");
|
||||
|
||||
// java.naming module present on JDK 9+?
|
||||
if (jndiPresent) {
|
||||
this.jndiFactory = new SimpleJndiBeanFactory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -332,7 +343,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||
}
|
||||
|
||||
|
||||
private InjectionMetadata findResourceMetadata(String beanName, final Class<?> clazz, @Nullable PropertyValues pvs) {
|
||||
private InjectionMetadata findResourceMetadata(String beanName, Class<?> clazz, @Nullable PropertyValues pvs) {
|
||||
// Fall back to class name as cache key, for backwards compatibility with custom callers.
|
||||
String cacheKey = (StringUtils.hasLength(beanName) ? beanName : clazz.getName());
|
||||
// Quick check on the concurrent map first, with minimal locking.
|
||||
@@ -352,7 +363,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||
return metadata;
|
||||
}
|
||||
|
||||
private InjectionMetadata buildResourceMetadata(final Class<?> clazz) {
|
||||
private InjectionMetadata buildResourceMetadata(Class<?> clazz) {
|
||||
if (!AnnotationUtils.isCandidateClass(clazz, resourceAnnotationTypes)) {
|
||||
return InjectionMetadata.EMPTY;
|
||||
}
|
||||
@@ -464,6 +475,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||
public void releaseTarget(Object target) {
|
||||
}
|
||||
};
|
||||
|
||||
ProxyFactory pf = new ProxyFactory();
|
||||
pf.setTargetSource(ts);
|
||||
if (element.lookupType.isInterface()) {
|
||||
@@ -484,12 +496,23 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||
protected Object getResource(LookupElement element, @Nullable String requestingBeanName)
|
||||
throws NoSuchBeanDefinitionException {
|
||||
|
||||
// JNDI lookup to perform?
|
||||
String jndiName = null;
|
||||
if (StringUtils.hasLength(element.mappedName)) {
|
||||
return this.jndiFactory.getBean(element.mappedName, element.lookupType);
|
||||
jndiName = element.mappedName;
|
||||
}
|
||||
if (this.alwaysUseJndiLookup) {
|
||||
return this.jndiFactory.getBean(element.name, element.lookupType);
|
||||
else if (this.alwaysUseJndiLookup) {
|
||||
jndiName = element.name;
|
||||
}
|
||||
if (jndiName != null) {
|
||||
if (this.jndiFactory == null) {
|
||||
throw new NoSuchBeanDefinitionException(element.lookupType,
|
||||
"No JNDI factory configured - specify the 'jndiFactory' property");
|
||||
}
|
||||
return this.jndiFactory.getBean(jndiName, element.lookupType);
|
||||
}
|
||||
|
||||
// Regular resource autowiring
|
||||
if (this.resourceFactory == null) {
|
||||
throw new NoSuchBeanDefinitionException(element.lookupType,
|
||||
"No resource factory configured - specify the 'resourceFactory' property");
|
||||
|
||||
+10
-59
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,13 +16,10 @@
|
||||
|
||||
package org.springframework.context.annotation;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
@@ -33,12 +30,7 @@ import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter;
|
||||
import org.springframework.core.type.filter.AnnotationTypeFilter;
|
||||
import org.springframework.core.type.filter.AspectJTypeFilter;
|
||||
import org.springframework.core.type.filter.AssignableTypeFilter;
|
||||
import org.springframework.core.type.filter.RegexPatternTypeFilter;
|
||||
import org.springframework.core.type.filter.TypeFilter;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -73,7 +65,7 @@ class ComponentScanAnnotationParser {
|
||||
}
|
||||
|
||||
|
||||
public Set<BeanDefinitionHolder> parse(AnnotationAttributes componentScan, final String declaringClass) {
|
||||
public Set<BeanDefinitionHolder> parse(AnnotationAttributes componentScan, String declaringClass) {
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(this.registry,
|
||||
componentScan.getBoolean("useDefaultFilters"), this.environment, this.resourceLoader);
|
||||
|
||||
@@ -93,13 +85,17 @@ class ComponentScanAnnotationParser {
|
||||
|
||||
scanner.setResourcePattern(componentScan.getString("resourcePattern"));
|
||||
|
||||
for (AnnotationAttributes filter : componentScan.getAnnotationArray("includeFilters")) {
|
||||
for (TypeFilter typeFilter : typeFiltersFor(filter)) {
|
||||
for (AnnotationAttributes includeFilterAttributes : componentScan.getAnnotationArray("includeFilters")) {
|
||||
List<TypeFilter> typeFilters = TypeFilterUtils.createTypeFiltersFor(includeFilterAttributes, this.environment,
|
||||
this.resourceLoader, this.registry);
|
||||
for (TypeFilter typeFilter : typeFilters) {
|
||||
scanner.addIncludeFilter(typeFilter);
|
||||
}
|
||||
}
|
||||
for (AnnotationAttributes filter : componentScan.getAnnotationArray("excludeFilters")) {
|
||||
for (TypeFilter typeFilter : typeFiltersFor(filter)) {
|
||||
for (AnnotationAttributes excludeFilterAttributes : componentScan.getAnnotationArray("excludeFilters")) {
|
||||
List<TypeFilter> typeFilters = TypeFilterUtils.createTypeFiltersFor(excludeFilterAttributes, this.environment,
|
||||
this.resourceLoader, this.registry);
|
||||
for (TypeFilter typeFilter : typeFilters) {
|
||||
scanner.addExcludeFilter(typeFilter);
|
||||
}
|
||||
}
|
||||
@@ -132,49 +128,4 @@ class ComponentScanAnnotationParser {
|
||||
return scanner.doScan(StringUtils.toStringArray(basePackages));
|
||||
}
|
||||
|
||||
private List<TypeFilter> typeFiltersFor(AnnotationAttributes filterAttributes) {
|
||||
List<TypeFilter> typeFilters = new ArrayList<>();
|
||||
FilterType filterType = filterAttributes.getEnum("type");
|
||||
|
||||
for (Class<?> filterClass : filterAttributes.getClassArray("classes")) {
|
||||
switch (filterType) {
|
||||
case ANNOTATION:
|
||||
Assert.isAssignable(Annotation.class, filterClass,
|
||||
"@ComponentScan ANNOTATION type filter requires an annotation type");
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<Annotation> annotationType = (Class<Annotation>) filterClass;
|
||||
typeFilters.add(new AnnotationTypeFilter(annotationType));
|
||||
break;
|
||||
case ASSIGNABLE_TYPE:
|
||||
typeFilters.add(new AssignableTypeFilter(filterClass));
|
||||
break;
|
||||
case CUSTOM:
|
||||
Assert.isAssignable(TypeFilter.class, filterClass,
|
||||
"@ComponentScan CUSTOM type filter requires a TypeFilter implementation");
|
||||
|
||||
TypeFilter filter = ParserStrategyUtils.instantiateClass(filterClass, TypeFilter.class,
|
||||
this.environment, this.resourceLoader, this.registry);
|
||||
typeFilters.add(filter);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Filter type not supported with Class value: " + filterType);
|
||||
}
|
||||
}
|
||||
|
||||
for (String expression : filterAttributes.getStringArray("pattern")) {
|
||||
switch (filterType) {
|
||||
case ASPECTJ:
|
||||
typeFilters.add(new AspectJTypeFilter(expression, this.resourceLoader.getClassLoader()));
|
||||
break;
|
||||
case REGEX:
|
||||
typeFilters.add(new RegexPatternTypeFilter(Pattern.compile(expression)));
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Filter type not supported with String pattern: " + filterType);
|
||||
}
|
||||
}
|
||||
|
||||
return typeFilters;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -129,7 +129,7 @@ import org.springframework.stereotype.Component;
|
||||
* @Configuration
|
||||
* public class AppConfig {
|
||||
*
|
||||
* @Autowired Environment env;
|
||||
* @Autowired Environment env;
|
||||
*
|
||||
* @Bean
|
||||
* public MyBean myBean() {
|
||||
@@ -149,7 +149,7 @@ import org.springframework.stereotype.Component;
|
||||
* @PropertySource("classpath:/com/acme/app.properties")
|
||||
* public class AppConfig {
|
||||
*
|
||||
* @Inject Environment env;
|
||||
* @Inject Environment env;
|
||||
*
|
||||
* @Bean
|
||||
* public MyBean myBean() {
|
||||
@@ -170,7 +170,7 @@ import org.springframework.stereotype.Component;
|
||||
* @PropertySource("classpath:/com/acme/app.properties")
|
||||
* public class AppConfig {
|
||||
*
|
||||
* @Value("${bean.name}") String beanName;
|
||||
* @Value("${bean.name}") String beanName;
|
||||
*
|
||||
* @Bean
|
||||
* public MyBean myBean() {
|
||||
@@ -297,7 +297,7 @@ import org.springframework.stereotype.Component;
|
||||
* @ImportResource("classpath:/com/acme/database-config.xml")
|
||||
* public class AppConfig {
|
||||
*
|
||||
* @Inject DataSource dataSource; // from XML
|
||||
* @Inject DataSource dataSource; // from XML
|
||||
*
|
||||
* @Bean
|
||||
* public MyBean myBean() {
|
||||
|
||||
+7
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -453,8 +453,8 @@ class ConfigurationClassEnhancer {
|
||||
* instance directly. If a FactoryBean instance is fetched through the container via &-dereferencing,
|
||||
* it will not be proxied. This too is aligned with the way XML configuration works.
|
||||
*/
|
||||
private Object enhanceFactoryBean(final Object factoryBean, Class<?> exposedType,
|
||||
final ConfigurableBeanFactory beanFactory, final String beanName) {
|
||||
private Object enhanceFactoryBean(Object factoryBean, Class<?> exposedType,
|
||||
ConfigurableBeanFactory beanFactory, String beanName) {
|
||||
|
||||
try {
|
||||
Class<?> clazz = factoryBean.getClass();
|
||||
@@ -489,8 +489,8 @@ class ConfigurationClassEnhancer {
|
||||
return createCglibProxyForFactoryBean(factoryBean, beanFactory, beanName);
|
||||
}
|
||||
|
||||
private Object createInterfaceProxyForFactoryBean(final Object factoryBean, Class<?> interfaceType,
|
||||
final ConfigurableBeanFactory beanFactory, final String beanName) {
|
||||
private Object createInterfaceProxyForFactoryBean(Object factoryBean, Class<?> interfaceType,
|
||||
ConfigurableBeanFactory beanFactory, String beanName) {
|
||||
|
||||
return Proxy.newProxyInstance(
|
||||
factoryBean.getClass().getClassLoader(), new Class<?>[] {interfaceType},
|
||||
@@ -502,8 +502,8 @@ class ConfigurationClassEnhancer {
|
||||
});
|
||||
}
|
||||
|
||||
private Object createCglibProxyForFactoryBean(final Object factoryBean,
|
||||
final ConfigurableBeanFactory beanFactory, final String beanName) {
|
||||
private Object createCglibProxyForFactoryBean(Object factoryBean,
|
||||
ConfigurableBeanFactory beanFactory, String beanName) {
|
||||
|
||||
Enhancer enhancer = new Enhancer();
|
||||
enhancer.setSuperclass(factoryBean.getClass());
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -98,7 +98,7 @@ import java.lang.annotation.Target;
|
||||
* @EnableAspectJAutoProxy
|
||||
* public class AppConfig {
|
||||
*
|
||||
* // no explicit @Bean definitions required
|
||||
* // no explicit @Bean definitions required
|
||||
* }</pre>
|
||||
*
|
||||
* <b>Note: {@code @EnableAspectJAutoProxy} applies to its local application context only,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,6 +47,11 @@ import java.lang.annotation.Target;
|
||||
* or {@link javax.inject.Inject}: In that context, it leads to the creation of a
|
||||
* lazy-resolution proxy for all affected dependencies, as an alternative to using
|
||||
* {@link org.springframework.beans.factory.ObjectFactory} or {@link javax.inject.Provider}.
|
||||
* Please note that such a lazy-resolution proxy will always be injected; if the target
|
||||
* dependency does not exist, you will only be able to find out through an exception on
|
||||
* invocation. As a consequence, such an injection point results in unintuitive behavior
|
||||
* for optional dependencies. For a programmatic equivalent, allowing for lazy references
|
||||
* with more sophistication, consider {@link org.springframework.beans.factory.ObjectProvider}.
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @author Juergen Hoeller
|
||||
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.context.annotation;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.type.filter.AnnotationTypeFilter;
|
||||
import org.springframework.core.type.filter.AspectJTypeFilter;
|
||||
import org.springframework.core.type.filter.AssignableTypeFilter;
|
||||
import org.springframework.core.type.filter.RegexPatternTypeFilter;
|
||||
import org.springframework.core.type.filter.TypeFilter;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Collection of utilities for working with {@link ComponentScan @ComponentScan}
|
||||
* {@linkplain ComponentScan.Filter type filters}.
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
* @since 5.3.13
|
||||
* @see ComponentScan.Filter
|
||||
* @see org.springframework.core.type.filter.TypeFilter
|
||||
*/
|
||||
public abstract class TypeFilterUtils {
|
||||
|
||||
/**
|
||||
* Create {@linkplain TypeFilter type filters} from the supplied
|
||||
* {@link AnnotationAttributes}, such as those sourced from
|
||||
* {@link ComponentScan#includeFilters()} or {@link ComponentScan#excludeFilters()}.
|
||||
* <p>Each {@link TypeFilter} will be instantiated using an appropriate
|
||||
* constructor, with {@code BeanClassLoaderAware}, {@code BeanFactoryAware},
|
||||
* {@code EnvironmentAware}, and {@code ResourceLoaderAware} contracts
|
||||
* invoked if they are implemented by the type filter.
|
||||
* @param filterAttributes {@code AnnotationAttributes} for a
|
||||
* {@link ComponentScan.Filter @Filter} declaration
|
||||
* @param environment the {@code Environment} to make available to filters
|
||||
* @param resourceLoader the {@code ResourceLoader} to make available to filters
|
||||
* @param registry the {@code BeanDefinitionRegistry} to make available to filters
|
||||
* as a {@link org.springframework.beans.factory.BeanFactory} if applicable
|
||||
* @return a list of instantiated and configured type filters
|
||||
* @see TypeFilter
|
||||
* @see AnnotationTypeFilter
|
||||
* @see AssignableTypeFilter
|
||||
* @see AspectJTypeFilter
|
||||
* @see RegexPatternTypeFilter
|
||||
* @see org.springframework.beans.factory.BeanClassLoaderAware
|
||||
* @see org.springframework.beans.factory.BeanFactoryAware
|
||||
* @see org.springframework.context.EnvironmentAware
|
||||
* @see org.springframework.context.ResourceLoaderAware
|
||||
*/
|
||||
public static List<TypeFilter> createTypeFiltersFor(AnnotationAttributes filterAttributes, Environment environment,
|
||||
ResourceLoader resourceLoader, BeanDefinitionRegistry registry) {
|
||||
|
||||
List<TypeFilter> typeFilters = new ArrayList<>();
|
||||
FilterType filterType = filterAttributes.getEnum("type");
|
||||
|
||||
for (Class<?> filterClass : filterAttributes.getClassArray("classes")) {
|
||||
switch (filterType) {
|
||||
case ANNOTATION:
|
||||
Assert.isAssignable(Annotation.class, filterClass,
|
||||
"@ComponentScan ANNOTATION type filter requires an annotation type");
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<Annotation> annotationType = (Class<Annotation>) filterClass;
|
||||
typeFilters.add(new AnnotationTypeFilter(annotationType));
|
||||
break;
|
||||
case ASSIGNABLE_TYPE:
|
||||
typeFilters.add(new AssignableTypeFilter(filterClass));
|
||||
break;
|
||||
case CUSTOM:
|
||||
Assert.isAssignable(TypeFilter.class, filterClass,
|
||||
"@ComponentScan CUSTOM type filter requires a TypeFilter implementation");
|
||||
TypeFilter filter = ParserStrategyUtils.instantiateClass(filterClass, TypeFilter.class,
|
||||
environment, resourceLoader, registry);
|
||||
typeFilters.add(filter);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Filter type not supported with Class value: " + filterType);
|
||||
}
|
||||
}
|
||||
|
||||
for (String expression : filterAttributes.getStringArray("pattern")) {
|
||||
switch (filterType) {
|
||||
case ASPECTJ:
|
||||
typeFilters.add(new AspectJTypeFilter(expression, resourceLoader.getClassLoader()));
|
||||
break;
|
||||
case REGEX:
|
||||
typeFilters.add(new RegexPatternTypeFilter(Pattern.compile(expression)));
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Filter type not supported with String pattern: " + filterType);
|
||||
}
|
||||
}
|
||||
|
||||
return typeFilters;
|
||||
}
|
||||
|
||||
}
|
||||
+11
-2
@@ -75,7 +75,7 @@ public abstract class CachedExpressionEvaluator {
|
||||
|
||||
/**
|
||||
* Return the {@link Expression} for the specified SpEL value
|
||||
* <p>Parse the expression if it hasn't been already.
|
||||
* <p>{@link #parseExpression(String) Parse the expression} if it hasn't been already.
|
||||
* @param cache the cache to use
|
||||
* @param elementKey the element on which the expression is defined
|
||||
* @param expression the expression to parse
|
||||
@@ -86,12 +86,21 @@ public abstract class CachedExpressionEvaluator {
|
||||
ExpressionKey expressionKey = createKey(elementKey, expression);
|
||||
Expression expr = cache.get(expressionKey);
|
||||
if (expr == null) {
|
||||
expr = getParser().parseExpression(expression);
|
||||
expr = parseExpression(expression);
|
||||
cache.put(expressionKey, expr);
|
||||
}
|
||||
return expr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the specified {@code expression}.
|
||||
* @param expression the expression to parse
|
||||
* @since 5.3.13
|
||||
*/
|
||||
protected Expression parseExpression(String expression) {
|
||||
return getParser().parseExpression(expression);
|
||||
}
|
||||
|
||||
private ExpressionKey createKey(AnnotatedElementKey elementKey, String expression) {
|
||||
return new ExpressionKey(elementKey, expression);
|
||||
}
|
||||
|
||||
+6
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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 @@ import org.springframework.beans.factory.BeanExpressionException;
|
||||
import org.springframework.beans.factory.config.BeanExpressionContext;
|
||||
import org.springframework.beans.factory.config.BeanExpressionResolver;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.support.DefaultConversionService;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.ExpressionParser;
|
||||
import org.springframework.expression.ParserContext;
|
||||
@@ -156,10 +157,10 @@ public class StandardBeanExpressionResolver implements BeanExpressionResolver {
|
||||
sec.addPropertyAccessor(new EnvironmentAccessor());
|
||||
sec.setBeanResolver(new BeanFactoryResolver(evalContext.getBeanFactory()));
|
||||
sec.setTypeLocator(new StandardTypeLocator(evalContext.getBeanFactory().getBeanClassLoader()));
|
||||
ConversionService conversionService = evalContext.getBeanFactory().getConversionService();
|
||||
if (conversionService != null) {
|
||||
sec.setTypeConverter(new StandardTypeConverter(conversionService));
|
||||
}
|
||||
sec.setTypeConverter(new StandardTypeConverter(() -> {
|
||||
ConversionService cs = evalContext.getBeanFactory().getConversionService();
|
||||
return (cs != null ? cs : DefaultConversionService.getSharedInstance());
|
||||
}));
|
||||
customizeEvaluationContext(sec);
|
||||
this.evaluationCache.put(evalContext, sec);
|
||||
}
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ public final class CandidateComponentsIndexLoader {
|
||||
result.add(properties);
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Loaded " + result.size() + "] index(es)");
|
||||
logger.debug("Loaded " + result.size() + " index(es)");
|
||||
}
|
||||
int totalCount = result.stream().mapToInt(Properties::size).sum();
|
||||
return (totalCount > 0 ? new CandidateComponentsIndex(result) : null);
|
||||
|
||||
+10
@@ -1331,6 +1331,16 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
|
||||
return getBeanFactory().findAnnotationOnBean(beanName, annotationType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <A extends Annotation> A findAnnotationOnBean(
|
||||
String beanName, Class<A> annotationType, boolean allowFactoryBeanInit)
|
||||
throws NoSuchBeanDefinitionException {
|
||||
|
||||
assertBeanFactoryActive();
|
||||
return getBeanFactory().findAnnotationOnBean(beanName, annotationType, allowFactoryBeanInit);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Implementation of HierarchicalBeanFactory interface
|
||||
|
||||
+6
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,18 +46,18 @@ import org.springframework.lang.Nullable;
|
||||
*
|
||||
* def context = new GenericGroovyApplicationContext()
|
||||
* context.reader.beans {
|
||||
* dataSource(BasicDataSource) { // <--- invokeMethod
|
||||
* dataSource(BasicDataSource) { // <--- invokeMethod
|
||||
* driverClassName = "org.hsqldb.jdbcDriver"
|
||||
* url = "jdbc:hsqldb:mem:grailsDB"
|
||||
* username = "sa" // <-- setProperty
|
||||
* username = "sa" // <-- setProperty
|
||||
* password = ""
|
||||
* settings = [mynew:"setting"]
|
||||
* }
|
||||
* sessionFactory(SessionFactory) {
|
||||
* dataSource = dataSource // <-- getProperty for retrieving references
|
||||
* dataSource = dataSource // <-- getProperty for retrieving references
|
||||
* }
|
||||
* myService(MyService) {
|
||||
* nestedBean = { AnotherBean bean -> // <-- setProperty with closure for nested bean
|
||||
* nestedBean = { AnotherBean bean -> // <-- setProperty with closure for nested bean
|
||||
* dataSource = dataSource
|
||||
* }
|
||||
* }
|
||||
@@ -84,7 +84,7 @@ import org.springframework.lang.Nullable;
|
||||
* dataSource = dataSource
|
||||
* }
|
||||
* myService(MyService) {
|
||||
* nestedBean = { AnotherBean bean ->
|
||||
* nestedBean = { AnotherBean bean ->
|
||||
* dataSource = dataSource
|
||||
* }
|
||||
* }
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -185,9 +185,9 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS
|
||||
/**
|
||||
* Implemented for compatibility with
|
||||
* {@link org.springframework.beans.factory.config.PlaceholderConfigurerSupport}.
|
||||
* @throws UnsupportedOperationException in this implementation
|
||||
* @deprecated in favor of
|
||||
* {@link #processProperties(ConfigurableListableBeanFactory, ConfigurablePropertyResolver)}
|
||||
* @throws UnsupportedOperationException in this implementation
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -229,7 +229,7 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased
|
||||
* for a Locale, after merging all specified resource bundles.
|
||||
* Either fetches the holder from the cache or freshly loads it.
|
||||
* <p>Only used when caching resource bundle contents forever, i.e.
|
||||
* with cacheSeconds < 0. Therefore, merged properties are always
|
||||
* with cacheSeconds < 0. Therefore, merged properties are always
|
||||
* cached forever.
|
||||
*/
|
||||
protected PropertiesHolder getMergedProperties(Locale locale) {
|
||||
@@ -315,7 +315,7 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased
|
||||
/**
|
||||
* Calculate the filenames for the given bundle basename and Locale,
|
||||
* appending language code, country code, and variant code.
|
||||
* E.g.: basename "messages", Locale "de_AT_oo" -> "messages_de_AT_OO",
|
||||
* <p>For example, basename "messages", Locale "de_AT_oo" → "messages_de_AT_OO",
|
||||
* "messages_de_AT", "messages_de".
|
||||
* <p>Follows the rules defined by {@link java.util.Locale#toString()}.
|
||||
* @param basename the basename of the bundle
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.format;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ import org.springframework.util.StringValueResolver;
|
||||
* as {@code DefaultConversionService} exposes its own
|
||||
* {@link DefaultConversionService#addDefaultConverters addDefaultConverters} method.
|
||||
*
|
||||
* <p>Automatically registers formatters for JSR-354 Money & Currency, JSR-310 Date-Time
|
||||
* <p>Automatically registers formatters for JSR-354 Money & Currency, JSR-310 Date-Time
|
||||
* and/or Joda-Time 2.x, depending on the presence of the corresponding API on the classpath.
|
||||
*
|
||||
* @author Chris Beams
|
||||
@@ -100,7 +100,7 @@ public class DefaultFormattingConversionService extends FormattingConversionServ
|
||||
|
||||
/**
|
||||
* Add formatters appropriate for most environments: including number formatters,
|
||||
* JSR-354 Money & Currency formatters, JSR-310 Date-Time and/or Joda-Time formatters,
|
||||
* JSR-354 Money & Currency formatters, JSR-310 Date-Time and/or Joda-Time formatters,
|
||||
* depending on the presence of the corresponding API on the classpath.
|
||||
* @param formatterRegistry the service to register default formatters with
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -44,8 +44,8 @@ public interface JndiCallback<T> {
|
||||
* <p>Implementations don't need to worry about error handling
|
||||
* or cleanup, as the JndiTemplate class will handle this.
|
||||
* @param ctx the current JNDI context
|
||||
* @throws NamingException if thrown by JNDI methods
|
||||
* @return a result object, or {@code null}
|
||||
* @throws NamingException if thrown by JNDI methods
|
||||
*/
|
||||
@Nullable
|
||||
T doInContext(Context ctx) throws NamingException;
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ import org.springframework.util.Assert;
|
||||
* For example:
|
||||
*
|
||||
* <pre class="code"><property name="jndiEnvironment">
|
||||
* <props>
|
||||
* <props>
|
||||
* <prop key="java.naming.factory.initial">com.sun.jndi.cosnaming.CNCtxFactory</prop>
|
||||
* <prop key="java.naming.provider.url">iiop://localhost:1050</prop>
|
||||
* </props>
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ import org.springframework.util.ClassUtils;
|
||||
* For example:
|
||||
*
|
||||
* <pre class="code"><property name="jndiEnvironment">
|
||||
* <props>
|
||||
* <props>
|
||||
* <prop key="java.naming.factory.initial">com.sun.jndi.cosnaming.CNCtxFactory</prop>
|
||||
* <prop key="java.naming.provider.url">iiop://localhost:1050</prop>
|
||||
* </props>
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* For example:
|
||||
*
|
||||
* <pre class="code"><property name="jndiEnvironment">
|
||||
* <props>
|
||||
* <props>
|
||||
* <prop key="java.naming.factory.initial">com.sun.jndi.cosnaming.CNCtxFactory</prop>
|
||||
* <prop key="java.naming.provider.url">iiop://localhost:1050</prop>
|
||||
* </props>
|
||||
|
||||
+28
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,11 +16,14 @@
|
||||
|
||||
package org.springframework.scheduling.annotation;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.ImportAware;
|
||||
@@ -28,6 +31,7 @@ import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.function.SingletonSupplier;
|
||||
|
||||
/**
|
||||
* Abstract base {@code Configuration} class providing common structure for enabling
|
||||
@@ -55,7 +59,7 @@ public abstract class AbstractAsyncConfiguration implements ImportAware {
|
||||
@Override
|
||||
public void setImportMetadata(AnnotationMetadata importMetadata) {
|
||||
this.enableAsync = AnnotationAttributes.fromMap(
|
||||
importMetadata.getAnnotationAttributes(EnableAsync.class.getName(), false));
|
||||
importMetadata.getAnnotationAttributes(EnableAsync.class.getName()));
|
||||
if (this.enableAsync == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"@EnableAsync is not present on importing class " + importMetadata.getClassName());
|
||||
@@ -65,17 +69,27 @@ public abstract class AbstractAsyncConfiguration implements ImportAware {
|
||||
/**
|
||||
* Collect any {@link AsyncConfigurer} beans through autowiring.
|
||||
*/
|
||||
@Autowired(required = false)
|
||||
void setConfigurers(Collection<AsyncConfigurer> configurers) {
|
||||
if (CollectionUtils.isEmpty(configurers)) {
|
||||
return;
|
||||
}
|
||||
if (configurers.size() > 1) {
|
||||
throw new IllegalStateException("Only one AsyncConfigurer may exist");
|
||||
}
|
||||
AsyncConfigurer configurer = configurers.iterator().next();
|
||||
this.executor = configurer::getAsyncExecutor;
|
||||
this.exceptionHandler = configurer::getAsyncUncaughtExceptionHandler;
|
||||
@Autowired
|
||||
void setConfigurers(ObjectProvider<AsyncConfigurer> configurers) {
|
||||
Supplier<AsyncConfigurer> configurer = SingletonSupplier.of(() -> {
|
||||
List<AsyncConfigurer> candidates = configurers.stream().collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(candidates)) {
|
||||
return null;
|
||||
}
|
||||
if (candidates.size() > 1) {
|
||||
throw new IllegalStateException("Only one AsyncConfigurer may exist");
|
||||
}
|
||||
return candidates.get(0);
|
||||
});
|
||||
this.executor = adapt(configurer, AsyncConfigurer::getAsyncExecutor);
|
||||
this.exceptionHandler = adapt(configurer, AsyncConfigurer::getAsyncUncaughtExceptionHandler);
|
||||
}
|
||||
|
||||
private <T> Supplier<T> adapt(Supplier<AsyncConfigurer> supplier, Function<AsyncConfigurer, T> provider) {
|
||||
return () -> {
|
||||
AsyncConfigurer configurer = supplier.get();
|
||||
return (configurer != null ? provider.apply(configurer) : null);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user