mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Compare commits
571 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0e56142890 | |||
| 3741ac7dd0 | |||
| d5b9b26fea | |||
| cac42ef233 | |||
| 02e79f5673 | |||
| cd933c7f84 | |||
| d940811d8b | |||
| 15e009f3a0 | |||
| 0601f0e520 | |||
| 1e39b0bbbc | |||
| df460f4486 | |||
| e5d551587a | |||
| a60cb43c6a | |||
| 7dcd71c543 | |||
| 5e3a5202fb | |||
| a1a7c32052 | |||
| 38041acc87 | |||
| 4a3c1292bc | |||
| fa3e9bdfdd | |||
| 4f1e74877a | |||
| 620018d16b | |||
| bce9149947 | |||
| 6933a1af28 | |||
| 97e047ed66 | |||
| b06b5502e0 | |||
| 32ebf18429 | |||
| c2e62f098a | |||
| 4f96edd901 | |||
| 7307f3d513 | |||
| 5976beca80 | |||
| 189cc262ad | |||
| 76283ed321 | |||
| a40f6585b4 | |||
| 8c6890605a | |||
| 5f8faa3ae7 | |||
| 0adcb2ad2e | |||
| cfb387383b | |||
| c09227a712 | |||
| 94d690fb2c | |||
| 2127b16051 | |||
| 9ece4a88a9 | |||
| c306afed63 | |||
| c84cccf06d | |||
| a2a4929c14 | |||
| 3af4cdb0f1 | |||
| ea2da0b6be | |||
| 1bf8634db1 | |||
| 5db1687d29 | |||
| 9c3c1c64b3 | |||
| dbe96b5cf9 | |||
| 3f58da1cd6 | |||
| 72420c79cb | |||
| da41c9bb11 | |||
| f3f29412d4 | |||
| 0d4469d8e3 | |||
| 266e1096ce | |||
| 2b17ee0911 | |||
| 39583d23fd | |||
| 16fc083310 | |||
| f1ad53d570 | |||
| d2a99de9fc | |||
| c7a350cde7 | |||
| 385d8e9482 | |||
| a1b7af5c9c | |||
| 07f985ac91 | |||
| 08180e97f8 | |||
| a8dbac6d8d | |||
| 0f6d890d97 | |||
| 6f146737f4 | |||
| 9d2ee7061c | |||
| bfecedf5e2 | |||
| 2913964b41 | |||
| ab704fdaba | |||
| 74b169e886 | |||
| 18f5d90235 | |||
| 14edc9fc03 | |||
| ac735d73ac | |||
| cee9da36eb | |||
| 9ca9287e35 | |||
| aa0c64d2f2 | |||
| 3e5c6306be | |||
| 066daaf5be | |||
| 645631ad2e | |||
| e0ad6500be | |||
| ce78a519f6 | |||
| 7be1b5c3f5 | |||
| 8227cb6243 | |||
| 6ae04eb7e6 | |||
| 0304a4b74d | |||
| cf2563bdf5 | |||
| 919b996027 | |||
| 4642cca893 | |||
| ff2a603f2f | |||
| 24a97805ef | |||
| 0c775416a6 | |||
| 3a2afde41d | |||
| f64344b296 | |||
| 13b7f1a31b | |||
| 6981ee566c | |||
| c7473f9124 | |||
| 67661693fe | |||
| c3675b44b4 | |||
| 14d50e3482 | |||
| 4feacf31e7 | |||
| 847b54f3b1 | |||
| 0067618b35 | |||
| f5a39ae7ff | |||
| e5702cd3de | |||
| 948aa4f589 | |||
| 1e1a05e9f8 | |||
| e36b5e9b7e | |||
| 2b4328023e | |||
| 2eea63eec5 | |||
| c4d98278e9 | |||
| fb9fb00c04 | |||
| c9e67b2ef2 | |||
| 2b51759113 | |||
| 788a65b8e7 | |||
| 8e169a2782 | |||
| f1b9b8e924 | |||
| e1d9457b7d | |||
| 0d69b80385 | |||
| 98c6a2784f | |||
| a966cba97f | |||
| c303b22e30 | |||
| af8aff3e49 | |||
| 127115671c | |||
| 367a0c2933 | |||
| 2ceeff370a | |||
| 0756a6abfe | |||
| 37d955b35b | |||
| f43d0e1003 | |||
| ad93d20a6c | |||
| 47e3f0948d | |||
| 01cbfd4f6f | |||
| c5833b192e | |||
| d02e37a307 | |||
| e25fbf2533 | |||
| e11d7c328f | |||
| c4363673dc | |||
| c696e195fa | |||
| e128ee2464 | |||
| 56720fc42c | |||
| 3c6254df90 | |||
| 7430fcd904 | |||
| 5c67dbf424 | |||
| 79f9d1cfc6 | |||
| 4d6a5849f7 | |||
| 4a6101a697 | |||
| 95b1dbadb0 | |||
| 5b2c7c4e58 | |||
| 76e3d2855a | |||
| 5fa7f24794 | |||
| c481d2e9fb | |||
| f893b62a9b | |||
| c06752ef72 | |||
| 615fcff7ae | |||
| 7271ba8182 | |||
| c4a13507f0 | |||
| 415057c184 | |||
| 818467b9e5 | |||
| 0bf92782ea | |||
| 60aa598c03 | |||
| dd8a9cce05 | |||
| 5ac2e4418f | |||
| 100fed47f3 | |||
| b39673aa79 | |||
| dadd0f57ee | |||
| 1eaca65720 | |||
| a618bcc8cd | |||
| 4520ea8690 | |||
| 6fcea8b99d | |||
| 8dfcae535e | |||
| 0eb40e1e5e | |||
| dea1fc933f | |||
| 861e481755 | |||
| 3699a037a5 | |||
| 0b917e3f9c | |||
| af1dfd3577 | |||
| 1bbdb0d2ff | |||
| b0a4be7cd1 | |||
| ad2e0d4587 | |||
| 57c757afc5 | |||
| d14d82612d | |||
| f8bf8742e1 | |||
| 1784df8d3e | |||
| 700a02b094 | |||
| cc519e7c6d | |||
| 5c0e22e7a8 | |||
| 4dd5ae16b2 | |||
| a986d758e7 | |||
| bb2cc8457f | |||
| a557878a6f | |||
| df5bab3454 | |||
| f8a2dd3f65 | |||
| b46598965e | |||
| 2afeb08e3c | |||
| 57206db152 | |||
| 8190b4f70a | |||
| 580f35f6ee | |||
| 2f733bedc5 | |||
| 5d8de5c449 | |||
| 726e920857 | |||
| c8bc54e0cc | |||
| 314a054a9b | |||
| 9b0c66dc6c | |||
| 80f0eabbd9 | |||
| 404f798048 | |||
| 3622c6f340 | |||
| dc2d5c107f | |||
| 693204aef8 | |||
| 52bef0b7b0 | |||
| 859185d086 | |||
| 71aae405d5 | |||
| 7f247a6b27 | |||
| b058d1e07a | |||
| 8d0ab1d2e5 | |||
| d0c31ad84c | |||
| c2b030a50d | |||
| 7e398f101c | |||
| 358cbf4301 | |||
| b7f4f2b546 | |||
| 1efb82d7cb | |||
| 2092a31f9d | |||
| 446dfdbff2 | |||
| 01e5120a26 | |||
| d9a89529f0 | |||
| de50789cb6 | |||
| cf0fc278bb | |||
| 17892a8ab2 | |||
| 7b999c676f | |||
| 2bc3527f76 | |||
| 9a271ce6c9 | |||
| cdb01cbd37 | |||
| 89005a5b70 | |||
| 856da7edb9 | |||
| cd4fb665d9 | |||
| 111fb71fe1 | |||
| 0a790c143f | |||
| f683f781c5 | |||
| 84a63b6d4b | |||
| d2faef44fa | |||
| d3678caa37 | |||
| f30b7e3125 | |||
| 6d84f06d8c | |||
| 4b5208faad | |||
| 275d43dfde | |||
| c51c340881 | |||
| 3e2cc7dd19 | |||
| ddc9bbb555 | |||
| c91ab1ad6e | |||
| 50117dce40 | |||
| 5c27a04210 | |||
| 88e2277bff | |||
| ed9d9a402b | |||
| a4716c2a94 | |||
| 945cf43e2d | |||
| acb9433e5c | |||
| ab654a7a06 | |||
| 5206f5bc9a | |||
| e1d19d6c24 | |||
| d14c7f2d09 | |||
| 57d327d1ff | |||
| 9c65973b33 | |||
| 83ce399c47 | |||
| f5f738f2b4 | |||
| aa065e8310 | |||
| 62d40dc7aa | |||
| 8adb9a88d0 | |||
| 3244e0a644 | |||
| 8098ced387 | |||
| 58b779355b | |||
| 6e03b4dd64 | |||
| f812cd748e | |||
| 0c736776da | |||
| 3690002dce | |||
| 5486649394 | |||
| 767513de4e | |||
| 23e37b6842 | |||
| 54bbcf3a42 | |||
| 313546ad1f | |||
| 68b4687311 | |||
| 36970115ed | |||
| a16f3ba9dc | |||
| 174bf58308 | |||
| 522a879496 | |||
| 0584c26b2c | |||
| 22072b2414 | |||
| ef79d7cc8a | |||
| 03961a81d6 | |||
| b33478b4ba | |||
| c50d38ef8d | |||
| 28b6eae11a | |||
| 44b4f59c5e | |||
| 0cdb237576 | |||
| ff89c0e55a | |||
| bf6693dbc5 | |||
| 381af43f91 | |||
| 6fe0ff9e7b | |||
| 3d8b476f58 | |||
| 2710870d9e | |||
| 4c1f73ed83 | |||
| ffec444434 | |||
| ca9a3b4584 | |||
| 3ee6734424 | |||
| 28cdae2e50 | |||
| acc75aa4b8 | |||
| 0f7d43ba90 | |||
| 158a392d80 | |||
| eba33b6156 | |||
| 070b7b6afe | |||
| 74f1e0e9d0 | |||
| 4f7bdbd3de | |||
| fa4f90e648 | |||
| 4dcc79d6eb | |||
| f3d125626d | |||
| 293baeeb88 | |||
| 523c090551 | |||
| 70f883303f | |||
| 5373b43a53 | |||
| ad9c858bd2 | |||
| a60487655c | |||
| 744facbf64 | |||
| dd4d6e63ae | |||
| 9202224bca | |||
| b9d07b9c47 | |||
| fadfc76443 | |||
| 4f6df87615 | |||
| 3f11fbafaa | |||
| 006cbb25c5 | |||
| f5768fe00b | |||
| b0b1116f4b | |||
| 6809b234b1 | |||
| 2f5085aef1 | |||
| ec1b230ae5 | |||
| 732493951e | |||
| 10640233dc | |||
| 334e4f2212 | |||
| b50338fd32 | |||
| fa48a7b3a3 | |||
| 6ed1b1ebf8 | |||
| 8568250e77 | |||
| 45c6eb1d62 | |||
| 309fa92199 | |||
| daa074734f | |||
| adfcc929fb | |||
| 5c3ceb8ef0 | |||
| 71d70a6e06 | |||
| 726564c84d | |||
| d6be4c5a2a | |||
| 657b145ea2 | |||
| a3a0e5165c | |||
| eb4b68ffda | |||
| a20e73b148 | |||
| 6f80578a38 | |||
| f4e1cde33b | |||
| 150838bfc1 | |||
| b50ac7489b | |||
| d471266d44 | |||
| 529817301f | |||
| 43676bd660 | |||
| 76ce418556 | |||
| 8681536283 | |||
| c86bc2671a | |||
| 4cdb04ab25 | |||
| 704b229cc7 | |||
| 5cfbed8881 | |||
| f17f970144 | |||
| b5baa69f5d | |||
| 5de35e8f92 | |||
| 6993a8768a | |||
| c736e6b873 | |||
| 8f6fcbda3c | |||
| 08bccb28ae | |||
| 4a589a78e1 | |||
| c3a635196b | |||
| a4aca64007 | |||
| 5daad3e081 | |||
| a20dd8095e | |||
| fad2f2ca30 | |||
| 523a83ca28 | |||
| d7a8cf4b7e | |||
| 56d50ba8a5 | |||
| 386d8fdaa6 | |||
| 761a836236 | |||
| 4027cbd952 | |||
| 98d798dbe4 | |||
| bc342df08f | |||
| 9dbab116fd | |||
| 9779ca191c | |||
| 5a5fff5221 | |||
| 4889794bed | |||
| 716aa6974c | |||
| 0d70e08ac3 | |||
| 03190950d1 | |||
| 6bfead259e | |||
| d7a8536bd7 | |||
| c9c436128f | |||
| c84ef76fc3 | |||
| a6d35d4801 | |||
| ce761d3fe8 | |||
| df6be9f694 | |||
| 47c9278e32 | |||
| 93304b5ff2 | |||
| cd584afe93 | |||
| b7d7fa7b7e | |||
| 9cc125531b | |||
| 939da34869 | |||
| 91debc3a35 | |||
| c58b63a982 | |||
| b1756e2f17 | |||
| 2f7c2230f0 | |||
| 906b50ef51 | |||
| 6926e0f563 | |||
| e7c2713fd4 | |||
| 2d76dde611 | |||
| c5063004eb | |||
| a2bc381ade | |||
| 60414c9052 | |||
| 9bef79f5a8 | |||
| b4fea47d5c | |||
| b04987ccc3 | |||
| fb57316afa | |||
| ca2dbc1c59 | |||
| 4da39b48f7 | |||
| fbb1fa33a1 | |||
| ff7f3aebea | |||
| 7d1104e442 | |||
| 37e0a90350 | |||
| 7aaad37120 | |||
| 182b6a437c | |||
| 44b5df0db1 | |||
| 9c071e5d19 | |||
| f191be56d1 | |||
| 93de9622fc | |||
| 0c5a13cc96 | |||
| c4a954a618 | |||
| 62425568b9 | |||
| abff2b959b | |||
| 149348c907 | |||
| 9dd6f467b9 | |||
| 7af890cc5f | |||
| f4a2282d9d | |||
| b3f039ae5f | |||
| 4835be78b7 | |||
| 4e50eafe74 | |||
| f26b499cbd | |||
| 1ed1c59888 | |||
| d0d6a07870 | |||
| 33674933ea | |||
| 2ed3d77331 | |||
| 6362de44d1 | |||
| d3d7634574 | |||
| 465e093bfb | |||
| 157623b47f | |||
| 4998d061f8 | |||
| 2fcab44de0 | |||
| 34fbd5affa | |||
| 0d28b70aa8 | |||
| 7bf4e93783 | |||
| 414fcab899 | |||
| ac9fd008de | |||
| b5c167bdb1 | |||
| 90d8dade25 | |||
| 8df6b86dd1 | |||
| 5d6840e877 | |||
| 2ef629d5a8 | |||
| 1ed03fc6ca | |||
| 3bb17974d8 | |||
| b040606cfa | |||
| a7293d2961 | |||
| 71e60f4551 | |||
| 0fb631348e | |||
| bb4aa9cc39 | |||
| 8e23685a6d | |||
| 42403a37c3 | |||
| e254521952 | |||
| 4c9731d572 | |||
| 61cfb96d95 | |||
| c6c782df59 | |||
| c309ef74d7 | |||
| 7ec5f1694b | |||
| 86f1179606 | |||
| 15ac99f59c | |||
| a7704c8cce | |||
| 01c98c3bfb | |||
| 9420bdc246 | |||
| bc41cb2f27 | |||
| 7f8ede1407 | |||
| 431eaf6df8 | |||
| 2b99cf6d29 | |||
| 7c4582b4b3 | |||
| e971ad56b6 | |||
| 125b843cf7 | |||
| efe1e64b08 | |||
| 3fe2d037ed | |||
| a780a4a401 | |||
| 67d9b8b943 | |||
| cc91efecae | |||
| 3536b8178d | |||
| a417aa2ea3 | |||
| 818bd841fe | |||
| 9c64ac7482 | |||
| 3cfe557971 | |||
| fe386f1c10 | |||
| da898faac9 | |||
| 39e0c29d19 | |||
| 74b5b7b56a | |||
| e133bde01f | |||
| e5d8fa0771 | |||
| fbede64c86 | |||
| e98afc087f | |||
| 5e6912302a | |||
| b3ff9be78f | |||
| b130a36af7 | |||
| d7c4db1b49 | |||
| b8ab33e0c5 | |||
| 54a7ad9f74 | |||
| 30751c9b0a | |||
| f20ded5f63 | |||
| bfb3003cba | |||
| 9f5fd3afcf | |||
| 64c7549c70 | |||
| 29a8ca4edc | |||
| 893fc83f49 | |||
| e90f0a35e3 | |||
| 9f4499cb36 | |||
| d0394599ad | |||
| db3634f859 | |||
| 8285e9c2a7 | |||
| 18e141cbaa | |||
| 58633e4a89 | |||
| bbba832904 | |||
| faf01b0337 | |||
| 21d64a74ae | |||
| 47711c6743 | |||
| f105670cec | |||
| 1a7aebb0dd | |||
| c08a2764d0 | |||
| da97547f00 | |||
| fbb106cfbe | |||
| f46a455c72 | |||
| 8770ea96b0 | |||
| b3e36a335d | |||
| e693d9fa58 | |||
| b50abc67de | |||
| e0c5ced695 | |||
| 5062dc31af | |||
| b33da670e5 | |||
| c8b4915891 | |||
| b109a07fd9 | |||
| c52915bde6 | |||
| 197a46d0ab | |||
| 36ec06a917 | |||
| cfe1fdb5e5 | |||
| a3df1c4e41 | |||
| b73224427f | |||
| 01120eb2f0 | |||
| 8762ec956c | |||
| 01e79cfedd | |||
| caf1a0875a | |||
| 4f8105ccaa | |||
| 85c02981b5 | |||
| 416777022d | |||
| 7cc3f49910 | |||
| 095a36e853 | |||
| 6ef987bced | |||
| c13905ad16 | |||
| 4214bc0735 | |||
| f480333d31 | |||
| b0ea2b13d2 |
+15
-4
@@ -1,7 +1,18 @@
|
||||
target
|
||||
*.java.hsp
|
||||
*.sonarj
|
||||
*.sw*
|
||||
.DS_Store
|
||||
.settings
|
||||
.springBeans
|
||||
bin
|
||||
build.sh
|
||||
integration-repo
|
||||
ivy-cache
|
||||
spring-build
|
||||
jxl.log
|
||||
jmx.log
|
||||
.springBeans
|
||||
.DS_Store
|
||||
org.springframework.jdbc/derby.log
|
||||
org.springframework.spring-parent/.classpath
|
||||
org.springframework.spring-parent/.project
|
||||
org.springframework.test/test-output/
|
||||
spring-build
|
||||
target
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
|
||||
<!-- Main targets -->
|
||||
<target name="publish-documentation" depends="publish-documentation.init">
|
||||
<sshexec host="spring02.managed.contegix.com" username="${username}" keyfile="${key.file}" passphrase="${passphrase}"
|
||||
<sshexec host="static.springframework.org" username="${username}" keyfile="${key.file}" passphrase="${passphrase}"
|
||||
command="rm -rf /opt/www/domains/springframework.org/www/htdocs/spring/docs/${bundle.version}"/>
|
||||
<sshexec host="static.springframework.org" username="${username}" keyfile="${key.file}" passphrase="${passphrase}"
|
||||
command="mkdir /opt/www/domains/springframework.org/www/htdocs/spring/docs/${bundle.version}"/>
|
||||
|
||||
<scp remoteToDir="${username}@spring02.managed.contegix.com:/opt/www/domains/springframework.org/www/htdocs/spring/docs/${bundle.version}"
|
||||
<scp remoteToDir="${username}@static.springframework.org:/opt/www/domains/springframework.org/www/htdocs/spring/docs/${bundle.version}"
|
||||
keyfile="${key.file}" passphrase="${passphrase}" sftp="true" verbose="true">
|
||||
<fileset dir="${package.output.dir}">
|
||||
<include name="changelog.txt" />
|
||||
@@ -16,8 +18,8 @@
|
||||
<fileset dir="${package.docs.dir}" />
|
||||
</scp>
|
||||
|
||||
<sshexec host="spring02.managed.contegix.com" username="${username}" keyfile="${key.file}" passphrase="${passphrase}"
|
||||
command="rm /opt/www/domains/springframework.org/www/htdocs/spring/docs/3.0.x ; ln -s /opt/www/domains/springframework.org/www/htdocs/spring/docs/${bundle.version} /opt/www/domains/springframework.org/www/htdocs/spring/docs/3.0.x"/>
|
||||
<sshexec host="static.springframework.org" username="${username}" keyfile="${key.file}" passphrase="${passphrase}"
|
||||
command="rm -f /opt/www/domains/springframework.org/www/htdocs/spring/docs/3.1.x ; ln -s /opt/www/domains/springframework.org/www/htdocs/spring/docs/${bundle.version} /opt/www/domains/springframework.org/www/htdocs/spring/docs/3.1.x"/>
|
||||
</target>
|
||||
|
||||
<!-- Other targets -->
|
||||
|
||||
@@ -1,27 +1,42 @@
|
||||
This is where the master build that creates releases of Spring Framework resides. The build system is based on spring-build, which is linked in using an SVN external to https://src.springframework.org/svn/spring-build.
|
||||
This is where the master build that creates releases of Spring Framework resides.
|
||||
The build system is based on spring-build, which is linked in using an SVN
|
||||
external to https://src.springframework.org/svn/spring-build.
|
||||
|
||||
Build Pre-requisites:
|
||||
- javac 1.6 or > must be in your system path
|
||||
- ant 1.7 or > must be in your system path
|
||||
- set ANT_OPTS as follows (to avoid out of memory errors):
|
||||
ANT_OPTS="-XX:MaxPermSize=1024m -Xmx1024m -Dtest.vm.args='-XX:MaxPermSize=512m -Xmx1024m'"
|
||||
|
||||
USERS
|
||||
- To build all Spring Framework projects, including samples:
|
||||
|
||||
1. From this directory, run:
|
||||
ant
|
||||
|
||||
Build Pre-requisites:
|
||||
- javac 1.6 or > must be in your system path
|
||||
- ant 1.7 or > must be in your system path
|
||||
|
||||
- To install the built artifacts into your local Maven cache:
|
||||
|
||||
1. From this directory, run:
|
||||
ant install-maven
|
||||
|
||||
- For a complete tutorial, see:
|
||||
|
||||
http://blog.springsource.com/2009/03/03/building-spring-3
|
||||
|
||||
|
||||
DEVELOPERS
|
||||
- To build a new Spring Framework distribution for release:
|
||||
|
||||
1. Update the files containing the version number to reflect the new release version, if necessary.
|
||||
|
||||
1. Update the files containing the version number to reflect the new release
|
||||
version, if necessary.
|
||||
|
||||
build.properties
|
||||
build-spring-framework/resources/readme.txt
|
||||
spring-framework/src/spring-framework-reference.xml
|
||||
|
||||
2. From this directory, run:
|
||||
|
||||
|
||||
ant jar package
|
||||
|
||||
|
||||
The release archive will be created and placed in:
|
||||
target/artifacts
|
||||
target/artifacts
|
||||
|
||||
@@ -3,6 +3,64 @@ SPRING FRAMEWORK CHANGELOG
|
||||
http://www.springsource.org
|
||||
|
||||
|
||||
Changes in version 3.1 M2 (2011-06-08)
|
||||
--------------------------------------
|
||||
|
||||
* revised TypeDescriptor signature and implementation for clearer handling of nested generics
|
||||
* full support for arbitrary nesting of collections in fields
|
||||
* proper type detection in nested collections within arrays
|
||||
* AnnotatedBeanDefinitionReader now inherits Environment of supplied BeanDefinitionRegistry
|
||||
* eliminated @Feature support in favor of @Enable* and framework-provided @Configuration classes
|
||||
* introduced @EnableTransactionManagement, @EnableScheduling, etc
|
||||
* introduced @EnableWebMvc to provide default configuration for Spring MVC applications
|
||||
* introduced HandlerMethod abstraction representing a Spring MVC controller method
|
||||
* added HandlerMapping/HandlerAdapter/HandlerExceptionResolver HandlerMethod-based implementations
|
||||
* enabled HandlerMethod-based infrastructure through the mvc namespace and Java-based configuration
|
||||
* support for automatically adding @PathVariables to the model
|
||||
* support for including @PathVariables in data binding
|
||||
* support for URI template variables in view names with the "redirect:" prefix
|
||||
* added a flag for extracting the value from single-key models in MappingJacksonJsonView
|
||||
* added support for @Valid with @RequestBody arguments
|
||||
* allow bean references in mvc:interceptor namespace elements
|
||||
* consolidated the initialization and use of MappedInterceptors in AbstractHandlerMapping
|
||||
* added Servlet 3.0 based WebApplicationInitializer mechanism for programmatic bootstrapping
|
||||
* added Servlet 3.0 based StandardServletMultipartResolver
|
||||
* added "packagesToScan" feature to LocalContainerEntityManagerFactoryBean (avoiding persistence.xml)
|
||||
* fixed JPA 2.0 timeout hints to correctly specify milliseconds
|
||||
* revised cache abstraction to focus on minimal atomic access operations
|
||||
* updated Quartz package to support Quartz 1.8 as well (note: not fully supporting Quartz 2.0 yet)
|
||||
* RemoteExporter uses an opaque proxy for 'serviceInterface' (no AOP interfaces exposed)
|
||||
* introduced AnnotationConfigContextLoader to provide TestContext support for @Configuration classes
|
||||
* introduced @ActiveProfiles for declarative configuration of bean definition profiles in tests
|
||||
* TestContext generates context cache key based on all applicable configuration metadata
|
||||
* deprecated AbstractJUnit38SpringContextTests and AbstractTransactionalJUnit38SpringContextTests
|
||||
|
||||
|
||||
Changes in version 3.1 M1 (2011-02-11)
|
||||
--------------------------------------
|
||||
|
||||
* upgraded to JUnit 4.8.1 and TestNG 5.12.1
|
||||
* fixed aspects bundle to declare dependencies for @Async aspect as well
|
||||
* introduced Environment abstraction with flexible placeholder resolution
|
||||
* introduced support for environment profiles in XML bean definition files
|
||||
* introduced @Profile annotation for configuration classes and individual component classes
|
||||
* introduced PropertySourcesPlaceholderConfigurer as alternative to PropertyPlaceholderConfigurer
|
||||
* introduced "c:" namespace for constructor argument shortcuts (analogous to the "p:" namespace)
|
||||
* introduced @FeatureConfiguration classes with @Feature methods that return FeatureSpecifications
|
||||
* added TxAnnotationDriven, MvcAnnotationDriven, etc. as out-of-the-box FeatureSpecifications
|
||||
* introduced caching abstraction and cache annotation support
|
||||
* moved EhCache FactoryBeans from context-support to context module
|
||||
* EhCacheManagerFactoryBean properly closes "ehcache.xml" input stream, if any
|
||||
* exceptions thrown by @Scheduled methods will be propagated to a registered ErrorHandler
|
||||
* ProxyCreationContext uses "ThreadLocal.remove()" over "ThreadLocal.set(null)" as well
|
||||
* BeanDefinitionVisitor now actually visits factory method names
|
||||
* fixed potential InjectionMetadata NPE when using SpringBeanAutowiringInterceptor
|
||||
* fixed AbstractBindingResult to avoid NPE in "hashCode()" if target is null
|
||||
* Servlet/PortletRequestDataBinder perform unwrapping for MultipartRequest as well
|
||||
* ResourceHttpRequestHandler does not set Content-Length header for 304 response
|
||||
* LocaleChangeInterceptor validates locale values in order to prevent XSS vulnerability
|
||||
|
||||
|
||||
Changes in version 3.0.5 (2010-10-20)
|
||||
-------------------------------------
|
||||
|
||||
|
||||
@@ -199,3 +199,63 @@
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
=======================================================================
|
||||
|
||||
SPRING FRAMEWORK 3.1 SUBCOMPONENTS:
|
||||
|
||||
Spring Framework 3.1 includes a number of subcomponents with
|
||||
separate copyright notices and license terms. The product that
|
||||
includes this file does not necessarily use all the open source
|
||||
subcomponents referred to below. Your use of the source
|
||||
code for these subcomponents is subject to the terms and
|
||||
conditions of the following licenses.
|
||||
|
||||
>>> asm-2.2.3:
|
||||
|
||||
Copyright (c) 2000-2005 INRIA, France Telecom
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holders nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Copyright (c) 1999-2009, OW2 Consortium <http://www.ow2.org/>
|
||||
|
||||
=======================================================================
|
||||
|
||||
To the extent any open source subcomponents are licensed under the EPL and/or other
|
||||
similar licenses that require the source code and/or modifications to
|
||||
source code to be made available (as would be noted above), you may obtain a
|
||||
copy of the source code corresponding to the binaries for such open source
|
||||
components and modifications thereto, if any, (the "Source Files"), by
|
||||
downloading the Source Files from http://www.springsource.org/download,
|
||||
or by sending a request, with your name and address to: VMware, Inc., 3401 Hillview
|
||||
Avenue, Palo Alto, CA 94304, United States of America or email info@vmware.com. All
|
||||
such requests should clearly specify: OPEN SOURCE FILES REQUEST, Attention General
|
||||
Counsel. VMware shall mail a copy of the Source Files to you on a CD or equivalent
|
||||
physical medium. This offer to obtain a copy of the Source Files is valid for three
|
||||
years from the date you acquired this Software product.
|
||||
@@ -1,22 +1,9 @@
|
||||
======================================================================
|
||||
== NOTICE file corresponding to section 4 d of the Apache License, ==
|
||||
== Version 2.0, for the Spring Framework distribution. ==
|
||||
======================================================================
|
||||
Spring Framework 3.1
|
||||
Copyright (c) 2002-2011 SpringSource, a division of VMware, Inc.
|
||||
|
||||
This product includes software developed by
|
||||
the Apache Software Foundation (http://www.apache.org).
|
||||
|
||||
The end-user documentation included with a redistribution, if any,
|
||||
must include the following acknowledgement:
|
||||
|
||||
"This product includes software developed by the Spring Framework
|
||||
Project (http://www.springframework.org)."
|
||||
|
||||
Alternately, this acknowledgement may appear in the software itself,
|
||||
if and wherever such third-party acknowledgements normally appear.
|
||||
|
||||
The names "Spring", "Spring Framework", and "Spring Web Flow" must
|
||||
not be used to endorse or promote products derived from this
|
||||
software without prior written permission. For written permission,
|
||||
please contact enquiries@springsource.com.
|
||||
This product is licensed to you under the Apache License, Version 2.0 (the "License").
|
||||
You may not use this product except in compliance with the License.
|
||||
|
||||
This product may include a number of subcomponents with separate copyright notices and
|
||||
license terms. Your use of the source code for the these subcomponents is subject to
|
||||
the terms and conditions of the subcomponent's license, as noted in the LICENSE file.
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
SPRING FRAMEWORK 3.0.5 (October 2010)
|
||||
-------------------------------------
|
||||
SPRING FRAMEWORK 3.1 M2 (June 2011)
|
||||
-----------------------------------
|
||||
http://www.springframework.org
|
||||
|
||||
1. INTRODUCTION
|
||||
|
||||
Spring Framework 3.0 is the next generation of Spring: fully Java 5 based,
|
||||
EL enabled, REST enabled, and with support for JSR-330 (Dependency
|
||||
Injection) and JSR-303 (Bean Validation).
|
||||
Spring Framework 3.1 builds on the Spring Framework 3.0 foundation with
|
||||
a focus on Java-based application configuration and MVC enhancements.
|
||||
|
||||
2. RELEASE NOTES
|
||||
|
||||
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
version=3.0.5
|
||||
version=3.1.0
|
||||
# osgi ranges
|
||||
spring.osgi.range.nq=${version:[=.=.=, =.=.+1)}
|
||||
spring.osgi.range="${spring.osgi.range.nq}"
|
||||
aj.osgi.range="[1.5.4, 2.0.0)"
|
||||
|
||||
#
|
||||
release.type=integration
|
||||
#release.type=integration
|
||||
natural.name=spring-framework
|
||||
project.name=Spring Framework
|
||||
project.key=SPR
|
||||
@@ -22,8 +22,8 @@ compiler.args=-enableJavadoc -warn:none
|
||||
#build.stamp=RELEASE
|
||||
|
||||
# For when releasing milestones
|
||||
#release.type=milestone
|
||||
#build.stamp=M1
|
||||
release.type=milestone
|
||||
build.stamp=M2
|
||||
|
||||
# For development in trunk
|
||||
#release.type=integration
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
#common dependency versions
|
||||
# common dependency versions
|
||||
aspectj.version=1.6.8.RELEASE
|
||||
commons.pool.version=1.5.3
|
||||
slf4j.version=1.5.6
|
||||
org.testng.version=5.10.0
|
||||
org.junit.version=4.7.0
|
||||
org.junit.version=4.8.1
|
||||
org.testng.version=5.12.1
|
||||
slf4j.version=1.5.3
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<classpathentry kind="var" path="IVY_CACHE/com.jamonapi/com.springsource.com.jamonapi/2.4.0/com.springsource.com.jamonapi-2.4.0.jar" sourcepath="/IVY_CACHE/com.jamonapi/com.springsource.com.jamonapi/2.4.0/com.springsource.com.jamonapi-sources-2.4.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/net.sourceforge.cglib/com.springsource.net.sf.cglib/2.2.0/com.springsource.net.sf.cglib-2.2.0.jar" sourcepath="/IVY_CACHE/net.sourceforge.cglib/com.springsource.net.sf.cglib/2.1.3/com.springsource.net.sf.cglib-sources-2.1.3.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.log4j/com.springsource.org.apache.log4j/1.2.15/com.springsource.org.apache.log4j-1.2.15.jar" sourcepath="/IVY_CACHE/org.apache.log4j/com.springsource.org.apache.log4j/1.2.15/com.springsource.org.apache.log4j-sources-1.2.15.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-4.7.0.jar" sourcepath="/IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-sources-4.7.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.junit/com.springsource.org.junit/4.8.1/com.springsource.org.junit-4.8.1.jar" sourcepath="/IVY_CACHE/org.junit/com.springsource.org.junit/4.8.1/com.springsource.org.junit-sources-4.8.1.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.pool/1.3.0/com.springsource.org.apache.commons.pool-1.3.0.jar" sourcepath="/IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.pool/1.3.0/com.springsource.org.apache.commons.pool-sources-1.3.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.aspectj/com.springsource.org.aspectj.weaver/1.6.8.RELEASE/com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar" sourcepath="IVY_CACHE/org.aspectj/com.springsource.org.aspectj.weaver/1.6.8.RELEASE/com.springsource.org.aspectj.weaver-sources-1.6.8.RELEASE.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.beans"/>
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
#Wed Jul 15 00:01:31 PDT 2009
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-aop</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>3.0.5.BUILD-SNAPSHOT</version>
|
||||
<version>3.1.0.M2</version>
|
||||
<parent>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-parent</artifactId>
|
||||
<relativePath>../org.springframework.spring-parent</relativePath>
|
||||
<version>3.0.5.BUILD-SNAPSHOT</version>
|
||||
<version>3.1.0.M2</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
||||
+7
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2011 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,7 +46,12 @@ public class ProxyCreationContext {
|
||||
* @param beanName the name of the bean, or <code>null</code> to reset it
|
||||
*/
|
||||
static void setCurrentProxiedBeanName(String beanName) {
|
||||
currentProxiedBeanName.set(beanName);
|
||||
if (beanName != null) {
|
||||
currentProxiedBeanName.set(beanName);
|
||||
}
|
||||
else {
|
||||
currentProxiedBeanName.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
@@ -72,6 +72,11 @@ public abstract class AbstractBeanFactoryPointcutAdvisor extends AbstractPointcu
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
public void setAdvice(Advice advice) {
|
||||
synchronized (this.adviceMonitor) {
|
||||
this.advice = advice;
|
||||
}
|
||||
}
|
||||
|
||||
public Advice getAdvice() {
|
||||
synchronized (this.adviceMonitor) {
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.springframework.aop.Advisor;
|
||||
import org.springframework.aop.AopInvocationException;
|
||||
|
||||
@@ -0,0 +1,261 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
=======================================================================
|
||||
|
||||
SPRING FRAMEWORK 3.1 SUBCOMPONENTS:
|
||||
|
||||
Spring Framework 3.1 includes a number of subcomponents with
|
||||
separate copyright notices and license terms. The product that
|
||||
includes this file does not necessarily use all the open source
|
||||
subcomponents referred to below. Your use of the source
|
||||
code for these subcomponents is subject to the terms and
|
||||
conditions of the following licenses.
|
||||
|
||||
>>> asm-2.2.3:
|
||||
|
||||
Copyright (c) 2000-2005 INRIA, France Telecom
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holders nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Copyright (c) 1999-2009, OW2 Consortium <http://www.ow2.org/>
|
||||
|
||||
=======================================================================
|
||||
|
||||
To the extent any open source subcomponents are licensed under the EPL and/or other
|
||||
similar licenses that require the source code and/or modifications to
|
||||
source code to be made available (as would be noted above), you may obtain a
|
||||
copy of the source code corresponding to the binaries for such open source
|
||||
components and modifications thereto, if any, (the "Source Files"), by
|
||||
downloading the Source Files from http://www.springsource.org/download,
|
||||
or by sending a request, with your name and address to: VMware, Inc., 3401 Hillview
|
||||
Avenue, Palo Alto, CA 94304, United States of America or email info@vmware.com. All
|
||||
such requests should clearly specify: OPEN SOURCE FILES REQUEST, Attention General
|
||||
Counsel. VMware shall mail a copy of the Source Files to you on a CD or equivalent
|
||||
physical medium. This offer to obtain a copy of the Source Files is valid for three
|
||||
years from the date you acquired this Software product.
|
||||
@@ -0,0 +1,9 @@
|
||||
Spring Framework 3.1
|
||||
Copyright (c) 2002-2011 SpringSource, a division of VMware, Inc.
|
||||
|
||||
This product is licensed to you under the Apache License, Version 2.0 (the "License").
|
||||
You may not use this product except in compliance with the License.
|
||||
|
||||
This product may include a number of subcomponents with separate copyright notices and
|
||||
license terms. Your use of the source code for the these subcomponents is subject to
|
||||
the terms and conditions of the subcomponent's license, as noted in the LICENSE file.
|
||||
@@ -1,4 +1,5 @@
|
||||
http\://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd
|
||||
http\://www.springframework.org/schema/aop/spring-aop-2.5.xsd=org/springframework/aop/config/spring-aop-2.5.xsd
|
||||
http\://www.springframework.org/schema/aop/spring-aop-3.0.xsd=org/springframework/aop/config/spring-aop-3.0.xsd
|
||||
http\://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-3.0.xsd
|
||||
http\://www.springframework.org/schema/aop/spring-aop-3.1.xsd=org/springframework/aop/config/spring-aop-3.1.xsd
|
||||
http\://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-3.1.xsd
|
||||
|
||||
+407
@@ -0,0 +1,407 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
||||
<xsd:schema xmlns="http://www.springframework.org/schema/aop"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:tool="http://www.springframework.org/schema/tool"
|
||||
targetNamespace="http://www.springframework.org/schema/aop"
|
||||
elementFormDefault="qualified"
|
||||
attributeFormDefault="unqualified">
|
||||
|
||||
<xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"/>
|
||||
<xsd:import namespace="http://www.springframework.org/schema/tool" schemaLocation="http://www.springframework.org/schema/tool/spring-tool-3.1.xsd"/>
|
||||
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Defines the configuration elements for the Spring Framework's AOP support.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
|
||||
<xsd:element name="config">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
A section (compartmentalization) of AOP-specific configuration (including
|
||||
aspects, pointcuts, etc).
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="pointcut" type="pointcutType" minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
A named pointcut definition.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
<xsd:element name="advisor" type="advisorType" minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation source="java:org.springframework.aop.Advisor"><![CDATA[
|
||||
A named advisor definition.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
<xsd:element name="aspect" type="aspectType" minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
A named aspect definition.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="proxy-target-class" type="xsd:boolean" default="false">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Are class-based (CGLIB) proxies to be created? By default, standard
|
||||
Java interface-based proxies are created.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="expose-proxy" type="xsd:boolean" default="false">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Indicate that the proxy should be exposed by the AOP framework as a
|
||||
ThreadLocal for retrieval via the AopContext class. Off by default,
|
||||
i.e. no guarantees that AopContext access will work.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="aspectj-autoproxy">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation source="java:org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator"><![CDATA[
|
||||
Enables the use of the @AspectJ style of Spring AOP.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="include" type="includeType" minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Indicates that only @AspectJ beans with names matched by the (regex)
|
||||
pattern will be considered as defining aspects to use for Spring autoproxying.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="proxy-target-class" type="xsd:boolean" default="false">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Are class-based (CGLIB) proxies to be created? By default, standard
|
||||
Java interface-based proxies are created.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="expose-proxy" type="xsd:boolean" default="false">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Indicate that the proxy should be exposed by the AOP framework as a
|
||||
ThreadLocal for retrieval via the AopContext class. Off by default,
|
||||
i.e. no guarantees that AopContext access will work.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="scoped-proxy">
|
||||
<xsd:complexType>
|
||||
<xsd:annotation>
|
||||
<xsd:documentation source="java:org.springframework.aop.scope.ScopedProxyFactoryBean"><![CDATA[
|
||||
Marks a bean definition as being a scoped proxy.
|
||||
|
||||
A bean marked as such will be exposed via a proxy, with the 'real'
|
||||
bean instance being retrieved from some other source (such as a
|
||||
HttpSession) as and when required.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:attribute name="proxy-target-class" type="xsd:boolean" default="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Are class-based (CGLIB) proxies to be created? This is the default; in order to
|
||||
switch to standard Java interface-based proxies, turn this flag to "false".
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:complexType name="aspectType">
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="pointcut" type="pointcutType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
A named pointcut definition.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
<xsd:element name="declare-parents" type="declareParentsType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Allows this aspect to introduce additional interfaces that the advised
|
||||
object will transparently implement.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
<xsd:element name="before" type="basicAdviceType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
A before advice definition.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
<xsd:element name="after" type="basicAdviceType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
An after advice definition.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
<xsd:element name="after-returning" type="afterReturningAdviceType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
An after-returning advice definition.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
<xsd:element name="after-throwing" type="afterThrowingAdviceType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
An after-throwing advice definition.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
<xsd:element name="around" type="basicAdviceType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
An around advice definition.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="id" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The unique identifier for an aspect.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="ref" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The name of the (backing) bean that encapsulates the aspect.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="order" type="xsd:int">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation source="java:org.springframework.core.Ordered"><![CDATA[
|
||||
Controls the ordering of the execution of this aspect when multiple
|
||||
advice executes at a specific joinpoint.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="includeType">
|
||||
<xsd:attribute name="name" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation source="java:java.util.regex.Pattern"><![CDATA[
|
||||
The regular expression defining which beans are to be included in the
|
||||
list of @AspectJ beans; beans with names matched by the pattern will
|
||||
be included.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="pointcutType">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation>
|
||||
<tool:exports type="org.springframework.aop.Pointcut"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
<xsd:attribute name="id" type="xsd:string" use="required">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The unique identifier for a pointcut.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="expression" use="required" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The pointcut expression.
|
||||
|
||||
For example : 'execution(* com.xyz.myapp.service.*.*(..))'
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="declareParentsType">
|
||||
<xsd:attribute name="types-matching" type="xsd:string" use="required">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation source="java:org.springframework.aop.aspectj.TypePatternClassFilter"><![CDATA[
|
||||
The AspectJ type expression that defines what types (classes) the
|
||||
introduction is restricted to.
|
||||
|
||||
An example would be 'org.springframework.beans.ITestBean+'.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="implement-interface" type="xsd:string" use="required">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation source="java:java.lang.Class"><![CDATA[
|
||||
The fully qualified name of the interface that will be introduced.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="default-impl" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation source="java:java.lang.Class"><![CDATA[
|
||||
The fully qualified name of the class that will be instantiated to serve
|
||||
as the default implementation of the introduced interface.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="delegate-ref" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
A reference to the bean that will serve
|
||||
as the default implementation of the introduced interface.
|
||||
]]></xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref"/>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="basicAdviceType">
|
||||
<xsd:attribute name="pointcut" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The associated pointcut expression.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="pointcut-ref" type="pointcutRefType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The name of an associated pointcut definition.
|
||||
]]></xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.aop.Pointcut"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="method" type="xsd:string" use="required">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The name of the method that defines the logic of the advice.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="arg-names" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The comma-delimited list of advice method argument (parameter) names
|
||||
that will be matched from pointcut parameters.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="afterReturningAdviceType">
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="basicAdviceType">
|
||||
<xsd:attribute name="returning" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The name of the method parameter to which the return value must
|
||||
be passed.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="afterThrowingAdviceType">
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="basicAdviceType">
|
||||
<xsd:attribute name="throwing" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The name of the method parameter to which the thrown exception must
|
||||
be passed.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="advisorType">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation>
|
||||
<tool:exports type="org.springframework.aop.Advisor"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="advice-ref" type="xsd:string" use="required">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
A reference to an advice bean.
|
||||
]]></xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.aopalliance.aop.Advice"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="pointcut" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
A pointcut expression.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="pointcut-ref" type="pointcutRefType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
A reference to a pointcut definition.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="order" type="xsd:int">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation source="java:org.springframework.core.Ordered"><![CDATA[
|
||||
Controls the ordering of the execution of this advice when multiple
|
||||
advice executes at a specific joinpoint.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:simpleType name="pointcutRefType">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.aop.Pointcut"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
<xsd:union memberTypes="xsd:string"/>
|
||||
</xsd:simpleType>
|
||||
|
||||
</xsd:schema>
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
#Wed Jul 15 00:01:30 PDT 2009
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-asm</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>3.0.5.BUILD-SNAPSHOT</version>
|
||||
<version>3.1.0.M2</version>
|
||||
<parent>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-parent</artifactId>
|
||||
<relativePath>../org.springframework.spring-parent</relativePath>
|
||||
<version>3.0.5.BUILD-SNAPSHOT</version>
|
||||
<version>3.1.0.M2</version>
|
||||
</parent>
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.test"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar" sourcepath="/IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-sources-1.1.1.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.aspectj/com.springsource.org.aspectj.weaver/1.6.8.RELEASE/com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar" sourcepath="/IVY_CACHE/org.aspectj/com.springsource.org.aspectj.weaver/1.6.8.RELEASE/com.springsource.org.aspectj.weaver-sources-1.6.8.RELEASE.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-4.7.0.jar" sourcepath="/IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-sources-4.7.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.junit/com.springsource.org.junit/4.8.1/com.springsource.org.junit-4.8.1.jar" sourcepath="/IVY_CACHE/org.junit/com.springsource.org.junit/4.8.1/com.springsource.org.junit-sources-4.8.1.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/javax.persistence/com.springsource.javax.persistence/1.0.0/com.springsource.javax.persistence-1.0.0.jar" sourcepath="/IVY_CACHE/javax.persistence/com.springsource.javax.persistence/1.0.0/com.springsource.javax.persistence-sources-1.0.0.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.orm"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#Wed Jul 15 00:01:30 PDT 2009
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
|
||||
@@ -13,8 +13,10 @@
|
||||
<include file="${spring.build.dir}/common/default-ivy-configurations.xml"/>
|
||||
<conf name="commons-logging" extends="runtime" description="JARs needed to run with Commons Logging"/>
|
||||
<conf name="aspectj" extends="runtime" description="JARs needed to run with AspectJ"/>
|
||||
<conf name="context" extends="runtime" description="JARs needed to register @Configuration classes and @Bean methods"/>
|
||||
<conf name="tx" extends="runtime" description="JARs needed to run transactional aspects"/>
|
||||
<conf name="orm" extends="runtime" description="JARs needed to compile JPA aspects"/>
|
||||
<conf name="cache" extends="runtime" description="JARs needed to compile caching aspects"/>
|
||||
</configurations>
|
||||
|
||||
<publications>
|
||||
@@ -31,8 +33,8 @@
|
||||
<dependency org="org.springframework" name="org.springframework.transaction" rev="latest.integration" conf="optional, tx->compile"/>
|
||||
<dependency org="org.springframework" name="org.springframework.orm" rev="latest.integration" conf="optional, orm->compile"/>
|
||||
<dependency org="org.springframework" name="org.springframework.test" rev="latest.integration" conf="test->runtime"/>
|
||||
<dependency org="org.springframework" name="org.springframework.context" rev="latest.integration" conf="test->runtime"/>
|
||||
<dependency org="org.springframework" name="org.springframework.context.support" rev="latest.integration" conf="test->runtime"/>
|
||||
<dependency org="org.springframework" name="org.springframework.context" rev="latest.integration" conf="context->compile"/>
|
||||
<dependency org="org.springframework" name="org.springframework.context.support" rev="latest.integration" conf="optional, cache->compile"/>
|
||||
<dependency org="javax.persistence" name="com.springsource.javax.persistence" rev="1.0.0" conf="optional, orm->compile"/>
|
||||
<dependency org="org.junit" name="com.springsource.org.junit" rev="${org.junit.version}" conf="test->compile"/>
|
||||
<dependency org="javax.mail" name="com.springsource.javax.mail" rev="1.4.0" conf="optional, test->compile"/>
|
||||
|
||||
@@ -1,90 +1,90 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-aspects</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>3.0.5.BUILD-SNAPSHOT</version>
|
||||
<parent>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-parent</artifactId>
|
||||
<relativePath>../org.springframework.spring-parent</relativePath>
|
||||
<version>3.0.5.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<!-- commons logging dependency is in spring-core -->
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-orm</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.persistence</groupId>
|
||||
<artifactId>persistence-api</artifactId>
|
||||
<version>1.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
<version>1.4</version>
|
||||
<scope>test</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<junitArtifactName>junit:junit</junitArtifactName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-aspects</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>3.1.0.M2</version>
|
||||
<parent>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-parent</artifactId>
|
||||
<relativePath>../org.springframework.spring-parent</relativePath>
|
||||
<version>3.1.0.M2</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<!-- common logging dependency is in spring-core -->
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-orm</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.persistence</groupId>
|
||||
<artifactId>persistence-api</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
<version>1.4</version>
|
||||
<scope>test</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<junitArtifactName>junit:junit</junitArtifactName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
Vendored
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cache.aspectj;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.aspectj.lang.annotation.SuppressAjWarnings;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.cache.interceptor.CacheAspectSupport;
|
||||
import org.springframework.cache.interceptor.CacheOperationSource;
|
||||
|
||||
/**
|
||||
* Abstract superaspect for AspectJ cache aspects. Concrete
|
||||
* subaspects will implement the <code>cacheMethodExecution()</code>
|
||||
* pointcut using a strategy such as Java 5 annotations.
|
||||
*
|
||||
* <p>Suitable for use inside or outside the Spring IoC container.
|
||||
* Set the "cacheManager" property appropriately, allowing
|
||||
* use of any cache implementation supported by Spring.
|
||||
*
|
||||
* <p><b>NB:</b> If a method implements an interface that is itself
|
||||
* cache annotated, the relevant Spring cache definition
|
||||
* will <i>not</i> be resolved.
|
||||
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public abstract aspect AbstractCacheAspect extends CacheAspectSupport {
|
||||
|
||||
protected AbstractCacheAspect() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct object using the given caching metadata retrieval strategy.
|
||||
* @param cos {@link CacheOperationSource} implementation, retrieving Spring
|
||||
* cache metadata for each joinpoint.
|
||||
*/
|
||||
protected AbstractCacheAspect(CacheOperationSource... cos) {
|
||||
setCacheDefinitionSources(cos);
|
||||
}
|
||||
|
||||
@SuppressAjWarnings("adviceDidNotMatch")
|
||||
Object around(final Object cachedObject) : cacheMethodExecution(cachedObject){
|
||||
MethodSignature methodSignature = (MethodSignature) thisJoinPoint.getSignature();
|
||||
Method method = methodSignature.getMethod();
|
||||
|
||||
Callable<Object> ajInvocation = new Callable<Object>() {
|
||||
|
||||
public Object call() {
|
||||
return proceed(cachedObject);
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
return execute(ajInvocation, thisJoinPoint.getTarget(), method, thisJoinPoint.getArgs());
|
||||
} catch (Exception ex) {
|
||||
throw new UnsupportedOperationException("Should not throw exception", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Concrete subaspects must implement this pointcut, to identify
|
||||
* cached methods. For each selected joinpoint, {@link CacheOperationDefinition}
|
||||
* will be retrieved using Spring's {@link CacheOperationSource} interface.
|
||||
*/
|
||||
protected abstract pointcut cacheMethodExecution(Object cachedObject);
|
||||
}
|
||||
org.springframework.aspects/src/main/java/org/springframework/cache/aspectj/AnnotationCacheAspect.aj
Vendored
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cache.aspectj;
|
||||
|
||||
import org.springframework.cache.annotation.AnnotationCacheOperationSource;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
|
||||
/**
|
||||
* Concrete AspectJ cache aspect using Spring {@link Cacheable} annotation
|
||||
* for JDK 1.5+.
|
||||
*
|
||||
* <p>When using this aspect, you <i>must</i> annotate the implementation class
|
||||
* (and/or methods within that class), <i>not</i> the interface (if any) that
|
||||
* the class implements. AspectJ follows Java's rule that annotations on
|
||||
* interfaces are <i>not</i> inherited.
|
||||
*
|
||||
* <p>A {@link Cacheable} annotation on a class specifies the default caching
|
||||
* semantics for the execution of any <b>public</b> operation in the class.
|
||||
*
|
||||
* <p>A {@link Cacheable} annotation on a method within the class overrides the
|
||||
* default caching semantics given by the class annotation (if present).
|
||||
* Any method may be annotated (regardless of visibility).
|
||||
* Annotating non-public methods directly is the only way
|
||||
* to get caching demarcation for the execution of such operations.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public aspect AnnotationCacheAspect extends AbstractCacheAspect {
|
||||
|
||||
public AnnotationCacheAspect() {
|
||||
super(new AnnotationCacheOperationSource(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches the execution of any public method in a type with the
|
||||
* {@link Cacheable} annotation, or any subtype of a type with the
|
||||
* {@link Cacheable} annotation.
|
||||
*/
|
||||
private pointcut executionOfAnyPublicMethodInAtCacheableType() :
|
||||
execution(public * ((@Cacheable *)+).*(..)) && @this(Cacheable);
|
||||
|
||||
/**
|
||||
* Matches the execution of any public method in a type with the
|
||||
* {@link CacheEvict} annotation, or any subtype of a type with the
|
||||
* {@link CacheEvict} annotation.
|
||||
*/
|
||||
private pointcut executionOfAnyPublicMethodInAtCacheEvictType() :
|
||||
execution(public * ((@CacheEvict *)+).*(..)) && @this(CacheEvict);
|
||||
|
||||
/**
|
||||
* Matches the execution of any method with the
|
||||
* Cacheable annotation.
|
||||
*/
|
||||
private pointcut executionOfCacheableMethod() :
|
||||
execution(* *(..)) && @annotation(Cacheable);
|
||||
|
||||
/**
|
||||
* Matches the execution of any method with the {@link CacheEvict} annotation.
|
||||
*/
|
||||
private pointcut executionOfCacheEvictMethod() :
|
||||
execution(* *(..)) && @annotation(CacheEvict);
|
||||
|
||||
/**
|
||||
* Definition of pointcut from super aspect - matched join points
|
||||
* will have Spring cache management applied.
|
||||
*/
|
||||
protected pointcut cacheMethodExecution(Object cachedObject) :
|
||||
(executionOfAnyPublicMethodInAtCacheableType() || executionOfAnyPublicMethodInAtCacheEvictType()
|
||||
|| executionOfCacheableMethod() || executionOfCacheEvictMethod())
|
||||
&& this(cachedObject);
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.scheduling.aspectj;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.AnnotationConfigUtils;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Role;
|
||||
import org.springframework.scheduling.annotation.AbstractAsyncConfiguration;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
/**
|
||||
* {@code @Configuration} class that registers the Spring infrastructure beans necessary
|
||||
* to enable AspectJ-based asynchronous method execution.
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @since 3.1
|
||||
* @see EnableAsync
|
||||
* @see AsyncConfigurationSelector
|
||||
*/
|
||||
@Configuration
|
||||
public class AspectJAsyncConfiguration extends AbstractAsyncConfiguration {
|
||||
|
||||
@Override
|
||||
@Bean(name=AnnotationConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME)
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
public AnnotationAsyncExecutionAspect asyncAdvisor() {
|
||||
AnnotationAsyncExecutionAspect asyncAspect = AnnotationAsyncExecutionAspect.aspectOf();
|
||||
if (this.executor != null) {
|
||||
asyncAspect.setExecutor(this.executor);
|
||||
}
|
||||
return asyncAspect;
|
||||
}
|
||||
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.transaction.aspectj;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Role;
|
||||
import org.springframework.transaction.annotation.AbstractTransactionManagementConfiguration;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.springframework.transaction.annotation.TransactionManagementConfigurationSelector;
|
||||
import org.springframework.transaction.config.TransactionManagementConfigUtils;
|
||||
|
||||
/**
|
||||
* {@code @Configuration} class that registers the Spring infrastructure beans necessary
|
||||
* to enable AspectJ-based annotation-driven transaction management.
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @since 3.1
|
||||
* @see EnableTransactionManagement
|
||||
* @see TransactionManagementConfigurationSelector
|
||||
*/
|
||||
@Configuration
|
||||
public class AspectJTransactionManagementConfiguration extends AbstractTransactionManagementConfiguration {
|
||||
|
||||
@Bean(name=TransactionManagementConfigUtils.TRANSACTION_ASPECT_BEAN_NAME)
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
public AnnotationTransactionAspect transactionAspect() {
|
||||
AnnotationTransactionAspect txAspect = AnnotationTransactionAspect.aspectOf();
|
||||
if (this.txManager != null) {
|
||||
txAspect.setTransactionManager(this.txManager);
|
||||
}
|
||||
return txAspect;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
=======================================================================
|
||||
|
||||
SPRING FRAMEWORK 3.1 SUBCOMPONENTS:
|
||||
|
||||
Spring Framework 3.1 includes a number of subcomponents with
|
||||
separate copyright notices and license terms. The product that
|
||||
includes this file does not necessarily use all the open source
|
||||
subcomponents referred to below. Your use of the source
|
||||
code for these subcomponents is subject to the terms and
|
||||
conditions of the following licenses.
|
||||
|
||||
>>> asm-2.2.3:
|
||||
|
||||
Copyright (c) 2000-2005 INRIA, France Telecom
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holders nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Copyright (c) 1999-2009, OW2 Consortium <http://www.ow2.org/>
|
||||
|
||||
=======================================================================
|
||||
|
||||
To the extent any open source subcomponents are licensed under the EPL and/or other
|
||||
similar licenses that require the source code and/or modifications to
|
||||
source code to be made available (as would be noted above), you may obtain a
|
||||
copy of the source code corresponding to the binaries for such open source
|
||||
components and modifications thereto, if any, (the "Source Files"), by
|
||||
downloading the Source Files from http://www.springsource.org/download,
|
||||
or by sending a request, with your name and address to: VMware, Inc., 3401 Hillview
|
||||
Avenue, Palo Alto, CA 94304, United States of America or email info@vmware.com. All
|
||||
such requests should clearly specify: OPEN SOURCE FILES REQUEST, Attention General
|
||||
Counsel. VMware shall mail a copy of the Source Files to you on a CD or equivalent
|
||||
physical medium. This offer to obtain a copy of the Source Files is valid for three
|
||||
years from the date you acquired this Software product.
|
||||
@@ -0,0 +1,9 @@
|
||||
Spring Framework 3.1
|
||||
Copyright (c) 2002-2011 SpringSource, a division of VMware, Inc.
|
||||
|
||||
This product is licensed to you under the Apache License, Version 2.0 (the "License").
|
||||
You may not use this product except in compliance with the License.
|
||||
|
||||
This product may include a number of subcomponents with separate copyright notices and
|
||||
license terms. Your use of the source code for the these subcomponents is subject to
|
||||
the terms and conditions of the subcomponent's license, as noted in the LICENSE file.
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cache.aspectj;
|
||||
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.cache.config.CacheableService;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* Abstract annotation test (containing several reusable methods).
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public abstract class AbstractAnnotationTest {
|
||||
|
||||
protected ApplicationContext ctx;
|
||||
|
||||
protected CacheableService cs;
|
||||
|
||||
protected CacheableService ccs;
|
||||
|
||||
protected abstract String getConfig();
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
ctx = new ClassPathXmlApplicationContext(getConfig());
|
||||
cs = ctx.getBean("service", CacheableService.class);
|
||||
ccs = ctx.getBean("classService", CacheableService.class);
|
||||
}
|
||||
|
||||
public void testCacheable(CacheableService service) throws Exception {
|
||||
Object o1 = new Object();
|
||||
Object o2 = new Object();
|
||||
|
||||
Object r1 = service.cache(o1);
|
||||
Object r2 = service.cache(o1);
|
||||
Object r3 = service.cache(o1);
|
||||
|
||||
assertSame(r1, r2);
|
||||
assertSame(r1, r3);
|
||||
}
|
||||
|
||||
public void testInvalidate(CacheableService service) throws Exception {
|
||||
Object o1 = new Object();
|
||||
Object o2 = new Object();
|
||||
|
||||
Object r1 = service.cache(o1);
|
||||
Object r2 = service.cache(o1);
|
||||
|
||||
assertSame(r1, r2);
|
||||
service.invalidate(o1);
|
||||
Object r3 = service.cache(o1);
|
||||
Object r4 = service.cache(o1);
|
||||
assertNotSame(r1, r3);
|
||||
assertSame(r3, r4);
|
||||
}
|
||||
|
||||
public void testConditionalExpression(CacheableService service) throws Exception {
|
||||
Object r1 = service.conditional(4);
|
||||
Object r2 = service.conditional(4);
|
||||
|
||||
assertNotSame(r1, r2);
|
||||
|
||||
Object r3 = service.conditional(3);
|
||||
Object r4 = service.conditional(3);
|
||||
|
||||
assertSame(r3, r4);
|
||||
}
|
||||
|
||||
public void testKeyExpression(CacheableService service) throws Exception {
|
||||
Object r1 = service.key(5, 1);
|
||||
Object r2 = service.key(5, 2);
|
||||
|
||||
assertSame(r1, r2);
|
||||
|
||||
Object r3 = service.key(1, 5);
|
||||
Object r4 = service.key(2, 5);
|
||||
|
||||
assertNotSame(r3, r4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCacheable() throws Exception {
|
||||
testCacheable(cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidate() throws Exception {
|
||||
testInvalidate(cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConditionalExpression() throws Exception {
|
||||
testConditionalExpression(cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKeyExpression() throws Exception {
|
||||
testKeyExpression(cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassCacheCacheable() throws Exception {
|
||||
testCacheable(ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassCacheInvalidate() throws Exception {
|
||||
testInvalidate(ccs);
|
||||
}
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cache.aspectj;
|
||||
|
||||
|
||||
/**
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public class AspectJAnnotationTest extends AbstractAnnotationTest {
|
||||
|
||||
@Override
|
||||
protected String getConfig() {
|
||||
return "/org/springframework/cache/config/annotation-cache-aspectj.xml";
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cache.config;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
|
||||
/**
|
||||
* @author Costin Leau
|
||||
*/
|
||||
@Cacheable("default")
|
||||
public class AnnotatedClassCacheableService implements CacheableService {
|
||||
|
||||
private AtomicLong counter = new AtomicLong();
|
||||
|
||||
public Object cache(Object arg1) {
|
||||
return counter.getAndIncrement();
|
||||
}
|
||||
|
||||
public Object conditional(int field) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@CacheEvict("default")
|
||||
public void invalidate(Object arg1) {
|
||||
}
|
||||
|
||||
@Cacheable(value = "default", key = "#p0")
|
||||
public Object key(Object arg1, Object arg2) {
|
||||
return counter.getAndIncrement();
|
||||
}
|
||||
}
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cache.config;
|
||||
|
||||
/**
|
||||
* Basic service interface.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public interface CacheableService<T> {
|
||||
|
||||
T cache(Object arg1);
|
||||
|
||||
void invalidate(Object arg1);
|
||||
|
||||
T conditional(int field);
|
||||
|
||||
T key(Object arg1, Object arg2);
|
||||
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cache.config;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
|
||||
|
||||
/**
|
||||
* Simple cacheable service
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public class DefaultCacheableService implements CacheableService<Long> {
|
||||
|
||||
private AtomicLong counter = new AtomicLong();
|
||||
|
||||
@Cacheable("default")
|
||||
public Long cache(Object arg1) {
|
||||
return counter.getAndIncrement();
|
||||
}
|
||||
|
||||
@CacheEvict("default")
|
||||
public void invalidate(Object arg1) {
|
||||
}
|
||||
|
||||
@Cacheable(value = "default", condition = "#classField == 3")
|
||||
public Long conditional(int classField) {
|
||||
return counter.getAndIncrement();
|
||||
}
|
||||
|
||||
@Cacheable(value = "default", key = "#p0")
|
||||
public Long key(Object arg1, Object arg2) {
|
||||
return counter.getAndIncrement();
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
|
||||
|
||||
<bean id="annotationSource" class="org.springframework.cache.annotation.AnnotationCacheOperationSource"/>
|
||||
|
||||
<aop:config>
|
||||
<aop:advisor advice-ref="debugInterceptor" pointcut="execution(* *..CacheableService.*(..))" order="1"/>
|
||||
</aop:config>
|
||||
|
||||
<bean id="cacheAspect" class="org.springframework.cache.aspectj.AnnotationCacheAspect" factory-method="aspectOf">
|
||||
<property name="cacheManager" ref="cacheManager"/>
|
||||
<property name="cacheDefinitionSources" ref="annotationSource"/>
|
||||
</bean>
|
||||
|
||||
<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
|
||||
<property name="caches">
|
||||
<set>
|
||||
<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="default"/>
|
||||
</set>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="debugInterceptor" class="org.springframework.aop.interceptor.DebugInterceptor"/>
|
||||
|
||||
<bean id="service" class="org.springframework.cache.config.DefaultCacheableService"/>
|
||||
<bean id="classService" class="org.springframework.cache.config.AnnotatedClassCacheableService"/>
|
||||
|
||||
</beans>
|
||||
@@ -1,16 +1,20 @@
|
||||
Bundle-SymbolicName: org.springframework.aspects
|
||||
Bundle-Name: Spring Aspects
|
||||
Bundle-Vendor: SpringSource
|
||||
Bundle-ManifestVersion: 2
|
||||
Import-Template:
|
||||
org.apache.commons.logging.*;version="[1.1.1, 2.0.0)",
|
||||
org.aspectj.*;version=${aj.osgi.range};resolution:=optional,
|
||||
org.springframework.beans.*;version=${spring.osgi.range},
|
||||
org.springframework.transaction.*;version=${spring.osgi.range};resolution:=optional,
|
||||
org.springframework.core.task.*;version=${spring.osgi.range};resolution:=optional,
|
||||
org.springframework.orm.jpa.*;version=${spring.osgi.range};resolution:=optional,
|
||||
org.springframework.dao.*;version=${spring.osgi.range};resolution:=optional
|
||||
Ignored-Existing-Headers:
|
||||
Bnd-LastModified,
|
||||
Import-Package,
|
||||
Tool
|
||||
Bundle-SymbolicName: org.springframework.aspects
|
||||
Bundle-Name: Spring Aspects
|
||||
Bundle-Vendor: SpringSource
|
||||
Bundle-ManifestVersion: 2
|
||||
Import-Template:
|
||||
javax.persistence;version="[1.0.0,3.0.0)";resolution:=optional,
|
||||
org.apache.commons.logging.*;version="[1.1.1, 2.0.0)",
|
||||
org.aspectj.*;version=${aj.osgi.range};resolution:=optional,
|
||||
org.springframework.context.*;version=${spring.osgi.range},
|
||||
org.springframework.beans.*;version=${spring.osgi.range},
|
||||
org.springframework.cache.*;version=${spring.osgi.range};resolution:=optional,
|
||||
org.springframework.core.*;version=${spring.osgi.range},
|
||||
org.springframework.dao.*;version=${spring.osgi.range};resolution:=optional,
|
||||
org.springframework.orm.*;version=${spring.osgi.range};resolution:=optional,
|
||||
org.springframework.scheduling.*;version=${spring.osgi.range};resolution:=optional,
|
||||
org.springframework.transaction.*;version=${spring.osgi.range};resolution:=optional
|
||||
Ignored-Existing-Headers:
|
||||
Bnd-LastModified,
|
||||
Import-Package,
|
||||
Tool
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
<classpathentry kind="var" path="IVY_CACHE/javax.inject/com.springsource.javax.inject/1.0.0/com.springsource.javax.inject-1.0.0.jar" sourcepath="/IVY_CACHE/javax.inject/com.springsource.javax.inject/1.0.0/com.springsource.javax.inject-sources-1.0.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/net.sourceforge.cglib/com.springsource.net.sf.cglib/2.2.0/com.springsource.net.sf.cglib-2.2.0.jar" sourcepath="/IVY_CACHE/net.sourceforge.cglib/com.springsource.net.sf.cglib/2.1.3/com.springsource.net.sf.cglib-sources-2.1.3.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.log4j/com.springsource.org.apache.log4j/1.2.15/com.springsource.org.apache.log4j-1.2.15.jar" sourcepath="/IVY_CACHE/org.apache.log4j/com.springsource.org.apache.log4j/1.2.15/com.springsource.org.apache.log4j-sources-1.2.15.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-4.7.0.jar" sourcepath="/IVY_CACHE/org.junit/com.springsource.org.junit/4.7.0/com.springsource.org.junit-sources-4.6.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.junit/com.springsource.org.junit/4.8.1/com.springsource.org.junit-4.8.1.jar" sourcepath="/IVY_CACHE/org.junit/com.springsource.org.junit/4.8.1/com.springsource.org.junit-sources-4.8.1.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.hamcrest/com.springsource.org.hamcrest/1.1.0/com.springsource.org.hamcrest-1.1.0.jar" sourcepath="/IVY_CACHE/org.hamcrest/com.springsource.org.hamcrest/1.1.0/com.springsource.org.hamcrest-sources-1.1.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.easymock/com.springsource.org.easymock/2.5.1/com.springsource.org.easymock-2.5.1.jar" sourcepath="/IVY_CACHE/org.easymock/com.springsource.org.easymock/2.5.1/com.springsource.org.easymock-sources-2.5.1.jar"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
#Wed Jul 15 00:01:31 PDT 2009
|
||||
#Mon Sep 06 21:54:17 CEST 2010
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<orderEntry type="library" name="EasyMock" level="project" />
|
||||
<orderEntry type="library" name="javax.el" level="project" />
|
||||
<orderEntry type="library" name="javax.inject" level="project" />
|
||||
<orderEntry type="library" name="Hamcrest" level="project" />
|
||||
<orderEntry type="library" name="JUnit" level="project" />
|
||||
<orderEntry type="library" name="Log4j" level="project" />
|
||||
</component>
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
<!-- test dependencies -->
|
||||
<dependency org="org.apache.log4j" name="com.springsource.org.apache.log4j" rev="1.2.15" conf="test->runtime"/>
|
||||
<dependency org="org.junit" name="com.springsource.org.junit" rev="${org.junit.version}" conf="test->runtime"/>
|
||||
<dependency org="org.hamcrest" name="com.springsource.org.hamcrest" rev="1.1.0" conf="test->runtime"/>
|
||||
<dependency org="org.easymock" name="com.springsource.org.easymock" rev="2.5.1" conf="test->compile"/>
|
||||
<dependency org="org.springframework" name="org.springframework.asm" rev="latest.integration" conf="compile->compile"/>
|
||||
</dependencies>
|
||||
|
||||
@@ -4,15 +4,20 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>3.0.5.BUILD-SNAPSHOT</version>
|
||||
<version>3.1.0.M2</version>
|
||||
<parent>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-parent</artifactId>
|
||||
<relativePath>../org.springframework.spring-parent</relativePath>
|
||||
<version>3.0.5.BUILD-SNAPSHOT</version>
|
||||
<version>3.1.0.M2</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-all</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.el</groupId>
|
||||
<artifactId>el-api</artifactId>
|
||||
@@ -48,7 +53,7 @@
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>org.easymock</groupId>
|
||||
<artifactId>easymock</artifactId>
|
||||
<scope>test</scope>
|
||||
|
||||
@@ -86,7 +86,7 @@ public abstract class BeanUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to instantiate a class using its no-arg constructor.
|
||||
* Instantiate a class using its no-arg constructor.
|
||||
* As this method doesn't try to load classes by name, it should avoid
|
||||
* class-loading issues.
|
||||
* <p>Note that this method tries to set the constructor accessible
|
||||
@@ -108,6 +108,27 @@ public abstract class BeanUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a class using its no-arg constructor and return the new instance
|
||||
* as the the specified assignable type.
|
||||
* <p>Useful in cases where
|
||||
* the type of the class to instantiate (clazz) is not available, but the type
|
||||
* desired (assignableTo) is known.
|
||||
* <p>As this method doesn't try to load classes by name, it should avoid
|
||||
* class-loading issues.
|
||||
* <p>Note that this method tries to set the constructor accessible
|
||||
* if given a non-accessible (that is, non-public) constructor.
|
||||
* @param clazz class to instantiate
|
||||
* @param assignableTo type that clazz must be assignableTo
|
||||
* @return the new instance
|
||||
* @throws BeanInstantiationException if the bean cannot be instantiated
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T instantiateClass(Class<?> clazz, Class<T> assignableTo) throws BeanInstantiationException {
|
||||
Assert.isAssignable(assignableTo, clazz);
|
||||
return (T)instantiateClass(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to instantiate a class using the given constructor.
|
||||
* As this method doesn't try to load classes by name, it should avoid
|
||||
|
||||
+49
-37
@@ -37,14 +37,13 @@ import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.CollectionFactory;
|
||||
import org.springframework.core.GenericCollectionTypeResolver;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.convert.ConversionException;
|
||||
import org.springframework.core.convert.ConverterNotFoundException;
|
||||
import org.springframework.core.convert.Property;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.core.convert.support.PropertyTypeDescriptor;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -364,15 +363,19 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||
|
||||
public TypeDescriptor getPropertyTypeDescriptor(String propertyName) throws BeansException {
|
||||
try {
|
||||
String actualPropertyName = PropertyAccessorUtils.getPropertyName(propertyName);
|
||||
PropertyDescriptor pd = getPropertyDescriptorInternal(actualPropertyName);
|
||||
BeanWrapperImpl nestedBw = getBeanWrapperForPropertyPath(propertyName);
|
||||
String finalPath = getFinalPath(nestedBw, propertyName);
|
||||
PropertyTokenHolder tokens = getPropertyNameTokens(finalPath);
|
||||
PropertyDescriptor pd = nestedBw.getCachedIntrospectionResults().getPropertyDescriptor(tokens.actualName);
|
||||
if (pd != null) {
|
||||
Class type = getPropertyType(propertyName);
|
||||
if (pd.getReadMethod() != null) {
|
||||
return new PropertyTypeDescriptor(pd, new MethodParameter(pd.getReadMethod(), -1), type);
|
||||
}
|
||||
else if (pd.getWriteMethod() != null) {
|
||||
return new PropertyTypeDescriptor(pd, BeanUtils.getWriteMethodParameter(pd), type);
|
||||
if (tokens.keys != null) {
|
||||
if (pd.getReadMethod() != null || pd.getWriteMethod() != null) {
|
||||
return TypeDescriptor.nested(property(pd), tokens.keys.length);
|
||||
}
|
||||
} else {
|
||||
if (pd.getReadMethod() != null || pd.getWriteMethod() != null) {
|
||||
return new TypeDescriptor(property(pd));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -468,12 +471,6 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||
}
|
||||
}
|
||||
|
||||
private Object convertIfNecessary(String propertyName, Object oldValue, Object newValue, Class<?> requiredType)
|
||||
throws TypeMismatchException {
|
||||
|
||||
return convertIfNecessary(propertyName, oldValue, newValue, requiredType, TypeDescriptor.valueOf(requiredType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given value for the specified property to the latter's type.
|
||||
* <p>This method is only intended for optimizations in a BeanFactory.
|
||||
@@ -495,9 +492,9 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||
|
||||
private Object convertForProperty(String propertyName, Object oldValue, Object newValue, PropertyDescriptor pd)
|
||||
throws TypeMismatchException {
|
||||
|
||||
return convertIfNecessary(propertyName, oldValue, newValue, pd.getPropertyType(),
|
||||
new PropertyTypeDescriptor(pd, BeanUtils.getWriteMethodParameter(pd)));
|
||||
GenericTypeAwarePropertyDescriptor gpd = (GenericTypeAwarePropertyDescriptor) pd;
|
||||
Class<?> beanClass = gpd.getBeanClass();
|
||||
return convertIfNecessary(propertyName, oldValue, newValue, pd.getPropertyType(), new TypeDescriptor(property(pd)));
|
||||
}
|
||||
|
||||
|
||||
@@ -592,11 +589,11 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||
private Object setDefaultValue(PropertyTokenHolder tokens) {
|
||||
PropertyValue pv = createDefaultPropertyValue(tokens);
|
||||
setPropertyValue(tokens, pv);
|
||||
return pv.getValue();
|
||||
return getPropertyValue(tokens);
|
||||
}
|
||||
|
||||
private PropertyValue createDefaultPropertyValue(PropertyTokenHolder tokens) {
|
||||
Class type = getPropertyType(tokens.canonicalName);
|
||||
Class<?> type = getPropertyTypeDescriptor(tokens.canonicalName).getType();
|
||||
if (type == null) {
|
||||
throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + tokens.canonicalName,
|
||||
"Could not determine property type for auto-growing a default value");
|
||||
@@ -630,6 +627,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// TODO Root cause exception context is lost here... should we throw another exception type that preserves context instead?
|
||||
throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + name,
|
||||
"Could not instantiate property type [" + type.getName() + "] to auto-grow nested property path: " + ex);
|
||||
}
|
||||
@@ -793,8 +791,8 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||
Class<?> mapKeyType = GenericCollectionTypeResolver.getMapKeyReturnType(pd.getReadMethod(), i + 1);
|
||||
// IMPORTANT: Do not pass full property name in here - property editors
|
||||
// must not kick in for map keys but rather only for map values.
|
||||
Object convertedMapKey = convertIfNecessary(null, null, key, mapKeyType,
|
||||
new PropertyTypeDescriptor(pd, new MethodParameter(pd.getReadMethod(), -1), mapKeyType));
|
||||
TypeDescriptor typeDescriptor = mapKeyType != null ? TypeDescriptor.valueOf(mapKeyType) : TypeDescriptor.valueOf(Object.class);
|
||||
Object convertedMapKey = convertIfNecessary(null, null, key, mapKeyType, typeDescriptor);
|
||||
value = map.get(convertedMapKey);
|
||||
}
|
||||
else {
|
||||
@@ -841,8 +839,9 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||
for (int i = length; i < Array.getLength(newArray); i++) {
|
||||
Array.set(newArray, i, newValue(componentType, name));
|
||||
}
|
||||
// TODO this is not efficient because conversion may create a copy ... set directly because we know its assignable.
|
||||
setPropertyValue(name, newArray);
|
||||
return newArray;
|
||||
return getPropertyValue(name);
|
||||
}
|
||||
else {
|
||||
return array;
|
||||
@@ -928,21 +927,31 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||
// Set value for last key.
|
||||
String key = tokens.keys[tokens.keys.length - 1];
|
||||
if (propValue == null) {
|
||||
throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + propertyName,
|
||||
"Cannot access indexed value in property referenced " +
|
||||
"in indexed property path '" + propertyName + "': returned null");
|
||||
// null map value case
|
||||
if (this.autoGrowNestedPaths) {
|
||||
// TODO: cleanup, this is pretty hacky
|
||||
int lastKeyIndex = tokens.canonicalName.lastIndexOf('[');
|
||||
getterTokens.canonicalName = tokens.canonicalName.substring(0, lastKeyIndex);
|
||||
propValue = setDefaultValue(getterTokens);
|
||||
}
|
||||
else {
|
||||
throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + propertyName,
|
||||
"Cannot access indexed value in property referenced " +
|
||||
"in indexed property path '" + propertyName + "': returned null");
|
||||
}
|
||||
}
|
||||
else if (propValue.getClass().isArray()) {
|
||||
if (propValue.getClass().isArray()) {
|
||||
PropertyDescriptor pd = getCachedIntrospectionResults().getPropertyDescriptor(actualName);
|
||||
Class requiredType = propValue.getClass().getComponentType();
|
||||
int arrayIndex = Integer.parseInt(key);
|
||||
Object oldValue = null;
|
||||
try {
|
||||
if (isExtractOldValueForEditor()) {
|
||||
if (isExtractOldValueForEditor() && arrayIndex < Array.getLength(propValue)) {
|
||||
oldValue = Array.get(propValue, arrayIndex);
|
||||
}
|
||||
Object convertedValue = convertIfNecessary(propertyName, oldValue, pv.getValue(), requiredType,
|
||||
new PropertyTypeDescriptor(pd, new MethodParameter(pd.getReadMethod(), -1), requiredType));
|
||||
Object convertedValue = convertIfNecessary(propertyName, oldValue, pv.getValue(), requiredType, TypeDescriptor.nested(property(pd), tokens.keys.length));
|
||||
// TODO review this grow algorithm along side the null gap algorithm for setting lists below ... the two are inconsistent
|
||||
propValue = growArrayIfNecessary(propValue, arrayIndex, actualName);
|
||||
Array.set(propValue, arrayIndex, convertedValue);
|
||||
}
|
||||
catch (IndexOutOfBoundsException ex) {
|
||||
@@ -960,8 +969,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||
if (isExtractOldValueForEditor() && index < list.size()) {
|
||||
oldValue = list.get(index);
|
||||
}
|
||||
Object convertedValue = convertIfNecessary(propertyName, oldValue, pv.getValue(), requiredType,
|
||||
new PropertyTypeDescriptor(pd, new MethodParameter(pd.getReadMethod(), -1), requiredType));
|
||||
Object convertedValue = convertIfNecessary(propertyName, oldValue, pv.getValue(), requiredType, TypeDescriptor.nested(property(pd), tokens.keys.length));
|
||||
if (index < list.size()) {
|
||||
list.set(index, convertedValue);
|
||||
}
|
||||
@@ -989,8 +997,8 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||
Map map = (Map) propValue;
|
||||
// IMPORTANT: Do not pass full property name in here - property editors
|
||||
// must not kick in for map keys but rather only for map values.
|
||||
Object convertedMapKey = convertIfNecessary(null, null, key, mapKeyType,
|
||||
new PropertyTypeDescriptor(pd, new MethodParameter(pd.getReadMethod(), -1), mapKeyType));
|
||||
TypeDescriptor typeDescriptor = mapKeyType != null ? TypeDescriptor.valueOf(mapKeyType) : TypeDescriptor.valueOf(Object.class);
|
||||
Object convertedMapKey = convertIfNecessary(null, null, key, mapKeyType, typeDescriptor);
|
||||
Object oldValue = null;
|
||||
if (isExtractOldValueForEditor()) {
|
||||
oldValue = map.get(convertedMapKey);
|
||||
@@ -998,8 +1006,7 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||
// Pass full property name and old value in here, since we want full
|
||||
// conversion ability for map values.
|
||||
Object convertedMapValue = convertIfNecessary(
|
||||
propertyName, oldValue, pv.getValue(), mapValueType,
|
||||
new TypeDescriptor(new MethodParameter(pd.getReadMethod(), -1, tokens.keys.length + 1)));
|
||||
propertyName, oldValue, pv.getValue(), mapValueType, TypeDescriptor.nested(property(pd), tokens.keys.length));
|
||||
map.put(convertedMapKey, convertedMapValue);
|
||||
}
|
||||
else {
|
||||
@@ -1161,5 +1168,10 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||
|
||||
public String[] keys;
|
||||
}
|
||||
|
||||
private Property property(PropertyDescriptor pd) {
|
||||
GenericTypeAwarePropertyDescriptor typeAware = (GenericTypeAwarePropertyDescriptor) pd;
|
||||
return new Property(typeAware.getBeanClass(), typeAware.getReadMethod(), typeAware.getWriteMethod());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -221,7 +221,7 @@ public class CachedIntrospectionResults {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Getting BeanInfo for class [" + beanClass.getName() + "]");
|
||||
}
|
||||
this.beanInfo = Introspector.getBeanInfo(beanClass);
|
||||
this.beanInfo = new ExtendedBeanInfo(Introspector.getBeanInfo(beanClass));
|
||||
|
||||
// Immediately remove class from Introspector cache, to allow for proper
|
||||
// garbage collection on class loader shutdown - we cache it here anyway,
|
||||
|
||||
+332
@@ -0,0 +1,332 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.beans;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.beans.BeanDescriptor;
|
||||
import java.beans.BeanInfo;
|
||||
import java.beans.EventSetDescriptor;
|
||||
import java.beans.IndexedPropertyDescriptor;
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.Introspector;
|
||||
import java.beans.MethodDescriptor;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Comparator;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Decorates a standard {@link BeanInfo} object (likely created created by
|
||||
* {@link Introspector#getBeanInfo(Class)}) by including non-void returning setter
|
||||
* methods in the collection of {@link #getPropertyDescriptors() property descriptors}.
|
||||
* Both regular and
|
||||
* <a href="http://download.oracle.com/javase/tutorial/javabeans/properties/indexed.html">
|
||||
* indexed properties</a> are fully supported.
|
||||
*
|
||||
* <p>The wrapped {@code BeanInfo} object is not modified in any way.
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @since 3.1
|
||||
* @see CachedIntrospectionResults
|
||||
*/
|
||||
public class ExtendedBeanInfo implements BeanInfo {
|
||||
private final BeanInfo delegate;
|
||||
private final SortedSet<PropertyDescriptor> propertyDescriptors =
|
||||
new TreeSet<PropertyDescriptor>(new PropertyDescriptorComparator());
|
||||
|
||||
/**
|
||||
* Wrap the given delegate {@link BeanInfo} instance and find any non-void returning
|
||||
* setter methods, creating and adding a {@link PropertyDescriptor} for each.
|
||||
*
|
||||
* <p>The wrapped {@code BeanInfo} is not modified in any way by this process.
|
||||
*
|
||||
* @see #getPropertyDescriptors()
|
||||
* @throws IntrospectionException if any problems occur creating and adding new {@code PropertyDescriptors}
|
||||
*/
|
||||
public ExtendedBeanInfo(BeanInfo delegate) throws IntrospectionException {
|
||||
this.delegate = delegate;
|
||||
|
||||
// PropertyDescriptor instances from the delegate object are never added directly, but always
|
||||
// copied to the local collection of #propertyDescriptors and returned by calls to
|
||||
// #getPropertyDescriptors(). this algorithm iterates through all methods (method descriptors)
|
||||
// in the wrapped BeanInfo object, copying any existing PropertyDescriptor or creating a new
|
||||
// one for any non-standard setter methods found.
|
||||
|
||||
ALL_METHODS:
|
||||
for (MethodDescriptor md : delegate.getMethodDescriptors()) {
|
||||
Method method = md.getMethod();
|
||||
|
||||
// bypass non-getter java.lang.Class methods for efficiency
|
||||
if (ReflectionUtils.isObjectMethod(method) && !method.getName().startsWith("get")) {
|
||||
continue ALL_METHODS;
|
||||
}
|
||||
|
||||
// is the method a NON-INDEXED setter? ignore return type in order to capture non-void signatures
|
||||
if (method.getName().startsWith("set") && method.getParameterTypes().length == 1) {
|
||||
String propertyName = propertyNameFor(method);
|
||||
if(propertyName.length() == 0) {
|
||||
continue ALL_METHODS;
|
||||
}
|
||||
for (PropertyDescriptor pd : delegate.getPropertyDescriptors()) {
|
||||
Method readMethod = pd.getReadMethod();
|
||||
Method writeMethod = pd.getWriteMethod();
|
||||
// has the setter already been found by the wrapped BeanInfo?
|
||||
if (writeMethod != null
|
||||
&& writeMethod.getName().equals(method.getName())) {
|
||||
// yes -> copy it, including corresponding getter method (if any -- may be null)
|
||||
this.addOrUpdatePropertyDescriptor(propertyName, readMethod, writeMethod);
|
||||
continue ALL_METHODS;
|
||||
}
|
||||
// has a getter corresponding to this setter already been found by the wrapped BeanInfo?
|
||||
if (readMethod != null
|
||||
&& readMethod.getName().equals(getterMethodNameFor(propertyName))
|
||||
&& readMethod.getReturnType().equals(method.getParameterTypes()[0])) {
|
||||
this.addOrUpdatePropertyDescriptor(propertyName, readMethod, method);
|
||||
continue ALL_METHODS;
|
||||
}
|
||||
}
|
||||
// the setter method was not found by the wrapped BeanInfo -> add a new PropertyDescriptor for it
|
||||
// no corresponding getter was detected, so the 'read method' parameter is null.
|
||||
this.addOrUpdatePropertyDescriptor(propertyName, null, method);
|
||||
continue ALL_METHODS;
|
||||
}
|
||||
|
||||
// is the method an INDEXED setter? ignore return type in order to capture non-void signatures
|
||||
if (method.getName().startsWith("set") && method.getParameterTypes().length == 2 && method.getParameterTypes()[0].equals(int.class)) {
|
||||
String propertyName = propertyNameFor(method);
|
||||
if(propertyName.length() == 0) {
|
||||
continue ALL_METHODS;
|
||||
}
|
||||
DELEGATE_PD:
|
||||
for (PropertyDescriptor pd : delegate.getPropertyDescriptors()) {
|
||||
if (!(pd instanceof IndexedPropertyDescriptor)) {
|
||||
continue DELEGATE_PD;
|
||||
}
|
||||
IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
|
||||
Method readMethod = ipd.getReadMethod();
|
||||
Method writeMethod = ipd.getWriteMethod();
|
||||
Method indexedReadMethod = ipd.getIndexedReadMethod();
|
||||
Method indexedWriteMethod = ipd.getIndexedWriteMethod();
|
||||
// has the setter already been found by the wrapped BeanInfo?
|
||||
if (indexedWriteMethod != null
|
||||
&& indexedWriteMethod.getName().equals(method.getName())) {
|
||||
// yes -> copy it, including corresponding getter method (if any -- may be null)
|
||||
this.addOrUpdatePropertyDescriptor(propertyName, readMethod, writeMethod, indexedReadMethod, indexedWriteMethod);
|
||||
continue ALL_METHODS;
|
||||
}
|
||||
// has a getter corresponding to this setter already been found by the wrapped BeanInfo?
|
||||
if (indexedReadMethod != null
|
||||
&& indexedReadMethod.getName().equals(getterMethodNameFor(propertyName))
|
||||
&& indexedReadMethod.getReturnType().equals(method.getParameterTypes()[1])) {
|
||||
this.addOrUpdatePropertyDescriptor(propertyName, readMethod, writeMethod, indexedReadMethod, method);
|
||||
continue ALL_METHODS;
|
||||
}
|
||||
}
|
||||
// the INDEXED setter method was not found by the wrapped BeanInfo -> add a new PropertyDescriptor
|
||||
// for it. no corresponding INDEXED getter was detected, so the 'indexed read method' parameter is null.
|
||||
this.addOrUpdatePropertyDescriptor(propertyName, null, null, null, method);
|
||||
continue ALL_METHODS;
|
||||
}
|
||||
|
||||
// the method is not a setter, but is it a getter?
|
||||
for (PropertyDescriptor pd : delegate.getPropertyDescriptors()) {
|
||||
// have we already copied this read method to a property descriptor locally?
|
||||
for (PropertyDescriptor existingPD : this.propertyDescriptors) {
|
||||
if (method.equals(pd.getReadMethod())
|
||||
&& existingPD.getName().equals(pd.getName())) {
|
||||
if (existingPD.getReadMethod() == null) {
|
||||
// no -> add it now
|
||||
this.addOrUpdatePropertyDescriptor(pd.getName(), method, pd.getWriteMethod());
|
||||
}
|
||||
// yes -> do not add a duplicate
|
||||
continue ALL_METHODS;
|
||||
}
|
||||
}
|
||||
if (method == pd.getReadMethod()
|
||||
|| (pd instanceof IndexedPropertyDescriptor && method == ((IndexedPropertyDescriptor) pd).getIndexedReadMethod())) {
|
||||
// yes -> copy it, including corresponding setter method (if any -- may be null)
|
||||
if (pd instanceof IndexedPropertyDescriptor) {
|
||||
this.addOrUpdatePropertyDescriptor(pd.getName(), pd.getReadMethod(), pd.getWriteMethod(), ((IndexedPropertyDescriptor)pd).getIndexedReadMethod(), ((IndexedPropertyDescriptor)pd).getIndexedWriteMethod());
|
||||
} else {
|
||||
this.addOrUpdatePropertyDescriptor(pd.getName(), pd.getReadMethod(), pd.getWriteMethod());
|
||||
}
|
||||
continue ALL_METHODS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addOrUpdatePropertyDescriptor(String propertyName, Method readMethod, Method writeMethod) throws IntrospectionException {
|
||||
addOrUpdatePropertyDescriptor(propertyName, readMethod, writeMethod, null, null);
|
||||
}
|
||||
|
||||
private void addOrUpdatePropertyDescriptor(String propertyName, Method readMethod, Method writeMethod, Method indexedReadMethod, Method indexedWriteMethod) throws IntrospectionException {
|
||||
for (PropertyDescriptor existingPD : this.propertyDescriptors) {
|
||||
if (existingPD.getName().equals(propertyName)) {
|
||||
// is there already a descriptor that captures this read method or its corresponding write method?
|
||||
if (existingPD.getReadMethod() != null) {
|
||||
if (readMethod != null && existingPD.getReadMethod().getReturnType() != readMethod.getReturnType()
|
||||
|| writeMethod != null && existingPD.getReadMethod().getReturnType() != writeMethod.getParameterTypes()[0]) {
|
||||
// no -> add a new descriptor for it below
|
||||
break;
|
||||
}
|
||||
}
|
||||
// update the existing descriptor's read method
|
||||
if (readMethod != null) {
|
||||
try {
|
||||
existingPD.setReadMethod(readMethod);
|
||||
} catch (IntrospectionException ex) {
|
||||
// there is a conflicting setter method present -> null it out and try again
|
||||
existingPD.setWriteMethod(null);
|
||||
existingPD.setReadMethod(readMethod);
|
||||
}
|
||||
}
|
||||
|
||||
// is there already a descriptor that captures this write method or its corresponding read method?
|
||||
if (existingPD.getWriteMethod() != null) {
|
||||
if (readMethod != null && existingPD.getWriteMethod().getParameterTypes()[0] != readMethod.getReturnType()
|
||||
|| writeMethod != null && existingPD.getWriteMethod().getParameterTypes()[0] != writeMethod.getParameterTypes()[0]) {
|
||||
// no -> add a new descriptor for it below
|
||||
break;
|
||||
}
|
||||
}
|
||||
// update the existing descriptor's write method
|
||||
if (writeMethod != null) {
|
||||
existingPD.setWriteMethod(writeMethod);
|
||||
}
|
||||
|
||||
// is this descriptor indexed?
|
||||
if (existingPD instanceof IndexedPropertyDescriptor) {
|
||||
IndexedPropertyDescriptor existingIPD = (IndexedPropertyDescriptor) existingPD;
|
||||
|
||||
// is there already a descriptor that captures this indexed read method or its corresponding indexed write method?
|
||||
if (existingIPD.getIndexedReadMethod() != null) {
|
||||
if (indexedReadMethod != null && existingIPD.getIndexedReadMethod().getReturnType() != indexedReadMethod.getReturnType()
|
||||
|| indexedWriteMethod != null && existingIPD.getIndexedReadMethod().getReturnType() != indexedWriteMethod.getParameterTypes()[1]) {
|
||||
// no -> add a new descriptor for it below
|
||||
break;
|
||||
}
|
||||
}
|
||||
// update the existing descriptor's indexed read method
|
||||
try {
|
||||
existingIPD.setIndexedReadMethod(indexedReadMethod);
|
||||
} catch (IntrospectionException ex) {
|
||||
// there is a conflicting indexed setter method present -> null it out and try again
|
||||
existingIPD.setIndexedWriteMethod(null);
|
||||
existingIPD.setIndexedReadMethod(indexedReadMethod);
|
||||
}
|
||||
|
||||
// is there already a descriptor that captures this indexed write method or its corresponding indexed read method?
|
||||
if (existingIPD.getIndexedWriteMethod() != null) {
|
||||
if (indexedReadMethod != null && existingIPD.getIndexedWriteMethod().getParameterTypes()[1] != indexedReadMethod.getReturnType()
|
||||
|| indexedWriteMethod != null && existingIPD.getIndexedWriteMethod().getParameterTypes()[1] != indexedWriteMethod.getParameterTypes()[1]) {
|
||||
// no -> add a new descriptor for it below
|
||||
break;
|
||||
}
|
||||
}
|
||||
// update the existing descriptor's indexed write method
|
||||
if (indexedWriteMethod != null) {
|
||||
existingIPD.setIndexedWriteMethod(indexedWriteMethod);
|
||||
}
|
||||
}
|
||||
|
||||
// the descriptor has been updated -> return immediately
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// we haven't yet seen read or write methods for this property -> add a new descriptor
|
||||
if (indexedReadMethod == null && indexedWriteMethod == null) {
|
||||
this.propertyDescriptors.add(new PropertyDescriptor(propertyName, readMethod, writeMethod));
|
||||
} else {
|
||||
this.propertyDescriptors.add(new IndexedPropertyDescriptor(propertyName, readMethod, writeMethod, indexedReadMethod, indexedWriteMethod));
|
||||
}
|
||||
}
|
||||
|
||||
private String propertyNameFor(Method method) {
|
||||
return Introspector.decapitalize(method.getName().substring(3,method.getName().length()));
|
||||
}
|
||||
|
||||
private Object getterMethodNameFor(String name) {
|
||||
return "get" + StringUtils.capitalize(name);
|
||||
}
|
||||
|
||||
public BeanInfo[] getAdditionalBeanInfo() {
|
||||
return delegate.getAdditionalBeanInfo();
|
||||
}
|
||||
|
||||
public BeanDescriptor getBeanDescriptor() {
|
||||
return delegate.getBeanDescriptor();
|
||||
}
|
||||
|
||||
public int getDefaultEventIndex() {
|
||||
return delegate.getDefaultEventIndex();
|
||||
}
|
||||
|
||||
public int getDefaultPropertyIndex() {
|
||||
return delegate.getDefaultPropertyIndex();
|
||||
}
|
||||
|
||||
public EventSetDescriptor[] getEventSetDescriptors() {
|
||||
return delegate.getEventSetDescriptors();
|
||||
}
|
||||
|
||||
public Image getIcon(int arg0) {
|
||||
return delegate.getIcon(arg0);
|
||||
}
|
||||
|
||||
public MethodDescriptor[] getMethodDescriptors() {
|
||||
return delegate.getMethodDescriptors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the set of {@link PropertyDescriptor}s from the wrapped {@link BeanInfo}
|
||||
* object as well as {@code PropertyDescriptor}s for each non-void returning setter
|
||||
* method found during construction.
|
||||
* @see #ExtendedBeanInfo(BeanInfo)
|
||||
*/
|
||||
public PropertyDescriptor[] getPropertyDescriptors() {
|
||||
return this.propertyDescriptors.toArray(new PropertyDescriptor[this.propertyDescriptors.size()]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sorts PropertyDescriptor instances alphanumerically to emulate the behavior of {@link java.beans.BeanInfo#getPropertyDescriptors()}.
|
||||
*
|
||||
* @see ExtendedBeanInfo#propertyDescriptors
|
||||
*/
|
||||
static class PropertyDescriptorComparator implements Comparator<PropertyDescriptor> {
|
||||
public int compare(PropertyDescriptor desc1, PropertyDescriptor desc2) {
|
||||
String left = desc1.getName();
|
||||
String right = desc2.getName();
|
||||
for (int i = 0; i < left.length(); i++) {
|
||||
if (right.length() == i) {
|
||||
return 1;
|
||||
}
|
||||
int result = left.getBytes()[i] - right.getBytes()[i];
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return left.length() - right.length();
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -92,7 +92,10 @@ class GenericTypeAwarePropertyDescriptor extends PropertyDescriptor {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Class<?> getBeanClass() {
|
||||
return beanClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Method getReadMethod() {
|
||||
return this.readMethod;
|
||||
|
||||
+3
-3
@@ -39,7 +39,7 @@ public interface PropertyEditorRegistry {
|
||||
* @param requiredType the type of the property
|
||||
* @param propertyEditor the editor to register
|
||||
*/
|
||||
void registerCustomEditor(Class requiredType, PropertyEditor propertyEditor);
|
||||
void registerCustomEditor(Class<?> requiredType, PropertyEditor propertyEditor);
|
||||
|
||||
/**
|
||||
* Register the given custom property editor for the given type and
|
||||
@@ -64,7 +64,7 @@ public interface PropertyEditorRegistry {
|
||||
* <code>null</code> if registering an editor for all properties of the given type
|
||||
* @param propertyEditor editor to register
|
||||
*/
|
||||
void registerCustomEditor(Class requiredType, String propertyPath, PropertyEditor propertyEditor);
|
||||
void registerCustomEditor(Class<?> requiredType, String propertyPath, PropertyEditor propertyEditor);
|
||||
|
||||
/**
|
||||
* Find a custom property editor for the given type and property.
|
||||
@@ -74,6 +74,6 @@ public interface PropertyEditorRegistry {
|
||||
* <code>null</code> if looking for an editor for all properties of the given type
|
||||
* @return the registered editor, or <code>null</code> if none
|
||||
*/
|
||||
PropertyEditor findCustomEditor(Class requiredType, String propertyPath);
|
||||
PropertyEditor findCustomEditor(Class<?> requiredType, String propertyPath);
|
||||
|
||||
}
|
||||
|
||||
+28
-28
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2011 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.
|
||||
@@ -91,17 +91,17 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
|
||||
private boolean configValueEditorsActive = false;
|
||||
|
||||
private Map<Class, PropertyEditor> defaultEditors;
|
||||
private Map<Class<?>, PropertyEditor> defaultEditors;
|
||||
|
||||
private Map<Class, PropertyEditor> overriddenDefaultEditors;
|
||||
private Map<Class<?>, PropertyEditor> overriddenDefaultEditors;
|
||||
|
||||
private Map<Class, PropertyEditor> customEditors;
|
||||
private Map<Class<?>, PropertyEditor> customEditors;
|
||||
|
||||
private Map<String, CustomEditorHolder> customEditorsForPath;
|
||||
|
||||
private Set<PropertyEditor> sharedEditors;
|
||||
|
||||
private Map<Class, PropertyEditor> customEditorCache;
|
||||
private Map<Class<?>, PropertyEditor> customEditorCache;
|
||||
|
||||
|
||||
/**
|
||||
@@ -152,9 +152,9 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
* @param propertyEditor the editor to register
|
||||
* @see #registerCustomEditor(Class, PropertyEditor)
|
||||
*/
|
||||
public void overrideDefaultEditor(Class requiredType, PropertyEditor propertyEditor) {
|
||||
public void overrideDefaultEditor(Class<?> requiredType, PropertyEditor propertyEditor) {
|
||||
if (this.overriddenDefaultEditors == null) {
|
||||
this.overriddenDefaultEditors = new HashMap<Class, PropertyEditor>();
|
||||
this.overriddenDefaultEditors = new HashMap<Class<?>, PropertyEditor>();
|
||||
}
|
||||
this.overriddenDefaultEditors.put(requiredType, propertyEditor);
|
||||
}
|
||||
@@ -166,7 +166,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
* @return the default editor, or <code>null</code> if none found
|
||||
* @see #registerDefaultEditors
|
||||
*/
|
||||
public PropertyEditor getDefaultEditor(Class requiredType) {
|
||||
public PropertyEditor getDefaultEditor(Class<?> requiredType) {
|
||||
if (!this.defaultEditorsActive) {
|
||||
return null;
|
||||
}
|
||||
@@ -186,7 +186,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
* Actually register the default editors for this registry instance.
|
||||
*/
|
||||
private void createDefaultEditors() {
|
||||
this.defaultEditors = new HashMap<Class, PropertyEditor>(64);
|
||||
this.defaultEditors = new HashMap<Class<?>, PropertyEditor>(64);
|
||||
|
||||
// Simple editors, without parameterization capabilities.
|
||||
// The JDK does not contain a default editor for any of these target types.
|
||||
@@ -269,11 +269,11 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
// Management of custom editors
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
public void registerCustomEditor(Class requiredType, PropertyEditor propertyEditor) {
|
||||
public void registerCustomEditor(Class<?> requiredType, PropertyEditor propertyEditor) {
|
||||
registerCustomEditor(requiredType, null, propertyEditor);
|
||||
}
|
||||
|
||||
public void registerCustomEditor(Class requiredType, String propertyPath, PropertyEditor propertyEditor) {
|
||||
public void registerCustomEditor(Class<?> requiredType, String propertyPath, PropertyEditor propertyEditor) {
|
||||
if (requiredType == null && propertyPath == null) {
|
||||
throw new IllegalArgumentException("Either requiredType or propertyPath is required");
|
||||
}
|
||||
@@ -285,7 +285,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
}
|
||||
else {
|
||||
if (this.customEditors == null) {
|
||||
this.customEditors = new LinkedHashMap<Class, PropertyEditor>(16);
|
||||
this.customEditors = new LinkedHashMap<Class<?>, PropertyEditor>(16);
|
||||
}
|
||||
this.customEditors.put(requiredType, propertyEditor);
|
||||
this.customEditorCache = null;
|
||||
@@ -301,7 +301,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
* @deprecated as of Spring 3.0, in favor of PropertyEditorRegistrars or ConversionService usage
|
||||
*/
|
||||
@Deprecated
|
||||
public void registerSharedEditor(Class requiredType, PropertyEditor propertyEditor) {
|
||||
public void registerSharedEditor(Class<?> requiredType, PropertyEditor propertyEditor) {
|
||||
registerCustomEditor(requiredType, null, propertyEditor);
|
||||
if (this.sharedEditors == null) {
|
||||
this.sharedEditors = new HashSet<PropertyEditor>();
|
||||
@@ -319,8 +319,8 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
return (this.sharedEditors != null && this.sharedEditors.contains(propertyEditor));
|
||||
}
|
||||
|
||||
public PropertyEditor findCustomEditor(Class requiredType, String propertyPath) {
|
||||
Class requiredTypeToUse = requiredType;
|
||||
public PropertyEditor findCustomEditor(Class<?> requiredType, String propertyPath) {
|
||||
Class<?> requiredTypeToUse = requiredType;
|
||||
if (propertyPath != null) {
|
||||
if (this.customEditorsForPath != null) {
|
||||
// Check property-specific editor first.
|
||||
@@ -354,7 +354,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
* can be <code>null</code> if not known)
|
||||
* @return whether a matching custom editor has been found
|
||||
*/
|
||||
public boolean hasCustomEditorForElement(Class elementType, String propertyPath) {
|
||||
public boolean hasCustomEditorForElement(Class<?> elementType, String propertyPath) {
|
||||
if (propertyPath != null && this.customEditorsForPath != null) {
|
||||
for (Map.Entry<String, CustomEditorHolder> entry : this.customEditorsForPath.entrySet()) {
|
||||
if (PropertyAccessorUtils.matchesProperty(entry.getKey(), propertyPath)) {
|
||||
@@ -379,7 +379,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
* @return the type of the property, or <code>null</code> if not determinable
|
||||
* @see BeanWrapper#getPropertyType(String)
|
||||
*/
|
||||
protected Class getPropertyType(String propertyPath) {
|
||||
protected Class<?> getPropertyType(String propertyPath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
* @param requiredType the type to look for
|
||||
* @return the custom editor, or <code>null</code> if none specific for this property
|
||||
*/
|
||||
private PropertyEditor getCustomEditor(String propertyName, Class requiredType) {
|
||||
private PropertyEditor getCustomEditor(String propertyName, Class<?> requiredType) {
|
||||
CustomEditorHolder holder = this.customEditorsForPath.get(propertyName);
|
||||
return (holder != null ? holder.getPropertyEditor(requiredType) : null);
|
||||
}
|
||||
@@ -402,7 +402,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
* @return the custom editor, or <code>null</code> if none found for this type
|
||||
* @see java.beans.PropertyEditor#getAsText()
|
||||
*/
|
||||
private PropertyEditor getCustomEditor(Class requiredType) {
|
||||
private PropertyEditor getCustomEditor(Class<?> requiredType) {
|
||||
if (requiredType == null || this.customEditors == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -415,14 +415,14 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
}
|
||||
if (editor == null) {
|
||||
// Find editor for superclass or interface.
|
||||
for (Iterator<Class> it = this.customEditors.keySet().iterator(); it.hasNext() && editor == null;) {
|
||||
Class key = it.next();
|
||||
for (Iterator<Class<?>> it = this.customEditors.keySet().iterator(); it.hasNext() && editor == null;) {
|
||||
Class<?> key = it.next();
|
||||
if (key.isAssignableFrom(requiredType)) {
|
||||
editor = this.customEditors.get(key);
|
||||
// Cache editor for search type, to avoid the overhead
|
||||
// of repeated assignable-from checks.
|
||||
if (this.customEditorCache == null) {
|
||||
this.customEditorCache = new HashMap<Class, PropertyEditor>();
|
||||
this.customEditorCache = new HashMap<Class<?>, PropertyEditor>();
|
||||
}
|
||||
this.customEditorCache.put(requiredType, editor);
|
||||
}
|
||||
@@ -438,7 +438,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
* @param propertyName the name of the property
|
||||
* @return the property type, or <code>null</code> if not determinable
|
||||
*/
|
||||
protected Class guessPropertyTypeFromEditors(String propertyName) {
|
||||
protected Class<?> guessPropertyTypeFromEditors(String propertyName) {
|
||||
if (this.customEditorsForPath != null) {
|
||||
CustomEditorHolder editorHolder = this.customEditorsForPath.get(propertyName);
|
||||
if (editorHolder == null) {
|
||||
@@ -467,7 +467,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
String actualPropertyName =
|
||||
(nestedProperty != null ? PropertyAccessorUtils.getPropertyName(nestedProperty) : null);
|
||||
if (this.customEditors != null) {
|
||||
for (Map.Entry<Class, PropertyEditor> entry : this.customEditors.entrySet()) {
|
||||
for (Map.Entry<Class<?>, PropertyEditor> entry : this.customEditors.entrySet()) {
|
||||
target.registerCustomEditor(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
@@ -529,9 +529,9 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
|
||||
private final PropertyEditor propertyEditor;
|
||||
|
||||
private final Class registeredType;
|
||||
private final Class<?> registeredType;
|
||||
|
||||
private CustomEditorHolder(PropertyEditor propertyEditor, Class registeredType) {
|
||||
private CustomEditorHolder(PropertyEditor propertyEditor, Class<?> registeredType) {
|
||||
this.propertyEditor = propertyEditor;
|
||||
this.registeredType = registeredType;
|
||||
}
|
||||
@@ -540,11 +540,11 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
return this.propertyEditor;
|
||||
}
|
||||
|
||||
private Class getRegisteredType() {
|
||||
private Class<?> getRegisteredType() {
|
||||
return this.registeredType;
|
||||
}
|
||||
|
||||
private PropertyEditor getPropertyEditor(Class requiredType) {
|
||||
private PropertyEditor getPropertyEditor(Class<?> requiredType) {
|
||||
// Special case: If no required type specified, which usually only happens for
|
||||
// Collection elements, or required type is not assignable to registered type,
|
||||
// which usually only happens for generic properties of type Object -
|
||||
|
||||
+25
-49
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.beans;
|
||||
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.beans.PropertyEditor;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Constructor;
|
||||
@@ -27,13 +26,12 @@ import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.CollectionFactory;
|
||||
import org.springframework.core.GenericCollectionTypeResolver;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.convert.ConversionFailedException;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.core.convert.support.PropertyTypeDescriptor;
|
||||
import org.springframework.core.type.filter.TypeFilter;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -134,20 +132,23 @@ class TypeConverterDelegate {
|
||||
|
||||
// No custom editor but custom ConversionService specified?
|
||||
ConversionService conversionService = this.propertyEditorRegistry.getConversionService();
|
||||
if (editor == null && conversionService != null && convertedValue != null) {
|
||||
TypeDescriptor sourceTypeDesc = TypeDescriptor.forObject(convertedValue);
|
||||
TypeDescriptor targetTypeDesc = typeDescriptor.forElementType(requiredType);
|
||||
if (editor == null && conversionService != null && convertedValue != null && typeDescriptor != null) {
|
||||
TypeDescriptor sourceTypeDesc = TypeDescriptor.forObject(newValue);
|
||||
TypeDescriptor targetTypeDesc = typeDescriptor;
|
||||
if (conversionService.canConvert(sourceTypeDesc, targetTypeDesc)) {
|
||||
return (T) conversionService.convert(convertedValue, sourceTypeDesc, targetTypeDesc);
|
||||
try {
|
||||
return (T) conversionService.convert(convertedValue, sourceTypeDesc, targetTypeDesc);
|
||||
} catch (ConversionFailedException e) {
|
||||
// fallback to default conversion logic below
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Value not of required type?
|
||||
if (editor != null || (requiredType != null && !ClassUtils.isAssignableValue(requiredType, convertedValue))) {
|
||||
if (requiredType != null && Collection.class.isAssignableFrom(requiredType) &&
|
||||
convertedValue instanceof String && typeDescriptor.getMethodParameter() != null) {
|
||||
Class elemType = GenericCollectionTypeResolver.getCollectionParameterType(typeDescriptor.getMethodParameter());
|
||||
if (elemType != null && Enum.class.isAssignableFrom(elemType)) {
|
||||
if (requiredType != null && Collection.class.isAssignableFrom(requiredType) && convertedValue instanceof String) {
|
||||
TypeDescriptor elementType = typeDescriptor.getElementTypeDescriptor();
|
||||
if (elementType != null && Enum.class.isAssignableFrom(elementType.getType())) {
|
||||
convertedValue = StringUtils.commaDelimitedListToStringArray((String) convertedValue);
|
||||
}
|
||||
}
|
||||
@@ -290,10 +291,10 @@ class TypeConverterDelegate {
|
||||
*/
|
||||
protected PropertyEditor findDefaultEditor(Class requiredType, TypeDescriptor typeDescriptor) {
|
||||
PropertyEditor editor = null;
|
||||
if (typeDescriptor instanceof PropertyTypeDescriptor) {
|
||||
PropertyDescriptor pd = ((PropertyTypeDescriptor) typeDescriptor).getPropertyDescriptor();
|
||||
editor = pd.createPropertyEditor(this.targetObject);
|
||||
}
|
||||
//if (typeDescriptor instanceof PropertyTypeDescriptor) {
|
||||
//PropertyDescriptor pd = ((PropertyTypeDescriptor) typeDescriptor).getPropertyDescriptor();
|
||||
//editor = pd.createPropertyEditor(this.targetObject);
|
||||
//}
|
||||
if (editor == null && requiredType != null) {
|
||||
// No custom editor -> check BeanWrapperImpl's default editors.
|
||||
editor = this.propertyEditorRegistry.getDefaultEditor(requiredType);
|
||||
@@ -463,12 +464,8 @@ class TypeConverterDelegate {
|
||||
if (!originalAllowed && !Collection.class.isAssignableFrom(requiredType)) {
|
||||
return original;
|
||||
}
|
||||
|
||||
MethodParameter methodParam = typeDescriptor.getMethodParameter();
|
||||
Class elementType = null;
|
||||
if (methodParam != null) {
|
||||
elementType = GenericCollectionTypeResolver.getCollectionParameterType(methodParam);
|
||||
}
|
||||
typeDescriptor = typeDescriptor.narrow(original);
|
||||
TypeDescriptor elementType = typeDescriptor.getElementTypeDescriptor();
|
||||
if (elementType == null && originalAllowed &&
|
||||
!this.propertyEditorRegistry.hasCustomEditorForElement(null, propertyName)) {
|
||||
return original;
|
||||
@@ -514,14 +511,8 @@ class TypeConverterDelegate {
|
||||
for (; it.hasNext(); i++) {
|
||||
Object element = it.next();
|
||||
String indexedPropertyName = buildIndexedPropertyName(propertyName, i);
|
||||
if (methodParam != null) {
|
||||
methodParam.increaseNestingLevel();
|
||||
}
|
||||
Object convertedElement = convertIfNecessary(
|
||||
indexedPropertyName, null, element, elementType, typeDescriptor);
|
||||
if (methodParam != null) {
|
||||
methodParam.decreaseNestingLevel();
|
||||
}
|
||||
indexedPropertyName, null, element, elementType != null ? elementType.getType() : null , typeDescriptor.getElementTypeDescriptor());
|
||||
try {
|
||||
convertedCopy.add(convertedElement);
|
||||
}
|
||||
@@ -545,14 +536,9 @@ class TypeConverterDelegate {
|
||||
if (!originalAllowed && !Map.class.isAssignableFrom(requiredType)) {
|
||||
return original;
|
||||
}
|
||||
|
||||
Class keyType = null;
|
||||
Class valueType = null;
|
||||
MethodParameter methodParam = typeDescriptor.getMethodParameter();
|
||||
if (methodParam != null) {
|
||||
keyType = GenericCollectionTypeResolver.getMapKeyParameterType(methodParam);
|
||||
valueType = GenericCollectionTypeResolver.getMapValueParameterType(methodParam);
|
||||
}
|
||||
typeDescriptor = typeDescriptor.narrow(original);
|
||||
TypeDescriptor keyType = typeDescriptor.getMapKeyTypeDescriptor();
|
||||
TypeDescriptor valueType = typeDescriptor.getMapValueTypeDescriptor();
|
||||
if (keyType == null && valueType == null && originalAllowed &&
|
||||
!this.propertyEditorRegistry.hasCustomEditorForElement(null, propertyName)) {
|
||||
return original;
|
||||
@@ -599,18 +585,8 @@ class TypeConverterDelegate {
|
||||
Object key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
String keyedPropertyName = buildKeyedPropertyName(propertyName, key);
|
||||
if (methodParam != null) {
|
||||
methodParam.increaseNestingLevel();
|
||||
methodParam.setTypeIndexForCurrentLevel(0);
|
||||
}
|
||||
Object convertedKey = convertIfNecessary(keyedPropertyName, null, key, keyType, typeDescriptor);
|
||||
if (methodParam != null) {
|
||||
methodParam.setTypeIndexForCurrentLevel(1);
|
||||
}
|
||||
Object convertedValue = convertIfNecessary(keyedPropertyName, null, value, valueType, typeDescriptor);
|
||||
if (methodParam != null) {
|
||||
methodParam.decreaseNestingLevel();
|
||||
}
|
||||
Object convertedKey = convertIfNecessary(keyedPropertyName, null, key, keyType != null ? keyType.getType() : null, typeDescriptor.getMapKeyTypeDescriptor());
|
||||
Object convertedValue = convertIfNecessary(keyedPropertyName, null, value, valueType!= null ? valueType.getType() : null, typeDescriptor.getMapValueTypeDescriptor());
|
||||
try {
|
||||
convertedCopy.put(convertedKey, convertedValue);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.beans.factory;
|
||||
|
||||
/**
|
||||
* Marker superinterface indicating that a bean is eligible to be
|
||||
* notified by the Spring container of a particular framework object
|
||||
* through a callback-style method. Actual method signature is
|
||||
* determined by individual subinterfaces, but should typically
|
||||
* consist of just one void-returning method that accepts a single
|
||||
* argument.
|
||||
*
|
||||
* <p>Note that merely implementing {@link Aware} provides no default
|
||||
* functionality. Rather, processing must be done explicitly, for example
|
||||
* in a {@link org.springframework.beans.factory.config.BeanPostProcessor BeanPostProcessor}.
|
||||
* Refer to {@link org.springframework.context.support.ApplicationContextAwareProcessor}
|
||||
* and {@link org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory}
|
||||
* for examples of processing {@code *Aware} interface callbacks.
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @since 3.1
|
||||
*/
|
||||
public interface Aware {
|
||||
|
||||
}
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2006 the original author or authors.
|
||||
* Copyright 2002-2011 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,12 +29,13 @@ package org.springframework.beans.factory;
|
||||
* {@link BeanFactory BeanFactory javadocs}.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
* @since 2.0
|
||||
* @see BeanNameAware
|
||||
* @see BeanFactoryAware
|
||||
* @see InitializingBean
|
||||
*/
|
||||
public interface BeanClassLoaderAware {
|
||||
public interface BeanClassLoaderAware extends Aware {
|
||||
|
||||
/**
|
||||
* Callback that supplies the bean {@link ClassLoader class loader} to
|
||||
|
||||
+3
-3
@@ -87,6 +87,7 @@ import org.springframework.beans.BeansException;
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
* @since 13 April 2001
|
||||
* @see BeanNameAware#setBeanName
|
||||
* @see BeanClassLoaderAware#setBeanClassLoader
|
||||
@@ -113,7 +114,6 @@ public interface BeanFactory {
|
||||
*/
|
||||
String FACTORY_BEAN_PREFIX = "&";
|
||||
|
||||
|
||||
/**
|
||||
* Return an instance, which may be shared or independent, of the specified bean.
|
||||
* <p>This method allows a Spring BeanFactory to be used as a replacement for the
|
||||
@@ -152,7 +152,7 @@ public interface BeanFactory {
|
||||
/**
|
||||
* Return the bean instance that uniquely matches the given object type, if any.
|
||||
* @param requiredType type the bean must match; can be an interface or superclass.
|
||||
* {@literal null} is disallowed.
|
||||
* {@code null} is disallowed.
|
||||
* <p>This method goes into {@link ListableBeanFactory} by-type lookup territory
|
||||
* but may also be translated into a conventional by-name lookup based on the name
|
||||
* of the given type. For more extensive retrieval operations across sets of beans,
|
||||
@@ -240,7 +240,7 @@ public interface BeanFactory {
|
||||
* @see #getBean
|
||||
* @see #getType
|
||||
*/
|
||||
boolean isTypeMatch(String name, Class targetType) throws NoSuchBeanDefinitionException;
|
||||
boolean isTypeMatch(String name, Class<?> targetType) throws NoSuchBeanDefinitionException;
|
||||
|
||||
/**
|
||||
* Determine the type of the bean with the given name. More specifically,
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
* Copyright 2002-2010 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,13 +31,14 @@ import org.springframework.beans.BeansException;
|
||||
* {@link BeanFactory BeanFactory javadocs}.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Chris Beams
|
||||
* @since 11.03.2003
|
||||
* @see BeanNameAware
|
||||
* @see BeanClassLoaderAware
|
||||
* @see InitializingBean
|
||||
* @see org.springframework.context.ApplicationContextAware
|
||||
*/
|
||||
public interface BeanFactoryAware {
|
||||
public interface BeanFactoryAware extends Aware {
|
||||
|
||||
/**
|
||||
* Callback that supplies the owning factory to a bean instance.
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
* Copyright 2002-2011 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,12 +27,13 @@ package org.springframework.beans.factory;
|
||||
* {@link BeanFactory BeanFactory javadocs}.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
* @since 01.11.2003
|
||||
* @see BeanClassLoaderAware
|
||||
* @see BeanFactoryAware
|
||||
* @see InitializingBean
|
||||
*/
|
||||
public interface BeanNameAware {
|
||||
public interface BeanNameAware extends Aware {
|
||||
|
||||
/**
|
||||
* Set the name of the bean in the bean factory that created this bean.
|
||||
|
||||
+3
-3
@@ -110,7 +110,7 @@ public interface ListableBeanFactory extends BeanFactory {
|
||||
* @see FactoryBean#getObjectType
|
||||
* @see BeanFactoryUtils#beanNamesForTypeIncludingAncestors(ListableBeanFactory, Class)
|
||||
*/
|
||||
String[] getBeanNamesForType(Class type);
|
||||
String[] getBeanNamesForType(Class<?> type);
|
||||
|
||||
/**
|
||||
* Return the names of beans matching the given type (including subclasses),
|
||||
@@ -123,7 +123,7 @@ public interface ListableBeanFactory extends BeanFactory {
|
||||
* FactoryBean doesn't match, the raw FactoryBean itself will be matched against the
|
||||
* type. If "allowEagerInit" is not set, only raw FactoryBeans will be checked
|
||||
* (which doesn't require initialization of each FactoryBean).
|
||||
$ * <p>Does not consider any hierarchy this factory may participate in.
|
||||
* <p>Does not consider any hierarchy this factory may participate in.
|
||||
* Use BeanFactoryUtils' <code>beanNamesForTypeIncludingAncestors</code>
|
||||
* to include beans in ancestor factories too.
|
||||
* <p>Note: Does <i>not</i> ignore singleton beans that have been registered
|
||||
@@ -143,7 +143,7 @@ $ * <p>Does not consider any hierarchy this factory may participate in.
|
||||
* @see FactoryBean#getObjectType
|
||||
* @see BeanFactoryUtils#beanNamesForTypeIncludingAncestors(ListableBeanFactory, Class, boolean, boolean)
|
||||
*/
|
||||
String[] getBeanNamesForType(Class type, boolean includeNonSingletons, boolean allowEagerInit);
|
||||
String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit);
|
||||
|
||||
/**
|
||||
* Return the bean instances that match the given object type (including
|
||||
|
||||
+9
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2011 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,13 +46,20 @@ import java.lang.annotation.Target;
|
||||
* 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>Please do consult the javadoc for the {@link AutowiredAnnotationBeanPostProcessor}
|
||||
* <p>Note that actual injection is performed through a
|
||||
* {@link org.springframework.beans.factory.config.BeanPostProcessor
|
||||
* BeanPostProcessor} which in turn means that you <em>cannot</em>
|
||||
* use {@code @Autowired} to inject references into
|
||||
* {@link org.springframework.beans.factory.config.BeanPostProcessor
|
||||
* BeanPostProcessor} or {@link BeanFactoryPostProcessor} types. Please
|
||||
* consult the javadoc for the {@link AutowiredAnnotationBeanPostProcessor}
|
||||
* class (which, by default, checks for the presence of this annotation).
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Mark Fisher
|
||||
* @since 2.5
|
||||
* @see AutowiredAnnotationBeanPostProcessor
|
||||
* @see Value
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD})
|
||||
|
||||
+21
-19
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -62,7 +62,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* {@link org.springframework.beans.factory.config.BeanPostProcessor} implementation
|
||||
* that autowires annotated fields, setter methods and arbitrary config methods.
|
||||
* Such members to be injected are detected through a Java 5 annotation:
|
||||
* by default, Spring's {@link Autowired} annotation.
|
||||
* by default, Spring's @{@link Autowired} and @{@link Value} annotations.
|
||||
*
|
||||
* <p>Only one constructor (at max) of any given bean class may carry this
|
||||
* annotation with the 'required' parameter set to <code>true</code>,
|
||||
@@ -83,21 +83,23 @@ import org.springframework.util.ReflectionUtils;
|
||||
* a special case of such a general config method. Such config methods
|
||||
* do not have to be public.
|
||||
*
|
||||
* <p>Also supports JSR-330's {@link javax.inject.Inject} annotation, if available.
|
||||
* <p>Also supports JSR-330's {@link javax.inject.Inject @Inject} annotation, if
|
||||
* available.
|
||||
*
|
||||
* <p>Note: A default AutowiredAnnotationBeanPostProcessor will be registered
|
||||
* by the "context:annotation-config" and "context:component-scan" XML tags.
|
||||
* Remove or turn off the default annotation configuration there if you intend
|
||||
* to specify a custom AutowiredAnnotationBeanPostProcessor bean definition.
|
||||
* <p><b>NOTE:</b> Annotation injection will be performed <i>before</i> XML injection; thus
|
||||
* the latter configuration will override the former for properties wired through
|
||||
* both approaches.
|
||||
*
|
||||
* <p><b>NOTE:</b> Annotation injection will be performed <i>before</i> XML injection;
|
||||
* thus the latter configuration will override the former for properties wired through
|
||||
* both approaches.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Mark Fisher
|
||||
* @since 2.5
|
||||
* @see #setAutowiredAnnotationType
|
||||
* @see Autowired
|
||||
* @see Value
|
||||
*/
|
||||
public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter
|
||||
implements MergedBeanDefinitionPostProcessor, PriorityOrdered, BeanFactoryAware {
|
||||
@@ -115,8 +117,8 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
|
||||
private ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
private final Map<Class<?>, Constructor[]> candidateConstructorsCache =
|
||||
new ConcurrentHashMap<Class<?>, Constructor[]>();
|
||||
private final Map<Class<?>, Constructor<?>[]> candidateConstructorsCache =
|
||||
new ConcurrentHashMap<Class<?>, Constructor<?>[]>();
|
||||
|
||||
private final Map<Class<?>, InjectionMetadata> injectionMetadataCache =
|
||||
new ConcurrentHashMap<Class<?>, InjectionMetadata>();
|
||||
@@ -209,7 +211,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
}
|
||||
|
||||
|
||||
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class beanType, String beanName) {
|
||||
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
|
||||
if (beanType != null) {
|
||||
InjectionMetadata metadata = findAutowiringMetadata(beanType);
|
||||
metadata.checkConfigMembers(beanDefinition);
|
||||
@@ -217,17 +219,17 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
}
|
||||
|
||||
@Override
|
||||
public Constructor[] determineCandidateConstructors(Class beanClass, String beanName) throws BeansException {
|
||||
public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName) throws BeansException {
|
||||
// Quick check on the concurrent map first, with minimal locking.
|
||||
Constructor[] candidateConstructors = this.candidateConstructorsCache.get(beanClass);
|
||||
Constructor<?>[] candidateConstructors = this.candidateConstructorsCache.get(beanClass);
|
||||
if (candidateConstructors == null) {
|
||||
synchronized (this.candidateConstructorsCache) {
|
||||
candidateConstructors = this.candidateConstructorsCache.get(beanClass);
|
||||
if (candidateConstructors == null) {
|
||||
Constructor[] rawCandidates = beanClass.getDeclaredConstructors();
|
||||
List<Constructor> candidates = new ArrayList<Constructor>(rawCandidates.length);
|
||||
Constructor requiredConstructor = null;
|
||||
Constructor defaultConstructor = null;
|
||||
Constructor<?>[] rawCandidates = beanClass.getDeclaredConstructors();
|
||||
List<Constructor<?>> candidates = new ArrayList<Constructor<?>>(rawCandidates.length);
|
||||
Constructor<?> requiredConstructor = null;
|
||||
Constructor<?> defaultConstructor = null;
|
||||
for (Constructor<?> candidate : rawCandidates) {
|
||||
Annotation annotation = findAutowiredAnnotation(candidate);
|
||||
if (annotation != null) {
|
||||
@@ -305,7 +307,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
}
|
||||
|
||||
|
||||
private InjectionMetadata findAutowiringMetadata(Class clazz) {
|
||||
private InjectionMetadata findAutowiringMetadata(Class<?> clazz) {
|
||||
// Quick check on the concurrent map first, with minimal locking.
|
||||
InjectionMetadata metadata = this.injectionMetadataCache.get(clazz);
|
||||
if (metadata == null) {
|
||||
@@ -320,7 +322,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
return metadata;
|
||||
}
|
||||
|
||||
private InjectionMetadata buildAutowiringMetadata(Class clazz) {
|
||||
private InjectionMetadata buildAutowiringMetadata(Class<?> clazz) {
|
||||
LinkedList<InjectionMetadata.InjectedElement> elements = new LinkedList<InjectionMetadata.InjectedElement>();
|
||||
Class<?> targetClass = clazz;
|
||||
|
||||
@@ -534,7 +536,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
arguments = resolveCachedArguments(beanName);
|
||||
}
|
||||
else {
|
||||
Class[] paramTypes = method.getParameterTypes();
|
||||
Class<?>[] paramTypes = method.getParameterTypes();
|
||||
arguments = new Object[paramTypes.length];
|
||||
DependencyDescriptor[] descriptors = new DependencyDescriptor[paramTypes.length];
|
||||
Set<String> autowiredBeanNames = new LinkedHashSet<String>(paramTypes.length);
|
||||
|
||||
+6
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2011 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,6 +71,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @see #setInitAnnotationType
|
||||
* @see #setDestroyAnnotationType
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class InitDestroyAnnotationBeanPostProcessor
|
||||
implements DestructionAwareBeanPostProcessor, MergedBeanDefinitionPostProcessor, PriorityOrdered, Serializable {
|
||||
|
||||
@@ -117,7 +118,7 @@ public class InitDestroyAnnotationBeanPostProcessor
|
||||
}
|
||||
|
||||
|
||||
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class beanType, String beanName) {
|
||||
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
|
||||
if (beanType != null) {
|
||||
LifecycleMetadata metadata = findLifecycleMetadata(beanType);
|
||||
metadata.checkConfigMembers(beanDefinition);
|
||||
@@ -162,7 +163,7 @@ public class InitDestroyAnnotationBeanPostProcessor
|
||||
}
|
||||
|
||||
|
||||
private LifecycleMetadata findLifecycleMetadata(Class clazz) {
|
||||
private LifecycleMetadata findLifecycleMetadata(Class<?> clazz) {
|
||||
if (this.lifecycleMetadataCache == null) {
|
||||
// Happens after deserialization, during destruction...
|
||||
return buildLifecycleMetadata(clazz);
|
||||
@@ -182,7 +183,7 @@ public class InitDestroyAnnotationBeanPostProcessor
|
||||
return metadata;
|
||||
}
|
||||
|
||||
private LifecycleMetadata buildLifecycleMetadata(Class clazz) {
|
||||
private LifecycleMetadata buildLifecycleMetadata(Class<?> clazz) {
|
||||
final boolean debug = logger.isDebugEnabled();
|
||||
LinkedList<LifecycleElement> initMethods = new LinkedList<LifecycleElement>();
|
||||
LinkedList<LifecycleElement> destroyMethods = new LinkedList<LifecycleElement>();
|
||||
@@ -242,7 +243,7 @@ public class InitDestroyAnnotationBeanPostProcessor
|
||||
|
||||
private final Set<LifecycleElement> destroyMethods;
|
||||
|
||||
public LifecycleMetadata(Class targetClass, Collection<LifecycleElement> initMethods,
|
||||
public LifecycleMetadata(Class<?> targetClass, Collection<LifecycleElement> initMethods,
|
||||
Collection<LifecycleElement> destroyMethods) {
|
||||
|
||||
this.initMethods = new LinkedHashSet<LifecycleElement>();
|
||||
|
||||
+14
-12
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2011 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,21 +168,23 @@ public class InjectionMetadata {
|
||||
*/
|
||||
protected boolean checkPropertySkipping(PropertyValues pvs) {
|
||||
if (this.skip == null) {
|
||||
synchronized (pvs) {
|
||||
if (this.skip == null) {
|
||||
if (this.pd != null && pvs != null) {
|
||||
if (pvs.contains(this.pd.getName())) {
|
||||
// Explicit value provided as part of the bean definition.
|
||||
this.skip = true;
|
||||
return true;
|
||||
}
|
||||
else if (pvs instanceof MutablePropertyValues) {
|
||||
((MutablePropertyValues) pvs).registerProcessedProperty(this.pd.getName());
|
||||
if (pvs != null) {
|
||||
synchronized (pvs) {
|
||||
if (this.skip == null) {
|
||||
if (this.pd != null) {
|
||||
if (pvs.contains(this.pd.getName())) {
|
||||
// Explicit value provided as part of the bean definition.
|
||||
this.skip = true;
|
||||
return true;
|
||||
}
|
||||
else if (pvs instanceof MutablePropertyValues) {
|
||||
((MutablePropertyValues) pvs).registerProcessedProperty(this.pd.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
this.skip = false;
|
||||
}
|
||||
}
|
||||
this.skip = false;
|
||||
}
|
||||
return this.skip;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -129,7 +129,7 @@ public class RequiredAnnotationBeanPostProcessor extends InstantiationAwareBeanP
|
||||
}
|
||||
|
||||
|
||||
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class beanType, String beanName) {
|
||||
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+12
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2011 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,8 +31,19 @@ import java.lang.annotation.Target;
|
||||
* <p>A common use case is to assign default field values using
|
||||
* "#{systemProperties.myProp}" style expressions.
|
||||
*
|
||||
* <p>Note that actual processing of the {@code @Value} annotation is performed
|
||||
* by a {@link org.springframework.beans.factory.config.BeanPostProcessor
|
||||
* BeanPostProcessor} which in turn means that you <em>cannot</em> use
|
||||
* {@code @Value} within
|
||||
* {@link org.springframework.beans.factory.config.BeanPostProcessor
|
||||
* BeanPostProcessor} or {@link BeanFactoryPostProcessor} types. Please
|
||||
* consult the javadoc for the {@link AutowiredAnnotationBeanPostProcessor}
|
||||
* class (which, by default, checks for the presence of this annotation).
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 3.0
|
||||
* @see AutowiredAnnotationBeanPostProcessor
|
||||
* @see Value
|
||||
* @see org.springframework.beans.factory.config.BeanExpressionResolver
|
||||
* @see org.springframework.beans.factory.support.AutowireCandidateResolver#getSuggestedValue
|
||||
*/
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2011 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.
|
||||
@@ -123,8 +123,8 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
|
||||
/**
|
||||
* Specify a factory method, if any. This method will be invoked with
|
||||
* constructor arguments, or with no arguments if none are specified.
|
||||
* The method will be invoked on the specifed factory bean, if any,
|
||||
* or as static method on the local bean class else.
|
||||
* The method will be invoked on the specified factory bean, if any,
|
||||
* or otherwise as a static method on the local bean class.
|
||||
* @param factoryMethodName static factory method name,
|
||||
* or <code>null</code> if normal constructor creation should be used
|
||||
* @see #getBeanClassName()
|
||||
|
||||
+7
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2011 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,6 +37,7 @@ import org.springframework.util.StringValueResolver;
|
||||
* contained in a BeanDefinition, resolving any placeholders found.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
* @since 1.2
|
||||
* @see BeanDefinition
|
||||
* @see BeanDefinition#getPropertyValues
|
||||
@@ -115,7 +116,7 @@ public class BeanDefinitionVisitor {
|
||||
}
|
||||
|
||||
protected void visitFactoryMethodName(BeanDefinition beanDefinition) {
|
||||
String factoryMethodName = beanDefinition.getFactoryBeanName();
|
||||
String factoryMethodName = beanDefinition.getFactoryMethodName();
|
||||
if (factoryMethodName != null) {
|
||||
String resolvedName = resolveStringValue(factoryMethodName);
|
||||
if (!factoryMethodName.equals(resolvedName)) {
|
||||
@@ -162,6 +163,7 @@ public class BeanDefinitionVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected Object resolveValue(Object value) {
|
||||
if (value instanceof BeanDefinition) {
|
||||
visitBeanDefinition((BeanDefinition) value);
|
||||
@@ -209,7 +211,6 @@ public class BeanDefinitionVisitor {
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void visitArray(Object[] arrayVal) {
|
||||
for (int i = 0; i < arrayVal.length; i++) {
|
||||
Object elem = arrayVal[i];
|
||||
@@ -220,7 +221,7 @@ public class BeanDefinitionVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
protected void visitList(List listVal) {
|
||||
for (int i = 0; i < listVal.size(); i++) {
|
||||
Object elem = listVal.get(i);
|
||||
@@ -231,7 +232,7 @@ public class BeanDefinitionVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
protected void visitSet(Set setVal) {
|
||||
Set newContent = new LinkedHashSet();
|
||||
boolean entriesModified = false;
|
||||
@@ -248,7 +249,7 @@ public class BeanDefinitionVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
protected void visitMap(Map<?, ?> mapVal) {
|
||||
Map newContent = new LinkedHashMap();
|
||||
boolean entriesModified = false;
|
||||
|
||||
+10
-1
@@ -173,7 +173,7 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single
|
||||
* @param requiredType type of the property
|
||||
* @param propertyEditorClass the {@link PropertyEditor} class to register
|
||||
*/
|
||||
void registerCustomEditor(Class requiredType, Class<? extends PropertyEditor> propertyEditorClass);
|
||||
void registerCustomEditor(Class<?> requiredType, Class<? extends PropertyEditor> propertyEditorClass);
|
||||
|
||||
/**
|
||||
* Initialize the given PropertyEditorRegistry with the custom editors
|
||||
@@ -320,6 +320,15 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single
|
||||
*/
|
||||
boolean isFactoryBean(String name) throws NoSuchBeanDefinitionException;
|
||||
|
||||
/**
|
||||
* Explicitly control in-creation status of the specified bean. For
|
||||
* container internal use only.
|
||||
* @param beanName the name of the bean
|
||||
* @param inCreation whether the bean is currently in creation
|
||||
* @since 3.1
|
||||
*/
|
||||
void setCurrentlyInCreation(String beanName, boolean inCreation);
|
||||
|
||||
/**
|
||||
* Determine whether the specified bean is currently in creation.
|
||||
* @param beanName the name of the bean
|
||||
|
||||
+3
-3
@@ -44,7 +44,7 @@ public interface ConfigurableListableBeanFactory
|
||||
* for example, String. Default is none.
|
||||
* @param type the dependency type to ignore
|
||||
*/
|
||||
void ignoreDependencyType(Class type);
|
||||
void ignoreDependencyType(Class<?> type);
|
||||
|
||||
/**
|
||||
* Ignore the given dependency interface for autowiring.
|
||||
@@ -57,7 +57,7 @@ public interface ConfigurableListableBeanFactory
|
||||
* @see org.springframework.beans.factory.BeanFactoryAware
|
||||
* @see org.springframework.context.ApplicationContextAware
|
||||
*/
|
||||
void ignoreDependencyInterface(Class ifc);
|
||||
void ignoreDependencyInterface(Class<?> ifc);
|
||||
|
||||
/**
|
||||
* Register a special dependency type with corresponding autowired value.
|
||||
@@ -75,7 +75,7 @@ public interface ConfigurableListableBeanFactory
|
||||
* implementation of the {@link org.springframework.beans.factory.ObjectFactory}
|
||||
* interface, which allows for lazy resolution of the actual target value.
|
||||
*/
|
||||
void registerResolvableDependency(Class dependencyType, Object autowiredValue);
|
||||
void registerResolvableDependency(Class<?> dependencyType, Object autowiredValue);
|
||||
|
||||
/**
|
||||
* Determine whether the specified bean qualifies as an autowire candidate,
|
||||
|
||||
+202
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.beans.factory.config;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* A container object holding a map of attributes and optionally destruction callbacks. The callbacks will be invoked,
|
||||
* if an attribute is being removed or if the holder is cleaned out.
|
||||
*
|
||||
* @author Micha Kiener
|
||||
* @since 3.1
|
||||
*/
|
||||
public class DestructionAwareAttributeHolder implements Serializable {
|
||||
|
||||
/** The map containing the registered attributes. */
|
||||
private final Map<String, Object> attributes = new ConcurrentHashMap<String, Object>();
|
||||
|
||||
/**
|
||||
* The optional map having any destruction callbacks registered using the
|
||||
* name of the bean as the key.
|
||||
*/
|
||||
private Map<String, Runnable> registeredDestructionCallbacks;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the map representation of the registered attributes directly. Be
|
||||
* aware to synchronize any invocations to it on the map object itself to
|
||||
* avoid concurrent modification exceptions.
|
||||
*
|
||||
* @return the attributes as a map representation
|
||||
*/
|
||||
public Map<String, Object> getAttributeMap() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the attribute having the specified name, if available,
|
||||
* <code>null</code> otherwise.
|
||||
*
|
||||
* @param name
|
||||
* the name of the attribute to be returned
|
||||
* @return the attribute value or <code>null</code> if not available
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getAttribute(String name) {
|
||||
return attributes.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the given object with the specified name as an attribute to the
|
||||
* underlying map.
|
||||
*
|
||||
* @param name
|
||||
* the name of the attribute
|
||||
* @param value
|
||||
* the value to be stored
|
||||
* @return any previously object stored under the same name, if any,
|
||||
* <code>null</code> otherwise
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object setAttribute(String name, Object value) {
|
||||
return attributes.put(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the object with the given <code>name</code> from the underlying
|
||||
* scope.
|
||||
* <p>
|
||||
* Returns <code>null</code> if no object was found; otherwise returns the
|
||||
* removed <code>Object</code>.
|
||||
* <p>
|
||||
* Note that an implementation should also remove a registered destruction
|
||||
* callback for the specified object, if any. It does, however, <i>not</i>
|
||||
* need to <i>execute</i> a registered destruction callback in this case,
|
||||
* since the object will be destroyed by the caller (if appropriate).
|
||||
* <p>
|
||||
* <b>Note: This is an optional operation.</b> Implementations may throw
|
||||
* {@link UnsupportedOperationException} if they do not support explicitly
|
||||
* removing an object.
|
||||
*
|
||||
* @param name
|
||||
* the name of the object to remove
|
||||
* @return the removed object, or <code>null</code> if no object was present
|
||||
* @see #registerDestructionCallback
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object removeAttribute(String name) {
|
||||
Object value = attributes.remove(name);
|
||||
|
||||
// check for a destruction callback to be invoked
|
||||
Runnable callback = getDestructionCallback(name, true);
|
||||
if (callback != null) {
|
||||
callback.run();
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the map by removing all registered attribute values and invokes
|
||||
* every destruction callback registered.
|
||||
*/
|
||||
public void clear() {
|
||||
synchronized (this) {
|
||||
// step through the attribute map and invoke destruction callbacks,
|
||||
// if any
|
||||
if (registeredDestructionCallbacks != null) {
|
||||
for (Runnable runnable : registeredDestructionCallbacks.values()) {
|
||||
runnable.run();
|
||||
}
|
||||
|
||||
registeredDestructionCallbacks.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// clear out the registered attribute map
|
||||
attributes.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback to be executed on destruction of the specified object
|
||||
* in the scope (or at destruction of the entire scope, if the scope does
|
||||
* not destroy individual objects but rather only terminates in its
|
||||
* entirety).
|
||||
* <p>
|
||||
* <b>Note: This is an optional operation.</b> This method will only be
|
||||
* called for scoped beans with actual destruction configuration
|
||||
* (DisposableBean, destroy-method, DestructionAwareBeanPostProcessor).
|
||||
* Implementations should do their best to execute a given callback at the
|
||||
* appropriate time. If such a callback is not supported by the underlying
|
||||
* runtime environment at all, the callback <i>must be ignored and a
|
||||
* corresponding warning should be logged</i>.
|
||||
* <p>
|
||||
* Note that 'destruction' refers to to automatic destruction of the object
|
||||
* as part of the scope's own lifecycle, not to the individual scoped object
|
||||
* having been explicitly removed by the application. If a scoped object
|
||||
* gets removed via this facade's {@link #removeAttribute(String)} method,
|
||||
* any registered destruction callback should be removed as well, assuming
|
||||
* that the removed object will be reused or manually destroyed.
|
||||
*
|
||||
* @param name
|
||||
* the name of the object to execute the destruction callback for
|
||||
* @param callback
|
||||
* the destruction callback to be executed. Note that the
|
||||
* passed-in Runnable will never throw an exception, so it can
|
||||
* safely be executed without an enclosing try-catch block.
|
||||
* Furthermore, the Runnable will usually be serializable,
|
||||
* provided that its target object is serializable as well.
|
||||
* @see org.springframework.beans.factory.DisposableBean
|
||||
* @see org.springframework.beans.factory.support.AbstractBeanDefinition#getDestroyMethodName()
|
||||
* @see org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor
|
||||
*/
|
||||
public void registerDestructionCallback(String name, Runnable callback) {
|
||||
if (registeredDestructionCallbacks == null) {
|
||||
registeredDestructionCallbacks = new ConcurrentHashMap<String, Runnable>();
|
||||
}
|
||||
|
||||
registeredDestructionCallbacks.put(name, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the destruction callback, if any registered for the attribute
|
||||
* with the given name or <code>null</code> if no such callback was
|
||||
* registered.
|
||||
*
|
||||
* @param name
|
||||
* the name of the registered callback requested
|
||||
* @param remove
|
||||
* <code>true</code>, if the callback should be removed after
|
||||
* this call, <code>false</code>, if it stays
|
||||
* @return the callback, if found, <code>null</code> otherwise
|
||||
*/
|
||||
public Runnable getDestructionCallback(String name, boolean remove) {
|
||||
if (registeredDestructionCallbacks == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (remove) {
|
||||
return registeredDestructionCallbacks.remove(name);
|
||||
}
|
||||
|
||||
return registeredDestructionCallbacks.get(name);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2011 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.
|
||||
|
||||
+2
-2
@@ -43,7 +43,7 @@ public abstract class InstantiationAwareBeanPostProcessorAdapter implements Smar
|
||||
return null;
|
||||
}
|
||||
|
||||
public Constructor<?>[] determineCandidateConstructors(Class beanClass, String beanName) throws BeansException {
|
||||
public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName) throws BeansException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public abstract class InstantiationAwareBeanPostProcessorAdapter implements Smar
|
||||
return bean;
|
||||
}
|
||||
|
||||
public Object postProcessBeforeInstantiation(Class beanClass, String beanName) throws BeansException {
|
||||
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+221
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.beans.factory.config;
|
||||
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.util.StringValueResolver;
|
||||
|
||||
/**
|
||||
* Abstract base class for property resource configurers that resolve placeholders
|
||||
* in bean definition property values. Implementations <em>pull</em> values from a
|
||||
* properties file or other {@linkplain org.springframework.core.env.PropertySource
|
||||
* property source} into bean definitions.
|
||||
*
|
||||
* <p>The default placeholder syntax follows the Ant / Log4J / JSP EL style:
|
||||
*
|
||||
*<pre class="code">${...}</pre>
|
||||
*
|
||||
* Example XML bean definition:
|
||||
*
|
||||
*<pre class="code">{@code
|
||||
*<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"/>
|
||||
* <property name="driverClassName" value="}${driver}{@code"/>
|
||||
* <property name="url" value="jdbc:}${dbname}{@code"/>
|
||||
*</bean>
|
||||
*}</pre>
|
||||
*
|
||||
* Example properties file:
|
||||
*
|
||||
* <pre class="code"> driver=com.mysql.jdbc.Driver
|
||||
* dbname=mysql:mydb</pre>
|
||||
*
|
||||
* Annotated bean definitions may take advantage of property replacement using
|
||||
* the {@link org.springframework.beans.factory.annotation.Value @Value} annotation:
|
||||
*
|
||||
*<pre class="code">@Value("${person.age}")</pre>
|
||||
*
|
||||
* Implementations check simple property values, lists, maps, props, and bean names
|
||||
* in bean references. Furthermore, placeholder values can also cross-reference
|
||||
* other placeholders, like:
|
||||
*
|
||||
*<pre class="code">rootPath=myrootdir
|
||||
*subPath=${rootPath}/subdir</pre>
|
||||
*
|
||||
* In contrast to {@link PropertyOverrideConfigurer}, subclasses of this type allow
|
||||
* filling in of explicit placeholders in bean definitions.
|
||||
*
|
||||
* <p>If a configurer cannot resolve a placeholder, a {@link BeanDefinitionStoreException}
|
||||
* will be thrown. If you want to check against multiple properties files, specify multiple
|
||||
* resources via the {@link #setLocations locations} property. You can also define multiple
|
||||
* configurers, each with its <em>own</em> placeholder syntax. Use {@link
|
||||
* #ignoreUnresolvablePlaceholders} to intentionally suppress throwing an exception if a
|
||||
* placeholder cannot be resolved.
|
||||
*
|
||||
* <p>Default property values can be defined globally for each configurer instance
|
||||
* via the {@link #setProperties properties} property, or on a property-by-property basis
|
||||
* using the default value separator which is {@code ":"} by default and
|
||||
* customizable via {@link #setValueSeparator(String)}.
|
||||
*
|
||||
* <p>Example XML property with default value:
|
||||
*
|
||||
*<pre class="code">{@code
|
||||
* <property name="url" value="jdbc:}${dbname:defaultdb}{@code"/>
|
||||
*}</pre>
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @author Juergen Hoeller
|
||||
* @since 3.1
|
||||
* @see PropertyPlaceholderConfigurer
|
||||
* @see org.springframework.context.support.PropertySourcesPlaceholderConfigurer
|
||||
*/
|
||||
public abstract class PlaceholderConfigurerSupport extends PropertyResourceConfigurer
|
||||
implements BeanNameAware, BeanFactoryAware {
|
||||
|
||||
/** Default placeholder prefix: {@value} */
|
||||
public static final String DEFAULT_PLACEHOLDER_PREFIX = "${";
|
||||
|
||||
/** Default placeholder suffix: {@value} */
|
||||
public static final String DEFAULT_PLACEHOLDER_SUFFIX = "}";
|
||||
|
||||
/** Default value separator: {@value} */
|
||||
public static final String DEFAULT_VALUE_SEPARATOR = ":";
|
||||
|
||||
|
||||
/** Defaults to {@value #DEFAULT_PLACEHOLDER_PREFIX} */
|
||||
protected String placeholderPrefix = DEFAULT_PLACEHOLDER_PREFIX;
|
||||
|
||||
/** Defaults to {@value #DEFAULT_PLACEHOLDER_SUFFIX} */
|
||||
protected String placeholderSuffix = DEFAULT_PLACEHOLDER_SUFFIX;
|
||||
|
||||
/** Defaults to {@value #DEFAULT_VALUE_SEPARATOR} */
|
||||
protected String valueSeparator = DEFAULT_VALUE_SEPARATOR;
|
||||
|
||||
protected boolean ignoreUnresolvablePlaceholders = false;
|
||||
|
||||
protected String nullValue;
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
private String beanName;
|
||||
|
||||
|
||||
/**
|
||||
* Set the prefix that a placeholder string starts with.
|
||||
* The default is {@value #DEFAULT_PLACEHOLDER_PREFIX}.
|
||||
*/
|
||||
public void setPlaceholderPrefix(String placeholderPrefix) {
|
||||
this.placeholderPrefix = placeholderPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the suffix that a placeholder string ends with.
|
||||
* The default is {@value #DEFAULT_PLACEHOLDER_SUFFIX}.
|
||||
*/
|
||||
public void setPlaceholderSuffix(String placeholderSuffix) {
|
||||
this.placeholderSuffix = placeholderSuffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the separating character between the placeholder variable
|
||||
* and the associated default value, or {@code null} if no such
|
||||
* special character should be processed as a value separator.
|
||||
* The default is {@value #DEFAULT_VALUE_SEPARATOR}.
|
||||
*/
|
||||
public void setValueSeparator(String valueSeparator) {
|
||||
this.valueSeparator = valueSeparator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a value that should be treated as {@code null} when
|
||||
* resolved as a placeholder value: e.g. "" (empty String) or "null".
|
||||
* <p>Note that this will only apply to full property values,
|
||||
* not to parts of concatenated values.
|
||||
* <p>By default, no such null value is defined. This means that
|
||||
* there is no way to express {@code null} as a property
|
||||
* value unless you explicitly map a corresponding value here.
|
||||
*/
|
||||
public void setNullValue(String nullValue) {
|
||||
this.nullValue = nullValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to ignore unresolvable placeholders.
|
||||
* <p>Default is "false": An exception will be thrown if a placeholder fails
|
||||
* to resolve. Switch this flag to "true" in order to preserve the placeholder
|
||||
* String as-is in such a case, leaving it up to other placeholder configurers
|
||||
* to resolve it.
|
||||
*/
|
||||
public void setIgnoreUnresolvablePlaceholders(boolean ignoreUnresolvablePlaceholders) {
|
||||
this.ignoreUnresolvablePlaceholders = ignoreUnresolvablePlaceholders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only necessary to check that we're not parsing our own bean definition,
|
||||
* to avoid failing on unresolvable placeholders in properties file locations.
|
||||
* The latter case can happen with placeholders for system properties in
|
||||
* resource locations.
|
||||
* @see #setLocations
|
||||
* @see org.springframework.core.io.ResourceEditor
|
||||
*/
|
||||
public void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only necessary to check that we're not parsing our own bean definition,
|
||||
* to avoid failing on unresolvable placeholders in properties file locations.
|
||||
* The latter case can happen with placeholders for system properties in
|
||||
* resource locations.
|
||||
* @see #setLocations
|
||||
* @see org.springframework.core.io.ResourceEditor
|
||||
*/
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
|
||||
protected void doProcessProperties(ConfigurableListableBeanFactory beanFactoryToProcess,
|
||||
StringValueResolver valueResolver) {
|
||||
|
||||
BeanDefinitionVisitor visitor = new BeanDefinitionVisitor(valueResolver);
|
||||
|
||||
String[] beanNames = beanFactoryToProcess.getBeanDefinitionNames();
|
||||
for (String curName : beanNames) {
|
||||
// Check that we're not parsing our own bean definition,
|
||||
// to avoid failing on unresolvable placeholders in properties file locations.
|
||||
if (!(curName.equals(this.beanName) && beanFactoryToProcess.equals(this.beanFactory))) {
|
||||
BeanDefinition bd = beanFactoryToProcess.getBeanDefinition(curName);
|
||||
try {
|
||||
visitor.visitBeanDefinition(bd);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new BeanDefinitionStoreException(bd.getResourceDescription(), curName, ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// New in Spring 2.5: resolve placeholders in alias target names and aliases as well.
|
||||
beanFactoryToProcess.resolveAliases(valueResolver);
|
||||
|
||||
// New in Spring 3.0: resolve placeholders in embedded values such as annotation attributes.
|
||||
beanFactoryToProcess.addEmbeddedValueResolver(valueResolver);
|
||||
}
|
||||
|
||||
}
|
||||
+43
-191
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2011 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,89 +20,47 @@ import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.core.Constants;
|
||||
import org.springframework.util.PropertyPlaceholderHelper;
|
||||
import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver;
|
||||
import org.springframework.util.StringValueResolver;
|
||||
|
||||
/**
|
||||
* A property resource configurer that resolves placeholders in bean property values of
|
||||
* context definitions. It <i>pulls</i> values from a properties file into bean definitions.
|
||||
* {@link PlaceholderConfigurerSupport} subclass that resolves ${...} placeholders
|
||||
* against {@link #setLocation local} {@link #setProperties properties} and/or system properties
|
||||
* and environment variables.
|
||||
*
|
||||
* <p>The default placeholder syntax follows the Ant / Log4J / JSP EL style:
|
||||
* <p>As of Spring 3.1, {@link org.springframework.context.support.PropertySourcesPlaceholderConfigurer
|
||||
* PropertySourcesPlaceholderConfigurer} should be used preferentially over this implementation; it is
|
||||
* more flexible through taking advantage of the {@link org.springframework.core.env.Environment Environment} and
|
||||
* {@link org.springframework.core.env.PropertySource PropertySource} mechanisms also made available in Spring 3.1.
|
||||
*
|
||||
* <pre class="code">${...}</pre>
|
||||
* <p>{@link PropertyPlaceholderConfigurer} is still appropriate for use when:
|
||||
* <ul>
|
||||
* <li>the {@link org.springframework.context spring-context} module is not available (i.e., one is using
|
||||
* Spring's {@code BeanFactory} API as opposed to {@code ApplicationContext}).
|
||||
* <li>existing configuration makes use of the {@link #setSystemPropertiesMode(int) "systemPropertiesMode"} and/or
|
||||
* {@link #setSystemPropertiesModeName(String) "systemPropertiesModeName"} properties. Users are encouraged to move
|
||||
* away from using these settings, and rather configure property source search order through the container's
|
||||
* {@code Environment}; however, exact preservation of functionality may be maintained by continuing to
|
||||
* use {@code PropertyPlaceholderConfigurer}.
|
||||
* </ul>
|
||||
*
|
||||
* Example XML context definition:
|
||||
*
|
||||
* <pre class="code"><bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
||||
* <property name="driverClassName"><value>${driver}</value></property>
|
||||
* <property name="url"><value>jdbc:${dbname}</value></property>
|
||||
* </bean></pre>
|
||||
*
|
||||
* Example properties file:
|
||||
*
|
||||
* <pre class="code">driver=com.mysql.jdbc.Driver
|
||||
* dbname=mysql:mydb</pre>
|
||||
*
|
||||
* PropertyPlaceholderConfigurer checks simple property values, lists, maps,
|
||||
* props, and bean names in bean references. Furthermore, placeholder values can
|
||||
* also cross-reference other placeholders, like:
|
||||
*
|
||||
* <pre class="code">rootPath=myrootdir
|
||||
* subPath=${rootPath}/subdir</pre>
|
||||
*
|
||||
* In contrast to PropertyOverrideConfigurer, this configurer allows to fill in
|
||||
* explicit placeholders in context definitions. Therefore, the original definition
|
||||
* cannot specify any default values for such bean properties, and the placeholder
|
||||
* properties file is supposed to contain an entry for each defined placeholder.
|
||||
*
|
||||
* <p>If a configurer cannot resolve a placeholder, a BeanDefinitionStoreException
|
||||
* will be thrown. If you want to check against multiple properties files, specify
|
||||
* multiple resources via the "locations" setting. You can also define multiple
|
||||
* PropertyPlaceholderConfigurers, each with its <i>own</i> placeholder syntax.
|
||||
*
|
||||
* <p>Default property values can be defined via "properties", to make overriding
|
||||
* definitions in properties files optional. A configurer will also check against
|
||||
* system properties (e.g. "user.dir") if it cannot resolve a placeholder with any
|
||||
* of the specified properties. This can be customized via "systemPropertiesMode".
|
||||
*
|
||||
* <p>Note that the context definition <i>is</i> aware of being incomplete;
|
||||
* this is immediately obvious to users when looking at the XML definition file.
|
||||
* Hence, placeholders have to be resolved; any desired defaults have to be
|
||||
* defined as placeholder values as well (for example in a default properties file).
|
||||
*
|
||||
* <p>Property values can be converted after reading them in, through overriding
|
||||
* the {@link #convertPropertyValue} method. For example, encrypted values can
|
||||
* be detected and decrypted accordingly before processing them.
|
||||
* <p>Prior to Spring 3.1, the {@code <context:property-placeholder/>} namespace element
|
||||
* registered an instance of {@code PropertyPlaceholderConfigurer}. It will still do so if
|
||||
* using the {@code spring-context-3.0.xsd} definition of the namespace. That is, you can preserve
|
||||
* registration of {@code PropertyPlaceholderConfigurer} through the namespace, even if using Spring 3.1;
|
||||
* simply do not update your {@code xsi:schemaLocation} and continue using the 3.0 XSD.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
* @since 02.10.2003
|
||||
* @see #setLocations
|
||||
* @see #setProperties
|
||||
* @see #setPlaceholderPrefix
|
||||
* @see #setPlaceholderSuffix
|
||||
* @see #setSystemPropertiesModeName
|
||||
* @see System#getProperty(String)
|
||||
* @see #convertPropertyValue
|
||||
* @see PlaceholderConfigurerSupport
|
||||
* @see PropertyOverrideConfigurer
|
||||
* @see org.springframework.context.support.PropertySourcesPlaceholderConfigurer
|
||||
*/
|
||||
public class PropertyPlaceholderConfigurer extends PropertyResourceConfigurer
|
||||
implements BeanNameAware, BeanFactoryAware {
|
||||
|
||||
/** Default placeholder prefix: "${" */
|
||||
public static final String DEFAULT_PLACEHOLDER_PREFIX = "${";
|
||||
|
||||
/** Default placeholder suffix: "}" */
|
||||
public static final String DEFAULT_PLACEHOLDER_SUFFIX = "}";
|
||||
|
||||
/** Default value separator: ":" */
|
||||
public static final String DEFAULT_VALUE_SEPARATOR = ":";
|
||||
|
||||
public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport {
|
||||
|
||||
/** Never check system properties. */
|
||||
public static final int SYSTEM_PROPERTIES_MODE_NEVER = 0;
|
||||
@@ -122,52 +80,10 @@ public class PropertyPlaceholderConfigurer extends PropertyResourceConfigurer
|
||||
|
||||
private static final Constants constants = new Constants(PropertyPlaceholderConfigurer.class);
|
||||
|
||||
private String placeholderPrefix = DEFAULT_PLACEHOLDER_PREFIX;
|
||||
|
||||
private String placeholderSuffix = DEFAULT_PLACEHOLDER_SUFFIX;
|
||||
|
||||
private String valueSeparator = DEFAULT_VALUE_SEPARATOR;
|
||||
|
||||
private int systemPropertiesMode = SYSTEM_PROPERTIES_MODE_FALLBACK;
|
||||
|
||||
private boolean searchSystemEnvironment = true;
|
||||
|
||||
private boolean ignoreUnresolvablePlaceholders = false;
|
||||
|
||||
private String nullValue;
|
||||
|
||||
private String beanName;
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Set the prefix that a placeholder string starts with.
|
||||
* The default is "${".
|
||||
* @see #DEFAULT_PLACEHOLDER_PREFIX
|
||||
*/
|
||||
public void setPlaceholderPrefix(String placeholderPrefix) {
|
||||
this.placeholderPrefix = placeholderPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the suffix that a placeholder string ends with.
|
||||
* The default is "}".
|
||||
* @see #DEFAULT_PLACEHOLDER_SUFFIX
|
||||
*/
|
||||
public void setPlaceholderSuffix(String placeholderSuffix) {
|
||||
this.placeholderSuffix = placeholderSuffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the separating character between the placeholder variable
|
||||
* and the associated default value, or <code>null</code> if no such
|
||||
* special character should be processed as a value separator.
|
||||
* The default is ":".
|
||||
*/
|
||||
public void setValueSeparator(String valueSeparator) {
|
||||
this.valueSeparator = valueSeparator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the system property mode by the name of the corresponding constant,
|
||||
@@ -218,88 +134,10 @@ public class PropertyPlaceholderConfigurer extends PropertyResourceConfigurer
|
||||
this.searchSystemEnvironment = searchSystemEnvironment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to ignore unresolvable placeholders.
|
||||
* <p>Default is "false": An exception will be thrown if a placeholder fails
|
||||
* to resolve. Switch this flag to "true" in order to preserve the placeholder
|
||||
* String as-is in such a case, leaving it up to other placeholder configurers
|
||||
* to resolve it.
|
||||
*/
|
||||
public void setIgnoreUnresolvablePlaceholders(boolean ignoreUnresolvablePlaceholders) {
|
||||
this.ignoreUnresolvablePlaceholders = ignoreUnresolvablePlaceholders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a value that should be treated as <code>null</code> when
|
||||
* resolved as a placeholder value: e.g. "" (empty String) or "null".
|
||||
* <p>Note that this will only apply to full property values,
|
||||
* not to parts of concatenated values.
|
||||
* <p>By default, no such null value is defined. This means that
|
||||
* there is no way to express <code>null</code> as a property
|
||||
* value unless you explictly map a corresponding value here.
|
||||
*/
|
||||
public void setNullValue(String nullValue) {
|
||||
this.nullValue = nullValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only necessary to check that we're not parsing our own bean definition,
|
||||
* to avoid failing on unresolvable placeholders in properties file locations.
|
||||
* The latter case can happen with placeholders for system properties in
|
||||
* resource locations.
|
||||
* @see #setLocations
|
||||
* @see org.springframework.core.io.ResourceEditor
|
||||
*/
|
||||
public void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only necessary to check that we're not parsing our own bean definition,
|
||||
* to avoid failing on unresolvable placeholders in properties file locations.
|
||||
* The latter case can happen with placeholders for system properties in
|
||||
* resource locations.
|
||||
* @see #setLocations
|
||||
* @see org.springframework.core.io.ResourceEditor
|
||||
*/
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props)
|
||||
throws BeansException {
|
||||
|
||||
StringValueResolver valueResolver = new PlaceholderResolvingStringValueResolver(props);
|
||||
BeanDefinitionVisitor visitor = new BeanDefinitionVisitor(valueResolver);
|
||||
|
||||
String[] beanNames = beanFactoryToProcess.getBeanDefinitionNames();
|
||||
for (String curName : beanNames) {
|
||||
// Check that we're not parsing our own bean definition,
|
||||
// to avoid failing on unresolvable placeholders in properties file locations.
|
||||
if (!(curName.equals(this.beanName) && beanFactoryToProcess.equals(this.beanFactory))) {
|
||||
BeanDefinition bd = beanFactoryToProcess.getBeanDefinition(curName);
|
||||
try {
|
||||
visitor.visitBeanDefinition(bd);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new BeanDefinitionStoreException(bd.getResourceDescription(), curName, ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// New in Spring 2.5: resolve placeholders in alias target names and aliases as well.
|
||||
beanFactoryToProcess.resolveAliases(valueResolver);
|
||||
|
||||
// New in Spring 3.0: resolve placeholders in embedded values such as annotation attributes.
|
||||
beanFactoryToProcess.addEmbeddedValueResolver(valueResolver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the given placeholder using the given properties, performing
|
||||
* a system properties check according to the given mode.
|
||||
* <p>Default implementation delegates to <code>resolvePlaceholder
|
||||
* <p>The default implementation delegates to <code>resolvePlaceholder
|
||||
* (placeholder, props)</code> before/after the system properties check.
|
||||
* <p>Subclasses can override this for custom resolution strategies,
|
||||
* including customized points for the system properties check.
|
||||
@@ -368,6 +206,20 @@ public class PropertyPlaceholderConfigurer extends PropertyResourceConfigurer
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Visit each bean definition in the given bean factory and attempt to replace ${...} property
|
||||
* placeholders with values from the given properties.
|
||||
*/
|
||||
@Override
|
||||
protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props)
|
||||
throws BeansException {
|
||||
|
||||
StringValueResolver valueResolver = new PlaceholderResolvingStringValueResolver(props);
|
||||
|
||||
this.doProcessProperties(beanFactoryToProcess, valueResolver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the given String value for placeholder resolution.
|
||||
* @param strVal the String value to parse
|
||||
@@ -379,7 +231,7 @@ public class PropertyPlaceholderConfigurer extends PropertyResourceConfigurer
|
||||
* Only retained for compatibility with Spring 2.5 extensions.
|
||||
*/
|
||||
@Deprecated
|
||||
protected String parseStringValue(String strVal, Properties props, Set visitedPlaceholders) {
|
||||
protected String parseStringValue(String strVal, Properties props, Set<?> visitedPlaceholders) {
|
||||
PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper(
|
||||
placeholderPrefix, placeholderSuffix, valueSeparator, ignoreUnresolvablePlaceholders);
|
||||
PlaceholderResolver resolver = new PropertyPlaceholderConfigurerResolver(props);
|
||||
|
||||
+12
-3
@@ -55,15 +55,24 @@ public abstract class PropertyResourceConfigurer extends PropertiesLoaderSupport
|
||||
private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered
|
||||
|
||||
|
||||
/**
|
||||
* Set the order value of this object for sorting purposes.
|
||||
* @see PriorityOrdered
|
||||
*/
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return this.order;
|
||||
return this.order;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@linkplain #mergeProperties Merge}, {@linkplain #convertProperties convert} and
|
||||
* {@linkplain #processProperties process} properties against the given bean factory.
|
||||
* @throws BeanInitializationException if any properties cannot be loaded
|
||||
*/
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
try {
|
||||
Properties mergedProps = mergeProperties();
|
||||
@@ -88,7 +97,7 @@ public abstract class PropertyResourceConfigurer extends PropertiesLoaderSupport
|
||||
* @see #processProperties
|
||||
*/
|
||||
protected void convertProperties(Properties props) {
|
||||
Enumeration propertyNames = props.propertyNames();
|
||||
Enumeration<?> propertyNames = props.propertyNames();
|
||||
while (propertyNames.hasMoreElements()) {
|
||||
String propertyName = (String) propertyNames.nextElement();
|
||||
String propertyValue = props.getProperty(propertyName);
|
||||
|
||||
+13
-11
@@ -48,6 +48,7 @@ import org.springframework.beans.PropertyAccessorUtils;
|
||||
import org.springframework.beans.PropertyValue;
|
||||
import org.springframework.beans.PropertyValues;
|
||||
import org.springframework.beans.TypeConverter;
|
||||
import org.springframework.beans.factory.Aware;
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.BeanCurrentlyInCreationException;
|
||||
@@ -166,7 +167,6 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
setParentBeanFactory(parentBeanFactory);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the instantiation strategy to use for creating bean instances.
|
||||
* Default is CglibSubclassingInstantiationStrategy.
|
||||
@@ -631,7 +631,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
// If all factory methods have the same return type, return that type.
|
||||
// Can't clearly figure out exact method due to type converting / autowiring!
|
||||
int minNrOfArgs = mbd.getConstructorArgumentValues().getArgumentCount();
|
||||
Method[] candidates = ReflectionUtils.getAllDeclaredMethods(factoryClass);
|
||||
Method[] candidates = ReflectionUtils.getUniqueDeclaredMethods(factoryClass);
|
||||
Set<Class> returnTypes = new HashSet<Class>(1);
|
||||
for (Method factoryMethod : candidates) {
|
||||
if (Modifier.isStatic(factoryMethod.getModifiers()) == isStatic &&
|
||||
@@ -1427,16 +1427,18 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
}
|
||||
return wrappedBean;
|
||||
}
|
||||
|
||||
|
||||
private void invokeAwareMethods(final String beanName, final Object bean) {
|
||||
if (bean instanceof BeanNameAware) {
|
||||
((BeanNameAware) bean).setBeanName(beanName);
|
||||
}
|
||||
if (bean instanceof BeanClassLoaderAware) {
|
||||
((BeanClassLoaderAware) bean).setBeanClassLoader(getBeanClassLoader());
|
||||
}
|
||||
if (bean instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) bean).setBeanFactory(AbstractAutowireCapableBeanFactory.this);
|
||||
if (bean instanceof Aware) {
|
||||
if (bean instanceof BeanNameAware) {
|
||||
((BeanNameAware) bean).setBeanName(beanName);
|
||||
}
|
||||
if (bean instanceof BeanClassLoaderAware) {
|
||||
((BeanClassLoaderAware) bean).setBeanClassLoader(getBeanClassLoader());
|
||||
}
|
||||
if (bean instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) bean).setBeanFactory(AbstractAutowireCapableBeanFactory.this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+33
-2
@@ -21,8 +21,10 @@ import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.env.EnvironmentCapable;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
@@ -37,10 +39,11 @@ import org.springframework.util.Assert;
|
||||
* and the class loader to use for loading bean classes.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
* @since 11.12.2003
|
||||
* @see BeanDefinitionReaderUtils
|
||||
*/
|
||||
public abstract class AbstractBeanDefinitionReader implements BeanDefinitionReader {
|
||||
public abstract class AbstractBeanDefinitionReader implements EnvironmentCapable, BeanDefinitionReader {
|
||||
|
||||
/** Logger available to subclasses */
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
@@ -51,6 +54,8 @@ public abstract class AbstractBeanDefinitionReader implements BeanDefinitionRead
|
||||
|
||||
private ClassLoader beanClassLoader;
|
||||
|
||||
private Environment environment = new StandardEnvironment();
|
||||
|
||||
private BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
|
||||
|
||||
|
||||
@@ -62,9 +67,14 @@ public abstract class AbstractBeanDefinitionReader implements BeanDefinitionRead
|
||||
* {@link org.springframework.context.ApplicationContext} implementations.
|
||||
* <p>If given a plain BeanDefinitionRegistry, the default ResourceLoader will be a
|
||||
* {@link org.springframework.core.io.support.PathMatchingResourcePatternResolver}.
|
||||
* <p>If the the passed-in bean factory also implements {@link EnvironmentCapable} its
|
||||
* environment will be used by this reader. Otherwise, the reader will initialize and
|
||||
* use a {@link StandardEnvironment}. All ApplicationContext implementations are
|
||||
* EnvironmentCapable, while normal BeanFactory implementations are not.
|
||||
* @param registry the BeanFactory to load bean definitions into,
|
||||
* in the form of a BeanDefinitionRegistry
|
||||
* @see #setResourceLoader
|
||||
* @see #setEnvironment
|
||||
*/
|
||||
protected AbstractBeanDefinitionReader(BeanDefinitionRegistry registry) {
|
||||
Assert.notNull(registry, "BeanDefinitionRegistry must not be null");
|
||||
@@ -77,6 +87,14 @@ public abstract class AbstractBeanDefinitionReader implements BeanDefinitionRead
|
||||
else {
|
||||
this.resourceLoader = new PathMatchingResourcePatternResolver();
|
||||
}
|
||||
|
||||
// Inherit Environment if possible
|
||||
if (this.registry instanceof EnvironmentCapable) {
|
||||
this.environment = ((EnvironmentCapable)this.registry).getEnvironment();
|
||||
}
|
||||
else {
|
||||
this.environment = new StandardEnvironment();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,6 +140,19 @@ public abstract class AbstractBeanDefinitionReader implements BeanDefinitionRead
|
||||
return this.beanClassLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Environment to use when reading bean definitions. Most often used
|
||||
* for evaluating profile information to determine which bean definitions
|
||||
* should be read and which should be omitted.
|
||||
*/
|
||||
public void setEnvironment(Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
public Environment getEnvironment() {
|
||||
return this.environment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the BeanNameGenerator to use for anonymous beans
|
||||
* (without explicit bean name specified).
|
||||
|
||||
+7
-3
@@ -68,6 +68,8 @@ import org.springframework.beans.factory.config.Scope;
|
||||
import org.springframework.core.DecoratingClassLoader;
|
||||
import org.springframework.core.NamedThreadLocal;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -100,6 +102,7 @@ import org.springframework.util.StringValueResolver;
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
* @author Costin Leau
|
||||
* @author Chris Beams
|
||||
* @since 15 April 2001
|
||||
* @see #getBeanDefinition
|
||||
* @see #createBean
|
||||
@@ -166,6 +169,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
private final ThreadLocal<Object> prototypesCurrentlyInCreation =
|
||||
new NamedThreadLocal<Object>("Prototype beans currently in creation");
|
||||
|
||||
|
||||
/**
|
||||
* Create a new AbstractBeanFactory.
|
||||
*/
|
||||
@@ -189,7 +193,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
public Object getBean(String name) throws BeansException {
|
||||
return doGetBean(name, null, null, false);
|
||||
}
|
||||
|
||||
|
||||
public <T> T getBean(String name, Class<T> requiredType) throws BeansException {
|
||||
return doGetBean(name, requiredType, null, false);
|
||||
}
|
||||
@@ -682,7 +686,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
return this.propertyEditorRegistrars;
|
||||
}
|
||||
|
||||
public void registerCustomEditor(Class requiredType, Class<? extends PropertyEditor> propertyEditorClass) {
|
||||
public void registerCustomEditor(Class<?> requiredType, Class<? extends PropertyEditor> propertyEditorClass) {
|
||||
Assert.notNull(requiredType, "Required type must not be null");
|
||||
Assert.isAssignable(PropertyEditor.class, propertyEditorClass);
|
||||
this.customEditors.put(requiredType, propertyEditorClass);
|
||||
@@ -1253,7 +1257,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(), err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Class doResolveBeanClass(RootBeanDefinition mbd, Class... typesToMatch) throws ClassNotFoundException {
|
||||
if (!ObjectUtils.isEmpty(typesToMatch)) {
|
||||
ClassLoader tempClassLoader = getTempClassLoader();
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2011 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.
|
||||
@@ -305,7 +305,7 @@ public class BeanDefinitionBuilder {
|
||||
this.beanDefinition.setDependsOn(new String[] {beanName});
|
||||
}
|
||||
else {
|
||||
String[] added = (String[]) ObjectUtils.addObjectToArray(this.beanDefinition.getDependsOn(), beanName);
|
||||
String[] added = ObjectUtils.addObjectToArray(this.beanDefinition.getDependsOn(), beanName);
|
||||
this.beanDefinition.setDependsOn(added);
|
||||
}
|
||||
return this;
|
||||
|
||||
-1
@@ -168,7 +168,6 @@ public class BeanDefinitionReaderUtils {
|
||||
public static String registerWithGeneratedName(
|
||||
AbstractBeanDefinition definition, BeanDefinitionRegistry registry)
|
||||
throws BeanDefinitionStoreException {
|
||||
|
||||
String generatedName = generateBeanName(definition, registry, false);
|
||||
registry.registerBeanDefinition(generatedName, definition);
|
||||
return generatedName;
|
||||
|
||||
+1
-1
@@ -460,7 +460,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
// Implementation of ConfigurableListableBeanFactory interface
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
public void registerResolvableDependency(Class dependencyType, Object autowiredValue) {
|
||||
public void registerResolvableDependency(Class<?> dependencyType, Object autowiredValue) {
|
||||
Assert.notNull(dependencyType, "Type must not be null");
|
||||
if (autowiredValue != null) {
|
||||
Assert.isTrue((autowiredValue instanceof ObjectFactory || dependencyType.isInstance(autowiredValue)),
|
||||
|
||||
+13
-2
@@ -97,6 +97,9 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
|
||||
/** Names of beans that are currently in creation */
|
||||
private final Set<String> singletonsCurrentlyInCreation = Collections.synchronizedSet(new HashSet<String>());
|
||||
|
||||
/** Names of beans currently excluded from in creation checks */
|
||||
private final Set<String> inCreationCheckExclusions = new HashSet<String>();
|
||||
|
||||
/** List of suppressed Exceptions, available for associating related causes */
|
||||
private Set<Exception> suppressedExceptions;
|
||||
|
||||
@@ -293,7 +296,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
|
||||
* @see #isSingletonCurrentlyInCreation
|
||||
*/
|
||||
protected void beforeSingletonCreation(String beanName) {
|
||||
if (!this.singletonsCurrentlyInCreation.add(beanName)) {
|
||||
if (!this.inCreationCheckExclusions.contains(beanName) && !this.singletonsCurrentlyInCreation.add(beanName)) {
|
||||
throw new BeanCurrentlyInCreationException(beanName);
|
||||
}
|
||||
}
|
||||
@@ -305,11 +308,19 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
|
||||
* @see #isSingletonCurrentlyInCreation
|
||||
*/
|
||||
protected void afterSingletonCreation(String beanName) {
|
||||
if (!this.singletonsCurrentlyInCreation.remove(beanName)) {
|
||||
if (!this.inCreationCheckExclusions.contains(beanName) && !this.singletonsCurrentlyInCreation.remove(beanName)) {
|
||||
throw new IllegalStateException("Singleton '" + beanName + "' isn't currently in creation");
|
||||
}
|
||||
}
|
||||
|
||||
public final void setCurrentlyInCreation(String beanName, boolean inCreation) {
|
||||
if (!inCreation) {
|
||||
this.inCreationCheckExclusions.add(beanName);
|
||||
} else {
|
||||
this.inCreationCheckExclusions.remove(beanName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the specified singleton bean is currently in creation
|
||||
* (within the entire factory).
|
||||
|
||||
+1
-1
@@ -43,6 +43,6 @@ public interface MergedBeanDefinitionPostProcessor extends BeanPostProcessor {
|
||||
* @param beanType the actual type of the managed bean instance
|
||||
* @param beanName the name of the bean
|
||||
*/
|
||||
void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class beanType, String beanName);
|
||||
void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName);
|
||||
|
||||
}
|
||||
|
||||
+23
-3
@@ -42,6 +42,8 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class SimpleInstantiationStrategy implements InstantiationStrategy {
|
||||
|
||||
private static final ThreadLocal<Method> currentlyInvokedFactoryMethod = new ThreadLocal<Method>();
|
||||
|
||||
public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner) {
|
||||
// Don't override the class with CGLIB if no overrides.
|
||||
if (beanDefinition.getMethodOverrides().isEmpty()) {
|
||||
@@ -140,9 +142,19 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy {
|
||||
else {
|
||||
ReflectionUtils.makeAccessible(factoryMethod);
|
||||
}
|
||||
|
||||
// It's a static method if the target is null.
|
||||
return factoryMethod.invoke(factoryBean, args);
|
||||
|
||||
Method priorInvokedFactoryMethod = currentlyInvokedFactoryMethod.get();
|
||||
try {
|
||||
currentlyInvokedFactoryMethod.set(factoryMethod);
|
||||
return factoryMethod.invoke(factoryBean, args);
|
||||
} finally {
|
||||
if (priorInvokedFactoryMethod != null) {
|
||||
currentlyInvokedFactoryMethod.set(priorInvokedFactoryMethod);
|
||||
}
|
||||
else {
|
||||
currentlyInvokedFactoryMethod.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
throw new BeanDefinitionStoreException(
|
||||
@@ -159,4 +171,12 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the factory method currently being invoked or {@code null} if none.
|
||||
* Allows factory method implementations to determine whether the current
|
||||
* caller is the container itself as opposed to user code.
|
||||
*/
|
||||
public static Method getCurrentlyInvokedFactoryMethod() {
|
||||
return currentlyInvokedFactoryMethod.get();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2010 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 abstract class AbstractSingleBeanDefinitionParser extends AbstractBeanDef
|
||||
if (parentName != null) {
|
||||
builder.getRawBeanDefinition().setParentName(parentName);
|
||||
}
|
||||
Class beanClass = getBeanClass(element);
|
||||
Class<?> beanClass = getBeanClass(element);
|
||||
if (beanClass != null) {
|
||||
builder.getRawBeanDefinition().setBeanClass(beanClass);
|
||||
}
|
||||
@@ -111,7 +111,7 @@ public abstract class AbstractSingleBeanDefinitionParser extends AbstractBeanDef
|
||||
* the supplied <code>Element</code>, or <code>null</code> if none
|
||||
* @see #getBeanClassName
|
||||
*/
|
||||
protected Class getBeanClass(Element element) {
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+10
-2
@@ -16,9 +16,10 @@
|
||||
|
||||
package org.springframework.beans.factory.xml;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
/**
|
||||
* SPI for parsing an XML document that contains Spring bean definitions.
|
||||
@@ -46,4 +47,11 @@ public interface BeanDefinitionDocumentReader {
|
||||
void registerBeanDefinitions(Document doc, XmlReaderContext readerContext)
|
||||
throws BeanDefinitionStoreException;
|
||||
|
||||
/**
|
||||
* Set the Environment to use when reading bean definitions. Used for evaluating
|
||||
* profile information to determine whether a {@code <beans/>} document/element should
|
||||
* be included or omitted.
|
||||
*/
|
||||
void setEnvironment(Environment environment);
|
||||
|
||||
}
|
||||
|
||||
+6
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2006 the original author or authors.
|
||||
* Copyright 2002-2011 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,9 +21,8 @@ import org.w3c.dom.Element;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
|
||||
/**
|
||||
* Interface used by the
|
||||
* {@link org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader} to
|
||||
* handle custom, top-level (directly under <code><beans></code>) tags.
|
||||
* Interface used by the {@link DefaultBeanDefinitionDocumentReader} to handle custom,
|
||||
* top-level (directly under {@code <beans/>}) tags.
|
||||
*
|
||||
* <p>Implementations are free to turn the metadata in the custom tag into as many
|
||||
* {@link BeanDefinition BeanDefinitions} as required.
|
||||
@@ -34,7 +33,6 @@ import org.springframework.beans.factory.config.BeanDefinition;
|
||||
* @author Rob Harrop
|
||||
* @since 2.0
|
||||
* @see NamespaceHandler
|
||||
* @see org.springframework.beans.factory.xml.BeanDefinitionDecorator
|
||||
* @see AbstractBeanDefinitionParser
|
||||
*/
|
||||
public interface BeanDefinitionParser {
|
||||
@@ -42,12 +40,12 @@ public interface BeanDefinitionParser {
|
||||
/**
|
||||
* Parse the specified {@link Element} and register the resulting
|
||||
* {@link BeanDefinition BeanDefinition(s)} with the
|
||||
* {@link org.springframework.beans.factory.xml.ParserContext#getRegistry()} BeanDefinitionRegistry}
|
||||
* {@link org.springframework.beans.factory.xml.ParserContext#getRegistry() BeanDefinitionRegistry}
|
||||
* embedded in the supplied {@link ParserContext}.
|
||||
* <p>Implementations must return the primary {@link BeanDefinition} that results
|
||||
* from the parse if they will ever be used in a nested fashion (for example as
|
||||
* an inner tag in a <code><property/></code> tag). Implementations may return
|
||||
* <code>null</code> if they will <strong>not</strong> be used in a nested fashion.
|
||||
* an inner tag in a {@code <property/>} tag). Implementations may return
|
||||
* {@code null} if they will <strong>not</strong> be used in a nested fashion.
|
||||
* @param element the element that is to be parsed into one or more {@link BeanDefinition BeanDefinitions}
|
||||
* @param parserContext the object encapsulating the current state of the parsing process;
|
||||
* provides access to a {@link org.springframework.beans.factory.support.BeanDefinitionRegistry}
|
||||
|
||||
+96
-17
@@ -27,6 +27,7 @@ import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
@@ -58,6 +59,8 @@ import org.springframework.beans.factory.support.ManagedProperties;
|
||||
import org.springframework.beans.factory.support.ManagedSet;
|
||||
import org.springframework.beans.factory.support.MethodOverrides;
|
||||
import org.springframework.beans.factory.support.ReplaceOverride;
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -84,7 +87,10 @@ public class BeanDefinitionParserDelegate {
|
||||
|
||||
public static final String BEANS_NAMESPACE_URI = "http://www.springframework.org/schema/beans";
|
||||
|
||||
public static final String BEAN_NAME_DELIMITERS = ",; ";
|
||||
public static final String MULTI_VALUE_ATTRIBUTE_DELIMITERS = ",; ";
|
||||
|
||||
/** @deprecated as of Spring 3.1 in favor of {@link #MULTI_VALUE_ATTRIBUTE_DELIMITERS} */
|
||||
public static final String BEAN_NAME_DELIMITERS = MULTI_VALUE_ATTRIBUTE_DELIMITERS;
|
||||
|
||||
/**
|
||||
* Value of a T/F attribute that represents true.
|
||||
@@ -92,10 +98,14 @@ public class BeanDefinitionParserDelegate {
|
||||
*/
|
||||
public static final String TRUE_VALUE = "true";
|
||||
|
||||
public static final String FALSE_VALUE = "false";
|
||||
|
||||
public static final String DEFAULT_VALUE = "default";
|
||||
|
||||
public static final String DESCRIPTION_ELEMENT = "description";
|
||||
|
||||
public static final String AUTOWIRE_NO_VALUE = "no";
|
||||
|
||||
public static final String AUTOWIRE_BY_NAME_VALUE = "byName";
|
||||
|
||||
public static final String AUTOWIRE_BY_TYPE_VALUE = "byType";
|
||||
@@ -239,19 +249,36 @@ public class BeanDefinitionParserDelegate {
|
||||
|
||||
private final ParseState parseState = new ParseState();
|
||||
|
||||
private Environment environment;
|
||||
|
||||
/**
|
||||
* Stores all used bean names so we can enforce uniqueness on a per file basis.
|
||||
* Stores all used bean names so we can enforce uniqueness on a per
|
||||
* beans-element basis. Duplicate bean ids/names may not exist within the
|
||||
* same level of beans element nesting, but may be duplicated across levels.
|
||||
*/
|
||||
private final Set<String> usedNames = new HashSet<String>();
|
||||
|
||||
|
||||
/**
|
||||
* Create a new BeanDefinitionParserDelegate associated with the
|
||||
* supplied {@link XmlReaderContext}.
|
||||
* supplied {@link XmlReaderContext} and {@link Environment}.
|
||||
*/
|
||||
public BeanDefinitionParserDelegate(XmlReaderContext readerContext) {
|
||||
public BeanDefinitionParserDelegate(XmlReaderContext readerContext, Environment environment) {
|
||||
Assert.notNull(readerContext, "XmlReaderContext must not be null");
|
||||
Assert.notNull(readerContext, "Environment must not be null");
|
||||
this.readerContext = readerContext;
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new BeanDefinitionParserDelegate associated with the
|
||||
* supplied {@link XmlReaderContext} and a new {@link StandardEnvironment}.
|
||||
* @deprecated since Spring 3.1 in favor of
|
||||
* {@link #BeanDefinitionParserDelegate(XmlReaderContext, Environment)}
|
||||
*/
|
||||
@Deprecated
|
||||
public BeanDefinitionParserDelegate(XmlReaderContext readerContext) {
|
||||
this(readerContext, new StandardEnvironment());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,6 +288,12 @@ public class BeanDefinitionParserDelegate {
|
||||
return this.readerContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link Environment} associated with this helper instance.
|
||||
*/
|
||||
public final Environment getEnvironment() {
|
||||
return this.environment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke the {@link org.springframework.beans.factory.parsing.SourceExtractor} to pull the
|
||||
@@ -294,33 +327,78 @@ public class BeanDefinitionParserDelegate {
|
||||
|
||||
/**
|
||||
* Initialize the default lazy-init, autowire, dependency check settings,
|
||||
* init-method, destroy-method and merge settings.
|
||||
* @see #populateDefaults(DocumentDefaultsDefinition, org.w3c.dom.Element)
|
||||
* init-method, destroy-method and merge settings. Support nested 'beans'
|
||||
* element use cases by falling back to the given parent in case the
|
||||
* defaults are not explicitly set locally.
|
||||
* @see #populateDefaults(DocumentDefaultsDefinition, DocumentDefaultsDefinition, org.w3c.dom.Element)
|
||||
* @see #getDefaults()
|
||||
*/
|
||||
public void initDefaults(Element root) {
|
||||
populateDefaults(this.defaults, root);
|
||||
public void initDefaults(Element root, BeanDefinitionParserDelegate parent) {
|
||||
populateDefaults(this.defaults, (parent != null ? parent.defaults : null), root);
|
||||
this.readerContext.fireDefaultsRegistered(this.defaults);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the default settings assuming a {@code null} parent delegate.
|
||||
* @deprecated in Spring 3.1 in favor of
|
||||
* {@link #initDefaults(Element, BeanDefinitionParserDelegate)}
|
||||
*/
|
||||
public void initDefaults(Element root) {
|
||||
initDefaults(root, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the given DocumentDefaultsDefinition instance with the default lazy-init,
|
||||
* autowire, dependency check settings, init-method, destroy-method and merge settings.
|
||||
* Support nested 'beans' element use cases by falling back to
|
||||
* <literal>parentDefaults</literal> in case the defaults are not explicitly set
|
||||
* locally.
|
||||
* @param defaults the defaults to populate
|
||||
* @param defaults the parent BeanDefinitionParserDelegate (if any) defaults to fall back to
|
||||
* @param root the root element of the current bean definition document (or nested beans element)
|
||||
*/
|
||||
protected void populateDefaults(DocumentDefaultsDefinition defaults, Element root) {
|
||||
defaults.setLazyInit(root.getAttribute(DEFAULT_LAZY_INIT_ATTRIBUTE));
|
||||
defaults.setMerge(root.getAttribute(DEFAULT_MERGE_ATTRIBUTE));
|
||||
defaults.setAutowire(root.getAttribute(DEFAULT_AUTOWIRE_ATTRIBUTE));
|
||||
protected void populateDefaults(DocumentDefaultsDefinition defaults, DocumentDefaultsDefinition parentDefaults, Element root) {
|
||||
String lazyInit = root.getAttribute(DEFAULT_LAZY_INIT_ATTRIBUTE);
|
||||
if (DEFAULT_VALUE.equals(lazyInit)) {
|
||||
lazyInit = parentDefaults != null ? parentDefaults.getLazyInit() : FALSE_VALUE;
|
||||
}
|
||||
defaults.setLazyInit(lazyInit);
|
||||
|
||||
String merge = root.getAttribute(DEFAULT_MERGE_ATTRIBUTE);
|
||||
if (DEFAULT_VALUE.equals(merge)) {
|
||||
merge = parentDefaults != null ? parentDefaults.getMerge() : FALSE_VALUE;
|
||||
}
|
||||
defaults.setMerge(merge);
|
||||
|
||||
String autowire = root.getAttribute(DEFAULT_AUTOWIRE_ATTRIBUTE);
|
||||
if (DEFAULT_VALUE.equals(autowire)) {
|
||||
autowire = parentDefaults != null ? parentDefaults.getAutowire() : AUTOWIRE_NO_VALUE;
|
||||
}
|
||||
defaults.setAutowire(autowire);
|
||||
|
||||
// don't fall back to parentDefaults for dependency-check as it's no
|
||||
// longer supported in <beans> as of 3.0. Therefore, no nested <beans>
|
||||
// would ever need to fall back to it.
|
||||
defaults.setDependencyCheck(root.getAttribute(DEFAULT_DEPENDENCY_CHECK_ATTRIBUTE));
|
||||
|
||||
if (root.hasAttribute(DEFAULT_AUTOWIRE_CANDIDATES_ATTRIBUTE)) {
|
||||
defaults.setAutowireCandidates(root.getAttribute(DEFAULT_AUTOWIRE_CANDIDATES_ATTRIBUTE));
|
||||
} else if (parentDefaults != null) {
|
||||
defaults.setAutowireCandidates(parentDefaults.getAutowireCandidates());
|
||||
}
|
||||
|
||||
if (root.hasAttribute(DEFAULT_INIT_METHOD_ATTRIBUTE)) {
|
||||
defaults.setInitMethod(root.getAttribute(DEFAULT_INIT_METHOD_ATTRIBUTE));
|
||||
} else if (parentDefaults != null) {
|
||||
defaults.setInitMethod(parentDefaults.getInitMethod());
|
||||
}
|
||||
|
||||
if (root.hasAttribute(DEFAULT_DESTROY_METHOD_ATTRIBUTE)) {
|
||||
defaults.setDestroyMethod(root.getAttribute(DEFAULT_DESTROY_METHOD_ATTRIBUTE));
|
||||
} else if (parentDefaults != null) {
|
||||
defaults.setDestroyMethod(parentDefaults.getDestroyMethod());
|
||||
}
|
||||
|
||||
defaults.setSource(this.readerContext.extractSource(root));
|
||||
}
|
||||
|
||||
@@ -376,7 +454,7 @@ public class BeanDefinitionParserDelegate {
|
||||
|
||||
List<String> aliases = new ArrayList<String>();
|
||||
if (StringUtils.hasLength(nameAttr)) {
|
||||
String[] nameArr = StringUtils.tokenizeToStringArray(nameAttr, BEAN_NAME_DELIMITERS);
|
||||
String[] nameArr = StringUtils.tokenizeToStringArray(nameAttr, MULTI_VALUE_ATTRIBUTE_DELIMITERS);
|
||||
aliases.addAll(Arrays.asList(nameArr));
|
||||
}
|
||||
|
||||
@@ -431,7 +509,8 @@ public class BeanDefinitionParserDelegate {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that the specified bean name and aliases have not been used already.
|
||||
* Validate that the specified bean name and aliases have not been used already
|
||||
* within the current level of beans element nesting.
|
||||
*/
|
||||
protected void checkNameUniqueness(String beanName, List<String> aliases, Element beanElement) {
|
||||
String foundName = null;
|
||||
@@ -443,7 +522,7 @@ public class BeanDefinitionParserDelegate {
|
||||
foundName = (String) CollectionUtils.findFirstMatch(this.usedNames, aliases);
|
||||
}
|
||||
if (foundName != null) {
|
||||
error("Bean name '" + foundName + "' is already used in this file", beanElement);
|
||||
error("Bean name '" + foundName + "' is already used in this <beans> element", beanElement);
|
||||
}
|
||||
|
||||
this.usedNames.add(beanName);
|
||||
@@ -548,7 +627,7 @@ public class BeanDefinitionParserDelegate {
|
||||
|
||||
if (ele.hasAttribute(DEPENDS_ON_ATTRIBUTE)) {
|
||||
String dependsOn = ele.getAttribute(DEPENDS_ON_ATTRIBUTE);
|
||||
bd.setDependsOn(StringUtils.tokenizeToStringArray(dependsOn, BEAN_NAME_DELIMITERS));
|
||||
bd.setDependsOn(StringUtils.tokenizeToStringArray(dependsOn, MULTI_VALUE_ATTRIBUTE_DELIMITERS));
|
||||
}
|
||||
|
||||
String autowireCandidate = ele.getAttribute(AUTOWIRE_CANDIDATE_ATTRIBUTE);
|
||||
@@ -1422,7 +1501,7 @@ public class BeanDefinitionParserDelegate {
|
||||
/**
|
||||
* Determine whether the name of the supplied node is equal to the supplied name.
|
||||
* <p>The default implementation checks the supplied desired name against both
|
||||
* {@link Node#getNodeName()) and {@link Node#getLocalName()}.
|
||||
* {@link Node#getNodeName()} and {@link Node#getLocalName()}.
|
||||
* <p>Subclasses may override the default implementation to provide a different
|
||||
* mechanism for comparing node names.
|
||||
* @param node the node to compare
|
||||
|
||||
+67
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2011 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,11 +32,12 @@ import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.ResourcePatternUtils;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.SystemPropertyUtils;
|
||||
|
||||
/**
|
||||
* Default implementation of the {@link BeanDefinitionDocumentReader} interface.
|
||||
@@ -59,6 +60,8 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume
|
||||
|
||||
public static final String BEAN_ELEMENT = BeanDefinitionParserDelegate.BEAN_ELEMENT;
|
||||
|
||||
public static final String NESTED_BEANS_ELEMENT = "beans";
|
||||
|
||||
public static final String ALIAS_ELEMENT = "alias";
|
||||
|
||||
public static final String NAME_ATTRIBUTE = "name";
|
||||
@@ -69,17 +72,35 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume
|
||||
|
||||
public static final String RESOURCE_ATTRIBUTE = "resource";
|
||||
|
||||
/** @see org.springframework.context.annotation.Profile */
|
||||
public static final String PROFILE_ATTRIBUTE = "profile";
|
||||
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private XmlReaderContext readerContext;
|
||||
|
||||
private Environment environment;
|
||||
|
||||
private BeanDefinitionParserDelegate delegate;
|
||||
|
||||
|
||||
/**
|
||||
* Parses bean definitions according to the "spring-beans" DTD.
|
||||
* {@inheritDoc}
|
||||
* <p>Default value is {@code null}; property is required for parsing any
|
||||
* {@code <beans/>} element with a {@code profile} attribute present.
|
||||
* @see #doRegisterBeanDefinitions
|
||||
*/
|
||||
public void setEnvironment(Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>This implementation parses bean definitions according to the "spring-beans" XSD
|
||||
* (or DTD, historically).
|
||||
* <p>Opens a DOM Document; then initializes the default settings
|
||||
* specified at <code><beans></code> level; then parses
|
||||
* the contained bean definitions.
|
||||
* specified at the {@code <beans/>} level; then parses the contained bean definitions.
|
||||
*/
|
||||
public void registerBeanDefinitions(Document doc, XmlReaderContext readerContext) {
|
||||
this.readerContext = readerContext;
|
||||
@@ -87,16 +108,44 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume
|
||||
logger.debug("Loading bean definitions");
|
||||
Element root = doc.getDocumentElement();
|
||||
|
||||
BeanDefinitionParserDelegate delegate = createHelper(readerContext, root);
|
||||
|
||||
preProcessXml(root);
|
||||
parseBeanDefinitions(root, delegate);
|
||||
postProcessXml(root);
|
||||
doRegisterBeanDefinitions(root);
|
||||
}
|
||||
|
||||
protected BeanDefinitionParserDelegate createHelper(XmlReaderContext readerContext, Element root) {
|
||||
BeanDefinitionParserDelegate delegate = new BeanDefinitionParserDelegate(readerContext);
|
||||
delegate.initDefaults(root);
|
||||
/**
|
||||
* Register each bean definition within the given root {@code <beans/>} element.
|
||||
* @throws IllegalStateException if {@code <beans profile="..."} attribute is present
|
||||
* and Environment property has not been set
|
||||
* @see #setEnvironment
|
||||
*/
|
||||
protected void doRegisterBeanDefinitions(Element root) {
|
||||
String profileSpec = root.getAttribute(PROFILE_ATTRIBUTE);
|
||||
if (StringUtils.hasText(profileSpec)) {
|
||||
Assert.state(this.environment != null, "environment property must not be null");
|
||||
String[] specifiedProfiles = StringUtils.tokenizeToStringArray(profileSpec, BeanDefinitionParserDelegate.MULTI_VALUE_ATTRIBUTE_DELIMITERS);
|
||||
if (!this.environment.acceptsProfiles(specifiedProfiles)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// any nested <beans> elements will cause recursion in this method. In
|
||||
// order to propagate and preserve <beans> default-* attributes correctly,
|
||||
// keep track of the current (parent) delegate, which may be null. Create
|
||||
// the new (child) delegate with a reference to the parent for fallback purposes,
|
||||
// then ultimately reset this.delegate back to its original (parent) reference.
|
||||
// this behavior emulates a stack of delegates without actually necessitating one.
|
||||
BeanDefinitionParserDelegate parent = this.delegate;
|
||||
this.delegate = createHelper(readerContext, root, parent);
|
||||
|
||||
preProcessXml(root);
|
||||
parseBeanDefinitions(root, this.delegate);
|
||||
postProcessXml(root);
|
||||
|
||||
this.delegate = parent;
|
||||
}
|
||||
|
||||
protected BeanDefinitionParserDelegate createHelper(XmlReaderContext readerContext, Element root, BeanDefinitionParserDelegate parentDelegate) {
|
||||
BeanDefinitionParserDelegate delegate = new BeanDefinitionParserDelegate(readerContext, environment);
|
||||
delegate.initDefaults(root, parentDelegate);
|
||||
return delegate;
|
||||
}
|
||||
|
||||
@@ -152,6 +201,10 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume
|
||||
else if (delegate.nodeNameEquals(ele, BEAN_ELEMENT)) {
|
||||
processBeanDefinition(ele, delegate);
|
||||
}
|
||||
else if (delegate.nodeNameEquals(ele, NESTED_BEANS_ELEMENT)) {
|
||||
// recurse
|
||||
doRegisterBeanDefinitions(ele);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,7 +219,7 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume
|
||||
}
|
||||
|
||||
// Resolve system properties: e.g. "${user.dir}"
|
||||
location = SystemPropertyUtils.resolvePlaceholders(location);
|
||||
location = environment.resolveRequiredPlaceholders(location);
|
||||
|
||||
Set<Resource> actualResources = new LinkedHashSet<Resource>(4);
|
||||
|
||||
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.beans.factory.xml;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.config.ConstructorArgumentValues;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder;
|
||||
import org.springframework.core.Conventions;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* Simple <code>NamespaceHandler</code> implementation that maps custom
|
||||
* attributes directly through to bean properties. An important point to note is
|
||||
* that this <code>NamespaceHandler</code> does not have a corresponding schema
|
||||
* since there is no way to know in advance all possible attribute names.
|
||||
*
|
||||
* <p>
|
||||
* An example of the usage of this <code>NamespaceHandler</code> is shown below:
|
||||
*
|
||||
* <pre class="code">
|
||||
* <bean id="author" class="..TestBean" c:name="Enescu" c:work-ref="compositions"/>
|
||||
* </pre>
|
||||
*
|
||||
* Here the '<code>c:name</code>' corresponds directly to the '<code>name</code>
|
||||
* ' argument declared on the constructor of class '<code>TestBean</code>'. The
|
||||
* '<code>c:work-ref</code>' attributes corresponds to the '<code>work</code>'
|
||||
* argument and, rather than being the concrete value, it contains the name of
|
||||
* the bean that will be considered as a parameter.
|
||||
*
|
||||
* <b>Note</b>: This implementation supports only named parameters - there is no
|
||||
* support for indexes or types. Further more, the names are used as hints by
|
||||
* the container which, by default, does type introspection.
|
||||
*
|
||||
* @see SimplePropertyNamespaceHandler
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
|
||||
|
||||
private static final String REF_SUFFIX = "-ref";
|
||||
private static final String DELIMITER_PREFIX = "_";
|
||||
|
||||
public void init() {
|
||||
}
|
||||
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
parserContext.getReaderContext().error(
|
||||
"Class [" + getClass().getName() + "] does not support custom elements.", element);
|
||||
return null;
|
||||
}
|
||||
|
||||
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
|
||||
if (node instanceof Attr) {
|
||||
Attr attr = (Attr) node;
|
||||
String argName = StringUtils.trimWhitespace(parserContext.getDelegate().getLocalName(attr));
|
||||
String argValue = StringUtils.trimWhitespace(attr.getValue());
|
||||
|
||||
ConstructorArgumentValues cvs = definition.getBeanDefinition().getConstructorArgumentValues();
|
||||
boolean ref = false;
|
||||
|
||||
// handle -ref arguments
|
||||
if (argName.endsWith(REF_SUFFIX)) {
|
||||
ref = true;
|
||||
argName = argName.substring(0, argName.length() - REF_SUFFIX.length());
|
||||
}
|
||||
|
||||
ValueHolder valueHolder = new ValueHolder(ref ? new RuntimeBeanReference(argValue) : argValue);
|
||||
valueHolder.setSource(parserContext.getReaderContext().extractSource(attr));
|
||||
|
||||
// handle "escaped"/"_" arguments
|
||||
if (argName.startsWith(DELIMITER_PREFIX)) {
|
||||
String arg = argName.substring(1).trim();
|
||||
|
||||
// fast default check
|
||||
if (!StringUtils.hasText(arg)) {
|
||||
cvs.addGenericArgumentValue(valueHolder);
|
||||
}
|
||||
// assume an index otherwise
|
||||
else {
|
||||
int index = -1;
|
||||
try {
|
||||
index = Integer.parseInt(arg);
|
||||
} catch (NumberFormatException ex) {
|
||||
parserContext.getReaderContext().error(
|
||||
"Constructor argument '" + argName + "' specifies an invalid integer", attr);
|
||||
}
|
||||
if (index < 0) {
|
||||
parserContext.getReaderContext().error(
|
||||
"Constructor argument '" + argName + "' specifies a negative index", attr);
|
||||
}
|
||||
|
||||
if (cvs.hasIndexedArgumentValue(index)){
|
||||
parserContext.getReaderContext().error(
|
||||
"Constructor argument '" + argName + "' with index "+ index+" already defined using <constructor-arg>." +
|
||||
" Only one approach may be used per argument.", attr);
|
||||
}
|
||||
|
||||
cvs.addIndexedArgumentValue(index, valueHolder);
|
||||
}
|
||||
}
|
||||
// no escaping -> ctr name
|
||||
else {
|
||||
String name = Conventions.attributeNameToPropertyName(argName);
|
||||
if (containsArgWithName(name, cvs)){
|
||||
parserContext.getReaderContext().error(
|
||||
"Constructor argument '" + argName + "' already defined using <constructor-arg>." +
|
||||
" Only one approach may be used per argument.", attr);
|
||||
}
|
||||
valueHolder.setName(Conventions.attributeNameToPropertyName(argName));
|
||||
cvs.addGenericArgumentValue(valueHolder);
|
||||
}
|
||||
}
|
||||
return definition;
|
||||
}
|
||||
|
||||
private boolean containsArgWithName(String name, ConstructorArgumentValues cvs) {
|
||||
if (!checkName(name, cvs.getGenericArgumentValues())) {
|
||||
return checkName(name, cvs.getIndexedArgumentValues().values());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkName(String name, Collection<ValueHolder> values) {
|
||||
for (ValueHolder holder : values) {
|
||||
if (name.equals(holder.getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+4
-5
@@ -65,6 +65,7 @@ import org.springframework.util.xml.XmlValidationModeDetector;
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Rob Harrop
|
||||
* @author Chris Beams
|
||||
* @since 26.11.2003
|
||||
* @see #setDocumentReaderClass
|
||||
* @see BeanDefinitionDocumentReader
|
||||
@@ -103,7 +104,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader {
|
||||
|
||||
private boolean namespaceAware = false;
|
||||
|
||||
private Class documentReaderClass = DefaultBeanDefinitionDocumentReader.class;
|
||||
private Class<?> documentReaderClass = DefaultBeanDefinitionDocumentReader.class;
|
||||
|
||||
private ProblemReporter problemReporter = new FailFastProblemReporter();
|
||||
|
||||
@@ -134,7 +135,6 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader {
|
||||
super(registry);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set whether to use XML validation. Default is <code>true</code>.
|
||||
* <p>This method switches namespace awareness on if validation is turned off,
|
||||
@@ -283,7 +283,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader {
|
||||
* <p>The default is {@link DefaultBeanDefinitionDocumentReader}.
|
||||
* @param documentReaderClass the desired BeanDefinitionDocumentReader implementation class
|
||||
*/
|
||||
public void setDocumentReaderClass(Class documentReaderClass) {
|
||||
public void setDocumentReaderClass(Class<?> documentReaderClass) {
|
||||
if (documentReaderClass == null || !BeanDefinitionDocumentReader.class.isAssignableFrom(documentReaderClass)) {
|
||||
throw new IllegalArgumentException(
|
||||
"documentReaderClass must be an implementation of the BeanDefinitionDocumentReader interface");
|
||||
@@ -487,8 +487,8 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader {
|
||||
* @see BeanDefinitionDocumentReader#registerBeanDefinitions
|
||||
*/
|
||||
public int registerBeanDefinitions(Document doc, Resource resource) throws BeanDefinitionStoreException {
|
||||
// Read document based on new BeanDefinitionDocumentReader SPI.
|
||||
BeanDefinitionDocumentReader documentReader = createBeanDefinitionDocumentReader();
|
||||
documentReader.setEnvironment(this.getEnvironment());
|
||||
int countBefore = getRegistry().getBeanDefinitionCount();
|
||||
documentReader.registerBeanDefinitions(doc, createReaderContext(resource));
|
||||
return getRegistry().getBeanDefinitionCount() - countBefore;
|
||||
@@ -500,7 +500,6 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader {
|
||||
* <p>The default implementation instantiates the specified "documentReaderClass".
|
||||
* @see #setDocumentReaderClass
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected BeanDefinitionDocumentReader createBeanDefinitionDocumentReader() {
|
||||
return BeanDefinitionDocumentReader.class.cast(BeanUtils.instantiateClass(this.documentReaderClass));
|
||||
}
|
||||
|
||||
+7
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
* Copyright 2002-2011 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,8 @@ import org.springframework.core.io.Resource;
|
||||
* <p>This class registers each bean definition with the {@link DefaultListableBeanFactory}
|
||||
* superclass, and relies on the latter's implementation of the {@link BeanFactory} interface.
|
||||
* It supports singletons, prototypes, and references to either of these kinds of bean.
|
||||
* See "spring-beans-2.0.dtd" for details on options and configuration style.
|
||||
* See {@code "spring-beans-3.x.xsd"} (or historically, {@code "spring-beans-2.0.dtd"}) for
|
||||
* details on options and configuration style.
|
||||
*
|
||||
* <p><b>For advanced needs, consider using a {@link DefaultListableBeanFactory} with
|
||||
* an {@link XmlBeanDefinitionReader}.</b> The latter allows for reading from multiple XML
|
||||
@@ -42,10 +43,14 @@ import org.springframework.core.io.Resource;
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
* @since 15 April 2001
|
||||
* @see org.springframework.beans.factory.support.DefaultListableBeanFactory
|
||||
* @see XmlBeanDefinitionReader
|
||||
* @deprecated as of Spring 3.1 in favor of {@link DefaultListableBeanFactory} and
|
||||
* {@link XmlBeanDefinitionReader}
|
||||
*/
|
||||
@Deprecated
|
||||
public class XmlBeanFactory extends DefaultListableBeanFactory {
|
||||
|
||||
private final XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this);
|
||||
|
||||
+5
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2011 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.
|
||||
@@ -77,7 +77,10 @@ public class CustomDateEditor extends PropertyEditorSupport {
|
||||
* thrown if the String does not exactly match the length specified. This is useful
|
||||
* because SimpleDateFormat does not enforce strict parsing of the year part,
|
||||
* not even with <code>setLenient(false)</code>. Without an "exactDateLength"
|
||||
* specified, the "01/01/05" would get parsed to "01/01/0005".
|
||||
* specified, the "01/01/05" would get parsed to "01/01/0005". However, even
|
||||
* with an "exactDateLength" specified, prepended zeros in the day or month
|
||||
* part may still allow for a shorter year part, so consider this as just
|
||||
* one more assertion that gets you closer to the intended date format.
|
||||
* @param dateFormat DateFormat to use for parsing and rendering
|
||||
* @param allowEmpty if empty strings should be allowed
|
||||
* @param exactDateLength the exact expected length of the date String
|
||||
|
||||
+4
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2011 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,7 +46,7 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class CustomNumberEditor extends PropertyEditorSupport {
|
||||
|
||||
private final Class numberClass;
|
||||
private final Class<? extends Number> numberClass;
|
||||
|
||||
private final NumberFormat numberFormat;
|
||||
|
||||
@@ -67,7 +67,7 @@ public class CustomNumberEditor extends PropertyEditorSupport {
|
||||
* @see Integer#valueOf
|
||||
* @see Integer#toString
|
||||
*/
|
||||
public CustomNumberEditor(Class numberClass, boolean allowEmpty) throws IllegalArgumentException {
|
||||
public CustomNumberEditor(Class<? extends Number> numberClass, boolean allowEmpty) throws IllegalArgumentException {
|
||||
this(numberClass, null, allowEmpty);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class CustomNumberEditor extends PropertyEditorSupport {
|
||||
* @see java.text.NumberFormat#parse
|
||||
* @see java.text.NumberFormat#format
|
||||
*/
|
||||
public CustomNumberEditor(Class numberClass, NumberFormat numberFormat, boolean allowEmpty)
|
||||
public CustomNumberEditor(Class<? extends Number> numberClass, NumberFormat numberFormat, boolean allowEmpty)
|
||||
throws IllegalArgumentException {
|
||||
|
||||
if (numberClass == null || !Number.class.isAssignableFrom(numberClass)) {
|
||||
@@ -101,7 +101,6 @@ public class CustomNumberEditor extends PropertyEditorSupport {
|
||||
* Parse the Number from the given text, using the specified NumberFormat.
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
if (this.allowEmpty && !StringUtils.hasText(text)) {
|
||||
// Treat empty String as null value.
|
||||
@@ -121,7 +120,6 @@ public class CustomNumberEditor extends PropertyEditorSupport {
|
||||
* Coerce a Number value into the required target class, if necessary.
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setValue(Object value) {
|
||||
if (value instanceof Number) {
|
||||
super.setValue(NumberUtils.convertNumberToTargetClass((Number) value, this.numberClass));
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,8 +24,8 @@ import org.springframework.util.StringUtils;
|
||||
/**
|
||||
* Custom {@link java.beans.PropertyEditor} for String arrays.
|
||||
*
|
||||
* <p>Strings must be in CSV format, with a customizable separator. By default values in the result are trimmed
|
||||
* of whitespace.
|
||||
* <p>Strings must be in CSV format, with a customizable separator.
|
||||
* By default values in the result are trimmed of whitespace.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,7 +24,7 @@ import org.springframework.util.StringUtils;
|
||||
* Property editor that trims Strings.
|
||||
*
|
||||
* <p>Optionally allows transforming an empty string into a <code>null</code> value.
|
||||
* Needs to be explictly registered, e.g. for command binding.
|
||||
* Needs to be explicitly registered, e.g. for command binding.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @see org.springframework.validation.DataBinder#registerCustomEditor
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* <p>By default, this editor will encode Strings into URIs. For instance,
|
||||
* a space will be encoded into {@code %20}. This behavior can be changed
|
||||
* by setting calling the {@link #URIEditor(boolean)} constructor.
|
||||
* by calling the {@link #URIEditor(boolean)} constructor.
|
||||
*
|
||||
* <p>Note: A URI is more relaxed than a URL in that it does not require
|
||||
* a valid protocol to be specified. Any scheme within a valid URI syntax
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user