mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Compare commits
466 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f428cbb72f | |||
| 6a5d986b33 | |||
| 8ce9236b0f | |||
| 1a626ab948 | |||
| 56194a1051 | |||
| a496836e46 | |||
| 974e7b88ee | |||
| 069704f4a0 | |||
| d38eb9d6a0 | |||
| 5bd4f88af1 | |||
| b16a3229bc | |||
| a409233e80 | |||
| 7a97ba54ea | |||
| 9de85f1336 | |||
| 484a2f3f2d | |||
| 5bd5df3ec4 | |||
| b51685bf00 | |||
| 687d350b57 | |||
| 73dfa9a968 | |||
| 5a66a339a6 | |||
| 45598ca53a | |||
| 4b30fe2b44 | |||
| e94c69149e | |||
| c69fdfadfc | |||
| bd060a19ac | |||
| 5515112f87 | |||
| 89cadfa8d9 | |||
| 73da153e5c | |||
| 75b323e6c2 | |||
| 13637ec3b5 | |||
| 7da02fb7e3 | |||
| 92c210201e | |||
| ae6d778c3e | |||
| e24ac55480 | |||
| b17a6f9e03 | |||
| 4c050207e7 | |||
| 7ac99c1c2d | |||
| 42e550a178 | |||
| 1b78afe445 | |||
| 001cecd46a | |||
| 21b7dc1ce4 | |||
| a403a754e9 | |||
| 2ae2249842 | |||
| 484addb4f8 | |||
| 65e423219e | |||
| 22fc3255b7 | |||
| 322b0f431f | |||
| 1ff1c950fb | |||
| 1e9b2b1c07 | |||
| 19e944bd4f | |||
| e9e864b093 | |||
| f4b644dfec | |||
| b129fb4b62 | |||
| 50f7ffddf8 | |||
| 4298744c4a | |||
| 44b2657c8e | |||
| 9f69638420 | |||
| 740751bc01 | |||
| de8d4e917d | |||
| fa8acfafbf | |||
| d5bfddac69 | |||
| 1b0d838a19 | |||
| a0f52bf633 | |||
| a9dd927870 | |||
| 323ccf99e5 | |||
| 437eca0b25 | |||
| 965f3c6434 | |||
| 6df7ba2447 | |||
| 1d6f71718d | |||
| 4a6e9a5557 | |||
| 357ca21675 | |||
| 874859493b | |||
| 75a6f3b2b6 | |||
| 88456d4799 | |||
| c44de3c5df | |||
| 9d1789e718 | |||
| 849b6ccb8b | |||
| 997ca5cd3f | |||
| a54bc6650e | |||
| 70424a7e3d | |||
| 318d04cd2b | |||
| d9ff109b0f | |||
| 8501cef98d | |||
| c99a104919 | |||
| 193c289080 | |||
| 9c3270ad35 | |||
| e4a9ade991 | |||
| fbd83015b1 | |||
| 3a15595d0c | |||
| 289a6091f1 | |||
| 3502f6fdc2 | |||
| 8d67a982ec | |||
| c09e10405b | |||
| 6a727e1ed7 | |||
| 246a6db1ca | |||
| 8748ba4c4b | |||
| 2989f01013 | |||
| c6a7732a30 | |||
| e54c9d4a93 | |||
| ac19c696fe | |||
| fecbcd4e93 | |||
| 59396e1a6f | |||
| c4ef47b29f | |||
| c2fdd56107 | |||
| 98536e1387 | |||
| ba13950d3a | |||
| 0009806deb | |||
| 6deee3e818 | |||
| d3acf45ea4 | |||
| 573f1d77f2 | |||
| 1ca06537c1 | |||
| 1ab0850303 | |||
| 2a9eaab674 | |||
| 1fbd38c2d8 | |||
| 49eafe4261 | |||
| b0ed385f84 | |||
| 5d54adfb9a | |||
| 1cbc353dd1 | |||
| 4cf1795359 | |||
| 5629fa2c9f | |||
| 2903cb7f50 | |||
| 986d219391 | |||
| de4da5ea4e | |||
| e8c656d2bc | |||
| bcda243f63 | |||
| 64f304c333 | |||
| 5f6b04251e | |||
| 618cb6155c | |||
| f3dd22da5b | |||
| 6e4bbac6f7 | |||
| 2e4963fca3 | |||
| 4d0adc7d95 | |||
| 3b3f27d5ff | |||
| f32b13c5b3 | |||
| 1897d8e858 | |||
| 71126faae0 | |||
| 9cc03fa8b0 | |||
| 59189e5957 | |||
| 65a8aa1c09 | |||
| f046a066ec | |||
| 6e1cac9145 | |||
| 7cafa6764c | |||
| c1cb0311aa | |||
| f2478cf8cf | |||
| 977084a6b8 | |||
| 0e7e49bab0 | |||
| 301ba01427 | |||
| 881817678f | |||
| b8c92ce931 | |||
| 6158634d67 | |||
| 8d8bb04783 | |||
| 2cac3a8255 | |||
| 25a3019234 | |||
| 3dff1b3f6e | |||
| b1295d0499 | |||
| eeeb0a6546 | |||
| 1bde920cce | |||
| e02ff3a0da | |||
| ff377a3836 | |||
| ddb2bdf8c6 | |||
| b9ebdaaf37 | |||
| 4187e04b69 | |||
| d512cca3fd | |||
| 4bc3e0c2b4 | |||
| d57d914b26 | |||
| 68463e2018 | |||
| 6fa9539ae2 | |||
| ff53a26333 | |||
| b70d400c71 | |||
| 346d0e271d | |||
| c15f23bf0c | |||
| 0962c66592 | |||
| b643f7836c | |||
| 56fdda167e | |||
| 017f2a8ccc | |||
| f7898951bd | |||
| bd6b7b08f3 | |||
| bc043245cc | |||
| 6e8a3fb4db | |||
| 1f12214b45 | |||
| c6bd0c9f3d | |||
| fb22915563 | |||
| c5c27f2963 | |||
| 3e6cfb7c6d | |||
| 8e68ac44d2 | |||
| 81c50dc674 | |||
| 57aa3d1e3b | |||
| 2c45b09263 | |||
| 59f12635f9 | |||
| 901d48c803 | |||
| 0bc7c47bea | |||
| 06e2bada0a | |||
| 8181c0237f | |||
| d4af8c86b2 | |||
| 39ddd0f349 | |||
| 073e78b68d | |||
| f9754f92f4 | |||
| d5f358c33c | |||
| 295df21f06 | |||
| 57a9e8e6dd | |||
| e83491fbe9 | |||
| 37ee264fbf | |||
| 8b5563ecab | |||
| 0a3a82fd83 | |||
| 8b071633d3 | |||
| caed04473e | |||
| 87abdb92da | |||
| 6d11b40353 | |||
| 350f318d2e | |||
| 608ef46516 | |||
| d60446a4fe | |||
| 722cb36e01 | |||
| 5ba37762fe | |||
| f2dc075335 | |||
| 3b0eca921c | |||
| efe2539cf3 | |||
| 0030ff8711 | |||
| f93ca28884 | |||
| 4be416e2ca | |||
| 2033f50f22 | |||
| e33fb892f1 | |||
| afe461609c | |||
| 33d655a634 | |||
| 2654dbfcf1 | |||
| 14440949b3 | |||
| 05dec6d23e | |||
| cc77b4b995 | |||
| fd964ca4b1 | |||
| 5fd761ee39 | |||
| 8fda96cadb | |||
| 9926b68473 | |||
| d8a2672505 | |||
| b125b5e398 | |||
| 65743a68e6 | |||
| f187ca6413 | |||
| 13c213481a | |||
| ce9402618c | |||
| a041769799 | |||
| 09cb7f4c31 | |||
| 04f954956c | |||
| fe4472dbeb | |||
| b708027e94 | |||
| 333449598f | |||
| 03b2d9399e | |||
| 4ccf33e36b | |||
| 5eebe946bd | |||
| 13fa69bdaf | |||
| 4aeca67c4d | |||
| b695b15243 | |||
| ef4b62caa0 | |||
| 238e9ae59f | |||
| 347f2890df | |||
| 8b5a013423 | |||
| a73d9bbed5 | |||
| c1bc74c83f | |||
| f68fdd4454 | |||
| 19640ec3f9 | |||
| 69c882cfbc | |||
| 64af3a0f64 | |||
| d7959edb3e | |||
| 0b77c8835c | |||
| 28f15057ac | |||
| e5025419c2 | |||
| d53ede9bd3 | |||
| 092b3d4a52 | |||
| bf4cadadda | |||
| a9bad580d9 | |||
| 6f6ff33202 | |||
| 4bb837582e | |||
| 3368dcae22 | |||
| 86704112b0 | |||
| d62dd2dd8d | |||
| e935018b0c | |||
| 0747cd6a70 | |||
| 0a30b71dc3 | |||
| 03118542f4 | |||
| 1b3b058ebd | |||
| 8aa94aee27 | |||
| 6dbc828aa1 | |||
| 3c31e0378f | |||
| e6e6b8f4ad | |||
| 4fe94dffc0 | |||
| 4b8a937bee | |||
| 55fc731c59 | |||
| 40a61277e1 | |||
| 8c499cb10b | |||
| 723b2b19a6 | |||
| f09e252417 | |||
| f3b8d7138c | |||
| 47383fce97 | |||
| 8206f0652b | |||
| 1b58fad228 | |||
| a58ef88f1d | |||
| 1d060ecff0 | |||
| 122a3fe9fd | |||
| 2a309a031a | |||
| 03fef655ff | |||
| a9e2040831 | |||
| ffbaa26b4f | |||
| 586912792a | |||
| 640c8ff693 | |||
| d52d9fd268 | |||
| f861f182fa | |||
| d5f34ed641 | |||
| a88c47a120 | |||
| 6dc73469f9 | |||
| 59d654b0cf | |||
| 9779b8b2ab | |||
| 2c8a6bb6f5 | |||
| 5800c7a18a | |||
| dc0a934c99 | |||
| 9ca4de1ccf | |||
| 519195cf66 | |||
| 573ff2c58d | |||
| 9470719cdb | |||
| 97bc2762e1 | |||
| 5867ea0c3c | |||
| 9cc3349e2d | |||
| 8904de2149 | |||
| 4208ec0ba8 | |||
| ab19c227d3 | |||
| be5b9354a9 | |||
| c92393b168 | |||
| 75a813aff6 | |||
| 6446ffd063 | |||
| db7d71503d | |||
| 99d39eb2ee | |||
| c32c9ecb61 | |||
| 40f3fb20c2 | |||
| 268ccb6b6b | |||
| 9c7141a24a | |||
| b0ae8f6058 | |||
| d473506d32 | |||
| 6f65b638de | |||
| 97c63857c4 | |||
| 4cc8f4c4d8 | |||
| dff2c84ed1 | |||
| 17fb4fed09 | |||
| 77bab959a3 | |||
| c2438cb932 | |||
| 03be8095ca | |||
| 4daf685eee | |||
| b6ca8a9018 | |||
| 8071f13481 | |||
| 565b20d638 | |||
| 7610210a0e | |||
| a4803d8b0f | |||
| ab081c4fab | |||
| dbc04282e2 | |||
| bb41ccefc0 | |||
| d0d4421aea | |||
| 1a1d767d59 | |||
| 1bf3e7c021 | |||
| 40ba95f82e | |||
| cc70fdcbeb | |||
| 5f167fd7f8 | |||
| 9fdc4404a5 | |||
| 18a3322d2f | |||
| 87df393f91 | |||
| 963dd3f804 | |||
| 8e3a55ba89 | |||
| a839477d4a | |||
| 53a9697ff1 | |||
| d11bd64e0d | |||
| dedecb9daa | |||
| 35af7ff854 | |||
| 5e904ddcaa | |||
| 74532a24a4 | |||
| c0ee1ff896 | |||
| f944815d92 | |||
| 0d0399ac02 | |||
| d1f42ac729 | |||
| 17f42fc97a | |||
| fa2c377405 | |||
| 9dcdfec2e2 | |||
| 07a0a31565 | |||
| f3a2f57696 | |||
| 80bf394fdc | |||
| f948742781 | |||
| 0088922dfd | |||
| 57fbdc0ad5 | |||
| f5d689e764 | |||
| 681ced8fd3 | |||
| 8b64ad3192 | |||
| 35248498ae | |||
| 5f07434360 | |||
| cd602e5904 | |||
| 0e8bd71d53 | |||
| c752ba5b38 | |||
| 12978b8185 | |||
| 40b4276475 | |||
| 4160ced64c | |||
| a032e86355 | |||
| 4b2bad96ce | |||
| 1513c4a952 | |||
| bb6d9fabee | |||
| bffcd33ea3 | |||
| c9ffa64140 | |||
| aa0d7a61b6 | |||
| e138d7d29f | |||
| 50f8b6b3ab | |||
| 121a3bf670 | |||
| e4031f290e | |||
| 55fa5f2b65 | |||
| 3802aca474 | |||
| a9a4d7cf78 | |||
| 17382aec6d | |||
| 8ad3c958e1 | |||
| 8d743181da | |||
| f92ab75bc9 | |||
| 092b5f7556 | |||
| d4d609318d | |||
| 501891c749 | |||
| 2b0dc8d7ff | |||
| 674e2320a8 | |||
| fee259a3c5 | |||
| 016b7d753c | |||
| a17255a2e3 | |||
| 35efdf6b51 | |||
| b35c238d27 | |||
| db1fd516ea | |||
| b7337b304e | |||
| 7cac1f1e6e | |||
| fa09cd3737 | |||
| be93ee77e4 | |||
| 8330134757 | |||
| 9cb9884533 | |||
| ac25db6d2b | |||
| 22bf9febcc | |||
| c6deeb31ec | |||
| f80b2d9a94 | |||
| 8c206bf477 | |||
| 6aeb8ef56d | |||
| 04a96ffa27 | |||
| 2677584658 | |||
| 99236759ec | |||
| e2aa117ff9 | |||
| 8deec9569c | |||
| 0f8bf10aa8 | |||
| e0a7b074ed | |||
| 4fc41eeeb9 | |||
| 81143a80c4 | |||
| 9572859a35 | |||
| 78931ee3ea | |||
| e522fec611 | |||
| a12bbde87e | |||
| 50235be746 | |||
| 1332482c40 | |||
| 799589ec1c | |||
| 16fdda00c1 | |||
| d2985613d1 | |||
| beac891ff0 | |||
| 2d1b551248 | |||
| aa8cf190d3 | |||
| d643e57318 | |||
| 84d2e5a3c8 | |||
| dab56dbb05 | |||
| 9b647021f7 | |||
| 38089d8e66 | |||
| 554c3f3d7e | |||
| ee40310c92 | |||
| 226cddadef | |||
| 5a80f4f16e | |||
| bb63ce9935 | |||
| 1b4289803b | |||
| 3d7576df7f |
+71
-69
@@ -34,14 +34,14 @@ configure(allprojects) { project ->
|
||||
ext.aspectjVersion = "1.8.9"
|
||||
ext.caffeineVersion = "2.3.5"
|
||||
ext.eclipselinkVersion = "2.4.2"
|
||||
ext.ehcacheVersion = "2.10.3"
|
||||
ext.ehcacheVersion = "2.10.4"
|
||||
ext.ehcachejcacheVersion = "1.0.1"
|
||||
ext.ehcache3Version = "3.1.3"
|
||||
ext.ehcache3Version = "3.1.4"
|
||||
ext.ejbVersion = "3.0"
|
||||
ext.fileuploadVersion = "1.3.2"
|
||||
ext.fileuploadVersion = "1.3.3"
|
||||
ext.freemarkerVersion = "2.3.23"
|
||||
ext.groovyVersion = "2.4.9"
|
||||
ext.gsonVersion = "2.8.0"
|
||||
ext.groovyVersion = "2.4.15"
|
||||
ext.gsonVersion = "2.8.2"
|
||||
ext.guavaVersion = "20.0"
|
||||
ext.hamcrestVersion = "1.3"
|
||||
ext.hibernate3Version = "3.6.10.Final"
|
||||
@@ -51,33 +51,33 @@ configure(allprojects) { project ->
|
||||
ext.hibval5Version = "5.2.5.Final"
|
||||
ext.hsqldbVersion = "2.3.4"
|
||||
ext.httpasyncVersion = "4.1.3"
|
||||
ext.httpclientVersion = "4.5.3"
|
||||
ext.jackson2Version = "2.8.7"
|
||||
ext.httpclientVersion = "4.5.5"
|
||||
ext.jackson2Version = "2.8.11.2"
|
||||
ext.jasperreportsVersion = "6.2.1" // our tests fail with JR-internal NPEs against 6.2.2 and higher
|
||||
ext.javamailVersion = "1.5.6"
|
||||
ext.jettyVersion = "9.3.14.v20161028" // as of 9.3.15, Jetty has hard Servlet 3.1 requirement
|
||||
ext.jetty94Version = "9.4.3.v20170317" // for spring-websocket support, optimized for Jetty 9.4
|
||||
ext.jetty94Version = "9.4.6.v20170531" // for spring-websocket support, optimized for Jetty 9.4
|
||||
ext.jodaVersion = "2.9.9"
|
||||
ext.jrubyVersion = "1.7.26" // JRuby 9000 primarily supported through JSR-223 (StandardScriptFactory)
|
||||
ext.jrubyVersion = "1.7.27" // JRuby 9000 primarily supported through JSR-223 (StandardScriptFactory)
|
||||
ext.jtaVersion = "1.2"
|
||||
ext.junitVersion = "4.12"
|
||||
ext.log4jVersion = "1.2.17"
|
||||
ext.nettyVersion = "4.1.8.Final"
|
||||
ext.nettyVersion = "4.1.29.Final"
|
||||
ext.okhttpVersion = "2.7.5"
|
||||
ext.okhttp3Version = "3.6.0"
|
||||
ext.openjpaVersion = "2.4.1"
|
||||
ext.okhttp3Version = "3.8.1"
|
||||
ext.openjpaVersion = "2.4.2"
|
||||
ext.poiVersion = "3.14"
|
||||
ext.reactorVersion = "2.0.8.RELEASE"
|
||||
ext.romeVersion = "1.7.1"
|
||||
ext.slf4jVersion = "1.7.21"
|
||||
ext.romeVersion = "1.7.4"
|
||||
ext.slf4jVersion = "1.7.25"
|
||||
ext.snakeyamlVersion = "1.17"
|
||||
ext.snifferVersion = "1.15"
|
||||
ext.snifferVersion = "1.16"
|
||||
ext.testngVersion = "6.9.10"
|
||||
ext.tiles2Version = "2.2.2"
|
||||
ext.tiles3Version = "3.0.7"
|
||||
ext.tomcatVersion = "8.5.11"
|
||||
ext.tomcatVersion = "8.5.33"
|
||||
ext.tyrusVersion = "1.3.5" // constrained by WebLogic 12.1.3 support
|
||||
ext.undertowVersion = "1.3.28.Final"
|
||||
ext.undertowVersion = "1.3.33.Final"
|
||||
ext.xmlunitVersion = "1.6"
|
||||
ext.xstreamVersion = "1.4.9"
|
||||
|
||||
@@ -293,8 +293,8 @@ project("spring-core") {
|
||||
// both into the spring-core jar. cglib 3.2 itself depends on asm 5.x and is therefore
|
||||
// further transformed by the JarJar task to depend on org.springframework.asm; this
|
||||
// avoids including two different copies of asm unnecessarily.
|
||||
def cglibVersion = "3.2.5"
|
||||
def objenesisVersion = "2.5.1"
|
||||
def cglibVersion = "3.2.6"
|
||||
def objenesisVersion = "2.6"
|
||||
|
||||
configurations {
|
||||
jarjar
|
||||
@@ -316,7 +316,7 @@ project("spring-core") {
|
||||
}
|
||||
// Repackage net.sf.cglib => org.springframework.cglib
|
||||
rule(pattern: "net.sf.cglib.**", result: "org.springframework.cglib.@1")
|
||||
// As mentioned above, transform cglib"s internal asm dependencies from
|
||||
// As mentioned above, transform cglib's internal asm dependencies from
|
||||
// org.objectweb.asm => org.springframework.asm. Doing this counts on the
|
||||
// the fact that Spring and cglib depend on the same version of asm!
|
||||
rule(pattern: "org.objectweb.asm.**", result: "org.springframework.asm.@1")
|
||||
@@ -475,8 +475,8 @@ project("spring-context") {
|
||||
dependencies {
|
||||
compile(project(":spring-aop"))
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-expression"))
|
||||
compile(project(":spring-core"))
|
||||
compile(project(":spring-expression"))
|
||||
compile(files(project(":spring-core").cglibRepackJar))
|
||||
optional(project(":spring-instrument"))
|
||||
optional("javax.inject:javax.inject:1")
|
||||
@@ -499,13 +499,44 @@ project("spring-context") {
|
||||
}
|
||||
}
|
||||
|
||||
project("spring-oxm") {
|
||||
description = "Spring Object/XML Marshalling"
|
||||
apply from: "oxm.gradle"
|
||||
|
||||
dependencies {
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-core"))
|
||||
optional("org.codehaus.castor:castor-xml:1.4.1") {
|
||||
exclude group: 'stax', module: 'stax-api'
|
||||
exclude group: "org.springframework", module: "spring-context"
|
||||
}
|
||||
optional("org.apache.xmlbeans:xmlbeans:2.6.0") {
|
||||
exclude group: 'stax', module: 'stax-api'
|
||||
}
|
||||
optional("com.thoughtworks.xstream:xstream:${xstreamVersion}") {
|
||||
exclude group: 'xpp3', module: 'xpp3_min'
|
||||
exclude group: 'xmlpull', module: 'xmlpull'
|
||||
}
|
||||
optional("org.jibx:jibx-run:1.2.6")
|
||||
testCompile(project(":spring-context"))
|
||||
testCompile("org.ogce:xpp3:1.1.6")
|
||||
testCompile("org.codehaus.jettison:jettison:1.3.8") {
|
||||
exclude group: 'stax', module: 'stax-api'
|
||||
}
|
||||
testCompile("xmlunit:xmlunit:${xmlunitVersion}")
|
||||
testCompile(files(genCastor.classesDir).builtBy(genCastor))
|
||||
testCompile(files(genJaxb.classesDir).builtBy(genJaxb))
|
||||
testCompile(files(genXmlbeans.classesDir).builtBy(genXmlbeans))
|
||||
}
|
||||
}
|
||||
|
||||
project("spring-messaging") {
|
||||
description = "Spring Messaging"
|
||||
|
||||
dependencies {
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-core"))
|
||||
compile(project(":spring-context"))
|
||||
compile(project(":spring-core"))
|
||||
optional(project(":spring-oxm"))
|
||||
optional("io.projectreactor:reactor-core:${reactorVersion}")
|
||||
optional("io.projectreactor:reactor-net:${reactorVersion}") {
|
||||
@@ -557,45 +588,14 @@ project("spring-tx") {
|
||||
}
|
||||
}
|
||||
|
||||
project("spring-oxm") {
|
||||
description = "Spring Object/XML Marshalling"
|
||||
apply from: "oxm.gradle"
|
||||
|
||||
dependencies {
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-core"))
|
||||
optional("org.codehaus.castor:castor-xml:1.4.1") {
|
||||
exclude group: 'stax', module: 'stax-api'
|
||||
exclude group: "org.springframework", module: "spring-context"
|
||||
}
|
||||
optional("org.apache.xmlbeans:xmlbeans:2.6.0") {
|
||||
exclude group: 'stax', module: 'stax-api'
|
||||
}
|
||||
optional("com.thoughtworks.xstream:xstream:${xstreamVersion}") {
|
||||
exclude group: 'xpp3', module: 'xpp3_min'
|
||||
exclude group: 'xmlpull', module: 'xmlpull'
|
||||
}
|
||||
optional("org.jibx:jibx-run:1.2.6")
|
||||
testCompile(project(":spring-context"))
|
||||
testCompile("xmlunit:xmlunit:${xmlunitVersion}")
|
||||
testCompile("xpp3:xpp3:1.1.4c")
|
||||
testCompile("org.codehaus.jettison:jettison:1.3.8") {
|
||||
exclude group: 'stax', module: 'stax-api'
|
||||
}
|
||||
testCompile(files(genCastor.classesDir).builtBy(genCastor))
|
||||
testCompile(files(genJaxb.classesDir).builtBy(genJaxb))
|
||||
testCompile(files(genXmlbeans.classesDir).builtBy(genXmlbeans))
|
||||
}
|
||||
}
|
||||
|
||||
project("spring-jms") {
|
||||
description = "Spring JMS"
|
||||
|
||||
dependencies {
|
||||
compile(project(":spring-core"))
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-aop"))
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-context"))
|
||||
compile(project(":spring-core"))
|
||||
compile(project(":spring-messaging"))
|
||||
compile(project(":spring-tx"))
|
||||
provided("javax.jms:jms-api:1.1-rev-1")
|
||||
@@ -627,9 +627,9 @@ project("spring-context-support") {
|
||||
description = "Spring Context Support"
|
||||
|
||||
dependencies {
|
||||
compile(project(":spring-core"))
|
||||
compile(project(":spring-beans"))
|
||||
compile(project(":spring-context"))
|
||||
compile(project(":spring-core"))
|
||||
optional(project(":spring-jdbc")) // for Quartz support
|
||||
optional(project(":spring-tx")) // for Quartz support
|
||||
optional("javax.mail:javax.mail-api:${javamailVersion}")
|
||||
@@ -658,6 +658,8 @@ project("spring-context-support") {
|
||||
testCompile("org.slf4j:slf4j-api:${slf4jVersion}")
|
||||
testRuntime("com.sun.mail:javax.mail:${javamailVersion}")
|
||||
testRuntime("org.ehcache:jcache:${ehcachejcacheVersion}")
|
||||
testRuntime("org.ehcache:ehcache:${ehcache3Version}")
|
||||
testRuntime("org.terracotta:management-model:2.3.0")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -702,7 +704,7 @@ project("spring-web") {
|
||||
optional("com.squareup.okhttp:okhttp:${okhttpVersion}")
|
||||
optional("com.squareup.okhttp3:okhttp:${okhttp3Version}")
|
||||
optional("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}")
|
||||
optional("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${jackson2Version}")
|
||||
optional("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.8.11")
|
||||
optional("com.google.code.gson:gson:${gsonVersion}")
|
||||
optional("com.rometools:rome:${romeVersion}")
|
||||
optional("org.eclipse.jetty:jetty-servlet:${jettyVersion}") {
|
||||
@@ -718,13 +720,14 @@ project("spring-web") {
|
||||
testCompile(project(":spring-context-support")) // for JafMediaTypeFactory
|
||||
testCompile("xmlunit:xmlunit:${xmlunitVersion}")
|
||||
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
|
||||
testCompile("org.skyscreamer:jsonassert:1.4.0")
|
||||
testCompile("org.apache.taglibs:taglibs-standard-jstlel:1.2.1") {
|
||||
exclude group: "org.apache.taglibs", module: "taglibs-standard-spec"
|
||||
}
|
||||
testCompile("com.fasterxml.jackson.datatype:jackson-datatype-joda:${jackson2Version}")
|
||||
testCompile("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${jackson2Version}")
|
||||
testCompile("com.fasterxml.jackson.module:jackson-module-kotlin:${jackson2Version}")
|
||||
testCompile("com.squareup.okhttp3:mockwebserver:${okhttp3Version}")
|
||||
testCompile("com.fasterxml.jackson.datatype:jackson-datatype-joda:2.8.11")
|
||||
testCompile("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.8.11")
|
||||
testCompile("com.fasterxml.jackson.module:jackson-module-kotlin:2.8.11.1")
|
||||
testCompile("com.squareup.okhttp3:mockwebserver:${okhttp3Version}")
|
||||
testRuntime("com.sun.mail:javax.mail:${javamailVersion}")
|
||||
}
|
||||
}
|
||||
@@ -834,7 +837,7 @@ project("spring-webmvc") {
|
||||
exclude group: "org.springframework", module: "spring-context"
|
||||
}
|
||||
optional("com.fasterxml.jackson.core:jackson-databind:${jackson2Version}")
|
||||
optional("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${jackson2Version}")
|
||||
optional("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.8.11")
|
||||
optional("com.rometools:rome:${romeVersion}")
|
||||
optional("javax.el:javax.el-api:2.2.5")
|
||||
optional("org.apache.tiles:tiles-api:${tiles3Version}")
|
||||
@@ -854,7 +857,7 @@ project("spring-webmvc") {
|
||||
exclude group: "org.slf4j", module: "jcl-over-slf4j"
|
||||
exclude group: "org.springframework", module: "spring-web"
|
||||
}
|
||||
optional('org.webjars:webjars-locator:0.32')
|
||||
optional('org.webjars:webjars-locator:0.32-1')
|
||||
testCompile("xmlunit:xmlunit:${xmlunitVersion}")
|
||||
testCompile("dom4j:dom4j:1.6.1") {
|
||||
exclude group: "xml-apis", module: "xml-apis"
|
||||
@@ -877,7 +880,7 @@ project("spring-webmvc") {
|
||||
testCompile("commons-io:commons-io:1.4")
|
||||
testCompile("joda-time:joda-time:${jodaVersion}")
|
||||
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
|
||||
testCompile("org.mozilla:rhino:1.7.7.1")
|
||||
testCompile("org.mozilla:rhino:1.7.7.2")
|
||||
testRuntime("org.jruby:jruby:${jrubyVersion}")
|
||||
testRuntime("org.python:jython-standalone:2.5.3")
|
||||
testRuntime("org.webjars:underscorejs:1.8.3")
|
||||
@@ -935,8 +938,8 @@ project("spring-websocket") {
|
||||
description = "Spring WebSocket"
|
||||
|
||||
dependencies {
|
||||
compile(project(":spring-core"))
|
||||
compile(project(":spring-context"))
|
||||
compile(project(":spring-core"))
|
||||
compile(project(":spring-web"))
|
||||
optional(project(":spring-messaging"))
|
||||
optional(project(":spring-webmvc"))
|
||||
@@ -981,11 +984,12 @@ project("spring-test") {
|
||||
|
||||
dependencies {
|
||||
compile(project(":spring-core"))
|
||||
optional(project(":spring-aop"))
|
||||
optional(project(":spring-beans"))
|
||||
optional(project(":spring-context"))
|
||||
optional(project(":spring-jdbc"))
|
||||
optional(project(":spring-tx"))
|
||||
optional(project(":spring-orm"))
|
||||
optional(project(":spring-tx"))
|
||||
optional(project(":spring-web"))
|
||||
optional(project(":spring-webmvc"))
|
||||
optional(project(":spring-webmvc-portlet"))
|
||||
@@ -1010,7 +1014,7 @@ project("spring-test") {
|
||||
optional("org.seleniumhq.selenium:htmlunit-driver:2.23.2")
|
||||
optional("org.seleniumhq.selenium:selenium-java:2.53.1")
|
||||
optional("org.skyscreamer:jsonassert:1.4.0")
|
||||
optional("com.jayway.jsonpath:json-path:2.2.0")
|
||||
optional("com.jayway.jsonpath:json-path:2.3.0")
|
||||
testCompile(project(":spring-context-support"))
|
||||
testCompile(project(":spring-oxm"))
|
||||
testCompile("javax.mail:javax.mail-api:${javamailVersion}")
|
||||
@@ -1033,8 +1037,6 @@ project("spring-test") {
|
||||
testCompile("org.apache.httpcomponents:httpclient:${httpclientVersion}")
|
||||
testCompile("javax.cache:cache-api:1.0.0")
|
||||
testRuntime("log4j:log4j:${log4jVersion}")
|
||||
testRuntime("org.ehcache:ehcache:${ehcache3Version}")
|
||||
testRuntime("org.terracotta:management-model:2.3.0")
|
||||
}
|
||||
|
||||
task testNG(type: Test) {
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
version=4.3.8.RELEASE
|
||||
version=4.3.19.RELEASE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -48,10 +48,11 @@ import java.lang.reflect.Method;
|
||||
public interface MethodMatcher {
|
||||
|
||||
/**
|
||||
* Perform static checking whether the given method matches. If this
|
||||
* returns {@code false} or if the {@link #isRuntime()} method
|
||||
* returns {@code false}, no runtime check (i.e. no.
|
||||
* {@link #matches(java.lang.reflect.Method, Class, Object[])} call) will be made.
|
||||
* Perform static checking whether the given method matches.
|
||||
* <p>If this returns {@code false} or if the {@link #isRuntime()}
|
||||
* method returns {@code false}, no runtime check (i.e. no
|
||||
* {@link #matches(java.lang.reflect.Method, Class, Object[])} call)
|
||||
* will be made.
|
||||
* @param method the candidate method
|
||||
* @param targetClass the target class (may be {@code null}, in which case
|
||||
* the candidate class must be taken to be the method's declaring class)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*<
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,9 +34,8 @@ public interface TargetSource extends TargetClassAware {
|
||||
|
||||
/**
|
||||
* Return the type of targets returned by this {@link TargetSource}.
|
||||
* <p>Can return {@code null}, although certain usages of a
|
||||
* {@code TargetSource} might just work with a predetermined
|
||||
* target class.
|
||||
* <p>Can return {@code null}, although certain usages of a {@code TargetSource}
|
||||
* might just work with a predetermined target class.
|
||||
* @return the type of targets returned by this {@link TargetSource}
|
||||
*/
|
||||
@Override
|
||||
@@ -44,9 +43,8 @@ public interface TargetSource extends TargetClassAware {
|
||||
|
||||
/**
|
||||
* Will all calls to {@link #getTarget()} return the same object?
|
||||
* <p>In that case, there will be no need to invoke
|
||||
* {@link #releaseTarget(Object)}, and the AOP framework can cache
|
||||
* the return value of {@link #getTarget()}.
|
||||
* <p>In that case, there will be no need to invoke {@link #releaseTarget(Object)},
|
||||
* and the AOP framework can cache the return value of {@link #getTarget()}.
|
||||
* @return {@code true} if the target is immutable
|
||||
* @see #getTarget
|
||||
*/
|
||||
@@ -55,14 +53,15 @@ public interface TargetSource extends TargetClassAware {
|
||||
/**
|
||||
* Return a target instance. Invoked immediately before the
|
||||
* AOP framework calls the "target" of an AOP method invocation.
|
||||
* @return the target object, which contains the joinpoint
|
||||
* @return the target object which contains the joinpoint,
|
||||
* or {@code null} if there is no actual target instance
|
||||
* @throws Exception if the target object can't be resolved
|
||||
*/
|
||||
Object getTarget() throws Exception;
|
||||
|
||||
/**
|
||||
* Release the given target object obtained from the
|
||||
* {@link #getTarget()} method.
|
||||
* {@link #getTarget()} method, if any.
|
||||
* @param target object obtained from a call to {@link #getTarget()}
|
||||
* @throws Exception if the object can't be released
|
||||
*/
|
||||
|
||||
+14
-16
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -103,8 +103,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
private final AspectInstanceFactory aspectInstanceFactory;
|
||||
|
||||
/**
|
||||
* The name of the aspect (ref bean) in which this advice was defined (used
|
||||
* when determining advice precedence so that we can determine
|
||||
* The name of the aspect (ref bean) in which this advice was defined
|
||||
* (used when determining advice precedence so that we can determine
|
||||
* whether two pieces of advice come from the same aspect).
|
||||
*/
|
||||
private String aspectName;
|
||||
@@ -118,13 +118,13 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
* This will be non-null if the creator of this advice object knows the argument names
|
||||
* and sets them explicitly
|
||||
*/
|
||||
private String[] argumentNames = null;
|
||||
private String[] argumentNames;
|
||||
|
||||
/** Non-null if after throwing advice binds the thrown value */
|
||||
private String throwingName = null;
|
||||
private String throwingName;
|
||||
|
||||
/** Non-null if after returning advice binds the return value */
|
||||
private String returningName = null;
|
||||
private String returningName;
|
||||
|
||||
private Class<?> discoveredReturningType = Object.class;
|
||||
|
||||
@@ -227,7 +227,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <b>declaration order</b> of this advice within the aspect
|
||||
* Set the declaration order of this advice within the aspect.
|
||||
*/
|
||||
public void setDeclarationOrder(int order) {
|
||||
this.declarationOrder = order;
|
||||
@@ -295,8 +295,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalArgumentException("Returning name '" + name +
|
||||
"' is neither a valid argument name nor the fully-qualified name of a Java type on the classpath. " +
|
||||
"Root cause: " + ex);
|
||||
"' is neither a valid argument name nor the fully-qualified " +
|
||||
"name of a Java type on the classpath. Root cause: " + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -329,8 +329,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
throw new IllegalArgumentException("Throwing name '" + name +
|
||||
"' is neither a valid argument name nor the fully-qualified name of a Java type on the classpath. " +
|
||||
"Root cause: " + ex);
|
||||
"' is neither a valid argument name nor the fully-qualified " +
|
||||
"name of a Java type on the classpath. Root cause: " + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -366,7 +366,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
* to which argument name. There are multiple strategies for determining
|
||||
* this binding, which are arranged in a ChainOfResponsibility.
|
||||
*/
|
||||
public synchronized final void calculateArgumentBindings() {
|
||||
public final synchronized void calculateArgumentBindings() {
|
||||
// The simple case... nothing to bind.
|
||||
if (this.argumentsIntrospected || this.parameterTypes.length == 0) {
|
||||
return;
|
||||
@@ -374,10 +374,8 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
|
||||
|
||||
int numUnboundArgs = this.parameterTypes.length;
|
||||
Class<?>[] parameterTypes = this.aspectJAdviceMethod.getParameterTypes();
|
||||
if (maybeBindJoinPoint(parameterTypes[0]) || maybeBindProceedingJoinPoint(parameterTypes[0])) {
|
||||
numUnboundArgs--;
|
||||
}
|
||||
else if (maybeBindJoinPointStaticPart(parameterTypes[0])) {
|
||||
if (maybeBindJoinPoint(parameterTypes[0]) || maybeBindProceedingJoinPoint(parameterTypes[0]) ||
|
||||
maybeBindJoinPointStaticPart(parameterTypes[0])) {
|
||||
numUnboundArgs--;
|
||||
}
|
||||
|
||||
|
||||
+12
-15
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -113,6 +113,7 @@ import org.springframework.util.StringUtils;
|
||||
* returning {@code null} in the case that the parameter names cannot be discovered.
|
||||
*
|
||||
* @author Adrian Colyer
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.0
|
||||
*/
|
||||
public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscoverer {
|
||||
@@ -154,23 +155,17 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||
}
|
||||
|
||||
|
||||
/** The pointcut expression associated with the advice, as a simple String */
|
||||
private String pointcutExpression;
|
||||
|
||||
private boolean raiseExceptions;
|
||||
|
||||
/**
|
||||
* If the advice is afterReturning, and binds the return value, this is the parameter name used.
|
||||
*/
|
||||
/** If the advice is afterReturning, and binds the return value, this is the parameter name used */
|
||||
private String returningName;
|
||||
|
||||
/**
|
||||
* If the advice is afterThrowing, and binds the thrown value, this is the parameter name used.
|
||||
*/
|
||||
/** If the advice is afterThrowing, and binds the thrown value, this is the parameter name used */
|
||||
private String throwingName;
|
||||
|
||||
/**
|
||||
* The pointcut expression associated with the advice, as a simple String.
|
||||
*/
|
||||
private String pointcutExpression;
|
||||
|
||||
private Class<?>[] argumentTypes;
|
||||
|
||||
private String[] parameterNameBindings;
|
||||
@@ -186,6 +181,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||
this.pointcutExpression = pointcutExpression;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicate whether {@link IllegalArgumentException} and {@link AmbiguousBindingException}
|
||||
* must be thrown as appropriate in the case of failing to deduce advice parameter names.
|
||||
@@ -213,6 +209,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||
this.throwingName = throwingName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deduce the parameter names for an advice method.
|
||||
* <p>See the {@link AspectJAdviceParameterNameDiscoverer class level javadoc}
|
||||
@@ -418,7 +415,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||
String[] tokens = StringUtils.tokenizeToStringArray(this.pointcutExpression, " ");
|
||||
for (int i = 0; i < tokens.length; i++) {
|
||||
String toMatch = tokens[i];
|
||||
int firstParenIndex = toMatch.indexOf("(");
|
||||
int firstParenIndex = toMatch.indexOf('(');
|
||||
if (firstParenIndex != -1) {
|
||||
toMatch = toMatch.substring(0, firstParenIndex);
|
||||
}
|
||||
@@ -474,7 +471,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||
* If the token starts meets Java identifier conventions, it's in.
|
||||
*/
|
||||
private String maybeExtractVariableName(String candidateToken) {
|
||||
if (candidateToken == null || candidateToken.equals("")) {
|
||||
if (!StringUtils.hasLength(candidateToken)) {
|
||||
return null;
|
||||
}
|
||||
if (Character.isJavaIdentifierStart(candidateToken.charAt(0)) &&
|
||||
@@ -578,7 +575,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
|
||||
if (toMatch.startsWith("!")) {
|
||||
toMatch = toMatch.substring(1);
|
||||
}
|
||||
int firstParenIndex = toMatch.indexOf("(");
|
||||
int firstParenIndex = toMatch.indexOf('(');
|
||||
if (firstParenIndex != -1) {
|
||||
toMatch = toMatch.substring(0, firstParenIndex);
|
||||
}
|
||||
|
||||
+4
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,7 +22,6 @@ import org.springframework.aop.Pointcut;
|
||||
import org.springframework.aop.PointcutAdvisor;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* AspectJPointcutAdvisor that adapts an {@link AbstractAspectJAdvice}
|
||||
@@ -51,11 +50,11 @@ public class AspectJPointcutAdvisor implements PointcutAdvisor, Ordered {
|
||||
this.pointcut = advice.buildSafePointcut();
|
||||
}
|
||||
|
||||
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isPerInstance() {
|
||||
return true;
|
||||
@@ -91,12 +90,12 @@ public class AspectJPointcutAdvisor implements PointcutAdvisor, Ordered {
|
||||
return false;
|
||||
}
|
||||
AspectJPointcutAdvisor otherAdvisor = (AspectJPointcutAdvisor) other;
|
||||
return (ObjectUtils.nullSafeEquals(this.advice, otherAdvisor.advice));
|
||||
return this.advice.equals(otherAdvisor.advice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return AspectJPointcutAdvisor.class.hashCode();
|
||||
return AspectJPointcutAdvisor.class.hashCode() * 29 + this.advice.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+12
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 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,6 +20,7 @@ import org.aopalliance.aop.Advice;
|
||||
|
||||
import org.springframework.aop.ClassFilter;
|
||||
import org.springframework.aop.IntroductionAdvisor;
|
||||
import org.springframework.aop.IntroductionInterceptor;
|
||||
import org.springframework.aop.support.ClassFilters;
|
||||
import org.springframework.aop.support.DelegatePerTargetObjectIntroductionInterceptor;
|
||||
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
|
||||
@@ -34,12 +35,12 @@ import org.springframework.aop.support.DelegatingIntroductionInterceptor;
|
||||
*/
|
||||
public class DeclareParentsAdvisor implements IntroductionAdvisor {
|
||||
|
||||
private final Advice advice;
|
||||
|
||||
private final Class<?> introducedInterface;
|
||||
|
||||
private final ClassFilter typePatternClassFilter;
|
||||
|
||||
private final Advice advice;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new advisor for this DeclareParents field.
|
||||
@@ -48,8 +49,8 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
|
||||
* @param defaultImpl the default implementation class
|
||||
*/
|
||||
public DeclareParentsAdvisor(Class<?> interfaceType, String typePattern, Class<?> defaultImpl) {
|
||||
this(interfaceType, typePattern, defaultImpl,
|
||||
new DelegatePerTargetObjectIntroductionInterceptor(defaultImpl, interfaceType));
|
||||
this(interfaceType, typePattern,
|
||||
new DelegatePerTargetObjectIntroductionInterceptor(defaultImpl, interfaceType));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,8 +60,7 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
|
||||
* @param delegateRef the delegate implementation object
|
||||
*/
|
||||
public DeclareParentsAdvisor(Class<?> interfaceType, String typePattern, Object delegateRef) {
|
||||
this(interfaceType, typePattern, delegateRef.getClass(),
|
||||
new DelegatingIntroductionInterceptor(delegateRef));
|
||||
this(interfaceType, typePattern, new DelegatingIntroductionInterceptor(delegateRef));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,23 +68,21 @@ public class DeclareParentsAdvisor implements IntroductionAdvisor {
|
||||
* (cannot use method such as init() to share common code, due the use of final fields)
|
||||
* @param interfaceType static field defining the introduction
|
||||
* @param typePattern type pattern the introduction is restricted to
|
||||
* @param implementationClass implementation class
|
||||
* @param advice delegation advice
|
||||
* @param interceptor the delegation advice as {@link IntroductionInterceptor}
|
||||
*/
|
||||
private DeclareParentsAdvisor(Class<?> interfaceType, String typePattern, Class<?> implementationClass, Advice advice) {
|
||||
private DeclareParentsAdvisor(Class<?> interfaceType, String typePattern, IntroductionInterceptor interceptor) {
|
||||
this.advice = interceptor;
|
||||
this.introducedInterface = interfaceType;
|
||||
ClassFilter typePatternFilter = new TypePatternClassFilter(typePattern);
|
||||
|
||||
// Excludes methods implemented.
|
||||
ClassFilter typePatternFilter = new TypePatternClassFilter(typePattern);
|
||||
ClassFilter exclusion = new ClassFilter() {
|
||||
@Override
|
||||
public boolean matches(Class<?> clazz) {
|
||||
return !(introducedInterface.isAssignableFrom(clazz));
|
||||
return !introducedInterface.isAssignableFrom(clazz);
|
||||
}
|
||||
};
|
||||
|
||||
this.typePatternClassFilter = ClassFilters.intersection(typePatternFilter, exclusion);
|
||||
this.advice = advice;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+14
-17
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -32,17 +32,15 @@ import org.springframework.core.ParameterNameDiscoverer;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Implementation of AspectJ ProceedingJoinPoint interface
|
||||
* wrapping an AOP Alliance MethodInvocation.
|
||||
* An implementation of the AspectJ {@link ProceedingJoinPoint} interface
|
||||
* wrapping an AOP Alliance {@link org.aopalliance.intercept.MethodInvocation}.
|
||||
*
|
||||
* <p><b>Note</b>: the {@code getThis()} method returns the current Spring AOP proxy.
|
||||
* <p><b>Note</b>: The {@code getThis()} method returns the current Spring AOP proxy.
|
||||
* The {@code getTarget()} method returns the current Spring AOP target (which may be
|
||||
* {@code null} if there is no target), and is a plain POJO without any advice.
|
||||
* <b>If you want to call the object and have the advice take effect, use
|
||||
* {@code getThis()}.</b> A common example is casting the object to an
|
||||
* introduced interface in the implementation of an introduction.
|
||||
*
|
||||
* <p>Of course there is no such distinction between target and proxy in AspectJ.
|
||||
* {@code null} if there is no target instance) as a plain POJO without any advice.
|
||||
* <b>If you want to call the object and have the advice take effect, use {@code getThis()}.</b>
|
||||
* A common example is casting the object to an introduced interface in the implementation of
|
||||
* an introduction. There is no such distinction between target and proxy in AspectJ itself.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
@@ -56,7 +54,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||
|
||||
private final ProxyMethodInvocation methodInvocation;
|
||||
|
||||
private Object[] defensiveCopyOfArgs;
|
||||
private Object[] args;
|
||||
|
||||
/** Lazily initialized signature object */
|
||||
private Signature signature;
|
||||
@@ -75,6 +73,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||
this.methodInvocation = methodInvocation;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void set$AroundClosure(AroundClosure aroundClosure) {
|
||||
throw new UnsupportedOperationException();
|
||||
@@ -115,12 +114,10 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||
|
||||
@Override
|
||||
public Object[] getArgs() {
|
||||
if (this.defensiveCopyOfArgs == null) {
|
||||
Object[] argsSource = this.methodInvocation.getArguments();
|
||||
this.defensiveCopyOfArgs = new Object[argsSource.length];
|
||||
System.arraycopy(argsSource, 0, this.defensiveCopyOfArgs, 0, argsSource.length);
|
||||
if (this.args == null) {
|
||||
this.args = this.methodInvocation.getArguments().clone();
|
||||
}
|
||||
return this.defensiveCopyOfArgs;
|
||||
return this.args;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,7 +125,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||
if (this.signature == null) {
|
||||
this.signature = new MethodSignatureImpl();
|
||||
}
|
||||
return signature;
|
||||
return this.signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -41,6 +41,7 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
|
||||
this.aspectClass = aspectClass;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the specified aspect class (never {@code null}).
|
||||
*/
|
||||
@@ -48,7 +49,6 @@ public class SimpleAspectInstanceFactory implements AspectInstanceFactory {
|
||||
return this.aspectClass;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final Object getAspectInstance() {
|
||||
try {
|
||||
|
||||
+37
-50
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -59,6 +59,9 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||
|
||||
private static final String AJC_MAGIC = "ajc$";
|
||||
|
||||
private static final Class<?>[] ASPECTJ_ANNOTATION_CLASSES = new Class<?>[] {
|
||||
Pointcut.class, Around.class, Before.class, After.class, AfterReturning.class, AfterThrowing.class};
|
||||
|
||||
|
||||
/** Logger available to subclasses */
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
@@ -122,14 +125,12 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||
|
||||
/**
|
||||
* Find and return the first AspectJ annotation on the given method
|
||||
* (there <i>should</i> only be one anyway...)
|
||||
* (there <i>should</i> only be one anyway...).
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected static AspectJAnnotation<?> findAspectJAnnotationOnMethod(Method method) {
|
||||
Class<?>[] classesToLookFor = new Class<?>[] {
|
||||
Before.class, Around.class, After.class, AfterReturning.class, AfterThrowing.class, Pointcut.class};
|
||||
for (Class<?> c : classesToLookFor) {
|
||||
AspectJAnnotation<?> foundAnnotation = findAnnotation(method, (Class<Annotation>) c);
|
||||
for (Class<?> clazz : ASPECTJ_ANNOTATION_CLASSES) {
|
||||
AspectJAnnotation<?> foundAnnotation = findAnnotation(method, (Class<Annotation>) clazz);
|
||||
if (foundAnnotation != null) {
|
||||
return foundAnnotation;
|
||||
}
|
||||
@@ -148,14 +149,13 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enum for AspectJ annotation types.
|
||||
* @see AspectJAnnotation#getAnnotationType()
|
||||
*/
|
||||
protected enum AspectJAnnotationType {
|
||||
|
||||
AtPointcut,
|
||||
AtBefore,
|
||||
AtAfter,
|
||||
AtAfterReturning,
|
||||
AtAfterThrowing,
|
||||
AtAround
|
||||
AtPointcut, AtAround, AtBefore, AtAfter, AtAfterReturning, AtAfterThrowing
|
||||
}
|
||||
|
||||
|
||||
@@ -165,18 +165,18 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||
*/
|
||||
protected static class AspectJAnnotation<A extends Annotation> {
|
||||
|
||||
private static final String[] EXPRESSION_PROPERTIES = new String[] {"value", "pointcut"};
|
||||
private static final String[] EXPRESSION_ATTRIBUTES = new String[] {"pointcut", "value"};
|
||||
|
||||
private static Map<Class<?>, AspectJAnnotationType> annotationTypes =
|
||||
new HashMap<Class<?>, AspectJAnnotationType>();
|
||||
private static Map<Class<?>, AspectJAnnotationType> annotationTypeMap =
|
||||
new HashMap<Class<?>, AspectJAnnotationType>(8);
|
||||
|
||||
static {
|
||||
annotationTypes.put(Pointcut.class,AspectJAnnotationType.AtPointcut);
|
||||
annotationTypes.put(After.class,AspectJAnnotationType.AtAfter);
|
||||
annotationTypes.put(AfterReturning.class,AspectJAnnotationType.AtAfterReturning);
|
||||
annotationTypes.put(AfterThrowing.class,AspectJAnnotationType.AtAfterThrowing);
|
||||
annotationTypes.put(Around.class,AspectJAnnotationType.AtAround);
|
||||
annotationTypes.put(Before.class,AspectJAnnotationType.AtBefore);
|
||||
annotationTypeMap.put(Pointcut.class, AspectJAnnotationType.AtPointcut);
|
||||
annotationTypeMap.put(Around.class, AspectJAnnotationType.AtAround);
|
||||
annotationTypeMap.put(Before.class, AspectJAnnotationType.AtBefore);
|
||||
annotationTypeMap.put(After.class, AspectJAnnotationType.AtAfter);
|
||||
annotationTypeMap.put(AfterReturning.class, AspectJAnnotationType.AtAfterReturning);
|
||||
annotationTypeMap.put(AfterThrowing.class, AspectJAnnotationType.AtAfterThrowing);
|
||||
}
|
||||
|
||||
private final A annotation;
|
||||
@@ -190,44 +190,31 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||
public AspectJAnnotation(A annotation) {
|
||||
this.annotation = annotation;
|
||||
this.annotationType = determineAnnotationType(annotation);
|
||||
// We know these methods exist with the same name on each object,
|
||||
// but need to invoke them reflectively as there isn't a common interface.
|
||||
try {
|
||||
this.pointcutExpression = resolveExpression(annotation);
|
||||
this.argumentNames = (String) annotation.getClass().getMethod("argNames").invoke(annotation);
|
||||
this.argumentNames = (String) AnnotationUtils.getValue(annotation, "argNames");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalArgumentException(annotation + " cannot be an AspectJ annotation", ex);
|
||||
throw new IllegalArgumentException(annotation + " is not a valid AspectJ annotation", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private AspectJAnnotationType determineAnnotationType(A annotation) {
|
||||
for (Class<?> type : annotationTypes.keySet()) {
|
||||
if (type.isInstance(annotation)) {
|
||||
return annotationTypes.get(type);
|
||||
}
|
||||
AspectJAnnotationType type = annotationTypeMap.get(annotation.annotationType());
|
||||
if (type != null) {
|
||||
return type;
|
||||
}
|
||||
throw new IllegalStateException("Unknown annotation type: " + annotation.toString());
|
||||
throw new IllegalStateException("Unknown annotation type: " + annotation);
|
||||
}
|
||||
|
||||
private String resolveExpression(A annotation) throws Exception {
|
||||
String expression = null;
|
||||
for (String methodName : EXPRESSION_PROPERTIES) {
|
||||
Method method;
|
||||
try {
|
||||
method = annotation.getClass().getDeclaredMethod(methodName);
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
method = null;
|
||||
}
|
||||
if (method != null) {
|
||||
String candidate = (String) method.invoke(annotation);
|
||||
if (StringUtils.hasText(candidate)) {
|
||||
expression = candidate;
|
||||
}
|
||||
private String resolveExpression(A annotation) {
|
||||
for (String attributeName : EXPRESSION_ATTRIBUTES) {
|
||||
String candidate = (String) AnnotationUtils.getValue(annotation, attributeName);
|
||||
if (StringUtils.hasText(candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return expression;
|
||||
throw new IllegalStateException("Failed to resolve expression: " + annotation);
|
||||
}
|
||||
|
||||
public AspectJAnnotationType getAnnotationType() {
|
||||
@@ -268,11 +255,11 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac
|
||||
if (annotation == null) {
|
||||
return null;
|
||||
}
|
||||
StringTokenizer strTok = new StringTokenizer(annotation.getArgumentNames(), ",");
|
||||
if (strTok.countTokens() > 0) {
|
||||
String[] names = new String[strTok.countTokens()];
|
||||
StringTokenizer nameTokens = new StringTokenizer(annotation.getArgumentNames(), ",");
|
||||
if (nameTokens.countTokens() > 0) {
|
||||
String[] names = new String[nameTokens.countTokens()];
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
names[i] = strTok.nextToken();
|
||||
names[i] = nameTokens.nextToken();
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
+14
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -168,19 +168,19 @@ public class AspectJProxyFactory extends ProxyCreatorSupport {
|
||||
synchronized (aspectCache) {
|
||||
// To be safe, check within full lock now...
|
||||
instance = aspectCache.get(aspectClass);
|
||||
if (instance != null) {
|
||||
return instance;
|
||||
}
|
||||
try {
|
||||
instance = aspectClass.newInstance();
|
||||
aspectCache.put(aspectClass, instance);
|
||||
return instance;
|
||||
}
|
||||
catch (InstantiationException ex) {
|
||||
throw new AopConfigException("Unable to instantiate aspect class [" + aspectClass.getName() + "]", ex);
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
throw new AopConfigException("Cannot access aspect class [" + aspectClass.getName() + "]", ex);
|
||||
if (instance == null) {
|
||||
try {
|
||||
instance = aspectClass.newInstance();
|
||||
aspectCache.put(aspectClass, instance);
|
||||
}
|
||||
catch (InstantiationException ex) {
|
||||
throw new AopConfigException(
|
||||
"Unable to instantiate aspect class: " + aspectClass.getName(), ex);
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
throw new AopConfigException(
|
||||
"Could not access aspect constructor: " + aspectClass.getName(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -127,7 +127,7 @@ public class AspectMetadata implements Serializable {
|
||||
*/
|
||||
private String findPerClause(Class<?> aspectClass) {
|
||||
String str = aspectClass.getAnnotation(Aspect.class).value();
|
||||
str = str.substring(str.indexOf("(") + 1);
|
||||
str = str.substring(str.indexOf('(') + 1);
|
||||
str = str.substring(0, str.length() - 1);
|
||||
return str;
|
||||
}
|
||||
@@ -148,7 +148,7 @@ public class AspectMetadata implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the aspect class.
|
||||
* Return the aspect name.
|
||||
*/
|
||||
public String getAspectName() {
|
||||
return this.aspectName;
|
||||
|
||||
+52
-51
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -109,14 +109,40 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||
|
||||
|
||||
/**
|
||||
* The pointcut for Spring AOP to use. Actual behaviour of the pointcut will change
|
||||
* depending on the state of the advice.
|
||||
* The pointcut for Spring AOP to use.
|
||||
* Actual behaviour of the pointcut will change depending on the state of the advice.
|
||||
*/
|
||||
@Override
|
||||
public Pointcut getPointcut() {
|
||||
return this.pointcut;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLazy() {
|
||||
return this.lazy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isAdviceInstantiated() {
|
||||
return (this.instantiatedAdvice != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazily instantiate advice if necessary.
|
||||
*/
|
||||
@Override
|
||||
public synchronized Advice getAdvice() {
|
||||
if (this.instantiatedAdvice == null) {
|
||||
this.instantiatedAdvice = instantiateAdvice(this.declaredPointcut);
|
||||
}
|
||||
return this.instantiatedAdvice;
|
||||
}
|
||||
|
||||
private Advice instantiateAdvice(AspectJExpressionPointcut pcut) {
|
||||
return this.aspectJAdvisorFactory.getAdvice(this.aspectJAdviceMethod, pcut,
|
||||
this.aspectInstanceFactory, this.declarationOrder, this.aspectName);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is only of interest for Spring AOP: AspectJ instantiation semantics
|
||||
* are much richer. In AspectJ terminology, all a return of {@code true}
|
||||
@@ -134,33 +160,6 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||
return this.aspectInstanceFactory.getAspectMetadata();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazily instantiate advice if necessary.
|
||||
*/
|
||||
@Override
|
||||
public synchronized Advice getAdvice() {
|
||||
if (this.instantiatedAdvice == null) {
|
||||
this.instantiatedAdvice = instantiateAdvice(this.declaredPointcut);
|
||||
}
|
||||
return this.instantiatedAdvice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLazy() {
|
||||
return this.lazy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isAdviceInstantiated() {
|
||||
return (this.instantiatedAdvice != null);
|
||||
}
|
||||
|
||||
|
||||
private Advice instantiateAdvice(AspectJExpressionPointcut pcut) {
|
||||
return this.aspectJAdvisorFactory.getAdvice(this.aspectJAdviceMethod, pcut,
|
||||
this.aspectInstanceFactory, this.declarationOrder, this.aspectName);
|
||||
}
|
||||
|
||||
public MetadataAwareAspectInstanceFactory getAspectInstanceFactory() {
|
||||
return this.aspectInstanceFactory;
|
||||
}
|
||||
@@ -213,33 +212,26 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||
}
|
||||
else {
|
||||
switch (aspectJAnnotation.getAnnotationType()) {
|
||||
case AtPointcut:
|
||||
case AtAround:
|
||||
this.isBeforeAdvice = false;
|
||||
this.isAfterAdvice = false;
|
||||
break;
|
||||
case AtBefore:
|
||||
this.isBeforeAdvice = true;
|
||||
this.isAfterAdvice = false;
|
||||
break;
|
||||
case AtAfter:
|
||||
case AtAfterReturning:
|
||||
case AtAfterThrowing:
|
||||
this.isBeforeAdvice = false;
|
||||
this.isAfterAdvice = true;
|
||||
this.isBeforeAdvice = false;
|
||||
break;
|
||||
case AtAround:
|
||||
case AtPointcut:
|
||||
this.isAfterAdvice = false;
|
||||
this.isBeforeAdvice = false;
|
||||
break;
|
||||
case AtBefore:
|
||||
this.isAfterAdvice = false;
|
||||
this.isBeforeAdvice = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InstantiationModelAwarePointcutAdvisor: expression [" + getDeclaredPointcut().getExpression() +
|
||||
"]; advice method [" + this.aspectJAdviceMethod + "]; perClauseKind=" +
|
||||
this.aspectInstanceFactory.getAspectMetadata().getAjType().getPerClause().getKind();
|
||||
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream inputStream) throws IOException, ClassNotFoundException {
|
||||
inputStream.defaultReadObject();
|
||||
try {
|
||||
@@ -250,11 +242,18 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InstantiationModelAwarePointcutAdvisor: expression [" + getDeclaredPointcut().getExpression() +
|
||||
"]; advice method [" + this.aspectJAdviceMethod + "]; perClauseKind=" +
|
||||
this.aspectInstanceFactory.getAspectMetadata().getAjType().getPerClause().getKind();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pointcut implementation that changes its behaviour when the advice is instantiated.
|
||||
* Note that this is a <i>dynamic</i> pointcut. Otherwise it might
|
||||
* be optimized out if it does not at first match statically.
|
||||
* Note that this is a <i>dynamic</i> pointcut; otherwise it might be optimized out
|
||||
* if it does not at first match statically.
|
||||
*/
|
||||
private class PerTargetInstantiationModelPointcut extends DynamicMethodMatcherPointcut {
|
||||
|
||||
@@ -264,8 +263,9 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||
|
||||
private LazySingletonAspectInstanceFactoryDecorator aspectInstanceFactory;
|
||||
|
||||
private PerTargetInstantiationModelPointcut(AspectJExpressionPointcut declaredPointcut,
|
||||
public PerTargetInstantiationModelPointcut(AspectJExpressionPointcut declaredPointcut,
|
||||
Pointcut preInstantiationPointcut, MetadataAwareAspectInstanceFactory aspectInstanceFactory) {
|
||||
|
||||
this.declaredPointcut = declaredPointcut;
|
||||
this.preInstantiationPointcut = preInstantiationPointcut;
|
||||
if (aspectInstanceFactory instanceof LazySingletonAspectInstanceFactoryDecorator) {
|
||||
@@ -275,7 +275,8 @@ class InstantiationModelAwarePointcutAdvisorImpl
|
||||
|
||||
@Override
|
||||
public boolean matches(Method method, Class<?> targetClass) {
|
||||
// We're either instantiated and matching on declared pointcut, or uninstantiated matching on either pointcut
|
||||
// We're either instantiated and matching on declared pointcut,
|
||||
// or uninstantiated matching on either pointcut...
|
||||
return (isAspectMaterialized() && this.declaredPointcut.matches(method, targetClass)) ||
|
||||
this.preInstantiationPointcut.getMethodMatcher().matches(method, targetClass);
|
||||
}
|
||||
|
||||
+15
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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,9 +20,9 @@ import java.io.Serializable;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.aopalliance.aop.Advice;
|
||||
@@ -131,7 +131,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||
MetadataAwareAspectInstanceFactory lazySingletonAspectInstanceFactory =
|
||||
new LazySingletonAspectInstanceFactoryDecorator(aspectInstanceFactory);
|
||||
|
||||
List<Advisor> advisors = new LinkedList<Advisor>();
|
||||
List<Advisor> advisors = new ArrayList<Advisor>();
|
||||
for (Method method : getAdvisorMethods(aspectClass)) {
|
||||
Advisor advisor = getAdvisor(method, lazySingletonAspectInstanceFactory, advisors.size(), aspectName);
|
||||
if (advisor != null) {
|
||||
@@ -157,7 +157,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||
}
|
||||
|
||||
private List<Method> getAdvisorMethods(Class<?> aspectClass) {
|
||||
final List<Method> methods = new LinkedList<Method>();
|
||||
final List<Method> methods = new ArrayList<Method>();
|
||||
ReflectionUtils.doWithMethods(aspectClass, new ReflectionUtils.MethodCallback() {
|
||||
@Override
|
||||
public void doWith(Method method) throws IllegalArgumentException {
|
||||
@@ -176,7 +176,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||
* for the given introduction field.
|
||||
* <p>Resulting Advisors will need to be evaluated for targets.
|
||||
* @param introductionField the field to introspect
|
||||
* @return {@code null} if not an Advisor
|
||||
* @return the Advisor instance, or {@code null} if not an Advisor
|
||||
*/
|
||||
private Advisor getDeclareParentsAdvisor(Field introductionField) {
|
||||
DeclareParents declareParents = introductionField.getAnnotation(DeclareParents.class);
|
||||
@@ -253,6 +253,15 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||
AbstractAspectJAdvice springAdvice;
|
||||
|
||||
switch (aspectJAnnotation.getAnnotationType()) {
|
||||
case AtPointcut:
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Processing pointcut '" + candidateAdviceMethod.getName() + "'");
|
||||
}
|
||||
return null;
|
||||
case AtAround:
|
||||
springAdvice = new AspectJAroundAdvice(
|
||||
candidateAdviceMethod, expressionPointcut, aspectInstanceFactory);
|
||||
break;
|
||||
case AtBefore:
|
||||
springAdvice = new AspectJMethodBeforeAdvice(
|
||||
candidateAdviceMethod, expressionPointcut, aspectInstanceFactory);
|
||||
@@ -277,15 +286,6 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||
springAdvice.setThrowingName(afterThrowingAnnotation.throwing());
|
||||
}
|
||||
break;
|
||||
case AtAround:
|
||||
springAdvice = new AspectJAroundAdvice(
|
||||
candidateAdviceMethod, expressionPointcut, aspectInstanceFactory);
|
||||
break;
|
||||
case AtPointcut:
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Processing pointcut '" + candidateAdviceMethod.getName() + "'");
|
||||
}
|
||||
return null;
|
||||
default:
|
||||
throw new UnsupportedOperationException(
|
||||
"Unsupported advice type on method: " + candidateAdviceMethod);
|
||||
@@ -299,6 +299,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
|
||||
springAdvice.setArgumentNamesFromStringArray(argNames);
|
||||
}
|
||||
springAdvice.calculateArgumentBindings();
|
||||
|
||||
return springAdvice;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,11 +31,10 @@ import org.springframework.util.Assert;
|
||||
/**
|
||||
* Utility class for handling registration of AOP auto-proxy creators.
|
||||
*
|
||||
* <p>Only a single auto-proxy creator can be registered yet multiple concrete
|
||||
* implementations are available. Therefore this class wraps a simple escalation
|
||||
* protocol, allowing classes to request a particular auto-proxy creator and know
|
||||
* that class, {@code or a subclass thereof}, will eventually be resident
|
||||
* in the application context.
|
||||
* <p>Only a single auto-proxy creator should be registered yet multiple concrete
|
||||
* implementations are available. This class provides a simple escalation protocol,
|
||||
* allowing a caller to request a particular auto-proxy creator and know that creator,
|
||||
* <i>or a more capable variant thereof</i>, will be registered as a post-processor.
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
@@ -54,12 +53,10 @@ public abstract class AopConfigUtils {
|
||||
/**
|
||||
* Stores the auto proxy creator classes in escalation order.
|
||||
*/
|
||||
private static final List<Class<?>> APC_PRIORITY_LIST = new ArrayList<Class<?>>();
|
||||
private static final List<Class<?>> APC_PRIORITY_LIST = new ArrayList<Class<?>>(3);
|
||||
|
||||
/**
|
||||
* Setup the escalation list.
|
||||
*/
|
||||
static {
|
||||
// Set up the escalation list...
|
||||
APC_PRIORITY_LIST.add(InfrastructureAdvisorAutoProxyCreator.class);
|
||||
APC_PRIORITY_LIST.add(AspectJAwareAdvisorAutoProxyCreator.class);
|
||||
APC_PRIORITY_LIST.add(AnnotationAwareAspectJAutoProxyCreator.class);
|
||||
@@ -107,6 +104,7 @@ public abstract class AopConfigUtils {
|
||||
|
||||
private static BeanDefinition registerOrEscalateApcAsRequired(Class<?> cls, BeanDefinitionRegistry registry, Object source) {
|
||||
Assert.notNull(registry, "BeanDefinitionRegistry must not be null");
|
||||
|
||||
if (registry.containsBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME)) {
|
||||
BeanDefinition apcDefinition = registry.getBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME);
|
||||
if (!cls.getName().equals(apcDefinition.getBeanClassName())) {
|
||||
@@ -118,6 +116,7 @@ public abstract class AopConfigUtils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
RootBeanDefinition beanDefinition = new RootBeanDefinition(cls);
|
||||
beanDefinition.setSource(source);
|
||||
beanDefinition.getPropertyValues().add("order", Ordered.HIGHEST_PRECEDENCE);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -27,11 +27,11 @@ import org.springframework.beans.factory.xml.ParserContext;
|
||||
* Utility class for handling registration of auto-proxy creators used internally
|
||||
* by the '{@code aop}' namespace tags.
|
||||
*
|
||||
* <p>Only a single auto-proxy creator can be registered and multiple tags may wish
|
||||
* to register different concrete implementations. As such this class delegates to
|
||||
* {@link AopConfigUtils} which wraps a simple escalation protocol. Therefore classes
|
||||
* may request a particular auto-proxy creator and know that class, <i>or a subclass
|
||||
* thereof</i>, will eventually be resident in the application context.
|
||||
* <p>Only a single auto-proxy creator should be registered and multiple configuration
|
||||
* elements may wish to register different concrete implementations. As such this class
|
||||
* delegates to {@link AopConfigUtils} which provides a simple escalation protocol.
|
||||
* Callers may request a particular auto-proxy creator and know that creator,
|
||||
* <i>or a more capable variant thereof</i>, will be registered as a post-processor.
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
@@ -81,11 +81,11 @@ public abstract class AopNamespaceUtils {
|
||||
|
||||
private static void useClassProxyingIfNecessary(BeanDefinitionRegistry registry, Element sourceElement) {
|
||||
if (sourceElement != null) {
|
||||
boolean proxyTargetClass = Boolean.valueOf(sourceElement.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE));
|
||||
boolean proxyTargetClass = Boolean.parseBoolean(sourceElement.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE));
|
||||
if (proxyTargetClass) {
|
||||
AopConfigUtils.forceAutoProxyCreatorToUseClassProxying(registry);
|
||||
}
|
||||
boolean exposeProxy = Boolean.valueOf(sourceElement.getAttribute(EXPOSE_PROXY_ATTRIBUTE));
|
||||
boolean exposeProxy = Boolean.parseBoolean(sourceElement.getAttribute(EXPOSE_PROXY_ATTRIBUTE));
|
||||
if (exposeProxy) {
|
||||
AopConfigUtils.forceAutoProxyCreatorToExposeProxy(registry);
|
||||
}
|
||||
@@ -94,9 +94,8 @@ public abstract class AopNamespaceUtils {
|
||||
|
||||
private static void registerComponentIfNecessary(BeanDefinition beanDefinition, ParserContext parserContext) {
|
||||
if (beanDefinition != null) {
|
||||
BeanComponentDefinition componentDefinition =
|
||||
new BeanComponentDefinition(beanDefinition, AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
|
||||
parserContext.registerComponent(componentDefinition);
|
||||
parserContext.registerComponent(
|
||||
new BeanComponentDefinition(beanDefinition, AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,8 +21,8 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Implementation of {@link AspectInstanceFactory} that locates the aspect from the
|
||||
@@ -50,9 +50,7 @@ public class SimpleBeanFactoryAwareAspectInstanceFactory implements AspectInstan
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
this.beanFactory = beanFactory;
|
||||
if (!StringUtils.hasText(this.aspectBeanName)) {
|
||||
throw new IllegalArgumentException("'aspectBeanName' is required");
|
||||
}
|
||||
Assert.notNull(this.aspectBeanName, "'aspectBeanName' is required");
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -90,7 +90,7 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyProcessorSu
|
||||
return proxyFactory.getProxy(getProxyClassLoader());
|
||||
}
|
||||
|
||||
// No async proxy needed.
|
||||
// No proxy needed.
|
||||
return bean;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyProcessorSu
|
||||
* Subclasses may choose to implement this: for example,
|
||||
* to change the interfaces exposed.
|
||||
* <p>The default implementation is empty.
|
||||
* @param proxyFactory ProxyFactory that is already configured with
|
||||
* @param proxyFactory the ProxyFactory that is already configured with
|
||||
* target, advisor and interfaces and will be used to create the proxy
|
||||
* immediately after this method returns
|
||||
* @since 4.2.3
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,7 +22,6 @@ import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -93,7 +92,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||
* List of Advisors. If an Advice is added, it will be wrapped
|
||||
* in an Advisor before being added to this List.
|
||||
*/
|
||||
private List<Advisor> advisors = new LinkedList<Advisor>();
|
||||
private List<Advisor> advisors = new ArrayList<Advisor>();
|
||||
|
||||
/**
|
||||
* Array updated on changes to the advisors list, which is easier
|
||||
@@ -234,7 +233,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||
|
||||
@Override
|
||||
public Class<?>[] getProxiedInterfaces() {
|
||||
return this.interfaces.toArray(new Class<?>[this.interfaces.size()]);
|
||||
return ClassUtils.toClassArray(this.interfaces);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -480,7 +479,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||
* for the given method, based on this configuration.
|
||||
* @param method the proxied method
|
||||
* @param targetClass the target class
|
||||
* @return List of MethodInterceptors (may also include InterceptorAndDynamicMethodMatchers)
|
||||
* @return a List of MethodInterceptors (may also include InterceptorAndDynamicMethodMatchers)
|
||||
*/
|
||||
public List<Object> getInterceptorsAndDynamicInterceptionAdvice(Method method, Class<?> targetClass) {
|
||||
MethodCacheKey cacheKey = new MethodCacheKey(method);
|
||||
@@ -534,7 +533,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||
|
||||
/**
|
||||
* Build a configuration-only copy of this AdvisedSupport,
|
||||
* replacing the TargetSource
|
||||
* replacing the TargetSource.
|
||||
*/
|
||||
AdvisedSupport getConfigurationOnlyCopy() {
|
||||
AdvisedSupport copy = new AdvisedSupport();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -201,15 +201,13 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||
return createProxyClassAndInstance(enhancer, callbacks);
|
||||
}
|
||||
catch (CodeGenerationException ex) {
|
||||
throw new AopConfigException("Could not generate CGLIB subclass of class [" +
|
||||
this.advised.getTargetClass() + "]: " +
|
||||
"Common causes of this problem include using a final class or a non-visible class",
|
||||
throw new AopConfigException("Could not generate CGLIB subclass of " + this.advised.getTargetClass() +
|
||||
": Common causes of this problem include using a final class or a non-visible class",
|
||||
ex);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
throw new AopConfigException("Could not generate CGLIB subclass of class [" +
|
||||
this.advised.getTargetClass() + "]: " +
|
||||
"Common causes of this problem include using a final class or a non-visible class",
|
||||
throw new AopConfigException("Could not generate CGLIB subclass of " + this.advised.getTargetClass() +
|
||||
": Common causes of this problem include using a final class or a non-visible class",
|
||||
ex);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
@@ -259,7 +257,7 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||
Method[] methods = proxySuperClass.getDeclaredMethods();
|
||||
for (Method method : methods) {
|
||||
int mod = method.getModifiers();
|
||||
if (!Modifier.isStatic(mod)) {
|
||||
if (!Modifier.isStatic(mod) && !Modifier.isPrivate(mod)) {
|
||||
if (Modifier.isFinal(mod)) {
|
||||
if (implementsInterface(method, ifcs)) {
|
||||
logger.warn("Unable to proxy interface-implementing method [" + method + "] because " +
|
||||
@@ -269,7 +267,7 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||
"Calls to this method will NOT be routed to the target instance and " +
|
||||
"might lead to NPEs against uninitialized fields in the proxy instance.");
|
||||
}
|
||||
else if (!Modifier.isPublic(mod) && !Modifier.isProtected(mod) && !Modifier.isPrivate(mod) &&
|
||||
else if (!Modifier.isPublic(mod) && !Modifier.isProtected(mod) &&
|
||||
proxyClassLoader != null && proxySuperClass.getClassLoader() != proxyClassLoader) {
|
||||
logger.info("Method [" + method + "] is package-visible across different ClassLoaders " +
|
||||
"and cannot get proxied via CGLIB: Declare this method as public or protected " +
|
||||
@@ -294,20 +292,20 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||
// unadvised but can return this). May be required to expose the proxy.
|
||||
Callback targetInterceptor;
|
||||
if (exposeProxy) {
|
||||
targetInterceptor = isStatic ?
|
||||
targetInterceptor = (isStatic ?
|
||||
new StaticUnadvisedExposedInterceptor(this.advised.getTargetSource().getTarget()) :
|
||||
new DynamicUnadvisedExposedInterceptor(this.advised.getTargetSource());
|
||||
new DynamicUnadvisedExposedInterceptor(this.advised.getTargetSource()));
|
||||
}
|
||||
else {
|
||||
targetInterceptor = isStatic ?
|
||||
targetInterceptor = (isStatic ?
|
||||
new StaticUnadvisedInterceptor(this.advised.getTargetSource().getTarget()) :
|
||||
new DynamicUnadvisedInterceptor(this.advised.getTargetSource());
|
||||
new DynamicUnadvisedInterceptor(this.advised.getTargetSource()));
|
||||
}
|
||||
|
||||
// Choose a "direct to target" dispatcher (used for
|
||||
// unadvised calls to static targets that cannot return this).
|
||||
Callback targetDispatcher = isStatic ?
|
||||
new StaticDispatcher(this.advised.getTargetSource().getTarget()) : new SerializableNoOp();
|
||||
Callback targetDispatcher = (isStatic ?
|
||||
new StaticDispatcher(this.advised.getTargetSource().getTarget()) : new SerializableNoOp());
|
||||
|
||||
Callback[] mainCallbacks = new Callback[] {
|
||||
aopInterceptor, // for normal advice
|
||||
@@ -812,12 +810,16 @@ class CglibAopProxy implements AopProxy, Serializable {
|
||||
}
|
||||
// We must always proxy equals, to direct calls to this.
|
||||
if (AopUtils.isEqualsMethod(method)) {
|
||||
logger.debug("Found 'equals' method: " + method);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Found 'equals' method: " + method);
|
||||
}
|
||||
return INVOKE_EQUALS;
|
||||
}
|
||||
// We must always calculate hashCode based on the proxy.
|
||||
if (AopUtils.isHashCodeMethod(method)) {
|
||||
logger.debug("Found 'hashCode' method: " + method);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Found 'hashCode' method: " + method);
|
||||
}
|
||||
return INVOKE_HASHCODE;
|
||||
}
|
||||
Class<?> targetClass = this.advised.getTargetClass();
|
||||
|
||||
+3
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -62,9 +62,9 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ
|
||||
// Add it conditionally.
|
||||
PointcutAdvisor pointcutAdvisor = (PointcutAdvisor) advisor;
|
||||
if (config.isPreFiltered() || pointcutAdvisor.getPointcut().getClassFilter().matches(actualClass)) {
|
||||
MethodInterceptor[] interceptors = registry.getInterceptors(advisor);
|
||||
MethodMatcher mm = pointcutAdvisor.getPointcut().getMethodMatcher();
|
||||
if (MethodMatchers.matches(mm, method, actualClass, hasIntroductions)) {
|
||||
MethodInterceptor[] interceptors = registry.getInterceptors(advisor);
|
||||
if (mm.isRuntime()) {
|
||||
// Creating a new object instance in the getInterceptors() method
|
||||
// isn't a problem as we normally cache created chains.
|
||||
@@ -98,8 +98,7 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ
|
||||
* Determine whether the Advisors contain matching introductions.
|
||||
*/
|
||||
private static boolean hasMatchingIntroductions(Advised config, Class<?> actualClass) {
|
||||
for (int i = 0; i < config.getAdvisors().length; i++) {
|
||||
Advisor advisor = config.getAdvisors()[i];
|
||||
for (Advisor advisor : config.getAdvisors()) {
|
||||
if (advisor instanceof IntroductionAdvisor) {
|
||||
IntroductionAdvisor ia = (IntroductionAdvisor) advisor;
|
||||
if (ia.getClassFilter().matches(actualClass)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 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 @@ public class ProxyCreatorSupport extends AdvisedSupport {
|
||||
|
||||
private AopProxyFactory aopProxyFactory;
|
||||
|
||||
private List<AdvisedSupportListener> listeners = new LinkedList<AdvisedSupportListener>();
|
||||
private final List<AdvisedSupportListener> listeners = new LinkedList<AdvisedSupportListener>();
|
||||
|
||||
/** Set to true when the first AOP proxy has been created */
|
||||
private boolean active = false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -640,7 +640,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
||||
}
|
||||
|
||||
public String getBeanName() {
|
||||
return beanName;
|
||||
return this.beanName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+9
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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,8 @@
|
||||
|
||||
package org.springframework.aop.framework;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
import org.springframework.beans.factory.Aware;
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
@@ -48,9 +50,9 @@ public class ProxyProcessorSupport extends ProxyConfig implements Ordered, BeanC
|
||||
|
||||
|
||||
/**
|
||||
* Set the ordering which will apply to this class's implementation
|
||||
* of Ordered, used when applying multiple processors.
|
||||
* <p>Default value is {@code Integer.MAX_VALUE}, meaning that it's non-ordered.
|
||||
* Set the ordering which will apply to this processor's implementation
|
||||
* of {@link Ordered}, used when applying multiple processors.
|
||||
* <p>The default value is {@code Ordered.LOWEST_PRECEDENCE}, meaning non-ordered.
|
||||
* @param order the ordering value
|
||||
*/
|
||||
public void setOrder(int order) {
|
||||
@@ -127,6 +129,7 @@ public class ProxyProcessorSupport extends ProxyConfig implements Ordered, BeanC
|
||||
*/
|
||||
protected boolean isConfigurationCallbackInterface(Class<?> ifc) {
|
||||
return (InitializingBean.class == ifc || DisposableBean.class == ifc ||
|
||||
Closeable.class == ifc || "java.lang.AutoCloseable".equals(ifc.getName()) ||
|
||||
ObjectUtils.containsElement(ifc.getInterfaces(), Aware.class));
|
||||
}
|
||||
|
||||
@@ -140,7 +143,8 @@ public class ProxyProcessorSupport extends ProxyConfig implements Ordered, BeanC
|
||||
*/
|
||||
protected boolean isInternalLanguageInterface(Class<?> ifc) {
|
||||
return (ifc.getName().equals("groovy.lang.GroovyObject") ||
|
||||
ifc.getName().endsWith(".cglib.proxy.Factory"));
|
||||
ifc.getName().endsWith(".cglib.proxy.Factory") ||
|
||||
ifc.getName().endsWith(".bytebuddy.MockAccess"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+10
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,15 +31,15 @@ import org.springframework.aop.Advisor;
|
||||
public interface AdvisorAdapterRegistry {
|
||||
|
||||
/**
|
||||
* Return an Advisor wrapping the given advice.
|
||||
* Return an {@link Advisor} wrapping the given advice.
|
||||
* <p>Should by default at least support
|
||||
* {@link org.aopalliance.intercept.MethodInterceptor},
|
||||
* {@link org.springframework.aop.MethodBeforeAdvice},
|
||||
* {@link org.springframework.aop.AfterReturningAdvice},
|
||||
* {@link org.springframework.aop.ThrowsAdvice}.
|
||||
* @param advice object that should be an advice
|
||||
* @return an Advisor wrapping the given advice. Never returns {@code null}.
|
||||
* If the advice parameter is an Advisor, return it.
|
||||
* @return an Advisor wrapping the given advice (never {@code null};
|
||||
* if the advice parameter is an Advisor, it is to be returned as-is)
|
||||
* @throws UnknownAdviceTypeException if no registered advisor adapter
|
||||
* can wrap the supposed advice
|
||||
*/
|
||||
@@ -48,21 +48,20 @@ public interface AdvisorAdapterRegistry {
|
||||
/**
|
||||
* Return an array of AOP Alliance MethodInterceptors to allow use of the
|
||||
* given Advisor in an interception-based framework.
|
||||
* <p>Don't worry about the pointcut associated with the Advisor,
|
||||
* if it's a PointcutAdvisor: just return an interceptor.
|
||||
* <p>Don't worry about the pointcut associated with the {@link Advisor}, if it is
|
||||
* a {@link org.springframework.aop.PointcutAdvisor}: just return an interceptor.
|
||||
* @param advisor Advisor to find an interceptor for
|
||||
* @return an array of MethodInterceptors to expose this Advisor's behavior
|
||||
* @throws UnknownAdviceTypeException if the Advisor type is
|
||||
* not understood by any registered AdvisorAdapter.
|
||||
* not understood by any registered AdvisorAdapter
|
||||
*/
|
||||
MethodInterceptor[] getInterceptors(Advisor advisor) throws UnknownAdviceTypeException;
|
||||
|
||||
/**
|
||||
* Register the given AdvisorAdapter. Note that it is not necessary to register
|
||||
* Register the given {@link AdvisorAdapter}. Note that it is not necessary to register
|
||||
* adapters for an AOP Alliance Interceptors or Spring Advices: these must be
|
||||
* automatically recognized by an AdvisorAdapterRegistry implementation.
|
||||
* @param adapter AdvisorAdapter that understands a particular Advisor
|
||||
* or Advice types
|
||||
* automatically recognized by an {@code AdvisorAdapterRegistry} implementation.
|
||||
* @param adapter AdvisorAdapter that understands particular Advisor or Advice types
|
||||
*/
|
||||
void registerAdvisorAdapter(AdvisorAdapter adapter);
|
||||
|
||||
|
||||
+4
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,6 +31,8 @@ import org.springframework.util.Assert;
|
||||
* to use this class directly.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @see MethodBeforeAdviceInterceptor
|
||||
* @see ThrowsAdviceInterceptor
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class AfterReturningAdviceInterceptor implements MethodInterceptor, AfterAdvice, Serializable {
|
||||
@@ -47,6 +49,7 @@ public class AfterReturningAdviceInterceptor implements MethodInterceptor, After
|
||||
this.advice = advice;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||
Object retVal = mi.proceed();
|
||||
|
||||
+8
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +21,7 @@ import java.io.Serializable;
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
|
||||
import org.springframework.aop.BeforeAdvice;
|
||||
import org.springframework.aop.MethodBeforeAdvice;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -30,11 +31,13 @@ import org.springframework.util.Assert;
|
||||
* to use this class directly.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @see AfterReturningAdviceInterceptor
|
||||
* @see ThrowsAdviceInterceptor
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class MethodBeforeAdviceInterceptor implements MethodInterceptor, Serializable {
|
||||
public class MethodBeforeAdviceInterceptor implements MethodInterceptor, BeforeAdvice, Serializable {
|
||||
|
||||
private MethodBeforeAdvice advice;
|
||||
private final MethodBeforeAdvice advice;
|
||||
|
||||
|
||||
/**
|
||||
@@ -46,9 +49,10 @@ public class MethodBeforeAdviceInterceptor implements MethodInterceptor, Seriali
|
||||
this.advice = advice;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||
this.advice.before(mi.getMethod(), mi.getArguments(), mi.getThis() );
|
||||
this.advice.before(mi.getMethod(), mi.getArguments(), mi.getThis());
|
||||
return mi.proceed();
|
||||
}
|
||||
|
||||
|
||||
+38
-29
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,6 +50,8 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
* @see MethodBeforeAdviceInterceptor
|
||||
* @see AfterReturningAdviceInterceptor
|
||||
*/
|
||||
public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice {
|
||||
|
||||
@@ -66,9 +68,8 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice {
|
||||
|
||||
/**
|
||||
* Create a new ThrowsAdviceInterceptor for the given ThrowsAdvice.
|
||||
* @param throwsAdvice the advice object that defines the exception
|
||||
* handler methods (usually a {@link org.springframework.aop.ThrowsAdvice}
|
||||
* implementation)
|
||||
* @param throwsAdvice the advice object that defines the exception handler methods
|
||||
* (usually a {@link org.springframework.aop.ThrowsAdvice} implementation)
|
||||
*/
|
||||
public ThrowsAdviceInterceptor(Object throwsAdvice) {
|
||||
Assert.notNull(throwsAdvice, "Advice must not be null");
|
||||
@@ -76,14 +77,17 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice {
|
||||
|
||||
Method[] methods = throwsAdvice.getClass().getMethods();
|
||||
for (Method method : methods) {
|
||||
if (method.getName().equals(AFTER_THROWING) &&
|
||||
(method.getParameterTypes().length == 1 || method.getParameterTypes().length == 4) &&
|
||||
Throwable.class.isAssignableFrom(method.getParameterTypes()[method.getParameterTypes().length - 1])
|
||||
) {
|
||||
// Have an exception handler
|
||||
this.exceptionHandlerMap.put(method.getParameterTypes()[method.getParameterTypes().length - 1], method);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Found exception handler method: " + method);
|
||||
if (method.getName().equals(AFTER_THROWING)) {
|
||||
Class<?>[] paramTypes = method.getParameterTypes();
|
||||
if (paramTypes.length == 1 || paramTypes.length == 4) {
|
||||
Class<?> throwableParam = paramTypes[paramTypes.length - 1];
|
||||
if (Throwable.class.isAssignableFrom(throwableParam)) {
|
||||
// An exception handler to register...
|
||||
this.exceptionHandlerMap.put(throwableParam, method);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Found exception handler method on throws advice: " + method);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,14 +98,33 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the number of handler methods in this advice.
|
||||
*/
|
||||
public int getHandlerMethodCount() {
|
||||
return this.exceptionHandlerMap.size();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||
try {
|
||||
return mi.proceed();
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
Method handlerMethod = getExceptionHandler(ex);
|
||||
if (handlerMethod != null) {
|
||||
invokeHandlerMethod(mi, ex, handlerMethod);
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the exception handle method. Can return null if not found.
|
||||
* Determine the exception handle method for the given exception.
|
||||
* @param exception the exception thrown
|
||||
* @return a handler for the given exception type
|
||||
* @return a handler for the given exception type, or {@code null} if none found
|
||||
*/
|
||||
private Method getExceptionHandler(Throwable exception) {
|
||||
Class<?> exceptionClass = exception.getClass();
|
||||
@@ -119,24 +142,10 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice {
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||
try {
|
||||
return mi.proceed();
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
Method handlerMethod = getExceptionHandler(ex);
|
||||
if (handlerMethod != null) {
|
||||
invokeHandlerMethod(mi, ex, handlerMethod);
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
private void invokeHandlerMethod(MethodInvocation mi, Throwable ex, Method method) throws Throwable {
|
||||
Object[] handlerArgs;
|
||||
if (method.getParameterTypes().length == 1) {
|
||||
handlerArgs = new Object[] { ex };
|
||||
handlerArgs = new Object[] {ex};
|
||||
}
|
||||
else {
|
||||
handlerArgs = new Object[] {mi.getMethod(), mi.getArguments(), mi.getThis(), ex};
|
||||
|
||||
+4
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -412,7 +412,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
|
||||
// Found a matching TargetSource.
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("TargetSourceCreator [" + tsc +
|
||||
" found custom TargetSource for bean with name '" + beanName + "'");
|
||||
"] found custom TargetSource for bean with name '" + beanName + "'");
|
||||
}
|
||||
return ts;
|
||||
}
|
||||
@@ -454,10 +454,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
|
||||
}
|
||||
|
||||
Advisor[] advisors = buildAdvisors(beanName, specificInterceptors);
|
||||
for (Advisor advisor : advisors) {
|
||||
proxyFactory.addAdvisor(advisor);
|
||||
}
|
||||
|
||||
proxyFactory.addAdvisors(advisors);
|
||||
proxyFactory.setTargetSource(targetSource);
|
||||
customizeProxyFactory(proxyFactory);
|
||||
|
||||
@@ -556,7 +553,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
|
||||
* Subclasses may choose to implement this: for example,
|
||||
* to change the interfaces exposed.
|
||||
* <p>The default implementation is empty.
|
||||
* @param proxyFactory ProxyFactory that is already configured with
|
||||
* @param proxyFactory a ProxyFactory that is already configured with
|
||||
* TargetSource and interfaces and will be used to create the proxy
|
||||
* immediately after this method returns
|
||||
*/
|
||||
|
||||
+12
-15
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.aop.framework.autoproxy;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -43,7 +43,7 @@ public class BeanFactoryAdvisorRetrievalHelper {
|
||||
|
||||
private final ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
private String[] cachedAdvisorBeanNames;
|
||||
private volatile String[] cachedAdvisorBeanNames;
|
||||
|
||||
|
||||
/**
|
||||
@@ -64,22 +64,19 @@ public class BeanFactoryAdvisorRetrievalHelper {
|
||||
*/
|
||||
public List<Advisor> findAdvisorBeans() {
|
||||
// Determine list of advisor bean names, if not cached already.
|
||||
String[] advisorNames = null;
|
||||
synchronized (this) {
|
||||
advisorNames = this.cachedAdvisorBeanNames;
|
||||
if (advisorNames == null) {
|
||||
// Do not initialize FactoryBeans here: We need to leave all regular beans
|
||||
// uninitialized to let the auto-proxy creator apply to them!
|
||||
advisorNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
|
||||
this.beanFactory, Advisor.class, true, false);
|
||||
this.cachedAdvisorBeanNames = advisorNames;
|
||||
}
|
||||
String[] advisorNames = this.cachedAdvisorBeanNames;
|
||||
if (advisorNames == null) {
|
||||
// Do not initialize FactoryBeans here: We need to leave all regular beans
|
||||
// uninitialized to let the auto-proxy creator apply to them!
|
||||
advisorNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
|
||||
this.beanFactory, Advisor.class, true, false);
|
||||
this.cachedAdvisorBeanNames = advisorNames;
|
||||
}
|
||||
if (advisorNames.length == 0) {
|
||||
return new LinkedList<Advisor>();
|
||||
return new ArrayList<Advisor>();
|
||||
}
|
||||
|
||||
List<Advisor> advisors = new LinkedList<Advisor>();
|
||||
List<Advisor> advisors = new ArrayList<Advisor>();
|
||||
for (String name : advisorNames) {
|
||||
if (isEligibleBean(name)) {
|
||||
if (this.beanFactory.isCurrentlyInCreation(name)) {
|
||||
|
||||
+6
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,12 +22,12 @@ import org.aopalliance.intercept.MethodInvocation;
|
||||
|
||||
/**
|
||||
* Base class for monitoring interceptors, such as performance monitors.
|
||||
* Provides {@code prefix} and {@code suffix} properties
|
||||
* that help to classify/group performance monitoring results.
|
||||
* Provides configurable "prefix and "suffix" properties that help to
|
||||
* classify/group performance monitoring results.
|
||||
*
|
||||
* <p>Subclasses should call the {@code createInvocationTraceName(MethodInvocation)}
|
||||
* method to create a name for the given trace that includes information about the
|
||||
* method invocation under trace along with the prefix and suffix added as appropriate.
|
||||
* <p>In their {@link #invokeUnderTrace} implementation, subclasses should call the
|
||||
* {@link #createInvocationTraceName} method to create a name for the given trace,
|
||||
* including information about the method invocation along with a prefix/suffix.
|
||||
*
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
|
||||
+56
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -58,6 +58,12 @@ public abstract class AbstractTraceInterceptor implements MethodInterceptor, Ser
|
||||
*/
|
||||
private boolean hideProxyClassNames = false;
|
||||
|
||||
/**
|
||||
* Indicates whether to pass an exception to the logger.
|
||||
* @see #writeToLog(Log, String, Throwable)
|
||||
*/
|
||||
private boolean logExceptionStackTrace = true;
|
||||
|
||||
|
||||
/**
|
||||
* Set whether to use a dynamic logger or a static logger.
|
||||
@@ -98,6 +104,17 @@ public abstract class AbstractTraceInterceptor implements MethodInterceptor, Ser
|
||||
this.hideProxyClassNames = hideProxyClassNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to pass an exception to the logger, suggesting inclusion
|
||||
* of its stack trace into the log. Default is "true"; set this to "false"
|
||||
* in order to reduce the log output to just the trace message (which may
|
||||
* include the exception class name and exception message, if applicable).
|
||||
* @since 4.3.10
|
||||
*/
|
||||
public void setLogExceptionStackTrace(boolean logExceptionStackTrace) {
|
||||
this.logExceptionStackTrace = logExceptionStackTrace;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines whether or not logging is enabled for the particular {@code MethodInvocation}.
|
||||
@@ -171,6 +188,40 @@ public abstract class AbstractTraceInterceptor implements MethodInterceptor, Ser
|
||||
return logger.isTraceEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the supplied trace message to the supplied {@code Log} instance.
|
||||
* <p>To be called by {@link #invokeUnderTrace} for enter/exit messages.
|
||||
* <p>Delegates to {@link #writeToLog(Log, String, Throwable)} as the
|
||||
* ultimate delegate that controls the underlying logger invocation.
|
||||
* @since 4.3.10
|
||||
* @see #writeToLog(Log, String, Throwable)
|
||||
*/
|
||||
protected void writeToLog(Log logger, String message) {
|
||||
writeToLog(logger, message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the supplied trace message and {@link Throwable} to the
|
||||
* supplied {@code Log} instance.
|
||||
* <p>To be called by {@link #invokeUnderTrace} for enter/exit outcomes,
|
||||
* potentially including an exception. Note that an exception's stack trace
|
||||
* won't get logged when {@link #setLogExceptionStackTrace} is "false".
|
||||
* <p>By default messages are written at {@code TRACE} level. Subclasses
|
||||
* can override this method to control which level the message is written
|
||||
* at, typically also overriding {@link #isLogEnabled} accordingly.
|
||||
* @since 4.3.10
|
||||
* @see #setLogExceptionStackTrace
|
||||
* @see #isLogEnabled
|
||||
*/
|
||||
protected void writeToLog(Log logger, String message, Throwable ex) {
|
||||
if (ex != null && this.logExceptionStackTrace) {
|
||||
logger.trace(message, ex);
|
||||
}
|
||||
else {
|
||||
logger.trace(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Subclasses must override this method to perform any tracing around the
|
||||
@@ -180,13 +231,15 @@ public abstract class AbstractTraceInterceptor implements MethodInterceptor, Ser
|
||||
* <p>By default, the passed-in {@code Log} instance will have log level
|
||||
* "trace" enabled. Subclasses do not have to check for this again, unless
|
||||
* they overwrite the {@code isInterceptorEnabled} method to modify
|
||||
* the default behavior.
|
||||
* the default behavior, and may delegate to {@code writeToLog} for actual
|
||||
* messages to be written.
|
||||
* @param logger the {@code Log} to write trace messages to
|
||||
* @return the result of the call to {@code MethodInvocation.proceed()}
|
||||
* @throws Throwable if the call to {@code MethodInvocation.proceed()}
|
||||
* encountered any errors
|
||||
* @see #isInterceptorEnabled
|
||||
* @see #isLogEnabled
|
||||
* @see #writeToLog(Log, String)
|
||||
* @see #writeToLog(Log, String, Throwable)
|
||||
*/
|
||||
protected abstract Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable;
|
||||
|
||||
|
||||
+9
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -228,6 +228,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
|
||||
return beanFactory.getBean(TaskExecutor.class);
|
||||
}
|
||||
catch (NoUniqueBeanDefinitionException ex) {
|
||||
logger.debug("Could not find unique TaskExecutor bean", ex);
|
||||
try {
|
||||
return beanFactory.getBean(DEFAULT_TASK_EXECUTOR_BEAN_NAME, Executor.class);
|
||||
}
|
||||
@@ -241,8 +242,14 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
logger.debug("Could not find default TaskExecutor bean", ex);
|
||||
try {
|
||||
return beanFactory.getBean(DEFAULT_TASK_EXECUTOR_BEAN_NAME, Executor.class);
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex2) {
|
||||
logger.info("No task executor bean found for async processing: " +
|
||||
"no bean of type TaskExecutor and no bean named 'taskExecutor' either");
|
||||
}
|
||||
// Giving up -> either using local default executor or none at all...
|
||||
logger.info("No TaskExecutor bean found for async processing");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
+19
-44
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -128,20 +128,20 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
|
||||
/**
|
||||
* The default message used for writing method entry messages.
|
||||
*/
|
||||
private static final String DEFAULT_ENTER_MESSAGE =
|
||||
"Entering method '" + PLACEHOLDER_METHOD_NAME + "' of class [" + PLACEHOLDER_TARGET_CLASS_NAME + "]";
|
||||
private static final String DEFAULT_ENTER_MESSAGE = "Entering method '" +
|
||||
PLACEHOLDER_METHOD_NAME + "' of class [" + PLACEHOLDER_TARGET_CLASS_NAME + "]";
|
||||
|
||||
/**
|
||||
* The default message used for writing method exit messages.
|
||||
*/
|
||||
private static final String DEFAULT_EXIT_MESSAGE =
|
||||
"Exiting method '" + PLACEHOLDER_METHOD_NAME + "' of class [" + PLACEHOLDER_TARGET_CLASS_NAME + "]";
|
||||
private static final String DEFAULT_EXIT_MESSAGE = "Exiting method '" +
|
||||
PLACEHOLDER_METHOD_NAME + "' of class [" + PLACEHOLDER_TARGET_CLASS_NAME + "]";
|
||||
|
||||
/**
|
||||
* The default message used for writing exception messages.
|
||||
*/
|
||||
private static final String DEFAULT_EXCEPTION_MESSAGE =
|
||||
"Exception thrown in method '" + PLACEHOLDER_METHOD_NAME + "' of class [" + PLACEHOLDER_TARGET_CLASS_NAME + "]";
|
||||
private static final String DEFAULT_EXCEPTION_MESSAGE = "Exception thrown in method '" +
|
||||
PLACEHOLDER_METHOD_NAME + "' of class [" + PLACEHOLDER_TARGET_CLASS_NAME + "]";
|
||||
|
||||
/**
|
||||
* The {@code Pattern} used to match placeholders.
|
||||
@@ -182,14 +182,14 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
|
||||
* </ul>
|
||||
*/
|
||||
public void setEnterMessage(String enterMessage) throws IllegalArgumentException {
|
||||
Assert.hasText(enterMessage, "'enterMessage' must not be empty");
|
||||
Assert.hasText(enterMessage, "enterMessage must not be empty");
|
||||
checkForInvalidPlaceholders(enterMessage);
|
||||
Assert.doesNotContain(enterMessage, PLACEHOLDER_RETURN_VALUE,
|
||||
"enterMessage cannot contain placeholder [" + PLACEHOLDER_RETURN_VALUE + "]");
|
||||
"enterMessage cannot contain placeholder " + PLACEHOLDER_RETURN_VALUE);
|
||||
Assert.doesNotContain(enterMessage, PLACEHOLDER_EXCEPTION,
|
||||
"enterMessage cannot contain placeholder [" + PLACEHOLDER_EXCEPTION + "]");
|
||||
"enterMessage cannot contain placeholder " + PLACEHOLDER_EXCEPTION);
|
||||
Assert.doesNotContain(enterMessage, PLACEHOLDER_INVOCATION_TIME,
|
||||
"enterMessage cannot contain placeholder [" + PLACEHOLDER_INVOCATION_TIME + "]");
|
||||
"enterMessage cannot contain placeholder " + PLACEHOLDER_INVOCATION_TIME);
|
||||
this.enterMessage = enterMessage;
|
||||
}
|
||||
|
||||
@@ -206,10 +206,10 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
|
||||
* </ul>
|
||||
*/
|
||||
public void setExitMessage(String exitMessage) {
|
||||
Assert.hasText(exitMessage, "'exitMessage' must not be empty");
|
||||
Assert.hasText(exitMessage, "exitMessage must not be empty");
|
||||
checkForInvalidPlaceholders(exitMessage);
|
||||
Assert.doesNotContain(exitMessage, PLACEHOLDER_EXCEPTION,
|
||||
"exitMessage cannot contain placeholder [" + PLACEHOLDER_EXCEPTION + "]");
|
||||
"exitMessage cannot contain placeholder" + PLACEHOLDER_EXCEPTION);
|
||||
this.exitMessage = exitMessage;
|
||||
}
|
||||
|
||||
@@ -225,12 +225,10 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
|
||||
* </ul>
|
||||
*/
|
||||
public void setExceptionMessage(String exceptionMessage) {
|
||||
Assert.hasText(exceptionMessage, "'exceptionMessage' must not be empty");
|
||||
Assert.hasText(exceptionMessage, "exceptionMessage must not be empty");
|
||||
checkForInvalidPlaceholders(exceptionMessage);
|
||||
Assert.doesNotContain(exceptionMessage, PLACEHOLDER_RETURN_VALUE,
|
||||
"exceptionMessage cannot contain placeholder [" + PLACEHOLDER_RETURN_VALUE + "]");
|
||||
Assert.doesNotContain(exceptionMessage, PLACEHOLDER_INVOCATION_TIME,
|
||||
"exceptionMessage cannot contain placeholder [" + PLACEHOLDER_INVOCATION_TIME + "]");
|
||||
"exceptionMessage cannot contain placeholder " + PLACEHOLDER_RETURN_VALUE);
|
||||
this.exceptionMessage = exceptionMessage;
|
||||
}
|
||||
|
||||
@@ -262,8 +260,8 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
|
||||
stopWatch.stop();
|
||||
}
|
||||
exitThroughException = true;
|
||||
writeToLog(logger,
|
||||
replacePlaceholders(this.exceptionMessage, invocation, null, ex, stopWatch.getTotalTimeMillis()), ex);
|
||||
writeToLog(logger, replacePlaceholders(
|
||||
this.exceptionMessage, invocation, null, ex, stopWatch.getTotalTimeMillis()), ex);
|
||||
throw ex;
|
||||
}
|
||||
finally {
|
||||
@@ -271,35 +269,12 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
|
||||
if (stopWatch.isRunning()) {
|
||||
stopWatch.stop();
|
||||
}
|
||||
writeToLog(logger,
|
||||
replacePlaceholders(this.exitMessage, invocation, returnValue, null, stopWatch.getTotalTimeMillis()));
|
||||
writeToLog(logger, replacePlaceholders(
|
||||
this.exitMessage, invocation, returnValue, null, stopWatch.getTotalTimeMillis()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the supplied message to the supplied {@code Log} instance.
|
||||
* @see #writeToLog(org.apache.commons.logging.Log, String, Throwable)
|
||||
*/
|
||||
protected void writeToLog(Log logger, String message) {
|
||||
writeToLog(logger, message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the supplied message and {@link Throwable} to the
|
||||
* supplied {@code Log} instance. By default messages are written
|
||||
* at {@code TRACE} level. Sub-classes can override this method
|
||||
* to control which level the message is written at.
|
||||
*/
|
||||
protected void writeToLog(Log logger, String message, Throwable ex) {
|
||||
if (ex != null) {
|
||||
logger.trace(message, ex);
|
||||
}
|
||||
else {
|
||||
logger.trace(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the placeholders in the given message with the supplied values,
|
||||
* or values derived from those supplied.
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -121,7 +121,7 @@ public class JamonPerformanceMonitorInterceptor extends AbstractMonitoringInterc
|
||||
finally {
|
||||
monitor.stop();
|
||||
if (!this.trackAllInvocations || isLogEnabled(logger)) {
|
||||
logger.trace("JAMon performance statistics for method [" + name + "]:\n" + monitor);
|
||||
writeToLog(logger, "JAMon performance statistics for method [" + name + "]:\n" + monitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -63,7 +63,7 @@ public class PerformanceMonitorInterceptor extends AbstractMonitoringInterceptor
|
||||
}
|
||||
finally {
|
||||
stopWatch.stop();
|
||||
logger.trace(stopWatch.shortSummary());
|
||||
writeToLog(logger, stopWatch.shortSummary());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -29,13 +29,13 @@ import org.apache.commons.logging.LogFactory;
|
||||
*/
|
||||
public class SimpleAsyncUncaughtExceptionHandler implements AsyncUncaughtExceptionHandler {
|
||||
|
||||
private final Log logger = LogFactory.getLog(SimpleAsyncUncaughtExceptionHandler.class);
|
||||
private static final Log logger = LogFactory.getLog(SimpleAsyncUncaughtExceptionHandler.class);
|
||||
|
||||
|
||||
@Override
|
||||
public void handleUncaughtException(Throwable ex, Method method, Object... params) {
|
||||
if (logger.isErrorEnabled()) {
|
||||
logger.error(String.format("Unexpected error occurred invoking async " +
|
||||
"method '%s'.", method), ex);
|
||||
logger.error("Unexpected error occurred invoking async method: " + method, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -55,14 +55,14 @@ public class SimpleTraceInterceptor extends AbstractTraceInterceptor {
|
||||
@Override
|
||||
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
|
||||
String invocationDescription = getInvocationDescription(invocation);
|
||||
logger.trace("Entering " + invocationDescription);
|
||||
writeToLog(logger, "Entering " + invocationDescription);
|
||||
try {
|
||||
Object rval = invocation.proceed();
|
||||
logger.trace("Exiting " + invocationDescription);
|
||||
writeToLog(logger, "Exiting " + invocationDescription);
|
||||
return rval;
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
logger.trace("Exception thrown in " + invocationDescription, ex);
|
||||
writeToLog(logger, "Exception thrown in " + invocationDescription, ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,7 +50,8 @@ import org.springframework.util.ClassUtils;
|
||||
* @see #setProxyTargetClass
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ScopedProxyFactoryBean extends ProxyConfig implements FactoryBean<Object>, BeanFactoryAware {
|
||||
public class ScopedProxyFactoryBean extends ProxyConfig
|
||||
implements FactoryBean<Object>, BeanFactoryAware, AopInfrastructureBean {
|
||||
|
||||
/** The TargetSource that manages scoping */
|
||||
private final SimpleBeanTargetSource scopedTargetSource = new SimpleBeanTargetSource();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -89,7 +89,7 @@ public abstract class ScopedProxyUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the bean name that is used within the scoped proxy to reference the target bean.
|
||||
* Generate the bean name that is used within the scoped proxy to reference the target bean.
|
||||
* @param originalBeanName the original name of bean
|
||||
* @return the generated bean to be used to reference the target bean
|
||||
*/
|
||||
|
||||
+4
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -130,8 +130,9 @@ public abstract class AbstractRegexpMethodPointcut extends StaticMethodMatcherPo
|
||||
*/
|
||||
@Override
|
||||
public boolean matches(Method method, Class<?> targetClass) {
|
||||
return ((targetClass != null && matchesPattern(ClassUtils.getQualifiedMethodName(method, targetClass))) ||
|
||||
matchesPattern(ClassUtils.getQualifiedMethodName(method)));
|
||||
return ((targetClass != null && targetClass != method.getDeclaringClass() &&
|
||||
matchesPattern(ClassUtils.getQualifiedMethodName(method, targetClass))) ||
|
||||
matchesPattern(ClassUtils.getQualifiedMethodName(method, method.getDeclaringClass())));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,7 +22,6 @@ import org.springframework.aop.ClassFilter;
|
||||
import org.springframework.aop.MethodMatcher;
|
||||
import org.springframework.aop.Pointcut;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Convenient class for building up pointcuts. All methods return
|
||||
@@ -188,21 +187,14 @@ public class ComposablePointcut implements Pointcut, Serializable {
|
||||
if (!(other instanceof ComposablePointcut)) {
|
||||
return false;
|
||||
}
|
||||
ComposablePointcut that = (ComposablePointcut) other;
|
||||
return ObjectUtils.nullSafeEquals(that.classFilter, this.classFilter) &&
|
||||
ObjectUtils.nullSafeEquals(that.methodMatcher, this.methodMatcher);
|
||||
ComposablePointcut otherPointcut = (ComposablePointcut) other;
|
||||
return (this.classFilter.equals(otherPointcut.classFilter) &&
|
||||
this.methodMatcher.equals(otherPointcut.methodMatcher));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int code = 17;
|
||||
if (this.classFilter != null) {
|
||||
code = 37 * code + this.classFilter.hashCode();
|
||||
}
|
||||
if (this.methodMatcher != null) {
|
||||
code = 37 * code + this.methodMatcher.hashCode();
|
||||
}
|
||||
return code;
|
||||
return this.classFilter.hashCode() * 37 + this.methodMatcher.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -45,7 +45,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||
|
||||
private final Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>();
|
||||
|
||||
private int order = Integer.MAX_VALUE;
|
||||
private int order = Ordered.LOWEST_PRECEDENCE;
|
||||
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||
|
||||
@Override
|
||||
public Class<?>[] getInterfaces() {
|
||||
return this.interfaces.toArray(new Class<?>[this.interfaces.size()]);
|
||||
return ClassUtils.toClassArray(this.interfaces);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,7 +118,6 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
@@ -128,7 +127,6 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
|
||||
return this.order;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Advice getAdvice() {
|
||||
return this.advice;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,8 @@ import org.springframework.aop.MethodMatcher;
|
||||
/**
|
||||
* Convenient abstract superclass for dynamic method matchers,
|
||||
* which do care about arguments at runtime.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
*/
|
||||
public abstract class DynamicMethodMatcher implements MethodMatcher {
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.springframework.aop.Pointcut;
|
||||
* Convenient superclass when we want to force subclasses to
|
||||
* implement MethodMatcher interface, but subclasses
|
||||
* will want to be pointcuts. The getClassFilter() method can
|
||||
* be overriden to customize ClassFilter behaviour as well.
|
||||
* be overridden to customize ClassFilter behaviour as well.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
*/
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -53,15 +53,15 @@ public class IntroductionInfoSupport implements IntroductionInfo, Serializable {
|
||||
* due to the delegate implementing it. Call this method to exclude
|
||||
* internal interfaces from being visible at the proxy level.
|
||||
* <p>Does nothing if the interface is not implemented by the delegate.
|
||||
* @param intf the interface to suppress
|
||||
* @param ifc the interface to suppress
|
||||
*/
|
||||
public void suppressInterface(Class<?> intf) {
|
||||
this.publishedInterfaces.remove(intf);
|
||||
public void suppressInterface(Class<?> ifc) {
|
||||
this.publishedInterfaces.remove(ifc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?>[] getInterfaces() {
|
||||
return this.publishedInterfaces.toArray(new Class<?>[this.publishedInterfaces.size()]);
|
||||
return ClassUtils.toClassArray(this.publishedInterfaces);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,7 +27,7 @@ import org.springframework.util.PatternMatchUtils;
|
||||
|
||||
/**
|
||||
* Pointcut bean for simple method name matches, as alternative to regexp patterns.
|
||||
* Does not handle overloaded methods: all methods *with a given name will be eligible.
|
||||
* Does not handle overloaded methods: all methods with a given name will be eligible.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Rod Johnson
|
||||
|
||||
@@ -94,7 +94,7 @@ public abstract class Pointcuts {
|
||||
@SuppressWarnings("serial")
|
||||
private static class SetterPointcut extends StaticMethodMatcherPointcut implements Serializable {
|
||||
|
||||
public static SetterPointcut INSTANCE = new SetterPointcut();
|
||||
public static final SetterPointcut INSTANCE = new SetterPointcut();
|
||||
|
||||
@Override
|
||||
public boolean matches(Method method, Class<?> targetClass) {
|
||||
@@ -115,7 +115,7 @@ public abstract class Pointcuts {
|
||||
@SuppressWarnings("serial")
|
||||
private static class GetterPointcut extends StaticMethodMatcherPointcut implements Serializable {
|
||||
|
||||
public static GetterPointcut INSTANCE = new GetterPointcut();
|
||||
public static final GetterPointcut INSTANCE = new GetterPointcut();
|
||||
|
||||
@Override
|
||||
public boolean matches(Method method, Class<?> targetClass) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,7 +21,8 @@ import java.io.Serializable;
|
||||
import org.springframework.aop.ClassFilter;
|
||||
|
||||
/**
|
||||
* Simple ClassFilter implementation that passes classes (and optionally subclasses)
|
||||
* Simple ClassFilter implementation that passes classes (and optionally subclasses).
|
||||
*
|
||||
* @author Rod Johnson
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@@ -37,7 +38,7 @@ public class RootClassFilter implements ClassFilter, Serializable {
|
||||
|
||||
@Override
|
||||
public boolean matches(Class<?> candidate) {
|
||||
return clazz.isAssignableFrom(candidate);
|
||||
return this.clazz.isAssignableFrom(candidate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,6 +23,8 @@ import org.springframework.aop.MethodMatcher;
|
||||
/**
|
||||
* Convenient abstract superclass for static method matchers, which don't care
|
||||
* about arguments at runtime.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
*/
|
||||
public abstract class StaticMethodMatcher implements MethodMatcher {
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -36,10 +36,10 @@ import org.springframework.util.Assert;
|
||||
public abstract class StaticMethodMatcherPointcutAdvisor extends StaticMethodMatcherPointcut
|
||||
implements PointcutAdvisor, Ordered, Serializable {
|
||||
|
||||
private int order = Integer.MAX_VALUE;
|
||||
|
||||
private Advice advice;
|
||||
|
||||
private int order = Integer.MAX_VALUE;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new StaticMethodMatcherPointcutAdvisor,
|
||||
|
||||
+9
-18
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,7 +22,6 @@ import org.springframework.aop.ClassFilter;
|
||||
import org.springframework.aop.MethodMatcher;
|
||||
import org.springframework.aop.Pointcut;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Simple Pointcut that looks for a specific Java 5 annotation
|
||||
@@ -46,16 +45,15 @@ public class AnnotationMatchingPointcut implements Pointcut {
|
||||
* @param classAnnotationType the annotation type to look for at the class level
|
||||
*/
|
||||
public AnnotationMatchingPointcut(Class<? extends Annotation> classAnnotationType) {
|
||||
this.classFilter = new AnnotationClassFilter(classAnnotationType);
|
||||
this.methodMatcher = MethodMatcher.TRUE;
|
||||
this(classAnnotationType, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new AnnotationMatchingPointcut for the given annotation type.
|
||||
* @param classAnnotationType the annotation type to look for at the class level
|
||||
* @param checkInherited whether to explicitly check the superclasses and
|
||||
* interfaces for the annotation type as well (even if the annotation type
|
||||
* is not marked as inherited itself)
|
||||
* @param checkInherited whether to also check the superclasses and interfaces
|
||||
* as well as meta-annotations for the annotation type
|
||||
* @see AnnotationClassFilter#AnnotationClassFilter(Class, boolean)
|
||||
*/
|
||||
public AnnotationMatchingPointcut(Class<? extends Annotation> classAnnotationType, boolean checkInherited) {
|
||||
this.classFilter = new AnnotationClassFilter(classAnnotationType, checkInherited);
|
||||
@@ -109,21 +107,14 @@ public class AnnotationMatchingPointcut implements Pointcut {
|
||||
if (!(other instanceof AnnotationMatchingPointcut)) {
|
||||
return false;
|
||||
}
|
||||
AnnotationMatchingPointcut that = (AnnotationMatchingPointcut) other;
|
||||
return ObjectUtils.nullSafeEquals(that.classFilter, this.classFilter) &&
|
||||
ObjectUtils.nullSafeEquals(that.methodMatcher, this.methodMatcher);
|
||||
AnnotationMatchingPointcut otherPointcut = (AnnotationMatchingPointcut) other;
|
||||
return (this.classFilter.equals(otherPointcut.classFilter) &&
|
||||
this.methodMatcher.equals(otherPointcut.methodMatcher));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int code = 17;
|
||||
if (this.classFilter != null) {
|
||||
code = 37 * code + this.classFilter.hashCode();
|
||||
}
|
||||
if (this.methodMatcher != null) {
|
||||
code = 37 * code + this.methodMatcher.hashCode();
|
||||
}
|
||||
return code;
|
||||
return this.classFilter.hashCode() * 37 + this.methodMatcher.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+23
-16
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -60,7 +60,7 @@ public abstract class AbstractBeanFactoryBasedTargetSource implements TargetSour
|
||||
private String targetBeanName;
|
||||
|
||||
/** Class of the target */
|
||||
private Class<?> targetClass;
|
||||
private volatile Class<?> targetClass;
|
||||
|
||||
/**
|
||||
* BeanFactory that owns this TargetSource. We need to hold onto this
|
||||
@@ -120,21 +120,28 @@ public abstract class AbstractBeanFactoryBasedTargetSource implements TargetSour
|
||||
|
||||
|
||||
@Override
|
||||
public synchronized Class<?> getTargetClass() {
|
||||
if (this.targetClass == null && this.beanFactory != null) {
|
||||
// Determine type of the target bean.
|
||||
this.targetClass = this.beanFactory.getType(this.targetBeanName);
|
||||
if (this.targetClass == null) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Getting bean with name '" + this.targetBeanName + "' in order to determine type");
|
||||
}
|
||||
Object beanInstance = this.beanFactory.getBean(this.targetBeanName);
|
||||
if (beanInstance != null) {
|
||||
this.targetClass = beanInstance.getClass();
|
||||
}
|
||||
}
|
||||
public Class<?> getTargetClass() {
|
||||
Class<?> targetClass = this.targetClass;
|
||||
if (targetClass != null) {
|
||||
return targetClass;
|
||||
}
|
||||
synchronized (this) {
|
||||
// Full check within synchronization, entering the BeanFactory interaction algorithm only once...
|
||||
targetClass = this.targetClass;
|
||||
if (targetClass == null && this.beanFactory != null) {
|
||||
// Determine type of the target bean.
|
||||
targetClass = this.beanFactory.getType(this.targetBeanName);
|
||||
if (targetClass == null) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Getting bean with name '" + this.targetBeanName + "' for type determination");
|
||||
}
|
||||
Object beanInstance = this.beanFactory.getBean(this.targetBeanName);
|
||||
targetClass = beanInstance.getClass();
|
||||
}
|
||||
this.targetClass = targetClass;
|
||||
}
|
||||
return targetClass;
|
||||
}
|
||||
return this.targetClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -74,8 +74,8 @@ public abstract class AbstractPrototypeBasedTargetSource extends AbstractBeanFac
|
||||
* @param target the bean instance to destroy
|
||||
*/
|
||||
protected void destroyPrototypeInstance(Object target) {
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Destroying instance of bean '" + getTargetBeanName() + "'");
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Destroying instance of bean '" + getTargetBeanName() + "'");
|
||||
}
|
||||
if (getBeanFactory() instanceof ConfigurableBeanFactory) {
|
||||
((ConfigurableBeanFactory) getBeanFactory()).destroyBean(getTargetBeanName(), target);
|
||||
|
||||
+2
-2
@@ -44,7 +44,7 @@ import static org.junit.Assert.*;
|
||||
* @author Ramnivas Laddad
|
||||
* @since 2.0
|
||||
*/
|
||||
public final class MethodInvocationProceedingJoinPointTests {
|
||||
public class MethodInvocationProceedingJoinPointTests {
|
||||
|
||||
@Test
|
||||
public void testingBindingWithJoinPoint() {
|
||||
@@ -217,7 +217,7 @@ public final class MethodInvocationProceedingJoinPointTests {
|
||||
itb.unreliableFileOperation();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
// we don't realy care...
|
||||
// we don't really care...
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -37,26 +37,26 @@ import static org.junit.Assert.*;
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public final class ArgumentBindingTests {
|
||||
public class ArgumentBindingTests {
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testBindingInPointcutUsedByAdvice() {
|
||||
TestBean tb = new TestBean();
|
||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(tb);
|
||||
proxyFactory.addAspect(NamedPointcutWithArgs.class);
|
||||
|
||||
ITestBean proxiedTestBean = (ITestBean) proxyFactory.getProxy();
|
||||
proxiedTestBean.setName("Supercalifragalisticexpialidocious"); // should throw
|
||||
ITestBean proxiedTestBean = proxyFactory.getProxy();
|
||||
proxiedTestBean.setName("Supercalifragalisticexpialidocious");
|
||||
}
|
||||
|
||||
@Test(expected=IllegalStateException.class)
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testAnnotationArgumentNameBinding() {
|
||||
TransactionalBean tb = new TransactionalBean();
|
||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(tb);
|
||||
proxyFactory.addAspect(PointcutWithAnnotationArgument.class);
|
||||
|
||||
ITransactionalBean proxiedTestBean = (ITransactionalBean) proxyFactory.getProxy();
|
||||
proxiedTestBean.doInTransaction(); // should throw
|
||||
ITransactionalBean proxiedTestBean = proxyFactory.getProxy();
|
||||
proxiedTestBean.doInTransaction();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,6 +71,7 @@ public final class ArgumentBindingTests {
|
||||
assertEquals("formal", pnames[0]);
|
||||
}
|
||||
|
||||
|
||||
public void methodWithOneParam(String aParam) {
|
||||
}
|
||||
|
||||
@@ -100,9 +101,6 @@ public final class ArgumentBindingTests {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
@Aspect
|
||||
class PointcutWithAnnotationArgument {
|
||||
|
||||
@@ -115,9 +113,6 @@ class PointcutWithAnnotationArgument {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author Adrian Colyer
|
||||
*/
|
||||
@Aspect
|
||||
class NamedPointcutWithArgs {
|
||||
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2018 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,7 +47,7 @@ public final class ConcurrencyThrottleInterceptorTests {
|
||||
public void testSerializable() throws Exception {
|
||||
DerivedTestBean tb = new DerivedTestBean();
|
||||
ProxyFactory proxyFactory = new ProxyFactory();
|
||||
proxyFactory.setInterfaces(new Class[] {ITestBean.class});
|
||||
proxyFactory.setInterfaces(ITestBean.class);
|
||||
ConcurrencyThrottleInterceptor cti = new ConcurrencyThrottleInterceptor();
|
||||
proxyFactory.addAdvice(cti);
|
||||
proxyFactory.setTarget(tb);
|
||||
@@ -75,7 +75,7 @@ public final class ConcurrencyThrottleInterceptorTests {
|
||||
private void testMultipleThreads(int concurrencyLimit) {
|
||||
TestBean tb = new TestBean();
|
||||
ProxyFactory proxyFactory = new ProxyFactory();
|
||||
proxyFactory.setInterfaces(new Class[] {ITestBean.class});
|
||||
proxyFactory.setInterfaces(ITestBean.class);
|
||||
ConcurrencyThrottleInterceptor cti = new ConcurrencyThrottleInterceptor();
|
||||
cti.setConcurrencyLimit(concurrencyLimit);
|
||||
proxyFactory.addAdvice(cti);
|
||||
@@ -95,7 +95,7 @@ public final class ConcurrencyThrottleInterceptorTests {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
threads[i] = new ConcurrencyThread(proxy,
|
||||
i % 2 == 0 ? (Throwable) new OutOfMemoryError() : (Throwable) new IllegalStateException());
|
||||
i % 2 == 0 ? new OutOfMemoryError() : new IllegalStateException());
|
||||
threads[i].start();
|
||||
}
|
||||
for (int i = 0; i < NR_OF_THREADS; i++) {
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -83,7 +83,7 @@ public final class CustomizableTraceInterceptorTests {
|
||||
public void testSunnyDayPathLogsCorrectly() throws Throwable {
|
||||
|
||||
MethodInvocation methodInvocation = mock(MethodInvocation.class);
|
||||
given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString", new Class[]{}));
|
||||
given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString"));
|
||||
given(methodInvocation.getThis()).willReturn(this);
|
||||
|
||||
Log log = mock(Log.class);
|
||||
@@ -101,7 +101,7 @@ public final class CustomizableTraceInterceptorTests {
|
||||
MethodInvocation methodInvocation = mock(MethodInvocation.class);
|
||||
|
||||
IllegalArgumentException exception = new IllegalArgumentException();
|
||||
given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString", new Class[]{}));
|
||||
given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString"));
|
||||
given(methodInvocation.getThis()).willReturn(this);
|
||||
given(methodInvocation.proceed()).willThrow(exception);
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2018 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 @@ public final class SimpleTraceInterceptorTests {
|
||||
@Test
|
||||
public void testSunnyDayPathLogsCorrectly() throws Throwable {
|
||||
MethodInvocation mi = mock(MethodInvocation.class);
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[]{}));
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
|
||||
given(mi.getThis()).willReturn(this);
|
||||
|
||||
Log log = mock(Log.class);
|
||||
@@ -48,7 +48,7 @@ public final class SimpleTraceInterceptorTests {
|
||||
@Test
|
||||
public void testExceptionPathStillLogsCorrectly() throws Throwable {
|
||||
MethodInvocation mi = mock(MethodInvocation.class);
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[]{}));
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
|
||||
given(mi.getThis()).willReturn(this);
|
||||
IllegalArgumentException exception = new IllegalArgumentException();
|
||||
given(mi.proceed()).willThrow(exception);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// redefine the compileJava and compileTestJava tasks in order to
|
||||
// compile sources with ajc instead of javac
|
||||
// Redefine the compileJava and compileTestJava tasks in order to compile sources with ajc instead of javac
|
||||
|
||||
configurations {
|
||||
rt
|
||||
@@ -8,22 +7,14 @@ configurations {
|
||||
ajInpath
|
||||
}
|
||||
|
||||
// exclude spring-aspects as a module within IDEA until IDEA-64446 is resolved
|
||||
tasks.getByName("idea").onlyIf { false }
|
||||
tasks.getByName("ideaModule").onlyIf { false }
|
||||
|
||||
compileJava {
|
||||
actions = []
|
||||
dependsOn configurations.ajc.getTaskDependencyFromProjectDependency(true, "compileJava")
|
||||
|
||||
def outputDir = project.sourceSets.main.output.classesDir
|
||||
|
||||
inputs.files(project.sourceSets.main.allSource + project.sourceSets.main.compileClasspath)
|
||||
outputs.dir outputDir
|
||||
|
||||
ext.sourceCompatibility = project(":spring-core").compileJava.sourceCompatibility
|
||||
ext.targetCompatibility = project(":spring-core").compileJava.targetCompatibility
|
||||
|
||||
doLast{
|
||||
// Assemble runtime classpath from folders and JARs that actually exist
|
||||
def runtimeClasspath = project.files(sourceSets.main.runtimeClasspath.files.findAll({ it.exists() }))
|
||||
@@ -53,13 +44,9 @@ compileTestJava {
|
||||
dependsOn jar
|
||||
|
||||
def outputDir = project.sourceSets.test.output.classesDir
|
||||
|
||||
inputs.files(project.sourceSets.test.allSource + project.sourceSets.test.compileClasspath)
|
||||
outputs.dir outputDir
|
||||
|
||||
ext.sourceCompatibility = project(":spring-core").compileTestJava.sourceCompatibility
|
||||
ext.targetCompatibility = project(":spring-core").compileTestJava.targetCompatibility
|
||||
|
||||
doLast{
|
||||
// Assemble runtime classpath from folders and JARs that actually exist
|
||||
def runtimeClasspath = project.files(sourceSets.test.runtimeClasspath.files.findAll({ it.exists() }))
|
||||
|
||||
Vendored
+2
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,6 +34,7 @@ import org.springframework.context.annotation.Role;
|
||||
* @see org.springframework.cache.annotation.CachingConfigurationSelector
|
||||
*/
|
||||
@Configuration
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
public class AspectJCachingConfiguration extends AbstractCachingConfiguration {
|
||||
|
||||
@Bean(name = CacheManagementConfigUtils.CACHE_ASPECT_BEAN_NAME)
|
||||
|
||||
Vendored
+2
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,6 +34,7 @@ import org.springframework.context.annotation.Role;
|
||||
* @see org.springframework.cache.annotation.CachingConfigurationSelector
|
||||
*/
|
||||
@Configuration
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
public class AspectJJCacheConfiguration extends AbstractJCacheConfiguration {
|
||||
|
||||
@Bean(name = CacheManagementConfigUtils.JCACHE_ASPECT_BEAN_NAME)
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ import org.springframework.transaction.annotation.AnnotationTransactionAttribute
|
||||
* @see javax.transaction.Transactional
|
||||
* @see AnnotationTransactionAspect
|
||||
*/
|
||||
@RequiredTypes({"javax.transaction.Transactional"})
|
||||
@RequiredTypes("javax.transaction.Transactional")
|
||||
public aspect JtaAnnotationTransactionAspect extends AbstractTransactionAspect {
|
||||
|
||||
public JtaAnnotationTransactionAspect() {
|
||||
|
||||
+10
-13
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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,6 +237,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
|
||||
}
|
||||
|
||||
Closure beans = new Closure(this) {
|
||||
@Override
|
||||
public Object call(Object[] args) {
|
||||
invokeBeanDefiningClosure((Closure) args[0]);
|
||||
return null;
|
||||
@@ -380,10 +381,8 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
|
||||
refName = args[0].toString();
|
||||
}
|
||||
boolean parentRef = false;
|
||||
if (args.length > 1) {
|
||||
if (args[1] instanceof Boolean) {
|
||||
parentRef = (Boolean) args[1];
|
||||
}
|
||||
if (args.length > 1 && args[1] instanceof Boolean) {
|
||||
parentRef = (Boolean) args[1];
|
||||
}
|
||||
return new RuntimeBeanReference(refName, parentRef);
|
||||
}
|
||||
@@ -410,12 +409,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
|
||||
}
|
||||
|
||||
private boolean addDeferredProperty(String property, Object newValue) {
|
||||
if (newValue instanceof List) {
|
||||
this.deferredProperties.put(this.currentBeanDefinition.getBeanName() + '.' + property,
|
||||
new DeferredProperty(this.currentBeanDefinition, property, newValue));
|
||||
return true;
|
||||
}
|
||||
else if (newValue instanceof Map) {
|
||||
if (newValue instanceof List || newValue instanceof Map) {
|
||||
this.deferredProperties.put(this.currentBeanDefinition.getBeanName() + '.' + property,
|
||||
new DeferredProperty(this.currentBeanDefinition, property, newValue));
|
||||
return true;
|
||||
@@ -527,10 +521,10 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
|
||||
Closure callable = (Closure) args[args.length - 1];
|
||||
callable.setDelegate(this);
|
||||
callable.setResolveStrategy(Closure.DELEGATE_FIRST);
|
||||
callable.call(new Object[]{currentBeanDefinition});
|
||||
callable.call(this.currentBeanDefinition);
|
||||
}
|
||||
|
||||
GroovyBeanDefinitionWrapper beanDefinition = currentBeanDefinition;
|
||||
GroovyBeanDefinitionWrapper beanDefinition = this.currentBeanDefinition;
|
||||
this.currentBeanDefinition = null;
|
||||
beanDefinition.getBeanDefinition().setAttribute(GroovyBeanDefinitionWrapper.class.getName(), beanDefinition);
|
||||
getRegistry().registerBeanDefinition(beanName, beanDefinition.getBeanDefinition());
|
||||
@@ -818,14 +812,17 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object invokeMethod(String name, Object args) {
|
||||
return InvokerHelper.invokeMethod(this.propertyValue, name, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getProperty(String name) {
|
||||
return InvokerHelper.getProperty(this.propertyValue, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperty(String name, Object value) {
|
||||
InvokerHelper.setProperty(this.propertyValue, name, value);
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -162,6 +162,7 @@ class GroovyBeanDefinitionWrapper extends GroovyObjectSupport {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getProperty(String property) {
|
||||
if (this.definitionWrapper.isReadableProperty(property)) {
|
||||
return this.definitionWrapper.getPropertyValue(property);
|
||||
@@ -172,6 +173,7 @@ class GroovyBeanDefinitionWrapper extends GroovyObjectSupport {
|
||||
return super.getProperty(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperty(String property, Object newValue) {
|
||||
if (PARENT.equals(property)) {
|
||||
setParent(newValue);
|
||||
|
||||
+4
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -55,10 +55,10 @@ import org.springframework.util.StringUtils;
|
||||
* as String arrays are converted in such a format if the array itself is not
|
||||
* assignable.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
* @author Rob Harrop
|
||||
* @author Stephane Nicoll
|
||||
* @author Rod Johnson
|
||||
* @author Rob Harrop
|
||||
* @since 4.2
|
||||
* @see #registerCustomEditor
|
||||
* @see #setPropertyValues
|
||||
@@ -96,9 +96,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
|
||||
Object rootObject;
|
||||
|
||||
/**
|
||||
* Map with cached nested Accessors: nested path -> Accessor instance.
|
||||
*/
|
||||
/** Map with cached nested Accessors: nested path -> Accessor instance */
|
||||
private Map<String, AbstractNestablePropertyAccessor> nestedPropertyAccessors;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -311,23 +311,23 @@ public abstract class BeanUtils {
|
||||
public static Method resolveSignature(String signature, Class<?> clazz) {
|
||||
Assert.hasText(signature, "'signature' must not be empty");
|
||||
Assert.notNull(clazz, "Class must not be null");
|
||||
int firstParen = signature.indexOf("(");
|
||||
int lastParen = signature.indexOf(")");
|
||||
if (firstParen > -1 && lastParen == -1) {
|
||||
int startParen = signature.indexOf('(');
|
||||
int endParen = signature.indexOf(')');
|
||||
if (startParen > -1 && endParen == -1) {
|
||||
throw new IllegalArgumentException("Invalid method signature '" + signature +
|
||||
"': expected closing ')' for args list");
|
||||
}
|
||||
else if (lastParen > -1 && firstParen == -1) {
|
||||
else if (startParen == -1 && endParen > -1) {
|
||||
throw new IllegalArgumentException("Invalid method signature '" + signature +
|
||||
"': expected opening '(' for args list");
|
||||
}
|
||||
else if (firstParen == -1 && lastParen == -1) {
|
||||
else if (startParen == -1 && endParen == -1) {
|
||||
return findMethodWithMinimalParameters(clazz, signature);
|
||||
}
|
||||
else {
|
||||
String methodName = signature.substring(0, firstParen);
|
||||
String methodName = signature.substring(0, startParen);
|
||||
String[] parameterTypeNames =
|
||||
StringUtils.commaDelimitedListToStringArray(signature.substring(firstParen + 1, lastParen));
|
||||
StringUtils.commaDelimitedListToStringArray(signature.substring(startParen + 1, endParen));
|
||||
Class<?>[] parameterTypes = new Class<?>[parameterTypeNames.length];
|
||||
for (int i = 0; i < parameterTypeNames.length; i++) {
|
||||
String parameterTypeName = parameterTypeNames[i].trim();
|
||||
@@ -506,13 +506,14 @@ public abstract class BeanUtils {
|
||||
|
||||
/**
|
||||
* Check if the given type represents a "simple" value type:
|
||||
* a primitive, a String or other CharSequence, a Number, a Date,
|
||||
* a primitive, an enum, a String or other CharSequence, a Number, a Date,
|
||||
* a URI, a URL, a Locale or a Class.
|
||||
* @param clazz the type to check
|
||||
* @return whether the given type represents a "simple" value type
|
||||
*/
|
||||
public static boolean isSimpleValueType(Class<?> clazz) {
|
||||
return (ClassUtils.isPrimitiveOrWrapper(clazz) || clazz.isEnum() ||
|
||||
return (ClassUtils.isPrimitiveOrWrapper(clazz) ||
|
||||
Enum.class.isAssignableFrom(clazz) ||
|
||||
CharSequence.class.isAssignableFrom(clazz) ||
|
||||
Number.class.isAssignableFrom(clazz) ||
|
||||
Date.class.isAssignableFrom(clazz) ||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -224,10 +224,7 @@ public class BeanWrapperImpl extends AbstractNestablePropertyAccessor implements
|
||||
@Override
|
||||
protected BeanPropertyHandler getLocalPropertyHandler(String propertyName) {
|
||||
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(propertyName);
|
||||
if (pd != null) {
|
||||
return new BeanPropertyHandler(pd);
|
||||
}
|
||||
return null;
|
||||
return (pd != null ? new BeanPropertyHandler(pd) : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -238,8 +235,7 @@ public class BeanWrapperImpl extends AbstractNestablePropertyAccessor implements
|
||||
@Override
|
||||
protected NotWritablePropertyException createNotWritablePropertyException(String propertyName) {
|
||||
PropertyMatches matches = PropertyMatches.forProperty(propertyName, getRootClass());
|
||||
throw new NotWritablePropertyException(
|
||||
getRootClass(), getNestedPath() + propertyName,
|
||||
throw new NotWritablePropertyException(getRootClass(), getNestedPath() + propertyName,
|
||||
matches.buildErrorMessage(), matches.getPossibleMatches());
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -339,10 +339,10 @@ public class CachedIntrospectionResults {
|
||||
PropertyDescriptor getPropertyDescriptor(String name) {
|
||||
PropertyDescriptor pd = this.propertyDescriptorCache.get(name);
|
||||
if (pd == null && StringUtils.hasLength(name)) {
|
||||
// Same lenient fallback checking as in PropertyTypeDescriptor...
|
||||
pd = this.propertyDescriptorCache.get(name.substring(0, 1).toLowerCase() + name.substring(1));
|
||||
// Same lenient fallback checking as in Property...
|
||||
pd = this.propertyDescriptorCache.get(StringUtils.uncapitalize(name));
|
||||
if (pd == null) {
|
||||
pd = this.propertyDescriptorCache.get(name.substring(0, 1).toUpperCase() + name.substring(1));
|
||||
pd = this.propertyDescriptorCache.get(StringUtils.capitalize(name));
|
||||
}
|
||||
}
|
||||
return (pd == null || pd instanceof GenericTypeAwarePropertyDescriptor ? pd :
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -76,8 +76,8 @@ public class DirectFieldAccessor extends AbstractNestablePropertyAccessor {
|
||||
Field field = ReflectionUtils.findField(getWrappedClass(), propertyName);
|
||||
if (field != null) {
|
||||
propertyHandler = new FieldPropertyHandler(field);
|
||||
this.fieldMap.put(propertyName, propertyHandler);
|
||||
}
|
||||
this.fieldMap.put(propertyName, propertyHandler);
|
||||
}
|
||||
return propertyHandler;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -41,7 +41,7 @@ public interface Mergeable {
|
||||
* @param parent the object to merge with
|
||||
* @return the result of the merge operation
|
||||
* @throws IllegalArgumentException if the supplied parent is {@code null}
|
||||
* @exception IllegalStateException if merging is not enabled for this instance
|
||||
* @throws IllegalStateException if merging is not enabled for this instance
|
||||
* (i.e. {@code mergeEnabled} equals {@code false}).
|
||||
*/
|
||||
Object merge(Object parent);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -262,7 +262,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable {
|
||||
/**
|
||||
* Get the raw property value, if any.
|
||||
* @param propertyName the name to search for
|
||||
* @return the raw property value, or {@code null}
|
||||
* @return the raw property value, or {@code null} if none found
|
||||
* @since 4.0
|
||||
* @see #getPropertyValue(String)
|
||||
* @see PropertyValue#getValue()
|
||||
@@ -283,11 +283,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable {
|
||||
for (PropertyValue newPv : this.propertyValueList) {
|
||||
// if there wasn't an old one, add it
|
||||
PropertyValue pvOld = old.getPropertyValue(newPv.getName());
|
||||
if (pvOld == null) {
|
||||
changes.addPropertyValue(newPv);
|
||||
}
|
||||
else if (!pvOld.equals(newPv)) {
|
||||
// it's changed
|
||||
if (pvOld == null || !pvOld.equals(newPv)) {
|
||||
changes.addPropertyValue(newPv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -81,8 +81,6 @@ public interface PropertyAccessor {
|
||||
* (may be a nested path and/or an indexed/mapped property)
|
||||
* @return the property type for the particular property,
|
||||
* or {@code null} if not determinable
|
||||
* @throws InvalidPropertyException if there is no such property or
|
||||
* if the property isn't readable
|
||||
* @throws PropertyAccessException if the property was valid but the
|
||||
* accessor method failed
|
||||
*/
|
||||
@@ -95,8 +93,8 @@ public interface PropertyAccessor {
|
||||
* (may be a nested path and/or an indexed/mapped property)
|
||||
* @return the property type for the particular property,
|
||||
* or {@code null} if not determinable
|
||||
* @throws InvalidPropertyException if there is no such property or
|
||||
* if the property isn't readable
|
||||
* @throws PropertyAccessException if the property was valid but the
|
||||
* accessor method failed
|
||||
*/
|
||||
TypeDescriptor getPropertyTypeDescriptor(String propertyName) throws BeansException;
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class PropertyDescriptorUtils {
|
||||
}
|
||||
|
||||
if (writeMethod != null) {
|
||||
Class<?> params[] = writeMethod.getParameterTypes();
|
||||
Class<?>[] params = writeMethod.getParameterTypes();
|
||||
if (params.length != 1) {
|
||||
throw new IntrospectionException("Bad write method arg count: " + writeMethod);
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class PropertyDescriptorUtils {
|
||||
Class<?> indexedPropertyType = null;
|
||||
|
||||
if (indexedReadMethod != null) {
|
||||
Class<?> params[] = indexedReadMethod.getParameterTypes();
|
||||
Class<?>[] params = indexedReadMethod.getParameterTypes();
|
||||
if (params.length != 1) {
|
||||
throw new IntrospectionException("Bad indexed read method arg count: " + indexedReadMethod);
|
||||
}
|
||||
@@ -123,7 +123,7 @@ class PropertyDescriptorUtils {
|
||||
}
|
||||
|
||||
if (indexedWriteMethod != null) {
|
||||
Class<?> params[] = indexedWriteMethod.getParameterTypes();
|
||||
Class<?>[] params = indexedWriteMethod.getParameterTypes();
|
||||
if (params.length != 2) {
|
||||
throw new IntrospectionException("Bad indexed write method arg count: " + indexedWriteMethod);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -156,8 +156,8 @@ public abstract class PropertyMatches {
|
||||
if (s2.isEmpty()) {
|
||||
return s1.length();
|
||||
}
|
||||
int d[][] = new int[s1.length() + 1][s2.length() + 1];
|
||||
|
||||
int[][] d = new int[s1.length() + 1][s2.length() + 1];
|
||||
for (int i = 0; i <= s1.length(); i++) {
|
||||
d[i][0] = i;
|
||||
}
|
||||
@@ -166,18 +166,17 @@ public abstract class PropertyMatches {
|
||||
}
|
||||
|
||||
for (int i = 1; i <= s1.length(); i++) {
|
||||
char s_i = s1.charAt(i - 1);
|
||||
char c1 = s1.charAt(i - 1);
|
||||
for (int j = 1; j <= s2.length(); j++) {
|
||||
int cost;
|
||||
char t_j = s2.charAt(j - 1);
|
||||
if (s_i == t_j) {
|
||||
char c2 = s2.charAt(j - 1);
|
||||
if (c1 == c2) {
|
||||
cost = 0;
|
||||
}
|
||||
else {
|
||||
cost = 1;
|
||||
}
|
||||
d[i][j] = Math.min(Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1),
|
||||
d[i - 1][j - 1] + cost);
|
||||
d[i][j] = Math.min(Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1), d[i - 1][j - 1] + cost);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,24 +189,23 @@ public abstract class PropertyMatches {
|
||||
private static class BeanPropertyMatches extends PropertyMatches {
|
||||
|
||||
public BeanPropertyMatches(String propertyName, Class<?> beanClass, int maxDistance) {
|
||||
super(propertyName, calculateMatches(propertyName,
|
||||
BeanUtils.getPropertyDescriptors(beanClass), maxDistance));
|
||||
super(propertyName,
|
||||
calculateMatches(propertyName, BeanUtils.getPropertyDescriptors(beanClass), maxDistance));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate possible property alternatives for the given property and
|
||||
* class. Internally uses the {@code getStringDistance} method, which
|
||||
* in turn uses the Levenshtein algorithm to determine the distance between
|
||||
* two Strings.
|
||||
* @param propertyDescriptors the JavaBeans property descriptors to search
|
||||
* Generate possible property alternatives for the given property and class.
|
||||
* Internally uses the {@code getStringDistance} method, which in turn uses
|
||||
* the Levenshtein algorithm to determine the distance between two Strings.
|
||||
* @param descriptors the JavaBeans property descriptors to search
|
||||
* @param maxDistance the maximum distance to accept
|
||||
*/
|
||||
private static String[] calculateMatches(String propertyName, PropertyDescriptor[] propertyDescriptors, int maxDistance) {
|
||||
private static String[] calculateMatches(String name, PropertyDescriptor[] descriptors, int maxDistance) {
|
||||
List<String> candidates = new ArrayList<String>();
|
||||
for (PropertyDescriptor pd : propertyDescriptors) {
|
||||
for (PropertyDescriptor pd : descriptors) {
|
||||
if (pd.getWriteMethod() != null) {
|
||||
String possibleAlternative = pd.getName();
|
||||
if (calculateStringDistance(propertyName, possibleAlternative) <= maxDistance) {
|
||||
if (calculateStringDistance(name, possibleAlternative) <= maxDistance) {
|
||||
candidates.add(possibleAlternative);
|
||||
}
|
||||
}
|
||||
@@ -216,21 +214,16 @@ public abstract class PropertyMatches {
|
||||
return StringUtils.toStringArray(candidates);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String buildErrorMessage() {
|
||||
String propertyName = getPropertyName();
|
||||
String[] possibleMatches = getPossibleMatches();
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("Bean property '");
|
||||
msg.append(propertyName);
|
||||
msg.append("' is not writable or has an invalid setter method. ");
|
||||
|
||||
if (ObjectUtils.isEmpty(possibleMatches)) {
|
||||
msg.append("Does the parameter type of the setter match the return type of the getter?");
|
||||
StringBuilder msg = new StringBuilder(160);
|
||||
msg.append("Bean property '").append(getPropertyName()).append(
|
||||
"' is not writable or has an invalid setter method. ");
|
||||
if (!ObjectUtils.isEmpty(getPossibleMatches())) {
|
||||
appendHintMessage(msg);
|
||||
}
|
||||
else {
|
||||
appendHintMessage(msg);
|
||||
msg.append("Does the parameter type of the setter match the return type of the getter?");
|
||||
}
|
||||
return msg.toString();
|
||||
}
|
||||
@@ -243,13 +236,13 @@ public abstract class PropertyMatches {
|
||||
super(propertyName, calculateMatches(propertyName, beanClass, maxDistance));
|
||||
}
|
||||
|
||||
private static String[] calculateMatches(final String propertyName, Class<?> beanClass, final int maxDistance) {
|
||||
private static String[] calculateMatches(final String name, Class<?> clazz, final int maxDistance) {
|
||||
final List<String> candidates = new ArrayList<String>();
|
||||
ReflectionUtils.doWithFields(beanClass, new ReflectionUtils.FieldCallback() {
|
||||
ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
|
||||
@Override
|
||||
public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
|
||||
String possibleAlternative = field.getName();
|
||||
if (calculateStringDistance(propertyName, possibleAlternative) <= maxDistance) {
|
||||
if (calculateStringDistance(name, possibleAlternative) <= maxDistance) {
|
||||
candidates.add(possibleAlternative);
|
||||
}
|
||||
}
|
||||
@@ -260,14 +253,10 @@ public abstract class PropertyMatches {
|
||||
|
||||
@Override
|
||||
public String buildErrorMessage() {
|
||||
String propertyName = getPropertyName();
|
||||
String[] possibleMatches = getPossibleMatches();
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("Bean property '");
|
||||
msg.append(propertyName);
|
||||
msg.append("' has no matching field. ");
|
||||
|
||||
if (!ObjectUtils.isEmpty(possibleMatches)) {
|
||||
StringBuilder msg = new StringBuilder(80);
|
||||
msg.append("Bean property '").append(getPropertyName()).append("' has no matching field.");
|
||||
if (!ObjectUtils.isEmpty(getPossibleMatches())) {
|
||||
msg.append(' ');
|
||||
appendHintMessage(msg);
|
||||
}
|
||||
return msg.toString();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -35,6 +35,7 @@ import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.NumberUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -324,7 +325,7 @@ class TypeConverterDelegate {
|
||||
|
||||
if (Enum.class == requiredType) {
|
||||
// target type is declared as raw enum, treat the trimmed value as <enum.fqn>.FIELD_NAME
|
||||
int index = trimmedValue.lastIndexOf(".");
|
||||
int index = trimmedValue.lastIndexOf('.');
|
||||
if (index > - 1) {
|
||||
String enumType = trimmedValue.substring(0, index);
|
||||
String fieldName = trimmedValue.substring(index + 1);
|
||||
@@ -353,6 +354,7 @@ class TypeConverterDelegate {
|
||||
// to be checked, hence we don't return it right away.
|
||||
try {
|
||||
Field enumField = requiredType.getField(trimmedValue);
|
||||
ReflectionUtils.makeAccessible(enumField);
|
||||
convertedValue = enumField.get(null);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -41,7 +41,7 @@ public class TypeMismatchException extends PropertyAccessException {
|
||||
|
||||
|
||||
/**
|
||||
* Create a new TypeMismatchException.
|
||||
* Create a new {@code TypeMismatchException}.
|
||||
* @param propertyChangeEvent the PropertyChangeEvent that resulted in the problem
|
||||
* @param requiredType the required target type
|
||||
*/
|
||||
@@ -50,7 +50,7 @@ public class TypeMismatchException extends PropertyAccessException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new TypeMismatchException.
|
||||
* Create a new {@code TypeMismatchException}.
|
||||
* @param propertyChangeEvent the PropertyChangeEvent that resulted in the problem
|
||||
* @param requiredType the required target type (or {@code null} if not known)
|
||||
* @param cause the root cause (may be {@code null})
|
||||
@@ -69,7 +69,7 @@ public class TypeMismatchException extends PropertyAccessException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new TypeMismatchException without PropertyChangeEvent.
|
||||
* Create a new {@code TypeMismatchException} without a {@code PropertyChangeEvent}.
|
||||
* @param value the offending value that couldn't be converted (may be {@code null})
|
||||
* @param requiredType the required target type (or {@code null} if not known)
|
||||
*/
|
||||
@@ -78,7 +78,7 @@ public class TypeMismatchException extends PropertyAccessException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new TypeMismatchException without PropertyChangeEvent.
|
||||
* Create a new {@code TypeMismatchException} without a {@code PropertyChangeEvent}.
|
||||
* @param value the offending value that couldn't be converted (may be {@code null})
|
||||
* @param requiredType the required target type (or {@code null} if not known)
|
||||
* @param cause the root cause (may be {@code null})
|
||||
|
||||
+7
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -75,7 +75,7 @@ public class BeanDefinitionStoreException extends FatalBeanException {
|
||||
/**
|
||||
* Create a new BeanDefinitionStoreException.
|
||||
* @param resourceDescription description of the resource that the bean definition came from
|
||||
* @param beanName the name of the bean requested
|
||||
* @param beanName the name of the bean
|
||||
* @param msg the detail message (appended to an introductory message that indicates
|
||||
* the resource and the name of the bean)
|
||||
*/
|
||||
@@ -86,28 +86,28 @@ public class BeanDefinitionStoreException extends FatalBeanException {
|
||||
/**
|
||||
* Create a new BeanDefinitionStoreException.
|
||||
* @param resourceDescription description of the resource that the bean definition came from
|
||||
* @param beanName the name of the bean requested
|
||||
* @param beanName the name of the bean
|
||||
* @param msg the detail message (appended to an introductory message that indicates
|
||||
* the resource and the name of the bean)
|
||||
* @param cause the root cause (may be {@code null})
|
||||
*/
|
||||
public BeanDefinitionStoreException(String resourceDescription, String beanName, String msg, Throwable cause) {
|
||||
super("Invalid bean definition with name '" + beanName + "' defined in " + resourceDescription + ": " + msg, cause);
|
||||
super("Invalid bean definition with name '" + beanName + "' defined in " + resourceDescription + ": " + msg,
|
||||
cause);
|
||||
this.resourceDescription = resourceDescription;
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the description of the resource that the bean
|
||||
* definition came from, if any.
|
||||
* Return the description of the resource that the bean definition came from, if available.
|
||||
*/
|
||||
public String getResourceDescription() {
|
||||
return this.resourceDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the bean requested, if any.
|
||||
* Return the name of the bean, if available.
|
||||
*/
|
||||
public String getBeanName() {
|
||||
return this.beanName;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -158,6 +158,22 @@ public interface BeanFactory {
|
||||
*/
|
||||
<T> T getBean(String name, Class<T> requiredType) throws BeansException;
|
||||
|
||||
/**
|
||||
* Return an instance, which may be shared or independent, of the specified bean.
|
||||
* <p>Allows for specifying explicit constructor arguments / factory method arguments,
|
||||
* overriding the specified default arguments (if any) in the bean definition.
|
||||
* @param name the name of the bean to retrieve
|
||||
* @param args arguments to use when creating a bean instance using explicit arguments
|
||||
* (only applied when creating a new instance as opposed to retrieving an existing one)
|
||||
* @return an instance of the bean
|
||||
* @throws NoSuchBeanDefinitionException if there is no such bean definition
|
||||
* @throws BeanDefinitionStoreException if arguments have been given but
|
||||
* the affected bean isn't a prototype
|
||||
* @throws BeansException if the bean could not be created
|
||||
* @since 2.5
|
||||
*/
|
||||
Object getBean(String name, Object... args) throws BeansException;
|
||||
|
||||
/**
|
||||
* Return the bean instance that uniquely matches the given object type, if any.
|
||||
* <p>This method goes into {@link ListableBeanFactory} by-type lookup territory
|
||||
@@ -175,22 +191,6 @@ public interface BeanFactory {
|
||||
*/
|
||||
<T> T getBean(Class<T> requiredType) throws BeansException;
|
||||
|
||||
/**
|
||||
* Return an instance, which may be shared or independent, of the specified bean.
|
||||
* <p>Allows for specifying explicit constructor arguments / factory method arguments,
|
||||
* overriding the specified default arguments (if any) in the bean definition.
|
||||
* @param name the name of the bean to retrieve
|
||||
* @param args arguments to use when creating a bean instance using explicit arguments
|
||||
* (only applied when creating a new instance as opposed to retrieving an existing one)
|
||||
* @return an instance of the bean
|
||||
* @throws NoSuchBeanDefinitionException if there is no such bean definition
|
||||
* @throws BeanDefinitionStoreException if arguments have been given but
|
||||
* the affected bean isn't a prototype
|
||||
* @throws BeansException if the bean could not be created
|
||||
* @since 2.5
|
||||
*/
|
||||
Object getBean(String name, Object... args) throws BeansException;
|
||||
|
||||
/**
|
||||
* Return an instance, which may be shared or independent, of the specified bean.
|
||||
* <p>Allows for specifying explicit constructor arguments / factory method arguments,
|
||||
|
||||
+30
-28
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -147,14 +147,7 @@ public abstract class BeanFactoryUtils {
|
||||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||
String[] parentResult = beanNamesForTypeIncludingAncestors(
|
||||
(ListableBeanFactory) hbf.getParentBeanFactory(), type);
|
||||
List<String> resultList = new ArrayList<String>();
|
||||
resultList.addAll(Arrays.asList(result));
|
||||
for (String beanName : parentResult) {
|
||||
if (!resultList.contains(beanName) && !hbf.containsLocalBean(beanName)) {
|
||||
resultList.add(beanName);
|
||||
}
|
||||
}
|
||||
result = StringUtils.toStringArray(resultList);
|
||||
result = mergeNamesWithParent(result, parentResult, hbf);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -180,14 +173,7 @@ public abstract class BeanFactoryUtils {
|
||||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||
String[] parentResult = beanNamesForTypeIncludingAncestors(
|
||||
(ListableBeanFactory) hbf.getParentBeanFactory(), type);
|
||||
List<String> resultList = new ArrayList<String>();
|
||||
resultList.addAll(Arrays.asList(result));
|
||||
for (String beanName : parentResult) {
|
||||
if (!resultList.contains(beanName) && !hbf.containsLocalBean(beanName)) {
|
||||
resultList.add(beanName);
|
||||
}
|
||||
}
|
||||
result = StringUtils.toStringArray(resultList);
|
||||
result = mergeNamesWithParent(result, parentResult, hbf);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -223,14 +209,7 @@ public abstract class BeanFactoryUtils {
|
||||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||
String[] parentResult = beanNamesForTypeIncludingAncestors(
|
||||
(ListableBeanFactory) hbf.getParentBeanFactory(), type, includeNonSingletons, allowEagerInit);
|
||||
List<String> resultList = new ArrayList<String>();
|
||||
resultList.addAll(Arrays.asList(result));
|
||||
for (String beanName : parentResult) {
|
||||
if (!resultList.contains(beanName) && !hbf.containsLocalBean(beanName)) {
|
||||
resultList.add(beanName);
|
||||
}
|
||||
}
|
||||
result = StringUtils.toStringArray(resultList);
|
||||
result = mergeNamesWithParent(result, parentResult, hbf);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -446,6 +425,29 @@ public abstract class BeanFactoryUtils {
|
||||
return uniqueBean(type, beansOfType);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Merge the given bean names result with the given parent result.
|
||||
* @param result the local bean name result
|
||||
* @param parentResult the parent bean name result (possibly empty)
|
||||
* @param hbf the local bean factory
|
||||
* @return the merged result (possibly the local result as-is)
|
||||
* @since 4.3.15
|
||||
*/
|
||||
private static String[] mergeNamesWithParent(String[] result, String[] parentResult, HierarchicalBeanFactory hbf) {
|
||||
if (parentResult.length == 0) {
|
||||
return result;
|
||||
}
|
||||
List<String> merged = new ArrayList<String>(result.length + parentResult.length);
|
||||
merged.addAll(Arrays.asList(result));
|
||||
for (String beanName : parentResult) {
|
||||
if (!merged.contains(beanName) && !hbf.containsLocalBean(beanName)) {
|
||||
merged.add(beanName);
|
||||
}
|
||||
}
|
||||
return StringUtils.toStringArray(merged);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a unique bean for the given type from the given Map of matching beans.
|
||||
* @param type type of bean to match
|
||||
@@ -455,11 +457,11 @@ public abstract class BeanFactoryUtils {
|
||||
* @throws NoUniqueBeanDefinitionException if more than one bean of the given type was found
|
||||
*/
|
||||
private static <T> T uniqueBean(Class<T> type, Map<String, T> matchingBeans) {
|
||||
int nrFound = matchingBeans.size();
|
||||
if (nrFound == 1) {
|
||||
int count = matchingBeans.size();
|
||||
if (count == 1) {
|
||||
return matchingBeans.values().iterator().next();
|
||||
}
|
||||
else if (nrFound > 1) {
|
||||
else if (count > 1) {
|
||||
throw new NoUniqueBeanDefinitionException(type, matchingBeans.keySet());
|
||||
}
|
||||
else {
|
||||
|
||||
+6
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,8 +46,8 @@ public class CannotLoadBeanClassException extends FatalBeanException {
|
||||
public CannotLoadBeanClassException(
|
||||
String resourceDescription, String beanName, String beanClassName, ClassNotFoundException cause) {
|
||||
|
||||
super("Cannot find class [" + beanClassName + "] for bean with name '" + beanName +
|
||||
"' defined in " + resourceDescription, cause);
|
||||
super("Cannot find class [" + beanClassName + "] for bean with name '" + beanName + "'" +
|
||||
(resourceDescription != null ? " defined in " + resourceDescription : ""), cause);
|
||||
this.resourceDescription = resourceDescription;
|
||||
this.beanName = beanName;
|
||||
this.beanClassName = beanClassName;
|
||||
@@ -64,8 +64,9 @@ public class CannotLoadBeanClassException extends FatalBeanException {
|
||||
public CannotLoadBeanClassException(
|
||||
String resourceDescription, String beanName, String beanClassName, LinkageError cause) {
|
||||
|
||||
super("Error loading class [" + beanClassName + "] for bean with name '" + beanName +
|
||||
"' defined in " + resourceDescription + ": problem with class file or dependent class", cause);
|
||||
super("Error loading class [" + beanClassName + "] for bean with name '" + beanName + "'" +
|
||||
(resourceDescription != null ? " defined in " + resourceDescription : "") +
|
||||
": problem with class file or dependent class", cause);
|
||||
this.resourceDescription = resourceDescription;
|
||||
this.beanName = beanName;
|
||||
this.beanClassName = beanClassName;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,27 +17,29 @@
|
||||
package org.springframework.beans.factory;
|
||||
|
||||
/**
|
||||
* Interface to be implemented by beans that want to release resources
|
||||
* on destruction. A BeanFactory is supposed to invoke the destroy
|
||||
* method if it disposes a cached singleton. An application context
|
||||
* is supposed to dispose all of its singletons on close.
|
||||
* Interface to be implemented by beans that want to release resources on destruction.
|
||||
* A {@link BeanFactory} will invoke the destroy method on individual destruction of a
|
||||
* scoped bean. An {@link org.springframework.context.ApplicationContext} is supposed
|
||||
* to dispose all of its singletons on shutdown, driven by the application lifecycle.
|
||||
*
|
||||
* <p>An alternative to implementing DisposableBean is specifying a custom
|
||||
* destroy-method, for example in an XML bean definition.
|
||||
* For a list of all bean lifecycle methods, see the BeanFactory javadocs.
|
||||
* <p>A Spring-managed bean may also implement Java's {@link AutoCloseable} interface
|
||||
* for the same purpose. An alternative to implementing an interface is specifying a
|
||||
* custom destroy method, for example in an XML bean definition. For a list of all
|
||||
* bean lifecycle methods, see the {@link BeanFactory BeanFactory javadocs}.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 12.08.2003
|
||||
* @see org.springframework.beans.factory.support.RootBeanDefinition#getDestroyMethodName
|
||||
* @see org.springframework.context.ConfigurableApplicationContext#close
|
||||
* @see InitializingBean
|
||||
* @see org.springframework.beans.factory.support.RootBeanDefinition#getDestroyMethodName()
|
||||
* @see org.springframework.beans.factory.config.ConfigurableBeanFactory#destroySingletons()
|
||||
* @see org.springframework.context.ConfigurableApplicationContext#close()
|
||||
*/
|
||||
public interface DisposableBean {
|
||||
|
||||
/**
|
||||
* Invoked by a BeanFactory on destruction of a singleton.
|
||||
* @throws Exception in case of shutdown errors.
|
||||
* Exceptions will get logged but not rethrown to allow
|
||||
* other beans to release their resources too.
|
||||
* Invoked by the containing {@code BeanFactory} on destruction of a bean.
|
||||
* @throws Exception in case of shutdown errors. Exceptions will get logged
|
||||
* but not rethrown to allow other beans to release their resources as well.
|
||||
*/
|
||||
void destroy() throws Exception;
|
||||
|
||||
|
||||
+17
-19
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,31 +17,29 @@
|
||||
package org.springframework.beans.factory;
|
||||
|
||||
/**
|
||||
* Interface to be implemented by beans that need to react once all their
|
||||
* properties have been set by a BeanFactory: for example, to perform custom
|
||||
* initialization, or merely to check that all mandatory properties have been set.
|
||||
* Interface to be implemented by beans that need to react once all their properties
|
||||
* have been set by a {@link BeanFactory}: e.g. to perform custom initialization,
|
||||
* or merely to check that all mandatory properties have been set.
|
||||
*
|
||||
* <p>An alternative to implementing InitializingBean is specifying a custom
|
||||
* init-method, for example in an XML bean definition.
|
||||
* For a list of all bean lifecycle methods, see the BeanFactory javadocs.
|
||||
* <p>An alternative to implementing {@code InitializingBean} is specifying a custom
|
||||
* init method, for example in an XML bean definition. For a list of all bean
|
||||
* lifecycle methods, see the {@link BeanFactory BeanFactory javadocs}.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @see BeanNameAware
|
||||
* @see BeanFactoryAware
|
||||
* @see BeanFactory
|
||||
* @see org.springframework.beans.factory.support.RootBeanDefinition#getInitMethodName
|
||||
* @see org.springframework.context.ApplicationContextAware
|
||||
* @author Juergen Hoeller
|
||||
* @see DisposableBean
|
||||
* @see org.springframework.beans.factory.config.BeanDefinition#getPropertyValues()
|
||||
* @see org.springframework.beans.factory.support.AbstractBeanDefinition#getInitMethodName()
|
||||
*/
|
||||
public interface InitializingBean {
|
||||
|
||||
/**
|
||||
* Invoked by a BeanFactory after it has set all bean properties supplied
|
||||
* (and satisfied BeanFactoryAware and ApplicationContextAware).
|
||||
* <p>This method allows the bean instance to perform initialization only
|
||||
* possible when all bean properties have been set and to throw an
|
||||
* exception in the event of misconfiguration.
|
||||
* @throws Exception in the event of misconfiguration (such
|
||||
* as failure to set an essential property) or if initialization fails.
|
||||
* Invoked by the containing {@code BeanFactory} after it has set all bean properties
|
||||
* and satisfied {@link BeanFactoryAware}, {@code ApplicationContextAware} etc.
|
||||
* <p>This method allows the bean instance to perform validation of its overall
|
||||
* configuration and final initialization when all bean properties have been set.
|
||||
* @throws Exception in the event of misconfiguration (such as failure to set an
|
||||
* essential property) or if initialization fails for any other reason
|
||||
*/
|
||||
void afterPropertiesSet() throws Exception;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -111,6 +111,17 @@ public class InjectionPoint {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a field/parameter annotation of the given type, if any.
|
||||
* @param annotationType the annotation type to retrieve
|
||||
* @return the annotation instance, or {@code null} if none found
|
||||
* @since 4.3.9
|
||||
*/
|
||||
public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
|
||||
return (this.field != null ? this.field.getAnnotation(annotationType) :
|
||||
this.methodParameter.getParameterAnnotation(annotationType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the type declared by the underlying field or method/constructor parameter,
|
||||
* indicating the injection type.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,7 +40,7 @@ public interface ObjectFactory<T> {
|
||||
/**
|
||||
* Return an instance (possibly shared or independent)
|
||||
* of the object managed by this factory.
|
||||
* @return an instance of the bean (should never be {@code null})
|
||||
* @return the resulting instance
|
||||
* @throws BeansException in case of creation errors
|
||||
*/
|
||||
T getObject() throws BeansException;
|
||||
|
||||
+23
-19
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,29 +23,33 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Marks a constructor, field, setter method or config method as to be
|
||||
* autowired by Spring's dependency injection facilities.
|
||||
* Marks a constructor, field, setter method or config method as to be autowired
|
||||
* by Spring's dependency injection facilities.
|
||||
*
|
||||
* <p>Only one constructor (at max) of any given bean class may carry this
|
||||
* annotation, indicating the constructor to autowire when used as a Spring
|
||||
* bean. Such a constructor does not have to be public.
|
||||
* <p>Only one constructor (at max) of any given bean class may carry this annotation,
|
||||
* indicating the constructor to autowire when used as a Spring bean. Such a
|
||||
* constructor does not have to be public.
|
||||
*
|
||||
* <p>Fields are injected right after construction of a bean, before any
|
||||
* config methods are invoked. Such a config field does not have to be public.
|
||||
* <p>Fields are injected right after construction of a bean, before any config
|
||||
* methods are invoked. Such a config field does not have to be public.
|
||||
*
|
||||
* <p>Config methods may have an arbitrary name and any number of arguments;
|
||||
* each of those arguments will be autowired with a matching bean in the
|
||||
* Spring container. Bean property setter methods are effectively just
|
||||
* a special case of such a general config method. Such config methods
|
||||
* do not have to be public.
|
||||
* <p>Config methods may have an arbitrary name and any number of arguments; each of
|
||||
* those arguments will be autowired with a matching bean in the Spring container.
|
||||
* Bean property setter methods are effectively just a special case of such a general
|
||||
* config method. Such config methods do not have to be public.
|
||||
*
|
||||
* <p>In the case of multiple argument methods, the 'required' parameter is
|
||||
* applicable for all arguments.
|
||||
* <p>In the case of a multi-arg constructor or method, the 'required' parameter is
|
||||
* applicable to all arguments. Individual parameters may be declared as Java-8-style
|
||||
* {@link java.util.Optional}, overriding the base required semantics.
|
||||
*
|
||||
* <p>In case of a {@link java.util.Collection} or {@link java.util.Map}
|
||||
* dependency type, the container will autowire all beans matching the
|
||||
* declared value type. In case of a Map, the keys must be declared as
|
||||
* type String and will be resolved to the corresponding bean names.
|
||||
* <p>In case of a {@link java.util.Collection} or {@link java.util.Map} dependency type,
|
||||
* the container autowires all beans matching the declared value type. For such purposes,
|
||||
* the map keys must be declared as type String which will be resolved to the corresponding
|
||||
* bean names. Such a container-provided collection will be ordered, taking into account
|
||||
* {@link org.springframework.core.Ordered}/{@link org.springframework.core.annotation.Order}
|
||||
* values of the target components, otherwise following their registration order in the
|
||||
* container. Alternatively, a single matching target bean may also be a generally typed
|
||||
* {@code Collection} or {@code Map} itself, getting injected as such.
|
||||
*
|
||||
* <p>Note that actual injection is performed through a
|
||||
* {@link org.springframework.beans.factory.config.BeanPostProcessor
|
||||
|
||||
+7
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -120,7 +120,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private final Set<Class<? extends Annotation>> autowiredAnnotationTypes =
|
||||
new LinkedHashSet<Class<? extends Annotation>>();
|
||||
new LinkedHashSet<Class<? extends Annotation>>(4);
|
||||
|
||||
private String requiredParameterName = "required";
|
||||
|
||||
@@ -484,7 +484,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
}
|
||||
|
||||
private AnnotationAttributes findAutowiredAnnotation(AccessibleObject ao) {
|
||||
if (ao.getAnnotations().length > 0) {
|
||||
if (ao.getAnnotations().length > 0) { // autowiring annotations have to be local
|
||||
for (Class<? extends Annotation> type : this.autowiredAnnotationTypes) {
|
||||
AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(ao, type);
|
||||
if (attributes != null) {
|
||||
@@ -594,11 +594,10 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
registerDependentBeans(beanName, autowiredBeanNames);
|
||||
if (autowiredBeanNames.size() == 1) {
|
||||
String autowiredBeanName = autowiredBeanNames.iterator().next();
|
||||
if (beanFactory.containsBean(autowiredBeanName)) {
|
||||
if (beanFactory.isTypeMatch(autowiredBeanName, field.getType())) {
|
||||
this.cachedFieldValue = new ShortcutDependencyDescriptor(
|
||||
desc, autowiredBeanName, field.getType());
|
||||
}
|
||||
if (beanFactory.containsBean(autowiredBeanName) &&
|
||||
beanFactory.isTypeMatch(autowiredBeanName, field.getType())) {
|
||||
this.cachedFieldValue = new ShortcutDependencyDescriptor(
|
||||
desc, autowiredBeanName, field.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -80,9 +80,8 @@ public class InjectionMetadata {
|
||||
Collection<InjectedElement> elementsToIterate =
|
||||
(this.checkedElements != null ? this.checkedElements : this.injectedElements);
|
||||
if (!elementsToIterate.isEmpty()) {
|
||||
boolean debug = logger.isDebugEnabled();
|
||||
for (InjectedElement element : elementsToIterate) {
|
||||
if (debug) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Processing injected element of bean '" + beanName + "': " + element);
|
||||
}
|
||||
element.inject(target, beanName, pvs);
|
||||
@@ -109,7 +108,10 @@ public class InjectionMetadata {
|
||||
}
|
||||
|
||||
|
||||
public static abstract class InjectedElement {
|
||||
/**
|
||||
* A single injected element.
|
||||
*/
|
||||
public abstract static class InjectedElement {
|
||||
|
||||
protected final Member member;
|
||||
|
||||
@@ -216,6 +218,7 @@ public class InjectionMetadata {
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear property skipping for this element.
|
||||
* @since 3.2.13
|
||||
*/
|
||||
protected void clearPropertySkipping(PropertyValues pvs) {
|
||||
|
||||
+22
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -309,7 +309,21 @@ public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwa
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether the given dependency carries a value annotation.
|
||||
* Determine whether the given dependency declares an autowired annotation,
|
||||
* checking its required flag.
|
||||
* @see Autowired#required()
|
||||
*/
|
||||
@Override
|
||||
public boolean isRequired(DependencyDescriptor descriptor) {
|
||||
if (!super.isRequired(descriptor)) {
|
||||
return false;
|
||||
}
|
||||
Autowired autowired = descriptor.getAnnotation(Autowired.class);
|
||||
return (autowired == null || autowired.required());
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the given dependency declares a value annotation.
|
||||
* @see Value
|
||||
*/
|
||||
@Override
|
||||
@@ -328,10 +342,12 @@ public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwa
|
||||
* Determine a suggested value from any of the given candidate annotations.
|
||||
*/
|
||||
protected Object findValue(Annotation[] annotationsToSearch) {
|
||||
AnnotationAttributes attr = AnnotatedElementUtils.getMergedAnnotationAttributes(
|
||||
AnnotatedElementUtils.forAnnotations(annotationsToSearch), this.valueAnnotationType);
|
||||
if (attr != null) {
|
||||
return extractValue(attr);
|
||||
if (annotationsToSearch.length > 0) { // qualifier annotations have to be local
|
||||
AnnotationAttributes attr = AnnotatedElementUtils.getMergedAnnotationAttributes(
|
||||
AnnotatedElementUtils.forAnnotations(annotationsToSearch), this.valueAnnotationType);
|
||||
if (attr != null) {
|
||||
return extractValue(attr);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -55,8 +55,8 @@ import org.springframework.util.Assert;
|
||||
* and obviates the need (<b>in part</b>) for a developer to code a method that
|
||||
* simply checks that all required properties have actually been set.
|
||||
*
|
||||
* <p>Please note that an 'init' method may still need to implemented (and may
|
||||
* still be desirable), because all that this class does is enforce that a
|
||||
* <p>Please note that an 'init' method may still need to be implemented (and may
|
||||
* still be desirable), because all that this class does is enforcing that a
|
||||
* 'required' property has actually been configured with a value. It does
|
||||
* <b>not</b> check anything else... In particular, it does not check that a
|
||||
* configured value is not {@code null}.
|
||||
|
||||
+5
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -33,6 +33,7 @@ import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.FactoryBeanNotInitializedException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -153,7 +154,7 @@ public abstract class AbstractFactoryBean<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine an 'eager singleton' instance, exposed in case of a
|
||||
* Determine an 'early singleton' instance, exposed in case of a
|
||||
* circular reference. Not called in a non-circular scenario.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -176,9 +177,7 @@ public abstract class AbstractFactoryBean<T>
|
||||
* @throws IllegalStateException if the singleton instance is not initialized
|
||||
*/
|
||||
private T getSingletonInstance() throws IllegalStateException {
|
||||
if (!this.initialized) {
|
||||
throw new IllegalStateException("Singleton instance not initialized yet");
|
||||
}
|
||||
Assert.state(this.initialized, "Singleton instance not initialized yet");
|
||||
return this.singletonInstance;
|
||||
}
|
||||
|
||||
@@ -218,7 +217,7 @@ public abstract class AbstractFactoryBean<T>
|
||||
* FactoryBean is supposed to implement, for use with an 'early singleton
|
||||
* proxy' that will be exposed in case of a circular reference.
|
||||
* <p>The default implementation returns this FactoryBean's object type,
|
||||
* provided that it is an interface, or {@code null} else. The latter
|
||||
* provided that it is an interface, or {@code null} otherwise. The latter
|
||||
* indicates that early singleton access is not supported by this FactoryBean.
|
||||
* This will lead to a FactoryBeanNotInitializedException getting thrown.
|
||||
* @return the interfaces to use for 'early singletons',
|
||||
|
||||
+2
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -232,6 +232,7 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
|
||||
/**
|
||||
* Return whether this a <b>Prototype</b>, with an independent instance
|
||||
* returned for each call.
|
||||
* @since 3.0
|
||||
* @see #SCOPE_PROTOTYPE
|
||||
*/
|
||||
boolean isPrototype();
|
||||
|
||||
+7
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -240,18 +240,20 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
|
||||
* @since 4.0
|
||||
*/
|
||||
public ResolvableType getResolvableType() {
|
||||
if (this.resolvableType == null) {
|
||||
this.resolvableType = (this.field != null ?
|
||||
ResolvableType resolvableType = this.resolvableType;
|
||||
if (resolvableType == null) {
|
||||
resolvableType = (this.field != null ?
|
||||
ResolvableType.forField(this.field, this.nestingLevel, this.containingClass) :
|
||||
ResolvableType.forMethodParameter(this.methodParameter));
|
||||
this.resolvableType = resolvableType;
|
||||
}
|
||||
return this.resolvableType;
|
||||
return resolvableType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether a fallback match is allowed.
|
||||
* <p>This is {@code false} by default but may be overridden to return {@code true} in order
|
||||
* to suggest to a {@link org.springframework.beans.factory.support.AutowireCandidateResolver}
|
||||
* to suggest to an {@link org.springframework.beans.factory.support.AutowireCandidateResolver}
|
||||
* that a fallback match is acceptable as well.
|
||||
* @since 4.0
|
||||
*/
|
||||
@@ -306,7 +308,6 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
|
||||
Type[] args = ((ParameterizedType) type).getActualTypeArguments();
|
||||
type = args[args.length - 1];
|
||||
}
|
||||
// TODO: Object.class if unresolvable
|
||||
}
|
||||
if (type instanceof Class) {
|
||||
return (Class<?>) type;
|
||||
|
||||
+8
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -30,16 +30,16 @@ import org.springframework.beans.BeansException;
|
||||
public interface DestructionAwareBeanPostProcessor extends BeanPostProcessor {
|
||||
|
||||
/**
|
||||
* Apply this BeanPostProcessor to the given bean instance before
|
||||
* its destruction. Can invoke custom destruction callbacks.
|
||||
* <p>Like DisposableBean's {@code destroy} and a custom destroy method,
|
||||
* this callback just applies to singleton beans in the factory (including
|
||||
* inner beans).
|
||||
* Apply this BeanPostProcessor to the given bean instance before its
|
||||
* destruction, e.g. invoking custom destruction callbacks.
|
||||
* <p>Like DisposableBean's {@code destroy} and a custom destroy method, this
|
||||
* callback will only apply to beans which the container fully manages the
|
||||
* lifecycle for. This is usually the case for singletons and scoped beans.
|
||||
* @param bean the bean instance to be destroyed
|
||||
* @param beanName the name of the bean
|
||||
* @throws org.springframework.beans.BeansException in case of errors
|
||||
* @see org.springframework.beans.factory.DisposableBean
|
||||
* @see org.springframework.beans.factory.support.AbstractBeanDefinition#setDestroyMethodName
|
||||
* @see org.springframework.beans.factory.DisposableBean#destroy()
|
||||
* @see org.springframework.beans.factory.support.AbstractBeanDefinition#setDestroyMethodName(String)
|
||||
*/
|
||||
void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException;
|
||||
|
||||
|
||||
+3
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -71,9 +71,8 @@ public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor {
|
||||
/**
|
||||
* Perform operations after the bean has been instantiated, via a constructor or factory method,
|
||||
* but before Spring property population (from explicit properties or autowiring) occurs.
|
||||
* <p>This is the ideal callback for performing field injection on the given bean instance.
|
||||
* See Spring's own {@link org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor}
|
||||
* for a typical example.
|
||||
* <p>This is the ideal callback for performing custom field injection on the given bean
|
||||
* instance, right before Spring's autowiring kicks in.
|
||||
* @param bean the bean instance created, with properties not having been set yet
|
||||
* @param beanName the name of the bean
|
||||
* @return {@code true} if properties should be set on the bean; {@code false}
|
||||
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -281,15 +281,15 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Constructor<Exception> determineServiceLocatorExceptionConstructor(Class<? extends Exception> exceptionClass) {
|
||||
try {
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(new Class<?>[] {String.class, Throwable.class});
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(String.class, Throwable.class);
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
try {
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(new Class<?>[] {Throwable.class});
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(Throwable.class);
|
||||
}
|
||||
catch (NoSuchMethodException ex2) {
|
||||
try {
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(new Class<?>[] {String.class});
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(String.class);
|
||||
}
|
||||
catch (NoSuchMethodException ex3) {
|
||||
throw new IllegalArgumentException(
|
||||
@@ -357,7 +357,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
|
||||
return System.identityHashCode(proxy);
|
||||
}
|
||||
else if (ReflectionUtils.isToStringMethod(method)) {
|
||||
return "Service locator: " + serviceLocatorInterface.getName();
|
||||
return "Service locator: " + serviceLocatorInterface;
|
||||
}
|
||||
else {
|
||||
return invokeServiceLocatorMethod(method, args);
|
||||
|
||||
+9
-12
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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,7 +25,6 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -77,15 +76,16 @@ public abstract class YamlProcessor {
|
||||
* name: My Cool App
|
||||
* </pre>
|
||||
* when mapped with
|
||||
* <code>documentMatchers = YamlProcessor.mapMatcher({"environment": "prod"})</code>
|
||||
* <pre class="code">
|
||||
* setDocumentMatchers(properties ->
|
||||
* ("prod".equals(properties.getProperty("environment")) ? MatchStatus.FOUND : MatchStatus.NOT_FOUND));
|
||||
* </pre>
|
||||
* would end up as
|
||||
* <pre class="code">
|
||||
* environment=prod
|
||||
* url=http://foo.bar.com
|
||||
* name=My Cool App
|
||||
* url=http://dev.bar.com
|
||||
* </pre>
|
||||
* @param matchers a map of keys to value patterns (regular expressions)
|
||||
*/
|
||||
public void setDocumentMatchers(DocumentMatcher... matchers) {
|
||||
this.documentMatchers = Arrays.asList(matchers);
|
||||
@@ -94,8 +94,7 @@ public abstract class YamlProcessor {
|
||||
/**
|
||||
* Flag indicating that a document for which all the
|
||||
* {@link #setDocumentMatchers(DocumentMatcher...) document matchers} abstain will
|
||||
* nevertheless match.
|
||||
* @param matchDefault the flag to set (default true)
|
||||
* nevertheless match. Default is {@code true}.
|
||||
*/
|
||||
public void setMatchDefault(boolean matchDefault) {
|
||||
this.matchDefault = matchDefault;
|
||||
@@ -104,9 +103,7 @@ public abstract class YamlProcessor {
|
||||
/**
|
||||
* Method to use for resolving resources. Each resource will be converted to a Map,
|
||||
* so this property is used to decide which map entries to keep in the final output
|
||||
* from this factory.
|
||||
* @param resolutionMethod the resolution method to set (defaults to
|
||||
* {@link ResolutionMethod#OVERRIDE}).
|
||||
* from this factory. Default is {@link ResolutionMethod#OVERRIDE}.
|
||||
*/
|
||||
public void setResolutionMethod(ResolutionMethod resolutionMethod) {
|
||||
Assert.notNull(resolutionMethod, "ResolutionMethod must not be null");
|
||||
@@ -201,7 +198,7 @@ public abstract class YamlProcessor {
|
||||
}
|
||||
|
||||
Map<Object, Object> map = (Map<Object, Object>) object;
|
||||
for (Entry<Object, Object> entry : map.entrySet()) {
|
||||
for (Map.Entry<Object, Object> entry : map.entrySet()) {
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof Map) {
|
||||
value = asMap(value);
|
||||
@@ -273,7 +270,7 @@ public abstract class YamlProcessor {
|
||||
}
|
||||
|
||||
private void buildFlattenedMap(Map<String, Object> result, Map<String, Object> source, String path) {
|
||||
for (Entry<String, Object> entry : source.entrySet()) {
|
||||
for (Map.Entry<String, Object> entry : source.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (StringUtils.hasText(path)) {
|
||||
if (key.startsWith("[")) {
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -76,8 +76,7 @@ public class BeanComponentDefinition extends BeanDefinitionHolder implements Com
|
||||
List<BeanDefinition> innerBeans = new ArrayList<BeanDefinition>();
|
||||
List<BeanReference> references = new ArrayList<BeanReference>();
|
||||
PropertyValues propertyValues = beanDefinition.getPropertyValues();
|
||||
for (int i = 0; i < propertyValues.getPropertyValues().length; i++) {
|
||||
PropertyValue propertyValue = propertyValues.getPropertyValues()[i];
|
||||
for (PropertyValue propertyValue : propertyValues.getPropertyValues()) {
|
||||
Object value = propertyValue.getValue();
|
||||
if (value instanceof BeanDefinitionHolder) {
|
||||
innerBeans.add(((BeanDefinitionHolder) value).getBeanDefinition());
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ import org.springframework.beans.factory.config.BeanReference;
|
||||
* all {@link BeanReference BeanReferences} that are required to validate the configuration of the
|
||||
* overall logical entity as well as those required to provide full user visualisation of the configuration.
|
||||
* It is expected that certain {@link BeanReference BeanReferences} will not be important to
|
||||
* validation or to the user view of the configuration and as such these may be ommitted. A tool may wish to
|
||||
* validation or to the user view of the configuration and as such these may be omitted. A tool may wish to
|
||||
* display any additional {@link BeanReference BeanReferences} sourced through the supplied
|
||||
* {@link BeanDefinition BeanDefinitions} but this is not considered to be a typical case.
|
||||
*
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user