Compare commits
1507 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7f64abc21 | ||
|
|
800da01c72 | ||
|
|
6ade0fdb77 | ||
|
|
08e79dfde2 | ||
|
|
fa982b33cc | ||
|
|
84ac030c42 | ||
|
|
bfb0848fa2 | ||
|
|
7a76256317 | ||
|
|
f700743134 | ||
|
|
6401c74f10 | ||
|
|
65b4e66677 | ||
|
|
243bd95b44 | ||
|
|
b40f167867 | ||
|
|
550f955678 | ||
|
|
39b1ea3e4e | ||
|
|
da25cd531f | ||
|
|
3876f149fd | ||
|
|
151b09ce0b | ||
|
|
9d691e50f7 | ||
|
|
0895c82525 | ||
|
|
e6d4b26c9d | ||
|
|
39f743b47d | ||
|
|
f33ac5f88a | ||
|
|
edfc7b9190 | ||
|
|
c43d151d4d | ||
|
|
f3f84bd5b3 | ||
|
|
8f257761fd | ||
|
|
020d9c853d | ||
|
|
da88762f99 | ||
|
|
60a47d33c4 | ||
|
|
ec17eea1e0 | ||
|
|
29ea1eb76b | ||
|
|
9c7ece9282 | ||
|
|
2c0dbeaa15 | ||
|
|
377799f19a | ||
|
|
7e85fc134b | ||
|
|
95e207fd34 | ||
|
|
3a7a462f65 | ||
|
|
f8b8429044 | ||
|
|
f9744b8480 | ||
|
|
4695d787c5 | ||
|
|
1d9f385da9 | ||
|
|
72fe0dc2ba | ||
|
|
5fbe56bfc1 | ||
|
|
e2a3560661 | ||
|
|
c524e15267 | ||
|
|
5da88a7916 | ||
|
|
7c9c3822e0 | ||
|
|
1d6b1a3a30 | ||
|
|
aec47a7a9a | ||
|
|
754c9f0c2b | ||
|
|
7405ce4dab | ||
|
|
59b9c695ec | ||
|
|
c2a923619e | ||
|
|
a19b083478 | ||
|
|
9cf402f18c | ||
|
|
9a085536fb | ||
|
|
e82f7e39b0 | ||
|
|
fa8ca1fb38 | ||
|
|
fd5225ab37 | ||
|
|
c0960b21f1 | ||
|
|
062f9a09db | ||
|
|
264cc3995b | ||
|
|
173a5c8a24 | ||
|
|
1491f6be70 | ||
|
|
cc760ff327 | ||
|
|
2c47e5db30 | ||
|
|
4f6ca16ca6 | ||
|
|
57686cf221 | ||
|
|
7586577521 | ||
|
|
f1ae2bd165 | ||
|
|
048c718ba2 | ||
|
|
6429cc93f8 | ||
|
|
e4bf7432f4 | ||
|
|
a989f1af9f | ||
|
|
687606282a | ||
|
|
ae7bae1b05 | ||
|
|
bea6f6fd5a | ||
|
|
50994c3f78 | ||
|
|
0d45e6c43b | ||
|
|
3e06534b63 | ||
|
|
2ec628cc7d | ||
|
|
4d17fe7e3f | ||
|
|
4e2ba22fc3 | ||
|
|
85ac8f743d | ||
|
|
f65c02677f | ||
|
|
399df22672 | ||
|
|
1cc659276b | ||
|
|
909b813573 | ||
|
|
38ec269df2 | ||
|
|
dbee6c15b0 | ||
|
|
3a532617a1 | ||
|
|
b6accc97f6 | ||
|
|
a1c4fafa47 | ||
|
|
bb611413a5 | ||
|
|
3f172824b6 | ||
|
|
acf8eb1ce0 | ||
|
|
45b0e7098b | ||
|
|
5a7181428f | ||
|
|
d5908815d9 | ||
|
|
f86f82db8d | ||
|
|
1dc07638e5 | ||
|
|
335933a0f4 | ||
|
|
8ea63c5171 | ||
|
|
ed2d9527bf | ||
|
|
dc3396daf5 | ||
|
|
72d9427426 | ||
|
|
35754cb8f5 | ||
|
|
6769389f3a | ||
|
|
1bcc35cbcf | ||
|
|
227e94b546 | ||
|
|
0d84ef0541 | ||
|
|
21c00b3419 | ||
|
|
62eb06f272 | ||
|
|
e5acbdcdee | ||
|
|
71cec55f1c | ||
|
|
76623e9c6b | ||
|
|
59ad1d8617 | ||
|
|
a542c03e8b | ||
|
|
845a1e97ff | ||
|
|
3d8c2f1fc5 | ||
|
|
77a8b8fa7f | ||
|
|
0427a76b55 | ||
|
|
ba7bbed7b1 | ||
|
|
0138e46ee5 | ||
|
|
8ca483c63e | ||
|
|
2b06bc26bf | ||
|
|
1db55185d7 | ||
|
|
d6a90f23a5 | ||
|
|
c8cd1e23ef | ||
|
|
34fef28ed6 | ||
|
|
d20d20f46a | ||
|
|
acdd626d4f | ||
|
|
f3a0e7a1a8 | ||
|
|
545a0c5473 | ||
|
|
4eb34ba7d9 | ||
|
|
7bab2742a5 | ||
|
|
154fd08183 | ||
|
|
07eb1386de | ||
|
|
162401ee19 | ||
|
|
a0a12bc709 | ||
|
|
d2b8ef4471 | ||
|
|
a2ac9ff896 | ||
|
|
04e539ab0f | ||
|
|
2f5f96290f | ||
|
|
198a3575f8 | ||
|
|
69fa2c9156 | ||
|
|
37cc5dd080 | ||
|
|
a3cbc19de9 | ||
|
|
b56feefd8a | ||
|
|
96ac0d8715 | ||
|
|
b5c381d992 | ||
|
|
aaa719214d | ||
|
|
5c5bce467f | ||
|
|
b7a604ebee | ||
|
|
88417f35a4 | ||
|
|
8e981e1b7e | ||
|
|
67aa3c0609 | ||
|
|
4e71f8009a | ||
|
|
692f0fa8b1 | ||
|
|
cd15a1a586 | ||
|
|
e8a53d6b24 | ||
|
|
00c22d4a72 | ||
|
|
bb92e4541a | ||
|
|
e7f05c31e0 | ||
|
|
306dbabc7d | ||
|
|
f18ffb7940 | ||
|
|
850ff211ca | ||
|
|
40000ae026 | ||
|
|
dad7d38202 | ||
|
|
8cf8a2c037 | ||
|
|
c847b349a2 | ||
|
|
4070945270 | ||
|
|
b40f975c14 | ||
|
|
fbe2a01519 | ||
|
|
0b10009d5e | ||
|
|
b724ce1a0c | ||
|
|
ab2773ba86 | ||
|
|
bc4b3ab17f | ||
|
|
f42ff13824 | ||
|
|
b736cbafc6 | ||
|
|
090bfb5629 | ||
|
|
73eb306eb2 | ||
|
|
71cfd9e1cd | ||
|
|
1dec372d18 | ||
|
|
7536744d93 | ||
|
|
b50a28132b | ||
|
|
c804cb8c1c | ||
|
|
fd5b63f58c | ||
|
|
7229fb90de | ||
|
|
81c7c162bb | ||
|
|
20b4080f40 | ||
|
|
4f9805b254 | ||
|
|
d245f134b7 | ||
|
|
84177f43f4 | ||
|
|
438ce904ab | ||
|
|
de5114a480 | ||
|
|
a0472438c8 | ||
|
|
a3e660ff63 | ||
|
|
271f6d1e03 | ||
|
|
2ad4dce50e | ||
|
|
78ba874dbf | ||
|
|
4028c9a465 | ||
|
|
1d4a1d4b66 | ||
|
|
23eaff080b | ||
|
|
bc55d24e08 | ||
|
|
c50cb855d1 | ||
|
|
cf638997f6 | ||
|
|
a42e3cd63c | ||
|
|
b58b630be0 | ||
|
|
aa4c592d9e | ||
|
|
133c280dc2 | ||
|
|
3e23c9143a | ||
|
|
3ce56c08df | ||
|
|
ee29eb98a0 | ||
|
|
1d453b7883 | ||
|
|
f0fae107ba | ||
|
|
242f668aa6 | ||
|
|
97e732e9e3 | ||
|
|
5f6a8c5a12 | ||
|
|
6aa4e87b35 | ||
|
|
c098674ab8 | ||
|
|
7b03a9fffe | ||
|
|
9235cd035a | ||
|
|
6162e71d29 | ||
|
|
a060075d08 | ||
|
|
5474cd846d | ||
|
|
f207999117 | ||
|
|
f51a52e895 | ||
|
|
82d375b517 | ||
|
|
8ad28e8932 | ||
|
|
5f2abc725b | ||
|
|
f4c4bfda70 | ||
|
|
2cf74bedca | ||
|
|
3646e0ab15 | ||
|
|
a79c4303aa | ||
|
|
79e63fa7ad | ||
|
|
10842830dc | ||
|
|
016ee632c1 | ||
|
|
5015834d69 | ||
|
|
58d3f5101c | ||
|
|
f2992a76fa | ||
|
|
8cc83af502 | ||
|
|
64f6ac55e7 | ||
|
|
a7cddab9fb | ||
|
|
1cfc17766a | ||
|
|
c8ba21dac2 | ||
|
|
fe293c6f25 | ||
|
|
6dca528381 | ||
|
|
fcff5ccf7e | ||
|
|
a65f4318f5 | ||
|
|
cc5a3106aa | ||
|
|
c4a02e05e1 | ||
|
|
67312e3a7e | ||
|
|
767f689351 | ||
|
|
334c4920d9 | ||
|
|
0c1f605dbb | ||
|
|
c0ea28cf9c | ||
|
|
28aa2285f5 | ||
|
|
a757504877 | ||
|
|
aa3a00a40f | ||
|
|
1035052f02 | ||
|
|
c370c885e6 | ||
|
|
2c39167025 | ||
|
|
ff1d392196 | ||
|
|
20518259aa | ||
|
|
5aa3e61686 | ||
|
|
12a39ac405 | ||
|
|
2a8bda69e5 | ||
|
|
ebf498edf8 | ||
|
|
357d8b3d11 | ||
|
|
91eee09e2f | ||
|
|
2b18310050 | ||
|
|
61586beb45 | ||
|
|
eced5e522e | ||
|
|
352dc9038f | ||
|
|
9c4aeda85c | ||
|
|
ac8d146c98 | ||
|
|
98021cb87f | ||
|
|
588e1eca90 | ||
|
|
d5c3841198 | ||
|
|
da8ee3a6d7 | ||
|
|
672b5a7cf5 | ||
|
|
3ca986e5a5 | ||
|
|
8c448da19a | ||
|
|
2f37dd9c03 | ||
|
|
9da964657d | ||
|
|
50c10f31fa | ||
|
|
9cb4889a9c | ||
|
|
426e8e463a | ||
|
|
2c25cc9f27 | ||
|
|
ea01415b5f | ||
|
|
21b9239c8d | ||
|
|
aab8a631f0 | ||
|
|
2506405d8c | ||
|
|
3cda0c4dd9 | ||
|
|
8ca6f46c4a | ||
|
|
ec7f54809f | ||
|
|
cfcb11ae61 | ||
|
|
01c8aca36a | ||
|
|
4c6403a4ca | ||
|
|
1d3049b743 | ||
|
|
932bf729b0 | ||
|
|
48007b141b | ||
|
|
5ddf730c7d | ||
|
|
6fb70c3945 | ||
|
|
cce667e019 | ||
|
|
6a72fecbb1 | ||
|
|
4328eb7770 | ||
|
|
a33f5dcd6f | ||
|
|
21cb0e191e | ||
|
|
f6d20a6324 | ||
|
|
254ab9a25a | ||
|
|
b48182f7cc | ||
|
|
4adf23e57c | ||
|
|
95fff255cf | ||
|
|
05d2a5aa8c | ||
|
|
ff70491e55 | ||
|
|
43d739638d | ||
|
|
2c65bb5996 | ||
|
|
74823fe2fe | ||
|
|
9137aed8db | ||
|
|
6f9d851965 | ||
|
|
cd415699b7 | ||
|
|
9402db9fd5 | ||
|
|
96e9d897ec | ||
|
|
5384e9ab96 | ||
|
|
cf65c780c8 | ||
|
|
e1a88ef5d9 | ||
|
|
86ea5f8cb9 | ||
|
|
db0b81b4a0 | ||
|
|
e7ed4ae9bc | ||
|
|
60b4425a47 | ||
|
|
742a0fde42 | ||
|
|
b1d87f4d66 | ||
|
|
5a2dbc4e67 | ||
|
|
6edf8b58fc | ||
|
|
dd0debd51e | ||
|
|
c520910d5c | ||
|
|
8c0b9a0f6a | ||
|
|
4876191e7a | ||
|
|
5168dd59ce | ||
|
|
09d710b928 | ||
|
|
d3580668b6 | ||
|
|
0c9576603d | ||
|
|
f10ade8795 | ||
|
|
483244bda2 | ||
|
|
d69412b1f8 | ||
|
|
66806d60a5 | ||
|
|
9d169c568b | ||
|
|
3acf6a40ad | ||
|
|
3158f9265f | ||
|
|
df8fd31e75 | ||
|
|
44bb9ac086 | ||
|
|
cb9b57a04c | ||
|
|
f694b617cf | ||
|
|
f19e2a916e | ||
|
|
a51141d497 | ||
|
|
aee5745172 | ||
|
|
cebd463d58 | ||
|
|
45548f2de9 | ||
|
|
6ad3ba192b | ||
|
|
f8fbabaef9 | ||
|
|
328d2c432e | ||
|
|
f871c36080 | ||
|
|
33c579f14f | ||
|
|
aa47820ee7 | ||
|
|
b6659ea15e | ||
|
|
cca73a5045 | ||
|
|
c6fa2a688c | ||
|
|
2733cbcc62 | ||
|
|
f1f8f653e4 | ||
|
|
d6cd97c798 | ||
|
|
61a9e88cd0 | ||
|
|
c357373310 | ||
|
|
15cd481713 | ||
|
|
7bbf05af21 | ||
|
|
20d400178b | ||
|
|
8fde50fabf | ||
|
|
69c2baae51 | ||
|
|
9b48e85b26 | ||
|
|
913a055e7e | ||
|
|
ff76c698f4 | ||
|
|
8136345484 | ||
|
|
def85ca1ac | ||
|
|
f9d762534d | ||
|
|
68af3c7495 | ||
|
|
da17758614 | ||
|
|
76761acb9b | ||
|
|
c05be6d4f8 | ||
|
|
978afdd829 | ||
|
|
38e8da994e | ||
|
|
c99cf9d0d9 | ||
|
|
52cf34ba29 | ||
|
|
ca06085dfb | ||
|
|
9ddd8472b1 | ||
|
|
4411a32522 | ||
|
|
892e09cb53 | ||
|
|
01439d0779 | ||
|
|
f1fe2ac81b | ||
|
|
c5de588fd3 | ||
|
|
1e5442a1b9 | ||
|
|
0ccddc04c0 | ||
|
|
fd4aa227d3 | ||
|
|
7d841e938c | ||
|
|
a47f73cf10 | ||
|
|
9acb7a5290 | ||
|
|
15a501b2cd | ||
|
|
0f110fca33 | ||
|
|
3060b99a89 | ||
|
|
53f1d6dded | ||
|
|
145dcdf1d3 | ||
|
|
a676dca6b4 | ||
|
|
7c28f2c54d | ||
|
|
a1645e8b46 | ||
|
|
52c120e5ac | ||
|
|
5913c515b9 | ||
|
|
b89bc452e6 | ||
|
|
ff1bba7679 | ||
|
|
da6855193b | ||
|
|
7d2903b1a8 | ||
|
|
a6ae2ec816 | ||
|
|
c23055a7d3 | ||
|
|
2ee9dcfeb2 | ||
|
|
4478c521e6 | ||
|
|
36fb3391cc | ||
|
|
74b91ac5b0 | ||
|
|
ca7c0d47b0 | ||
|
|
6bcb1de304 | ||
|
|
bbf72bb27b | ||
|
|
f62b276033 | ||
|
|
f9339229bc | ||
|
|
c60c96a672 | ||
|
|
0ff3d3133b | ||
|
|
5e5577e685 | ||
|
|
1a4e2986ad | ||
|
|
90097909ce | ||
|
|
ba25120dea | ||
|
|
1c07fcc6fa | ||
|
|
f0bc867220 | ||
|
|
4ee64ed1ef | ||
|
|
02202e3d06 | ||
|
|
43012a5399 | ||
|
|
2e8c183c3a | ||
|
|
9fefe9d19e | ||
|
|
f3896483ad | ||
|
|
a358e5bf01 | ||
|
|
071f1f35b7 | ||
|
|
07d2ca87b9 | ||
|
|
5a8557bf63 | ||
|
|
698e6c6ee7 | ||
|
|
f3f5f53535 | ||
|
|
00e0a820c7 | ||
|
|
7d84c0ca1f | ||
|
|
c1992434d0 | ||
|
|
0c61ffbe19 | ||
|
|
81c6543650 | ||
|
|
31cd2163e5 | ||
|
|
9668623b25 | ||
|
|
e733980e33 | ||
|
|
e9645e6b05 | ||
|
|
19041335b4 | ||
|
|
3819e42593 | ||
|
|
897eb97d46 | ||
|
|
9b22fc3f5d | ||
|
|
91a353900a | ||
|
|
fb82801bda | ||
|
|
d8c13c8420 | ||
|
|
bea1900fdc | ||
|
|
439d702e97 | ||
|
|
e67720f066 | ||
|
|
90dab3a4c6 | ||
|
|
a49e340622 | ||
|
|
d7ca6bdc6e | ||
|
|
2355bb2796 | ||
|
|
02013be08a | ||
|
|
7f7c4c857e | ||
|
|
09e00c02b9 | ||
|
|
1b41b6e568 | ||
|
|
2665ebf52b | ||
|
|
da807e5b8e | ||
|
|
4d3a94ca17 | ||
|
|
b37cdc2c6d | ||
|
|
41c293ed1f | ||
|
|
5cdde0eeaa | ||
|
|
3e0bfc581c | ||
|
|
9463887112 | ||
|
|
7e77183dad | ||
|
|
9fe7069eed | ||
|
|
ffd0ccdf21 | ||
|
|
30df2c5b07 | ||
|
|
db40973bea | ||
|
|
a641485921 | ||
|
|
7b571f630c | ||
|
|
931b3f57a1 | ||
|
|
080b3a77f3 | ||
|
|
d56b9b7ac9 | ||
|
|
244909db85 | ||
|
|
98571c3779 | ||
|
|
32234cd1dd | ||
|
|
4608c34dc8 | ||
|
|
fb4bbb1ce5 | ||
|
|
5fe760c40b | ||
|
|
80b0feb611 | ||
|
|
825fad4109 | ||
|
|
1226f0bd21 | ||
|
|
3a837e4cf3 | ||
|
|
8ea2415586 | ||
|
|
14f4c81e75 | ||
|
|
20f9ad40d3 | ||
|
|
1cd58f4a01 | ||
|
|
e98cdd4028 | ||
|
|
26308abc70 | ||
|
|
635e7111cf | ||
|
|
54a8822bf8 | ||
|
|
b3514773ad | ||
|
|
c85188b026 | ||
|
|
220dff2802 | ||
|
|
8cab0c78df | ||
|
|
30236f9bbc | ||
|
|
641efad649 | ||
|
|
b5b8e5b59b | ||
|
|
f556d9fe29 | ||
|
|
c94be39f02 | ||
|
|
ec9a0bbaf0 | ||
|
|
bf6213aca1 | ||
|
|
249468c601 | ||
|
|
5f0b738264 | ||
|
|
5f9a06c1e4 | ||
|
|
5f5f246c2e | ||
|
|
c21801767f | ||
|
|
e5b7921860 | ||
|
|
54487a73c0 | ||
|
|
698591fe28 | ||
|
|
53e50bbd95 | ||
|
|
d665c89799 | ||
|
|
717fd0376b | ||
|
|
17889c2b33 | ||
|
|
284785841a | ||
|
|
54e8ab3b7e | ||
|
|
09304c198c | ||
|
|
2209d6147e | ||
|
|
faea36a92b | ||
|
|
e9005637af | ||
|
|
65413baccd | ||
|
|
0ce73064f5 | ||
|
|
6632846f10 | ||
|
|
3cff00b5b8 | ||
|
|
f5479e13db | ||
|
|
6cc6056e37 | ||
|
|
a70cc585a9 | ||
|
|
626c2452d8 | ||
|
|
d27657b113 | ||
|
|
36fd26264e | ||
|
|
51656cbaa1 | ||
|
|
dc8ec75ada | ||
|
|
58685dacb2 | ||
|
|
10f9f57218 | ||
|
|
bb14060517 | ||
|
|
a77180a0ba | ||
|
|
d47ecacf1f | ||
|
|
5813e99f0c | ||
|
|
38b3bec2a8 | ||
|
|
27bfda94a0 | ||
|
|
cbb224046c | ||
|
|
053cda1017 | ||
|
|
5079560037 | ||
|
|
4d1eaa9766 | ||
|
|
41e6b5da7d | ||
|
|
bcf74fbe71 | ||
|
|
f189803bb7 | ||
|
|
56c460e6c3 | ||
|
|
db048652cc | ||
|
|
f71e824539 | ||
|
|
dbc5ff378a | ||
|
|
7f05b61ad9 | ||
|
|
8147001f3f | ||
|
|
325639a49c | ||
|
|
38e31df6d7 | ||
|
|
5722b25429 | ||
|
|
74421024ea | ||
|
|
6cea220256 | ||
|
|
3a4e41c531 | ||
|
|
9cbb706302 | ||
|
|
ecc53303d1 | ||
|
|
aeeb7a3c72 | ||
|
|
7230be701e | ||
|
|
b5e7111e78 | ||
|
|
05dd539f4f | ||
|
|
b51259cb91 | ||
|
|
4227a8a080 | ||
|
|
b4ded6f746 | ||
|
|
4f008796d7 | ||
|
|
46e5130e08 | ||
|
|
0f0c4eac6e | ||
|
|
3331723aea | ||
|
|
95836a73cd | ||
|
|
04a8c6f784 | ||
|
|
665b295a96 | ||
|
|
07cdf26aaf | ||
|
|
e0aac13710 | ||
|
|
6f21745537 | ||
|
|
49405c509b | ||
|
|
94bc2a512d | ||
|
|
2b6e44015b | ||
|
|
f5c412c286 | ||
|
|
9fbce21de9 | ||
|
|
dc7a481463 | ||
|
|
dc57d62f34 | ||
|
|
cd059c02a2 | ||
|
|
5ce226edd7 | ||
|
|
54d629155b | ||
|
|
c83aa7e8a8 | ||
|
|
f725e491f0 | ||
|
|
3fdea1b1d8 | ||
|
|
75f645e9cf | ||
|
|
7bf75b69cd | ||
|
|
c94c34e6a8 | ||
|
|
258fa43bba | ||
|
|
0ef0ebabd2 | ||
|
|
4cd6d85bc1 | ||
|
|
16a1e25f42 | ||
|
|
84e4a24ff5 | ||
|
|
99a217cef6 | ||
|
|
97d517abd9 | ||
|
|
b326e6ea6f | ||
|
|
ddfdf68c83 | ||
|
|
07e9ad4a21 | ||
|
|
2d80646cc4 | ||
|
|
cd39b484f5 | ||
|
|
1c19b70ae9 | ||
|
|
257b406d73 | ||
|
|
70fe0fde1e | ||
|
|
470e636e55 | ||
|
|
436853dd03 | ||
|
|
f9994b33af | ||
|
|
47584f3106 | ||
|
|
ef985e2aef | ||
|
|
4f34f1fd2e | ||
|
|
c633d1c0e8 | ||
|
|
e347a43738 | ||
|
|
636927e4eb | ||
|
|
49f03f9701 | ||
|
|
93d7277bfe | ||
|
|
4b7b140c7b | ||
|
|
b17716780a | ||
|
|
2992250745 | ||
|
|
ef802bb1ce | ||
|
|
076c260793 | ||
|
|
7162116ae3 | ||
|
|
5ea5869897 | ||
|
|
fb2cf4e5e3 | ||
|
|
7d327e7864 | ||
|
|
ce630ee253 | ||
|
|
4de3d3f505 | ||
|
|
6c331f733b | ||
|
|
853f501ffd | ||
|
|
6b877e8136 | ||
|
|
8c5b8b0a70 | ||
|
|
a7f1ef2c3b | ||
|
|
a34bc80f19 | ||
|
|
267a17858f | ||
|
|
81340be2e1 | ||
|
|
87f46d2785 | ||
|
|
503c2c6f72 | ||
|
|
6348aa884f | ||
|
|
0435cc4e48 | ||
|
|
1e715285fa | ||
|
|
f3707a3499 | ||
|
|
552d1ac872 | ||
|
|
6078c9a686 | ||
|
|
564eadec11 | ||
|
|
d6b9df4109 | ||
|
|
95539580a7 | ||
|
|
34a03b0e26 | ||
|
|
cad219d7e1 | ||
|
|
4a383a9dc1 | ||
|
|
5ee14bc859 | ||
|
|
e6f22a1f18 | ||
|
|
fe6a5dd91c | ||
|
|
263aa86211 | ||
|
|
718dfc6fd1 | ||
|
|
372f96b3a9 | ||
|
|
af3079377f | ||
|
|
62042d3aaa | ||
|
|
ce94610a72 | ||
|
|
7648f0cdc8 | ||
|
|
a4f8519bcf | ||
|
|
6cade6a1da | ||
|
|
fc420221cf | ||
|
|
be202cef6a | ||
|
|
06a1d5d1bb | ||
|
|
79a310181c | ||
|
|
46d2629fca | ||
|
|
83dd4da4ec | ||
|
|
fb321c58a7 | ||
|
|
0840f04847 | ||
|
|
8a19914a07 | ||
|
|
dc1dc42bef | ||
|
|
9c64cde003 | ||
|
|
1d80041c16 | ||
|
|
fb9bdd22c4 | ||
|
|
f552c657b6 | ||
|
|
0c10e928fc | ||
|
|
58bd2b08a4 | ||
|
|
fd3e33d836 | ||
|
|
cac8da9b4d | ||
|
|
c57a32143b | ||
|
|
6db029263c | ||
|
|
498b2ff70f | ||
|
|
710f8fc632 | ||
|
|
0c18e29aaf | ||
|
|
08f679c422 | ||
|
|
0578fa3ca5 | ||
|
|
7ef195f49e | ||
|
|
a5fc08a821 | ||
|
|
88392fd5dd | ||
|
|
ae03bdecad | ||
|
|
240b2b226b | ||
|
|
b52090d1f2 | ||
|
|
7664edb9a1 | ||
|
|
5a156467d7 | ||
|
|
5951b1b9cb | ||
|
|
29bf353e40 | ||
|
|
69014e83c5 | ||
|
|
25881ff06a | ||
|
|
d6e82eb8c1 | ||
|
|
2cc67af409 | ||
|
|
88c20f798f | ||
|
|
ce36250e60 | ||
|
|
ec26e3c9f7 | ||
|
|
cfbf4bbe85 | ||
|
|
95b08e1db0 | ||
|
|
382ad87c5f | ||
|
|
bbddb31752 | ||
|
|
81da17ddd4 | ||
|
|
e5a3c4c102 | ||
|
|
63c3326265 | ||
|
|
cda78cfc7d | ||
|
|
f9ec08adea | ||
|
|
50607df3ef | ||
|
|
00ead74204 | ||
|
|
3fba0a3eeb | ||
|
|
ebaf4ebe16 | ||
|
|
ff7ed50e82 | ||
|
|
0c1e34c2cc | ||
|
|
5d9bd3018a | ||
|
|
ef5349098d | ||
|
|
4ddf2dbe86 | ||
|
|
7a37df319c | ||
|
|
e8eea11ca6 | ||
|
|
8e413db8d1 | ||
|
|
ec48417e20 | ||
|
|
9942a194a6 | ||
|
|
70aac955c6 | ||
|
|
24a043195a | ||
|
|
d3a6f46c6c | ||
|
|
1a49db8a1b | ||
|
|
d971fe94ee | ||
|
|
fc228964fd | ||
|
|
7e45b458e9 | ||
|
|
eb7c44de18 | ||
|
|
6cb0a05720 | ||
|
|
387f1688f4 | ||
|
|
eec8939461 | ||
|
|
feb063a4ed | ||
|
|
56d0ad2711 | ||
|
|
9b641edc11 | ||
|
|
398b7b76a5 | ||
|
|
a357c9f20e | ||
|
|
680a12d83b | ||
|
|
9df80032a7 | ||
|
|
8ef27add1c | ||
|
|
8ab6b6e955 | ||
|
|
08d667d4d1 | ||
|
|
8698d12d1f | ||
|
|
618a42c5df | ||
|
|
f7e3f7d7ec | ||
|
|
a2f6578503 | ||
|
|
53f029052b | ||
|
|
ce5125db9c | ||
|
|
d6b9402ce0 | ||
|
|
8780365e17 | ||
|
|
c008dfdfd7 | ||
|
|
2ee787f08b | ||
|
|
71a7e7e7f6 | ||
|
|
bd088ab9ec | ||
|
|
8e51f99c7a | ||
|
|
d589eef853 | ||
|
|
5b6c978620 | ||
|
|
7dc6dc6a6d | ||
|
|
23cfbf6f1e | ||
|
|
d06406c200 | ||
|
|
6d9f2ec6be | ||
|
|
c2f66b61ec | ||
|
|
86cfeafd8d | ||
|
|
e7a7461d9d | ||
|
|
6615326edb | ||
|
|
64c3a2c4bd | ||
|
|
8f6098834f | ||
|
|
e204b60ac4 | ||
|
|
0177599442 | ||
|
|
9f0a2b99b7 | ||
|
|
42a1229f1f | ||
|
|
cdcc42c90a | ||
|
|
875d335cc9 | ||
|
|
989153815f | ||
|
|
b3ea041b67 | ||
|
|
54f9b68b3d | ||
|
|
a0da13bc4f | ||
|
|
dbd4a79589 | ||
|
|
158ff3b961 | ||
|
|
c62b55fea4 | ||
|
|
aeafac22b0 | ||
|
|
225460f522 | ||
|
|
7522e79f7d | ||
|
|
ed8719c27b | ||
|
|
31c6ffdd17 | ||
|
|
0085493b3f | ||
|
|
c234663f87 | ||
|
|
061fecf7b4 | ||
|
|
609242bce8 | ||
|
|
916f0eb793 | ||
|
|
9dff5967fb | ||
|
|
c25001c5e4 | ||
|
|
f0e53d4a8e | ||
|
|
a4b277e875 | ||
|
|
ba788eec9c | ||
|
|
fa575da721 | ||
|
|
ad58cb76aa | ||
|
|
b574313e61 | ||
|
|
c3862297b1 | ||
|
|
e192d37bf0 | ||
|
|
252a45fbb4 | ||
|
|
90e813a06c | ||
|
|
0a93ccb818 | ||
|
|
05e3046af8 | ||
|
|
0bb91186a8 | ||
|
|
7433530998 | ||
|
|
aefd10c029 | ||
|
|
b1b58da3ec | ||
|
|
5be0cb5d2e | ||
|
|
19d2bab0d1 | ||
|
|
aecbf0fb26 | ||
|
|
4a8c3a58f7 | ||
|
|
2223845ab3 | ||
|
|
753d8b020a | ||
|
|
ae91e47a73 | ||
|
|
930f0781b8 | ||
|
|
8f913dff0b | ||
|
|
c82f454e42 | ||
|
|
1ee5d79866 | ||
|
|
02b24953ea | ||
|
|
b29dedbb79 | ||
|
|
36c68df5ff | ||
|
|
ea13e89146 | ||
|
|
044e6c8b7a | ||
|
|
b256db65d4 | ||
|
|
e44afc9208 | ||
|
|
af45c451a3 | ||
|
|
ea91894cec | ||
|
|
c9386a445b | ||
|
|
73411593b2 | ||
|
|
d1a318f8ed | ||
|
|
cfcc229000 | ||
|
|
5e25bc623c | ||
|
|
cb2abab70c | ||
|
|
fdfa70c765 | ||
|
|
2f80bbf379 | ||
|
|
0391304024 | ||
|
|
03152e4e6a | ||
|
|
553622cfec | ||
|
|
3eb357055f | ||
|
|
25398327c7 | ||
|
|
700ef231df | ||
|
|
b5a21838d2 | ||
|
|
602647891c | ||
|
|
ff4c34fe33 | ||
|
|
7f8d6f96f1 | ||
|
|
8cbdcca40f | ||
|
|
c065f693a9 | ||
|
|
d78f2df9a8 | ||
|
|
ce164d3047 | ||
|
|
bd9b04ce0b | ||
|
|
2304e115da | ||
|
|
073568d6ac | ||
|
|
8ed6d18190 | ||
|
|
f04d55adab | ||
|
|
960e4ff358 | ||
|
|
b3c1b156ee | ||
|
|
9dd3128a65 | ||
|
|
cb3cb00e2b | ||
|
|
da81509157 | ||
|
|
48a4c60737 | ||
|
|
2019c0ce3c | ||
|
|
09596e9b4b | ||
|
|
482a3313c4 | ||
|
|
fa8225fb1b | ||
|
|
ca93aceafc | ||
|
|
3d8dcc0026 | ||
|
|
8cba160af8 | ||
|
|
d743d7e90d | ||
|
|
cde5b80c2d | ||
|
|
3b5010c0a7 | ||
|
|
cc6624bfdc | ||
|
|
0e30db3463 | ||
|
|
bda65b483e | ||
|
|
2155c58989 | ||
|
|
c3928fdc2b | ||
|
|
8c625e93c7 | ||
|
|
c4b91ebbc6 | ||
|
|
6d63798ccf | ||
|
|
a32586bf3b | ||
|
|
b1f91d3b8a | ||
|
|
89b0a06e51 | ||
|
|
c5acc25dec | ||
|
|
59ccb0fe6a | ||
|
|
007db8d508 | ||
|
|
17fbb29957 | ||
|
|
c2e3636062 | ||
|
|
8ed540890b | ||
|
|
48c1263ea1 | ||
|
|
bad571aecb | ||
|
|
98ff3cdfcf | ||
|
|
5936ec1986 | ||
|
|
2dd2f6c38e | ||
|
|
c783c1ef31 | ||
|
|
52d7a7a3f7 | ||
|
|
a5e3a277ba | ||
|
|
71a0a69bd3 | ||
|
|
404e1b8eee | ||
|
|
2fd56afe2a | ||
|
|
bf4920de93 | ||
|
|
c66aafe7fe | ||
|
|
c58c603e6d | ||
|
|
1fa17bf10c | ||
|
|
33e751a44c | ||
|
|
fc574a31ff | ||
|
|
0d406530eb | ||
|
|
26795ece3f | ||
|
|
341309e7ae | ||
|
|
89ff54a15e | ||
|
|
4351b74a91 | ||
|
|
2e060cba45 | ||
|
|
690acf286c | ||
|
|
d5e193d0a8 | ||
|
|
d961a4283b | ||
|
|
361e5a8500 | ||
|
|
001c51c8fe | ||
|
|
8954c63285 | ||
|
|
c7e06ed519 | ||
|
|
da1de47927 | ||
|
|
61e2cc16ad | ||
|
|
a71544a78d | ||
|
|
b8d5800434 | ||
|
|
e280061dff | ||
|
|
f4b4609acc | ||
|
|
87f260d25a | ||
|
|
dbf4c2e8ca | ||
|
|
1eb153f51f | ||
|
|
1c7bcdebc7 | ||
|
|
e41af85715 | ||
|
|
f97f17bceb | ||
|
|
19db4fdae9 | ||
|
|
8b65320491 | ||
|
|
e60e869fe9 | ||
|
|
915583d915 | ||
|
|
eab480f0be | ||
|
|
2939556800 | ||
|
|
df0c4489db | ||
|
|
bca85e7e5f | ||
|
|
d748ca1bde | ||
|
|
164ec113cd | ||
|
|
39eea4be5a | ||
|
|
94121da0f3 | ||
|
|
b2b8c0de2d | ||
|
|
c1414de552 | ||
|
|
fc1487bda4 | ||
|
|
ddfabc0010 | ||
|
|
42bf6ec73b | ||
|
|
30213e9b0b | ||
|
|
4c3f919238 | ||
|
|
ddd3d33edc | ||
|
|
388505c899 | ||
|
|
da41c7f7fa | ||
|
|
8af945d8c2 | ||
|
|
b599dc9acb | ||
|
|
55d26693bc | ||
|
|
95499542a4 | ||
|
|
651be0c50d | ||
|
|
79ee417ae6 | ||
|
|
707ad2da70 | ||
|
|
3979af71cb | ||
|
|
58620ac519 | ||
|
|
d326750222 | ||
|
|
8db24bdcd6 | ||
|
|
41daf2ede5 | ||
|
|
2caf609a2e | ||
|
|
1a95fb3d3a | ||
|
|
24188de9e0 | ||
|
|
4bfe4278f3 | ||
|
|
061575bb94 | ||
|
|
00a37fb263 | ||
|
|
8130eea859 | ||
|
|
3c33c2ecbb | ||
|
|
317f1ffbb8 | ||
|
|
87892b27e7 | ||
|
|
5ed7bc2c6f | ||
|
|
1d52cc5acf | ||
|
|
eb1c0e1513 | ||
|
|
e729f04917 | ||
|
|
a6de4df777 | ||
|
|
509e81888c | ||
|
|
c0e2295c1c | ||
|
|
56cf1d0873 | ||
|
|
0b5c74b458 | ||
|
|
e8e9b46206 | ||
|
|
52a1fa9f3a | ||
|
|
e5d31344b9 | ||
|
|
302259e30d | ||
|
|
398071a272 | ||
|
|
7fa66930a4 | ||
|
|
3e2a8c932e | ||
|
|
357962ec97 | ||
|
|
6d613f715f | ||
|
|
906c147ed6 | ||
|
|
d228228eee | ||
|
|
30a6e29897 | ||
|
|
11d88c887f | ||
|
|
213a9a362d | ||
|
|
f1a7c4588b | ||
|
|
82b64c2e38 | ||
|
|
be11b0767e | ||
|
|
0fb3684a18 | ||
|
|
25a7aeacfa | ||
|
|
4804eed0a7 | ||
|
|
07585a01ed | ||
|
|
8346df60ec | ||
|
|
047149798b | ||
|
|
b84006d8db | ||
|
|
e20d398a73 | ||
|
|
a8ee396ffa | ||
|
|
56924fb447 | ||
|
|
5b8f797b33 | ||
|
|
f2769dc182 | ||
|
|
fe67add571 | ||
|
|
70764f1ea4 | ||
|
|
e86638e490 | ||
|
|
1e87f6497c | ||
|
|
16acc3a959 | ||
|
|
06efe3f5c3 | ||
|
|
3c45093632 | ||
|
|
f33a1b997f | ||
|
|
835e9b7eea | ||
|
|
f9bee11001 | ||
|
|
ede8f40b0d | ||
|
|
7dcaa3eda0 | ||
|
|
2a5184f4fc | ||
|
|
0b1c02ac96 | ||
|
|
8b3c472d70 | ||
|
|
8ccea3750e | ||
|
|
222969e8a3 | ||
|
|
f9463c0f82 | ||
|
|
6b27653a99 | ||
|
|
50faf01d10 | ||
|
|
ad71343650 | ||
|
|
f234ed0614 | ||
|
|
69797fd29c | ||
|
|
2163ce3c4c | ||
|
|
a57b186c67 | ||
|
|
4c11217dda | ||
|
|
78b1285b37 | ||
|
|
1ef6d51497 | ||
|
|
1b7bdd2ad9 | ||
|
|
cfd22623b7 | ||
|
|
7b7fb33b7b | ||
|
|
c64763cb35 | ||
|
|
c80bb876a3 | ||
|
|
fbea655e96 | ||
|
|
5390147985 | ||
|
|
81e871cca9 | ||
|
|
f016d5fb4a | ||
|
|
319b9e04dd | ||
|
|
6bb91552f7 | ||
|
|
7c66446459 | ||
|
|
f38adacbe4 | ||
|
|
479d2d427a | ||
|
|
6be5f42ddd | ||
|
|
93524d515a | ||
|
|
2fa3b1c7b2 | ||
|
|
4a62ea0cd3 | ||
|
|
1fd6dca941 | ||
|
|
647cf7ca7d | ||
|
|
49823d457c | ||
|
|
5f34ef68cc | ||
|
|
f6abbc99ab | ||
|
|
9ff03e3ec6 | ||
|
|
773a260438 | ||
|
|
7e7e352924 | ||
|
|
cdb3dce63a | ||
|
|
00cc5d896e | ||
|
|
2591d92959 | ||
|
|
5b45022dfb | ||
|
|
a2be5a9430 | ||
|
|
8c08112097 | ||
|
|
5e6b2fb86e | ||
|
|
f3475341a0 | ||
|
|
87899d514b | ||
|
|
acee7cdfb0 | ||
|
|
564aa972dc | ||
|
|
936f50659b | ||
|
|
264dce055c | ||
|
|
ff5b9a897a | ||
|
|
d44fb67f88 | ||
|
|
27f54ebd15 | ||
|
|
94774d917f | ||
|
|
06d71bb2bc | ||
|
|
cc0f35ce70 | ||
|
|
4b329296f2 | ||
|
|
197d76fd3c | ||
|
|
644186a398 | ||
|
|
e2c6990265 | ||
|
|
98f89d87d4 | ||
|
|
3d379d59ef | ||
|
|
a00a5eb5e2 | ||
|
|
2daa9ce7fd | ||
|
|
4dfeb2aa88 | ||
|
|
8603e98b9b | ||
|
|
4b0570770c | ||
|
|
85d23214ec | ||
|
|
2e35abccd0 | ||
|
|
685ae89685 | ||
|
|
2e6ec01711 | ||
|
|
d63d8ff836 | ||
|
|
450ae24e94 | ||
|
|
39b0e0f318 | ||
|
|
ca9a13ea27 | ||
|
|
ca782e7c62 | ||
|
|
29d45b1e3d | ||
|
|
2202465e31 | ||
|
|
454e6b60d7 | ||
|
|
6ff04b408c | ||
|
|
de7c5e84f4 | ||
|
|
18932bf48b | ||
|
|
1b1bfbb3ac | ||
|
|
20a98e2a95 | ||
|
|
8dbf474662 | ||
|
|
26d0cce404 | ||
|
|
eb5142a125 | ||
|
|
4911aa3f15 | ||
|
|
4a8fc9d771 | ||
|
|
0d9216dd35 | ||
|
|
331047957a | ||
|
|
bec1c0c2d8 | ||
|
|
82fa56d66c | ||
|
|
8db6fd7b73 | ||
|
|
b82a7d86e5 | ||
|
|
698269f8b0 | ||
|
|
5e9c85e0fc | ||
|
|
0fca7cd47b | ||
|
|
d56af6043d | ||
|
|
021bf8ce51 | ||
|
|
53e8f44088 | ||
|
|
3f244b2cff | ||
|
|
3178221c44 | ||
|
|
41d0cbcb46 | ||
|
|
e6a2167261 | ||
|
|
7286531bc5 | ||
|
|
91d7f51678 | ||
|
|
5746449cfb | ||
|
|
4bdbf0f493 | ||
|
|
68b9d955f6 | ||
|
|
39ac48884f | ||
|
|
663ca4f441 | ||
|
|
8f3ae4b5a7 | ||
|
|
db77b8c8cb | ||
|
|
dc6d53e6be | ||
|
|
849d628a75 | ||
|
|
22fd2212de | ||
|
|
188a74423b | ||
|
|
8727b5165a | ||
|
|
aa03d356b8 | ||
|
|
d417fb7232 | ||
|
|
156131d4b5 | ||
|
|
dba72cab46 | ||
|
|
0b4a52ccb1 | ||
|
|
6b92748b7c | ||
|
|
00829cf198 | ||
|
|
20ebcad982 | ||
|
|
6f03f38222 | ||
|
|
5c6b9dcec8 | ||
|
|
c9be4a89af | ||
|
|
41e1ffa6e2 | ||
|
|
c9c202f63f | ||
|
|
1dbaf107ca | ||
|
|
ee535692b4 | ||
|
|
df0a290032 | ||
|
|
7de19f142f | ||
|
|
0cfb00e40b | ||
|
|
3cf560f220 | ||
|
|
3bb287b3ef | ||
|
|
49662a7d5f | ||
|
|
d7655aa2be | ||
|
|
a61d515a49 | ||
|
|
94185cc23e | ||
|
|
9ef977aee9 | ||
|
|
34fb441817 | ||
|
|
ac33b36d20 | ||
|
|
372656fea9 | ||
|
|
a872c6e75f | ||
|
|
067b88ab72 | ||
|
|
ffbad698b4 | ||
|
|
71d3c015d9 | ||
|
|
051299d4a5 | ||
|
|
ac9995fb1a | ||
|
|
83d04d02da | ||
|
|
80bad30811 | ||
|
|
f34554f2cb | ||
|
|
e2f331ab6b | ||
|
|
039ed0f569 | ||
|
|
358ad80f21 | ||
|
|
f9a65f7492 | ||
|
|
32cae92848 | ||
|
|
e168c1368c | ||
|
|
9cab0c6443 | ||
|
|
9e7e4cc177 | ||
|
|
523c101e25 | ||
|
|
1428cd8f10 | ||
|
|
1edd256028 | ||
|
|
42201c7c11 | ||
|
|
aec65a2ff5 | ||
|
|
c2b5733ceb | ||
|
|
2e40c98b81 | ||
|
|
6622e88232 | ||
|
|
67cd0b1b46 | ||
|
|
3ec4f9f96d | ||
|
|
530bf8078e | ||
|
|
848f33bd2b | ||
|
|
1d6b76b182 | ||
|
|
bab857778b | ||
|
|
75469a49e8 | ||
|
|
7d2a9f6d94 | ||
|
|
35fddb48de | ||
|
|
89f9baee46 | ||
|
|
797d04fea7 | ||
|
|
5df83b2649 | ||
|
|
0aa8e8653c | ||
|
|
2751e6475e | ||
|
|
e9d25a67f8 | ||
|
|
eef43e8edc | ||
|
|
b60e5fef96 | ||
|
|
b9c1fa723c | ||
|
|
63f4a6ee0d | ||
|
|
894ea65a35 | ||
|
|
73c9a3cdb4 | ||
|
|
de39ac1981 | ||
|
|
6973e6b159 | ||
|
|
7f379f9874 | ||
|
|
3c6b15ee9d | ||
|
|
c6ef28c358 | ||
|
|
2ef5eb6cd0 | ||
|
|
cfc20c6248 | ||
|
|
ea9505c2da | ||
|
|
1c1c54ea8a | ||
|
|
851c81e096 | ||
|
|
78f969d2cc | ||
|
|
ad981835f9 | ||
|
|
f7f9e8db41 | ||
|
|
44f0fe1852 | ||
|
|
8088197e29 | ||
|
|
76797228a0 | ||
|
|
ba3c0fdf72 | ||
|
|
c6a1d584ea | ||
|
|
be5da6e287 | ||
|
|
7c8f54dd5c | ||
|
|
7b2dc52a35 | ||
|
|
e55d991bce | ||
|
|
e47abd6417 | ||
|
|
afaf97aaf8 | ||
|
|
9bafeccd38 | ||
|
|
18afbd6bae | ||
|
|
4d2458da64 | ||
|
|
737d36be67 | ||
|
|
6d1cf4b6bf | ||
|
|
7dc57c67ed | ||
|
|
823b89ec48 | ||
|
|
d428c58e15 | ||
|
|
4b70e19211 | ||
|
|
ae27fffdb0 | ||
|
|
f41a1bc3a1 | ||
|
|
ed5c52cfdc | ||
|
|
5740d2704a | ||
|
|
56e7775c5a | ||
|
|
d4e807ada3 | ||
|
|
0b5a8863f3 | ||
|
|
83b4887dd6 | ||
|
|
2a7f0901af | ||
|
|
71fb4102f6 | ||
|
|
a492cbd815 | ||
|
|
8d4ebe653d | ||
|
|
88026fae3c | ||
|
|
f34ec61458 | ||
|
|
4d42f94be4 | ||
|
|
961ff7fa22 | ||
|
|
4d41b2afda | ||
|
|
ec5b337460 | ||
|
|
1d559ef4d4 | ||
|
|
732e855daa | ||
|
|
b74bc43007 | ||
|
|
f5d79c7035 | ||
|
|
19c8ffb79d | ||
|
|
39ade6f3ab | ||
|
|
8789c0915b | ||
|
|
55ddf7c417 | ||
|
|
58e206d0e9 | ||
|
|
dc0849d82a | ||
|
|
9192cb4606 | ||
|
|
87f7b82e0a | ||
|
|
21df7f05dd | ||
|
|
e6150b3469 | ||
|
|
68bfa944fe | ||
|
|
a973834325 | ||
|
|
6c8b482f65 | ||
|
|
0712b71b71 | ||
|
|
52b9fd8326 | ||
|
|
8e7b27eb16 | ||
|
|
ab79359eff | ||
|
|
f904af3da6 | ||
|
|
48e1c5dc86 | ||
|
|
25214db1dd | ||
|
|
091a08b783 | ||
|
|
cf37303b5e | ||
|
|
ad059eb3d6 | ||
|
|
41028384af | ||
|
|
43ff13867f | ||
|
|
9b66bd186f | ||
|
|
851efa5097 | ||
|
|
35d923d856 | ||
|
|
bf3bf836ac | ||
|
|
8f8a2ef325 | ||
|
|
eeaefb1ed2 | ||
|
|
6a605359d7 | ||
|
|
d603915d2b | ||
|
|
bb4482c08c | ||
|
|
645ecc3a32 | ||
|
|
da96d2ef9f | ||
|
|
084ba6609d | ||
|
|
9cef4b4f79 | ||
|
|
1898fa7717 | ||
|
|
159c7f9e1b | ||
|
|
158ea68265 | ||
|
|
7ce7c71163 | ||
|
|
4e5a03bb65 | ||
|
|
a986becb70 | ||
|
|
aa78b98ebf | ||
|
|
442d806161 | ||
|
|
310d6fe217 | ||
|
|
288cab7c4f | ||
|
|
6f9a6e32bd | ||
|
|
bb8faf14cb | ||
|
|
9be0afacef | ||
|
|
809b574f12 | ||
|
|
5975be44d9 | ||
|
|
7680b4e165 | ||
|
|
80c04d9645 | ||
|
|
abe73c4022 | ||
|
|
13ef219ab1 | ||
|
|
d6d3fd0966 | ||
|
|
43f2f38ae3 | ||
|
|
44500b6500 | ||
|
|
979a263c88 | ||
|
|
c72d0bec8c | ||
|
|
ba82ca3051 | ||
|
|
0032c06498 | ||
|
|
0c0cee756a | ||
|
|
21f66d13ee | ||
|
|
496b165d42 | ||
|
|
3a306a6235 | ||
|
|
6b75e950ec | ||
|
|
f09a323b20 | ||
|
|
6f6c3f70ff | ||
|
|
1c1211a298 | ||
|
|
b3862cea72 | ||
|
|
391352e077 | ||
|
|
de089072fa | ||
|
|
2542eb959a | ||
|
|
76a85a6e3d | ||
|
|
2c861a5ed4 | ||
|
|
8701450940 | ||
|
|
478b22e7c8 | ||
|
|
38436e7f37 | ||
|
|
43a665497d | ||
|
|
1622cb0285 | ||
|
|
3a28111cfc | ||
|
|
b8b8873eaf | ||
|
|
34023f6d08 | ||
|
|
65f7692116 | ||
|
|
2af90d790b | ||
|
|
daa6fe4cbb | ||
|
|
9c7676a3f2 | ||
|
|
06bd653b24 | ||
|
|
441a74a7c9 | ||
|
|
ebd010b6d9 | ||
|
|
9200a3a32b | ||
|
|
54ea96b820 | ||
|
|
ef6b90c2f6 | ||
|
|
bcb2a89388 | ||
|
|
9e37f693c3 | ||
|
|
337377c001 | ||
|
|
8636a1a43d | ||
|
|
b656c8877b | ||
|
|
48ba0edd2e | ||
|
|
e44bfbe9f3 | ||
|
|
5750dd5dc3 | ||
|
|
bb750d3689 | ||
|
|
6940b7af81 | ||
|
|
31eb6f8701 | ||
|
|
989f1cddf8 | ||
|
|
2d06fd6ea9 | ||
|
|
e79427f708 | ||
|
|
68ff0f7bab | ||
|
|
19b22161c9 | ||
|
|
2d84fc3eda | ||
|
|
e823c2e4e1 | ||
|
|
e5a905f04c | ||
|
|
616a501af7 | ||
|
|
c48ba58d55 | ||
|
|
d3236f57d2 | ||
|
|
f327378d18 | ||
|
|
66a1850c49 | ||
|
|
3ac01eca15 | ||
|
|
e7aac019e1 | ||
|
|
628e3f15b1 | ||
|
|
321ce372d2 | ||
|
|
4fa449990f | ||
|
|
d57b4715d0 | ||
|
|
664ad9e4aa | ||
|
|
a31e47ea42 | ||
|
|
1334e2439d | ||
|
|
543db6f8ab | ||
|
|
8fd679d21f | ||
|
|
d4def48c99 | ||
|
|
c805beeb34 | ||
|
|
a2331ad71a | ||
|
|
eaa2c4c269 | ||
|
|
bab765a8f8 | ||
|
|
348b27365b | ||
|
|
164dd3d8ea | ||
|
|
4a91e6eb18 | ||
|
|
b6a0885927 | ||
|
|
93ce83f137 | ||
|
|
d36c168faa | ||
|
|
86c66aab6d | ||
|
|
8c20ba96f6 | ||
|
|
8a630ff007 | ||
|
|
8e55ddfcae | ||
|
|
1e49fa50b5 | ||
|
|
5093663cfd | ||
|
|
b41f34cade | ||
|
|
1972e6308c | ||
|
|
c0c5cb7e93 | ||
|
|
186b6c8649 | ||
|
|
23e68e2d0d | ||
|
|
1247c37d71 | ||
|
|
2d92c78c0b | ||
|
|
07ed7163ea | ||
|
|
4560c231ce | ||
|
|
5a1f6c8b1a | ||
|
|
7a915c7015 | ||
|
|
2663b6dea0 | ||
|
|
cc3c07d0c2 | ||
|
|
e01cb1b94d | ||
|
|
709d320a5a | ||
|
|
e781be25a0 | ||
|
|
f8eb3d03ad | ||
|
|
b2e7160ce7 | ||
|
|
18bb3b807b | ||
|
|
af92ac4048 | ||
|
|
6ab8aa8e72 | ||
|
|
595e2b83f5 | ||
|
|
ea8ffbc510 | ||
|
|
2663fb318c | ||
|
|
1c70fd201a | ||
|
|
6e635d4272 | ||
|
|
2c41a354f3 | ||
|
|
b24eb1ce9e | ||
|
|
d6b626fd47 | ||
|
|
53f7e5d337 | ||
|
|
232accc0da | ||
|
|
56119d2aab | ||
|
|
53d35fa02f | ||
|
|
a68d63d2be | ||
|
|
17dcddcd80 | ||
|
|
7621c4bdc3 | ||
|
|
949498f3a7 | ||
|
|
0b2f2b189c | ||
|
|
050ebc673a | ||
|
|
cc397ed07b | ||
|
|
5c7e0b8098 | ||
|
|
16ebdcde85 | ||
|
|
4e675d007e | ||
|
|
a4dd37fff2 | ||
|
|
20a545825c | ||
|
|
b912e3a35f | ||
|
|
86a7ffb642 | ||
|
|
cd3e5bdd14 | ||
|
|
48db5a76b0 |
36
.github/workflows/maven_check.yml
vendored
Normal file
36
.github/workflows/maven_check.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
|
||||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
|
||||
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
|
||||
name: Maven Check
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
#push:
|
||||
# branches: [ "main" ]
|
||||
#pull_request:
|
||||
# branches: [ "main" ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'temurin'
|
||||
cache: maven
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
|
||||
# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
|
||||
- name: Update dependency graph
|
||||
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
|
||||
35
.github/workflows/maven_snapshot.yml
vendored
Normal file
35
.github/workflows/maven_snapshot.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
name: Maven Snapshot
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
java: [11]
|
||||
name: Java ${{ matrix.java }} build
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Java ${{ matrix.java }}
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
distribution: 'temurin'
|
||||
cache: maven
|
||||
server-id: ossrh
|
||||
server-username: MAVEN_USERNAME
|
||||
server-password: MAVEN_PASSWORD
|
||||
env:
|
||||
MAVEN_USERNAME: ${{ secrets.OSSRHUSERNAME }}
|
||||
MAVEN_PASSWORD: ${{ secrets.OSSRHPASSWORD }}
|
||||
- name: Build with Maven
|
||||
run: |
|
||||
cp -fr my/pom.xml pom.xml
|
||||
mvn --batch-mode -e -X clean deploy -DskipTests=true
|
||||
env:
|
||||
MAVEN_GPG_KEY: ${{ secrets.OSSRHGPGKEY }}
|
||||
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRHGPGPASSWORD }}
|
||||
34
.gitignore
vendored
34
.gitignore
vendored
@@ -1,15 +1,19 @@
|
||||
*.class
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
/target/
|
||||
/.idea/
|
||||
/redkale.iml
|
||||
*.class
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
/target/
|
||||
/.idea/
|
||||
/redkale.iml
|
||||
/ClientConnection.java
|
||||
/nbactions.xml
|
||||
/nb-configuration.xml
|
||||
/my/target/
|
||||
|
||||
71
README.md
71
README.md
@@ -1,27 +1,48 @@
|
||||
<b>项目介绍</b>
|
||||
<p>
|
||||
Redkale (中文名: 红菜苔,一种湖北特产蔬菜) 是基于Java 11全新的微服务框架, 包含HTTP、WebSocket、TCP/UDP、数据序列化、数据缓存、依赖注入等功能。 本框架致力于简化集中式和微服务架构的开发,在增强开发敏捷性的同时保持高性能。
|
||||
</p>
|
||||
<strong>RedKale 有如下主要特点:</strong>
|
||||
<ol>
|
||||
<li>大量使用Java 8+新特性(接口默认值、Stream、Lambda、内置的ASM、HttpClient等)</li>
|
||||
<li>提供HTTP服务,同时内置JSON功能与限时缓存功能</li>
|
||||
<li>TCP层完全使用NIO,并统一TCP与UDP的接口换</li>
|
||||
<li>提供分布式与集中式部署的无缝切换</li>
|
||||
<li>提供类似JPA功能,包含数据缓存自动同步、分表分库与简洁的数据层操作接口</li>
|
||||
<li>可以动态修改已依赖注入的资源</li>
|
||||
</ol>
|
||||
# [Redkale 2.8](https://redkale.org) <img src="docs/images/logo.png" alt="redkale" width="100" align="right"/>
|
||||
|
||||
<strong>Redkale 设计理念</strong>
|
||||
<p>
|
||||
作为一个全新的微服务框架,Redkale在接口定义上使用了Java 8以上版本的大量新特性,接口有默认实现、接口带静态方法、重复注解等特性,同时在设计上与主流框架有很大不同。Redkale是按组件形式设计的,而非以容器为主,几乎每个子包都是能提供独立功能的组件。如Tomcat是按容器设计的,所有web资源/配置由Tomcat控制,开发者很能难控制到Tomcat内部,而Redkale的HTTP服务只是个组件,开发者既可以自己启动和配置HttpServer,也可以把Redkale当成容器通过Redkale进程来初始化服务。Spring的Ioc容器也是如此,Redkale提供的依赖注入仅通过ResouceFactory一个类来控制,非常轻量,并且可动态更改已注入的资源。Spring提倡控制反转思想,而自身的容器却让开发者很难控制。Redkale是一个既能以组件形式也能以容器形式存在的框架。从整体上看,Redkale的架构分两层:接口和默认实现。开发者若想替换掉Redkale内置的HTTP服务而使用符合JavaEE规范的HttpServlet, 可以采用自定义协议基于JSR 340(Servlet 3.1)来实现自己的HTTP服务;若想使用Hibernate作为数据库操作,可以写一个自己的DataSource实现类;JSON的序列化和反序列化也可以使用第三方的实现;Memcached或Redis也可以作为另一个CacheSource的实现替换Redkale的默认实现。这其实包含了控制反转的思想,让框架里的各个组件均可让开发者控制。<br/>
|
||||
与主流框架比,功能上Redkale显得很简单,这体现了Redkale的简易性,而并非是不足,从一个良好的设计习惯或架构上来看,有些常用功能是不需要提供的,如Redkale的HTTP服务不支持JSP, JSP其实算是一个落后的技术,现在是一个多样化终端的时代,终端不只局限于桌面程序和PC浏览器,还有原生App、混合式App、微信端、移动H5、提供第三方接口等各种形式的终端,这些都不是JSP能方便兼顾的,而HTTP+JSON作为通用性接口可以避免重复开发,模版引擎的功能加上各种强大的JS框架足以取代JSP。Redkale在功能上做了筛选,不会为了迎合主流而提供,而是以良好的设计思想为指导。这是Redkale的主导思维。
|
||||
</p>
|
||||
|
||||
|
||||
<b>详情请访问: <a href='https://redkale.org' target='_blank'>https://redkale.org</a></b>
|
||||
|
||||
<b>基本文档: <a href='https://redkale.org/articles.html' target='_blank'>https://redkale.org/articles.html</a></b>
|
||||
|
||||
<b>欢迎加入Redkale QQ群: 527523235</b>
|
||||
|
||||
|
||||
## 简介
|
||||
  Redkale (中文名: 红菜苔,一种湖北特产蔬菜) 是基于Java 11全新的微服务框架, 包含HTTP、WebSocket、TCP/UDP、数据序列化、数据缓存、依赖注入等功能。 本框架致力于简化集中式和微服务架构的开发,在增强开发敏捷性的同时保持高性能。
|
||||
|
||||
主要特点::
|
||||
* 提供了动态依赖注入和动态字节码生成类功能
|
||||
* 提供HTTP服务,同时内置JSON功能与限时缓存功能
|
||||
* TCP层完全使用NIO,并统一TCP与UDP的接口换
|
||||
* 提供分布式与集中式部署的无缝切换
|
||||
* 提供类似JPA功能,包含数据缓存自动同步、分表分库与简洁的数据层操作接口
|
||||
* 提供了MQ消息消费与生产简洁化API
|
||||
|
||||
## 版本
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.redkale</groupId>
|
||||
<artifactId>redkale</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
## 开发文档
|
||||
* [快速入门](docs/quick-start.md)
|
||||
* [Service组件](docs/service.md)
|
||||
* [序列化](docs/convert.md)
|
||||
* [DB数据源组件](docs/datasource.md)
|
||||
* [Cache数据源组件](docs/cachesource.md)
|
||||
* [WebSocket](docs/websocket.md)
|
||||
* [native-image](docs/native-image.md)
|
||||
* [方法缓存Cached](docs/cached.md)
|
||||
* [定时任务Scheduled](docs/scheduled.md)
|
||||
* [消息队列MQ](docs/agent-message.md)
|
||||
* [基本配置](docs/config.md)
|
||||
* [FAQ](docs/faq.md)
|
||||
|
||||
## 设计理念
|
||||
  作为一个全新的微服务框架,Redkale在接口定义上使用了默认实现、接口带静态方法、重复注解等特性,同时在设计上与主流框架有很大不同。Redkale是按组件形式设计的,而非以容器为主,几乎每个子包都是能提供独立功能的组件。如Tomcat是按容器设计的,所有web资源/配置由Tomcat控制,开发者很能难控制到Tomcat内部,而Redkale的HTTP服务只是个组件,开发者既可以自己启动和配置HttpServer,也可以把Redkale当成容器通过Redkale进程来初始化服务。Spring的Ioc容器也是如此,Redkale提供的依赖注入仅通过ResouceFactory一个类来控制,非常轻量,并且可动态更改已注入的资源。Spring提倡控制反转思想,而自身的容器却让开发者很难控制。Redkale是一个既能以组件形式也能以容器形式存在的框架。从整体上看,Redkale的架构分两层:接口和默认实现。开发者若想替换掉Redkale内置的HTTP服务而使用符合JavaEE规范的HttpServlet, 可以采用自定义协议基于JSR 340(Servlet 3.1)来实现自己的HTTP服务;若想使用Hibernate作为数据库操作,可以写一个自己的DataSource实现类;JSON的序列化和反序列化也可以使用第三方的实现;Memcached或Redis也可以作为另一个CacheSource的实现替换Redkale的默认实现。这其实包含了控制反转的思想,让框架里的各个组件均可让开发者控制。
|
||||
  与主流框架比,功能上Redkale显得很简单,这体现了Redkale的简易性,而并非是不足,从一个良好的设计习惯或架构上来看,有些常用功能是不需要提供的,如Redkale的HTTP服务不支持JSP, JSP其实算是一个落后的技术,现在是一个多样化终端的时代,终端不只局限于桌面程序和PC浏览器,还有原生App、混合式App、微信端、移动H5、提供第三方接口等各种形式的终端,这些都不是JSP能方便兼顾的,而HTTP+JSON作为通用性接口可以避免重复开发,模版引擎的功能加上各种强大的JS框架足以取代JSP。Redkale在功能上做了筛选,不会为了迎合主流而提供,而是以良好的设计思想为指导。这是Redkale的主导思维。
|
||||
|
||||
   <b>详情请访问:  <a href='https://redkale.org' target='_blank'>https://redkale.org</a></b>
|
||||
|
||||
   <b>基本文档:  <a href='https://redkale.org/articles.html' target='_blank'>https://redkale.org/articles.html</a></b>
|
||||
|
||||
   <b>欢迎加入Redkale QQ群: 527523235</b>
|
||||
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
|
||||
<application nodeid="10000" port="2020">
|
||||
|
||||
<resources>
|
||||
<properties load="config.properties">
|
||||
<property name="system.property.redkale.convert.protobuf.enumtostring" value="true"/>
|
||||
</properties>
|
||||
</resources>
|
||||
<properties load="config.properties">
|
||||
<property name="system.property.redkale.convert.protobuf.enumtostring" value="true"/>
|
||||
</properties>
|
||||
|
||||
<server protocol="HTTP" port="5050">
|
||||
<request>
|
||||
|
||||
@@ -6,6 +6,15 @@
|
||||
### true: auto ddl;
|
||||
#redkale.datasource[platf].table-autoddl = true
|
||||
|
||||
############ DataSource @Resource(name="user") ############
|
||||
#redkale.datasource[user].read.url = jdbc:mysql://127.0.0.1:3306/user_r?allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&serverTimezone=UTC&characterEncoding=utf8
|
||||
#redkale.datasource[user].read.user = root
|
||||
#redkale.datasource[user].read.password = 12345678
|
||||
|
||||
#redkale.datasource[user].write.url = jdbc:mysql://127.0.0.1:3306/user_w?allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&serverTimezone=UTC&characterEncoding=utf8
|
||||
#redkale.datasource[user].write.user = root
|
||||
#redkale.datasource[user].write.password = 12345678
|
||||
|
||||
|
||||
############ CacheSource @Resource(name="usersession") ############
|
||||
#redkale.cachesource[usersession].node[0].url = redis://127.0.0.1:6363
|
||||
|
||||
2
docs/agent-cluster.md
Normal file
2
docs/agent-cluster.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# 服务管理
|
||||
文档完善中……
|
||||
104
docs/agent-message.md
Normal file
104
docs/agent-message.md
Normal file
@@ -0,0 +1,104 @@
|
||||
# 消息队列
|
||||
   MessageAgent是消息中心抽象接口。
|
||||
## 配置
|
||||
```xml
|
||||
<mq name="mymq" type="kafka">
|
||||
<servers value="127.0.0.1:9092"/>
|
||||
<consumer autoload="true"/>
|
||||
</mq>
|
||||
```
|
||||
|
||||
## 消费消息
|
||||
   通过```@ResourceConsumer```和```MessageConsumer```接口实现消费
|
||||
```java
|
||||
@ResourceConsumer(mq = "mymq", topics = "test_bean_topic")
|
||||
public class TestMessageConsumer implements MessageConsumer<TestBean> {
|
||||
|
||||
@Override
|
||||
public void init(AnyValue config) {
|
||||
System.out.println("执行 TestMessageConsumer.init");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(MessageEvent<TestBean>[] events) {
|
||||
for (MessageEvent<TestBean> event : events) {
|
||||
System.out.println("消费消息, message: " + event.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy(AnyValue config) {
|
||||
System.out.println("执行 TestMessageConsumer.destroy");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
  通过Service里标记```@Messaged```的方法实现消费, 方法只能是```protected```或```public```, 不能是```final```、```static```。
|
||||
```java
|
||||
public class TestMessageService extends AbstractService {
|
||||
|
||||
@Messaged(mq = "mymq", topics = "test_bean_topic")
|
||||
protected void runMessage(MessageEvent<TestBean>[] events) {
|
||||
for (MessageEvent<TestBean> event : events) {
|
||||
System.out.println("消费消息, message: " + event.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
  通过```@Component```的Service里标记```@Messaged```的方法实现消费, 方法只能是```public```。
|
||||
```java
|
||||
@Component
|
||||
public final class TestMessageService extends AbstractService {
|
||||
|
||||
@Messaged(mq = "mymq", topics = "test_bean_topic")
|
||||
public int runMessage(MessageEvent<TestBean>[] events) {
|
||||
for (MessageEvent<TestBean> event : events) {
|
||||
System.out.println("消费消息, message: " + event.getMessage());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 生产消息
|
||||
  通过```@Component```的Service里标记```@Messaged```的方法实现消费, 方法只能是```public```。
|
||||
```java
|
||||
@Component
|
||||
public class TestMessageService extends AbstractService {
|
||||
|
||||
@ResourceProducer(mq = "mymq")
|
||||
private MessageProducer producer;
|
||||
|
||||
public void sendMessage() {
|
||||
TestBean bean = new TestBean(12345, "this is a message");
|
||||
System.out.println("生产消息: " + bean);
|
||||
producer.sendMessage("test_bean_topic", bean);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Topic管理
|
||||
  通过```MessageManager```操作topic。
|
||||
```java
|
||||
public class TestMessageManager extends AbstractService {
|
||||
|
||||
@Resource(name = "mymq")
|
||||
private MessageManager manager;
|
||||
|
||||
// 创建topic
|
||||
public void initTopic() {
|
||||
manager.createTopic("topic_1", "topic_2").join();
|
||||
}
|
||||
|
||||
// 删除topic
|
||||
public void deleteTopic() {
|
||||
manager.deleteTopic("topic_1", "topic_2").join();
|
||||
}
|
||||
|
||||
// 查询topic
|
||||
public void printTopic() {
|
||||
List<String> topics = manager.queryTopic().join();
|
||||
}
|
||||
}
|
||||
```
|
||||
2
docs/agent-properties.md
Normal file
2
docs/agent-properties.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# 配置中心
|
||||
文档完善中……
|
||||
123
docs/cached.md
Normal file
123
docs/cached.md
Normal file
@@ -0,0 +1,123 @@
|
||||
# 方法缓存
|
||||
  @Cached注解在Service的方法上,实现对方法结果进行缓存。
|
||||
     1、返回类型不能是```void```/```CompletableFuture<Void>```<br>
|
||||
     2、返回类型必须是可json序列化的 <br>
|
||||
     3、修饰必须是```protected```/```public``` <br>
|
||||
     4、修饰不能是```final```/```static``` <br>
|
||||
  本地缓存和远程缓存可同时设置,```expire```设置为0,表示永不过期, 支持异步方法(返回类型为```CompletableFuture```)。
|
||||
|
||||
## 属性说明
|
||||
|属性|默认值|说明|
|
||||
| --- | --- | --- |
|
||||
|name|未定义|缓存的名称|
|
||||
|key|未定义|缓存的key,支持参数动态组合,比如"key_#{id}"|
|
||||
|manager|空|缓存管理器名称, 不能含有':'、'#'、'@'字符|
|
||||
|localLimit|-1|本地缓存数量上限, 小于1表示无上限。 <br> 参数值支持方式:<br>  100: 设置数值 <br>  ${env.cache.limit}: 读取系统配置项 |
|
||||
|localExpire|-1|本地缓存过期时长, 0表示永不过期, -1表示不作本地缓存。 <br> 参数值支持方式:<br>  100: 设置数值 <br>  ${env.cache.expires}: 读取系统配置项 |
|
||||
|remoteExpire|-1|远程缓存过期时长, 0表示永不过期, -1表示不作远程缓存。 <br> 参数值支持方式:<br>  100: 设置数值 <br>  ${env.cache.expires}: 读取系统配置项 |
|
||||
|nullable|false|是否可以缓存null值|
|
||||
|timeUnit|```TimeUnit.SECONDS```|时间单位TimeUnit|
|
||||
|comment|未定义|备注描述|
|
||||
|mode|```LoadMode.ANY```|作用于Service模式,默认值为:ANY,作用于所有模式Service,<br> LOCAL: 表示远程模式的Service对象中的缓存功能不起作用|
|
||||
|
||||
## 基本用法
|
||||
  将结果进行本地缓存30秒且远程缓存60秒
|
||||
```java
|
||||
@Cached(name = "name", key = "name", localExpire = "30", remoteExpire = "60")
|
||||
public String getName() {
|
||||
return "haha";
|
||||
}
|
||||
```
|
||||
|
||||
  以参数code为key将结果进行本地缓存(时长由环境变量```env.cache.expire```配置,没配置采用默认值30秒)
|
||||
```java
|
||||
@Cached(name = "name", key = "#{code}", localExpire = "${env.cache.expire:30}")
|
||||
public CompletableFuture<String> getNameAsync(String code) {
|
||||
return redis.getStringAsync(code);
|
||||
}
|
||||
```
|
||||
|
||||
  以参数code+map.id为key将结果进行远程缓存60毫秒
|
||||
```java
|
||||
@Resource
|
||||
private CachedManager cachedManager;
|
||||
|
||||
//实时修改远程缓存的key值
|
||||
public void updateName(String code, Map<String, Long> map) {
|
||||
cachedManager.remoteSetString("name", code + "_" + map.get("id"), code + "-" + map, Duration.ofMillis(60));
|
||||
}
|
||||
|
||||
@Cached(name = "name", key = "#{code}_#{map.id}", remoteExpire = "60", timeUnit = TimeUnit.MILLISECONDS)
|
||||
public String getName(String code, Map<String, Long> map) {
|
||||
return code + "-" + map;
|
||||
}
|
||||
```
|
||||
|
||||
## 动态调整缓存时长
|
||||
  使用```@Resource```注入多个```CachedManager```
|
||||
```java
|
||||
|
||||
@Resource
|
||||
private CachedManager cachedManager;
|
||||
|
||||
@Cached(name = "name", key = "#{code}_#{map.id}", remoteExpire = "60", timeUnit = TimeUnit.MILLISECONDS)
|
||||
public String getName(String code, Map<String, Long> map) {
|
||||
return code + "-" + map;
|
||||
}
|
||||
|
||||
public void updateExpire() {
|
||||
Duration expire = Duration.ofMillis(600);
|
||||
cachedManager.acceptCachedAction("name", action -> {
|
||||
//将缓存时长改成600毫秒,并开启本地缓存
|
||||
action.setLocalExpire(expire);
|
||||
action.setRemoteExpire(expire);
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
## 缓存配置
|
||||
```xml
|
||||
<!--
|
||||
全局Serivce的缓存设置,没配置该节点将自动创建一个。
|
||||
name: 缓存管理器的名称, 默认: ""
|
||||
enabled: 是否开启缓存功能。默认: true
|
||||
remote: 远程CacheSource的资源名
|
||||
broadcastable: 存在远程CacheSource时修改数据是否进行广播到其他集群服务中。默认: true
|
||||
-->
|
||||
<cached name="" enabled="true" remote="xxx" broadcastable="true"/>
|
||||
```
|
||||
|
||||
## 多缓存器
|
||||
```xml
|
||||
<cached name="" enabled="true" remote="redis_1" broadcastable="true"/>
|
||||
<cached name="backup" enabled="true" remote="redis_2" broadcastable="true"/>
|
||||
```
|
||||
|
||||
  使用```@Resource```注入多个```CachedManager```
|
||||
```java
|
||||
|
||||
//第一个缓存器
|
||||
@Resource
|
||||
private CachedManager cachedManager;
|
||||
|
||||
//第二个缓存器
|
||||
@Resource(name = "backup")
|
||||
private CachedManager cachedManager2;
|
||||
|
||||
//第一个缓存器实时修改远程缓存的key值
|
||||
public void updateName(String code, Map<String, Long> map) {
|
||||
cachedManager.remoteSetString("name", code + "_" + map.get("id"), code + "-" + map, Duration.ofMillis(60));
|
||||
}
|
||||
|
||||
//使用第一个缓存器
|
||||
@Cached(name = "name", key = "#{code}_#{map.id}", remoteExpire = "60", timeUnit = TimeUnit.MILLISECONDS)
|
||||
public String getName(String code, Map<String, Long> map) {
|
||||
return code + "-" + map;
|
||||
}
|
||||
|
||||
//使用第二个缓存器
|
||||
@Cached(manager = "backup", name = "name", key = "#{code}_#{map.id}_2", remoteExpire = "60", timeUnit = TimeUnit.MILLISECONDS)
|
||||
public String getName2(String code, Map<String, Long> map) {
|
||||
return code + "-" + map;
|
||||
}
|
||||
```
|
||||
58
docs/cachesource.md
Normal file
58
docs/cachesource.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# 缓存组件 CacheSource
|
||||
  ```CachedCacheSource```是框架主要的缓存组件,主要提供redis和内存两大实现,接口大部分与redis命令保持一致。
|
||||
|
||||
## 使用CacheSouce存放登录会话
|
||||
```java
|
||||
public class UserService implements Service {
|
||||
|
||||
//用户简单信息缓存
|
||||
private final Map<Integer, UserInfo> users = new ConcurrentHashMap<>();
|
||||
|
||||
//使用CacheSource必须要指明泛型
|
||||
@Resource(name = "usersessions")
|
||||
protected CacheSource sessions;
|
||||
|
||||
//登录
|
||||
public RetResult<UserInfo> login(LoginBean bean) { //bean.sessionid 在接入层进行赋值
|
||||
UserInfo user = null;
|
||||
// 登陆逻辑 user = ...
|
||||
users.put(user.getUserid(), user);
|
||||
sessions.setLong(600, bean.getSessionid(), user.getUserid()); //session过期时间设置为10分钟
|
||||
return new RetResult<>(user);
|
||||
}
|
||||
|
||||
//获取当前用户信息
|
||||
public UserInfo current(String sessionid) { //给HTTP的BaseServlet用
|
||||
Long userid = sessions.getexLong(sessionid, 600);
|
||||
return userid == null ? null : users.get(userid.intValue());
|
||||
}
|
||||
|
||||
//注销
|
||||
public void logout(String sessionid) {
|
||||
sessions.del(sessionid);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## source.properties 配置说明
|
||||
```
|
||||
|
||||
# usersession为@Resource.name值
|
||||
# type可以不用设置,框架会根据url判断使用哪个CacheSource实现类
|
||||
redkale.cachesource.usersession.type = org.redkalex.cache.redis.RedisCacheSource
|
||||
# 最大连接数
|
||||
redkale.cachesource.usersession.maxconns = 16
|
||||
# 节点地址
|
||||
redkale.cachesource.usersession.nodes = redis://127.0.0.1:6363
|
||||
# 节点密码
|
||||
redkale.cachesource.usersession.password = 12345678
|
||||
# 节点db
|
||||
redkale.cachesource.usersession.db = 0
|
||||
|
||||
#简化写法: 可以不用.node[0], 将参数都合并到url中
|
||||
redkale.cachesource.usersession.url = redis://user:123456@127.0.0.1:6363?db=0
|
||||
|
||||
@Resource.name=""的CacheSource
|
||||
redkale.cachesource.nodes = redis://127.0.0.1:6363
|
||||
redkale.cachesource.password = 12345678
|
||||
```
|
||||
463
docs/config.md
Normal file
463
docs/config.md
Normal file
@@ -0,0 +1,463 @@
|
||||
# 配置说明
|
||||
# application.xml 配置:
|
||||
```xml
|
||||
<!--
|
||||
文件说明:
|
||||
${APP_HOME} 指当前程序的根目录APP_HOME
|
||||
没注明唯一的节点可多个存在
|
||||
required: 被声明required的属性值不能为空
|
||||
-->
|
||||
<!--
|
||||
nodeid: int 进程的节点ID,用于分布式环境,一个系统中节点ID必须全局唯一,使用cluster时框架会进行唯一性校验
|
||||
name: 进程的名称,用于监控识别,命名规则: 字母、数字、下划线、短横、点
|
||||
address: 本地局域网的IP地址, 默认值为默认网卡的ip,当不使用默认值需要指定值,如192.168.1.22
|
||||
port: required 程序的管理Server的端口,用于关闭或者与监管系统进行数据交互
|
||||
lib: 加上额外的lib路径,多个路径用分号;隔开; 默认为空。 例如: ${APP_HOME}/lib/a.jar;${APP_HOME}/lib2/b.jar;
|
||||
-->
|
||||
<application nodeid="1000" port="6560" lib="">
|
||||
|
||||
<!--
|
||||
【节点全局唯一】 @since 2.3.0
|
||||
全局Serivce执行的线程池, Application.workExecutor, 没配置该节点将自动创建一个。
|
||||
threads: 线程数,默认值: CPU核数*10, 核数=2的情况下默认值为20。值为0表示不启用workExecutor,都在IO线程中运行。
|
||||
clients: client回调函数运行的线程池大小, 默认值: CPU核数*4
|
||||
-->
|
||||
<executor threads="4"/>
|
||||
|
||||
<!--
|
||||
【节点全局唯一】 @since 2.8.0
|
||||
全局Serivce的定时任务设置,没配置该节点将自动创建一个。
|
||||
enabled: 是否开启缓存功能。默认: true
|
||||
-->
|
||||
<scheduled enabled="true"/>
|
||||
|
||||
<!--
|
||||
@since 2.8.0
|
||||
全局Serivce的缓存设置,没配置该节点将自动创建一个。
|
||||
name: 缓存管理器的名称, 默认: ""
|
||||
enabled: 是否开启缓存功能。默认: true
|
||||
remote: 远程CacheSource的资源名
|
||||
broadcastable: 存在远程CacheSource时修改数据是否进行广播到其他集群服务中。默认: true
|
||||
-->
|
||||
<cached name="" enabled="true" remote="xxx" broadcastable="true"/>
|
||||
|
||||
<!--
|
||||
【节点全局唯一】
|
||||
第三方服务发现管理接口
|
||||
type: 类名,必须是org.redkale.cluster.ClusterAgent的子类
|
||||
waits: 注销服务后是否需要等待检查周期时间后再进行Service销毁,默认值为:false
|
||||
当一个Service进行服务注销后,不能立刻销毁Service,因为健康检测是有间隔时间差的,
|
||||
需要等待一个健康检测周期时间,让其他进程都更新完服务列表。
|
||||
如果使用MQ,可以设置为false,如果对服务健壮性要求高,建议设置为true
|
||||
protocols: 服务发现可以处理的协议, 默认值为: SNCP, 多个协议用分号;隔开
|
||||
ports: 服务发现可以处理的端口, 多个端口用分号;隔开
|
||||
ttls: 心跳频率,多少秒一次
|
||||
xxxx: 自定义的字段属性,例如:CacheClusterAgent有source字段; ConsulClusterAgent有apiurl字段;
|
||||
-->
|
||||
<cluster type="org.redkalex.cluster.consul.ConsulClusterAgent" waits="false" protocols="SNCP" ports="7070;7071" xxx="xxx" />
|
||||
|
||||
<!--
|
||||
MQ管理接口配置
|
||||
不同MQ节点所配置的MQ集群不能重复。
|
||||
MQ跟着协议走,所以mq的属性值需要被赋值在rest节点上, 由于SncpServlet是自动生成的,故SNCP协议下,mq属性值被赋值在service/services节点上
|
||||
name: 服务的名称,用于监控识别,多个mq节点时只能有一个name为空的节点,mq.name不能重复,命名规则: 字母、数字、下划线
|
||||
type: 实现类名,必须是org.redkale.mq.MessageAgent的子类
|
||||
threads: 线程数,为0表示使用workExecutor。默认: CPU核数, 核数=1的情况下默认值为2,JDK 21以上版本默认使用虚拟线程池
|
||||
rpcfirst:cluster和mq同名组件时,HttpRpcClient优先使用MQ,默认不优先走MQ。
|
||||
coder: MessageRecord的解析器类,必须是org.redkale.mq.MessageCoder<MessageRecord>的实现类,
|
||||
可对数据包进行加密解密,默认值:org.redkale.mq.MessageRecordCoder
|
||||
MQ节点下的子节点配置没有固定格式, 根据MessageAgent实现方的定义来配置
|
||||
-->
|
||||
<mq name="" type="org.redkalex.mq.kafka.KafkaMessageAgent" rpcfirst="false" threads="4">
|
||||
<servers value="127.0.0.1:9101"/>
|
||||
<!--
|
||||
加载所有的MessageConsumer实例;
|
||||
autoload="true" 默认值. 自动加载classpath下所有的MessageConsumer类
|
||||
autoload="false" 需要显著的指定MessageConsumer类
|
||||
includes: 当autoload="true", 拉取类名与includes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
excludes: 当autoload="true", 排除类名与excludes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
-->
|
||||
<consumer autoload="true" includes="" excludes=""/>
|
||||
<!--
|
||||
MQ实现方的配置项
|
||||
type: 配置项类型,值只能是consumer或producer
|
||||
-->
|
||||
<config type="consumer">
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
</config>
|
||||
<config type="producer">
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
</config>
|
||||
</mq>
|
||||
|
||||
<!--
|
||||
一个组包含多个node, 同一Service服务可以由多个进程提供,这些进程称为一个GROUP,且同一GROUP内的进程必须在同一机房或局域网内
|
||||
name: 服务组ID,长度不能超过11个字节. 默认为空字符串。 注意: name不能包含$符号。
|
||||
protocol: 值范围:UDP TCP, 默认TCP
|
||||
nodes: 多个node节点值; 例如:192.168.0.1:6060,192.168.0.2:6060
|
||||
注意: 一个node只能所属一个group。只要存在protocol=SNCP的Server节点信息, 就必须有group节点信息。
|
||||
-->
|
||||
<group name="" protocol="TCP" nodes="192.168.0.1:6060,192.168.0.2:6060">
|
||||
<!--
|
||||
需要将本地node的addr与port列在此处, 也可以直接用nodes属性。
|
||||
同一个<node>节点值只能存在一个<group>节点内,即同一个addr+port只能属于一个group。
|
||||
addr: required IP地址
|
||||
port: required 端口
|
||||
-->
|
||||
<node addr="127.0.0.1" port="7070"/>
|
||||
</group>
|
||||
|
||||
<!--
|
||||
Application启动的监听事件,可配置多个节点
|
||||
value: 类名,必须是ApplicationListener的子类
|
||||
-->
|
||||
<listener value="org.redkalex.xxx.XXXApplicationListener"/>
|
||||
|
||||
<!--
|
||||
【节点全局唯一】
|
||||
全局的参数配置, 可以通过@Resource(name="property.xxxxxx") 进行注入<property>的信息, 被注解的字段类型只能是String、primitive class
|
||||
如果name是system.property.开头的值将会在进程启动时进行System.setProperty("yyyy", "YYYYYY")操作。
|
||||
如果name是mimetype.property.开头的值将会在进程启动时进行MimeType.add("yyyy", "YYYYYY")操作。
|
||||
先加载子节点property,再加载load文件, 最后加载agent的实现子类。
|
||||
load: 加载文件,多个用;隔开。
|
||||
其他属性: 供org.redkale.boot.PropertiesAgentProvider使用判断
|
||||
默认置入的system.property.的有:
|
||||
System.setProperty("redkale.convert.pool.size", "128");
|
||||
System.setProperty("redkale.convert.writer.buffer.defsize", "4096");
|
||||
|
||||
<properties>节点下也可包含非<property>节点.
|
||||
非<property>其节点可以通过@Resource(name="properties.xxxxxx")进行注入, 被注解的字段类型只能是AnyValue、AnyValue[]
|
||||
-->
|
||||
<properties load="config.properties">
|
||||
<property name="system.property.yyyy" value="YYYYYY"/>
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
</properties>
|
||||
|
||||
<!--
|
||||
protocol: required server所启动的协议,Redkale内置的有HTTP、SNCP、WATCH。协议均使用TCP实现; WATCH服务只能存在一个。
|
||||
name: 服务的名称,用于监控识别,一个配置文件中的server.name不能重复,命名规则: 字母、数字、下划线
|
||||
host: 服务所占address , 默认: 0.0.0.0
|
||||
port: required 服务所占端口
|
||||
root: 如果是web类型服务,则包含页面 默认:{APP_HOME}/root
|
||||
lib: server额外的class目录, 默认为${APP_HOME}/libs/*;
|
||||
charset: 文本编码, 默认: UTF-8
|
||||
backlog: 默认10K
|
||||
maxconns: 最大连接数, 小于1表示无限制, 默认: 0
|
||||
maxbody: request.body最大值, 默认: 256K
|
||||
bufferCapacity: ByteBuffer的初始化大小, TCP默认: 32K; (HTTP 2.0、WebSocket,必须要16k以上); UDP默认: 8K
|
||||
bufferPoolSize: ByteBuffer池的大小,默认: 线程数*4
|
||||
responsePoolSize: Response池的大小,默认: 1024
|
||||
aliveTimeoutSeconds: KeepAlive读操作超时秒数, 默认30, 0表示永久不超时; -1表示禁止KeepAlive
|
||||
readTimeoutSeconds: 读操作超时秒数, 默认0, 0表示永久不超时
|
||||
writeTimeoutSeconds: 写操作超时秒数, 默认0, 0表示永久不超时
|
||||
interceptor: 启动/关闭NodeServer时被调用的拦截器实现类,必须是org.redkale.boot.NodeInterceptor的子类,默认为null
|
||||
-->
|
||||
<server protocol="HTTP" host="127.0.0.1" port="6060" root="root" lib="">
|
||||
|
||||
<!--
|
||||
【节点在<server>中唯一】
|
||||
builder: 创建SSLContext的实现类, 可自定义,必须是org.redkale.net.SSLBuilder的子类
|
||||
sslProvider: java.security.Provider自定义的实现类,如第三方: org.conscrypt.OpenSSLProvider、org.bouncycastle.jce.provider.BouncyCastleProvider
|
||||
jsseProvider: java.security.Provider自定义的实现类,如第三方: org.conscrypt.JSSEProvider、 org.bouncycastle.jce.provider.BouncyCastleJsseProvider
|
||||
protocol: TLS版本,默认值: TLS
|
||||
protocols: 设置setEnabledProtocols, 多个用,隔开 如: TLSv1.2,TLSv1.3
|
||||
clientAuth: WANT/NEED/NONE, 默认值: NONE
|
||||
ciphers: 设置setEnabledCipherSuites, 多个用,隔开 如: TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA256
|
||||
keystorePass: KEY密码
|
||||
keystoreFile: KEY文件 .jks
|
||||
keystoreType: KEY类型, 默认值为JKS
|
||||
keystoreAlgorithm: KEY文件的algorithm, 默认值为SunX509
|
||||
truststorePass: TRUST密码
|
||||
truststoreFile: TRUST文件
|
||||
truststoreType: TRUST类型, 默认值为JKS
|
||||
truststoreAlgorithm: TRUST文件的algorithm, 默认值为SunX509
|
||||
-->
|
||||
<ssl builder=""/>
|
||||
|
||||
<!--
|
||||
加载所有的Service服务;
|
||||
在同一个进程中同一个name同一类型的Service将共用同一个实例
|
||||
autoload="true" 默认值. 自动加载classpath下所有的Service类
|
||||
autoload="false" 需要显著的指定Service类
|
||||
mq: 所属的MQ管理器,当 protocol == SNCP 时该值才有效, 存在该属性表示Service的SNCP协议采用消息总线代理模式
|
||||
includes: 当autoload="true", 拉取类名与includes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
excludes: 当autoload="true", 排除类名与excludes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
group: 所属组的节点, 不能指定多个group, 如果配置文件中存在多个SNCP协议的Server节点,需要显式指定group属性.
|
||||
当 protocol == SNCP 时 group表示当前Server与哪些节点组关联。
|
||||
当 protocol != SNCP 时 group只能是空或者一个group的节点值。
|
||||
特殊值"$remote", 视为通过第三方服务注册发现管理工具来获取远程模式的ip端口信息
|
||||
-->
|
||||
<services autoload="true" includes="" excludes="">
|
||||
|
||||
<!-- 显著加载指定的Service的接口类 -->
|
||||
<service value="com.xxx.XXX1Service"/>
|
||||
<!--
|
||||
name: 显式指定name,覆盖默认的空字符串值。 注意: name不能包含$符号。
|
||||
mq: 所属的MQ管理器,当 protocol == SNCP 时该值才有效, 存在该属性表示Service的SNCP协议采用消息总线代理模式
|
||||
group: 显式指定group,覆盖<services>节点的group默认值。
|
||||
ignore: 是否禁用, 默认为false。
|
||||
-->
|
||||
<service value="com.xxx.XXX2Service" name="" group="xxx"/>
|
||||
<!-- 给Service增加配置属性 -->
|
||||
<service value="com.xxx.XXX1Service">
|
||||
<!-- property值在public void init(AnyValue conf)方法中可以通过AnyValue properties=conf.getAnyValue("properties")获取 -->
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
</service>
|
||||
</services>
|
||||
|
||||
<!--
|
||||
加载所有的Filter服务;
|
||||
autoload="true" 默认值.
|
||||
autoload="false" 需要显著的指定Filter类
|
||||
includes: 当autoload="true", 拉取类名与includes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
excludes: 当autoload="true", 排除类名与excludes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
-->
|
||||
<filters autoload="true" includes="" excludes="">
|
||||
|
||||
<!--
|
||||
显著加载指定的Filter类
|
||||
value=: Filter类名。必须与Server的协议层相同,HTTP必须是HttpFilter
|
||||
ignore: 是否禁用, 默认为false。
|
||||
-->
|
||||
<!-- 显著加载指定的Filter类 -->
|
||||
<filter value="com.xxx.XXX1Filter"/>
|
||||
|
||||
<!-- 给Filter增加配置属性 -->
|
||||
<filter value="com.xxx.XXX12Filter">
|
||||
<!-- property值在public void init(AnyValue conf)方法中可以通过AnyValue properties=conf.getAnyValue("properties")获取 -->
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
</filter>
|
||||
</filters>
|
||||
|
||||
<!--
|
||||
REST的核心配置项
|
||||
当Server为HTTP协议时, rest节点才有效。存在[rest]节点则Server启动时会加载REST服务, 节点可以多个,(WATCH协议不需要设置,系统会自动生成)
|
||||
path: servlet的ContextPath前缀 默认为空 【注: 开启MQ时,该字段失效】
|
||||
base: REST服务的BaseServlet,必须是 org.redkale.net.http.HttpServlet 的子类,且子类必须标记@HttpUserType。
|
||||
mq: 所属的MQ管理器, 存在该属性表示RestService的请求来自于消息总线 【注: 开启MQ时,path字段失效】
|
||||
autoload:默认值"true" 默认值. 加载当前server所能使用的Servce对象;
|
||||
includes:当autoload="true", 拉取类名与includes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
excludes:当autoload="true", 排除类名与excludes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
-->
|
||||
<rest path="/pipes" base="org.redkale.net.http.HttpServlet" autoload="true" includes="" excludes="">
|
||||
<!--
|
||||
value: Service类名,列出的表示必须被加载的Service对象
|
||||
ignore: 是否忽略,设置为true则不会加载该Service对象,默认值为false
|
||||
-->
|
||||
<service value="com.xxx.XXXXService"/>
|
||||
<!--
|
||||
value: WebSocket类名,列出的表示必须被加载且标记为@RestWebSocket的WebSocket对象
|
||||
ignore: 是否忽略,设置为true则不会加载该RestWebSocket对象,默认值为false
|
||||
-->
|
||||
<websocket value="com.xxx.XXXXRestWebSocket"/>
|
||||
</rest>
|
||||
|
||||
<!--
|
||||
【节点在<server>中唯一】
|
||||
当Server为HTTP协议时, request节点才有效。
|
||||
remoteaddr 节点: 替换请求方节点的IP地址, 通常请求方是由nginx等web静态服务器转发过的则需要配置该节点。
|
||||
且value值只能是以request.headers.开头,表示从request.headers中获取对应的header值。
|
||||
locale value值必须是request.headers.或request.parameters.开头。
|
||||
例如下面例子获取request.getRemoteAddr()值,如果header存在X-RemoteAddress值则返回X-RemoteAddress值,不存在返回getRemoteAddress()。
|
||||
-->
|
||||
<request>
|
||||
<remoteaddr value="request.headers.X-RemoteAddress"/>
|
||||
<locale value="request.headers.locale" />
|
||||
<rpc authenticator="org.redkale.net.http.HttpRpcAuthenticator的实现类"/>
|
||||
</request>
|
||||
|
||||
<!--
|
||||
【节点在<server>中唯一】
|
||||
当Server为HTTP协议时, response节点才有效。
|
||||
contenttype: plain值为调用finish时的ContentType; 默认值: text/plain; charset=utf-8
|
||||
json值为调用finishJson时的ContentType; 默认值: application/json; charset=utf-8
|
||||
defcookie 节点: 当response里输出的cookie没有指定domain 和path时,使用该节点的默认值。
|
||||
addheader、setheader 的value值以request.parameters.开头则表示从request.parameters中获取对应的parameter值
|
||||
addheader、setheader 的value值以request.headers.开头则表示从request.headers中获取对应的header值
|
||||
例如下面例子是在Response输出header时添加两个header(一个addHeader, 一个setHeader)。
|
||||
options 节点: 设置了该节点且auto=true,当request的method=OPTIONS自动设置addheader、setheader并返回200状态码
|
||||
date 节点: 设置了该节点且period有值(单位:毫秒);返回response会包含Date头信息,默认为period=0
|
||||
period=0表示实时获取当前时间;
|
||||
period<0表示不设置date;
|
||||
period>0表示定时获取时间; 设置1000表示每秒刷新Date时间
|
||||
-->
|
||||
<response>
|
||||
<content-type plain="text/plain; charset=utf-8" json="application/json; charset=utf-8"/>
|
||||
<defcookie domain="" path=""/>
|
||||
<addheader name="Access-Control-Allow-Origin" value="request.headers.Origin" /> <!-- 可多节点 -->
|
||||
<setheader name="Access-Control-Allow-Headers" value="request.headers.Access-Control-Request-Headers"/> <!-- 可多节点 -->
|
||||
<setheader name="Access-Control-Allow-Credentials" value="true"/>
|
||||
<options auto="true" />
|
||||
<date period="0" />
|
||||
</response>
|
||||
<!--
|
||||
【节点在<server>中唯一】
|
||||
当Server为HTTP协议时,render才有效. 指定输出引擎的实现类
|
||||
value: 输出引擎的实现类, 必须是org.redkale.net.http.HttpRender的子类
|
||||
suffixs: 引擎文件名后缀,多个用;隔开,默认值为: .htel
|
||||
-->
|
||||
<render value="org.redkalex.htel.HttpTemplateRender" suffixs=".htel"/>
|
||||
<!--
|
||||
【节点在<server>中唯一】
|
||||
当Server为HTTP协议时,ResourceServlet才有效. 默认存在一个有默认属性的resource-servlet节点
|
||||
webroot: web资源的根目录, 默认取server节点中的root值
|
||||
servlet: 静态资源HttpServlet的实现,默认使用HttpResourceServlet
|
||||
index : 启始页,默认值:index.html
|
||||
-->
|
||||
<resource-servlet webroot="root" index="index.html">
|
||||
<!--
|
||||
【节点在<resource-servlet>中唯一】
|
||||
资源缓存的配置, 默认存在一个含默认属性的caches节点
|
||||
limit: 资源缓存最大容量, 默认: 0, 为0表示不缓存, 单位可以是B、K、M、G,不区分大小写
|
||||
lengthmax: 可缓存的文件大小上限, 默认: 1M(超过1M的文件不会被缓存)
|
||||
watch: 是否监控缓存文件的变化, 默认为false,不监控
|
||||
-->
|
||||
<cache limit="0M" lengthmax="1M" watch="false"/>
|
||||
<!--
|
||||
支持类似nginx中的rewrite, 目前只支持静态资源对静态资源的跳转。
|
||||
type: 匹配的类型, 目前只支持location(匹配path), 默认: location
|
||||
match: 匹配的正则表达式
|
||||
forward: 需跳转后的资源链接
|
||||
例如下面例子是将/xxx-yyy.html的页面全部跳转到/xxx.html
|
||||
-->
|
||||
<rewrite type="location" match="^/([^-]+)-[^-\.]+\.html(.*)" forward="/$1.html"/>
|
||||
</resource-servlet>
|
||||
<!--
|
||||
加载所有的Servlet服务;
|
||||
path: servlet的ContextPath前缀 默认为空
|
||||
autoload="true" 默认值. 自动加载classpath下所有的Servlet类
|
||||
autoload="false" 需要显著的指定Service类
|
||||
includes: 当autoload="true", 拉取类名与includes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
excludes: 当autoload="true", 排除类名与excludes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
-->
|
||||
<servlets path="/pipes" autoload="true" includes="" excludes="">
|
||||
<!--
|
||||
显著加载指定的Servlet类
|
||||
value=: Servlet类名。必须与Server的协议层相同,HTTP必须是HttpServlet
|
||||
ignore: 是否禁用, 默认为false。
|
||||
-->
|
||||
<servlet value="com.xxx.XXX1Servlet" />
|
||||
<servlet value="com.xxx.XXX2Servlet" />
|
||||
<servlet value="com.xxx.XXX3Servlet" >
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
<property name="yyyyyy" value="YYYYYYYY"/>
|
||||
</servlet>
|
||||
</servlets>
|
||||
</server>
|
||||
|
||||
<server protocol="SNCP" host="127.0.0.1" port="7070" root="root" lib="">
|
||||
<!-- 参数完全同上 -->
|
||||
<services autoload="true" includes="" excludes="" />
|
||||
</server>
|
||||
|
||||
</application>
|
||||
|
||||
```
|
||||
|
||||
# source.properties 配置:
|
||||
```properties
|
||||
|
||||
# CacheSource @Resource(name="usersession")
|
||||
# type可以不用设置,框架会根据url判断使用哪个CacheSource实现类
|
||||
redkale.cachesource.usersession.type = org.redkalex.cache.redis.RedisCacheSource
|
||||
# 最大连接数
|
||||
redkale.cachesource.usersession.maxconns = 16
|
||||
# 节点地址
|
||||
redkale.cachesource.usersession.nodes = redis://127.0.0.1:6363
|
||||
# 节点密码
|
||||
redkale.cachesource.usersession.password = 12345678
|
||||
# 节点db
|
||||
redkale.cachesource.usersession.db = 0
|
||||
|
||||
#简化写法: 可以不用.node[0], 将参数都合并到url中
|
||||
redkale.cachesource.usersession.url = redis://user:123456@127.0.0.1:6363?db=0
|
||||
|
||||
|
||||
# DataSource @Resource(name="platf")
|
||||
# type可以不用设置,框架会根据url判断使用哪个DataSource实现类,默认值: org.redkale.source.DataJdbcSource
|
||||
redkale.datasource.platf.type = org.redkale.source.DataJdbcSource
|
||||
# 是否开启缓存(标记为@Cacheable的Entity类),值目前只支持两种: ALL: 所有开启缓存。 NONE: 关闭所有缓存, 非NONE字样统一视为ALL
|
||||
redkale.datasource.platf.cachemode = ALL
|
||||
# 是否自动建表当表不存在的时候, 目前只支持mysql、postgres, 默认为false
|
||||
redkale.datasource.platf.table-autoddl = false
|
||||
# 用户
|
||||
redkale.datasource.platf.user = root
|
||||
# 密码
|
||||
redkale.datasource.platf.password = 12345678
|
||||
# 多个URL用;隔开,如分布式SearchSource需要配多个URL
|
||||
redkale.datasource.platf.url = jdbc:mysql://127.0.0.1:3306/platf?allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&serverTimezone=UTC&characterEncoding=utf8
|
||||
# 最大连接数,默认值:CPU数
|
||||
redkale.datasource.platf.maxconns = 16
|
||||
# 包含的SQL模板,相当于反向LIKE,不同的JDBC驱动的SQL语句不一样,Redkale内置了MySQL的语句
|
||||
redkale.datasource.platf.contain-sqltemplate = LOCATE(#{keystr}, #{column}) > 0
|
||||
# 包含的SQL模板,相当于反向LIKE,不同的JDBC驱动的SQL语句不一样,Redkale内置了MySQL的语句
|
||||
redkale.datasource.platf.notcontain-sqltemplate = LOCATE(#{keystr}, #{column}) = 0
|
||||
# 复制表结构的SQL模板,Redkale内置了MySQL的语句
|
||||
redkale.datasource.platf.tablenotexist-sqlstates = 42000;42S02
|
||||
# 复制表结构的SQL模板,Redkale内置了MySQL的语句
|
||||
redkale.datasource.platf.tablecopy-sqltemplate = CREATE TABLE IF NOT EXISTS #{newtable} LIKE #{oldtable}
|
||||
|
||||
|
||||
# DataSource 读写分离
|
||||
redkale.datasource.platf.read.url = jdbc:mysql://127.0.0.1:3306/platf_r?allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&serverTimezone=UTC&characterEncoding=utf8
|
||||
redkale.datasource.platf.read.user = root
|
||||
redkale.datasource.platf.read.password = 12345678
|
||||
|
||||
redkale.datasource.platf.write.url = jdbc:mysql://127.0.0.1:3306/platf_w?allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&serverTimezone=UTC&characterEncoding=utf8
|
||||
redkale.datasource.platf.write.user = root
|
||||
redkale.datasource.platf.write.password = 12345678
|
||||
```
|
||||
|
||||
# logging.properties 配置:
|
||||
```properties
|
||||
|
||||
handlers = java.util.logging.ConsoleHandler,java.util.logging.FileHandler
|
||||
.handlers = java.util.logging.ConsoleHandler,java.util.logging.FileHandler
|
||||
|
||||
############################################################
|
||||
.level = FINE
|
||||
|
||||
sun.level = INFO
|
||||
java.level = INFO
|
||||
javax.level = INFO
|
||||
com.sun.level = INFO
|
||||
|
||||
#java.util.logging.FileHandler.level = FINE
|
||||
|
||||
java.util.logging.FileHandler.limit = 20M
|
||||
java.util.logging.FileHandler.count = 100
|
||||
java.util.logging.FileHandler.encoding = UTF-8
|
||||
java.util.logging.FileHandler.pattern = ${APP_HOME}/logs-%tY%tm/log-%tY%tm%td.log
|
||||
#java.util.logging.FileHandler.unusual 属性表示将 WARNING、SEVERE 级别的日志复制写入单独的文件中
|
||||
java.util.logging.FileHandler.unusual = ${APP_HOME}/logs-%tY%tm/log-warnerr-%tY%tm%td.log
|
||||
#需要屏蔽消息内容的正则表达式
|
||||
java.util.logging.FileHandler.denyregx =
|
||||
java.util.logging.FileHandler.append = true
|
||||
|
||||
#java.util.logging.ConsoleHandler.level = FINE
|
||||
|
||||
#将日志写进SearchSource, 必须指定source资源名,在source.properties中定义
|
||||
#java.util.logging.SearchHandler.source = platfsearch
|
||||
#指定写进SearchSource的表名,默认值为log-record
|
||||
#java.util.logging.SearchHandler.tag = log-${APP_NAME}-%tY%tm%td
|
||||
```
|
||||
|
||||
# yaml配置:
|
||||
  application和source的配置文件支持yaml格式,需要依赖第三方包, 默认的yaml配置文件名为 application.yml、source.yml。
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.redkalex</groupId>
|
||||
<artifactId>redkale-plugins</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
```
|
||||
442
docs/convert.md
Normal file
442
docs/convert.md
Normal file
@@ -0,0 +1,442 @@
|
||||
# 序列化
|
||||
  Convert提供Java对象的序列化与反序列化功能。支持JSON、PROTOBUF两种格式化。 两种格式使用方式完全一样,其性能都大幅度超过其他JSON框架。同时JSON内置于HTTP服务中,PROTOBUF也是SNCP协议数据序列化的基础。
|
||||
## 基本API
|
||||
  JSON序列化其操作类主要是JsonConvert,配置类主要是JsonFactory、ConvertColumn。JsonFactory采用同ClassLoader类似的双亲委托方式设计。
|
||||
JsonConvert 序列化encode方法:
|
||||
```java
|
||||
public String convertTo(Object value);
|
||||
|
||||
public String convertTo(Type type, Object value);
|
||||
|
||||
public byte[] convertToBytes(Type type, Object value);
|
||||
|
||||
public void convertTo(OutputStream out, Type type, Object value);
|
||||
|
||||
public ByteBuffer[] convertTo(Supplier<ByteBuffer> supplier, Type type, Object value);
|
||||
|
||||
public void convertTo(JsonWriter writer, Type type, Object value);
|
||||
```
|
||||
JsonConvert 反序列化decode方法:
|
||||
```java
|
||||
public <T> T convertFrom(Type type, String text);
|
||||
|
||||
public <T> T convertFrom(Type type, InputStream in);
|
||||
|
||||
public <T> T convertFrom(Type type, ByteBuffer... buffers);
|
||||
|
||||
public <T> T convertFrom(Type type, JsonReader reader);
|
||||
|
||||
public Object[] convertFrom(Type[] types, String text);
|
||||
|
||||
// 返回非null的值是由String、ArrayList、HashMap任意组合的对象
|
||||
public <V> V convertFrom(final String text);
|
||||
|
||||
// 返回非null的值是由String、ArrayList、HashMap任意组合的对象
|
||||
public <V> V convertFrom(final InputStream in);
|
||||
```
|
||||
## JSON基本用法
|
||||
```java
|
||||
@Data
|
||||
public class UserRecord {
|
||||
|
||||
private int userid;
|
||||
|
||||
private String username = "";
|
||||
|
||||
private String password = "";
|
||||
|
||||
public UserRecord() {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
UserRecord user = new UserRecord();
|
||||
user.setUserid(100);
|
||||
user.setUsername("redkalename");
|
||||
user.setPassword("123456");
|
||||
final JsonConvert convert = JsonConvert.root();
|
||||
String json = convert.convertTo(user);
|
||||
System.out.println(json); //应该是 {"password":"123456","userid":100,"username":"redkalename"}
|
||||
UserRecord user2 = convert.convertFrom(UserRecord.class, json);
|
||||
//应该也是 {"password":"123456","userid":100,"username":"redkalename"}
|
||||
System.out.println(convert.convertTo(user2));
|
||||
|
||||
/**
|
||||
* 以下功能是为了屏蔽password字段。
|
||||
* 等价于 public String getPassword() 加上 @ConvertColumn :
|
||||
*
|
||||
* @ConvertColumn(ignore = true, type = ConvertType.JSON)
|
||||
* public String getPassword() {
|
||||
* return password;
|
||||
* }
|
||||
**/
|
||||
final JsonFactory childFactory = JsonFactory.root().createChild();
|
||||
childFactory.register(UserRecord.class, true, "password"); //屏蔽掉password字段使其不输出
|
||||
childFactory.reloadCoder(UserRecord.class); //重新加载Coder使之覆盖父Factory的配置
|
||||
final JsonConvert childConvert = childFactory.getConvert();
|
||||
json = childConvert.convertTo(user);
|
||||
System.out.println(json); //应该是 {"userid":100,"username":"redkalename"}
|
||||
user2 = childConvert.convertFrom(UserRecord.class, json);
|
||||
//应该也是 {"userid":100,"username":"redkalename"}
|
||||
System.out.println(childConvert.convertTo(user2));
|
||||
}
|
||||
```
|
||||
  在Redkale里存在默认的JsonConvert、ProtobufConvert对象。 只需在所有Service、Servlet中增加依赖注入资源。
|
||||
```java
|
||||
public class XXXService implements Service {
|
||||
|
||||
@Resource
|
||||
private JsonConvert jsonConvert;
|
||||
|
||||
@Resource
|
||||
private ProtobufConvert protobufConvert;
|
||||
}
|
||||
|
||||
public class XXXServlet extends HttpServlet {
|
||||
|
||||
@Resource
|
||||
private JsonConvert jsonConvert;
|
||||
|
||||
@Resource
|
||||
private ProtobufConvert protobufConvert;
|
||||
|
||||
}
|
||||
```
|
||||
   同一类型数据通过设置新的JsonFactory可以有不同的输出。
|
||||
```java
|
||||
@Data
|
||||
public class UserSimpleInfo {
|
||||
|
||||
private int userid;
|
||||
|
||||
private String username = "";
|
||||
|
||||
@ConvertColumn(ignore = true, type = ConvertType.JSON)
|
||||
private long regtime; //注册时间
|
||||
|
||||
@ConvertColumn(ignore = true, type = ConvertType.JSON)
|
||||
private String regaddr = ""; //注册IP
|
||||
|
||||
}
|
||||
|
||||
public class UserInfoServlet extends HttpBaseServlet {
|
||||
|
||||
@Resource
|
||||
private UserSerice service;
|
||||
|
||||
@Resource
|
||||
private JsonFactory jsonRootFactory;
|
||||
|
||||
@Resource
|
||||
private JsonConvert detailConvert;
|
||||
|
||||
@Override
|
||||
public void init(HttpContext context, AnyValue config) {
|
||||
final JsonFactory childFactory = jsonRootFactory.createChild();
|
||||
childFactory.register(UserSimpleInfo.class, false, "regtime", "regaddr"); //允许输出注册时间与注册地址
|
||||
childFactory.reloadCoder(UserSimpleInfo.class); //重新加载Coder使之覆盖父Factory的配置
|
||||
this.detailConvert = childFactory.getConvert();
|
||||
}
|
||||
|
||||
// 获取他人基本信息
|
||||
@HttpMapping(url = "/user/info/")
|
||||
public void info(HttpRequest req, HttpResponse resp) throws IOException {
|
||||
int userid = Integer.parseInt(req.getRequstURILastPath());
|
||||
UserSimpleInfo user = service.findUserInfo(userid);
|
||||
resp.finishJson(user); // 不包含用户的注册时间和注册地址字段信息
|
||||
}
|
||||
|
||||
//获取用户自己的信息
|
||||
@HttpMapping(url = "/user/myinfo")
|
||||
public void mydetail(HttpRequest req, HttpResponse resp) throws IOException {
|
||||
int userid = req.currentUser().getUserid(); //获取当前用户ID
|
||||
UserSimpleInfo user = service.findUserInfo(userid);
|
||||
resp.finishJson(detailConvert, user); // 包含用户的注册时间和注册地址字段信息
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
  Convert 支持带参数构造函数。
|
||||
|
||||
    1. public 带参数的构造函数加上 @ConstructorParameters 注解:
|
||||
```java
|
||||
public class UserRecord {
|
||||
|
||||
private int userid;
|
||||
|
||||
private String username = "";
|
||||
|
||||
private String password = "";
|
||||
|
||||
@ConstructorParameters({"userid", "username", "password"})
|
||||
public UserRecord(int userid, String username, String password) {
|
||||
this.userid = userid;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public int getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
}
|
||||
```
|
||||
    2. 自定义Creator:
|
||||
```java
|
||||
public class UserRecord {
|
||||
|
||||
private int userid;
|
||||
|
||||
private String username = "";
|
||||
|
||||
private String password = "";
|
||||
|
||||
UserRecord(int userid, String username, String password) {
|
||||
this.userid = userid;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public int getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义Creator方法。
|
||||
* 1) 方法名可以随意。
|
||||
* 2) 方法必须是static。
|
||||
* 3)方法的参数必须为空。
|
||||
* 4)方法的返回类型必须是Creator。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private static Creator<UserRecord> creator() {
|
||||
return new Creator<UserRecord>() {
|
||||
@Override
|
||||
@ConstructorParameters({"userid", "username", "password"}) //带参数的构造函数必须有ConstructorParameters注解
|
||||
public UserRecord create(Object... params) {
|
||||
int userid = (params[0] == null ? 0 : (Integer) params[0]);
|
||||
return new UserRecord(userid, (String) params[1], (String) params[2]);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
  通常JavaBean类默认有个public空参数的构造函数,因此大部分情况下不要自定义Creator,其实只要不是private的空参数构造函数Convert都能自动支持(其他的框架都仅支持public的构造函数),只有仅含private的构造函数才需要自定义Creator。带参数的构造函数就需要标记@ConstructorParameters,常见于Immutable Object。
|
||||
|
||||
## 自定义
|
||||
  Convert 支持自定义Decode、Encode。
|
||||
|
||||
    1. 通过ConvertFactory显式的注册:
|
||||
```java
|
||||
public class FileSimpleCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, File> {
|
||||
|
||||
public static final FileSimpleCoder instance = new FileSimpleCoder();
|
||||
|
||||
@Override
|
||||
public void convertTo(W out, File value) {
|
||||
out.writeString(value == null ? null : value.getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public File convertFrom(R in) {
|
||||
String path = in.readString();
|
||||
return path == null ? null : new File(path);
|
||||
}
|
||||
}
|
||||
|
||||
JsonFactory.root().register(File.class, FileSimpleCoder.instance);
|
||||
|
||||
ProtobufFactory.root().register(File.class, FileSimpleCoder.instance);
|
||||
```
|
||||
    2. 通过JavaBean类自定义静态方法自动加载:
|
||||
```java
|
||||
public class InnerCoderEntity {
|
||||
|
||||
private final String val;
|
||||
|
||||
private final int id;
|
||||
|
||||
private InnerCoderEntity(int id, String value) {
|
||||
this.id = id;
|
||||
this.val = value;
|
||||
}
|
||||
|
||||
public static InnerCoderEntity create(int id, String value) {
|
||||
return new InnerCoderEntity(id, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 该方法提供给Convert组件自动加载。
|
||||
* 1) 方法名可以随意。
|
||||
* 2) 方法必须是static
|
||||
* 3)方法的参数有且只能有一个, 且必须是org.redkale.convert.ConvertFactory或子类。
|
||||
* —3.1) 参数类型为org.redkale.convert.ConvertFactory 表示适合JSON,PROTOBUF。
|
||||
* —3.2) 参数类型为org.redkale.convert.json.JsonFactory 表示仅适合JSON。
|
||||
* —3.3) 参数类型为org.redkale.convert.pb.ProtobufFactory 表示仅适合PROTOBUF。
|
||||
* 4)方法的返回类型必须是 Decodeable/Encodeable/SimpledCoder
|
||||
* 若返回类型不是SimpledCoder, 就必须提供两个方法: 一个返回Decodeable 一个返回 Encodeable。
|
||||
*
|
||||
* @param factory
|
||||
* @return
|
||||
*/
|
||||
private static SimpledCoder<Reader, Writer, InnerCoderEntity> createConvertCoder(final ConvertFactory factory) {
|
||||
return new SimpledCoder<Reader, Writer, InnerCoderEntity>() {
|
||||
|
||||
//必须与EnMember[] 顺序一致
|
||||
private final DeMember[] deMembers = new DeMember[]{
|
||||
DeMember.create(factory, InnerCoderEntity.class, "id"),
|
||||
DeMember.create(factory, InnerCoderEntity.class, "val")};
|
||||
|
||||
//必须与DeMember[] 顺序一致
|
||||
private final EnMember[] enMembers = new EnMember[]{
|
||||
EnMember.create(factory, InnerCoderEntity.class, "id"),
|
||||
EnMember.create(factory, InnerCoderEntity.class, "val")};
|
||||
|
||||
@Override
|
||||
public void convertTo(Writer out, InnerCoderEntity value) {
|
||||
if (value == null) {
|
||||
out.writeObjectNull(InnerCoderEntity.class);
|
||||
return;
|
||||
}
|
||||
out.writeObjectB(value);
|
||||
for (EnMember member : enMembers) {
|
||||
out.writeObjectField(member, value);
|
||||
}
|
||||
out.writeObjectE(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InnerCoderEntity convertFrom(Reader in) {
|
||||
if (!in.readObjectB(this)) {
|
||||
return null;
|
||||
}
|
||||
int index = 0;
|
||||
final Object[] params = new Object[deMembers.length];
|
||||
while (in.hasNext()) {
|
||||
DeMember member = in.readFieldName(deMembers); //读取字段名
|
||||
in.readBlank(); //读取字段名与字段值之间的间隔符,JSON则是跳过冒号:
|
||||
if (member == null) {
|
||||
in.skipValue(); //跳过不存在的字段的值, 一般不会发生
|
||||
} else {
|
||||
params[index++] = member.read(in);
|
||||
}
|
||||
}
|
||||
in.readObjectE();
|
||||
return InnerCoderEntity.create(params[0] == null ? 0 : (Integer) params[0], (String) params[1]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getVal() {
|
||||
return val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonConvert.root().convertTo(this);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## RestConvert
|
||||
  ```@RestConvert```、```@RestConvertCoder```是针对```@RestService```接口进行自定义序列化注解
|
||||
```java
|
||||
@Data
|
||||
public class RestConvertItem {
|
||||
|
||||
private long createTime;
|
||||
|
||||
@ConvertColumn(ignore = true)
|
||||
private String aesKey;
|
||||
}
|
||||
|
||||
@Data
|
||||
public class RestConvertBean {
|
||||
|
||||
private int id;
|
||||
|
||||
private boolean enable;
|
||||
|
||||
private String name;
|
||||
|
||||
private RestConvertItem content;
|
||||
}
|
||||
|
||||
//将boolean类型值转换成0/1的int值
|
||||
public class RestConvertBoolCoder<R extends Reader, W extends Writer> extends SimpledCoder<R, W, Boolean> {
|
||||
|
||||
@Override
|
||||
public void convertTo(W out, Boolean value) {
|
||||
out.writeInt(value == null || !value ? 0 : 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean convertFrom(R in) {
|
||||
return in.readInt() == 1;
|
||||
}
|
||||
}
|
||||
|
||||
@RestService(name = "test", autoMapping = true)
|
||||
public class RestConvertService extends AbstractService {
|
||||
|
||||
//输出: {"content":{"createTime":100},"enable":true,"id":123,"name":"haha"}
|
||||
public RestConvertBean load1() {
|
||||
return createBean();
|
||||
}
|
||||
|
||||
//输出: {"content":{"aesKey":"keykey","createTime":100},"enable":true,"id":123,"name":"haha"}
|
||||
//aesKey字段也会被输出
|
||||
@RestConvert(type = RestConvertItem.class, skipIgnore = true)
|
||||
public RestConvertBean load2() {
|
||||
return createBean();
|
||||
}
|
||||
|
||||
//输出: {"id":123}
|
||||
//只输出id字段
|
||||
@RestConvert(type = RestConvertBean.class, onlyColumns = "id")
|
||||
public RestConvertBean load3() {
|
||||
return createBean();
|
||||
}
|
||||
|
||||
//输出: {"content":{"createTime":100},"enable":1,"id":123,"name":"haha"}
|
||||
//enable字段输出1,而不是true
|
||||
@RestConvertCoder(type = RestConvertBean.class, field = "enable", coder = RestConvertBoolCoder.class)
|
||||
public RestConvertBean load4() {
|
||||
return createBean();
|
||||
}
|
||||
|
||||
private RestConvertBean createBean() {
|
||||
RestConvertBean bean = new RestConvertBean();
|
||||
bean.setId(123);
|
||||
bean.setName("haha");
|
||||
bean.setEnable(true);
|
||||
RestConvertItem item = new RestConvertItem();
|
||||
item.setCreateTime(100);
|
||||
item.setAesKey("keykey");
|
||||
bean.setContent(item);
|
||||
return bean;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
195
docs/datasource.md
Normal file
195
docs/datasource.md
Normal file
@@ -0,0 +1,195 @@
|
||||
# DB数据源
|
||||
   DataSource是数据层操作的抽象接口,不仅用于关系型数据库,还支持内存、Mongodb、ElasticSearch等数据源,redkale内置了内存版DataSource,官方扩展包```redkale-plugins```提供了Mongodb、ElasticSearch的实现。<br>
|
||||
   DataSource几乎所有操作都提供同步与异步两种方法,对性能要求高的可以采用异步方式,例如使用vertx实现的DataSqlSource。
|
||||
## 注解说明
|
||||
|注解类名 | 功能描述|
|
||||
| --- | --- |
|
||||
|@Column |标记字段,与JPA用法一致 |
|
||||
|@Entity |标记实体类,与JPA用法一致 |
|
||||
|@Id |标记主键字段,与JPA用法一致 |
|
||||
|@Table |标记表的别名,与JPA用法一致 |
|
||||
|@Transient |标记是否为表对应的字段,与JPA用法一致 |
|
||||
|@VirtualEntity |用于非数据库表对应的Entity类,且仅用于开启缓存模式的DataSource |
|
||||
|@DistributeTable |标记表进行分表分库存储, 与DistributeTableStrategy接口结合使用 |
|
||||
|@FilterColumn |用于FilterBean过滤类的字段设置 |
|
||||
|@FilterJoinColumn |用于FilterBean过滤类的关联表字段设置 |
|
||||
|@FilterGroup | 用于FilterBean过滤类的过滤条件分组设置 |
|
||||
|@FilterOrs | 用于FilterBean字段间的与或关系 |
|
||||
|
||||
## 操作方法
|
||||
|系列方法 | 功能描述|
|
||||
| --- | --- |
|
||||
|insert |插入实体 |
|
||||
|delete |删除实体 |
|
||||
|update |更新实体 |
|
||||
|updateColumn |更新数据的部分字段 |
|
||||
|find |查找单个对象 |
|
||||
|queryList |查询对象的List集合 |
|
||||
|querySheet |查询对象的Sheet页式集合 |
|
||||
|getNumberXXX |统计查询,用于查询字段的总和、最大值、平均值等数据 |
|
||||
|queryColumnXXX |单个字段数据查询和字段的统计查询 |
|
||||
|nativeXXX |直接运行SQL语句,用于复杂的关联查询与更新(仅限DataSqlSource) |
|
||||
|
||||
## 配置数据源
|
||||
```properties
|
||||
redkale.datasource.platf.url = jdbc:mysql://127.0.0.1:3306/platf?serverTimezone=UTC&characterEncoding=utf8
|
||||
redkale.datasource.platf.user = root
|
||||
redkale.datasource.platf.password = pwd123
|
||||
```
|
||||
|
||||
## pom依赖
|
||||
   使用jdbc驱动:
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<version>8.2.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
   异步场景可使用vertx-mysql-client实现, 需要依赖官方扩展包 ```redkale-plugins```:
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.redkalex</groupId>
|
||||
<artifactId>redkale-plugins</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-mysql-client</artifactId>
|
||||
<version>4.5.1</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
## 增删改查
|
||||
```java
|
||||
@Data
|
||||
@Table(name = "t_account")
|
||||
public class Account {
|
||||
//男
|
||||
public static final short GENDER_MALE = 1;
|
||||
|
||||
//女
|
||||
public static final short GENDER_FEMALE = 2;
|
||||
|
||||
@Id
|
||||
@Column(name = "account_id")
|
||||
private String accountid;
|
||||
|
||||
@Column(name = "account_name")
|
||||
private String accountName;
|
||||
|
||||
private int age;
|
||||
|
||||
private short gender;
|
||||
|
||||
private String remark;
|
||||
|
||||
@Column(name = "create_time", updatable = false)
|
||||
private long createTime;
|
||||
}
|
||||
```
|
||||
|
||||
  新增实体对象:
|
||||
```java
|
||||
@Resource(name = "platf")
|
||||
private DataSource source;
|
||||
|
||||
public void insertTest() {
|
||||
//新增单个
|
||||
Account account = new Account();
|
||||
account.setAccountid("account1");
|
||||
account.setAccountName("Hello");
|
||||
account.setCreateTime(System.currentTimeMillis());
|
||||
source.insert(account);
|
||||
|
||||
//异步新增多个
|
||||
Account a1 = new Account();
|
||||
a1.setAccountid("account1");
|
||||
a1.setAccountName("Hello1");
|
||||
a1.setCreateTime(System.currentTimeMillis());
|
||||
Account a2 = new Account();
|
||||
a2.setAccountid("account2");
|
||||
a2.setAccountName("Hello2");
|
||||
a2.setCreateTime(System.currentTimeMillis());
|
||||
source.insertAsync(a1, a2);
|
||||
}
|
||||
```
|
||||
|
||||
  删除实体:
|
||||
```java
|
||||
//根据主键值删除
|
||||
Account account = new Account();
|
||||
account.setAccountid("account1");
|
||||
source.delete(account);
|
||||
|
||||
//过滤删除, 删除16以下男生
|
||||
//等价sql: DELETE FROM t_account WHERE age < 16 AND gender = 1;
|
||||
source.delete(Account.class, FilterNodes.lt(Account::getAge, 16).and("gender", GENDER_MALE));
|
||||
```
|
||||
|
||||
  修改实体对象:
|
||||
```java
|
||||
//Lambda方式,根据主键更新单个字段
|
||||
source.updateColumn(Account.class, "account1", Account::getRemark, "新备注");
|
||||
|
||||
//Lambda方式,根据主键更新多个字段
|
||||
//等价sql: UPDATE t_account SET account_name='新名称', remark='新备注', age=age+2 WHERE account_id='account1';
|
||||
source.updateColumn(Account.class, "account1",
|
||||
ColumnValue.set(Account::getAccountName, "新名称"),
|
||||
ColumnValue.set(Account::getRemark, "新备注"),
|
||||
ColumnValue.inc(Account::getAge, 2)); //年龄+2
|
||||
|
||||
//根据主键更新多个字段
|
||||
Account account = new Account();
|
||||
account.setAccountid("account1");
|
||||
account.setAccountName("新名称");
|
||||
account.setRemark("新备注");
|
||||
source.updateColumn(account, "accountName", "remark");
|
||||
//或者
|
||||
//等价sql: UPDATE t_account SET account_name='新名称', remark='新备注' WHERE account_id='account1';
|
||||
source.updateColumn(account, Account::getAccountName, Account::getRemark);
|
||||
|
||||
//根据主键更新整个对象
|
||||
Account one = new Account();
|
||||
one.setAccountid("account1");
|
||||
one.setAccountName("Hello1");
|
||||
one.setCreateTime(System.currentTimeMillis());
|
||||
source.update(one); //createTime不会被更新,因字段设置了@Column(updatable=false)
|
||||
|
||||
//过滤更新
|
||||
//等价sql: UPDATE t_account SET remark = '不满16岁是青少年' WHERE age < 16;
|
||||
source.updateColumn(Account.class, FilterNodes.lt(Account::getAge, 16),
|
||||
ColumnValue.set(Account::getRemark, "不满16岁是青少年"));
|
||||
```
|
||||
|
||||
  批量操作:
|
||||
```java
|
||||
Account a1 = new Account();
|
||||
a1.setAccountid("account1");
|
||||
a1.setAccountName("Hello1");
|
||||
a1.setCreateTime(System.currentTimeMillis());
|
||||
|
||||
//事务性批量操作
|
||||
DataBatch batch = DataBatch.create()
|
||||
.insert(a1)
|
||||
.updateColumn(Account.class, "account1", ColumnValue.set(Account::getRemark, "不满16岁是青少年"))
|
||||
.delete(Account.class, FilterNodes.lt(Account::getAge, 16).and("gender", GENDER_MALE));
|
||||
source.batch(batch);
|
||||
```
|
||||
|
||||
  查询实体对象:
|
||||
```java
|
||||
//主键查询
|
||||
//等价sql: SELECT * FROM t_account WHERE account_id = 'account1';
|
||||
Account account = source.find(Account.class, "account1");
|
||||
|
||||
//等价sql: SELECT * FROM t_account WHERE account_name = 'Hello' AND age = 18 LIMIT 1;
|
||||
Account one = source.find(Account.class, FilterNodes.eq(Account::getAccountName, "Hello").and(Account::getAge, 18));
|
||||
|
||||
//等价sql: SELECT * FROM t_account WHERE account_name = 'Hello' OR age = 18;
|
||||
FilterNode filter = FilterNodes.eq(Account::getAccountName, "Hello").or(Account::getAge, 18);
|
||||
List<Account> list = source.queryList(Account.class, filter);
|
||||
|
||||
```
|
||||
2
docs/faq.md
Normal file
2
docs/faq.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# FAQ
|
||||
文档完善中……
|
||||
1
docs/http.md
Normal file
1
docs/http.md
Normal file
@@ -0,0 +1 @@
|
||||
文档完善中……
|
||||
BIN
docs/images/hello-console.png
Normal file
BIN
docs/images/hello-console.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 86 KiB |
BIN
docs/images/home-dir.png
Normal file
BIN
docs/images/home-dir.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
BIN
docs/images/logo.png
Normal file
BIN
docs/images/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.9 KiB |
1
docs/locked.md
Normal file
1
docs/locked.md
Normal file
@@ -0,0 +1 @@
|
||||
文档完善中……
|
||||
40
docs/native-image.md
Normal file
40
docs/native-image.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# 使用native-image
|
||||
   Redkale支持GraalVM的native-image, 由于Redkale使用了大量的asm动态生成代码,而native-image不支持动态字节码,因此需要使用```redkale-maven-plugin```执行预编译,提前生成动态字节码进行打包。
|
||||
|
||||
## 安装GraalVM
|
||||
```
|
||||
下载地址: https://www.graalvm.org/downloads/
|
||||
```
|
||||
|
||||
## 安装native-image
|
||||
```
|
||||
install native-image
|
||||
```
|
||||
|
||||
## 配置pom
|
||||
```xml
|
||||
<plugin>
|
||||
<groupId>org.redkale.maven.plugins</groupId>
|
||||
<artifactId>redkale-maven-plugin</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<configuration>
|
||||
<nativeimageArgs>
|
||||
<arg>--no-fallback</arg>
|
||||
</nativeimageArgs>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>redkale-compile</id>
|
||||
<phase>process-classes</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
```
|
||||
|
||||
## native-image编译
|
||||
```
|
||||
native-image -H:+ReportExceptionStackTraces --report-unsupported-elements-at-runtime -jar xxx.jar
|
||||
```
|
||||
62
docs/quick-start.md
Normal file
62
docs/quick-start.md
Normal file
@@ -0,0 +1,62 @@
|
||||
|
||||
# 安装
|
||||
使用maven:
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.redkale</groupId>
|
||||
<artifactId>redkale</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
```
|
||||
如果工程需要用到Redis、Kafka、Elasticsearch、SQL模板、模板引擎等,可使用redkale的官方插件:
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.redkalex</groupId>
|
||||
<artifactId>redkale-plugins</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
# 创建工程
|
||||
在IDE中使用ant或maven方式创建工程,增加redkale的依赖。下载解压
|
||||
|
||||
  
|
||||
|
||||
并覆盖到工程目录下。
|
||||
* bin: 存放启动/关闭脚本(start.sh、shutdown.sh、redkale.sh等)
|
||||
* conf : 存放服务器所需配置文件:
|
||||
*    application.xml: 服务配置文件 (必需);
|
||||
*    logging.properties:日志配置文件 (可选);
|
||||
*    source.properties: 数据库配置文件 (可选);
|
||||
* lib : 存放服务所依赖jar
|
||||
* logs : logging.properties配置中默认的日志存放目录。
|
||||
|
||||
|
||||
# Hello World
|
||||
|
||||
演示工程, 编写HelloService:
|
||||
```java
|
||||
package org.redkalex.example;
|
||||
|
||||
import org.redkale.net.http.*;
|
||||
import org.redkale.service.Service;
|
||||
|
||||
@RestService(autoMapping = true)
|
||||
public class HelloService implements Service {
|
||||
|
||||
public String sayHello() {
|
||||
return "Hello World!";
|
||||
}
|
||||
|
||||
public String hi(String name) {
|
||||
return "Hi, " + name + "!";
|
||||
}
|
||||
}
|
||||
```
|
||||
运行结果:
|
||||
|
||||
  
|
||||
|
||||
# 进一步阅读
|
||||
* 详细的配置说明看[这里](config.md)。
|
||||
* 数据源[这里](source.md)
|
||||
85
docs/scheduled.md
Normal file
85
docs/scheduled.md
Normal file
@@ -0,0 +1,85 @@
|
||||
# 定时任务
|
||||
  @Scheduled注解在Service的方法上,实现对方法结果进行定时运行。方法必须是无参数或者```ScheduledEvent```参数。
|
||||
|
||||
## 属性说明
|
||||
|属性|默认值|说明|
|
||||
| --- | --- | --- |
|
||||
|name|未定义|名称, 可用于第三方实现的定时任务组件的key, 比如xxl-job的任务标识|
|
||||
|cron|未定义|cron表达式,也可以使用常量值: <br>  @yearly、@annually、@monthly、@weekly、<br>  @daily、@midnight、@hourly、@minutely <br>  @1m、@2m、@3m、@5m、@10m、@15m、@30m <br>  @1h、@2h、@3h、@6h <br>  ${env.scheduled.cron}: 读取系统配置项|
|
||||
|zone|未定义|时区,```cron```有值才有效, 例如: "Asia/Shanghai"|
|
||||
|fixedDelay|-1|延迟时间,负数为无效值,支持参数配置、乘法表达式和对象字段值 <br> 参数值支持方式:<br>  100: 设置数值 <br>  ${env.scheduled.fixedDelay}: 读取系统配置项 <br> 值大于0且fixedRate小于0则使用 ScheduledThreadPoolExecutor.scheduleWithFixedDelay |
|
||||
|fixedRate|-1|周期时间,负数为无效值,支持参数配置、乘法表达式和对象字段值 <br> 参数值支持方式:<br>  100: 设置数值 <br>  ${env.scheduled.fixedRate}: 读取系统配置项 <br> 值大于0且fixedRate小于0则使用 ScheduledThreadPoolExecutor.scheduleAtFixedRate |
|
||||
|initialDelay|-1|起始延迟时间,负数为无效值,支持参数配置、乘法表达式和对象字段值 <br> 参数值支持方式:<br>  100: 设置数值 <br>  ${env.scheduled.initialDelay}: 读取系统配置项 <br> 值大于0且fixedRate和fixedDelay小于0则使用 ScheduledThreadPoolExecutor.schedule |
|
||||
|timeUnit|```TimeUnit.SECONDS```|时间单位TimeUnit|
|
||||
|comment|未定义|备注描述|
|
||||
|mode|```LoadMode.LOCAL```|作用于Service模式,默认值为:LOCAL,<br> LOCAL: 表示远程模式的Service对象中的定时任务不起作用|
|
||||
|
||||
## 基本用法
|
||||
  每秒执行
|
||||
```java
|
||||
@Scheduled(cron = "0/1 * * * * ?")
|
||||
public void task1() {
|
||||
System.out.println(Times.nowMillis() + "执行一次");
|
||||
}
|
||||
```
|
||||
|
||||
  <b>数值配置</b>, 系统启动后延迟10分钟后每60分钟执行一次,
|
||||
```java
|
||||
@Scheduled(fixedDelay = "10", fixedRate = "60", timeUnit = TimeUnit.MINUTES)
|
||||
private void task3() {
|
||||
System.out.println(Times.nowMillis() + "执行一次");
|
||||
}
|
||||
```
|
||||
|
||||
  <b>环境配置</b>, 定时间隔时间由环境变量```env.scheduled.fixedRate```配置,没配置采用默认值60秒)
|
||||
```java
|
||||
@Scheduled(fixedRate = "${env.scheduled.fixedRate:60}")
|
||||
public String task2() {
|
||||
System.out.println(Times.nowMillis() + "执行一次");
|
||||
return "";
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## 基本配置
|
||||
```xml
|
||||
<!--
|
||||
全局Serivce的定时任务设置,没配置该节点将自动创建一个。
|
||||
enabled: 是否开启缓存功能。默认: true
|
||||
-->
|
||||
<scheduled enabled="true"/>
|
||||
```
|
||||
|
||||
|
||||
## 使用Xxl-Job
|
||||
  Scheduled可以采用第三方实现, 官方扩展包```redkale-plugins```提供了xxl-job实现,且不依赖xxl-job包。
|
||||
|
||||
### pom依赖
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.redkalex</groupId>
|
||||
<artifactId>redkale-plugins</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
### 配置文件
|
||||
```xml
|
||||
<scheduled enabled="true">
|
||||
<xxljob addresses="http://localhost:8080/xxl-job-admin"
|
||||
executorName="redkale-examples"
|
||||
ip="127.0.0.1" <!-- 可选 -->
|
||||
port="5678" <!-- 可选 -->
|
||||
accessToken="default_token" />
|
||||
</scheduled>
|
||||
```
|
||||
|
||||
### 使用方法
|
||||
```java
|
||||
@Scheduled(name = "testTask")
|
||||
public void runTask(ScheduledEvent event) {
|
||||
System.out.println("xxl-job参数param: " + event.getString("param"));
|
||||
System.out.println("xxl-job参数index: " + event.getInteger("index"));
|
||||
System.out.println("xxl-job参数total: " + event.getInteger("total"));
|
||||
}
|
||||
```
|
||||
64
docs/service.md
Normal file
64
docs/service.md
Normal file
@@ -0,0 +1,64 @@
|
||||
# Service组件
|
||||
  Service是Redkale最核心的组件,主要处理业务逻辑和操作数据层。Service实例分两种模式: <b>本地模式</b>和<b>远程模式</b>。其模式由```conf/application.xml```文件来配置。开发人员在调用过程中通常不需要区分Service实例是哪种模式。 <br/>
|
||||
  并不是Sevice都能进行本地和远程模式切换, 以下情况的Service不能转成远程模式:
|
||||
     1、类被修饰为```final``` <br>
|
||||
     2、类被标记```@Local``` <br>
|
||||
     3、类被标记```@Component``` <br>
|
||||
|
||||
  Redkale进程启动时扫描可加载的Service实现类,根据配置文件配置的模式采用```ASM```技术动态生成相应的Service临时类进行实例化,并注册到ResourceFactory同其他Service、Servlet依赖注入。
|
||||
|
||||
## Service使用类型
|
||||
|类型|使用注解|场景说明|
|
||||
| --- | --- | --- |
|
||||
|默认加载|```@AutoLoad```或无注解|默认的Service会自动加载并初始化,且会自动生成对应协议层Servlet|
|
||||
|依赖加载|```@AutoLoad(false)```|此类Service只有被其他服务依赖或者显式的配置时才会被初始化,<br> 主要用于工具类功能服务, <br> 比如```DataSource```、```CacheSource```|
|
||||
|本地模式|```@Local```|此类Service无论配不配成远程模式,都不会转成远程模式,<br>主要用于功能依赖本地环境或者参数无法序列化的服务|
|
||||
|组件模式|```@Component```|此类Service不会被动态生成协议层Servlet,<br>主要用于无需提供对进程外提供接口的服务,<br> 比如```DataSource```、```CacheSource```的实现|
|
||||
# 用法
|
||||
```java
|
||||
@RestService(comment = "用户服务模块")
|
||||
public class UserService implements Service {
|
||||
|
||||
@Resource(name = "platf")
|
||||
private DataSource source;
|
||||
|
||||
//请求url: /user/updatePwd?bean={}
|
||||
@RestMapping(auth = true, methods = "POST", comment = "更改密码(只能POST请求)")
|
||||
public RetResult<String> updatePwd(@RestUserid long userid, UserPwdBean bean) {
|
||||
//逻辑处理
|
||||
return RetResult.success();
|
||||
}
|
||||
|
||||
//请求url: /user/updateIntro?intro=xxx
|
||||
@RestMapping(auth = true, comment = "更新用户介绍")
|
||||
public RetResult<String> updateIntro(@RestUserid long userid, String intro) {
|
||||
intro = Utility.orElse(intro, ""); //为null则用""
|
||||
//更新数据库
|
||||
source.updateColumn(UserDetail.class, userid, UserDetail::getIntro, intro);
|
||||
return RetResult.success();
|
||||
}
|
||||
|
||||
//请求url: /user/updateGender?gender=1
|
||||
@RestMapping(auth = true, comment = "修改用户性别(异步方法)")
|
||||
public CompletableFuture<RetResult<String>> updateGender(@RestUserid long userid, short gender) {
|
||||
if (gender != GENDER_MALE && gender != GENDER_FEMALE) {
|
||||
return RetCodes.retResultFuture(RET_USER_GENDER_ILLEGAL);
|
||||
}
|
||||
//更新数据库
|
||||
return source.updateColumnAsync(UserDetail.class, userid, UserDetail::getGender, gender)
|
||||
.thenApply(v -> RetResult.success());
|
||||
}
|
||||
}
|
||||
```
|
||||
  ```@RestUserid int userid```为当前用户Id, 值是在BaseServlet里进行设置,userid可以是String、long、int类型。
|
||||
|
||||
## 远程模式Service
|
||||
  远程Servie其实是提供RPC接口,需要配置文件中显式配置才可使用远程模式。
|
||||
```xml
|
||||
<group name="remote-A" nodes="192.168.10.11:6060,192.168.10.22:7070"/>
|
||||
|
||||
<server protocol="HTTP" host="0.0.0.0" port="8080">
|
||||
<services autoload="true" group="remote-A"/>
|
||||
<service name="" value="org.redkale.demo.user.UserService" group="remote-A"/>
|
||||
</server>
|
||||
```
|
||||
1
docs/sncp.md
Normal file
1
docs/sncp.md
Normal file
@@ -0,0 +1 @@
|
||||
文档完善中……
|
||||
108
docs/sqlsource.md
Normal file
108
docs/sqlsource.md
Normal file
@@ -0,0 +1,108 @@
|
||||
# DataSqlSource数据源
|
||||
  ```DataSqlSource```是```DataSource```的SQL扩展类,增强了对原生SQL的操作。
|
||||
|
||||
## SQL模板
|
||||
  Redkale中的SQL模板与Mybatis里的SQL模板用法类似, 最大区别在于不需要写很多```if/else```判断语句,也不用写xml文件, 框架会根据参数存在与否动态生成sql语句, 查询结果时下划线式sql字段名和驼峰式类字段名会自动匹配。
|
||||
```sql
|
||||
SELECT * FROM user WHERE user_id IN #{bean.userIds} OR user_name = #{bean.userName}
|
||||
```
|
||||
  当bean.userIds=null,bean.userName='hello'时,sql语句转换成:
|
||||
```sql
|
||||
SELECT * FROM user WHERE user_name = 'hello'
|
||||
```
|
||||
  当bean.userIds=[1,2,3],bean.userName=null时,sql语句转换成:
|
||||
```sql
|
||||
SELECT * FROM user WHERE user_id IN (1,2,3)
|
||||
```
|
||||
  IN或者NOT IN语句当参数不为null而是空数组或者空List会进行特殊处理,IN语句会转化成```1=1```, NOT IN语句会转化成```1=2```。 当bean.userIds=空数组,bean.userName='hello'时,sql语句转换成:
|
||||
```sql
|
||||
SELECT * FROM user WHERE 1=2 OR user_name = 'hello'
|
||||
```
|
||||
  参数支持默认值,用逗号隔开,非String参数类型主要指定数据类型,目前支持(int)、(long)、(short)、(float)、(double), 参数不存在会使用默认值aaa:
|
||||
```sql
|
||||
DELETE FROM user WHERE user_name = #{bean.userName,aaa}
|
||||
```
|
||||
  IN参数也支持默认值:
|
||||
```sql
|
||||
DELETE FROM user WHERE type IN #{types,(1, 2, 3)}
|
||||
DELETE FROM user WHERE type IN (1, 2, #{type, (int)3})
|
||||
DELETE FROM user WHERE user_name IN #{name, ('aa','bb','cc')}
|
||||
DELETE FROM user WHERE user_name ('aa', 'bb', #{type,cc})
|
||||
```
|
||||
  有些场景要求参数是必需的,就需要使用##{}来校验参数是否必需。
|
||||
```sql
|
||||
DELETE FROM user WHERE user_name = ##{bean.userName}
|
||||
```
|
||||
  当bean=null或者bean.userName=null时,执行sql会报错 ```Missing parameter bean.userName```
|
||||
|
||||
  Service调用原生SQL模板示例:
|
||||
```java
|
||||
public class ForumInfoService extends AbstractService {
|
||||
|
||||
//查询单个记录的sql
|
||||
private static final String findSql = "SELECT f.forum_groupid, s.forum_section_color "
|
||||
+ "FROM forum_info f, forum_section s "
|
||||
+ " WHERE f.forumid = s.forumid AND "
|
||||
+ "s.forum_sectionid = #{bean.forumSectionid} AND "
|
||||
+ "f.forumid = #{bean.forumid} AND s.forum_section_color = #{bean.forumSectionColor}";
|
||||
|
||||
//查询列表记录的sql
|
||||
private static final String querySql = "SELECT f.forum_groupid, s.forum_section_color "
|
||||
+ "FROM forum_info f, forum_section s "
|
||||
+ " WHERE f.forumid = s.forumid AND "
|
||||
+ "s.forum_sectionid = #{bean.forumSectionid} AND "
|
||||
+ "f.forumid = #{bean.forumid} AND s.forum_section_color = #{bean.forumSectionColor}";
|
||||
|
||||
@Resource
|
||||
private DataSqlSource source;
|
||||
|
||||
public ForumResult findForumResultOne(ForumBean bean) {
|
||||
return source.nativeQueryOne(ForumResult.class, findSql, Map.of("bean", bean));
|
||||
}
|
||||
|
||||
public CompletableFuture<List<ForumResult>> queryForumResultListAsync(ForumBean bean) {
|
||||
return source.nativeQueryListAsync(ForumResult.class, querySql, Map.of("bean", bean));
|
||||
}
|
||||
|
||||
//翻页查询
|
||||
public Sheet<ForumResult> queryForumResult(RowBound bound, ForumBean bean){
|
||||
return source.nativeQuerySheet(ForumResult.class, querySql, round, Map.of("bean", bean));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## DataSqlMapper
|
||||
  DataSqlMapper与MyBatis里的Mapper用法类似,且都支持异步方法。
|
||||
```java
|
||||
public interface ForumInfoMapper extends BaseMapper<ForumInfo> {
|
||||
|
||||
@Sql("SELECT f.forum_groupid, s.forum_section_color "
|
||||
+ "FROM forum_info f, forum_section s "
|
||||
+ "WHERE f.forumid = s.forumid "
|
||||
+ "AND s.forum_sectionid = #{bean.forumSectionid} "
|
||||
+ "AND f.forumid = #{bean.forumid} "
|
||||
+ "AND s.forum_section_color = #{bean.forumSectionColor}")
|
||||
public ForumResult findForumResultOne(ForumBean bean);
|
||||
|
||||
@Sql("SELECT f.forum_groupid, s.forum_section_color "
|
||||
+ "FROM forum_info f, forum_section s "
|
||||
+ "WHERE f.forumid = s.forumid AND "
|
||||
+ "s.forum_sectionid = #{bean.forumSectionid} "
|
||||
+ "AND f.forumid = #{bean.forumid} "
|
||||
+ "AND s.forum_section_color = #{bean.forumSectionColor}")
|
||||
public CompletableFuture<ForumResult> findForumResultOneAsync(ForumBean bean);
|
||||
|
||||
//翻页查询
|
||||
@Sql("SELECT f.forum_groupid, s.forum_section_color "
|
||||
+ "FROM forum_info f, forum_section s "
|
||||
+ " WHERE f.forumid = s.forumid AND "
|
||||
+ "s.forum_sectionid = #{bean.forumSectionid} AND "
|
||||
+ "f.forumid = #{bean.forumid} AND s.forum_section_color = #{bean.forumSectionColor}")
|
||||
public Sheet<ForumResult> queryForumResult(RowBound bound, ForumBean bean);
|
||||
|
||||
@Sql("UPDATE forum_section s "
|
||||
+ " SET s.forum_sectionid = '' "
|
||||
+ " WHERE s.forum_section_color = ##{bean.forumSectionColor}")
|
||||
public int updateForumResult(@Param("bean") ForumBean bean0);
|
||||
}
|
||||
```
|
||||
1
docs/watch.md
Normal file
1
docs/watch.md
Normal file
@@ -0,0 +1 @@
|
||||
文档完善中……
|
||||
1
docs/websocket.md
Normal file
1
docs/websocket.md
Normal file
@@ -0,0 +1 @@
|
||||
文档完善中……
|
||||
196
my/pom.xml
196
my/pom.xml
@@ -1,35 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.redkale</groupId>
|
||||
<artifactId>redkale</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>RedkaleProject</name>
|
||||
<url>http://redkale.org</url>
|
||||
<url>https://redkale.org</url>
|
||||
<description>redkale -- java framework</description>
|
||||
<version>2.7.0-SNAPSHOT</version>
|
||||
<version>2.8.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
|
||||
<junit.version>5.7.0</junit.version>
|
||||
<maven-plugin.version>3.2.0</maven-plugin.version>
|
||||
<maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version>
|
||||
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
|
||||
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
|
||||
<maven-failsafe-plugin.version>3.0.0-M5</maven-failsafe-plugin.version>
|
||||
|
||||
<junit.version>5.9.0</junit.version>
|
||||
<maven-jar-plugin.version>3.4.0</maven-jar-plugin.version>
|
||||
<maven-gpg-plugin.version>3.2.4</maven-gpg-plugin.version>
|
||||
<maven-source-plugin.version>3.2.0</maven-source-plugin.version>
|
||||
<maven-assembly-plugin.version>3.7.0</maven-assembly-plugin.version>
|
||||
<nexus-staging-plugin.version>1.7.0</nexus-staging-plugin.version>
|
||||
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
|
||||
<maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
|
||||
<maven-failsafe-plugin.version>3.2.5</maven-failsafe-plugin.version>
|
||||
<spotless-maven-plugin.version>2.43.0</spotless-maven-plugin.version>
|
||||
<palantir-java-format.version>2.46.0</palantir-java-format.version>
|
||||
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
@@ -40,6 +38,28 @@
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>central</id>
|
||||
<name>Central Repository</name>
|
||||
<url>https://repo.maven.apache.org/maven2</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype-nexus-snapshots</id>
|
||||
<name>Sonatype Nexus Snapshots</name>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<id>Redkale</id>
|
||||
@@ -58,16 +78,16 @@
|
||||
<timezone>8</timezone>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<scm>
|
||||
@@ -75,36 +95,71 @@
|
||||
<connection>scm:git:git@github.com/redkale/redkale.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:redkale/redkale.git</developerConnection>
|
||||
</scm>
|
||||
|
||||
|
||||
<issueManagement>
|
||||
<system>GitHub Issues</system>
|
||||
<url>https://github.com/redkale/redkale/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<compilerArgument>-parameters</compilerArgument>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<compilerArguments>
|
||||
<verbose />
|
||||
</compilerArguments>
|
||||
</configuration>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- 需要注释掉, 否则会生成native-image配置信息
|
||||
<plugin>
|
||||
<groupId>org.redkale.maven.plugins</groupId>
|
||||
<artifactId>redkale-maven-plugin</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>redkale-compile</id>
|
||||
<phase>process-classes</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
-->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>${maven-plugin.version}</version>
|
||||
<version>${maven-jar-plugin.version}</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<addMavenDescriptor>false</addMavenDescriptor>
|
||||
<addMavenDescriptor>false</addMavenDescriptor>
|
||||
<manifest>
|
||||
<mainClass>org.redkale.boot.Application</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
<configuration>
|
||||
<forkMode>once</forkMode>
|
||||
<argLine>-Dfile.encoding=UTF-8</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>${maven-failsafe-plugin.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
@@ -116,6 +171,9 @@
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<signer>bc</signer>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
@@ -123,7 +181,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>${maven-plugin.version}</version>
|
||||
<version>${maven-source-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@@ -132,11 +190,11 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>${maven-plugin.version}</version>
|
||||
<version>${maven-source-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
@@ -144,16 +202,16 @@
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>${maven-plugin.version}</version>
|
||||
<version>${maven-assembly-plugin.version}</version>
|
||||
<configuration>
|
||||
<appendAssemblyId>false</appendAssemblyId>
|
||||
<descriptors>
|
||||
<descriptor>assembly.xml</descriptor>
|
||||
<descriptor>my/assembly.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
@@ -166,8 +224,56 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>${nexus-staging-plugin.version}</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId>
|
||||
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.diffplug.spotless</groupId>
|
||||
<artifactId>spotless-maven-plugin</artifactId>
|
||||
<version>${spotless-maven-plugin.version}</version>
|
||||
<configuration>
|
||||
<lineEndings>UNIX</lineEndings>
|
||||
<formats>
|
||||
<format>
|
||||
<includes>
|
||||
<include>src/**/java/**/*.java</include>
|
||||
</includes>
|
||||
<trimTrailingWhitespace/>
|
||||
<endWithNewline/>
|
||||
<indent>
|
||||
<spaces>true</spaces>
|
||||
<spacesPerTab>4</spacesPerTab>
|
||||
</indent>
|
||||
</format>
|
||||
</formats>
|
||||
<java>
|
||||
<palantirJavaFormat>
|
||||
<version>${palantir-java-format.version}</version>
|
||||
<style>PALANTIR</style>
|
||||
<formatJavadoc>true</formatJavadoc>
|
||||
</palantirJavaFormat>
|
||||
</java>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
<phase>compile</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
||||
76
pom.xml
76
pom.xml
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.redkale</groupId>
|
||||
<artifactId>redkale</artifactId>
|
||||
@@ -7,18 +8,22 @@
|
||||
<name>RedkaleProject</name>
|
||||
<url>https://redkale.org</url>
|
||||
<description>redkale -- java framework</description>
|
||||
<version>2.7.0</version>
|
||||
<version>2.8.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
|
||||
<junit.version>5.7.0</junit.version>
|
||||
<maven-jar-plugin.version>3.2.2</maven-jar-plugin.version>
|
||||
<maven-compiler-plugin.version>3.9.0</maven-compiler-plugin.version>
|
||||
<maven-surefire-plugin.version>3.0.0-M6</maven-surefire-plugin.version>
|
||||
<maven-failsafe-plugin.version>3.0.0-M6</maven-failsafe-plugin.version>
|
||||
<junit.version>5.9.0</junit.version>
|
||||
<jmh.version>1.37</jmh.version>
|
||||
<maven-jar-plugin.version>3.4.0</maven-jar-plugin.version>
|
||||
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
|
||||
<maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
|
||||
<maven-failsafe-plugin.version>3.2.5</maven-failsafe-plugin.version>
|
||||
<spotless-maven-plugin.version>2.43.0</spotless-maven-plugin.version>
|
||||
<palantir-java-format.version>2.46.0</palantir-java-format.version>
|
||||
|
||||
</properties>
|
||||
|
||||
<licenses>
|
||||
@@ -36,7 +41,19 @@
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-core</artifactId>
|
||||
<version>${jmh.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-generator-annprocess</artifactId>
|
||||
<version>${jmh.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
@@ -76,7 +93,7 @@
|
||||
<connection>scm:git:git@github.com/redkale/redkale.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:redkale/redkale.git</developerConnection>
|
||||
</scm>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
@@ -91,7 +108,7 @@
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- 需要注释掉, 否则会生成native-image配置信息
|
||||
<!-- must commented, otherwise native-image information will be generated
|
||||
<plugin>
|
||||
<groupId>org.redkale.maven.plugins</groupId>
|
||||
<artifactId>redkale-maven-plugin</artifactId>
|
||||
@@ -136,7 +153,44 @@
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>${maven-failsafe-plugin.version}</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.diffplug.spotless</groupId>
|
||||
<artifactId>spotless-maven-plugin</artifactId>
|
||||
<version>${spotless-maven-plugin.version}</version>
|
||||
<configuration>
|
||||
<lineEndings>UNIX</lineEndings>
|
||||
<formats>
|
||||
<format>
|
||||
<includes>
|
||||
<include>src/**/java/**/*.java</include>
|
||||
</includes>
|
||||
<trimTrailingWhitespace/>
|
||||
<endWithNewline/>
|
||||
<indent>
|
||||
<spaces>true</spaces>
|
||||
<spacesPerTab>4</spacesPerTab>
|
||||
</indent>
|
||||
</format>
|
||||
</formats>
|
||||
<java>
|
||||
<palantirJavaFormat>
|
||||
<version>${palantir-java-format.version}</version>
|
||||
<style>PALANTIR</style>
|
||||
<formatJavadoc>true</formatJavadoc>
|
||||
</palantirJavaFormat>
|
||||
</java>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
<phase>compile</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
||||
@@ -1,110 +1,110 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8"><title>接口文档(apidoc生成)</title>
|
||||
<style type="text/css">
|
||||
body {text-align: center;margin:auto;}
|
||||
a{text-decoration: none;}
|
||||
.table {margin: auto;border-collapse: collapse;border-spacing: 0;display: block;width: 100%;overflow: auto;word-break: normal;word-break: keep-all;}
|
||||
.table td,.table th{padding: 0.2rem 0.8rem 0.2rem 0.8rem;border: 1px solid #aaa;}
|
||||
.table td {text-align: left;}
|
||||
.s {font-size: 0.8rem; vertical-align: middle;}
|
||||
.subtable {border-spacing: 0;border: 0;margin:0;}
|
||||
.subtable td{border: 0;padding: 0 0 0 10px;}
|
||||
.typetable {border-spacing: 0;border: 0;margin:0;}
|
||||
.typetable td{border: 0;padding: 2px 20px 2px 10px;}
|
||||
.typetable .l{border-bottom: 1px solid red;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<head>
|
||||
<meta charset="UTF-8"><title>接口文档(apidoc生成)</title>
|
||||
<style type="text/css">
|
||||
body {text-align: center;margin:auto;}
|
||||
a{text-decoration: none;}
|
||||
.table {margin: auto;border-collapse: collapse;border-spacing: 0;display: block;width: 100%;overflow: auto;word-break: normal;word-break: keep-all;}
|
||||
.table td,.table th{padding: 0.2rem 0.8rem 0.2rem 0.8rem;border: 1px solid #aaa;}
|
||||
.table td {text-align: left;}
|
||||
.s {font-size: 0.8rem; vertical-align: middle;}
|
||||
.subtable {border-spacing: 0;border: 0;margin:0;}
|
||||
.subtable td{border: 0;padding: 0 0 0 10px;}
|
||||
.typetable {border-spacing: 0;border: 0;margin:0;}
|
||||
.typetable td{border: 0;padding: 2px 20px 2px 10px;}
|
||||
.typetable .l{border-bottom: 1px solid red;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script>
|
||||
var createhtml = function (jsoncontent) {
|
||||
var classmap = jsoncontent.types;
|
||||
var html = [];
|
||||
html.push('<div style="width:' + Math.floor(window.screen.width * 0.9) + 'px;margin:0 auto;text-align: center;">');
|
||||
html.push('<br/><br/><table class="table" align="center">');
|
||||
for (var i = 0; i < jsoncontent.servers.length; i++) {
|
||||
var servlets = jsoncontent.servers[i].servlets;
|
||||
if (servlets.length && (servlets[0].comment || "").indexOf("【") === 0) {
|
||||
servlets.sort(function (a, b) {
|
||||
return a.comment > b.comment ? -1 : (a.comment == b.comment ? 0 : 1);
|
||||
});
|
||||
}
|
||||
for (var j = 0; j < servlets.length; j++) {
|
||||
var servlet = servlets[j];
|
||||
if (html.length > 2) html.push(' <tr><th colspan="5" style="border-bottom:0;"> </th></tr>');
|
||||
html.push(' <tr><th colspan="5" style="border-top:' + ((html.length > 2) ? 0 : 1) + ';">' + (servlet.comment || '未知模块') + '</th></tr>');
|
||||
html.push(' <tr><th>请求URL</th><th>描 述</th><th>鉴 权</th><th>参 数 <span style="font-size:12px;">(粗体: 必填项; 红色: Header; 蓝色: Cookie)</span></th><th>输 出</th></tr>');
|
||||
for (var k = 0; k < servlet.mappings.length; k++) {
|
||||
var action = servlet.mappings[k];
|
||||
html.push(' <tr>');
|
||||
html.push('<td style="color:#ff00ff;">' + action.url + '</td>');
|
||||
html.push('<td>' + action.comment + '</td>');
|
||||
html.push('<td class="s" style="width:80px;">模块ID: ' + servlet.moduleid + '<br/>操作ID: ' + action.actionid + '<br/>需鉴权: ' + (action.auth ? '<font style="font-weight:bold;color:green;">true</font>' : '<font color=red>false</font>') + '</td>');
|
||||
var paramshtml = [];
|
||||
paramshtml.push('<table class="subtable">');
|
||||
for (var p = 0; p < action.params.length; p++) {
|
||||
var param = action.params[p];
|
||||
var t = param.type.substring(param.type.lastIndexOf('.') + 1);
|
||||
if (classmap[param.type.replace('[]', '')]) {
|
||||
t = '<a href="#' + param.type.replace('[]', '') + '">' + t + '</a>';
|
||||
}
|
||||
if (param.name == '&') {
|
||||
paramshtml.push('<tr><td style="font-size:12px;">内置 </td><td> ' + t + '</td><td> 当前用户</td></tr>');
|
||||
} else {
|
||||
var w = param.required ? "font-weight:bold;" : "";
|
||||
var c = ' style="' + w + '"';
|
||||
if (param.style == "HEADER") c = ' style="color:red;' + w + '"';
|
||||
if (param.style == "COOKIE") c = ' style="color:blue;' + w + '"';
|
||||
paramshtml.push('<tr><td ' + c + '> ' + param.name + ' </td><td> ' + t + '</td><td> ' + param.comment + '</td></tr>');
|
||||
}
|
||||
}
|
||||
paramshtml.push('</table>');
|
||||
html.push('<td class="s" style="padding:0 5px;">' + paramshtml.join('') + '</td>');
|
||||
var rs = [];
|
||||
rs.push(action.result.replace(/</g, "<").replace(/>/g, ">").replace(/([a-zA-Z0-9_\$]+\.)+/g, ""));
|
||||
var results = action.results || [];
|
||||
for (var r = 0; r < results.length; r++) {
|
||||
rs.push('<a href="#' + results[r].replace('[]', '') + '">' + results[r].replace(/([a-zA-Z0-9_\$]+\.)+/g, "") + '</a>');
|
||||
}
|
||||
html.push('<td>' + rs.join("<br/>") + '</td>');
|
||||
html.push('</tr>');
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var type in classmap) {
|
||||
html.push(' <tr><th colspan="5" style="border-bottom:0;"> </th></tr>');
|
||||
html.push(' <tr id="' + type + '"><th colspan="5" style="border-top:0;">' + type + '</th></tr>');
|
||||
html.push(' <tr><td colspan="5"><table class="typetable">');
|
||||
for (var fieldname in classmap[type]) {
|
||||
var field = classmap[type][fieldname];
|
||||
var t = field.type.replace(/</g, "<").replace(/>/g, ">").replace(/\$/g, ".").replace(/([a-zA-Z0-9_\$]+\.)+/g, "");
|
||||
if (t == 'boolean' || t == 'short' || t == 'int' || t == 'long' || t == 'float' || t == 'double'
|
||||
|| t == 'boolean[]' || t == 'short[]' || t == 'int[]' || t == 'long[]' || t == 'float[]' || t == 'double[]') {
|
||||
t = '<font color=blue>' + t + '</font>';
|
||||
} else if (t == 'String' || t == 'String[]' || t == 'LongRange' || t.indexOf('Map<') === 0) {
|
||||
t = '<font color=red>' + t + '</font>';
|
||||
}
|
||||
var c = (field.comment || '');
|
||||
if (field.primary) {
|
||||
c = '【主键】 ' + c;
|
||||
} else if (!field.updatable) {
|
||||
c = '【只读】 ' + c;
|
||||
}
|
||||
html.push(' <tr class="l"><td>' + fieldname + '</td><td>' + t + '</td><td colspan="2">' + c + '</td></tr>');
|
||||
}
|
||||
html.push(' </table></td></tr>');
|
||||
}
|
||||
html.push('</table><br/><br/><br/>');
|
||||
html.push('</div>');
|
||||
return html.join('');
|
||||
};
|
||||
</script>
|
||||
<script>
|
||||
var createhtml = function (jsoncontent) {
|
||||
var classmap = jsoncontent.types;
|
||||
var html = [];
|
||||
html.push('<div style="width:' + Math.floor(window.screen.width * 0.9) + 'px;margin:0 auto;text-align: center;">');
|
||||
html.push('<br/><br/><table class="table" align="center">');
|
||||
for (var i = 0; i < jsoncontent.servers.length; i++) {
|
||||
var servlets = jsoncontent.servers[i].servlets;
|
||||
if (servlets.length && (servlets[0].comment || "").indexOf("【") === 0) {
|
||||
servlets.sort(function (a, b) {
|
||||
return a.comment > b.comment ? -1 : (a.comment == b.comment ? 0 : 1);
|
||||
});
|
||||
}
|
||||
for (var j = 0; j < servlets.length; j++) {
|
||||
var servlet = servlets[j];
|
||||
if (html.length > 2) html.push(' <tr><th colspan="5" style="border-bottom:0;"> </th></tr>');
|
||||
html.push(' <tr><th colspan="5" style="border-top:' + ((html.length > 2) ? 0 : 1) + ';">' + (servlet.comment || '未知模块') + '</th></tr>');
|
||||
html.push(' <tr><th>请求URL</th><th>描 述</th><th>鉴 权</th><th>参 数 <span style="font-size:12px;">(粗体: 必填项; 红色: Header; 蓝色: Cookie)</span></th><th>输 出</th></tr>');
|
||||
for (var k = 0; k < servlet.mappings.length; k++) {
|
||||
var action = servlet.mappings[k];
|
||||
html.push(' <tr>');
|
||||
html.push('<td style="color:#ff00ff;">' + action.url + '</td>');
|
||||
html.push('<td>' + action.comment + '</td>');
|
||||
html.push('<td class="s" style="width:80px;">模块ID: ' + servlet.moduleid + '<br/>操作ID: ' + action.actionid + '<br/>需鉴权: ' + (action.auth ? '<font style="font-weight:bold;color:green;">true</font>' : '<font color=red>false</font>') + '</td>');
|
||||
var paramshtml = [];
|
||||
paramshtml.push('<table class="subtable">');
|
||||
for (var p = 0; p < action.params.length; p++) {
|
||||
var param = action.params[p];
|
||||
var t = param.type.substring(param.type.lastIndexOf('.') + 1);
|
||||
if (classmap[param.type.replace('[]', '')]) {
|
||||
t = '<a href="#' + param.type.replace('[]', '') + '">' + t + '</a>';
|
||||
}
|
||||
if (param.name == '&') {
|
||||
paramshtml.push('<tr><td style="font-size:12px;">内置 </td><td> ' + t + '</td><td> 当前用户</td></tr>');
|
||||
} else {
|
||||
var w = param.required ? "font-weight:bold;" : "";
|
||||
var c = ' style="' + w + '"';
|
||||
if (param.style == "HEADER") c = ' style="color:red;' + w + '"';
|
||||
if (param.style == "COOKIE") c = ' style="color:blue;' + w + '"';
|
||||
paramshtml.push('<tr><td ' + c + '> ' + param.name + ' </td><td> ' + t + '</td><td> ' + param.comment + '</td></tr>');
|
||||
}
|
||||
}
|
||||
paramshtml.push('</table>');
|
||||
html.push('<td class="s" style="padding:0 5px;">' + paramshtml.join('') + '</td>');
|
||||
var rs = [];
|
||||
rs.push(action.result.replace(/</g, "<").replace(/>/g, ">").replace(/([a-zA-Z0-9_\$]+\.)+/g, ""));
|
||||
var results = action.results || [];
|
||||
for (var r = 0; r < results.length; r++) {
|
||||
rs.push('<a href="#' + results[r].replace('[]', '') + '">' + results[r].replace(/([a-zA-Z0-9_\$]+\.)+/g, "") + '</a>');
|
||||
}
|
||||
html.push('<td>' + rs.join("<br/>") + '</td>');
|
||||
html.push('</tr>');
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var type in classmap) {
|
||||
html.push(' <tr><th colspan="5" style="border-bottom:0;"> </th></tr>');
|
||||
html.push(' <tr id="' + type + '"><th colspan="5" style="border-top:0;">' + type + '</th></tr>');
|
||||
html.push(' <tr><td colspan="5"><table class="typetable">');
|
||||
for (var fieldname in classmap[type]) {
|
||||
var field = classmap[type][fieldname];
|
||||
var t = field.type.replace(/</g, "<").replace(/>/g, ">").replace(/\$/g, ".").replace(/([a-zA-Z0-9_\$]+\.)+/g, "");
|
||||
if (t == 'boolean' || t == 'short' || t == 'int' || t == 'long' || t == 'float' || t == 'double'
|
||||
|| t == 'boolean[]' || t == 'short[]' || t == 'int[]' || t == 'long[]' || t == 'float[]' || t == 'double[]') {
|
||||
t = '<font color=blue>' + t + '</font>';
|
||||
} else if (t == 'String' || t == 'String[]' || t == 'LongRange' || t.indexOf('Map<') === 0) {
|
||||
t = '<font color=red>' + t + '</font>';
|
||||
}
|
||||
var c = (field.comment || '');
|
||||
if (field.primary) {
|
||||
c = '【主键】 ' + c;
|
||||
} else if (!field.updatable) {
|
||||
c = '【只读】 ' + c;
|
||||
}
|
||||
html.push(' <tr class="l"><td>' + fieldname + '</td><td>' + t + '</td><td colspan="2">' + c + '</td></tr>');
|
||||
}
|
||||
html.push(' </table></td></tr>');
|
||||
}
|
||||
html.push('</table><br/><br/><br/>');
|
||||
html.push('</div>');
|
||||
return html.join('');
|
||||
};
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var jsoncontent = '${content}'; //这里必须要用单引号引起来
|
||||
document.write(createhtml(jsoncontent));
|
||||
</script>
|
||||
</body>
|
||||
<script>
|
||||
var jsoncontent = '#{content}'; //这里必须要用单引号引起来
|
||||
document.write(createhtml(jsoncontent));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,51 +1,43 @@
|
||||
|
||||
redkale.nodeid = 1000
|
||||
redkale.port = 6560
|
||||
redkale.lib = ./
|
||||
|
||||
#\u3010resources\u8282\u70b9\u5168\u5c40\u552f\u4e00\u3011
|
||||
#\u3010executor\u8282\u70b9\u5168\u5c40\u552f\u4e00\u3011
|
||||
redkale.resources.executor.threads = 4
|
||||
redkale.resources.executor.hash = false
|
||||
|
||||
#\u3010transport\u8282\u70b9\u5168\u5c40\u552f\u4e00\u3011
|
||||
redkale.resources.transport.bufferCapacity = 32k
|
||||
redkale.resources.transport.bufferPoolSize = 32
|
||||
|
||||
#\u3010excludelibs\u8282\u70b9\u5168\u5c40\u552f\u4e00\u3011
|
||||
redkale.resources.excludelibs.value = ^.*mysql.*$;^.*kafka.*$
|
||||
|
||||
#\u3010cluster\u8282\u70b9\u5168\u5c40\u552f\u4e00\u3011
|
||||
redkale.resources.cluster.type = org.redkalex.cluster.consul.ConsulClusterAgent
|
||||
redkale.resources.cluster.waits= = false
|
||||
redkale.resources.cluster.protocols = SNCP
|
||||
redkale.resources.cluster.ports = 7070;7071
|
||||
|
||||
redkale.resources.mq[0].name =
|
||||
redkale.resources.mq[0].type = org.redkalex.mq.kafka.KafkaMessageAgent
|
||||
redkale.resources.mq[0].servers.value = 127.0.0.1:9101
|
||||
|
||||
redkale.resources.group[0].name =
|
||||
redkale.resources.group[0].protocol = TCP
|
||||
redkale.resources.group[0].node[0].addr = 127.0.0.1
|
||||
redkale.resources.group[0].node[0].port = 7070
|
||||
|
||||
#\u3010listener\u8282\u70b9\u5168\u5c40\u552f\u4e00\u3011
|
||||
redkale.resources.listener.value = org.redkalex.xxx.XXXApplicationListener
|
||||
|
||||
#\u3010properties\u8282\u70b9\u5168\u5c40\u552f\u4e00\u3011
|
||||
redkale.resources.properties.load = config.properties
|
||||
redkale.resources.properties.property[0].name = system.property.yyyy
|
||||
redkale.resources.properties.property[0].value = YYYYYY
|
||||
redkale.resources.properties.property[1].name = xxxxxxx
|
||||
redkale.resources.properties.property[1].value = YYYYYY
|
||||
|
||||
redkale.server[0].protocol = HTTP
|
||||
redkale.server[0].host = 127.0.0.1
|
||||
redkale.server[0].port = 6060
|
||||
redkale.server[0].root = root
|
||||
redkale.server[0].lib =
|
||||
#\u3010\u8282\u70b9\u5728<server>\u4e2d\u552f\u4e00\u3011
|
||||
redkale.server[0].ssl.build = org.redkale.net.SSLBuilder\u5b50\u7c7b
|
||||
|
||||
redkale.server[0].services[0].autoload = true
|
||||
|
||||
redkale.nodeid = 1000
|
||||
redkale.port = 6560
|
||||
redkale.lib = ./
|
||||
|
||||
#\u3010executor\u8282\u70b9\u5168\u5c40\u552f\u4e00\u3011
|
||||
redkale.executor.threads = 4
|
||||
redkale.executor.hash = false
|
||||
|
||||
#\u3010cluster\u8282\u70b9\u5168\u5c40\u552f\u4e00\u3011
|
||||
redkale.cluster.type = org.redkalex.cluster.consul.ConsulClusterAgent
|
||||
redkale.cluster.waits= = false
|
||||
redkale.cluster.protocols = SNCP
|
||||
redkale.cluster.ports = 7070;7071
|
||||
|
||||
redkale.mq[0].name =
|
||||
redkale.mq[0].type = org.redkalex.mq.kafka.KafkaMessageAgent
|
||||
redkale.mq[0].servers.value = 127.0.0.1:9101
|
||||
|
||||
redkale.group[0].name =
|
||||
redkale.group[0].protocol = TCP
|
||||
redkale.group[0].node[0].addr = 127.0.0.1
|
||||
redkale.group[0].node[0].port = 7070
|
||||
|
||||
redkale.listener[0].value = org.redkalex.xxx.XXXApplicationListener
|
||||
|
||||
#\u3010properties\u8282\u70b9\u5168\u5c40\u552f\u4e00\u3011
|
||||
redkale.properties.load = config.properties
|
||||
redkale.properties.property[0].name = system.property.yyyy
|
||||
redkale.properties.property[0].value = YYYYYY
|
||||
redkale.properties.property[1].name = xxxxxxx
|
||||
redkale.properties.property[1].value = YYYYYY
|
||||
|
||||
redkale.server[0].protocol = HTTP
|
||||
redkale.server[0].host = 127.0.0.1
|
||||
redkale.server[0].port = 6060
|
||||
redkale.server[0].root = root
|
||||
redkale.server[0].lib =
|
||||
|
||||
#\u3010ssl\u8282\u70b9\u5728<server>\u4e2d\u552f\u4e00\u3011
|
||||
redkale.server[0].ssl.build = org.redkale.net.SSLBuilder\u5b50\u7c7b
|
||||
|
||||
redkale.server[0].services[0].autoload = true
|
||||
|
||||
@@ -1,324 +1,324 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
<!--
|
||||
文件说明:
|
||||
${APP_HOME} 指当前程序的根目录APP_HOME
|
||||
没注明唯一的节点可多个存在
|
||||
required: 被声明required的属性值不能为空
|
||||
|
||||
|
||||
group
|
||||
/ / \ \
|
||||
/ / \ \
|
||||
/ / \ \
|
||||
node1 node2 node3 node4
|
||||
/ \
|
||||
/ \
|
||||
/ \
|
||||
/ / \ \
|
||||
/ / \ \
|
||||
/ / \ \
|
||||
node1 node2 node3 node4
|
||||
/ \
|
||||
/ \
|
||||
/ \
|
||||
/ \
|
||||
serviceid1 serviceid2
|
||||
serviceid1 serviceid2
|
||||
/ \ / \
|
||||
serviceid1_name1 serviceid1_name2 serviceid2_name1 serviceid2_name2
|
||||
serviceid1_name1 serviceid1_name2 serviceid2_name1 serviceid2_name2
|
||||
-->
|
||||
<!--
|
||||
<!--
|
||||
nodeid: int 进程的节点ID,用于分布式环境,一个系统中节点ID必须全局唯一,使用cluster时框架会进行唯一性校验
|
||||
name: 进程的名称,用于监控识别,命名规则: 字母、数字、下划线、短横、点
|
||||
address: 本地局域网的IP地址, 默认值为默认网卡的ip,当不使用默认值需要指定值,如192.168.1.22
|
||||
port: required 程序的管理Server的端口,用于关闭或者与监管系统进行数据交互
|
||||
lib: 加上额外的lib路径,多个路径用分号;隔开; 默认为空。 例如: ${APP_HOME}/lib/a.jar;${APP_HOME}/lib2/b.jar;
|
||||
-->
|
||||
<application nodeid="1000" port="6560" lib="">
|
||||
|
||||
<!--
|
||||
【节点全局唯一】
|
||||
所有服务所需的资源
|
||||
<application nodeid="1000" port="6560" lib="">
|
||||
|
||||
<!--
|
||||
【节点全局唯一】 @since 2.3.0
|
||||
全局Serivce执行的线程池, Application.workExecutor, 没配置该节点将自动创建一个。
|
||||
threads: 线程数,默认值: CPU核数*10, 核数=2的情况下默认值为20。值为0表示不启用workExecutor,都在IO线程中运行。
|
||||
clients: client回调函数运行的线程池大小, 默认值: CPU核数*4
|
||||
-->
|
||||
<resources>
|
||||
|
||||
<!--
|
||||
【节点全局唯一】 @since 2.3.0
|
||||
全局Serivce执行的线程池, Application.workExecutor, 没配置该节点将自动创建一个。
|
||||
threads: 线程数,为0表示不启用workExecutor,只用IO线程。默认: CPU核数, 核数=1的情况下默认值为2
|
||||
hash: 是否使用ThreadHashExecutor作为线程池,默认值为:false
|
||||
-->
|
||||
<executor threads="4" hash="false"/>
|
||||
|
||||
<!--
|
||||
【节点全局唯一】
|
||||
transport节点只能有一个,用于配置所有Transport的池参数,没配置该节点将自动创建一个。
|
||||
threads: 线程总数, 默认: <group>节点数*CPU核数*2
|
||||
bufferCapacity: ByteBuffer的初始化大小, 默认: 32K;
|
||||
bufferPoolSize: ByteBuffer池的大小,默认: 线程总数*4
|
||||
readTimeoutSeconds: TCP读取超时秒数, 默认为6秒, 为0表示无超时限制
|
||||
writeTimeoutSeconds: TCP写入超时秒数, 默认为6秒, 为0表示无超时限制
|
||||
strategy: 远程请求的负载均衡策略, 必须是org.redkale.net.TransportStrategy的实现类
|
||||
-->
|
||||
<transport bufferCapacity="32K" bufferPoolSize="32" threads="32" readTimeoutSeconds="6" writeTimeoutSeconds="6"/>
|
||||
|
||||
<!--
|
||||
【节点全局唯一】
|
||||
自动扫描时排除部分包路径
|
||||
value: 排除lib.path与excludes中的正则表达式匹配的路径, 多个正则表达式用分号;隔开
|
||||
-->
|
||||
<excludelibs value="^.*mysql.*$;^.*kafka.*$"/>
|
||||
|
||||
<!--
|
||||
【节点全局唯一】
|
||||
第三方服务发现管理接口
|
||||
type: 类名,必须是org.redkale.cluster.ClusterAgent的子类
|
||||
waits: 注销服务后是否需要等待检查周期时间后再进行Service销毁,默认值为:false
|
||||
当一个Service进行服务注销后,不能立刻销毁Service,因为健康检测是有间隔时间差的,
|
||||
需要等待一个健康检测周期时间,让其他进程都更新完服务列表。
|
||||
如果使用MQ,可以设置为false,如果对服务健壮性要求高,建议设置为true
|
||||
protocols: 服务发现可以处理的协议, 默认值为: SNCP, 多个协议用分号;隔开
|
||||
ports: 服务发现可以处理的端口, 多个端口用分号;隔开
|
||||
ttls: 心跳频率,多少秒一次
|
||||
xxxx: 自定义的字段属性,例如:CacheClusterAgent有source字段; ConsulClusterAgent有apiurl字段;
|
||||
-->
|
||||
<cluster type="org.redkalex.cluster.consul.ConsulClusterAgent" waits="false" protocols="SNCP" ports="7070;7071" xxx="xxx" />
|
||||
<executor threads="4"/>
|
||||
|
||||
<!--
|
||||
MQ管理接口配置
|
||||
不同MQ节点所配置的MQ集群不能重复。
|
||||
MQ跟着协议走,所以mq的属性值需要被赋值在rest节点上, 由于SncpServlet是自动生成的,故SNCP协议下,mq属性值被赋值在service/services节点上
|
||||
name: 服务的名称,用于监控识别,多个mq节点时只能有一个name为空的节点,mq.name不能重复,命名规则: 字母、数字、下划线
|
||||
type: 实现类名,必须是org.redkale.mq.MessageAgent的子类
|
||||
coder: MessageRecord的解析器类,必须是org.redkale.mq.MessageCoder<MessageRecord>的实现类,
|
||||
可对数据包进行加密解密,默认值:org.redkale.mq.MessageRecordCoder
|
||||
MQ节点下的子节点配置没有固定格式, 根据MessageAgent实现方的定义来配置
|
||||
-->
|
||||
<mq name="" type="org.redkalex.mq.kafka.KafkaMessageAgent">
|
||||
<servers value="127.0.0.1:9101"/>
|
||||
<consumer>
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
</consumer>
|
||||
<producer>
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
</producer>
|
||||
</mq>
|
||||
|
||||
<!--
|
||||
一个组包含多个node, 同一Service服务可以由多个进程提供,这些进程称为一个GROUP,且同一GROUP内的进程必须在同一机房或局域网内
|
||||
一个group节点对应一个 Transport 对象。
|
||||
name: 服务组ID,长度不能超过11个字节. 默认为空字符串。 注意: name不能包含$符号。
|
||||
protocol: 值范围:UDP TCP, 默认TCP
|
||||
注意: 一个node只能所属一个group。只要存在protocol=SNCP的Server节点信息, 就必须有group节点信息。
|
||||
-->
|
||||
<group name="" protocol="TCP">
|
||||
<!--
|
||||
需要将本地node的addr与port列在此处。
|
||||
同一个<node>节点值只能存在一个<group>节点内,即同一个addr+port只能属于一个group。
|
||||
addr: required IP地址
|
||||
port: required 端口
|
||||
-->
|
||||
<node addr="127.0.0.1" port="7070"/>
|
||||
</group>
|
||||
<!--
|
||||
【节点全局唯一】 @since 2.8.0
|
||||
全局Serivce的定时任务设置,没配置该节点将自动创建一个。
|
||||
enabled: 是否开启缓存功能。默认: true
|
||||
-->
|
||||
<scheduled enabled="true"/>
|
||||
|
||||
<!--
|
||||
@since 2.8.0
|
||||
全局Serivce的缓存设置,没配置该节点将自动创建一个。
|
||||
name: 缓存管理器的名称, 默认: ""
|
||||
enabled: 是否开启缓存功能。默认: true
|
||||
remote: 远程CacheSource的资源名
|
||||
broadcastable: 存在远程CacheSource时修改数据是否进行广播到其他集群服务中。默认: true
|
||||
-->
|
||||
<cached name="" enabled="true" remote="xxx" broadcastable="true"/>
|
||||
|
||||
<!--
|
||||
【节点全局唯一】
|
||||
第三方服务发现管理接口
|
||||
type: 类名,必须是org.redkale.cluster.ClusterAgent的子类
|
||||
waits: 注销服务后是否需要等待检查周期时间后再进行Service销毁,默认值为:false
|
||||
当一个Service进行服务注销后,不能立刻销毁Service,因为健康检测是有间隔时间差的,
|
||||
需要等待一个健康检测周期时间,让其他进程都更新完服务列表。
|
||||
如果使用MQ,可以设置为false,如果对服务健壮性要求高,建议设置为true
|
||||
protocols: 服务发现可以处理的协议, 默认值为: SNCP, 多个协议用分号;隔开
|
||||
ports: 服务发现可以处理的端口, 多个端口用分号;隔开
|
||||
ttls: 心跳频率,多少秒一次
|
||||
xxxx: 自定义的字段属性,例如:CacheClusterAgent有source字段; ConsulClusterAgent有apiurl字段;
|
||||
-->
|
||||
<cluster type="org.redkalex.cluster.consul.ConsulClusterAgent" waits="false" protocols="SNCP" ports="7070;7071" xxx="xxx" />
|
||||
|
||||
<!--
|
||||
MQ管理接口配置
|
||||
不同MQ节点所配置的MQ集群不能重复。
|
||||
MQ跟着协议走,所以mq的属性值需要被赋值在rest节点上, 由于SncpServlet是自动生成的,故SNCP协议下,mq属性值被赋值在service/services节点上
|
||||
name: 服务的名称,用于监控识别,多个mq节点时只能有一个name为空的节点,mq.name不能重复,命名规则: 字母、数字、下划线
|
||||
type: 实现类名,必须是org.redkale.mq.MessageAgent的子类
|
||||
threads:线程数,为0表示使用workExecutor。默认: CPU核数, 核数=1的情况下默认值为2,JDK 21以上版本默认使用虚拟线程池
|
||||
rpc:cluster和mq同名组件时,HttpRpcClient优先使用MQ,默认不优先走MQ。
|
||||
coder: MessageRecord的解析器类,必须是org.redkale.mq.MessageCoder<MessageRecord>的实现类,
|
||||
可对数据包进行加密解密,默认值:org.redkale.mq.MessageRecordCoder
|
||||
MQ节点下的子节点配置没有固定格式, 根据MessageAgent实现方的定义来配置
|
||||
-->
|
||||
<mq name="" type="org.redkalex.mq.kafka.KafkaMessageAgent" rpc="false" threads="4">
|
||||
<servers value="127.0.0.1:9101"/>
|
||||
<!--
|
||||
Application启动的监听事件,可配置多个节点
|
||||
value: 类名,必须是ApplicationListener的子类
|
||||
加载所有的MessageConsumer实例;
|
||||
autoload="true" 默认值. 自动加载classpath下所有的MessageConsumer类
|
||||
autoload="false" 需要显著的指定MessageConsumer类
|
||||
includes: 当autoload="true", 拉取类名与includes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
excludes: 当autoload="true", 排除类名与excludes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
-->
|
||||
<listener value="org.redkalex.xxx.XXXApplicationListener"/>
|
||||
|
||||
<!--
|
||||
【节点全局唯一】
|
||||
全局的参数配置, 可以通过@Resource(name="property.xxxxxx") 进行注入<property>的信息, 被注解的字段类型只能是String、primitive class
|
||||
如果name是system.property.开头的值将会在进程启动时进行System.setProperty("yyyy", "YYYYYY")操作。
|
||||
如果name是mimetype.property.开头的值将会在进程启动时进行MimeType.add("yyyy", "YYYYYY")操作。
|
||||
先加载子节点property,再加载load文件, 最后加载agent的实现子类。
|
||||
agent: 实现类名,必须是org.redkale.boot.PropertiesAgent的子类
|
||||
load: 加载文件,多个用;隔开。
|
||||
默认置入的system.property.的有:
|
||||
System.setProperty("redkale.net.transport.poolmaxconns", "100");
|
||||
System.setProperty("redkale.net.transport.pinginterval", "30");
|
||||
System.setProperty("redkale.net.transport.checkinterval", "30");
|
||||
System.setProperty("redkale.convert.tiny", "true");
|
||||
System.setProperty("redkale.convert.pool.size", "128");
|
||||
System.setProperty("redkale.convert.writer.buffer.defsize", "4096");
|
||||
|
||||
<properties>节点下也可包含非<property>节点.
|
||||
非<property>其节点可以通过@Resource(name="properties.xxxxxx")进行注入, 被注解的字段类型只能是AnyValue、AnyValue[]
|
||||
<consumer autoload="true" includes="" excludes=""/>
|
||||
<!--
|
||||
MQ实现方的配置项
|
||||
type: 配置项类型,值只能是consumer或producer
|
||||
-->
|
||||
<properties load="config.properties" agent="">
|
||||
<property name="system.property.yyyy" value="YYYYYY"/>
|
||||
<config type="consumer">
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
</config>
|
||||
<config type="producer">
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
</properties>
|
||||
|
||||
</resources>
|
||||
</config>
|
||||
</mq>
|
||||
|
||||
<!--
|
||||
一个组包含多个node, 同一Service服务可以由多个进程提供,这些进程称为一个GROUP,且同一GROUP内的进程必须在同一机房或局域网内
|
||||
name: 服务组ID,长度不能超过11个字节. 默认为空字符串。 注意: name不能包含$符号。
|
||||
protocol: 值范围:UDP TCP, 默认TCP
|
||||
nodes: 多个node节点值; 例如:192.168.0.1:6060,192.168.0.2:6060
|
||||
注意: 一个node只能所属一个group。只要存在protocol=SNCP的Server节点信息, 就必须有group节点信息。
|
||||
-->
|
||||
<group name="" protocol="TCP" nodes="192.168.0.1:6060,192.168.0.2:6060">
|
||||
<!--
|
||||
需要将本地node的addr与port列在此处, 也可以直接用nodes属性。
|
||||
同一个<node>节点值只能存在一个<group>节点内,即同一个addr+port只能属于一个group。
|
||||
addr: required IP地址
|
||||
port: required 端口
|
||||
-->
|
||||
<node addr="127.0.0.1" port="7070"/>
|
||||
</group>
|
||||
|
||||
<!--
|
||||
Application启动的监听事件,可配置多个节点
|
||||
value: 类名,必须是ApplicationListener的子类
|
||||
-->
|
||||
<listener value="org.redkalex.xxx.XXXApplicationListener"/>
|
||||
|
||||
<!--
|
||||
【节点全局唯一】
|
||||
全局的参数配置, 可以通过@Resource(name="property.xxxxxx") 进行注入<property>的信息, 被注解的字段类型只能是String、primitive class
|
||||
如果name是system.property.开头的值将会在进程启动时进行System.setProperty("yyyy", "YYYYYY")操作。
|
||||
如果name是mimetype.property.开头的值将会在进程启动时进行MimeType.add("yyyy", "YYYYYY")操作。
|
||||
先加载子节点property,再加载load文件, 最后加载agent的实现子类。
|
||||
load: 加载文件,多个用;隔开。
|
||||
其他属性: 供org.redkale.boot.PropertiesAgentProvider使用判断
|
||||
默认置入的system.property.的有:
|
||||
System.setProperty("redkale.convert.pool.size", "128");
|
||||
System.setProperty("redkale.convert.writer.buffer.defsize", "4096");
|
||||
|
||||
<properties>节点下也可包含非<property>节点.
|
||||
非<property>其节点可以通过@Resource(name="properties.xxxxxx")进行注入, 被注解的字段类型只能是AnyValue、AnyValue[]
|
||||
-->
|
||||
<properties load="config.properties">
|
||||
<property name="system.property.yyyy" value="YYYYYY"/>
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
</properties>
|
||||
|
||||
<!--
|
||||
protocol: required server所启动的协议,Redkale内置的有HTTP、SNCP、WATCH。协议均使用TCP实现; WATCH服务只能存在一个。
|
||||
name: 服务的名称,用于监控识别,一个配置文件中的server.name不能重复,命名规则: 字母、数字、下划线
|
||||
host: 服务所占address , 默认: 0.0.0.0
|
||||
port: required 服务所占端口
|
||||
port: required 服务所占端口
|
||||
root: 如果是web类型服务,则包含页面 默认:{APP_HOME}/root
|
||||
lib: server额外的class目录, 默认为${APP_HOME}/libs/*;
|
||||
excludelibs: 排除lib.path与excludes中的正则表达式匹配的路径, 多个正则表达式用分号;隔开
|
||||
lib: server额外的class目录, 默认为${APP_HOME}/libs/*;
|
||||
charset: 文本编码, 默认: UTF-8
|
||||
backlog: 默认10K
|
||||
threads【已废弃】: 线程数, 默认: CPU核数*2,最小8个【已废弃 @since 2.3.0】
|
||||
maxconns: 最大连接数, 小于1表示无限制, 默认: 0
|
||||
maxbody: request.body最大值, 默认: 64K
|
||||
bufferCapacity: ByteBuffer的初始化大小, TCP默认: 32K; (HTTP 2.0、WebSocket,必须要16k以上); UDP默认: 1350B
|
||||
maxConns: 最大连接数, 小于1表示无限制, 默认: 0
|
||||
maxHeader: request.header最大值, 默认: 16K
|
||||
maxBody: request.body最大值, 默认: 256K
|
||||
bufferCapacity: ByteBuffer的初始化大小, TCP默认: 32K; (HTTP 2.0、WebSocket,必须要16k以上); UDP默认: 8K
|
||||
bufferPoolSize: ByteBuffer池的大小,默认: 线程数*4
|
||||
responsePoolSize: Response池的大小,默认: 1024
|
||||
aliveTimeoutSeconds: KeepAlive读操作超时秒数, 默认30, 0表示永久不超时; -1表示禁止KeepAlive
|
||||
readTimeoutSeconds: 读操作超时秒数, 默认0, 表示永久不超时
|
||||
writeTimeoutSeconds: 写操作超时秒数, 默认0, 表示永久不超时
|
||||
readTimeoutSeconds: 读操作超时秒数, 默认0, 0表示永久不超时
|
||||
writeTimeoutSeconds: 写操作超时秒数, 默认0, 0表示永久不超时
|
||||
interceptor: 启动/关闭NodeServer时被调用的拦截器实现类,必须是org.redkale.boot.NodeInterceptor的子类,默认为null
|
||||
-->
|
||||
<server protocol="HTTP" host="127.0.0.1" port="6060" root="root" lib="">
|
||||
|
||||
<!--
|
||||
【节点在<server>中唯一】
|
||||
builder: 创建SSLContext的实现类, 可自定义,必须是org.redkale.net.SSLBuilder的子类
|
||||
sslProvider: java.security.Provider自定义的实现类,如第三方: org.conscrypt.OpenSSLProvider、org.bouncycastle.jce.provider.BouncyCastleProvider
|
||||
jsseProvider: java.security.Provider自定义的实现类,如第三方: org.conscrypt.JSSEProvider、 org.bouncycastle.jce.provider.BouncyCastleJsseProvider
|
||||
protocol: TLS版本,默认值: TLS
|
||||
protocols: 设置setEnabledProtocols, 多个用,隔开 如: TLSv1.2,TLSv1.3
|
||||
clientAuth: WANT/NEED/NONE, 默认值: NONE
|
||||
ciphers: 设置setEnabledCipherSuites, 多个用,隔开 如: TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA256
|
||||
keystorePass: KEY密码
|
||||
keystoreFile: KEY文件 .jks
|
||||
keystoreType: KEY类型, 默认值为JKS
|
||||
keystoreAlgorithm: KEY文件的algorithm, 默认值为SunX509
|
||||
truststorePass: TRUST密码
|
||||
truststoreFile: TRUST文件
|
||||
truststoreType: TRUST类型, 默认值为JKS
|
||||
truststoreAlgorithm: TRUST文件的algorithm, 默认值为SunX509
|
||||
<server protocol="HTTP" host="127.0.0.1" port="6060" root="root" lib="">
|
||||
|
||||
<!--
|
||||
【节点在<server>中唯一】
|
||||
builder: 创建SSLContext的实现类, 可自定义,必须是org.redkale.net.SSLBuilder的子类
|
||||
sslProvider: java.security.Provider自定义的实现类,如第三方: org.conscrypt.OpenSSLProvider、org.bouncycastle.jce.provider.BouncyCastleProvider
|
||||
jsseProvider: java.security.Provider自定义的实现类,如第三方: org.conscrypt.JSSEProvider、 org.bouncycastle.jce.provider.BouncyCastleJsseProvider
|
||||
protocol: TLS版本,默认值: TLS
|
||||
protocols: 设置setEnabledProtocols, 多个用,隔开 如: TLSv1.2,TLSv1.3
|
||||
clientAuth: WANT/NEED/NONE, 默认值: NONE
|
||||
ciphers: 设置setEnabledCipherSuites, 多个用,隔开 如: TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA256
|
||||
keystorePass: KEY密码
|
||||
keystoreFile: KEY文件 .jks
|
||||
keystoreType: KEY类型, 默认值为JKS
|
||||
keystoreAlgorithm: KEY文件的algorithm, 默认值为SunX509
|
||||
truststorePass: TRUST密码
|
||||
truststoreFile: TRUST文件
|
||||
truststoreType: TRUST类型, 默认值为JKS
|
||||
truststoreAlgorithm: TRUST文件的algorithm, 默认值为SunX509
|
||||
-->
|
||||
<ssl builder=""/>
|
||||
|
||||
<!--
|
||||
加载所有的Service服务;
|
||||
在同一个进程中同一个name同一类型的Service将共用同一个实例
|
||||
autoload="true" 默认值. 自动加载classpath下所有的Service类
|
||||
autoload="false" 需要显著的指定Service类
|
||||
mq: 所属的MQ管理器,当 protocol == SNCP 时该值才有效, 存在该属性表示Service的SNCP协议采用消息总线代理模式
|
||||
includes: 当autoload="true", 拉取类名与includes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
excludes: 当autoload="true", 排除类名与excludes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
groups: 所属组的节点,多个节点值用;隔开,如果配置文件中存在多个SNCP协议的Server节点,需要显式指定group属性.
|
||||
当 protocol == SNCP 时 group表示当前Server与哪些节点组关联。
|
||||
当 protocol != SNCP 时 group只能是空或者一个group的节点值,不能为多个节点值。
|
||||
特殊值"$cluster", 视为通过第三方服务注册发现管理工具来获取远程模式的ip端口信息
|
||||
|
||||
<!--
|
||||
加载所有的Service服务;
|
||||
在同一个进程中同一个name同一类型的Service将共用同一个实例
|
||||
autoload="true" 默认值. 自动加载classpath下所有的Service类
|
||||
autoload="false" 需要显著的指定Service类
|
||||
mq: 所属的MQ管理器,当 protocol == SNCP 时该值才有效, 存在该属性表示Service的SNCP协议采用消息总线代理模式
|
||||
includes: 当autoload="true", 拉取类名与includes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
excludes: 当autoload="true", 排除类名与excludes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
group: 所属组的节点, 不能指定多个group, 如果配置文件中存在多个SNCP协议的Server节点,需要显式指定group属性.
|
||||
当 protocol == SNCP 时 group表示当前Server与哪些节点组关联。
|
||||
当 protocol != SNCP 时 group只能是空或者一个group的节点值。
|
||||
特殊值"$remote", 视为通过第三方服务注册发现管理工具来获取远程模式的ip端口信息
|
||||
-->
|
||||
<services autoload="true" includes="" excludes="">
|
||||
|
||||
<!-- 显著加载指定的Service的接口类 -->
|
||||
<service value="com.xxx.XXX1Service"/>
|
||||
<!--
|
||||
name: 显式指定name,覆盖默认的空字符串值。 注意: name不能包含$符号。
|
||||
mq: 所属的MQ管理器,当 protocol == SNCP 时该值才有效, 存在该属性表示Service的SNCP协议采用消息总线代理模式
|
||||
groups: 显式指定groups,覆盖<services>节点的groups默认值。
|
||||
ignore: 是否禁用, 默认为false。
|
||||
<!--
|
||||
name: 显式指定name,覆盖默认的空字符串值。 注意: name不能包含$符号。
|
||||
mq: 所属的MQ管理器,当 protocol == SNCP 时该值才有效, 存在该属性表示Service的SNCP协议采用消息总线代理模式
|
||||
group: 显式指定group,覆盖<services>节点的group默认值。
|
||||
ignore: 是否禁用, 默认为false。
|
||||
-->
|
||||
<service value="com.xxx.XXX2Service" name="" groups="xxx;yyy"/>
|
||||
<service value="com.xxx.XXX2Service" name="" group="xxx"/>
|
||||
<!-- 给Service增加配置属性 -->
|
||||
<service value="com.xxx.XXX1Service">
|
||||
<service value="com.xxx.XXX1Service">
|
||||
<!-- property值在public void init(AnyValue conf)方法中可以通过AnyValue properties=conf.getAnyValue("properties")获取 -->
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
</service>
|
||||
</services>
|
||||
|
||||
<!--
|
||||
加载所有的Filter服务;
|
||||
autoload="true" 默认值.
|
||||
autoload="false" 需要显著的指定Filter类
|
||||
includes: 当autoload="true", 拉取类名与includes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
excludes: 当autoload="true", 排除类名与excludes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
|
||||
<!--
|
||||
加载所有的Filter服务;
|
||||
autoload="true" 默认值.
|
||||
autoload="false" 需要显著的指定Filter类
|
||||
includes: 当autoload="true", 拉取类名与includes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
excludes: 当autoload="true", 排除类名与excludes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
-->
|
||||
<filters autoload="true" includes="" excludes="">
|
||||
|
||||
<!--
|
||||
显著加载指定的Filter类
|
||||
value=: Filter类名。必须与Server的协议层相同,HTTP必须是HttpFilter
|
||||
ignore: 是否禁用, 默认为false。
|
||||
|
||||
<!--
|
||||
显著加载指定的Filter类
|
||||
value=: Filter类名。必须与Server的协议层相同,HTTP必须是HttpFilter
|
||||
ignore: 是否禁用, 默认为false。
|
||||
-->
|
||||
<!-- 显著加载指定的Filter类 -->
|
||||
<filter value="com.xxx.XXX1Filter"/>
|
||||
|
||||
|
||||
<!-- 给Filter增加配置属性 -->
|
||||
<filter value="com.xxx.XXX12Filter">
|
||||
<filter value="com.xxx.XXX12Filter">
|
||||
<!-- property值在public void init(AnyValue conf)方法中可以通过AnyValue properties=conf.getAnyValue("properties")获取 -->
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
<property name="xxxxxx" value="XXXXXXXX"/>
|
||||
</filter>
|
||||
</filters>
|
||||
|
||||
<!--
|
||||
REST的核心配置项
|
||||
当Server为HTTP协议时, rest节点才有效。存在[rest]节点则Server启动时会加载REST服务, 节点可以多个,(WATCH协议不需要设置,系统会自动生成)
|
||||
path: servlet的ContextPath前缀 默认为空 【注: 开启MQ时,该字段失效】
|
||||
base: REST服务的BaseServlet,必须是 org.redkale.net.http.HttpServlet 的子类,且子类必须标记@HttpUserType。
|
||||
mq: 所属的MQ管理器, 存在该属性表示RestService的请求来自于消息总线 【注: 开启MQ时,path字段失效】
|
||||
autoload:默认值"true" 默认值. 加载当前server所能使用的Servce对象;
|
||||
includes:当autoload="true", 拉取类名与includes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
excludes:当autoload="true", 排除类名与excludes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
|
||||
<!--
|
||||
REST的核心配置项
|
||||
当Server为HTTP协议时, rest节点才有效。存在[rest]节点则Server启动时会加载REST服务, 节点可以多个,(WATCH协议不需要设置,系统会自动生成)
|
||||
path: servlet的ContextPath前缀 默认为空 【注: 开启MQ时,该字段失效】
|
||||
base: REST服务的BaseServlet,必须是 org.redkale.net.http.HttpServlet 的子类,且子类必须标记@HttpUserType。
|
||||
mq: 所属的MQ管理器, 存在该属性表示RestService的请求来自于消息总线 【注: 开启MQ时,path字段失效】
|
||||
autoload:默认值"true" 默认值. 加载当前server所能使用的Servce对象;
|
||||
includes:当autoload="true", 拉取类名与includes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
excludes:当autoload="true", 排除类名与excludes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
-->
|
||||
<rest path="/pipes" base="org.redkale.net.http.HttpServlet" autoload="true" includes="" excludes="">
|
||||
<!--
|
||||
value: Service类名,列出的表示必须被加载的Service对象
|
||||
ignore: 是否忽略,设置为true则不会加载该Service对象,默认值为false
|
||||
<!--
|
||||
value: Service类名,列出的表示必须被加载的Service对象
|
||||
ignore: 是否忽略,设置为true则不会加载该Service对象,默认值为false
|
||||
-->
|
||||
<service value="com.xxx.XXXXService"/>
|
||||
<!--
|
||||
value: WebSocket类名,列出的表示必须被加载且标记为@RestWebSocket的WebSocket对象
|
||||
ignore: 是否忽略,设置为true则不会加载该RestWebSocket对象,默认值为false
|
||||
<!--
|
||||
value: WebSocket类名,列出的表示必须被加载且标记为@RestWebSocket的WebSocket对象
|
||||
ignore: 是否忽略,设置为true则不会加载该RestWebSocket对象,默认值为false
|
||||
-->
|
||||
<websocket value="com.xxx.XXXXRestWebSocket"/>
|
||||
</rest>
|
||||
|
||||
|
||||
<!--
|
||||
【节点在<server>中唯一】
|
||||
当Server为HTTP协议时, request节点才有效。
|
||||
remoteaddr 节点: 替换请求方节点的IP地址, 通常请求方是由nginx等web静态服务器转发过的则需要配置该节点。
|
||||
且value值只能是以request.headers.开头,表示从request.headers中获取对应的header值。
|
||||
locale value值必须是request.headers.或request.parameters.开头。
|
||||
例如下面例子获取request.getRemoteAddr()值,如果header存在X-RemoteAddress值则返回X-RemoteAddress值,不存在返回getRemoteAddress()。
|
||||
【节点在<server>中唯一】
|
||||
当Server为HTTP协议时, request节点才有效。
|
||||
remoteaddr 节点: 替换请求方节点的IP地址, 通常请求方是由nginx等web静态服务器转发过的则需要配置该节点。
|
||||
且value值只能是以request.headers.开头,表示从request.headers中获取对应的header值, 多个header用逗号隔开。
|
||||
locale value值必须是request.headers.或request.parameters.开头。
|
||||
例如下面例子获取request.getRemoteAddr()值,如果header存在X-RemoteAddress值则返回X-RemoteAddress值,不存在返回getRemoteAddress()。
|
||||
-->
|
||||
<request>
|
||||
<remoteaddr value="request.headers.X-RemoteAddress"/>
|
||||
<locale value="request.headers.locale" />
|
||||
<remoteaddr value="request.headers.X-RemoteAddress,X-Forwarded-For"/>
|
||||
<locale value="request.headers.locale" />
|
||||
<rpc authenticator="org.redkale.net.http.HttpRpcAuthenticator的实现类"/>
|
||||
</request>
|
||||
|
||||
|
||||
<!--
|
||||
【节点在<server>中唯一】
|
||||
当Server为HTTP协议时, response节点才有效。
|
||||
contenttype: plain值为调用finish时的ContentType; 默认值: text/plain; charset=utf-8
|
||||
【节点在<server>中唯一】
|
||||
当Server为HTTP协议时, response节点才有效。
|
||||
contenttype: plain值为调用finish时的ContentType; 默认值: text/plain; charset=utf-8
|
||||
json值为调用finishJson时的ContentType; 默认值: application/json; charset=utf-8
|
||||
defcookie 节点: 当response里输出的cookie没有指定domain 和path时,使用该节点的默认值。
|
||||
addheader、setheader 的value值以request.parameters.开头则表示从request.parameters中获取对应的parameter值
|
||||
addheader、setheader 的value值以request.headers.开头则表示从request.headers中获取对应的header值
|
||||
例如下面例子是在Response输出header时添加两个header(一个addHeader, 一个setHeader)。
|
||||
options 节点: 设置了该节点且auto=true,当request的method=OPTIONS自动设置addheader、setheader并返回200状态码
|
||||
date 节点: 设置了该节点且period有值(单位:毫秒);返回response会包含Date头信息,默认为period=0
|
||||
period=0表示实时获取当前时间;
|
||||
period<0表示不设置date;
|
||||
period>0表示定时获取时间; 设置1000表示每秒刷新Date时间
|
||||
defcookie 节点: 当response里输出的cookie没有指定domain 和path时,使用该节点的默认值。
|
||||
addheader、setheader 的value值以request.parameters.开头则表示从request.parameters中获取对应的parameter值
|
||||
addheader、setheader 的value值以request.headers.开头则表示从request.headers中获取对应的header值
|
||||
例如下面例子是在Response输出header时添加两个header(一个addHeader, 一个setHeader)。
|
||||
options 节点: 设置了该节点且auto=true,当request的method=OPTIONS自动设置addheader、setheader并返回200状态码
|
||||
date 节点: 设置了该节点且period有值(单位:毫秒);返回response会包含Date头信息,默认为period=0
|
||||
period=0表示实时获取当前时间;
|
||||
period<0表示不设置date;
|
||||
period>0表示定时获取时间; 设置1000表示每秒刷新Date时间
|
||||
-->
|
||||
<response>
|
||||
<content-type plain="text/plain; charset=utf-8" json="application/json; charset=utf-8"/>
|
||||
<defcookie domain="" path=""/>
|
||||
<addheader name="Access-Control-Allow-Origin" value="request.headers.Origin" />
|
||||
<setheader name="Access-Control-Allow-Headers" value="request.headers.Access-Control-Request-Headers"/>
|
||||
<content-type plain="text/plain; charset=utf-8" json="application/json; charset=utf-8"/>
|
||||
<defcookie domain="" path=""/>
|
||||
<addheader name="Access-Control-Allow-Origin" value="request.headers.Origin" /> <!-- 可多节点 -->
|
||||
<setheader name="Access-Control-Allow-Headers" value="request.headers.Access-Control-Request-Headers"/> <!-- 可多节点 -->
|
||||
<setheader name="Access-Control-Allow-Credentials" value="true"/>
|
||||
<options auto="true" />
|
||||
<date period="0" />
|
||||
</response>
|
||||
<!--
|
||||
【节点在<server>中唯一】
|
||||
当Server为HTTP协议时,render才有效. 指定输出引擎的实现类
|
||||
value: 输出引擎的实现类, 必须是org.redkale.net.http.HttpRender的子类
|
||||
suffixs: 引擎文件名后缀,多个用;隔开,默认值为: .htel
|
||||
<!--
|
||||
【节点在<server>中唯一】
|
||||
当Server为HTTP协议时,render才有效. 指定输出引擎的实现类
|
||||
value: 输出引擎的实现类, 必须是org.redkale.net.http.HttpRender的子类
|
||||
suffixs: 引擎文件名后缀,多个用;隔开,默认值为: .htel
|
||||
-->
|
||||
<render value="org.redkalex.htel.HttpTemplateRender" suffixs=".htel"/>
|
||||
<!--
|
||||
【节点在<server>中唯一】
|
||||
当Server为HTTP协议时,ResourceServlet才有效. 默认存在一个有默认属性的resource-servlet节点
|
||||
webroot: web资源的根目录, 默认取server节点中的root值
|
||||
servlet: 静态资源HttpServlet的实现,默认使用HttpResourceServlet
|
||||
index : 启始页,默认值:index.html
|
||||
<!--
|
||||
【节点在<server>中唯一】
|
||||
当Server为HTTP协议时,ResourceServlet才有效. 默认存在一个有默认属性的resource-servlet节点
|
||||
webroot: web资源的根目录, 默认取server节点中的root值
|
||||
servlet: 静态资源HttpServlet的实现,默认使用HttpResourceServlet
|
||||
index : 启始页,默认值:index.html
|
||||
-->
|
||||
<resource-servlet webroot="root" index="index.html">
|
||||
<!--
|
||||
@@ -330,27 +330,27 @@
|
||||
-->
|
||||
<cache limit="0M" lengthmax="1M" watch="false"/>
|
||||
<!--
|
||||
支持类似nginx中的rewrite, 目前只支持静态资源对静态资源的跳转。
|
||||
type: 匹配的类型, 目前只支持location(匹配requestURI), 默认: location
|
||||
match: 匹配的正则表达式
|
||||
forward: 需跳转后的资源链接
|
||||
例如下面例子是将/xxx-yyy.html的页面全部跳转到/xxx.html
|
||||
支持类似nginx中的rewrite, 目前只支持静态资源对静态资源的跳转。
|
||||
type: 匹配的类型, 目前只支持location(匹配path), 默认: location
|
||||
match: 匹配的正则表达式
|
||||
forward: 需跳转后的资源链接
|
||||
例如下面例子是将/xxx-yyy.html的页面全部跳转到/xxx.html
|
||||
-->
|
||||
<rewrite type="location" match="^/([^-]+)-[^-\.]+\.html(.*)" forward="/$1.html"/>
|
||||
</resource-servlet>
|
||||
<!--
|
||||
加载所有的Servlet服务;
|
||||
path: servlet的ContextPath前缀 默认为空
|
||||
autoload="true" 默认值. 自动加载classpath下所有的Servlet类
|
||||
autoload="false" 需要显著的指定Service类
|
||||
includes: 当autoload="true", 拉取类名与includes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
excludes: 当autoload="true", 排除类名与excludes中的正则表达式匹配的类, 多个正则表达式用分号;隔开
|
||||
<!--
|
||||
加载所有的Servlet服务;
|
||||
path: servlet的ContextPath前缀 默认为空
|
||||
autoload="true" 默认值. 自动加载classpath下所有的Servlet类
|
||||
autoload="false" 需要显著的指定Service类
|
||||
includes: 当autoload="true", 拉取类名与includes中的正则表达式匹配的类, 多个正则表达式用分号;或者逗号,隔开
|
||||
excludes: 当autoload="true", 排除类名与excludes中的正则表达式匹配的类, 多个正则表达式用分号;或者逗号,隔开
|
||||
-->
|
||||
<servlets path="/pipes" autoload="true" includes="" excludes="">
|
||||
<!--
|
||||
显著加载指定的Servlet类
|
||||
value=: Servlet类名。必须与Server的协议层相同,HTTP必须是HttpServlet
|
||||
ignore: 是否禁用, 默认为false。
|
||||
<!--
|
||||
显著加载指定的Servlet类
|
||||
value=: Servlet类名。必须与Server的协议层相同,HTTP必须是HttpServlet
|
||||
ignore: 是否禁用, 默认为false。
|
||||
-->
|
||||
<servlet value="com.xxx.XXX1Servlet" />
|
||||
<servlet value="com.xxx.XXX2Servlet" />
|
||||
@@ -360,9 +360,10 @@
|
||||
</servlet>
|
||||
</servlets>
|
||||
</server>
|
||||
|
||||
<server protocol="SNCP" host="127.0.0.1" port="7070" root="root" lib="">
|
||||
|
||||
<server protocol="SNCP" host="127.0.0.1" port="7070" root="root" lib="">
|
||||
<!-- 参数完全同上 -->
|
||||
<services autoload="true" includes="" excludes="" />
|
||||
</server>
|
||||
|
||||
</application>
|
||||
|
||||
@@ -19,7 +19,7 @@ java.util.logging.FileHandler.pattern = ${APP_HOME}/logs-%tY%tm/log-%tY%tm%td.lo
|
||||
#java.util.logging.FileHandler.unusual \u5c5e\u6027\u8868\u793a\u5c06 WARNING\u3001SEVERE \u7ea7\u522b\u7684\u65e5\u5fd7\u590d\u5236\u5199\u5165\u5355\u72ec\u7684\u6587\u4ef6\u4e2d
|
||||
java.util.logging.FileHandler.unusual = ${APP_HOME}/logs-%tY%tm/log-warnerr-%tY%tm%td.log
|
||||
#\u9700\u8981\u5c4f\u853d\u6d88\u606f\u5185\u5bb9\u7684\u6b63\u5219\u8868\u8fbe\u5f0f
|
||||
java.util.logging.FileHandler.denyreg =
|
||||
java.util.logging.FileHandler.denyregex =
|
||||
java.util.logging.FileHandler.append = true
|
||||
|
||||
#java.util.logging.ConsoleHandler.level = FINE
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
【已废弃】,建议使用 source.properties
|
||||
其配置算是标准的JPA配置文件的缩略版
|
||||
-->
|
||||
<persistence>
|
||||
<!-- 系统基本库 -->
|
||||
<persistence-unit name="demouser">
|
||||
<properties>
|
||||
<!--
|
||||
DataSource的实现类,没有设置默认为org.redkale.source.DataJdbcSource的实现,使用常规基于JDBC的数据库驱动一般无需设置
|
||||
-->
|
||||
<property name="javax.persistence.datasource" value="org.redkale.source.DataJdbcSource"/>
|
||||
<!--
|
||||
是否开启缓存(标记为@Cacheable的Entity类),值目前只支持两种: ALL: 所有开启缓存。 NONE: 关闭所有缓存, 非NONE字样统一视为ALL
|
||||
-->
|
||||
<property name="javax.persistence.cachemode" value="ALL"/>
|
||||
<!--
|
||||
是否自动建表当表不存在的时候, 目前只支持mysql、postgres, 默认为false
|
||||
-->
|
||||
<property name="javax.persistence.table.autoddl" value="false"/>
|
||||
|
||||
<!-- 多个URL用;隔开,如分布式SearchSource需要配多个URL -->
|
||||
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://127.0.0.1:3306/dbuser?characterEncoding=utf8"/>
|
||||
<property name="javax.persistence.jdbc.user" value="root"/>
|
||||
<property name="javax.persistence.jdbc.password" value="123456"/>
|
||||
|
||||
<!-- 最大连接数,默认值:CPU数 -->
|
||||
<property name="javax.persistence.connections.limit" value="12"/>
|
||||
|
||||
<!-- 包含的SQL模板,相当于反向LIKE,不同的JDBC驱动的SQL语句不一样,Redkale内置了MySQL的语句 -->
|
||||
<property name="javax.persistence.contain.sqltemplate" value="LOCATE(${keystr}, ${column}) > 0"/>
|
||||
<property name="javax.persistence.notcontain.sqltemplate" value="LOCATE(${keystr}, ${column}) = 0"/>
|
||||
|
||||
<!-- 复制表结构的SQL模板,Redkale内置了MySQL的语句 -->
|
||||
<property name="javax.persistence.tablenotexist.sqlstates" value="42000;42S02"/>
|
||||
<property name="javax.persistence.tablecopy.sqltemplate" value="CREATE TABLE IF NOT EXISTS ${newtable} LIKE ${oldtable}"/>
|
||||
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
<!-- IM消息库 -->
|
||||
<persistence-unit name="demoim">
|
||||
<properties>
|
||||
<!-- jdbc:mysql://127.0.0.1:3306/dbim?allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&serverTimezone=UTC&characterEncoding=utf8 -->
|
||||
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://127.0.0.1:3306/dbim?characterEncoding=utf8"/>
|
||||
<property name="javax.persistence.jdbc.user" value="root"/>
|
||||
<property name="javax.persistence.jdbc.password" value="123456"/>
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
</persistence>
|
||||
@@ -1,50 +1,50 @@
|
||||
|
||||
# CacheSource @Resource(name="usersession")
|
||||
# type\u53ef\u4ee5\u4e0d\u7528\u8bbe\u7f6e\uff0c\u6846\u67b6\u4f1a\u6839\u636eurl\u5224\u65ad\u4f7f\u7528\u54ea\u4e2aCacheSource\u5b9e\u73b0\u7c7b
|
||||
redkale.cachesource[usersession].type = org.redkalex.cache.redis.RedisCacheSource
|
||||
# \u6700\u5927\u8fde\u63a5\u6570
|
||||
redkale.cachesource[usersession].maxconns = 16
|
||||
# \u8282\u70b9\u5730\u5740
|
||||
redkale.cachesource[usersession].node[0].url = redis://127.0.0.1:6363
|
||||
# \u8282\u70b9\u5bc6\u7801
|
||||
redkale.cachesource[usersession].node[0].password = 12345678
|
||||
# \u8282\u70b9db
|
||||
redkale.cachesource[usersession].node[0].db = 0
|
||||
|
||||
#\u7b80\u5316\u5199\u6cd5: \u53ef\u4ee5\u4e0d\u7528.node[0], \u5c06\u53c2\u6570\u90fd\u5408\u5e76\u5230url\u4e2d
|
||||
redkale.cachesource[usersession].url = redis://user:123456@127.0.0.1:6363?db=0
|
||||
|
||||
|
||||
# DataSource @Resource(name="platf")
|
||||
# type\u53ef\u4ee5\u4e0d\u7528\u8bbe\u7f6e\uff0c\u6846\u67b6\u4f1a\u6839\u636eurl\u5224\u65ad\u4f7f\u7528\u54ea\u4e2aDataSource\u5b9e\u73b0\u7c7b\uff0c\u9ed8\u8ba4\u503c: org.redkale.source.DataJdbcSource
|
||||
redkale.datasource[platf].type = org.redkale.source.DataJdbcSource
|
||||
# \u662f\u5426\u5f00\u542f\u7f13\u5b58(\u6807\u8bb0\u4e3a@Cacheable\u7684Entity\u7c7b)\uff0c\u503c\u76ee\u524d\u53ea\u652f\u6301\u4e24\u79cd\uff1a ALL: \u6240\u6709\u5f00\u542f\u7f13\u5b58\u3002 NONE: \u5173\u95ed\u6240\u6709\u7f13\u5b58\uff0c \u975eNONE\u5b57\u6837\u7edf\u4e00\u89c6\u4e3aALL
|
||||
redkale.datasource[platf].cachemode = ALL
|
||||
# \u662f\u5426\u81ea\u52a8\u5efa\u8868\u5f53\u8868\u4e0d\u5b58\u5728\u7684\u65f6\u5019\uff0c \u76ee\u524d\u53ea\u652f\u6301mysql\u3001postgres\uff0c \u9ed8\u8ba4\u4e3afalse
|
||||
redkale.datasource[platf].table-autoddl = false
|
||||
# \u7528\u6237
|
||||
redkale.datasource[platf].user = root
|
||||
# \u5bc6\u7801
|
||||
redkale.datasource[platf].password = 12345678
|
||||
# \u591a\u4e2aURL\u7528;\u9694\u5f00\uff0c\u5982\u5206\u5e03\u5f0fSearchSource\u9700\u8981\u914d\u591a\u4e2aURL
|
||||
redkale.datasource[platf].url = jdbc:mysql://127.0.0.1:3306/platf?allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&serverTimezone=UTC&characterEncoding=utf8
|
||||
# \u6700\u5927\u8fde\u63a5\u6570\uff0c\u9ed8\u8ba4\u503c\uff1aCPU\u6570
|
||||
redkale.datasource[platf].maxconns = 16
|
||||
# \u5305\u542b\u7684SQL\u6a21\u677f\uff0c\u76f8\u5f53\u4e8e\u53cd\u5411LIKE\uff0c\u4e0d\u540c\u7684JDBC\u9a71\u52a8\u7684SQL\u8bed\u53e5\u4e0d\u4e00\u6837\uff0cRedkale\u5185\u7f6e\u4e86MySQL\u7684\u8bed\u53e5
|
||||
redkale.datasource[platf].contain-sqltemplate = LOCATE(${keystr}, ${column}) > 0
|
||||
# \u5305\u542b\u7684SQL\u6a21\u677f\uff0c\u76f8\u5f53\u4e8e\u53cd\u5411LIKE\uff0c\u4e0d\u540c\u7684JDBC\u9a71\u52a8\u7684SQL\u8bed\u53e5\u4e0d\u4e00\u6837\uff0cRedkale\u5185\u7f6e\u4e86MySQL\u7684\u8bed\u53e5
|
||||
redkale.datasource[platf].notcontain-sqltemplate = LOCATE(${keystr}, ${column}) = 0
|
||||
# \u590d\u5236\u8868\u7ed3\u6784\u7684SQL\u6a21\u677f\uff0cRedkale\u5185\u7f6e\u4e86MySQL\u7684\u8bed\u53e5
|
||||
redkale.datasource[platf].tablenotexist-sqlstates = 42000;42S02
|
||||
# \u590d\u5236\u8868\u7ed3\u6784\u7684SQL\u6a21\u677f\uff0cRedkale\u5185\u7f6e\u4e86MySQL\u7684\u8bed\u53e5
|
||||
redkale.datasource[platf].tablecopy-sqltemplate = CREATE TABLE IF NOT EXISTS ${newtable} LIKE ${oldtable}
|
||||
|
||||
|
||||
# DataSource \u8bfb\u5199\u5206\u79bb
|
||||
redkale.datasource[platf].read.url = jdbc:mysql://127.0.0.1:3306/platf_r?allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&serverTimezone=UTC&characterEncoding=utf8
|
||||
redkale.datasource[platf].read.user = root
|
||||
redkale.datasource[platf].read.password = 12345678
|
||||
|
||||
redkale.datasource[platf].write.url = jdbc:mysql://127.0.0.1:3306/platf_w?allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&serverTimezone=UTC&characterEncoding=utf8
|
||||
redkale.datasource[platf].write.user = root
|
||||
redkale.datasource[platf].write.password = 12345678
|
||||
|
||||
# CacheSource @Resource(name="usersession")
|
||||
# type\u53ef\u4ee5\u4e0d\u7528\u8bbe\u7f6e\uff0c\u6846\u67b6\u4f1a\u6839\u636eurl\u5224\u65ad\u4f7f\u7528\u54ea\u4e2aCacheSource\u5b9e\u73b0\u7c7b
|
||||
redkale.cachesource.usersession.type = org.redkalex.cache.redis.RedisCacheSource
|
||||
# \u6700\u5927\u8fde\u63a5\u6570
|
||||
redkale.cachesource.usersession.maxconns = 16
|
||||
# \u8282\u70b9\u5730\u5740
|
||||
redkale.cachesource.usersession.nodes = redis://127.0.0.1:6363
|
||||
# \u8282\u70b9\u5bc6\u7801
|
||||
redkale.cachesource.usersession.password = 12345678
|
||||
# \u8282\u70b9db
|
||||
redkale.cachesource.usersession.db = 0
|
||||
|
||||
#\u7b80\u5316\u5199\u6cd5: \u53ef\u4ee5\u4e0d\u7528.node[0], \u5c06\u53c2\u6570\u90fd\u5408\u5e76\u5230url\u4e2d
|
||||
redkale.cachesource.usersession.url = redis://user:123456@127.0.0.1:6363?db=0
|
||||
|
||||
|
||||
# DataSource @Resource(name="platf")
|
||||
# type\u53ef\u4ee5\u4e0d\u7528\u8bbe\u7f6e\uff0c\u6846\u67b6\u4f1a\u6839\u636eurl\u5224\u65ad\u4f7f\u7528\u54ea\u4e2aDataSource\u5b9e\u73b0\u7c7b\uff0c\u9ed8\u8ba4\u503c: org.redkale.source.DataJdbcSource
|
||||
redkale.datasource.platf.type = org.redkale.source.DataJdbcSource
|
||||
# \u662f\u5426\u5f00\u542f\u7f13\u5b58(\u6807\u8bb0\u4e3a@Cacheable\u7684Entity\u7c7b)\uff0c\u503c\u76ee\u524d\u53ea\u652f\u6301\u4e24\u79cd\uff1a ALL: \u6240\u6709\u5f00\u542f\u7f13\u5b58\u3002 NONE: \u5173\u95ed\u6240\u6709\u7f13\u5b58\uff0c \u975eNONE\u5b57\u6837\u7edf\u4e00\u89c6\u4e3aALL
|
||||
redkale.datasource.platf.cachemode = ALL
|
||||
# \u662f\u5426\u81ea\u52a8\u5efa\u8868\u5f53\u8868\u4e0d\u5b58\u5728\u7684\u65f6\u5019\uff0c \u76ee\u524d\u53ea\u652f\u6301mysql\u3001postgres\uff0c \u9ed8\u8ba4\u4e3afalse
|
||||
redkale.datasource.platf.table-autoddl = false
|
||||
# \u7528\u6237
|
||||
redkale.datasource.platf.user = root
|
||||
# \u5bc6\u7801
|
||||
redkale.datasource.platf.password = 12345678
|
||||
# \u591a\u4e2aURL\u7528;\u9694\u5f00\uff0c\u5982\u5206\u5e03\u5f0fSearchSource\u9700\u8981\u914d\u591a\u4e2aURL
|
||||
redkale.datasource.platf.url = jdbc:mysql://127.0.0.1:3306/platf?allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&serverTimezone=UTC&characterEncoding=utf8
|
||||
# \u6700\u5927\u8fde\u63a5\u6570\uff0c\u9ed8\u8ba4\u503c\uff1aCPU\u6570
|
||||
redkale.datasource.platf.maxconns = 16
|
||||
# \u5305\u542b\u7684SQL\u6a21\u677f\uff0c\u76f8\u5f53\u4e8e\u53cd\u5411LIKE\uff0c\u4e0d\u540c\u7684JDBC\u9a71\u52a8\u7684SQL\u8bed\u53e5\u4e0d\u4e00\u6837\uff0cRedkale\u5185\u7f6e\u4e86MySQL\u7684\u8bed\u53e5
|
||||
redkale.datasource.platf.contain-sqltemplate = LOCATE(#{keystr}, #{column}) > 0
|
||||
# \u5305\u542b\u7684SQL\u6a21\u677f\uff0c\u76f8\u5f53\u4e8e\u53cd\u5411LIKE\uff0c\u4e0d\u540c\u7684JDBC\u9a71\u52a8\u7684SQL\u8bed\u53e5\u4e0d\u4e00\u6837\uff0cRedkale\u5185\u7f6e\u4e86MySQL\u7684\u8bed\u53e5
|
||||
redkale.datasource.platf.notcontain-sqltemplate = LOCATE(#{keystr}, #{column}) = 0
|
||||
# \u590d\u5236\u8868\u7ed3\u6784\u7684SQL\u6a21\u677f\uff0cRedkale\u5185\u7f6e\u4e86MySQL\u7684\u8bed\u53e5
|
||||
redkale.datasource.platf.tablenotexist-sqlstates = 42000;42S02
|
||||
# \u590d\u5236\u8868\u7ed3\u6784\u7684SQL\u6a21\u677f\uff0cRedkale\u5185\u7f6e\u4e86MySQL\u7684\u8bed\u53e5
|
||||
redkale.datasource.platf.tablecopy-sqltemplate = CREATE TABLE IF NOT EXISTS #{newtable} LIKE #{oldtable}
|
||||
|
||||
|
||||
# DataSource \u8bfb\u5199\u5206\u79bb
|
||||
redkale.datasource.platf.read.url = jdbc:mysql://127.0.0.1:3306/platf_r?allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&serverTimezone=UTC&characterEncoding=utf8
|
||||
redkale.datasource.platf.read.user = root
|
||||
redkale.datasource.platf.read.password = 12345678
|
||||
|
||||
redkale.datasource.platf.write.url = jdbc:mysql://127.0.0.1:3306/platf_w?allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&serverTimezone=UTC&characterEncoding=utf8
|
||||
redkale.datasource.platf.write.user = root
|
||||
redkale.datasource.platf.write.password = 12345678
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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 javax.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 值越大,优先级越高
|
||||
*
|
||||
* @since Common Annotations 1.2
|
||||
*/
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Priority {
|
||||
|
||||
/**
|
||||
* 优先级值
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int value();
|
||||
}
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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 javax.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 值越大,优先级越高
|
||||
*
|
||||
* @see org.redkale.annotation.Priority
|
||||
* @since Common Annotations 1.2
|
||||
* @deprecated replace by {@link org.redkale.annotation.Priority}
|
||||
*/
|
||||
@Deprecated(since = "2.8.0")
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Priority {
|
||||
|
||||
/**
|
||||
* 优先级值
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int value();
|
||||
}
|
||||
|
||||
@@ -1,83 +1,83 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package javax.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @since Common Annotations 1.0
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Resource {
|
||||
|
||||
// /**
|
||||
// * AuthenticationType
|
||||
// */
|
||||
// @Deprecated
|
||||
// public enum AuthenticationType {
|
||||
// /**
|
||||
// * @deprecated
|
||||
// */
|
||||
// CONTAINER,
|
||||
// /**
|
||||
// * @deprecated
|
||||
// */
|
||||
// APPLICATION
|
||||
// }
|
||||
|
||||
/**
|
||||
* 资源名称
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String name() default "";
|
||||
|
||||
/**
|
||||
* 依赖注入的类型
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class<?> type() default Object.class;
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// * @return AuthenticationType
|
||||
// */
|
||||
// @Deprecated
|
||||
// public AuthenticationType authenticationType() default AuthenticationType.CONTAINER;
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// * @return boolean
|
||||
// */
|
||||
// @Deprecated
|
||||
// public boolean shareable() default true;
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// * @return String
|
||||
// */
|
||||
// @Deprecated
|
||||
// public String description() default "";
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// * @return String
|
||||
// */
|
||||
// @Deprecated
|
||||
// public String mappedName() default "";
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// * @return String
|
||||
// */
|
||||
// @Deprecated
|
||||
// public String lookup() default "";
|
||||
}
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package javax.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @since Common Annotations 1.0
|
||||
* @see org.redkale.annotation.Resource
|
||||
* @deprecated replace by {@link org.redkale.annotation.Resource}
|
||||
*/
|
||||
@Deprecated(since = "2.8.0")
|
||||
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Resource {
|
||||
|
||||
// /**
|
||||
// * AuthenticationType
|
||||
// */
|
||||
// @Deprecated
|
||||
// public enum AuthenticationType {
|
||||
// /**
|
||||
// * @deprecated
|
||||
// */
|
||||
// CONTAINER,
|
||||
// /**
|
||||
// * @deprecated
|
||||
// */
|
||||
// APPLICATION
|
||||
// }
|
||||
//
|
||||
/**
|
||||
* 资源名称
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String name() default "";
|
||||
|
||||
/**
|
||||
* 依赖注入的类型
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class<?> type() default Object.class;
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// * @return AuthenticationType
|
||||
// */
|
||||
// @Deprecated
|
||||
// public AuthenticationType authenticationType() default AuthenticationType.CONTAINER;
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// * @return boolean
|
||||
// */
|
||||
// @Deprecated
|
||||
// public boolean shareable() default true;
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// * @return String
|
||||
// */
|
||||
// @Deprecated
|
||||
// public String description() default "";
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// * @return String
|
||||
// */
|
||||
// @Deprecated
|
||||
// public String mappedName() default "";
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// * @return String
|
||||
// */
|
||||
// @Deprecated
|
||||
// public String lookup() default "";
|
||||
}
|
||||
|
||||
@@ -1,62 +1,58 @@
|
||||
/** *****************************************************************************
|
||||
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
|
||||
* which accompanies this distribution.
|
||||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Linda DeMichiel - Java Persistence 2.1
|
||||
* Linda DeMichiel - Java Persistence 2.0
|
||||
*
|
||||
***************************************************************************** */
|
||||
package javax.persistence;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Specifies whether an entity should be cached if caching is enabled
|
||||
* when the value of the <code>persistence.xml</code> caching element
|
||||
* is <code>ENABLE_SELECTIVE</code> or <code>DISABLE_SELECTIVE</code>.
|
||||
* The value of the <code>Cacheable</code> annotation is inherited by
|
||||
* subclasses; it can be overridden by specifying
|
||||
* <code>Cacheable</code> on a subclass.
|
||||
*
|
||||
* <p>
|
||||
* <code>Cacheable(false)</code> means that the entity and its state must
|
||||
* not be cached by the provider.
|
||||
*
|
||||
* @since Java Persistence 2.0
|
||||
*/
|
||||
@Target({TYPE})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Cacheable {
|
||||
|
||||
/**
|
||||
* (Optional) Whether or not the entity should be cached.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean value() default true;
|
||||
|
||||
/**
|
||||
* (Optional) 定时自动更新缓存的周期秒数,为0表示不做定时更新, 大于0表示每经过interval秒后会自动从数据库中拉取数据更新Cache
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int interval() default 0;
|
||||
|
||||
/**
|
||||
* DataSource是否直接返回对象的真实引用, 而不是copy一份
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean direct() default false;
|
||||
|
||||
}
|
||||
/**
|
||||
* ***************************************************************************** Copyright (c) 2008 - 2013 Oracle
|
||||
* Corporation. All rights reserved.
|
||||
*
|
||||
* <p>This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0
|
||||
* and Eclipse Distribution License v. 1.0 which accompanies this distribution. The Eclipse Public License is available
|
||||
* at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* <p>Contributors: Linda DeMichiel - Java Persistence 2.1 Linda DeMichiel - Java Persistence 2.0
|
||||
*
|
||||
* <p>****************************************************************************
|
||||
*/
|
||||
package javax.persistence;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Specifies whether an entity should be cached if caching is enabled when the value of the <code>persistence.xml</code>
|
||||
* caching element is <code>ENABLE_SELECTIVE</code> or <code>DISABLE_SELECTIVE</code>. The value of the <code>Cacheable
|
||||
* </code> annotation is inherited by subclasses; it can be overridden by specifying <code>Cacheable</code> on a
|
||||
* subclass.
|
||||
*
|
||||
* <p><code>Cacheable(false)</code> means that the entity and its state must not be cached by the provider.
|
||||
*
|
||||
* @since Java Persistence 2.0
|
||||
* @deprecated replace by {@link org.redkale.persistence.Cacheable}
|
||||
* @see org.redkale.persistence.Cacheable
|
||||
*/
|
||||
@Deprecated(since = "2.8.0")
|
||||
@Target({TYPE})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Cacheable {
|
||||
|
||||
/**
|
||||
* (Optional) Whether or not the entity should be cached.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean value() default true;
|
||||
|
||||
/**
|
||||
* (Optional) 定时自动更新缓存的周期秒数,为0表示不做定时更新, 大于0表示每经过interval秒后会自动从数据库中拉取数据更新Cache
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int interval() default 0;
|
||||
|
||||
/**
|
||||
* DataSource是否直接返回对象的真实引用, 而不是copy一份
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean direct() default false;
|
||||
}
|
||||
|
||||
@@ -1,31 +1,30 @@
|
||||
/** *****************************************************************************
|
||||
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
|
||||
/**
|
||||
* ***************************************************************************** Copyright (c) 2008 - 2013 Oracle
|
||||
* Corporation. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
|
||||
* which accompanies this distribution.
|
||||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* <p>This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0
|
||||
* and Eclipse Distribution License v. 1.0 which accompanies this distribution. The Eclipse Public License is available
|
||||
* at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Linda DeMichiel - Java Persistence 2.1
|
||||
* Linda DeMichiel - Java Persistence 2.0
|
||||
* <p>Contributors: Linda DeMichiel - Java Persistence 2.1 Linda DeMichiel - Java Persistence 2.0
|
||||
*
|
||||
***************************************************************************** */
|
||||
* <p>****************************************************************************
|
||||
*/
|
||||
package javax.persistence;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Specifies the mapped column for a persistent property or field.
|
||||
* If no <code>Column</code> annotation is specified, the default values apply.
|
||||
* Specifies the mapped column for a persistent property or field. If no <code>Column</code> annotation is specified,
|
||||
* the default values apply.
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* <blockquote>
|
||||
*
|
||||
* <pre>
|
||||
* Example 1:
|
||||
*
|
||||
* @Column(name="DESC", nullable=false, length=512)
|
||||
@@ -44,18 +43,21 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
* @Column(name="ORDER_COST", updatable=false, precision=12, scale=2)
|
||||
* public BigDecimal getCost() { return cost; }
|
||||
*
|
||||
* </pre></blockquote>
|
||||
* </pre>
|
||||
*
|
||||
* </blockquote>
|
||||
*
|
||||
* @since Java Persistence 1.0
|
||||
* @deprecated replace by {@link org.redkale.persistence.Column}
|
||||
* @see org.redkale.persistence.Column
|
||||
*/
|
||||
@Deprecated(since = "2.8.0")
|
||||
@Target({METHOD, FIELD})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Column {
|
||||
|
||||
/**
|
||||
* (Optional) The name of the column. Defaults to
|
||||
* the property or field name.
|
||||
* (Optional) The name of the column. Defaults to the property or field name.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
@@ -69,12 +71,10 @@ public @interface Column {
|
||||
String comment() default "";
|
||||
|
||||
/**
|
||||
* (Optional) Whether the column is a unique key. This is a
|
||||
* shortcut for the <code>UniqueConstraint</code> annotation at the table
|
||||
* level and is useful for when the unique key constraint
|
||||
* corresponds to only a single column. This constraint applies
|
||||
* in addition to any constraint entailed by primary key mapping and
|
||||
* to constraints specified at the table level.
|
||||
* (Optional) Whether the column is a unique key. This is a shortcut for the <code>UniqueConstraint</code>
|
||||
* annotation at the table level and is useful for when the unique key constraint corresponds to only a single
|
||||
* column. This constraint applies in addition to any constraint entailed by primary key mapping and to constraints
|
||||
* specified at the table level.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
@@ -95,24 +95,22 @@ public @interface Column {
|
||||
String example() default "";
|
||||
|
||||
/**
|
||||
* (Optional) Whether the column is included in SQL INSERT
|
||||
* statements generated by the persistence provider.
|
||||
* (Optional) Whether the column is included in SQL INSERT statements generated by the persistence provider.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean insertable() default true;
|
||||
|
||||
/**
|
||||
* (Optional) Whether the column is included in SQL UPDATE
|
||||
* statements generated by the persistence provider.
|
||||
* (Optional) Whether the column is included in SQL UPDATE statements generated by the persistence provider.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean updatable() default true;
|
||||
|
||||
/**
|
||||
* (Optional) The name of the table that contains the column.
|
||||
* If absent the column is assumed to be in the primary table.
|
||||
* (Optional) The name of the table that contains the column. If absent the column is assumed to be in the primary
|
||||
* table.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
@@ -120,32 +118,28 @@ public @interface Column {
|
||||
String table() default "";
|
||||
|
||||
/**
|
||||
* (Optional) The column length. (Applies only if a
|
||||
* string-valued column is used.)
|
||||
* if type==String and length == 65535 then sqltype is TEXT <br>
|
||||
* if type==String and length <= 16777215 then sqltype is MEDIUMTEXT <br>
|
||||
* if type==String and length > 16777215 then sqltype is LONGTEXT <br>
|
||||
* if type==byte[] and length <= 65535 then sqltype is BLOB <br>
|
||||
* if type==byte[] and length <= 16777215 then sqltype is MEDIUMBLOB <br>
|
||||
* if type==byte[] and length > 16777215 then sqltype is LONGBLOB <br>
|
||||
* (Optional) The column length. (Applies only if a string-valued column is used.) if type==String and length ==
|
||||
* 65535 then sqltype is TEXT <br>
|
||||
* if type==String and length <= 16777215 then sqltype is MEDIUMTEXT <br>
|
||||
* if type==String and length > 16777215 then sqltype is LONGTEXT <br>
|
||||
* if type==byte[] and length <= 65535 then sqltype is BLOB <br>
|
||||
* if type==byte[] and length <= 16777215 then sqltype is MEDIUMBLOB <br>
|
||||
* if type==byte[] and length > 16777215 then sqltype is LONGBLOB <br>
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int length() default 255;
|
||||
|
||||
/**
|
||||
* (Optional) The precision for a decimal (exact numeric)
|
||||
* column. (Applies only if a decimal column is used.)
|
||||
* Value must be set by developer if used when generating
|
||||
* the DDL for the column.
|
||||
* (Optional) The precision for a decimal (exact numeric) column. (Applies only if a decimal column is used.) Value
|
||||
* must be set by developer if used when generating the DDL for the column.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int precision() default 0;
|
||||
|
||||
/**
|
||||
* (Optional) The scale for a decimal (exact numeric) column.
|
||||
* (Applies only if a decimal column is used.)
|
||||
* (Optional) The scale for a decimal (exact numeric) column. (Applies only if a decimal column is used.)
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
|
||||
/**
|
||||
* ***************************************************************************** Copyright (c) 2008 - 2013 Oracle
|
||||
* Corporation. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
|
||||
* which accompanies this distribution.
|
||||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* <p>This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0
|
||||
* and Eclipse Distribution License v. 1.0 which accompanies this distribution. The Eclipse Public License is available
|
||||
* at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Linda DeMichiel - Java Persistence 2.1
|
||||
* Linda DeMichiel - Java Persistence 2.0
|
||||
* <p>Contributors: Linda DeMichiel - Java Persistence 2.1 Linda DeMichiel - Java Persistence 2.0
|
||||
*
|
||||
******************************************************************************/
|
||||
* <p>****************************************************************************
|
||||
*/
|
||||
package javax.persistence;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Specifies that the class is an entity. This annotation is applied to the
|
||||
* entity class.
|
||||
*
|
||||
* Specifies that the class is an entity. This annotation is applied to the entity class.
|
||||
*
|
||||
* @since Java Persistence 1.0
|
||||
* @deprecated replace by {@link org.redkale.persistence.Entity}
|
||||
* @see org.redkale.persistence.Entity
|
||||
*/
|
||||
@Deprecated(since = "2.8.0")
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target(TYPE)
|
||||
@Retention(RUNTIME)
|
||||
public @interface Entity {
|
||||
|
||||
/**
|
||||
* (Optional) The entity name. Defaults to the unqualified
|
||||
* name of the entity class. This name is used to refer to the
|
||||
* entity in queries. The name must not be a reserved literal
|
||||
* in the Java Persistence query language.
|
||||
/**
|
||||
* (Optional) The entity name. Defaults to the unqualified name of the entity class. This name is used to refer to
|
||||
* the entity in queries. The name must not be a reserved literal in the Java Persistence query language.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String name() default "";
|
||||
|
||||
*/
|
||||
String name() default "";
|
||||
|
||||
/**
|
||||
* (Optional) The comment of the entity.
|
||||
*
|
||||
|
||||
@@ -1,41 +1,32 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
|
||||
/**
|
||||
* ***************************************************************************** Copyright (c) 2008 - 2013 Oracle
|
||||
* Corporation. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
|
||||
* which accompanies this distribution.
|
||||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* <p>This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0
|
||||
* and Eclipse Distribution License v. 1.0 which accompanies this distribution. The Eclipse Public License is available
|
||||
* at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Linda DeMichiel - Java Persistence 2.1
|
||||
* Linda DeMichiel - Java Persistence 2.0
|
||||
* <p>Contributors: Linda DeMichiel - Java Persistence 2.1 Linda DeMichiel - Java Persistence 2.0
|
||||
*
|
||||
******************************************************************************/
|
||||
* <p>****************************************************************************
|
||||
*/
|
||||
package javax.persistence;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Specifies the primary key of an entity.
|
||||
* The field or property to which the <code>Id</code> annotation is applied
|
||||
* should be one of the following types: any Java primitive type;
|
||||
* any primitive wrapper type;
|
||||
* <code>String</code>;
|
||||
* <code>java.util.Date</code>;
|
||||
* <code>java.sql.Date</code>;
|
||||
* <code>java.math.BigDecimal</code>;
|
||||
* <code>java.math.BigInteger</code>.
|
||||
* Specifies the primary key of an entity. The field or property to which the <code>Id</code> annotation is applied
|
||||
* should be one of the following types: any Java primitive type; any primitive wrapper type; <code>String</code>;
|
||||
* <code>java.util.Date</code>; <code>java.sql.Date</code>; <code>java.math.BigDecimal</code>; <code>
|
||||
* java.math.BigInteger</code>.
|
||||
*
|
||||
* <p>The mapped column for the primary key of the entity is assumed
|
||||
* to be the primary key of the primary table. If no <code>Column</code> annotation
|
||||
* is specified, the primary key column name is assumed to be the name
|
||||
* of the primary key property or field.
|
||||
* <p>The mapped column for the primary key of the entity is assumed to be the primary key of the primary table. If no
|
||||
* <code>Column</code> annotation is specified, the primary key column name is assumed to be the name of the primary key
|
||||
* property or field.
|
||||
*
|
||||
* <pre>
|
||||
* Example:
|
||||
@@ -44,12 +35,12 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
* public Long getId() { return id; }
|
||||
* </pre>
|
||||
*
|
||||
* @see Column
|
||||
* see GeneratedValue
|
||||
*
|
||||
* @see Column see GeneratedValue
|
||||
* @since Java Persistence 1.0
|
||||
* @deprecated replace by {@link org.redkale.persistence.Id}
|
||||
* @see org.redkale.persistence.Id
|
||||
*/
|
||||
@Deprecated(since = "2.8.0")
|
||||
@Target({METHOD, FIELD})
|
||||
@Retention(RUNTIME)
|
||||
|
||||
public @interface Id {}
|
||||
|
||||
@@ -1,45 +1,42 @@
|
||||
/** *****************************************************************************
|
||||
* Copyright (c) 2011 - 2013 Oracle Corporation. All rights reserved.
|
||||
/**
|
||||
* ***************************************************************************** Copyright (c) 2011 - 2013 Oracle
|
||||
* Corporation. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
|
||||
* which accompanies this distribution.
|
||||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* <p>This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0
|
||||
* and Eclipse Distribution License v. 1.0 which accompanies this distribution. The Eclipse Public License is available
|
||||
* at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Linda DeMichiel - Java Persistence 2.1
|
||||
* <p>Contributors: Linda DeMichiel - Java Persistence 2.1
|
||||
*
|
||||
***************************************************************************** */
|
||||
* <p>****************************************************************************
|
||||
*/
|
||||
package javax.persistence;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Used in schema generation to specify creation of an index.
|
||||
* <p>
|
||||
* Note that it is not necessary to specify an index for a primary key,
|
||||
* as the primary key index will be created automatically.
|
||||
*
|
||||
* <p>
|
||||
* The syntax of the <code>columnList</code> element is a
|
||||
* <code>column_list</code>, as follows:
|
||||
* <p>Note that it is not necessary to specify an index for a primary key, as the primary key index will be created
|
||||
* automatically.
|
||||
*
|
||||
* <p>The syntax of the <code>columnList</code> element is a <code>column_list</code>, as follows:
|
||||
*
|
||||
* <pre>
|
||||
* column::= index_column [,index_column]*
|
||||
* index_column::= column_name [ASC | DESC]
|
||||
* </pre>
|
||||
*
|
||||
* <p>
|
||||
* If <code>ASC</code> or <code>DESC</code> is not specified,
|
||||
* <code>ASC</code> (ascending order) is assumed.
|
||||
* <p>If <code>ASC</code> or <code>DESC</code> is not specified, <code>ASC</code> (ascending order) is assumed.
|
||||
*
|
||||
* @since Java Persistence 2.1
|
||||
*
|
||||
* @deprecated replace by {@link org.redkale.persistence.Index}
|
||||
* @see org.redkale.persistence.Index
|
||||
*/
|
||||
@Deprecated(since = "2.8.0")
|
||||
@Target({})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Index {
|
||||
@@ -52,8 +49,7 @@ public @interface Index {
|
||||
String name() default "";
|
||||
|
||||
/**
|
||||
* (Required) The names of the columns to be included in the index,
|
||||
* in order.
|
||||
* (Required) The names of the columns to be included in the index, in order.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
@@ -65,5 +61,4 @@ public @interface Index {
|
||||
* @return boolean
|
||||
*/
|
||||
boolean unique() default false;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,32 +1,28 @@
|
||||
/** *****************************************************************************
|
||||
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
|
||||
/**
|
||||
* ***************************************************************************** Copyright (c) 2008 - 2013 Oracle
|
||||
* Corporation. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
|
||||
* which accompanies this distribution.
|
||||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* <p>This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0
|
||||
* and Eclipse Distribution License v. 1.0 which accompanies this distribution. The Eclipse Public License is available
|
||||
* at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Linda DeMichiel - Java Persistence 2.1
|
||||
* Linda DeMichiel - Java Persistence 2.0
|
||||
* <p>Contributors: Linda DeMichiel - Java Persistence 2.1 Linda DeMichiel - Java Persistence 2.0
|
||||
*
|
||||
***************************************************************************** */
|
||||
* <p>****************************************************************************
|
||||
*/
|
||||
package javax.persistence;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Specifies the primary table for the annotated entity. Additional
|
||||
* tables may be specified using SecondaryTable or SecondaryTables annotation.
|
||||
* Specifies the primary table for the annotated entity. Additional tables may be specified using SecondaryTable or
|
||||
* SecondaryTables annotation.
|
||||
*
|
||||
* <p>
|
||||
* If no <code>Table</code> annotation is specified for an entity
|
||||
* class, the default values apply.
|
||||
* <p>If no <code>Table</code> annotation is specified for an entity class, the default values apply.
|
||||
*
|
||||
* <pre>
|
||||
* Example:
|
||||
@@ -37,45 +33,46 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
* </pre>
|
||||
*
|
||||
* @since Java Persistence 1.0
|
||||
* @deprecated replace by {@link org.redkale.persistence.Table}
|
||||
* @see org.redkale.persistence.Table
|
||||
*/
|
||||
@Deprecated(since = "2.8.0")
|
||||
@Target(TYPE)
|
||||
@Retention(RUNTIME)
|
||||
public @interface Table {
|
||||
|
||||
/**
|
||||
* (Optional) The name of the table.
|
||||
* <p>
|
||||
* Defaults to the entity name.
|
||||
*
|
||||
* <p>Defaults to the entity name.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String name() default "";
|
||||
|
||||
/** (Optional) The catalog of the table.
|
||||
* <p>
|
||||
* Defaults to the default catalog.
|
||||
/**
|
||||
* (Optional) The catalog of the table.
|
||||
*
|
||||
* <p>Defaults to the default catalog.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String catalog() default "";
|
||||
|
||||
/**
|
||||
* (Optional) Unique constraints that are to be placed on
|
||||
* the table. These are only used if table generation is in
|
||||
* effect. These constraints apply in addition to any constraints
|
||||
* specified by the <code>Column</code> and <code>JoinColumn</code>
|
||||
* annotations and constraints entailed by primary key mappings.
|
||||
* <p>
|
||||
* Defaults to no additional constraints.
|
||||
* (Optional) Unique constraints that are to be placed on the table. These are only used if table generation is in
|
||||
* effect. These constraints apply in addition to any constraints specified by the <code>Column</code> and <code>
|
||||
* JoinColumn</code> annotations and constraints entailed by primary key mappings.
|
||||
*
|
||||
* <p>Defaults to no additional constraints.
|
||||
*
|
||||
* @return UniqueConstraint[]
|
||||
*/
|
||||
UniqueConstraint[] uniqueConstraints() default {};
|
||||
|
||||
/**
|
||||
* (Optional) Indexes for the table. These are only used if
|
||||
* table generation is in effect. Note that it is not necessary
|
||||
* to specify an index for a primary key, as the primary key
|
||||
* index will be created automatically.
|
||||
* (Optional) Indexes for the table. These are only used if table generation is in effect. Note that it is not
|
||||
* necessary to specify an index for a primary key, as the primary key index will be created automatically.
|
||||
*
|
||||
* @return indexes
|
||||
* @since Java Persistence 2.1
|
||||
@@ -84,9 +81,8 @@ public @interface Table {
|
||||
|
||||
/**
|
||||
* comment
|
||||
*
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String comment() default "";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,30 +1,26 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
|
||||
/**
|
||||
* ***************************************************************************** Copyright (c) 2008 - 2013 Oracle
|
||||
* Corporation. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
|
||||
* which accompanies this distribution.
|
||||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* <p>This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0
|
||||
* and Eclipse Distribution License v. 1.0 which accompanies this distribution. The Eclipse Public License is available
|
||||
* at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Linda DeMichiel - Java Persistence 2.1
|
||||
* Linda DeMichiel - Java Persistence 2.0
|
||||
* <p>Contributors: Linda DeMichiel - Java Persistence 2.1 Linda DeMichiel - Java Persistence 2.0
|
||||
*
|
||||
******************************************************************************/
|
||||
* <p>****************************************************************************
|
||||
*/
|
||||
package javax.persistence;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Specifies that the property or field is not persistent. It is used
|
||||
* to annotate a property or field of an entity class, mapped
|
||||
* superclass, or embeddable class.
|
||||
* Specifies that the property or field is not persistent. It is used to annotate a property or field of an entity
|
||||
* class, mapped superclass, or embeddable class.
|
||||
*
|
||||
* <pre>
|
||||
* Example:
|
||||
@@ -38,8 +34,10 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
* </pre>
|
||||
*
|
||||
* @since Java Persistence 1.0
|
||||
* @deprecated replace by {@link org.redkale.persistence.Transient}
|
||||
* @see org.redkale.persistence.Transient
|
||||
*/
|
||||
@Deprecated(since = "2.8.0")
|
||||
@Target({METHOD, FIELD})
|
||||
@Retention(RUNTIME)
|
||||
|
||||
public @interface Transient {}
|
||||
|
||||
@@ -1,27 +1,24 @@
|
||||
/** *****************************************************************************
|
||||
* Copyright (c) 2008 - 2013 Oracle Corporation. All rights reserved.
|
||||
/**
|
||||
* ***************************************************************************** Copyright (c) 2008 - 2013 Oracle
|
||||
* Corporation. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
|
||||
* which accompanies this distribution.
|
||||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
|
||||
* and the Eclipse Distribution License is available at
|
||||
* <p>This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0
|
||||
* and Eclipse Distribution License v. 1.0 which accompanies this distribution. The Eclipse Public License is available
|
||||
* at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* Contributors:
|
||||
* Linda DeMichiel - Java Persistence 2.1
|
||||
* Linda DeMichiel - Java Persistence 2.0
|
||||
* <p>Contributors: Linda DeMichiel - Java Persistence 2.1 Linda DeMichiel - Java Persistence 2.0
|
||||
*
|
||||
***************************************************************************** */
|
||||
* <p>****************************************************************************
|
||||
*/
|
||||
package javax.persistence;
|
||||
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Specifies that a unique constraint is to be included in
|
||||
* the generated DDL for a primary or secondary table.
|
||||
* Specifies that a unique constraint is to be included in the generated DDL for a primary or secondary table.
|
||||
*
|
||||
* <pre>
|
||||
* Example:
|
||||
@@ -35,20 +32,24 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
* </pre>
|
||||
*
|
||||
* @since Java Persistence 1.0
|
||||
* @deprecated replace by {@link org.redkale.persistence.UniqueConstraint}
|
||||
* @see org.redkale.persistence.UniqueConstraint
|
||||
*/
|
||||
@Deprecated(since = "2.8.0")
|
||||
@Target({})
|
||||
@Retention(RUNTIME)
|
||||
public @interface UniqueConstraint {
|
||||
|
||||
/** (Optional) Constraint name. A provider-chosen name will be chosen
|
||||
* if a name is not specified.
|
||||
/**
|
||||
* (Optional) Constraint name. A provider-chosen name will be chosen if a name is not specified.
|
||||
*
|
||||
* @return String
|
||||
* @since Java Persistence 2.0
|
||||
*/
|
||||
String name() default "";
|
||||
|
||||
/** (Required) An array of the column names that make up the constraint.
|
||||
/**
|
||||
* (Required) An array of the column names that make up the constraint.
|
||||
*
|
||||
* @return String[]
|
||||
*/
|
||||
|
||||
@@ -1,44 +1,54 @@
|
||||
/**
|
||||
* <p>
|
||||
* see: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*
|
||||
*/
|
||||
module redkale {
|
||||
|
||||
module org.redkale {
|
||||
requires java.base;
|
||||
requires java.logging;
|
||||
requires java.logging;
|
||||
requires java.net.http;
|
||||
requires java.sql;
|
||||
requires jdk.unsupported; //sun.misc.Unsafe
|
||||
requires jdk.unsupported; // sun.misc.Unsafe
|
||||
|
||||
exports javax.annotation;
|
||||
exports javax.persistence;
|
||||
|
||||
exports org.redkale.asm;
|
||||
exports org.redkale.annotation;
|
||||
exports org.redkale.boot;
|
||||
exports org.redkale.boot.watch;
|
||||
exports org.redkale.cached;
|
||||
exports org.redkale.cached.spi;
|
||||
exports org.redkale.cluster;
|
||||
exports org.redkale.cluster.spi;
|
||||
exports org.redkale.convert;
|
||||
exports org.redkale.convert.bson;
|
||||
exports org.redkale.convert.ext;
|
||||
exports org.redkale.convert.json;
|
||||
exports org.redkale.convert.pb;
|
||||
exports org.redkale.convert.spi;
|
||||
exports org.redkale.inject;
|
||||
exports org.redkale.locked;
|
||||
exports org.redkale.locked.spi;
|
||||
exports org.redkale.mq;
|
||||
exports org.redkale.mq.spi;
|
||||
exports org.redkale.net;
|
||||
exports org.redkale.net.client;
|
||||
exports org.redkale.net.http;
|
||||
exports org.redkale.net.sncp;
|
||||
exports org.redkale.persistence;
|
||||
exports org.redkale.props.spi;
|
||||
exports org.redkale.scheduled;
|
||||
exports org.redkale.scheduled.spi;
|
||||
exports org.redkale.service;
|
||||
exports org.redkale.source;
|
||||
exports org.redkale.source.spi;
|
||||
exports org.redkale.util;
|
||||
exports org.redkale.watch;
|
||||
|
||||
uses org.redkale.mq.MessageAgent;
|
||||
uses org.redkale.cluster.ClusterAgent;
|
||||
uses org.redkale.convert.ConvertProvider;
|
||||
uses org.redkale.source.CacheSourceProvider;
|
||||
uses org.redkale.source.DataSourceProvider;
|
||||
uses org.redkale.util.ResourceAnnotationProvider;
|
||||
|
||||
|
||||
uses org.redkale.util.YamlProvider;
|
||||
uses org.redkale.props.spi.PropertiesAgentProvider;
|
||||
uses org.redkale.cached.spi.CachedManagerProvider;
|
||||
uses org.redkale.cluster.spi.ClusterAgentProvider;
|
||||
uses org.redkale.convert.spi.ConvertProvider;
|
||||
uses org.redkale.mq.spi.MessageAgentProvider;
|
||||
uses org.redkale.scheduled.spi.ScheduledManagerProvider;
|
||||
uses org.redkale.source.spi.CacheSourceProvider;
|
||||
uses org.redkale.source.spi.DataSourceProvider;
|
||||
uses org.redkale.source.spi.DataNativeSqlParserProvider;
|
||||
}
|
||||
|
||||
27
src/main/java/org/redkale/annotation/AutoLoad.java
Normal file
27
src/main/java/org/redkale/annotation/AutoLoad.java
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* 自动加载。 使用场景: <br>
|
||||
* 1、被标记为@AutoLoad(false)的Service类不会被自动加载, 当被依赖时才会被加载 <br>
|
||||
* 2、被标记为@AutoLoad(false)的Servlet类不会被自动加载 <br>
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Documented
|
||||
@Target({TYPE})
|
||||
@Retention(RUNTIME)
|
||||
public @interface AutoLoad {
|
||||
|
||||
boolean value() default true;
|
||||
}
|
||||
26
src/main/java/org/redkale/annotation/ClassDepends.java
Normal file
26
src/main/java/org/redkale/annotation/ClassDepends.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
/**
|
||||
* 被标记的元素表示会被动态字节码调用
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@Documented
|
||||
@Target({TYPE, METHOD, FIELD, CONSTRUCTOR})
|
||||
@Retention(SOURCE)
|
||||
public @interface ClassDepends {
|
||||
|
||||
Class[] value() default {};
|
||||
|
||||
String comment() default "";
|
||||
}
|
||||
47
src/main/java/org/redkale/annotation/Command.java
Normal file
47
src/main/java/org/redkale/annotation/Command.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 接收命令的标记, 只能标记在本地模式下Service里参数为(String)或(String, String[])的public方法上
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@Documented
|
||||
@Target({METHOD})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Command {
|
||||
|
||||
/**
|
||||
* 命令号,没有指定值则接收所有的命令
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String value() default "";
|
||||
|
||||
/**
|
||||
* 参数帮助说明,在value不为空命令redkale --help时显示
|
||||
*
|
||||
* @return String
|
||||
* @since 2.7.0
|
||||
*/
|
||||
String description() default "";
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String comment() default "";
|
||||
}
|
||||
@@ -1,25 +1,29 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.service;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import org.redkale.util.*;
|
||||
|
||||
/**
|
||||
* 参数回写, 当Service的方法需要更改参数对象内部的数据时,需要使用RpcCall
|
||||
*
|
||||
* <p> 详情见: https://redkale.org
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target({ElementType.PARAMETER})
|
||||
@Retention(RUNTIME)
|
||||
public @interface RpcCall {
|
||||
|
||||
Class<? extends Attribute> value();
|
||||
}
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 标记注释,备注
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target({TYPE, METHOD, FIELD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, ANNOTATION_TYPE, TYPE_PARAMETER})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Comment {
|
||||
|
||||
String name() default "";
|
||||
|
||||
String value();
|
||||
}
|
||||
22
src/main/java/org/redkale/annotation/Component.java
Normal file
22
src/main/java/org/redkale/annotation/Component.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package org.redkale.annotation;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 标记Component的Service类特点: <br>
|
||||
* 1、直接构造, 不使用Sncp动态构建对象 <br>
|
||||
* 2、不会生成对应协议的Servlet <br>
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target({TYPE})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Component {}
|
||||
49
src/main/java/org/redkale/annotation/Configuration.java
Normal file
49
src/main/java/org/redkale/annotation/Configuration.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 启动服务时的初始化配置,需要结合{@link org.redkale.annotation.Resource}使用
|
||||
* <blockquote>
|
||||
* <pre>
|
||||
* @Configuration
|
||||
* public class MyConfiguration {
|
||||
*
|
||||
* @Resource(name = "a")
|
||||
* BeanA createBeanA() {
|
||||
* System.out.println("创建一个Bean");
|
||||
* BeanA bean = new BeanA();
|
||||
* bean.desc = "auto";
|
||||
* return bean;
|
||||
* }
|
||||
*
|
||||
* @Resource(name = "b")
|
||||
* BeanA createBeanA(@Resource(name = "dev.desc") String desc) {
|
||||
* System.out.println("创建一个Bean");
|
||||
* BeanA bean = new BeanA();
|
||||
* bean.desc = name;
|
||||
* return bean;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
*
|
||||
* <p>
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@Documented
|
||||
@Target({TYPE})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Configuration {}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 类似java.beans.ConstructorProperties, 必须配合Creator使用
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Documented
|
||||
@Target({METHOD, CONSTRUCTOR})
|
||||
@Retention(RUNTIME)
|
||||
@ClassDepends
|
||||
public @interface ConstructorParameters {
|
||||
|
||||
String[] value();
|
||||
}
|
||||
51
src/main/java/org/redkale/annotation/LogExcludeLevel.java
Normal file
51
src/main/java/org/redkale/annotation/LogExcludeLevel.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 等于level日志级别且包含keys字符串的日志才会被排除 <br>
|
||||
*
|
||||
* <blockquote>
|
||||
*
|
||||
* <pre>
|
||||
* @LogExcludeLevel(levels = {"FINEST"}, keys = {"SET username ="})
|
||||
* public class UserRecord {
|
||||
* public int userid;
|
||||
* public String username = "";
|
||||
* }
|
||||
*
|
||||
* 这样当调用DataSource对UserRecord对象进行操作时,拼接的SQL语句含"SET username ="字样的都会在FINEST日志级别过滤掉
|
||||
* </pre>
|
||||
*
|
||||
* </blockquote>
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Documented
|
||||
@Target({TYPE})
|
||||
@Retention(RUNTIME)
|
||||
@Repeatable(LogExcludeLevel.LogExcludeLevels.class)
|
||||
public @interface LogExcludeLevel {
|
||||
|
||||
String[] levels();
|
||||
|
||||
String[] keys();
|
||||
|
||||
@Documented
|
||||
@Target({TYPE})
|
||||
@Retention(RUNTIME)
|
||||
@interface LogExcludeLevels {
|
||||
|
||||
LogExcludeLevel[] value();
|
||||
}
|
||||
}
|
||||
26
src/main/java/org/redkale/annotation/LogLevel.java
Normal file
26
src/main/java/org/redkale/annotation/LogLevel.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 被标记的日志级别以上的才会被记录
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Documented
|
||||
@Target({TYPE})
|
||||
@Retention(RUNTIME)
|
||||
public @interface LogLevel {
|
||||
|
||||
String value();
|
||||
}
|
||||
25
src/main/java/org/redkale/annotation/NonBlocking.java
Normal file
25
src/main/java/org/redkale/annotation/NonBlocking.java
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 非阻塞模式标记, 标记在Service类和方法、Filter类、HttpServlet类上 <br>
|
||||
* 一般情况下,没有显注此注解的方法视为阻塞时, 以下两种情况除外: <br>
|
||||
* 1、返回类型是CompletionStage <br>
|
||||
* 2、返回类型是void且参数存在CompletionHandler类型 <br>
|
||||
* 阻塞模式的方法会在work线程池中运行, 非阻塞在IO线程中运行。
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface NonBlocking { // 不可使用@Inherited,防止被继承, 见HttpServlet.preExecute/authenticate/execute
|
||||
|
||||
boolean value() default true;
|
||||
}
|
||||
18
src/main/java/org/redkale/annotation/Nonnull.java
Normal file
18
src/main/java/org/redkale/annotation/Nonnull.java
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 标记值可以为null
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Nonnull {}
|
||||
18
src/main/java/org/redkale/annotation/Nullable.java
Normal file
18
src/main/java/org/redkale/annotation/Nullable.java
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 标记值可以为null
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Nullable {}
|
||||
29
src/main/java/org/redkale/annotation/Param.java
Normal file
29
src/main/java/org/redkale/annotation/Param.java
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import static java.lang.annotation.ElementType.PARAMETER;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 参数名注解,编译时加上 <b>-parameters</b> 参数可以不用此注解
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@Documented
|
||||
@Target({PARAMETER})
|
||||
@Retention(RUNTIME)
|
||||
public @interface Param {
|
||||
|
||||
String value();
|
||||
|
||||
String comment() default "";
|
||||
}
|
||||
20
src/main/java/org/redkale/annotation/PostConstruct.java
Normal file
20
src/main/java/org/redkale/annotation/PostConstruct.java
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @since Common Annotations 1.0
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RUNTIME)
|
||||
@Target(METHOD)
|
||||
public @interface PostConstruct {}
|
||||
18
src/main/java/org/redkale/annotation/PreDestroy.java
Normal file
18
src/main/java/org/redkale/annotation/PreDestroy.java
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @since Common Annotations 1.0
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RUNTIME)
|
||||
@Target(METHOD)
|
||||
public @interface PreDestroy {}
|
||||
45
src/main/java/org/redkale/annotation/Priority.java
Normal file
45
src/main/java/org/redkale/annotation/Priority.java
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 值越大,优先级越高
|
||||
*
|
||||
* @since Common Annotations 1.2
|
||||
*/
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Priority {
|
||||
|
||||
/** 最高优先级, 其他值必须比此值小 */
|
||||
public static final int HIGHTEST = Integer.MAX_VALUE;
|
||||
|
||||
/** 最低优先级, 其他值必须比此值大 */
|
||||
public static final int LOWEST = Integer.MIN_VALUE;
|
||||
|
||||
/**
|
||||
* 优先级值
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int value();
|
||||
}
|
||||
60
src/main/java/org/redkale/annotation/Resource.java
Normal file
60
src/main/java/org/redkale/annotation/Resource.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @Resource(name = "@") 表示资源name采用所属对象的name <br>
|
||||
* @Resource(name = "#name") 表示资源对象自身的name <br>
|
||||
* @Resource(name = "#type") 表示资源对象自身的类型 <br>
|
||||
*
|
||||
* @since Common Annotations 1.0
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Resource {
|
||||
|
||||
public static final String PARENT_NAME = "@";
|
||||
|
||||
public static final String SELF_NAME = "#name";
|
||||
|
||||
public static final String SELF_TYPE = "#type";
|
||||
|
||||
/**
|
||||
* 是否必须存在
|
||||
*
|
||||
* @return boolean
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public boolean required() default true;
|
||||
|
||||
/**
|
||||
* 资源名称 <br>
|
||||
*
|
||||
* <blockquote>
|
||||
*
|
||||
* <pre>
|
||||
* name规则:
|
||||
* 1: "@"有特殊含义, 表示资源本身,"@"不能单独使用
|
||||
* 2: "#name"、"#type"有特殊含义
|
||||
* 3: 只能是字母、数字、(短横)-、(下划线)_、点(.)的组合
|
||||
* </pre>
|
||||
*
|
||||
* </blockquote>
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String name() default "";
|
||||
|
||||
/**
|
||||
* 依赖注入的类型
|
||||
*
|
||||
* @return Class
|
||||
*/
|
||||
public Class<?> type() default Object.class;
|
||||
}
|
||||
67
src/main/java/org/redkale/annotation/ResourceChanged.java
Normal file
67
src/main/java/org/redkale/annotation/ResourceChanged.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* @Resource资源被更新时的监听事件, 本注解只能标记在方法参数为ResourceEvent[]上 <br>
|
||||
* 注意: 一个类只能存在一个@ResourceChanged的方法, 多余的会被忽略 <br>
|
||||
* 方法在资源被更新以后调用。
|
||||
*
|
||||
* <blockquote>
|
||||
*
|
||||
* <pre>
|
||||
* public class RecordService implements Service {
|
||||
*
|
||||
* @Resource(name = "record.id")
|
||||
* private int id;
|
||||
*
|
||||
* @Resource(name = "record.name")
|
||||
* private String name;
|
||||
*
|
||||
* @ResourceChanged
|
||||
* private void changeResource(ResourceEvent[] events) {
|
||||
* for(ResourceEvent event : events) {
|
||||
* System.out .println("@Resource = " + event.name()
|
||||
* + " 资源变更: newVal = " + event.newValue() + ", oldVal = " + event.oldValue());
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* public static void main(String[] args) throws Exception {
|
||||
* ResourceFactory factory = ResourceFactory.create();
|
||||
* factory.register("record.id", "2345");
|
||||
* factory.register("record.name", "my old name");
|
||||
* Record record = new Record();
|
||||
* factory.inject(record);
|
||||
* factory.register("record.name", "my new name");
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* </blockquote>
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Documented
|
||||
@Target({METHOD})
|
||||
@Retention(RUNTIME)
|
||||
public @interface ResourceChanged {
|
||||
|
||||
/**
|
||||
* 新旧值是否不相同的情况下才回调方法 <br>
|
||||
* true: 新值与旧值不相同才回调ResourceChanged方法 <br>
|
||||
* false: 只要执行了ResourceFactory.register 就回调ResourceChanged方法
|
||||
*
|
||||
* @since 2.7.0
|
||||
* @return boolean
|
||||
*/
|
||||
boolean different() default true;
|
||||
}
|
||||
64
src/main/java/org/redkale/annotation/ResourceInjected.java
Normal file
64
src/main/java/org/redkale/annotation/ResourceInjected.java
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* @Resource资源被依赖注入时的监听事件。<br>
|
||||
* 本注解只能标记在空参数或者(String、Object、java.lang.reflect.Field)三个参数类型的任意组合方法上 <br>
|
||||
* 方法在资源被依赖注入后调用。
|
||||
*
|
||||
* <blockquote>
|
||||
*
|
||||
* <pre>
|
||||
* public class ResourceService implements Service {
|
||||
*
|
||||
* @Resource(name = "res.id")
|
||||
* private int id;
|
||||
*
|
||||
* @Resource(name = "res.name")
|
||||
* private String name;
|
||||
*
|
||||
* @ResourceInjected
|
||||
* private void onInjected(Object dest, String fieldName) {
|
||||
* System.out .println("资源被注入到对象(" + dest + ")的字段(" + fieldName + ")上");
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* public class RecordService implements Service {
|
||||
*
|
||||
* @Resource
|
||||
* private ResourceService resService;
|
||||
*
|
||||
* public void test() {
|
||||
* }
|
||||
*
|
||||
* public static void main(String[] args) throws Exception {
|
||||
* ResourceFactory factory = ResourceFactory.create();
|
||||
* factory.register("res.id", "2345");
|
||||
* factory.register("res.name", "my old name");
|
||||
* ResourceService res = new ResourceService();
|
||||
* factory.inject(res);
|
||||
* factory.register("", res);
|
||||
* RecordService serice = new RecordService();
|
||||
* factory.inject(record);
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* </blockquote>
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Documented
|
||||
@Target({METHOD})
|
||||
@Retention(RUNTIME)
|
||||
public @interface ResourceInjected {}
|
||||
28
src/main/java/org/redkale/annotation/ResourceType.java
Normal file
28
src/main/java/org/redkale/annotation/ResourceType.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 显式的指明资源类型。 调用ResourceFactory.register(Object rs)时通常执行的是ResourceFactory.register(rs.getClass(), Object rs);
|
||||
* 若rs.getClass()的类标记了@ResourceType, 则使用@ResourceType.value()的class值进行注入。
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target({TYPE})
|
||||
@Retention(RUNTIME)
|
||||
public @interface ResourceType {
|
||||
|
||||
Class value();
|
||||
}
|
||||
21
src/main/java/org/redkale/annotation/Serial.java
Normal file
21
src/main/java/org/redkale/annotation/Serial.java
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* 用于预编译时执行Convert.convertFrom方法
|
||||
*
|
||||
* @since 2.5.0
|
||||
*/
|
||||
@Inherited
|
||||
@Documented
|
||||
@Target(TYPE)
|
||||
@Retention(RUNTIME)
|
||||
public @interface Serial {}
|
||||
2
src/main/java/org/redkale/annotation/package-info.java
Normal file
2
src/main/java/org/redkale/annotation/package-info.java
Normal file
@@ -0,0 +1,2 @@
|
||||
/** 提供基础注解包 */
|
||||
package org.redkale.annotation;
|
||||
@@ -59,9 +59,9 @@
|
||||
package org.redkale.asm;
|
||||
|
||||
/**
|
||||
* A visitor to visit a Java annotation. The methods of this class must be
|
||||
* called in the following order: ( <tt>visit</tt> | <tt>visitEnum</tt> |
|
||||
* <tt>visitAnnotation</tt> | <tt>visitArray</tt> )* <tt>visitEnd</tt>.
|
||||
* A visitor to visit a Java annotation. The methods of this class must be called in the following order: (
|
||||
* <tt>visit</tt> | <tt>visitEnum</tt> | <tt>visitAnnotation</tt> |
|
||||
* <tt>visitArray</tt> )* <tt>visitEnd</tt>.
|
||||
*
|
||||
* @author Eric Bruneton
|
||||
* @author Eugene Kuleshov
|
||||
@@ -69,23 +69,19 @@ package org.redkale.asm;
|
||||
public abstract class AnnotationVisitor {
|
||||
|
||||
/**
|
||||
* The ASM API version implemented by this visitor. The value of this field
|
||||
* must be one of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of {@link Opcodes#ASM4},
|
||||
* {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
*/
|
||||
protected final int api;
|
||||
|
||||
/**
|
||||
* The annotation visitor to which this visitor must delegate method calls.
|
||||
* May be null.
|
||||
*/
|
||||
/** The annotation visitor to which this visitor must delegate method calls. May be null. */
|
||||
protected AnnotationVisitor av;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link AnnotationVisitor}.
|
||||
*
|
||||
* @param api
|
||||
* the ASM API version implemented by this visitor. Must be one
|
||||
* of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link Opcodes#ASM4},
|
||||
* {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
*/
|
||||
public AnnotationVisitor(final int api) {
|
||||
this(api, null);
|
||||
@@ -94,12 +90,9 @@ public abstract class AnnotationVisitor {
|
||||
/**
|
||||
* Constructs a new {@link AnnotationVisitor}.
|
||||
*
|
||||
* @param api
|
||||
* the ASM API version implemented by this visitor. Must be one
|
||||
* of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
* @param av
|
||||
* the annotation visitor to which this visitor must delegate
|
||||
* method calls. May be null.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link Opcodes#ASM4},
|
||||
* {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
* @param av the annotation visitor to which this visitor must delegate method calls. May be null.
|
||||
*/
|
||||
public AnnotationVisitor(final int api, final AnnotationVisitor av) {
|
||||
this.api = api;
|
||||
@@ -109,17 +102,12 @@ public abstract class AnnotationVisitor {
|
||||
/**
|
||||
* Visits a primitive value of the annotation.
|
||||
*
|
||||
* @param name
|
||||
* the value name.
|
||||
* @param value
|
||||
* the actual value, whose type must be {@link Byte},
|
||||
* {@link Boolean}, {@link Character}, {@link Short},
|
||||
* {@link Integer} , {@link Long}, {@link Float}, {@link Double},
|
||||
* {@link String} or {@link Type} of OBJECT or ARRAY sort. This
|
||||
* value can also be an array of byte, boolean, short, char, int,
|
||||
* long, float or double values (this is equivalent to using
|
||||
* {@link #visitArray visitArray} and visiting each array element
|
||||
* in turn, but is more convenient).
|
||||
* @param name the value name.
|
||||
* @param value the actual value, whose type must be {@link Byte}, {@link Boolean}, {@link Character},
|
||||
* {@link Short}, {@link Integer} , {@link Long}, {@link Float}, {@link Double}, {@link String} or {@link Type}
|
||||
* of OBJECT or ARRAY sort. This value can also be an array of byte, boolean, short, char, int, long, float or
|
||||
* double values (this is equivalent to using {@link #visitArray visitArray} and visiting each array element in
|
||||
* turn, but is more convenient).
|
||||
*/
|
||||
public void visit(String name, Object value) {
|
||||
if (av != null) {
|
||||
@@ -130,12 +118,9 @@ public abstract class AnnotationVisitor {
|
||||
/**
|
||||
* Visits an enumeration value of the annotation.
|
||||
*
|
||||
* @param name
|
||||
* the value name.
|
||||
* @param desc
|
||||
* the class descriptor of the enumeration class.
|
||||
* @param value
|
||||
* the actual enumeration value.
|
||||
* @param name the value name.
|
||||
* @param desc the class descriptor of the enumeration class.
|
||||
* @param value the actual enumeration value.
|
||||
*/
|
||||
public void visitEnum(String name, String desc, String value) {
|
||||
if (av != null) {
|
||||
@@ -146,15 +131,11 @@ public abstract class AnnotationVisitor {
|
||||
/**
|
||||
* Visits a nested annotation value of the annotation.
|
||||
*
|
||||
* @param name
|
||||
* the value name.
|
||||
* @param desc
|
||||
* the class descriptor of the nested annotation class.
|
||||
* @return a visitor to visit the actual nested annotation value, or
|
||||
* <tt>null</tt> if this visitor is not interested in visiting this
|
||||
* nested annotation. <i>The nested annotation value must be fully
|
||||
* visited before calling other methods on this annotation
|
||||
* visitor</i>.
|
||||
* @param name the value name.
|
||||
* @param desc the class descriptor of the nested annotation class.
|
||||
* @return a visitor to visit the actual nested annotation value, or <tt>null</tt> if this visitor
|
||||
* is not interested in visiting this nested annotation. <i>The nested annotation value must be fully visited
|
||||
* before calling other methods on this annotation visitor</i>.
|
||||
*/
|
||||
public AnnotationVisitor visitAnnotation(String name, String desc) {
|
||||
if (av != null) {
|
||||
@@ -164,18 +145,14 @@ public abstract class AnnotationVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an array value of the annotation. Note that arrays of primitive
|
||||
* types (such as byte, boolean, short, char, int, long, float or double)
|
||||
* can be passed as value to {@link #visit visit}. This is what
|
||||
* {@link ClassReader} does.
|
||||
* Visits an array value of the annotation. Note that arrays of primitive types (such as byte, boolean, short, char,
|
||||
* int, long, float or double) can be passed as value to {@link #visit visit}. This is what {@link ClassReader}
|
||||
* does.
|
||||
*
|
||||
* @param name
|
||||
* the value name.
|
||||
* @return a visitor to visit the actual array value elements, or
|
||||
* <tt>null</tt> if this visitor is not interested in visiting these
|
||||
* values. The 'name' parameters passed to the methods of this
|
||||
* visitor are ignored. <i>All the array values must be visited
|
||||
* before calling other methods on this annotation visitor</i>.
|
||||
* @param name the value name.
|
||||
* @return a visitor to visit the actual array value elements, or <tt>null</tt> if this visitor is
|
||||
* not interested in visiting these values. The 'name' parameters passed to the methods of this visitor are
|
||||
* ignored. <i>All the array values must be visited before calling other methods on this annotation visitor</i>.
|
||||
*/
|
||||
public AnnotationVisitor visitArray(String name) {
|
||||
if (av != null) {
|
||||
@@ -184,9 +161,7 @@ public abstract class AnnotationVisitor {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits the end of the annotation.
|
||||
*/
|
||||
/** Visits the end of the annotation. */
|
||||
public void visitEnd() {
|
||||
if (av != null) {
|
||||
av.visitEnd();
|
||||
|
||||
@@ -66,50 +66,34 @@ package org.redkale.asm;
|
||||
*/
|
||||
final class AnnotationWriter extends AnnotationVisitor {
|
||||
|
||||
/**
|
||||
* The class writer to which this annotation must be added.
|
||||
*/
|
||||
/** The class writer to which this annotation must be added. */
|
||||
private final ClassWriter cw;
|
||||
|
||||
/**
|
||||
* The number of values in this annotation.
|
||||
*/
|
||||
/** The number of values in this annotation. */
|
||||
private int size;
|
||||
|
||||
/**
|
||||
* <tt>true<tt> if values are named, <tt>false</tt> otherwise. Annotation
|
||||
* writers used for annotation default and annotation arrays use unnamed
|
||||
* values.
|
||||
* <tt>true<tt> if values are named, <tt>false</tt> otherwise. Annotation writers
|
||||
* used for annotation default and annotation arrays use unnamed values.
|
||||
*/
|
||||
private final boolean named;
|
||||
|
||||
/**
|
||||
* The annotation values in bytecode form. This byte vector only contains
|
||||
* the values themselves, i.e. the number of values must be stored as a
|
||||
* unsigned short just before these bytes.
|
||||
* The annotation values in bytecode form. This byte vector only contains the values themselves, i.e. the number of
|
||||
* values must be stored as a unsigned short just before these bytes.
|
||||
*/
|
||||
private final ByteVector bv;
|
||||
|
||||
/**
|
||||
* The byte vector to be used to store the number of values of this
|
||||
* annotation. See {@link #bv}.
|
||||
*/
|
||||
/** The byte vector to be used to store the number of values of this annotation. See {@link #bv}. */
|
||||
private final ByteVector parent;
|
||||
|
||||
/**
|
||||
* Where the number of values of this annotation must be stored in
|
||||
* {@link #parent}.
|
||||
*/
|
||||
/** Where the number of values of this annotation must be stored in {@link #parent}. */
|
||||
private final int offset;
|
||||
|
||||
/**
|
||||
* Next annotation writer. This field is used to store annotation lists.
|
||||
*/
|
||||
/** Next annotation writer. This field is used to store annotation lists. */
|
||||
AnnotationWriter next;
|
||||
|
||||
/**
|
||||
* Previous annotation writer. This field is used to store annotation lists.
|
||||
*/
|
||||
/** Previous annotation writer. This field is used to store annotation lists. */
|
||||
AnnotationWriter prev;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -119,20 +103,14 @@ final class AnnotationWriter extends AnnotationVisitor {
|
||||
/**
|
||||
* Constructs a new {@link AnnotationWriter}.
|
||||
*
|
||||
* @param cw
|
||||
* the class writer to which this annotation must be added.
|
||||
* @param named
|
||||
* <tt>true<tt> if values are named, <tt>false</tt> otherwise.
|
||||
* @param bv
|
||||
* where the annotation values must be stored.
|
||||
* @param parent
|
||||
* where the number of annotation values must be stored.
|
||||
* @param offset
|
||||
* where in <tt>parent</tt> the number of annotation values must
|
||||
* be stored.
|
||||
* @param cw the class writer to which this annotation must be added.
|
||||
* @param named <tt>true<tt> if values are named, <tt>false</tt> otherwise.
|
||||
* @param bv where the annotation values must be stored.
|
||||
* @param parent where the number of annotation values must be stored.
|
||||
* @param offset where in <tt>parent</tt> the number of annotation values must be stored.
|
||||
*/
|
||||
AnnotationWriter(final ClassWriter cw, final boolean named,
|
||||
final ByteVector bv, final ByteVector parent, final int offset) {
|
||||
AnnotationWriter(
|
||||
final ClassWriter cw, final boolean named, final ByteVector bv, final ByteVector parent, final int offset) {
|
||||
super(Opcodes.ASM6);
|
||||
this.cw = cw;
|
||||
this.named = named;
|
||||
@@ -219,8 +197,7 @@ final class AnnotationWriter extends AnnotationVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitEnum(final String name, final String desc,
|
||||
final String value) {
|
||||
public void visitEnum(final String name, final String desc, final String value) {
|
||||
++size;
|
||||
if (named) {
|
||||
bv.putShort(cw.newUTF8(name));
|
||||
@@ -229,8 +206,7 @@ final class AnnotationWriter extends AnnotationVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitAnnotation(final String name,
|
||||
final String desc) {
|
||||
public AnnotationVisitor visitAnnotation(final String name, final String desc) {
|
||||
++size;
|
||||
if (named) {
|
||||
bv.putShort(cw.newUTF8(name));
|
||||
@@ -280,11 +256,9 @@ final class AnnotationWriter extends AnnotationVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the annotations of this annotation writer list into the given byte
|
||||
* vector.
|
||||
* Puts the annotations of this annotation writer list into the given byte vector.
|
||||
*
|
||||
* @param out
|
||||
* where the annotations must be put.
|
||||
* @param out where the annotations must be put.
|
||||
*/
|
||||
void put(final ByteVector out) {
|
||||
int n = 0;
|
||||
@@ -311,15 +285,11 @@ final class AnnotationWriter extends AnnotationVisitor {
|
||||
/**
|
||||
* Puts the given annotation lists into the given byte vector.
|
||||
*
|
||||
* @param panns
|
||||
* an array of annotation writer lists.
|
||||
* @param off
|
||||
* index of the first annotation to be written.
|
||||
* @param out
|
||||
* where the annotations must be put.
|
||||
* @param panns an array of annotation writer lists.
|
||||
* @param off index of the first annotation to be written.
|
||||
* @param out where the annotations must be put.
|
||||
*/
|
||||
static void put(final AnnotationWriter[] panns, final int off,
|
||||
final ByteVector out) {
|
||||
static void put(final AnnotationWriter[] panns, final int off, final ByteVector out) {
|
||||
int size = 1 + 2 * (panns.length - off);
|
||||
for (int i = off; i < panns.length; ++i) {
|
||||
size += panns[i] == null ? 0 : panns[i].getSize();
|
||||
@@ -346,49 +316,45 @@ final class AnnotationWriter extends AnnotationVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the given type reference and type path into the given bytevector.
|
||||
* LOCAL_VARIABLE and RESOURCE_VARIABLE target types are not supported.
|
||||
* Puts the given type reference and type path into the given bytevector. LOCAL_VARIABLE and RESOURCE_VARIABLE
|
||||
* target types are not supported.
|
||||
*
|
||||
* @param typeRef
|
||||
* a reference to the annotated type. See {@link TypeReference}.
|
||||
* @param typePath
|
||||
* the path to the annotated type argument, wildcard bound, array
|
||||
* element type, or static inner type within 'typeRef'. May be
|
||||
* <tt>null</tt> if the annotation targets 'typeRef' as a whole.
|
||||
* @param out
|
||||
* where the type reference and type path must be put.
|
||||
* @param typeRef a reference to the annotated type. See {@link TypeReference}.
|
||||
* @param typePath the path to the annotated type argument, wildcard bound, array element type, or static inner type
|
||||
* within 'typeRef'. May be <tt>null</tt> if the annotation targets 'typeRef' as a whole.
|
||||
* @param out where the type reference and type path must be put.
|
||||
*/
|
||||
static void putTarget(int typeRef, TypePath typePath, ByteVector out) {
|
||||
switch (typeRef >>> 24) {
|
||||
case 0x00: // CLASS_TYPE_PARAMETER
|
||||
case 0x01: // METHOD_TYPE_PARAMETER
|
||||
case 0x16: // METHOD_FORMAL_PARAMETER
|
||||
out.putShort(typeRef >>> 16);
|
||||
break;
|
||||
case 0x13: // FIELD
|
||||
case 0x14: // METHOD_RETURN
|
||||
case 0x15: // METHOD_RECEIVER
|
||||
out.putByte(typeRef >>> 24);
|
||||
break;
|
||||
case 0x47: // CAST
|
||||
case 0x48: // CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
|
||||
case 0x49: // METHOD_INVOCATION_TYPE_ARGUMENT
|
||||
case 0x4A: // CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
|
||||
case 0x4B: // METHOD_REFERENCE_TYPE_ARGUMENT
|
||||
out.putInt(typeRef);
|
||||
break;
|
||||
// case 0x10: // CLASS_EXTENDS
|
||||
// case 0x11: // CLASS_TYPE_PARAMETER_BOUND
|
||||
// case 0x12: // METHOD_TYPE_PARAMETER_BOUND
|
||||
// case 0x17: // THROWS
|
||||
// case 0x42: // EXCEPTION_PARAMETER
|
||||
// case 0x43: // INSTANCEOF
|
||||
// case 0x44: // NEW
|
||||
// case 0x45: // CONSTRUCTOR_REFERENCE
|
||||
// case 0x46: // METHOD_REFERENCE
|
||||
default:
|
||||
out.put12(typeRef >>> 24, (typeRef & 0xFFFF00) >> 8);
|
||||
break;
|
||||
case 0x00: // CLASS_TYPE_PARAMETER
|
||||
case 0x01: // METHOD_TYPE_PARAMETER
|
||||
case 0x16: // METHOD_FORMAL_PARAMETER
|
||||
out.putShort(typeRef >>> 16);
|
||||
break;
|
||||
case 0x13: // FIELD
|
||||
case 0x14: // METHOD_RETURN
|
||||
case 0x15: // METHOD_RECEIVER
|
||||
out.putByte(typeRef >>> 24);
|
||||
break;
|
||||
case 0x47: // CAST
|
||||
case 0x48: // CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
|
||||
case 0x49: // METHOD_INVOCATION_TYPE_ARGUMENT
|
||||
case 0x4A: // CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
|
||||
case 0x4B: // METHOD_REFERENCE_TYPE_ARGUMENT
|
||||
out.putInt(typeRef);
|
||||
break;
|
||||
// case 0x10: // CLASS_EXTENDS
|
||||
// case 0x11: // CLASS_TYPE_PARAMETER_BOUND
|
||||
// case 0x12: // METHOD_TYPE_PARAMETER_BOUND
|
||||
// case 0x17: // THROWS
|
||||
// case 0x42: // EXCEPTION_PARAMETER
|
||||
// case 0x43: // INSTANCEOF
|
||||
// case 0x44: // NEW
|
||||
// case 0x45: // CONSTRUCTOR_REFERENCE
|
||||
// case 0x46: // METHOD_REFERENCE
|
||||
default:
|
||||
out.put12(typeRef >>> 24, (typeRef & 0xFFFF00) >> 8);
|
||||
break;
|
||||
}
|
||||
if (typePath == null) {
|
||||
out.putByte(0);
|
||||
|
||||
157
src/main/java/org/redkale/asm/AsmMethodBean.java
Normal file
157
src/main/java/org/redkale/asm/AsmMethodBean.java
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
package org.redkale.asm;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.redkale.annotation.Param;
|
||||
|
||||
/**
|
||||
* 存放方法的字节信息
|
||||
*
|
||||
* @see org.redkale.asm.AsmMethodBoost
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public class AsmMethodBean {
|
||||
|
||||
private List<AsmMethodParam> params;
|
||||
|
||||
private int access;
|
||||
|
||||
private String name;
|
||||
|
||||
private String desc;
|
||||
|
||||
private String signature;
|
||||
|
||||
private String[] exceptions;
|
||||
|
||||
public AsmMethodBean() {}
|
||||
|
||||
public AsmMethodBean(int access, String name, String desc, String signature, String[] exceptions) {
|
||||
this.access = access;
|
||||
this.name = name;
|
||||
this.desc = desc;
|
||||
this.signature = signature;
|
||||
this.exceptions = exceptions;
|
||||
this.params = new ArrayList<>();
|
||||
}
|
||||
|
||||
public static AsmMethodBean get(Map<String, AsmMethodBean> map, Method method) {
|
||||
return map == null ? null : map.get(method.getName() + ":" + Type.getMethodDescriptor(method));
|
||||
}
|
||||
|
||||
void removeEmptyNames() {
|
||||
if (params != null) {
|
||||
List<AsmMethodParam> dels = null;
|
||||
for (AsmMethodParam p : params) {
|
||||
if (" ".equals(p.getName())) {
|
||||
if (dels == null) {
|
||||
dels = new ArrayList<>();
|
||||
}
|
||||
dels.add(p);
|
||||
}
|
||||
}
|
||||
if (dels != null) {
|
||||
for (AsmMethodParam p : dels) {
|
||||
params.remove(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> fieldNameList() {
|
||||
return paramNameList(null);
|
||||
}
|
||||
|
||||
public List<String> paramNameList(Method method) {
|
||||
if (params == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
int index = 0;
|
||||
Parameter[] ps = method == null ? null : method.getParameters();
|
||||
List<String> rs = new ArrayList<>(params.size());
|
||||
for (AsmMethodParam p : params) {
|
||||
Param pann = ps == null ? null : ps[index].getAnnotation(Param.class);
|
||||
rs.add(pann == null ? p.getName() : pann.value());
|
||||
index++;
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
public String[] fieldNameArray() {
|
||||
return paramNameArray(null);
|
||||
}
|
||||
|
||||
public String[] paramNameArray(Method method) {
|
||||
if (params == null) {
|
||||
return null;
|
||||
}
|
||||
Parameter[] ps = method == null ? null : method.getParameters();
|
||||
// params包含了throws, size()可能比ps.length大
|
||||
String[] rs = new String[ps == null ? params.size() : ps.length];
|
||||
for (int i = 0; i < rs.length; i++) {
|
||||
Param pann = ps == null ? null : ps[i].getAnnotation(Param.class);
|
||||
rs[i] = pann == null ? params.get(i).getName() : pann.value();
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
public List<AsmMethodParam> getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(List<AsmMethodParam> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public int getAccess() {
|
||||
return access;
|
||||
}
|
||||
|
||||
public void setAccess(int access) {
|
||||
this.access = access;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public void setSignature(String signature) {
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
public String[] getExceptions() {
|
||||
return exceptions;
|
||||
}
|
||||
|
||||
public void setExceptions(String[] exceptions) {
|
||||
this.exceptions = exceptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{params:" + params + ", access:" + access + ", name:" + name + ", desc:" + desc + ", signature:"
|
||||
+ signature + ", exceptions:" + exceptions + '}';
|
||||
}
|
||||
}
|
||||
464
src/main/java/org/redkale/asm/AsmMethodBoost.java
Normal file
464
src/main/java/org/redkale/asm/AsmMethodBoost.java
Normal file
@@ -0,0 +1,464 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
package org.redkale.asm;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.redkale.annotation.Nullable;
|
||||
import static org.redkale.asm.Opcodes.ACC_PRIVATE;
|
||||
import static org.redkale.asm.Opcodes.ACC_PROTECTED;
|
||||
import static org.redkale.asm.Opcodes.ACC_PUBLIC;
|
||||
import static org.redkale.asm.Opcodes.ALOAD;
|
||||
import static org.redkale.asm.Opcodes.ARETURN;
|
||||
import static org.redkale.asm.Opcodes.DLOAD;
|
||||
import static org.redkale.asm.Opcodes.DRETURN;
|
||||
import static org.redkale.asm.Opcodes.FLOAD;
|
||||
import static org.redkale.asm.Opcodes.FRETURN;
|
||||
import static org.redkale.asm.Opcodes.ILOAD;
|
||||
import static org.redkale.asm.Opcodes.IRETURN;
|
||||
import static org.redkale.asm.Opcodes.LLOAD;
|
||||
import static org.redkale.asm.Opcodes.LRETURN;
|
||||
import static org.redkale.asm.Opcodes.RETURN;
|
||||
import org.redkale.inject.ResourceFactory;
|
||||
import org.redkale.util.RedkaleClassLoader;
|
||||
import org.redkale.util.Utility;
|
||||
|
||||
/**
|
||||
* 生产动态字节码的方法扩展器, 可以进行方法加强动作
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @author zhangjx
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public abstract class AsmMethodBoost<T> {
|
||||
|
||||
protected final AtomicInteger fieldIndex = new AtomicInteger();
|
||||
|
||||
protected final boolean remote;
|
||||
|
||||
protected final Class serviceType;
|
||||
|
||||
protected AsmMethodBoost(boolean remote, Class serviceType) {
|
||||
this.remote = remote;
|
||||
this.serviceType = serviceType;
|
||||
}
|
||||
|
||||
public static AsmMethodBoost create(boolean remote, Collection<AsmMethodBoost> list) {
|
||||
return new AsmMethodBoosts(remote, list);
|
||||
}
|
||||
|
||||
public static AsmMethodBoost create(boolean remote, AsmMethodBoost... items) {
|
||||
return new AsmMethodBoosts(remote, items);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回一个类所有方法的字节信息, key为: method.getName+':'+Type.getMethodDescriptor(method)
|
||||
*
|
||||
* @param clazz Class
|
||||
* @return Map
|
||||
*/
|
||||
public static Map<String, AsmMethodBean> getMethodBeans(Class clazz) {
|
||||
Map<String, AsmMethodBean> rs = MethodParamClassVisitor.getMethodParamNames(new HashMap<>(), clazz);
|
||||
// 返回的List中参数列表可能会比方法参数量多,因为方法内的临时变量也会存入list中, 所以需要list的元素集合比方法的参数多
|
||||
rs.values().forEach(AsmMethodBean::removeEmptyNames);
|
||||
return rs;
|
||||
}
|
||||
|
||||
public static String getMethodBeanKey(Method method) {
|
||||
return method.getName() + ":" + Type.getMethodDescriptor(method);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取需屏蔽的方法上的注解
|
||||
*
|
||||
* @param method 方法
|
||||
* @return 需要屏蔽的注解
|
||||
*/
|
||||
public abstract List<Class<? extends Annotation>> filterMethodAnnotations(Method method);
|
||||
|
||||
/**
|
||||
* 对方法进行动态加强处理
|
||||
*
|
||||
* @param classLoader ClassLoader
|
||||
* @param cw 动态字节码Writer
|
||||
* @param serviceImplClass 原始实现类
|
||||
* @param newDynName 动态新类名
|
||||
* @param fieldPrefix 动态字段的前缀
|
||||
* @param filterAnns 需要过滤的注解
|
||||
* @param method 操作的方法
|
||||
* @param newMethod 新的方法名, 可能为null
|
||||
* @return 下一个新的方法名,不做任何处理应返回参数newMethodName
|
||||
*/
|
||||
public abstract AsmNewMethod doMethod(
|
||||
RedkaleClassLoader classLoader,
|
||||
ClassWriter cw,
|
||||
Class serviceImplClass,
|
||||
String newDynName,
|
||||
String fieldPrefix,
|
||||
List<Class<? extends Annotation>> filterAnns,
|
||||
Method method,
|
||||
@Nullable AsmNewMethod newMethod);
|
||||
|
||||
/**
|
||||
* 处理所有动态方法后调用
|
||||
*
|
||||
* @param classLoader ClassLoader
|
||||
* @param cw 动态字节码Writer
|
||||
* @param newDynName 动态新类名
|
||||
* @param fieldPrefix 动态字段的前缀
|
||||
*/
|
||||
public void doAfterMethods(RedkaleClassLoader classLoader, ClassWriter cw, String newDynName, String fieldPrefix) {}
|
||||
|
||||
/**
|
||||
* 处理所有动态方法后调用
|
||||
*
|
||||
* @param classLoader ClassLoader
|
||||
* @param cw 动态字节码Writer
|
||||
* @param mv 构造函数MethodVisitor
|
||||
* @param newDynName 动态新类名
|
||||
* @param fieldPrefix 动态字段的前缀
|
||||
* @param remote 是否远程模式
|
||||
*/
|
||||
public void doConstructorMethod(
|
||||
RedkaleClassLoader classLoader,
|
||||
ClassWriter cw,
|
||||
MethodVisitor mv,
|
||||
String newDynName,
|
||||
String fieldPrefix,
|
||||
boolean remote) {}
|
||||
/**
|
||||
* 实例对象进行操作,通常用于给动态的字段赋值
|
||||
*
|
||||
* @param classLoader ClassLoader
|
||||
* @param resourceFactory ResourceFactory
|
||||
* @param service 实例对象
|
||||
*/
|
||||
public abstract void doInstance(RedkaleClassLoader classLoader, ResourceFactory resourceFactory, T service);
|
||||
|
||||
protected AsmMethodBean getMethodBean(Method method) {
|
||||
Map<String, AsmMethodBean> methodBeans = AsmMethodBoost.getMethodBeans(serviceType);
|
||||
return AsmMethodBean.get(methodBeans, method);
|
||||
}
|
||||
|
||||
protected MethodVisitor createMethodVisitor(
|
||||
ClassWriter cw, Method method, AsmNewMethod newMethod, AsmMethodBean methodBean) {
|
||||
return new MethodDebugVisitor(cw.visitMethod(
|
||||
getAcc(method, newMethod),
|
||||
getNowMethodName(method, newMethod),
|
||||
Type.getMethodDescriptor(method),
|
||||
getMethodSignature(method, methodBean),
|
||||
getMethodExceptions(method, methodBean)));
|
||||
}
|
||||
|
||||
protected final int getAcc(Method method, AsmNewMethod newMethod) {
|
||||
if (newMethod != null) {
|
||||
return ACC_PRIVATE;
|
||||
}
|
||||
return Modifier.isProtected(method.getModifiers()) ? ACC_PROTECTED : ACC_PUBLIC;
|
||||
}
|
||||
|
||||
protected String getNowMethodName(Method method, AsmNewMethod newMethod) {
|
||||
return newMethod == null ? method.getName() : newMethod.getMethodName();
|
||||
}
|
||||
|
||||
protected String getMethodSignature(Method method, AsmMethodBean methodBean) {
|
||||
return methodBean != null ? methodBean.getSignature() : null;
|
||||
}
|
||||
|
||||
protected String[] getMethodExceptions(Method method, AsmMethodBean methodBean) {
|
||||
if (methodBean == null) {
|
||||
String[] exceptions = null;
|
||||
Class<?>[] expTypes = method.getExceptionTypes();
|
||||
if (expTypes.length > 0) {
|
||||
exceptions = new String[expTypes.length];
|
||||
for (int i = 0; i < expTypes.length; i++) {
|
||||
exceptions[i] = expTypes[i].getName().replace('.', '/');
|
||||
}
|
||||
}
|
||||
return exceptions;
|
||||
} else {
|
||||
return methodBean.getExceptions();
|
||||
}
|
||||
}
|
||||
|
||||
protected void visitRawAnnotation(
|
||||
Method method, AsmNewMethod newMethod, MethodVisitor mv, Class skipAnnType, List skipAnns) {
|
||||
if (newMethod == null) {
|
||||
// 给方法加上原有的Annotation
|
||||
final Annotation[] anns = method.getAnnotations();
|
||||
for (Annotation ann : anns) {
|
||||
if (ann.annotationType() != skipAnnType
|
||||
&& (skipAnns == null || !skipAnns.contains(ann.annotationType()))) {
|
||||
Asms.visitAnnotation(
|
||||
mv.visitAnnotation(Type.getDescriptor(ann.annotationType()), true),
|
||||
ann.annotationType(),
|
||||
ann);
|
||||
}
|
||||
}
|
||||
// 给参数加上原有的Annotation
|
||||
final Annotation[][] annss = method.getParameterAnnotations();
|
||||
for (int k = 0; k < annss.length; k++) {
|
||||
for (Annotation ann : annss[k]) {
|
||||
Asms.visitAnnotation(
|
||||
mv.visitParameterAnnotation(k, Type.getDescriptor(ann.annotationType()), true),
|
||||
ann.annotationType(),
|
||||
ann);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected List<Integer> visitVarInsnParamTypes(MethodVisitor mv, Method method, int insn) {
|
||||
// 传参数
|
||||
Class[] paramTypes = method.getParameterTypes();
|
||||
List<Integer> insns = new ArrayList<>();
|
||||
for (Class pt : paramTypes) {
|
||||
insn++;
|
||||
if (pt.isPrimitive()) {
|
||||
if (pt == long.class) {
|
||||
mv.visitVarInsn(LLOAD, insn++);
|
||||
} else if (pt == float.class) {
|
||||
mv.visitVarInsn(FLOAD, insn++);
|
||||
} else if (pt == double.class) {
|
||||
mv.visitVarInsn(DLOAD, insn++);
|
||||
} else {
|
||||
mv.visitVarInsn(ILOAD, insn);
|
||||
}
|
||||
} else {
|
||||
mv.visitVarInsn(ALOAD, insn);
|
||||
}
|
||||
insns.add(insn);
|
||||
}
|
||||
return insns;
|
||||
}
|
||||
|
||||
protected void visitParamTypesLocalVariable(
|
||||
MethodVisitor mv, Method method, Label l0, Label l2, List<Integer> insns, AsmMethodBean methodBean) {
|
||||
Class[] paramTypes = method.getParameterTypes();
|
||||
if (methodBean != null && paramTypes.length > 0) {
|
||||
mv.visitLabel(l2);
|
||||
List<AsmMethodParam> params = methodBean.getParams();
|
||||
for (int i = 0; i < paramTypes.length; i++) {
|
||||
AsmMethodParam param = params.get(i);
|
||||
mv.visitLocalVariable(
|
||||
param.getName(),
|
||||
param.description(paramTypes[i]),
|
||||
param.signature(paramTypes[i]),
|
||||
l0,
|
||||
l2,
|
||||
insns.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void visitInsnReturn(
|
||||
MethodVisitor mv, Method method, Label l0, List<Integer> insns, AsmMethodBean methodBean) {
|
||||
if (method.getGenericReturnType() == void.class) {
|
||||
mv.visitInsn(RETURN);
|
||||
} else {
|
||||
Class returnclz = method.getReturnType();
|
||||
if (returnclz.isPrimitive()) {
|
||||
if (returnclz == long.class) {
|
||||
mv.visitInsn(LRETURN);
|
||||
} else if (returnclz == float.class) {
|
||||
mv.visitInsn(FRETURN);
|
||||
} else if (returnclz == double.class) {
|
||||
mv.visitInsn(DRETURN);
|
||||
} else {
|
||||
mv.visitInsn(IRETURN);
|
||||
}
|
||||
} else {
|
||||
mv.visitInsn(ARETURN);
|
||||
}
|
||||
}
|
||||
visitParamTypesLocalVariable(mv, method, l0, new Label(), insns, methodBean);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生产动态字节码的方法扩展器, 可以进行方法加强动作
|
||||
*
|
||||
* @param <T> 泛型
|
||||
* @since 2.8.0
|
||||
*/
|
||||
static class AsmMethodBoosts<T> extends AsmMethodBoost<T> {
|
||||
|
||||
private final AsmMethodBoost[] items;
|
||||
|
||||
public AsmMethodBoosts(boolean remote, Collection<AsmMethodBoost> list) {
|
||||
super(remote, null);
|
||||
this.items = list.toArray(new AsmMethodBoost[list.size()]);
|
||||
}
|
||||
|
||||
public AsmMethodBoosts(boolean remote, AsmMethodBoost... items) {
|
||||
super(remote, null);
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends Annotation>> filterMethodAnnotations(Method method) {
|
||||
List<Class<? extends Annotation>> list = null;
|
||||
for (AsmMethodBoost item : items) {
|
||||
if (item != null) {
|
||||
List<Class<? extends Annotation>> sub = item.filterMethodAnnotations(method);
|
||||
if (sub != null) {
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
list.addAll(sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsmNewMethod doMethod(
|
||||
RedkaleClassLoader classLoader,
|
||||
ClassWriter cw,
|
||||
Class serviceImplClass,
|
||||
String newDynName,
|
||||
String fieldPrefix,
|
||||
List<Class<? extends Annotation>> filterAnns,
|
||||
Method method,
|
||||
AsmNewMethod newMethod) {
|
||||
AsmNewMethod newResult = newMethod;
|
||||
for (AsmMethodBoost item : items) {
|
||||
if (item != null) {
|
||||
newResult = item.doMethod(
|
||||
classLoader, cw, serviceImplClass, newDynName, fieldPrefix, filterAnns, method, newResult);
|
||||
}
|
||||
}
|
||||
return newResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAfterMethods(
|
||||
RedkaleClassLoader classLoader, ClassWriter cw, String newDynName, String fieldPrefix) {
|
||||
for (AsmMethodBoost item : items) {
|
||||
if (item != null) {
|
||||
item.doAfterMethods(classLoader, cw, newDynName, fieldPrefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doConstructorMethod(
|
||||
RedkaleClassLoader classLoader,
|
||||
ClassWriter cw,
|
||||
MethodVisitor mv,
|
||||
String newDynName,
|
||||
String fieldPrefix,
|
||||
boolean remote) {
|
||||
for (AsmMethodBoost item : items) {
|
||||
if (item != null) {
|
||||
item.doConstructorMethod(classLoader, cw, mv, newDynName, fieldPrefix, remote);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doInstance(RedkaleClassLoader classLoader, ResourceFactory resourceFactory, T service) {
|
||||
for (AsmMethodBoost item : items) {
|
||||
if (item != null) {
|
||||
item.doInstance(classLoader, resourceFactory, service);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class MethodParamClassVisitor extends ClassVisitor {
|
||||
|
||||
private Class serviceType;
|
||||
|
||||
private final Map<String, AsmMethodBean> methodBeanMap;
|
||||
|
||||
public MethodParamClassVisitor(int api, Class serviceType, final Map<String, AsmMethodBean> methodBeanMap) {
|
||||
super(api);
|
||||
this.serviceType = serviceType;
|
||||
this.methodBeanMap = methodBeanMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(
|
||||
int methodAccess,
|
||||
String methodName,
|
||||
String methodDesc,
|
||||
String methodSignature,
|
||||
String[] methodExceptions) {
|
||||
super.visitMethod(api, methodName, methodDesc, methodSignature, methodExceptions);
|
||||
if (java.lang.reflect.Modifier.isStatic(methodAccess)) {
|
||||
return null;
|
||||
}
|
||||
String key = methodName + ":" + methodDesc;
|
||||
if (methodBeanMap.containsKey(key)) {
|
||||
return null;
|
||||
}
|
||||
AsmMethodBean bean =
|
||||
new AsmMethodBean(methodAccess, methodName, methodDesc, methodSignature, methodExceptions);
|
||||
List<AsmMethodParam> paramList = bean.getParams();
|
||||
methodBeanMap.put(key, bean);
|
||||
return new MethodVisitor(Opcodes.ASM6) {
|
||||
@Override
|
||||
public void visitParameter(String paramName, int paramAccess) {
|
||||
paramList.add(new AsmMethodParam(paramName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitLocalVariable(
|
||||
String varName, String varDesc, String varSignature, Label start, Label end, int varIndex) {
|
||||
if (varIndex < 1) {
|
||||
return;
|
||||
}
|
||||
int size = paramList.size();
|
||||
// index并不会按顺序执行
|
||||
if (varIndex > size) {
|
||||
for (int i = size; i < varIndex; i++) {
|
||||
paramList.add(new AsmMethodParam(" ", varDesc, varSignature));
|
||||
}
|
||||
paramList.set(varIndex - 1, new AsmMethodParam(varName, varDesc, varSignature));
|
||||
}
|
||||
paramList.set(varIndex - 1, new AsmMethodParam(varName, varDesc, varSignature));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 返回的List中参数列表可能会比方法参数量多,因为方法内的临时变量也会存入list中, 所以需要list的元素集合比方法的参数多
|
||||
static Map<String, AsmMethodBean> getMethodParamNames(Map<String, AsmMethodBean> map, Class clazz) {
|
||||
String n = clazz.getName();
|
||||
byte[] bs = RedkaleClassLoader.getDynClassBytes(n);
|
||||
if (bs == null) {
|
||||
InputStream in = clazz.getResourceAsStream(n.substring(n.lastIndexOf('.') + 1) + ".class");
|
||||
if (in == null) {
|
||||
return map;
|
||||
}
|
||||
try {
|
||||
bs = Utility.readBytesThenClose(in);
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
try {
|
||||
new ClassReader(bs).accept(new MethodParamClassVisitor(Opcodes.ASM6, clazz, map), 0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// do nothing
|
||||
}
|
||||
Class superClass = clazz.getSuperclass();
|
||||
if (superClass == null || superClass == Object.class) { // 接口的getSuperclass为null
|
||||
return map;
|
||||
}
|
||||
return getMethodParamNames(map, superClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
71
src/main/java/org/redkale/asm/AsmMethodParam.java
Normal file
71
src/main/java/org/redkale/asm/AsmMethodParam.java
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
package org.redkale.asm;
|
||||
|
||||
import org.redkale.util.TypeToken;
|
||||
|
||||
/**
|
||||
* 存放方法参数的字节信息
|
||||
*
|
||||
* @see org.redkale.asm.AsmMethodBean
|
||||
* @see org.redkale.asm.AsmMethodBoost
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public class AsmMethodParam {
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private String signature;
|
||||
|
||||
public AsmMethodParam() {}
|
||||
|
||||
public AsmMethodParam(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public AsmMethodParam(String name, String description, String signature) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
public String description(java.lang.reflect.Type type) {
|
||||
return description == null ? Type.getDescriptor(TypeToken.typeToClass(type)) : description;
|
||||
}
|
||||
|
||||
public String signature(java.lang.reflect.Type type) {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public void setSignature(String signature) {
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{name:" + name + ", description:" + description + ", signature:" + signature + '}';
|
||||
}
|
||||
}
|
||||
47
src/main/java/org/redkale/asm/AsmNewMethod.java
Normal file
47
src/main/java/org/redkale/asm/AsmNewMethod.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
package org.redkale.asm;
|
||||
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
|
||||
/**
|
||||
* 存放新方法的信息
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public class AsmNewMethod {
|
||||
|
||||
private String methodName;
|
||||
|
||||
private int methodAccs;
|
||||
|
||||
public AsmNewMethod() {}
|
||||
|
||||
public AsmNewMethod(String newName, int newAccs) {
|
||||
this.methodName = newName;
|
||||
this.methodAccs = newAccs;
|
||||
}
|
||||
|
||||
public String getMethodName() {
|
||||
return methodName;
|
||||
}
|
||||
|
||||
public void setMethodName(String methodName) {
|
||||
this.methodName = methodName;
|
||||
}
|
||||
|
||||
public int getMethodAccs() {
|
||||
return methodAccs;
|
||||
}
|
||||
|
||||
public void setMethodAccs(int methodAccs) {
|
||||
this.methodAccs = methodAccs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JsonConvert.root().convertTo(this);
|
||||
}
|
||||
}
|
||||
230
src/main/java/org/redkale/asm/Asms.java
Normal file
230
src/main/java/org/redkale/asm/Asms.java
Normal file
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
package org.redkale.asm;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import static org.redkale.asm.Opcodes.BIPUSH;
|
||||
import static org.redkale.asm.Opcodes.CHECKCAST;
|
||||
import static org.redkale.asm.Opcodes.GETSTATIC;
|
||||
import static org.redkale.asm.Opcodes.ICONST_0;
|
||||
import static org.redkale.asm.Opcodes.INVOKESTATIC;
|
||||
import static org.redkale.asm.Opcodes.INVOKEVIRTUAL;
|
||||
import static org.redkale.asm.Opcodes.SIPUSH;
|
||||
import org.redkale.util.RedkaleException;
|
||||
|
||||
/**
|
||||
* ASM简单的工具方法 <br>
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public final class Asms {
|
||||
|
||||
private Asms() {}
|
||||
|
||||
public static Handle createLambdaMetaHandle() {
|
||||
return new Handle(
|
||||
Opcodes.H_INVOKESTATIC,
|
||||
"java/lang/invoke/LambdaMetafactory",
|
||||
"metafactory",
|
||||
"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;",
|
||||
false);
|
||||
}
|
||||
|
||||
// annType与annValue不一定是同一类型
|
||||
public static <T extends Annotation> void visitAnnotation(
|
||||
final AnnotationVisitor av, final Class<T> annType, final Annotation annValue) {
|
||||
try {
|
||||
Set<String> methods = null;
|
||||
if (annType != annValue.annotationType()) {
|
||||
methods = new HashSet<>();
|
||||
for (Method anm : annType.getMethods()) {
|
||||
methods.add(anm.getName());
|
||||
}
|
||||
}
|
||||
for (Method anm : annValue.annotationType().getMethods()) {
|
||||
final String mname = anm.getName();
|
||||
if ("equals".equals(mname)
|
||||
|| "hashCode".equals(mname)
|
||||
|| "toString".equals(mname)
|
||||
|| "annotationType".equals(mname)) {
|
||||
continue;
|
||||
}
|
||||
if (methods != null && !methods.contains(mname)) {
|
||||
continue;
|
||||
}
|
||||
final Object r = anm.invoke(annValue);
|
||||
if (r instanceof String[]) {
|
||||
AnnotationVisitor av1 = av.visitArray(mname);
|
||||
for (String item : (String[]) r) {
|
||||
av1.visit(null, item);
|
||||
}
|
||||
av1.visitEnd();
|
||||
} else if (r instanceof Class[]) {
|
||||
AnnotationVisitor av1 = av.visitArray(mname);
|
||||
for (Class item : (Class[]) r) {
|
||||
av1.visit(null, Type.getType(item));
|
||||
}
|
||||
av1.visitEnd();
|
||||
} else if (r instanceof Enum[]) {
|
||||
AnnotationVisitor av1 = av.visitArray(mname);
|
||||
for (Enum item : (Enum[]) r) {
|
||||
av1.visitEnum(null, Type.getDescriptor(item.getClass()), item.name());
|
||||
}
|
||||
av1.visitEnd();
|
||||
} else if (r instanceof Annotation[]) {
|
||||
AnnotationVisitor av1 = av.visitArray(mname);
|
||||
for (Annotation item : (Annotation[]) r) {
|
||||
visitAnnotation(
|
||||
av1.visitAnnotation(null, Type.getDescriptor(((Annotation) r).annotationType())),
|
||||
item.annotationType(),
|
||||
item);
|
||||
}
|
||||
av1.visitEnd();
|
||||
} else if (r instanceof Class) {
|
||||
av.visit(mname, Type.getType((Class) r));
|
||||
} else if (r instanceof Enum) {
|
||||
av.visitEnum(mname, Type.getDescriptor(r.getClass()), ((Enum) r).name());
|
||||
} else if (r instanceof Annotation) {
|
||||
visitAnnotation(
|
||||
av.visitAnnotation(null, Type.getDescriptor(((Annotation) r).annotationType())),
|
||||
((Annotation) r).annotationType(),
|
||||
(Annotation) r);
|
||||
} else {
|
||||
av.visit(mname, r);
|
||||
}
|
||||
}
|
||||
av.visitEnd();
|
||||
} catch (Exception e) {
|
||||
throw new RedkaleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void visitInsn(MethodVisitor mv, int num) {
|
||||
if (num < 6) {
|
||||
mv.visitInsn(ICONST_0 + num);
|
||||
} else if (num <= Byte.MAX_VALUE) {
|
||||
mv.visitIntInsn(BIPUSH, num);
|
||||
} else if (num <= Short.MAX_VALUE) {
|
||||
mv.visitIntInsn(SIPUSH, num);
|
||||
} else {
|
||||
mv.visitLdcInsn(num);
|
||||
}
|
||||
}
|
||||
|
||||
public static void visitFieldInsn(MethodVisitor mv, Class clazz) {
|
||||
if (clazz == boolean.class) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Boolean", "TYPE", "Ljava/lang/Class;");
|
||||
} else if (clazz == byte.class) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Byte", "TYPE", "Ljava/lang/Class;");
|
||||
} else if (clazz == char.class) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Character", "TYPE", "Ljava/lang/Class;");
|
||||
} else if (clazz == short.class) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Short", "TYPE", "Ljava/lang/Class;");
|
||||
} else if (clazz == int.class) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Integer", "TYPE", "Ljava/lang/Class;");
|
||||
} else if (clazz == float.class) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Float", "TYPE", "Ljava/lang/Class;");
|
||||
} else if (clazz == long.class) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Long", "TYPE", "Ljava/lang/Class;");
|
||||
} else if (clazz == double.class) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Double", "TYPE", "Ljava/lang/Class;");
|
||||
} else {
|
||||
mv.visitLdcInsn(Type.getType(Type.getDescriptor(clazz)));
|
||||
}
|
||||
}
|
||||
|
||||
public static void visitPrimitiveValueOf(MethodVisitor mv, Class clazz) {
|
||||
if (clazz == boolean.class) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;", false);
|
||||
} else if (clazz == byte.class) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;", false);
|
||||
} else if (clazz == short.class) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;", false);
|
||||
} else if (clazz == char.class) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;", false);
|
||||
} else if (clazz == int.class) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false);
|
||||
} else if (clazz == float.class) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;", false);
|
||||
} else if (clazz == long.class) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;", false);
|
||||
} else if (clazz == double.class) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;", false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void visitCheckCast(MethodVisitor mv, Class clazz) {
|
||||
if (clazz == boolean.class) {
|
||||
mv.visitTypeInsn(CHECKCAST, "java/lang/Boolean");
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Boolean", "booleanValue", "()Z", false);
|
||||
} else if (clazz == byte.class) {
|
||||
mv.visitTypeInsn(CHECKCAST, "java/lang/Byte");
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Byte", "byteValue", "()B", false);
|
||||
} else if (clazz == short.class) {
|
||||
mv.visitTypeInsn(CHECKCAST, "java/lang/Short");
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Short", "shortValue", "()S", false);
|
||||
} else if (clazz == char.class) {
|
||||
mv.visitTypeInsn(CHECKCAST, "java/lang/Character");
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Character", "charValue", "()C", false);
|
||||
} else if (clazz == int.class) {
|
||||
mv.visitTypeInsn(CHECKCAST, "java/lang/Integer");
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I", false);
|
||||
} else if (clazz == float.class) {
|
||||
mv.visitTypeInsn(CHECKCAST, "java/lang/Float");
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Float", "floatValue", "()F", false);
|
||||
} else if (clazz == long.class) {
|
||||
mv.visitTypeInsn(CHECKCAST, "java/lang/Long");
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Long", "longValue", "()J", false);
|
||||
} else if (clazz == double.class) {
|
||||
mv.visitTypeInsn(CHECKCAST, "java/lang/Double");
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Double", "doubleValue", "()D", false);
|
||||
} else if (clazz == boolean[].class) {
|
||||
mv.visitTypeInsn(CHECKCAST, "[Z");
|
||||
} else if (clazz == byte[].class) {
|
||||
mv.visitTypeInsn(CHECKCAST, "[B");
|
||||
} else if (clazz == short[].class) {
|
||||
mv.visitTypeInsn(CHECKCAST, "[S");
|
||||
} else if (clazz == char[].class) {
|
||||
mv.visitTypeInsn(CHECKCAST, "[C");
|
||||
} else if (clazz == int[].class) {
|
||||
mv.visitTypeInsn(CHECKCAST, "[I");
|
||||
} else if (clazz == float[].class) {
|
||||
mv.visitTypeInsn(CHECKCAST, "[F");
|
||||
} else if (clazz == long[].class) {
|
||||
mv.visitTypeInsn(CHECKCAST, "[J");
|
||||
} else if (clazz == double[].class) {
|
||||
mv.visitTypeInsn(CHECKCAST, "[D");
|
||||
} else if (clazz.isArray()) {
|
||||
mv.visitTypeInsn(CHECKCAST, Type.getDescriptor(clazz));
|
||||
} else {
|
||||
mv.visitTypeInsn(CHECKCAST, clazz.getName().replace('.', '/'));
|
||||
}
|
||||
}
|
||||
|
||||
public static void visitPrimitiveVirtual(MethodVisitor mv, Class clazz) {
|
||||
if (clazz == boolean.class) {
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Boolean", "booleanValue", "()Z", false);
|
||||
} else if (clazz == byte.class) {
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Byte", "byteValue", "()B", false);
|
||||
} else if (clazz == short.class) {
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Short", "shortValue", "()S", false);
|
||||
} else if (clazz == char.class) {
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Character", "charValue", "()C", false);
|
||||
} else if (clazz == int.class) {
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I", false);
|
||||
} else if (clazz == float.class) {
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Float", "floatValue", "()F", false);
|
||||
} else if (clazz == long.class) {
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Long", "longValue", "()J", false);
|
||||
} else if (clazz == double.class) {
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Double", "doubleValue", "()D", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,34 +68,27 @@ import java.util.Arrays;
|
||||
*/
|
||||
public class Attribute {
|
||||
|
||||
/**
|
||||
* The type of this attribute.
|
||||
*/
|
||||
/** The type of this attribute. */
|
||||
public final String type;
|
||||
|
||||
/**
|
||||
* The raw value of this attribute, used only for unknown attributes.
|
||||
*/
|
||||
/** The raw value of this attribute, used only for unknown attributes. */
|
||||
byte[] value;
|
||||
|
||||
/**
|
||||
* The next attribute in this attribute list. May be <tt>null</tt>.
|
||||
*/
|
||||
/** The next attribute in this attribute list. May be <tt>null</tt>. */
|
||||
Attribute next;
|
||||
|
||||
/**
|
||||
* Constructs a new empty attribute.
|
||||
*
|
||||
* @param type
|
||||
* the type of the attribute.
|
||||
* @param type the type of the attribute.
|
||||
*/
|
||||
protected Attribute(final String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this type of attribute is unknown. The default
|
||||
* implementation of this method always returns <tt>true</tt>.
|
||||
* Returns <tt>true</tt> if this type of attribute is unknown. The default implementation of this
|
||||
* method always returns <tt>true</tt>.
|
||||
*
|
||||
* @return <tt>true</tt> if this type of attribute is unknown.
|
||||
*/
|
||||
@@ -115,46 +108,37 @@ public class Attribute {
|
||||
/**
|
||||
* Returns the labels corresponding to this attribute.
|
||||
*
|
||||
* @return the labels corresponding to this attribute, or <tt>null</tt> if
|
||||
* this attribute is not a code attribute that contains labels.
|
||||
* @return the labels corresponding to this attribute, or <tt>null</tt> if this attribute is not a
|
||||
* code attribute that contains labels.
|
||||
*/
|
||||
protected Label[] getLabels() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a {@link #type type} attribute. This method must return a
|
||||
* <i>new</i> {@link Attribute} object, of type {@link #type type},
|
||||
* corresponding to the <tt>len</tt> bytes starting at the given offset, in
|
||||
* the given class reader.
|
||||
* Reads a {@link #type type} attribute. This method must return a <i>new</i> {@link Attribute} object, of type
|
||||
* {@link #type type}, corresponding to the <tt>len</tt> bytes starting at the given offset, in the
|
||||
* given class reader.
|
||||
*
|
||||
* @param cr
|
||||
* the class that contains the attribute to be read.
|
||||
* @param off
|
||||
* index of the first byte of the attribute's content in
|
||||
* {@link ClassReader#b cr.b}. The 6 attribute header bytes,
|
||||
* containing the type and the length of the attribute, are not
|
||||
* taken into account here.
|
||||
* @param len
|
||||
* the length of the attribute's content.
|
||||
* @param buf
|
||||
* buffer to be used to call {@link ClassReader#readUTF8
|
||||
* readUTF8}, {@link ClassReader#readClass(int,char[]) readClass}
|
||||
* or {@link ClassReader#readConst readConst}.
|
||||
* @param codeOff
|
||||
* index of the first byte of code's attribute content in
|
||||
* {@link ClassReader#b cr.b}, or -1 if the attribute to be read
|
||||
* is not a code attribute. The 6 attribute header bytes,
|
||||
* containing the type and the length of the attribute, are not
|
||||
* taken into account here.
|
||||
* @param labels
|
||||
* the labels of the method's code, or <tt>null</tt> if the
|
||||
* attribute to be read is not a code attribute.
|
||||
* @return a <i>new</i> {@link Attribute} object corresponding to the given
|
||||
* bytes.
|
||||
* @param cr the class that contains the attribute to be read.
|
||||
* @param off index of the first byte of the attribute's content in {@link ClassReader#b cr.b}. The 6 attribute
|
||||
* header bytes, containing the type and the length of the attribute, are not taken into account here.
|
||||
* @param len the length of the attribute's content.
|
||||
* @param buf buffer to be used to call {@link ClassReader#readUTF8 readUTF8},
|
||||
* {@link ClassReader#readClass(int,char[]) readClass} or {@link ClassReader#readConst readConst}.
|
||||
* @param codeOff index of the first byte of code's attribute content in {@link ClassReader#b cr.b}, or -1 if the
|
||||
* attribute to be read is not a code attribute. The 6 attribute header bytes, containing the type and the
|
||||
* length of the attribute, are not taken into account here.
|
||||
* @param labels the labels of the method's code, or <tt>null</tt> if the attribute to be read is
|
||||
* not a code attribute.
|
||||
* @return a <i>new</i> {@link Attribute} object corresponding to the given bytes.
|
||||
*/
|
||||
protected Attribute read(final ClassReader cr, final int off,
|
||||
final int len, final char[] buf, final int codeOff,
|
||||
protected Attribute read(
|
||||
final ClassReader cr,
|
||||
final int off,
|
||||
final int len,
|
||||
final char[] buf,
|
||||
final int codeOff,
|
||||
final Label[] labels) {
|
||||
Attribute attr = new Attribute(type);
|
||||
attr.value = new byte[len];
|
||||
@@ -165,30 +149,20 @@ public class Attribute {
|
||||
/**
|
||||
* Returns the byte array form of this attribute.
|
||||
*
|
||||
* @param cw
|
||||
* the class to which this attribute must be added. This
|
||||
* parameter can be used to add to the constant pool of this
|
||||
* class the items that corresponds to this attribute.
|
||||
* @param code
|
||||
* the bytecode of the method corresponding to this code
|
||||
* attribute, or <tt>null</tt> if this attribute is not a code
|
||||
* attributes.
|
||||
* @param len
|
||||
* the length of the bytecode of the method corresponding to this
|
||||
* code attribute, or <tt>null</tt> if this attribute is not a
|
||||
* code attribute.
|
||||
* @param maxStack
|
||||
* the maximum stack size of the method corresponding to this
|
||||
* code attribute, or -1 if this attribute is not a code
|
||||
* attribute.
|
||||
* @param maxLocals
|
||||
* the maximum number of local variables of the method
|
||||
* corresponding to this code attribute, or -1 if this attribute
|
||||
* is not a code attribute.
|
||||
* @param cw the class to which this attribute must be added. This parameter can be used to add to the constant pool
|
||||
* of this class the items that corresponds to this attribute.
|
||||
* @param code the bytecode of the method corresponding to this code attribute, or <tt>null</tt> if
|
||||
* this attribute is not a code attributes.
|
||||
* @param len the length of the bytecode of the method corresponding to this code attribute, or
|
||||
* <tt>null</tt> if this attribute is not a code attribute.
|
||||
* @param maxStack the maximum stack size of the method corresponding to this code attribute, or -1 if this
|
||||
* attribute is not a code attribute.
|
||||
* @param maxLocals the maximum number of local variables of the method corresponding to this code attribute, or -1
|
||||
* if this attribute is not a code attribute.
|
||||
* @return the byte array form of this attribute.
|
||||
*/
|
||||
protected ByteVector write(final ClassWriter cw, final byte[] code,
|
||||
final int len, final int maxStack, final int maxLocals) {
|
||||
protected ByteVector write(
|
||||
final ClassWriter cw, final byte[] code, final int len, final int maxStack, final int maxLocals) {
|
||||
ByteVector v = new ByteVector();
|
||||
v.data = value;
|
||||
v.length = value.length;
|
||||
@@ -213,30 +187,20 @@ public class Attribute {
|
||||
/**
|
||||
* Returns the size of all the attributes in this attribute list.
|
||||
*
|
||||
* @param cw
|
||||
* the class writer to be used to convert the attributes into
|
||||
* byte arrays, with the {@link #write write} method.
|
||||
* @param code
|
||||
* the bytecode of the method corresponding to these code
|
||||
* attributes, or <tt>null</tt> if these attributes are not code
|
||||
* attributes.
|
||||
* @param len
|
||||
* the length of the bytecode of the method corresponding to
|
||||
* these code attributes, or <tt>null</tt> if these attributes
|
||||
* are not code attributes.
|
||||
* @param maxStack
|
||||
* the maximum stack size of the method corresponding to these
|
||||
* code attributes, or -1 if these attributes are not code
|
||||
* attributes.
|
||||
* @param maxLocals
|
||||
* the maximum number of local variables of the method
|
||||
* corresponding to these code attributes, or -1 if these
|
||||
* attributes are not code attributes.
|
||||
* @return the size of all the attributes in this attribute list. This size
|
||||
* includes the size of the attribute headers.
|
||||
* @param cw the class writer to be used to convert the attributes into byte arrays, with the {@link #write write}
|
||||
* method.
|
||||
* @param code the bytecode of the method corresponding to these code attributes, or <tt>null</tt>
|
||||
* if these attributes are not code attributes.
|
||||
* @param len the length of the bytecode of the method corresponding to these code attributes, or
|
||||
* <tt>null</tt> if these attributes are not code attributes.
|
||||
* @param maxStack the maximum stack size of the method corresponding to these code attributes, or -1 if these
|
||||
* attributes are not code attributes.
|
||||
* @param maxLocals the maximum number of local variables of the method corresponding to these code attributes, or
|
||||
* -1 if these attributes are not code attributes.
|
||||
* @return the size of all the attributes in this attribute list. This size includes the size of the attribute
|
||||
* headers.
|
||||
*/
|
||||
final int getSize(final ClassWriter cw, final byte[] code, final int len,
|
||||
final int maxStack, final int maxLocals) {
|
||||
final int getSize(final ClassWriter cw, final byte[] code, final int len, final int maxStack, final int maxLocals) {
|
||||
Attribute attr = this;
|
||||
int size = 0;
|
||||
while (attr != null) {
|
||||
@@ -248,33 +212,27 @@ public class Attribute {
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes all the attributes of this attribute list in the given byte
|
||||
* vector.
|
||||
* Writes all the attributes of this attribute list in the given byte vector.
|
||||
*
|
||||
* @param cw
|
||||
* the class writer to be used to convert the attributes into
|
||||
* byte arrays, with the {@link #write write} method.
|
||||
* @param code
|
||||
* the bytecode of the method corresponding to these code
|
||||
* attributes, or <tt>null</tt> if these attributes are not code
|
||||
* attributes.
|
||||
* @param len
|
||||
* the length of the bytecode of the method corresponding to
|
||||
* these code attributes, or <tt>null</tt> if these attributes
|
||||
* are not code attributes.
|
||||
* @param maxStack
|
||||
* the maximum stack size of the method corresponding to these
|
||||
* code attributes, or -1 if these attributes are not code
|
||||
* attributes.
|
||||
* @param maxLocals
|
||||
* the maximum number of local variables of the method
|
||||
* corresponding to these code attributes, or -1 if these
|
||||
* attributes are not code attributes.
|
||||
* @param out
|
||||
* where the attributes must be written.
|
||||
* @param cw the class writer to be used to convert the attributes into byte arrays, with the {@link #write write}
|
||||
* method.
|
||||
* @param code the bytecode of the method corresponding to these code attributes, or <tt>null</tt>
|
||||
* if these attributes are not code attributes.
|
||||
* @param len the length of the bytecode of the method corresponding to these code attributes, or
|
||||
* <tt>null</tt> if these attributes are not code attributes.
|
||||
* @param maxStack the maximum stack size of the method corresponding to these code attributes, or -1 if these
|
||||
* attributes are not code attributes.
|
||||
* @param maxLocals the maximum number of local variables of the method corresponding to these code attributes, or
|
||||
* -1 if these attributes are not code attributes.
|
||||
* @param out where the attributes must be written.
|
||||
*/
|
||||
final void put(final ClassWriter cw, final byte[] code, final int len,
|
||||
final int maxStack, final int maxLocals, final ByteVector out) {
|
||||
final void put(
|
||||
final ClassWriter cw,
|
||||
final byte[] code,
|
||||
final int len,
|
||||
final int maxStack,
|
||||
final int maxLocals,
|
||||
final ByteVector out) {
|
||||
Attribute attr = this;
|
||||
while (attr != null) {
|
||||
ByteVector b = attr.write(cw, code, len, maxStack, maxLocals);
|
||||
@@ -284,15 +242,12 @@ public class Attribute {
|
||||
}
|
||||
}
|
||||
|
||||
//The stuff below is temporary - once proper support for nestmate attribute has been added, it can be safely removed.
|
||||
//see also changes in ClassReader.accept.
|
||||
/**
|
||||
*
|
||||
*/
|
||||
// The stuff below is temporary - once proper support for nestmate attribute has been added, it can be safely
|
||||
// removed.
|
||||
// see also changes in ClassReader.accept.
|
||||
/** */
|
||||
public static class NestMembers extends Attribute {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/** */
|
||||
public NestMembers() {
|
||||
super("NestMembers");
|
||||
}
|
||||
@@ -307,7 +262,7 @@ public class Attribute {
|
||||
int size = cr.readShort(off);
|
||||
a.classes = new String[size];
|
||||
off += 2;
|
||||
for (int i = 0; i < size ; i++) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
a.classes[i] = cr.readClass(off, buf);
|
||||
off += 2;
|
||||
}
|
||||
@@ -326,16 +281,12 @@ public class Attribute {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/** */
|
||||
public static class NestHost extends Attribute {
|
||||
|
||||
byte[] bytes;
|
||||
String clazz;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/** */
|
||||
public NestHost() {
|
||||
super("NestHost");
|
||||
}
|
||||
@@ -357,8 +308,5 @@ public class Attribute {
|
||||
}
|
||||
}
|
||||
|
||||
static final Attribute[] DEFAULT_ATTRIBUTE_PROTOS = new Attribute[] {
|
||||
new NestMembers(),
|
||||
new NestHost()
|
||||
};
|
||||
static final Attribute[] DEFAULT_ATTRIBUTE_PROTOS = new Attribute[] {new NestMembers(), new NestHost()};
|
||||
}
|
||||
|
||||
@@ -59,48 +59,37 @@
|
||||
package org.redkale.asm;
|
||||
|
||||
/**
|
||||
* A dynamically extensible vector of bytes. This class is roughly equivalent to
|
||||
* a DataOutputStream on top of a ByteArrayOutputStream, but is more efficient.
|
||||
* A dynamically extensible vector of bytes. This class is roughly equivalent to a DataOutputStream on top of a
|
||||
* ByteArrayOutputStream, but is more efficient.
|
||||
*
|
||||
* @author Eric Bruneton
|
||||
*/
|
||||
public class ByteVector {
|
||||
|
||||
/**
|
||||
* The content of this vector.
|
||||
*/
|
||||
/** The content of this vector. */
|
||||
byte[] data;
|
||||
|
||||
/**
|
||||
* Actual number of bytes in this vector.
|
||||
*/
|
||||
/** Actual number of bytes in this vector. */
|
||||
int length;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link ByteVector ByteVector} with a default initial
|
||||
* size.
|
||||
*/
|
||||
/** Constructs a new {@link ByteVector ByteVector} with a default initial size. */
|
||||
public ByteVector() {
|
||||
data = new byte[64];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@link ByteVector ByteVector} with the given initial
|
||||
* size.
|
||||
* Constructs a new {@link ByteVector ByteVector} with the given initial size.
|
||||
*
|
||||
* @param initialSize
|
||||
* the initial size of the byte vector to be constructed.
|
||||
* @param initialSize the initial size of the byte vector to be constructed.
|
||||
*/
|
||||
public ByteVector(final int initialSize) {
|
||||
data = new byte[initialSize];
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts a byte into this byte vector. The byte vector is automatically
|
||||
* enlarged if necessary.
|
||||
* Puts a byte into this byte vector. The byte vector is automatically enlarged if necessary.
|
||||
*
|
||||
* @param b
|
||||
* a byte.
|
||||
* @param b a byte.
|
||||
* @return this byte vector.
|
||||
*/
|
||||
public ByteVector putByte(final int b) {
|
||||
@@ -114,13 +103,10 @@ public class ByteVector {
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts two bytes into this byte vector. The byte vector is automatically
|
||||
* enlarged if necessary.
|
||||
* Puts two bytes into this byte vector. The byte vector is automatically enlarged if necessary.
|
||||
*
|
||||
* @param b1
|
||||
* a byte.
|
||||
* @param b2
|
||||
* another byte.
|
||||
* @param b1 a byte.
|
||||
* @param b2 another byte.
|
||||
* @return this byte vector.
|
||||
*/
|
||||
ByteVector put11(final int b1, final int b2) {
|
||||
@@ -136,11 +122,9 @@ public class ByteVector {
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts a short into this byte vector. The byte vector is automatically
|
||||
* enlarged if necessary.
|
||||
* Puts a short into this byte vector. The byte vector is automatically enlarged if necessary.
|
||||
*
|
||||
* @param s
|
||||
* a short.
|
||||
* @param s a short.
|
||||
* @return this byte vector.
|
||||
*/
|
||||
public ByteVector putShort(final int s) {
|
||||
@@ -156,13 +140,10 @@ public class ByteVector {
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts a byte and a short into this byte vector. The byte vector is
|
||||
* automatically enlarged if necessary.
|
||||
* Puts a byte and a short into this byte vector. The byte vector is automatically enlarged if necessary.
|
||||
*
|
||||
* @param b
|
||||
* a byte.
|
||||
* @param s
|
||||
* a short.
|
||||
* @param b a byte.
|
||||
* @param s a short.
|
||||
* @return this byte vector.
|
||||
*/
|
||||
ByteVector put12(final int b, final int s) {
|
||||
@@ -179,11 +160,9 @@ public class ByteVector {
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts an int into this byte vector. The byte vector is automatically
|
||||
* enlarged if necessary.
|
||||
* Puts an int into this byte vector. The byte vector is automatically enlarged if necessary.
|
||||
*
|
||||
* @param i
|
||||
* an int.
|
||||
* @param i an int.
|
||||
* @return this byte vector.
|
||||
*/
|
||||
public ByteVector putInt(final int i) {
|
||||
@@ -201,11 +180,9 @@ public class ByteVector {
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts a long into this byte vector. The byte vector is automatically
|
||||
* enlarged if necessary.
|
||||
* Puts a long into this byte vector. The byte vector is automatically enlarged if necessary.
|
||||
*
|
||||
* @param l
|
||||
* a long.
|
||||
* @param l a long.
|
||||
* @return this byte vector.
|
||||
*/
|
||||
public ByteVector putLong(final long l) {
|
||||
@@ -229,11 +206,9 @@ public class ByteVector {
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts an UTF8 string into this byte vector. The byte vector is
|
||||
* automatically enlarged if necessary.
|
||||
* Puts an UTF8 string into this byte vector. The byte vector is automatically enlarged if necessary.
|
||||
*
|
||||
* @param s
|
||||
* a String whose UTF8 encoded length must be less than 65536.
|
||||
* @param s a String whose UTF8 encoded length must be less than 65536.
|
||||
* @return this byte vector.
|
||||
*/
|
||||
public ByteVector putUTF8(final String s) {
|
||||
@@ -268,20 +243,14 @@ public class ByteVector {
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts an UTF8 string into this byte vector. The byte vector is
|
||||
* automatically enlarged if necessary. The string length is encoded in two
|
||||
* bytes before the encoded characters, if there is space for that (i.e. if
|
||||
* this.length - i - 2 >= 0).
|
||||
* Puts an UTF8 string into this byte vector. The byte vector is automatically enlarged if necessary. The string
|
||||
* length is encoded in two bytes before the encoded characters, if there is space for that (i.e. if this.length - i
|
||||
* - 2 >= 0).
|
||||
*
|
||||
* @param s
|
||||
* the String to encode.
|
||||
* @param i
|
||||
* the index of the first character to encode. The previous
|
||||
* characters are supposed to have already been encoded, using
|
||||
* only one byte per character.
|
||||
* @param maxByteLength
|
||||
* the maximum byte length of the encoded string, including the
|
||||
* already encoded characters.
|
||||
* @param s the String to encode.
|
||||
* @param i the index of the first character to encode. The previous characters are supposed to have already been
|
||||
* encoded, using only one byte per character.
|
||||
* @param maxByteLength the maximum byte length of the encoded string, including the already encoded characters.
|
||||
* @return this byte vector.
|
||||
*/
|
||||
ByteVector encodeUTF8(final String s, int i, int maxByteLength) {
|
||||
@@ -303,8 +272,8 @@ public class ByteVector {
|
||||
}
|
||||
int start = length - i - 2;
|
||||
if (start >= 0) {
|
||||
data[start] = (byte) (byteLength >>> 8);
|
||||
data[start + 1] = (byte) byteLength;
|
||||
data[start] = (byte) (byteLength >>> 8);
|
||||
data[start + 1] = (byte) byteLength;
|
||||
}
|
||||
if (length + byteLength - i > data.length) {
|
||||
enlarge(byteLength - i);
|
||||
@@ -328,16 +297,12 @@ public class ByteVector {
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts an array of bytes into this byte vector. The byte vector is
|
||||
* automatically enlarged if necessary.
|
||||
* Puts an array of bytes into this byte vector. The byte vector is automatically enlarged if necessary.
|
||||
*
|
||||
* @param b
|
||||
* an array of bytes. May be <tt>null</tt> to put <tt>len</tt>
|
||||
* null bytes into this byte vector.
|
||||
* @param off
|
||||
* index of the fist byte of b that must be copied.
|
||||
* @param len
|
||||
* number of bytes of b that must be copied.
|
||||
* @param b an array of bytes. May be <tt>null</tt> to put <tt>len</tt> null bytes
|
||||
* into this byte vector.
|
||||
* @param off index of the fist byte of b that must be copied.
|
||||
* @param len number of bytes of b that must be copied.
|
||||
* @return this byte vector.
|
||||
*/
|
||||
public ByteVector putByteArray(final byte[] b, final int off, final int len) {
|
||||
@@ -354,9 +319,7 @@ public class ByteVector {
|
||||
/**
|
||||
* Enlarge this byte vector so that it can receive n more bytes.
|
||||
*
|
||||
* @param size
|
||||
* number of additional bytes that this byte vector should be
|
||||
* able to receive.
|
||||
* @param size number of additional bytes that this byte vector should be able to receive.
|
||||
*/
|
||||
private void enlarge(final int size) {
|
||||
int length1 = 2 * data.length;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -59,35 +59,31 @@
|
||||
package org.redkale.asm;
|
||||
|
||||
/**
|
||||
* A visitor to visit a Java class. The methods of this class must be called in
|
||||
* the following order: <tt>visit</tt> [ <tt>visitSource</tt> ] [
|
||||
* <tt>visitModule</tt> ][ <tt>visitOuterClass</tt> ] ( <tt>visitAnnotation</tt> |
|
||||
* A visitor to visit a Java class. The methods of this class must be called in the following order:
|
||||
* <tt>visit</tt> [ <tt>visitSource</tt> ] [ <tt>visitModule</tt> ][
|
||||
* <tt>visitOuterClass</tt> ] ( <tt>visitAnnotation</tt> |
|
||||
* <tt>visitTypeAnnotation</tt> | <tt>visitAttribute</tt> )* (
|
||||
* <tt>visitInnerClass</tt> | <tt>visitField</tt> | <tt>visitMethod</tt> )*
|
||||
* <tt>visitEnd</tt>.
|
||||
* <tt>visitInnerClass</tt> | <tt>visitField</tt> | <tt>visitMethod</tt>
|
||||
* )* <tt>visitEnd</tt>.
|
||||
*
|
||||
* @author Eric Bruneton
|
||||
*/
|
||||
public abstract class ClassVisitor {
|
||||
|
||||
/**
|
||||
* The ASM API version implemented by this visitor. The value of this field
|
||||
* must be one of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of {@link Opcodes#ASM4},
|
||||
* {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
*/
|
||||
protected final int api;
|
||||
|
||||
/**
|
||||
* The class visitor to which this visitor must delegate method calls. May
|
||||
* be null.
|
||||
*/
|
||||
/** The class visitor to which this visitor must delegate method calls. May be null. */
|
||||
protected ClassVisitor cv;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link ClassVisitor}.
|
||||
*
|
||||
* @param api
|
||||
* the ASM API version implemented by this visitor. Must be one
|
||||
* of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link Opcodes#ASM4},
|
||||
* {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
*/
|
||||
public ClassVisitor(final int api) {
|
||||
this(api, null);
|
||||
@@ -96,12 +92,9 @@ public abstract class ClassVisitor {
|
||||
/**
|
||||
* Constructs a new {@link ClassVisitor}.
|
||||
*
|
||||
* @param api
|
||||
* the ASM API version implemented by this visitor. Must be one
|
||||
* of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
* @param cv
|
||||
* the class visitor to which this visitor must delegate method
|
||||
* calls. May be null.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link Opcodes#ASM4},
|
||||
* {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
* @param cv the class visitor to which this visitor must delegate method calls. May be null.
|
||||
*/
|
||||
public ClassVisitor(final int api, final ClassVisitor cv) {
|
||||
this.api = api;
|
||||
@@ -111,30 +104,19 @@ public abstract class ClassVisitor {
|
||||
/**
|
||||
* Visits the header of the class.
|
||||
*
|
||||
* @param version
|
||||
* the class version.
|
||||
* @param access
|
||||
* the class's access flags (see {@link Opcodes}). This parameter
|
||||
* also indicates if the class is deprecated.
|
||||
* @param name
|
||||
* the internal name of the class (see
|
||||
* {@link Type#getInternalName() getInternalName}).
|
||||
* @param signature
|
||||
* the signature of this class. May be <tt>null</tt> if the class
|
||||
* is not a generic one, and does not extend or implement generic
|
||||
* classes or interfaces.
|
||||
* @param superName
|
||||
* the internal of name of the super class (see
|
||||
* {@link Type#getInternalName() getInternalName}). For
|
||||
* interfaces, the super class is {@link Object}. May be
|
||||
* <tt>null</tt>, but only for the {@link Object} class.
|
||||
* @param interfaces
|
||||
* the internal names of the class's interfaces (see
|
||||
* {@link Type#getInternalName() getInternalName}). May be
|
||||
* <tt>null</tt>.
|
||||
* @param version the class version.
|
||||
* @param access the class's access flags (see {@link Opcodes}). This parameter also indicates if the class is
|
||||
* deprecated.
|
||||
* @param name the internal name of the class (see {@link Type#getInternalName() getInternalName}).
|
||||
* @param signature the signature of this class. May be <tt>null</tt> if the class is not a generic
|
||||
* one, and does not extend or implement generic classes or interfaces.
|
||||
* @param superName the internal of name of the super class (see {@link Type#getInternalName() getInternalName}).
|
||||
* For interfaces, the super class is {@link Object}. May be <tt>null</tt>, but only for the
|
||||
* {@link Object} class.
|
||||
* @param interfaces the internal names of the class's interfaces (see {@link Type#getInternalName()
|
||||
* getInternalName}). May be <tt>null</tt>.
|
||||
*/
|
||||
public void visit(int version, int access, String name, String signature,
|
||||
String superName, String[] interfaces) {
|
||||
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
|
||||
if (cv != null) {
|
||||
cv.visit(version, access, name, signature, superName, interfaces);
|
||||
}
|
||||
@@ -143,13 +125,10 @@ public abstract class ClassVisitor {
|
||||
/**
|
||||
* Visits the source of the class.
|
||||
*
|
||||
* @param source
|
||||
* the name of the source file from which the class was compiled.
|
||||
* May be <tt>null</tt>.
|
||||
* @param debug
|
||||
* additional debug information to compute the correspondance
|
||||
* between source and compiled elements of the class. May be
|
||||
* <tt>null</tt>.
|
||||
* @param source the name of the source file from which the class was compiled. May be
|
||||
* <tt>null</tt>.
|
||||
* @param debug additional debug information to compute the correspondance between source and compiled elements of
|
||||
* the class. May be <tt>null</tt>.
|
||||
*/
|
||||
public void visitSource(String source, String debug) {
|
||||
if (cv != null) {
|
||||
@@ -159,15 +138,12 @@ public abstract class ClassVisitor {
|
||||
|
||||
/**
|
||||
* Visit the module corresponding to the class.
|
||||
* @param name
|
||||
* module name
|
||||
* @param access
|
||||
* module flags, among {@code ACC_OPEN}, {@code ACC_SYNTHETIC}
|
||||
* and {@code ACC_MANDATED}.
|
||||
* @param version
|
||||
* module version or null.
|
||||
* @return a visitor to visit the module values, or <tt>null</tt> if
|
||||
* this visitor is not interested in visiting this module.
|
||||
*
|
||||
* @param name module name
|
||||
* @param access module flags, among {@code ACC_OPEN}, {@code ACC_SYNTHETIC} and {@code ACC_MANDATED}.
|
||||
* @param version module version or null.
|
||||
* @return a visitor to visit the module values, or <tt>null</tt> if this visitor is not interested
|
||||
* in visiting this module.
|
||||
*/
|
||||
public ModuleVisitor visitModule(String name, int access, String version) {
|
||||
if (api < Opcodes.ASM6) {
|
||||
@@ -180,19 +156,13 @@ public abstract class ClassVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits the enclosing class of the class. This method must be called only
|
||||
* if the class has an enclosing class.
|
||||
* Visits the enclosing class of the class. This method must be called only if the class has an enclosing class.
|
||||
*
|
||||
* @param owner
|
||||
* internal name of the enclosing class of the class.
|
||||
* @param name
|
||||
* the name of the method that contains the class, or
|
||||
* <tt>null</tt> if the class is not enclosed in a method of its
|
||||
* enclosing class.
|
||||
* @param desc
|
||||
* the descriptor of the method that contains the class, or
|
||||
* <tt>null</tt> if the class is not enclosed in a method of its
|
||||
* enclosing class.
|
||||
* @param owner internal name of the enclosing class of the class.
|
||||
* @param name the name of the method that contains the class, or <tt>null</tt> if the class is not
|
||||
* enclosed in a method of its enclosing class.
|
||||
* @param desc the descriptor of the method that contains the class, or <tt>null</tt> if the class
|
||||
* is not enclosed in a method of its enclosing class.
|
||||
*/
|
||||
public void visitOuterClass(String owner, String name, String desc) {
|
||||
if (cv != null) {
|
||||
@@ -203,12 +173,10 @@ public abstract class ClassVisitor {
|
||||
/**
|
||||
* Visits an annotation of the class.
|
||||
*
|
||||
* @param desc
|
||||
* the class descriptor of the annotation class.
|
||||
* @param visible
|
||||
* <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if
|
||||
* this visitor is not interested in visiting this annotation.
|
||||
* @param desc the class descriptor of the annotation class.
|
||||
* @param visible <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if this visitor is not
|
||||
* interested in visiting this annotation.
|
||||
*/
|
||||
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
|
||||
if (cv != null) {
|
||||
@@ -220,27 +188,18 @@ public abstract class ClassVisitor {
|
||||
/**
|
||||
* Visits an annotation on a type in the class signature.
|
||||
*
|
||||
* @param typeRef
|
||||
* a reference to the annotated type. The sort of this type
|
||||
* reference must be {@link TypeReference#CLASS_TYPE_PARAMETER
|
||||
* CLASS_TYPE_PARAMETER},
|
||||
* {@link TypeReference#CLASS_TYPE_PARAMETER_BOUND
|
||||
* CLASS_TYPE_PARAMETER_BOUND} or
|
||||
* {@link TypeReference#CLASS_EXTENDS CLASS_EXTENDS}. See
|
||||
* {@link TypeReference}.
|
||||
* @param typePath
|
||||
* the path to the annotated type argument, wildcard bound, array
|
||||
* element type, or static inner type within 'typeRef'. May be
|
||||
* <tt>null</tt> if the annotation targets 'typeRef' as a whole.
|
||||
* @param desc
|
||||
* the class descriptor of the annotation class.
|
||||
* @param visible
|
||||
* <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if
|
||||
* this visitor is not interested in visiting this annotation.
|
||||
* @param typeRef a reference to the annotated type. The sort of this type reference must be
|
||||
* {@link TypeReference#CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER},
|
||||
* {@link TypeReference#CLASS_TYPE_PARAMETER_BOUND CLASS_TYPE_PARAMETER_BOUND} or
|
||||
* {@link TypeReference#CLASS_EXTENDS CLASS_EXTENDS}. See {@link TypeReference}.
|
||||
* @param typePath the path to the annotated type argument, wildcard bound, array element type, or static inner type
|
||||
* within 'typeRef'. May be <tt>null</tt> if the annotation targets 'typeRef' as a whole.
|
||||
* @param desc the class descriptor of the annotation class.
|
||||
* @param visible <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if this visitor is not
|
||||
* interested in visiting this annotation.
|
||||
*/
|
||||
public AnnotationVisitor visitTypeAnnotation(int typeRef,
|
||||
TypePath typePath, String desc, boolean visible) {
|
||||
public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) {
|
||||
if (cv != null) {
|
||||
return cv.visitTypeAnnotation(typeRef, typePath, desc, visible);
|
||||
}
|
||||
@@ -250,8 +209,7 @@ public abstract class ClassVisitor {
|
||||
/**
|
||||
* Visits a non standard attribute of the class.
|
||||
*
|
||||
* @param attr
|
||||
* an attribute.
|
||||
* @param attr an attribute.
|
||||
*/
|
||||
public void visitAttribute(Attribute attr) {
|
||||
if (cv != null) {
|
||||
@@ -260,25 +218,16 @@ public abstract class ClassVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits information about an inner class. This inner class is not
|
||||
* necessarily a member of the class being visited.
|
||||
* Visits information about an inner class. This inner class is not necessarily a member of the class being visited.
|
||||
*
|
||||
* @param name
|
||||
* the internal name of an inner class (see
|
||||
* {@link Type#getInternalName() getInternalName}).
|
||||
* @param outerName
|
||||
* the internal name of the class to which the inner class
|
||||
* belongs (see {@link Type#getInternalName() getInternalName}).
|
||||
* May be <tt>null</tt> for not member classes.
|
||||
* @param innerName
|
||||
* the (simple) name of the inner class inside its enclosing
|
||||
* class. May be <tt>null</tt> for anonymous inner classes.
|
||||
* @param access
|
||||
* the access flags of the inner class as originally declared in
|
||||
* the enclosing class.
|
||||
* @param name the internal name of an inner class (see {@link Type#getInternalName() getInternalName}).
|
||||
* @param outerName the internal name of the class to which the inner class belongs (see
|
||||
* {@link Type#getInternalName() getInternalName}). May be <tt>null</tt> for not member classes.
|
||||
* @param innerName the (simple) name of the inner class inside its enclosing class. May be
|
||||
* <tt>null</tt> for anonymous inner classes.
|
||||
* @param access the access flags of the inner class as originally declared in the enclosing class.
|
||||
*/
|
||||
public void visitInnerClass(String name, String outerName,
|
||||
String innerName, int access) {
|
||||
public void visitInnerClass(String name, String outerName, String innerName, int access) {
|
||||
if (cv != null) {
|
||||
cv.visitInnerClass(name, outerName, innerName, access);
|
||||
}
|
||||
@@ -287,32 +236,22 @@ public abstract class ClassVisitor {
|
||||
/**
|
||||
* Visits a field of the class.
|
||||
*
|
||||
* @param access
|
||||
* the field's access flags (see {@link Opcodes}). This parameter
|
||||
* also indicates if the field is synthetic and/or deprecated.
|
||||
* @param name
|
||||
* the field's name.
|
||||
* @param desc
|
||||
* the field's descriptor (see {@link Type Type}).
|
||||
* @param signature
|
||||
* the field's signature. May be <tt>null</tt> if the field's
|
||||
* type does not use generic types.
|
||||
* @param value
|
||||
* the field's initial value. This parameter, which may be
|
||||
* <tt>null</tt> if the field does not have an initial value,
|
||||
* must be an {@link Integer}, a {@link Float}, a {@link Long}, a
|
||||
* {@link Double} or a {@link String} (for <tt>int</tt>,
|
||||
* <tt>float</tt>, <tt>long</tt> or <tt>String</tt> fields
|
||||
* respectively). <i>This parameter is only used for static
|
||||
* fields</i>. Its value is ignored for non static fields, which
|
||||
* must be initialized through bytecode instructions in
|
||||
* constructors or methods.
|
||||
* @return a visitor to visit field annotations and attributes, or
|
||||
* <tt>null</tt> if this class visitor is not interested in visiting
|
||||
* these annotations and attributes.
|
||||
* @param access the field's access flags (see {@link Opcodes}). This parameter also indicates if the field is
|
||||
* synthetic and/or deprecated.
|
||||
* @param name the field's name.
|
||||
* @param desc the field's descriptor (see {@link Type Type}).
|
||||
* @param signature the field's signature. May be <tt>null</tt> if the field's type does not use
|
||||
* generic types.
|
||||
* @param value the field's initial value. This parameter, which may be <tt>null</tt> if the field
|
||||
* does not have an initial value, must be an {@link Integer}, a {@link Float}, a {@link Long}, a {@link Double}
|
||||
* or a {@link String} (for <tt>int</tt>, <tt>float</tt>,
|
||||
* <tt>long</tt> or <tt>String</tt> fields respectively). <i>This parameter is
|
||||
* only used for static fields</i>. Its value is ignored for non static fields, which must be initialized
|
||||
* through bytecode instructions in constructors or methods.
|
||||
* @return a visitor to visit field annotations and attributes, or <tt>null</tt> if this class
|
||||
* visitor is not interested in visiting these annotations and attributes.
|
||||
*/
|
||||
public FieldVisitor visitField(int access, String name, String desc,
|
||||
String signature, Object value) {
|
||||
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
|
||||
if (cv != null) {
|
||||
return cv.visitField(access, name, desc, signature, value);
|
||||
}
|
||||
@@ -320,32 +259,21 @@ public abstract class ClassVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a method of the class. This method <i>must</i> return a new
|
||||
* {@link MethodVisitor} instance (or <tt>null</tt>) each time it is called,
|
||||
* i.e., it should not return a previously returned visitor.
|
||||
* Visits a method of the class. This method <i>must</i> return a new {@link MethodVisitor} instance (or
|
||||
* <tt>null</tt>) each time it is called, i.e., it should not return a previously returned visitor.
|
||||
*
|
||||
* @param access
|
||||
* the method's access flags (see {@link Opcodes}). This
|
||||
* parameter also indicates if the method is synthetic and/or
|
||||
* deprecated.
|
||||
* @param name
|
||||
* the method's name.
|
||||
* @param desc
|
||||
* the method's descriptor (see {@link Type Type}).
|
||||
* @param signature
|
||||
* the method's signature. May be <tt>null</tt> if the method
|
||||
* parameters, return type and exceptions do not use generic
|
||||
* types.
|
||||
* @param exceptions
|
||||
* the internal names of the method's exception classes (see
|
||||
* {@link Type#getInternalName() getInternalName}). May be
|
||||
* <tt>null</tt>.
|
||||
* @return an object to visit the byte code of the method, or <tt>null</tt>
|
||||
* if this class visitor is not interested in visiting the code of
|
||||
* this method.
|
||||
* @param access the method's access flags (see {@link Opcodes}). This parameter also indicates if the method is
|
||||
* synthetic and/or deprecated.
|
||||
* @param name the method's name.
|
||||
* @param desc the method's descriptor (see {@link Type Type}).
|
||||
* @param signature the method's signature. May be <tt>null</tt> if the method parameters, return
|
||||
* type and exceptions do not use generic types.
|
||||
* @param exceptions the internal names of the method's exception classes (see {@link Type#getInternalName()
|
||||
* getInternalName}). May be <tt>null</tt>.
|
||||
* @return an object to visit the byte code of the method, or <tt>null</tt> if this class visitor is
|
||||
* not interested in visiting the code of this method.
|
||||
*/
|
||||
public MethodVisitor visitMethod(int access, String name, String desc,
|
||||
String signature, String[] exceptions) {
|
||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||
if (cv != null) {
|
||||
return cv.visitMethod(access, name, desc, signature, exceptions);
|
||||
}
|
||||
@@ -353,9 +281,8 @@ public abstract class ClassVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits the end of the class. This method, which is the last one to be
|
||||
* called, is used to inform the visitor that all the fields and methods of
|
||||
* the class have been visited.
|
||||
* Visits the end of the class. This method, which is the last one to be called, is used to inform the visitor that
|
||||
* all the fields and methods of the class have been visited.
|
||||
*/
|
||||
public void visitEnd() {
|
||||
if (cv != null) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -66,109 +66,78 @@ package org.redkale.asm;
|
||||
*/
|
||||
class Context {
|
||||
|
||||
/**
|
||||
* Prototypes of the attributes that must be parsed for this class.
|
||||
*/
|
||||
/** Prototypes of the attributes that must be parsed for this class. */
|
||||
Attribute[] attrs;
|
||||
|
||||
/**
|
||||
* The {@link ClassReader} option flags for the parsing of this class.
|
||||
*/
|
||||
/** The {@link ClassReader} option flags for the parsing of this class. */
|
||||
int flags;
|
||||
|
||||
/**
|
||||
* The buffer used to read strings.
|
||||
*/
|
||||
/** The buffer used to read strings. */
|
||||
char[] buffer;
|
||||
|
||||
/**
|
||||
* The start index of each bootstrap method.
|
||||
*/
|
||||
/** The start index of each bootstrap method. */
|
||||
int[] bootstrapMethods;
|
||||
|
||||
/**
|
||||
* The access flags of the method currently being parsed.
|
||||
*/
|
||||
/** The access flags of the method currently being parsed. */
|
||||
int access;
|
||||
|
||||
/**
|
||||
* The name of the method currently being parsed.
|
||||
*/
|
||||
/** The name of the method currently being parsed. */
|
||||
String name;
|
||||
|
||||
/**
|
||||
* The descriptor of the method currently being parsed.
|
||||
*/
|
||||
/** The descriptor of the method currently being parsed. */
|
||||
String desc;
|
||||
|
||||
/**
|
||||
* The label objects, indexed by bytecode offset, of the method currently
|
||||
* being parsed (only bytecode offsets for which a label is needed have a
|
||||
* non null associated Label object).
|
||||
* The label objects, indexed by bytecode offset, of the method currently being parsed (only bytecode offsets for
|
||||
* which a label is needed have a non null associated Label object).
|
||||
*/
|
||||
Label[] labels;
|
||||
|
||||
/**
|
||||
* The target of the type annotation currently being parsed.
|
||||
*/
|
||||
/** The target of the type annotation currently being parsed. */
|
||||
int typeRef;
|
||||
|
||||
/**
|
||||
* The path of the type annotation currently being parsed.
|
||||
*/
|
||||
/** The path of the type annotation currently being parsed. */
|
||||
TypePath typePath;
|
||||
|
||||
/**
|
||||
* The offset of the latest stack map frame that has been parsed.
|
||||
*/
|
||||
/** The offset of the latest stack map frame that has been parsed. */
|
||||
int offset;
|
||||
|
||||
/**
|
||||
* The labels corresponding to the start of the local variable ranges in the
|
||||
* local variable type annotation currently being parsed.
|
||||
* The labels corresponding to the start of the local variable ranges in the local variable type annotation
|
||||
* currently being parsed.
|
||||
*/
|
||||
Label[] start;
|
||||
|
||||
/**
|
||||
* The labels corresponding to the end of the local variable ranges in the
|
||||
* local variable type annotation currently being parsed.
|
||||
* The labels corresponding to the end of the local variable ranges in the local variable type annotation currently
|
||||
* being parsed.
|
||||
*/
|
||||
Label[] end;
|
||||
|
||||
/**
|
||||
* The local variable indices for each local variable range in the local
|
||||
* variable type annotation currently being parsed.
|
||||
* The local variable indices for each local variable range in the local variable type annotation currently being
|
||||
* parsed.
|
||||
*/
|
||||
int[] index;
|
||||
|
||||
/**
|
||||
* The encoding of the latest stack map frame that has been parsed.
|
||||
*/
|
||||
/** The encoding of the latest stack map frame that has been parsed. */
|
||||
int mode;
|
||||
|
||||
/**
|
||||
* The number of locals in the latest stack map frame that has been parsed.
|
||||
*/
|
||||
/** The number of locals in the latest stack map frame that has been parsed. */
|
||||
int localCount;
|
||||
|
||||
/**
|
||||
* The number locals in the latest stack map frame that has been parsed,
|
||||
* minus the number of locals in the previous frame.
|
||||
* The number locals in the latest stack map frame that has been parsed, minus the number of locals in the previous
|
||||
* frame.
|
||||
*/
|
||||
int localDiff;
|
||||
|
||||
/**
|
||||
* The local values of the latest stack map frame that has been parsed.
|
||||
*/
|
||||
/** The local values of the latest stack map frame that has been parsed. */
|
||||
Object[] local;
|
||||
|
||||
/**
|
||||
* The stack size of the latest stack map frame that has been parsed.
|
||||
*/
|
||||
/** The stack size of the latest stack map frame that has been parsed. */
|
||||
int stackCount;
|
||||
|
||||
/**
|
||||
* The stack values of the latest stack map frame that has been parsed.
|
||||
*/
|
||||
/** The stack values of the latest stack map frame that has been parsed. */
|
||||
Object[] stack;
|
||||
}
|
||||
|
||||
@@ -60,18 +60,16 @@
|
||||
package org.redkale.asm;
|
||||
|
||||
/**
|
||||
* Information about the input stack map frame at the "current" instruction of a
|
||||
* method. This is implemented as a Frame subclass for a "basic block"
|
||||
* containing only one instruction.
|
||||
* Information about the input stack map frame at the "current" instruction of a method. This is implemented as a Frame
|
||||
* subclass for a "basic block" containing only one instruction.
|
||||
*
|
||||
* @author Eric Bruneton
|
||||
*/
|
||||
class CurrentFrame extends Frame {
|
||||
|
||||
/**
|
||||
* Sets this CurrentFrame to the input stack map frame of the next "current"
|
||||
* instruction, i.e. the instruction just after the given one. It is assumed
|
||||
* that the value of this object when this method is called is the stack map
|
||||
* Sets this CurrentFrame to the input stack map frame of the next "current" instruction, i.e. the instruction just
|
||||
* after the given one. It is assumed that the value of this object when this method is called is the stack map
|
||||
* frame status just before the given instruction is executed.
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -65,40 +65,30 @@ package org.redkale.asm;
|
||||
*/
|
||||
class Edge {
|
||||
|
||||
/**
|
||||
* Denotes a normal control flow graph edge.
|
||||
*/
|
||||
/** Denotes a normal control flow graph edge. */
|
||||
static final int NORMAL = 0;
|
||||
|
||||
/**
|
||||
* Denotes a control flow graph edge corresponding to an exception handler.
|
||||
* More precisely any {@link Edge} whose {@link #info} is strictly positive
|
||||
* corresponds to an exception handler. The actual value of {@link #info} is
|
||||
* the index, in the {@link ClassWriter} type table, of the exception that
|
||||
* is catched.
|
||||
* Denotes a control flow graph edge corresponding to an exception handler. More precisely any {@link Edge} whose
|
||||
* {@link #info} is strictly positive corresponds to an exception handler. The actual value of {@link #info} is the
|
||||
* index, in the {@link ClassWriter} type table, of the exception that is catched.
|
||||
*/
|
||||
static final int EXCEPTION = 0x7FFFFFFF;
|
||||
|
||||
/**
|
||||
* Information about this control flow graph edge. If
|
||||
* {@link ClassWriter#COMPUTE_MAXS} is used this field is the (relative)
|
||||
* stack size in the basic block from which this edge originates. This size
|
||||
* is equal to the stack size at the "jump" instruction to which this edge
|
||||
* corresponds, relatively to the stack size at the beginning of the
|
||||
* originating basic block. If {@link ClassWriter#COMPUTE_FRAMES} is used,
|
||||
* this field is the kind of this control flow graph edge (i.e. NORMAL or
|
||||
* EXCEPTION).
|
||||
* Information about this control flow graph edge. If {@link ClassWriter#COMPUTE_MAXS} is used this field is the
|
||||
* (relative) stack size in the basic block from which this edge originates. This size is equal to the stack size at
|
||||
* the "jump" instruction to which this edge corresponds, relatively to the stack size at the beginning of the
|
||||
* originating basic block. If {@link ClassWriter#COMPUTE_FRAMES} is used, this field is the kind of this control
|
||||
* flow graph edge (i.e. NORMAL or EXCEPTION).
|
||||
*/
|
||||
int info;
|
||||
|
||||
/**
|
||||
* The successor block of the basic block from which this edge originates.
|
||||
*/
|
||||
/** The successor block of the basic block from which this edge originates. */
|
||||
Label successor;
|
||||
|
||||
/**
|
||||
* The next edge in the list of successors of the originating basic block.
|
||||
* See {@link Label#successors successors}.
|
||||
* The next edge in the list of successors of the originating basic block. See {@link Label#successors successors}.
|
||||
*/
|
||||
Edge next;
|
||||
}
|
||||
|
||||
@@ -59,32 +59,28 @@
|
||||
package org.redkale.asm;
|
||||
|
||||
/**
|
||||
* A visitor to visit a Java field. The methods of this class must be called in
|
||||
* the following order: ( <tt>visitAnnotation</tt> |
|
||||
* <tt>visitTypeAnnotation</tt> | <tt>visitAttribute</tt> )* <tt>visitEnd</tt>.
|
||||
* A visitor to visit a Java field. The methods of this class must be called in the following order: (
|
||||
* <tt>visitAnnotation</tt> | <tt>visitTypeAnnotation</tt> |
|
||||
* <tt>visitAttribute</tt> )* <tt>visitEnd</tt>.
|
||||
*
|
||||
* @author Eric Bruneton
|
||||
*/
|
||||
public abstract class FieldVisitor {
|
||||
|
||||
/**
|
||||
* The ASM API version implemented by this visitor. The value of this field
|
||||
* must be one of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of {@link Opcodes#ASM4},
|
||||
* {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
*/
|
||||
protected final int api;
|
||||
|
||||
/**
|
||||
* The field visitor to which this visitor must delegate method calls. May
|
||||
* be null.
|
||||
*/
|
||||
/** The field visitor to which this visitor must delegate method calls. May be null. */
|
||||
protected FieldVisitor fv;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link FieldVisitor}.
|
||||
*
|
||||
* @param api
|
||||
* the ASM API version implemented by this visitor. Must be one
|
||||
* of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link Opcodes#ASM4},
|
||||
* {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
*/
|
||||
public FieldVisitor(final int api) {
|
||||
this(api, null);
|
||||
@@ -93,12 +89,9 @@ public abstract class FieldVisitor {
|
||||
/**
|
||||
* Constructs a new {@link FieldVisitor}.
|
||||
*
|
||||
* @param api
|
||||
* the ASM API version implemented by this visitor. Must be one
|
||||
* of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
* @param fv
|
||||
* the field visitor to which this visitor must delegate method
|
||||
* calls. May be null.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link Opcodes#ASM4},
|
||||
* {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
* @param fv the field visitor to which this visitor must delegate method calls. May be null.
|
||||
*/
|
||||
public FieldVisitor(final int api, final FieldVisitor fv) {
|
||||
this.api = api;
|
||||
@@ -108,12 +101,10 @@ public abstract class FieldVisitor {
|
||||
/**
|
||||
* Visits an annotation of the field.
|
||||
*
|
||||
* @param desc
|
||||
* the class descriptor of the annotation class.
|
||||
* @param visible
|
||||
* <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if
|
||||
* this visitor is not interested in visiting this annotation.
|
||||
* @param desc the class descriptor of the annotation class.
|
||||
* @param visible <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if this visitor is not
|
||||
* interested in visiting this annotation.
|
||||
*/
|
||||
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
|
||||
if (fv != null) {
|
||||
@@ -125,23 +116,16 @@ public abstract class FieldVisitor {
|
||||
/**
|
||||
* Visits an annotation on the type of the field.
|
||||
*
|
||||
* @param typeRef
|
||||
* a reference to the annotated type. The sort of this type
|
||||
* reference must be {@link TypeReference#FIELD FIELD}. See
|
||||
* {@link TypeReference}.
|
||||
* @param typePath
|
||||
* the path to the annotated type argument, wildcard bound, array
|
||||
* element type, or static inner type within 'typeRef'. May be
|
||||
* <tt>null</tt> if the annotation targets 'typeRef' as a whole.
|
||||
* @param desc
|
||||
* the class descriptor of the annotation class.
|
||||
* @param visible
|
||||
* <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if
|
||||
* this visitor is not interested in visiting this annotation.
|
||||
* @param typeRef a reference to the annotated type. The sort of this type reference must be
|
||||
* {@link TypeReference#FIELD FIELD}. See {@link TypeReference}.
|
||||
* @param typePath the path to the annotated type argument, wildcard bound, array element type, or static inner type
|
||||
* within 'typeRef'. May be <tt>null</tt> if the annotation targets 'typeRef' as a whole.
|
||||
* @param desc the class descriptor of the annotation class.
|
||||
* @param visible <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if this visitor is not
|
||||
* interested in visiting this annotation.
|
||||
*/
|
||||
public AnnotationVisitor visitTypeAnnotation(int typeRef,
|
||||
TypePath typePath, String desc, boolean visible) {
|
||||
public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) {
|
||||
if (fv != null) {
|
||||
return fv.visitTypeAnnotation(typeRef, typePath, desc, visible);
|
||||
}
|
||||
@@ -151,8 +135,7 @@ public abstract class FieldVisitor {
|
||||
/**
|
||||
* Visits a non standard attribute of the field.
|
||||
*
|
||||
* @param attr
|
||||
* an attribute.
|
||||
* @param attr an attribute.
|
||||
*/
|
||||
public void visitAttribute(Attribute attr) {
|
||||
if (fv != null) {
|
||||
@@ -161,9 +144,8 @@ public abstract class FieldVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits the end of the field. This method, which is the last one to be
|
||||
* called, is used to inform the visitor that all the annotations and
|
||||
* attributes of the field have been visited.
|
||||
* Visits the end of the field. This method, which is the last one to be called, is used to inform the visitor that
|
||||
* all the annotations and attributes of the field have been visited.
|
||||
*/
|
||||
public void visitEnd() {
|
||||
if (fv != null) {
|
||||
|
||||
@@ -65,64 +65,37 @@ package org.redkale.asm;
|
||||
*/
|
||||
final class FieldWriter extends FieldVisitor {
|
||||
|
||||
/**
|
||||
* The class writer to which this field must be added.
|
||||
*/
|
||||
/** The class writer to which this field must be added. */
|
||||
private final ClassWriter cw;
|
||||
|
||||
/**
|
||||
* Access flags of this field.
|
||||
*/
|
||||
/** Access flags of this field. */
|
||||
private final int access;
|
||||
|
||||
/**
|
||||
* The index of the constant pool item that contains the name of this
|
||||
* method.
|
||||
*/
|
||||
/** The index of the constant pool item that contains the name of this method. */
|
||||
private final int name;
|
||||
|
||||
/**
|
||||
* The index of the constant pool item that contains the descriptor of this
|
||||
* field.
|
||||
*/
|
||||
/** The index of the constant pool item that contains the descriptor of this field. */
|
||||
private final int desc;
|
||||
|
||||
/**
|
||||
* The index of the constant pool item that contains the signature of this
|
||||
* field.
|
||||
*/
|
||||
/** The index of the constant pool item that contains the signature of this field. */
|
||||
private int signature;
|
||||
|
||||
/**
|
||||
* The index of the constant pool item that contains the constant value of
|
||||
* this field.
|
||||
*/
|
||||
/** The index of the constant pool item that contains the constant value of this field. */
|
||||
private int value;
|
||||
|
||||
/**
|
||||
* The runtime visible annotations of this field. May be <tt>null</tt>.
|
||||
*/
|
||||
/** The runtime visible annotations of this field. May be <tt>null</tt>. */
|
||||
private AnnotationWriter anns;
|
||||
|
||||
/**
|
||||
* The runtime invisible annotations of this field. May be <tt>null</tt>.
|
||||
*/
|
||||
/** The runtime invisible annotations of this field. May be <tt>null</tt>. */
|
||||
private AnnotationWriter ianns;
|
||||
|
||||
/**
|
||||
* The runtime visible type annotations of this field. May be <tt>null</tt>.
|
||||
*/
|
||||
/** The runtime visible type annotations of this field. May be <tt>null</tt>. */
|
||||
private AnnotationWriter tanns;
|
||||
|
||||
/**
|
||||
* The runtime invisible type annotations of this field. May be
|
||||
* <tt>null</tt>.
|
||||
*/
|
||||
/** The runtime invisible type annotations of this field. May be <tt>null</tt>. */
|
||||
private AnnotationWriter itanns;
|
||||
|
||||
/**
|
||||
* The non standard attributes of this field. May be <tt>null</tt>.
|
||||
*/
|
||||
/** The non standard attributes of this field. May be <tt>null</tt>. */
|
||||
private Attribute attrs;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -132,21 +105,20 @@ final class FieldWriter extends FieldVisitor {
|
||||
/**
|
||||
* Constructs a new {@link FieldWriter}.
|
||||
*
|
||||
* @param cw
|
||||
* the class writer to which this field must be added.
|
||||
* @param access
|
||||
* the field's access flags (see {@link Opcodes}).
|
||||
* @param name
|
||||
* the field's name.
|
||||
* @param desc
|
||||
* the field's descriptor (see {@link Type}).
|
||||
* @param signature
|
||||
* the field's signature. May be <tt>null</tt>.
|
||||
* @param value
|
||||
* the field's constant value. May be <tt>null</tt>.
|
||||
* @param cw the class writer to which this field must be added.
|
||||
* @param access the field's access flags (see {@link Opcodes}).
|
||||
* @param name the field's name.
|
||||
* @param desc the field's descriptor (see {@link Type}).
|
||||
* @param signature the field's signature. May be <tt>null</tt>.
|
||||
* @param value the field's constant value. May be <tt>null</tt>.
|
||||
*/
|
||||
FieldWriter(final ClassWriter cw, final int access, final String name,
|
||||
final String desc, final String signature, final Object value) {
|
||||
FieldWriter(
|
||||
final ClassWriter cw,
|
||||
final int access,
|
||||
final String name,
|
||||
final String desc,
|
||||
final String signature,
|
||||
final Object value) {
|
||||
super(Opcodes.ASM6);
|
||||
if (cw.firstField == null) {
|
||||
cw.firstField = this;
|
||||
@@ -171,8 +143,7 @@ final class FieldWriter extends FieldVisitor {
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitAnnotation(final String desc,
|
||||
final boolean visible) {
|
||||
public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
|
||||
ByteVector bv = new ByteVector();
|
||||
// write type, and reserve space for values count
|
||||
bv.putShort(cw.newUTF8(desc)).putShort(0);
|
||||
@@ -188,15 +159,14 @@ final class FieldWriter extends FieldVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationVisitor visitTypeAnnotation(final int typeRef,
|
||||
final TypePath typePath, final String desc, final boolean visible) {
|
||||
public AnnotationVisitor visitTypeAnnotation(
|
||||
final int typeRef, final TypePath typePath, final String desc, final boolean visible) {
|
||||
ByteVector bv = new ByteVector();
|
||||
// write target_type and target_info
|
||||
AnnotationWriter.putTarget(typeRef, typePath, bv);
|
||||
// write type, and reserve space for values count
|
||||
bv.putShort(cw.newUTF8(desc)).putShort(0);
|
||||
AnnotationWriter aw = new AnnotationWriter(cw, true, bv, bv,
|
||||
bv.length - 2);
|
||||
AnnotationWriter aw = new AnnotationWriter(cw, true, bv, bv, bv.length - 2);
|
||||
if (visible) {
|
||||
aw.next = tanns;
|
||||
tanns = aw;
|
||||
@@ -215,6 +185,7 @@ final class FieldWriter extends FieldVisitor {
|
||||
|
||||
@Override
|
||||
public void visitEnd() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -233,8 +204,7 @@ final class FieldWriter extends FieldVisitor {
|
||||
size += 8;
|
||||
}
|
||||
if ((access & Opcodes.ACC_SYNTHETIC) != 0) {
|
||||
if ((cw.version & 0xFFFF) < Opcodes.V1_5
|
||||
|| (access & ClassWriter.ACC_SYNTHETIC_ATTRIBUTE) != 0) {
|
||||
if ((cw.version & 0xFFFF) < Opcodes.V1_5 || (access & ClassWriter.ACC_SYNTHETIC_ATTRIBUTE) != 0) {
|
||||
cw.newUTF8("Synthetic");
|
||||
size += 6;
|
||||
}
|
||||
@@ -272,12 +242,12 @@ final class FieldWriter extends FieldVisitor {
|
||||
/**
|
||||
* Puts the content of this field into the given byte vector.
|
||||
*
|
||||
* @param out
|
||||
* where the content of this field must be put.
|
||||
* @param out where the content of this field must be put.
|
||||
*/
|
||||
void put(final ByteVector out) {
|
||||
final int FACTOR = ClassWriter.TO_ACC_SYNTHETIC;
|
||||
int mask = Opcodes.ACC_DEPRECATED | ClassWriter.ACC_SYNTHETIC_ATTRIBUTE
|
||||
int mask = Opcodes.ACC_DEPRECATED
|
||||
| ClassWriter.ACC_SYNTHETIC_ATTRIBUTE
|
||||
| ((access & ClassWriter.ACC_SYNTHETIC_ATTRIBUTE) / FACTOR);
|
||||
out.putShort(access & ~mask).putShort(name).putShort(desc);
|
||||
int attributeCount = 0;
|
||||
@@ -285,8 +255,7 @@ final class FieldWriter extends FieldVisitor {
|
||||
++attributeCount;
|
||||
}
|
||||
if ((access & Opcodes.ACC_SYNTHETIC) != 0) {
|
||||
if ((cw.version & 0xFFFF) < Opcodes.V1_5
|
||||
|| (access & ClassWriter.ACC_SYNTHETIC_ATTRIBUTE) != 0) {
|
||||
if ((cw.version & 0xFFFF) < Opcodes.V1_5 || (access & ClassWriter.ACC_SYNTHETIC_ATTRIBUTE) != 0) {
|
||||
++attributeCount;
|
||||
}
|
||||
}
|
||||
@@ -317,8 +286,7 @@ final class FieldWriter extends FieldVisitor {
|
||||
out.putInt(2).putShort(value);
|
||||
}
|
||||
if ((access & Opcodes.ACC_SYNTHETIC) != 0) {
|
||||
if ((cw.version & 0xFFFF) < Opcodes.V1_5
|
||||
|| (access & ClassWriter.ACC_SYNTHETIC_ATTRIBUTE) != 0) {
|
||||
if ((cw.version & 0xFFFF) < Opcodes.V1_5 || (access & ClassWriter.ACC_SYNTHETIC_ATTRIBUTE) != 0) {
|
||||
out.putShort(cw.newUTF8("Synthetic")).putInt(0);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -68,59 +68,36 @@ package org.redkale.asm;
|
||||
public final class Handle {
|
||||
|
||||
/**
|
||||
* The kind of field or method designated by this Handle. Should be
|
||||
* {@link Opcodes#H_GETFIELD}, {@link Opcodes#H_GETSTATIC},
|
||||
* {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC},
|
||||
* {@link Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC},
|
||||
* {@link Opcodes#H_INVOKESPECIAL}, {@link Opcodes#H_NEWINVOKESPECIAL} or
|
||||
* {@link Opcodes#H_INVOKEINTERFACE}.
|
||||
* The kind of field or method designated by this Handle. Should be {@link Opcodes#H_GETFIELD},
|
||||
* {@link Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC},
|
||||
* {@link Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC}, {@link Opcodes#H_INVOKESPECIAL},
|
||||
* {@link Opcodes#H_NEWINVOKESPECIAL} or {@link Opcodes#H_INVOKEINTERFACE}.
|
||||
*/
|
||||
final int tag;
|
||||
|
||||
/**
|
||||
* The internal name of the class that owns the field or method designated
|
||||
* by this handle.
|
||||
*/
|
||||
/** The internal name of the class that owns the field or method designated by this handle. */
|
||||
final String owner;
|
||||
|
||||
/**
|
||||
* The name of the field or method designated by this handle.
|
||||
*/
|
||||
/** The name of the field or method designated by this handle. */
|
||||
final String name;
|
||||
|
||||
/**
|
||||
* The descriptor of the field or method designated by this handle.
|
||||
*/
|
||||
/** The descriptor of the field or method designated by this handle. */
|
||||
final String desc;
|
||||
|
||||
|
||||
/**
|
||||
* Indicate if the owner is an interface or not.
|
||||
*/
|
||||
/** Indicate if the owner is an interface or not. */
|
||||
final boolean itf;
|
||||
|
||||
/**
|
||||
* Constructs a new field or method handle.
|
||||
*
|
||||
* @param tag
|
||||
* the kind of field or method designated by this Handle. Must be
|
||||
* {@link Opcodes#H_GETFIELD}, {@link Opcodes#H_GETSTATIC},
|
||||
* {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC},
|
||||
* {@link Opcodes#H_INVOKEVIRTUAL},
|
||||
* {@link Opcodes#H_INVOKESTATIC},
|
||||
* {@link Opcodes#H_INVOKESPECIAL},
|
||||
* {@link Opcodes#H_NEWINVOKESPECIAL} or
|
||||
* {@link Opcodes#H_INVOKEINTERFACE}.
|
||||
* @param owner
|
||||
* the internal name of the class that owns the field or method
|
||||
* designated by this handle.
|
||||
* @param name
|
||||
* the name of the field or method designated by this handle.
|
||||
* @param desc
|
||||
* the descriptor of the field or method designated by this
|
||||
* handle.
|
||||
* @param itf
|
||||
* true if the owner is an interface.
|
||||
* @param tag the kind of field or method designated by this Handle. Must be {@link Opcodes#H_GETFIELD},
|
||||
* {@link Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC},
|
||||
* {@link Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC}, {@link Opcodes#H_INVOKESPECIAL},
|
||||
* {@link Opcodes#H_NEWINVOKESPECIAL} or {@link Opcodes#H_INVOKEINTERFACE}.
|
||||
* @param owner the internal name of the class that owns the field or method designated by this handle.
|
||||
* @param name the name of the field or method designated by this handle.
|
||||
* @param desc the descriptor of the field or method designated by this handle.
|
||||
* @param itf true if the owner is an interface.
|
||||
*/
|
||||
public Handle(int tag, String owner, String name, String desc, boolean itf) {
|
||||
this.tag = tag;
|
||||
@@ -133,23 +110,18 @@ public final class Handle {
|
||||
/**
|
||||
* Returns the kind of field or method designated by this handle.
|
||||
*
|
||||
* @return {@link Opcodes#H_GETFIELD}, {@link Opcodes#H_GETSTATIC},
|
||||
* {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC},
|
||||
* {@link Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC},
|
||||
* {@link Opcodes#H_INVOKESPECIAL},
|
||||
* {@link Opcodes#H_NEWINVOKESPECIAL} or
|
||||
* {@link Opcodes#H_INVOKEINTERFACE}.
|
||||
* @return {@link Opcodes#H_GETFIELD}, {@link Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD},
|
||||
* {@link Opcodes#H_PUTSTATIC}, {@link Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC},
|
||||
* {@link Opcodes#H_INVOKESPECIAL}, {@link Opcodes#H_NEWINVOKESPECIAL} or {@link Opcodes#H_INVOKEINTERFACE}.
|
||||
*/
|
||||
public int getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the internal name of the class that owns the field or method
|
||||
* designated by this handle.
|
||||
* Returns the internal name of the class that owns the field or method designated by this handle.
|
||||
*
|
||||
* @return the internal name of the class that owns the field or method
|
||||
* designated by this handle.
|
||||
* @return the internal name of the class that owns the field or method designated by this handle.
|
||||
*/
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
@@ -174,11 +146,9 @@ public final class Handle {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the owner of the field or method designated
|
||||
* by this handle is an interface.
|
||||
* Returns true if the owner of the field or method designated by this handle is an interface.
|
||||
*
|
||||
* @return true if the owner of the field or method designated
|
||||
* by this handle is an interface.
|
||||
* @return true if the owner of the field or method designated by this handle is an interface.
|
||||
*/
|
||||
public boolean isInterface() {
|
||||
return itf;
|
||||
@@ -193,18 +163,16 @@ public final class Handle {
|
||||
return false;
|
||||
}
|
||||
Handle h = (Handle) obj;
|
||||
return tag == h.tag && itf == h.itf && owner.equals(h.owner)
|
||||
&& name.equals(h.name) && desc.equals(h.desc);
|
||||
return tag == h.tag && itf == h.itf && owner.equals(h.owner) && name.equals(h.name) && desc.equals(h.desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return tag + (itf? 64: 0) + owner.hashCode() * name.hashCode() * desc.hashCode();
|
||||
return tag + (itf ? 64 : 0) + owner.hashCode() * name.hashCode() * desc.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the textual representation of this handle. The textual
|
||||
* representation is:
|
||||
* Returns the textual representation of this handle. The textual representation is:
|
||||
*
|
||||
* <pre>
|
||||
* for a reference to a class:
|
||||
@@ -217,6 +185,6 @@ public final class Handle {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return owner + '.' + name + desc + " (" + tag + (itf? " itf": "") + ')';
|
||||
return owner + '.' + name + desc + " (" + tag + (itf ? " itf" : "") + ')';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,48 +65,36 @@ package org.redkale.asm;
|
||||
*/
|
||||
class Handler {
|
||||
|
||||
/**
|
||||
* Beginning of the exception handler's scope (inclusive).
|
||||
*/
|
||||
/** Beginning of the exception handler's scope (inclusive). */
|
||||
Label start;
|
||||
|
||||
/**
|
||||
* End of the exception handler's scope (exclusive).
|
||||
*/
|
||||
/** End of the exception handler's scope (exclusive). */
|
||||
Label end;
|
||||
|
||||
/**
|
||||
* Beginning of the exception handler's code.
|
||||
*/
|
||||
/** Beginning of the exception handler's code. */
|
||||
Label handler;
|
||||
|
||||
/**
|
||||
* Internal name of the type of exceptions handled by this handler, or
|
||||
* <tt>null</tt> to catch any exceptions.
|
||||
* Internal name of the type of exceptions handled by this handler, or <tt>null</tt> to catch any
|
||||
* exceptions.
|
||||
*/
|
||||
String desc;
|
||||
|
||||
/**
|
||||
* Constant pool index of the internal name of the type of exceptions
|
||||
* handled by this handler, or 0 to catch any exceptions.
|
||||
* Constant pool index of the internal name of the type of exceptions handled by this handler, or 0 to catch any
|
||||
* exceptions.
|
||||
*/
|
||||
int type;
|
||||
|
||||
/**
|
||||
* Next exception handler block info.
|
||||
*/
|
||||
/** Next exception handler block info. */
|
||||
Handler next;
|
||||
|
||||
/**
|
||||
* Removes the range between start and end from the given exception
|
||||
* handlers.
|
||||
* Removes the range between start and end from the given exception handlers.
|
||||
*
|
||||
* @param h
|
||||
* an exception handler list.
|
||||
* @param start
|
||||
* the start of the range to be removed.
|
||||
* @param end
|
||||
* the end of the range to be removed. Maybe null.
|
||||
* @param h an exception handler list.
|
||||
* @param start the start of the range to be removed.
|
||||
* @param end the end of the range to be removed. Maybe null.
|
||||
* @return the exception handler list with the start-end range removed.
|
||||
*/
|
||||
static Handler remove(Handler h, Label start, Label end) {
|
||||
|
||||
@@ -59,94 +59,61 @@
|
||||
package org.redkale.asm;
|
||||
|
||||
/**
|
||||
* A constant pool item. Constant pool items can be created with the 'newXXX'
|
||||
* methods in the {@link ClassWriter} class.
|
||||
* A constant pool item. Constant pool items can be created with the 'newXXX' methods in the {@link ClassWriter} class.
|
||||
*
|
||||
* @author Eric Bruneton
|
||||
*/
|
||||
final class Item {
|
||||
|
||||
/**
|
||||
* Index of this item in the constant pool.
|
||||
*/
|
||||
/** Index of this item in the constant pool. */
|
||||
int index;
|
||||
|
||||
/**
|
||||
* Type of this constant pool item. A single class is used to represent all
|
||||
* constant pool item types, in order to minimize the bytecode size of this
|
||||
* package. The value of this field is one of {@link ClassWriter#INT},
|
||||
* {@link ClassWriter#LONG}, {@link ClassWriter#FLOAT},
|
||||
* {@link ClassWriter#DOUBLE}, {@link ClassWriter#UTF8},
|
||||
* {@link ClassWriter#STR}, {@link ClassWriter#CLASS},
|
||||
* {@link ClassWriter#NAME_TYPE}, {@link ClassWriter#FIELD},
|
||||
* {@link ClassWriter#METH}, {@link ClassWriter#IMETH},
|
||||
* {@link ClassWriter#MODULE}, {@link ClassWriter#PACKAGE},
|
||||
* Type of this constant pool item. A single class is used to represent all constant pool item types, in order to
|
||||
* minimize the bytecode size of this package. The value of this field is one of {@link ClassWriter#INT},
|
||||
* {@link ClassWriter#LONG}, {@link ClassWriter#FLOAT}, {@link ClassWriter#DOUBLE}, {@link ClassWriter#UTF8},
|
||||
* {@link ClassWriter#STR}, {@link ClassWriter#CLASS}, {@link ClassWriter#NAME_TYPE}, {@link ClassWriter#FIELD},
|
||||
* {@link ClassWriter#METH}, {@link ClassWriter#IMETH}, {@link ClassWriter#MODULE}, {@link ClassWriter#PACKAGE},
|
||||
* {@link ClassWriter#MTYPE}, {@link ClassWriter#INDY}.
|
||||
*
|
||||
* MethodHandle constant 9 variations are stored using a range of 9 values
|
||||
* from {@link ClassWriter#HANDLE_BASE} + 1 to
|
||||
* {@link ClassWriter#HANDLE_BASE} + 9.
|
||||
* <p>MethodHandle constant 9 variations are stored using a range of 9 values from {@link ClassWriter#HANDLE_BASE} +
|
||||
* 1 to {@link ClassWriter#HANDLE_BASE} + 9.
|
||||
*
|
||||
* Special Item types are used for Items that are stored in the ClassWriter
|
||||
* {@link ClassWriter#typeTable}, instead of the constant pool, in order to
|
||||
* avoid clashes with normal constant pool items in the ClassWriter constant
|
||||
* pool's hash table. These special item types are
|
||||
* {@link ClassWriter#TYPE_NORMAL}, {@link ClassWriter#TYPE_UNINIT} and
|
||||
* {@link ClassWriter#TYPE_MERGED}.
|
||||
* <p>Special Item types are used for Items that are stored in the ClassWriter {@link ClassWriter#typeTable},
|
||||
* instead of the constant pool, in order to avoid clashes with normal constant pool items in the ClassWriter
|
||||
* constant pool's hash table. These special item types are {@link ClassWriter#TYPE_NORMAL},
|
||||
* {@link ClassWriter#TYPE_UNINIT} and {@link ClassWriter#TYPE_MERGED}.
|
||||
*/
|
||||
int type;
|
||||
|
||||
/**
|
||||
* Value of this item, for an integer item.
|
||||
*/
|
||||
/** Value of this item, for an integer item. */
|
||||
int intVal;
|
||||
|
||||
/**
|
||||
* Value of this item, for a long item.
|
||||
*/
|
||||
/** Value of this item, for a long item. */
|
||||
long longVal;
|
||||
|
||||
/**
|
||||
* First part of the value of this item, for items that do not hold a
|
||||
* primitive value.
|
||||
*/
|
||||
/** First part of the value of this item, for items that do not hold a primitive value. */
|
||||
String strVal1;
|
||||
|
||||
/**
|
||||
* Second part of the value of this item, for items that do not hold a
|
||||
* primitive value.
|
||||
*/
|
||||
/** Second part of the value of this item, for items that do not hold a primitive value. */
|
||||
String strVal2;
|
||||
|
||||
/**
|
||||
* Third part of the value of this item, for items that do not hold a
|
||||
* primitive value.
|
||||
*/
|
||||
/** Third part of the value of this item, for items that do not hold a primitive value. */
|
||||
String strVal3;
|
||||
|
||||
/**
|
||||
* The hash code value of this constant pool item.
|
||||
*/
|
||||
/** The hash code value of this constant pool item. */
|
||||
int hashCode;
|
||||
|
||||
/**
|
||||
* Link to another constant pool item, used for collision lists in the
|
||||
* constant pool's hash table.
|
||||
*/
|
||||
/** Link to another constant pool item, used for collision lists in the constant pool's hash table. */
|
||||
Item next;
|
||||
|
||||
/**
|
||||
* Constructs an uninitialized {@link Item}.
|
||||
*/
|
||||
Item() {
|
||||
}
|
||||
/** Constructs an uninitialized {@link Item}. */
|
||||
Item() {}
|
||||
|
||||
/**
|
||||
* Constructs an uninitialized {@link Item} for constant pool element at
|
||||
* given position.
|
||||
* Constructs an uninitialized {@link Item} for constant pool element at given position.
|
||||
*
|
||||
* @param index
|
||||
* index of the item to be constructed.
|
||||
* @param index index of the item to be constructed.
|
||||
*/
|
||||
Item(final int index) {
|
||||
this.index = index;
|
||||
@@ -155,10 +122,8 @@ final class Item {
|
||||
/**
|
||||
* Constructs a copy of the given item.
|
||||
*
|
||||
* @param index
|
||||
* index of the item to be constructed.
|
||||
* @param i
|
||||
* the item that must be copied into the item to be constructed.
|
||||
* @param index index of the item to be constructed.
|
||||
* @param i the item that must be copied into the item to be constructed.
|
||||
*/
|
||||
Item(final int index, final Item i) {
|
||||
this.index = index;
|
||||
@@ -174,8 +139,7 @@ final class Item {
|
||||
/**
|
||||
* Sets this item to an integer item.
|
||||
*
|
||||
* @param intVal
|
||||
* the value of this item.
|
||||
* @param intVal the value of this item.
|
||||
*/
|
||||
void set(final int intVal) {
|
||||
this.type = ClassWriter.INT;
|
||||
@@ -186,8 +150,7 @@ final class Item {
|
||||
/**
|
||||
* Sets this item to a long item.
|
||||
*
|
||||
* @param longVal
|
||||
* the value of this item.
|
||||
* @param longVal the value of this item.
|
||||
*/
|
||||
void set(final long longVal) {
|
||||
this.type = ClassWriter.LONG;
|
||||
@@ -198,8 +161,7 @@ final class Item {
|
||||
/**
|
||||
* Sets this item to a float item.
|
||||
*
|
||||
* @param floatVal
|
||||
* the value of this item.
|
||||
* @param floatVal the value of this item.
|
||||
*/
|
||||
void set(final float floatVal) {
|
||||
this.type = ClassWriter.FLOAT;
|
||||
@@ -210,8 +172,7 @@ final class Item {
|
||||
/**
|
||||
* Sets this item to a double item.
|
||||
*
|
||||
* @param doubleVal
|
||||
* the value of this item.
|
||||
* @param doubleVal the value of this item.
|
||||
*/
|
||||
void set(final double doubleVal) {
|
||||
this.type = ClassWriter.DOUBLE;
|
||||
@@ -222,76 +183,62 @@ final class Item {
|
||||
/**
|
||||
* Sets this item to an item that do not hold a primitive value.
|
||||
*
|
||||
* @param type
|
||||
* the type of this item.
|
||||
* @param strVal1
|
||||
* first part of the value of this item.
|
||||
* @param strVal2
|
||||
* second part of the value of this item.
|
||||
* @param strVal3
|
||||
* third part of the value of this item.
|
||||
* @param type the type of this item.
|
||||
* @param strVal1 first part of the value of this item.
|
||||
* @param strVal2 second part of the value of this item.
|
||||
* @param strVal3 third part of the value of this item.
|
||||
*/
|
||||
@SuppressWarnings("fallthrough")
|
||||
void set(final int type, final String strVal1, final String strVal2,
|
||||
final String strVal3) {
|
||||
void set(final int type, final String strVal1, final String strVal2, final String strVal3) {
|
||||
this.type = type;
|
||||
this.strVal1 = strVal1;
|
||||
this.strVal2 = strVal2;
|
||||
this.strVal3 = strVal3;
|
||||
switch (type) {
|
||||
case ClassWriter.CLASS:
|
||||
this.intVal = 0; // intVal of a class must be zero, see visitInnerClass
|
||||
case ClassWriter.UTF8:
|
||||
case ClassWriter.STR:
|
||||
case ClassWriter.MTYPE:
|
||||
case ClassWriter.MODULE:
|
||||
case ClassWriter.PACKAGE:
|
||||
case ClassWriter.TYPE_NORMAL:
|
||||
hashCode = 0x7FFFFFFF & (type + strVal1.hashCode());
|
||||
return;
|
||||
case ClassWriter.NAME_TYPE: {
|
||||
hashCode = 0x7FFFFFFF & (type + strVal1.hashCode()
|
||||
* strVal2.hashCode());
|
||||
return;
|
||||
}
|
||||
// ClassWriter.FIELD:
|
||||
// ClassWriter.METH:
|
||||
// ClassWriter.IMETH:
|
||||
// ClassWriter.HANDLE_BASE + 1..9
|
||||
default:
|
||||
hashCode = 0x7FFFFFFF & (type + strVal1.hashCode()
|
||||
* strVal2.hashCode() * strVal3.hashCode());
|
||||
case ClassWriter.CLASS:
|
||||
this.intVal = 0; // intVal of a class must be zero, see visitInnerClass
|
||||
case ClassWriter.UTF8:
|
||||
case ClassWriter.STR:
|
||||
case ClassWriter.MTYPE:
|
||||
case ClassWriter.MODULE:
|
||||
case ClassWriter.PACKAGE:
|
||||
case ClassWriter.TYPE_NORMAL:
|
||||
hashCode = 0x7FFFFFFF & (type + strVal1.hashCode());
|
||||
return;
|
||||
case ClassWriter.NAME_TYPE: {
|
||||
hashCode = 0x7FFFFFFF & (type + strVal1.hashCode() * strVal2.hashCode());
|
||||
return;
|
||||
}
|
||||
// ClassWriter.FIELD:
|
||||
// ClassWriter.METH:
|
||||
// ClassWriter.IMETH:
|
||||
// ClassWriter.HANDLE_BASE + 1..9
|
||||
default:
|
||||
hashCode = 0x7FFFFFFF & (type + strVal1.hashCode() * strVal2.hashCode() * strVal3.hashCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the item to an InvokeDynamic item.
|
||||
*
|
||||
* @param name
|
||||
* invokedynamic's name.
|
||||
* @param desc
|
||||
* invokedynamic's desc.
|
||||
* @param bsmIndex
|
||||
* zero based index into the class attribute BootrapMethods.
|
||||
* @param name invokedynamic's name.
|
||||
* @param desc invokedynamic's desc.
|
||||
* @param bsmIndex zero based index into the class attribute BootrapMethods.
|
||||
*/
|
||||
void set(String name, String desc, int bsmIndex) {
|
||||
this.type = ClassWriter.INDY;
|
||||
this.longVal = bsmIndex;
|
||||
this.strVal1 = name;
|
||||
this.strVal2 = desc;
|
||||
this.hashCode = 0x7FFFFFFF & (ClassWriter.INDY + bsmIndex
|
||||
* strVal1.hashCode() * strVal2.hashCode());
|
||||
this.hashCode = 0x7FFFFFFF & (ClassWriter.INDY + bsmIndex * strVal1.hashCode() * strVal2.hashCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the item to a BootstrapMethod item.
|
||||
*
|
||||
* @param position
|
||||
* position in byte in the class attribute BootrapMethods.
|
||||
* @param hashCode
|
||||
* hashcode of the item. This hashcode is processed from the
|
||||
* hashcode of the bootstrap method and the hashcode of all
|
||||
* bootstrap arguments.
|
||||
* @param position position in byte in the class attribute BootrapMethods.
|
||||
* @param hashCode hashcode of the item. This hashcode is processed from the hashcode of the bootstrap method and
|
||||
* the hashcode of all bootstrap arguments.
|
||||
*/
|
||||
void set(int position, int hashCode) {
|
||||
this.type = ClassWriter.BSM;
|
||||
@@ -300,48 +247,43 @@ final class Item {
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the given item is equal to this one. <i>This method assumes
|
||||
* that the two items have the same {@link #type}</i>.
|
||||
* Indicates if the given item is equal to this one. <i>This method assumes that the two items have the same
|
||||
* {@link #type}</i>.
|
||||
*
|
||||
* @param i
|
||||
* the item to be compared to this one. Both items must have the
|
||||
* same {@link #type}.
|
||||
* @return <tt>true</tt> if the given item if equal to this one,
|
||||
* <tt>false</tt> otherwise.
|
||||
* @param i the item to be compared to this one. Both items must have the same {@link #type}.
|
||||
* @return <tt>true</tt> if the given item if equal to this one, <tt>false</tt>
|
||||
* otherwise.
|
||||
*/
|
||||
boolean isEqualTo(final Item i) {
|
||||
switch (type) {
|
||||
case ClassWriter.UTF8:
|
||||
case ClassWriter.STR:
|
||||
case ClassWriter.CLASS:
|
||||
case ClassWriter.MODULE:
|
||||
case ClassWriter.PACKAGE:
|
||||
case ClassWriter.MTYPE:
|
||||
case ClassWriter.TYPE_NORMAL:
|
||||
return i.strVal1.equals(strVal1);
|
||||
case ClassWriter.TYPE_MERGED:
|
||||
case ClassWriter.LONG:
|
||||
case ClassWriter.DOUBLE:
|
||||
return i.longVal == longVal;
|
||||
case ClassWriter.INT:
|
||||
case ClassWriter.FLOAT:
|
||||
return i.intVal == intVal;
|
||||
case ClassWriter.TYPE_UNINIT:
|
||||
return i.intVal == intVal && i.strVal1.equals(strVal1);
|
||||
case ClassWriter.NAME_TYPE:
|
||||
return i.strVal1.equals(strVal1) && i.strVal2.equals(strVal2);
|
||||
case ClassWriter.INDY: {
|
||||
return i.longVal == longVal && i.strVal1.equals(strVal1)
|
||||
&& i.strVal2.equals(strVal2);
|
||||
}
|
||||
// case ClassWriter.FIELD:
|
||||
// case ClassWriter.METH:
|
||||
// case ClassWriter.IMETH:
|
||||
// case ClassWriter.HANDLE_BASE + 1..9
|
||||
default:
|
||||
return i.strVal1.equals(strVal1) && i.strVal2.equals(strVal2)
|
||||
&& i.strVal3.equals(strVal3);
|
||||
case ClassWriter.UTF8:
|
||||
case ClassWriter.STR:
|
||||
case ClassWriter.CLASS:
|
||||
case ClassWriter.MODULE:
|
||||
case ClassWriter.PACKAGE:
|
||||
case ClassWriter.MTYPE:
|
||||
case ClassWriter.TYPE_NORMAL:
|
||||
return i.strVal1.equals(strVal1);
|
||||
case ClassWriter.TYPE_MERGED:
|
||||
case ClassWriter.LONG:
|
||||
case ClassWriter.DOUBLE:
|
||||
return i.longVal == longVal;
|
||||
case ClassWriter.INT:
|
||||
case ClassWriter.FLOAT:
|
||||
return i.intVal == intVal;
|
||||
case ClassWriter.TYPE_UNINIT:
|
||||
return i.intVal == intVal && i.strVal1.equals(strVal1);
|
||||
case ClassWriter.NAME_TYPE:
|
||||
return i.strVal1.equals(strVal1) && i.strVal2.equals(strVal2);
|
||||
case ClassWriter.INDY: {
|
||||
return i.longVal == longVal && i.strVal1.equals(strVal1) && i.strVal2.equals(strVal2);
|
||||
}
|
||||
// case ClassWriter.FIELD:
|
||||
// case ClassWriter.METH:
|
||||
// case ClassWriter.IMETH:
|
||||
// case ClassWriter.HANDLE_BASE + 1..9
|
||||
default:
|
||||
return i.strVal1.equals(strVal1) && i.strVal2.equals(strVal2) && i.strVal3.equals(strVal3);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,88 +59,61 @@
|
||||
package org.redkale.asm;
|
||||
|
||||
/**
|
||||
* A label represents a position in the bytecode of a method. Labels are used
|
||||
* for jump, goto, and switch instructions, and for try catch blocks. A label
|
||||
* designates the <i>instruction</i> that is just after. Note however that there
|
||||
* can be other elements between a label and the instruction it designates (such
|
||||
* as other labels, stack map frames, line numbers, etc.).
|
||||
* A label represents a position in the bytecode of a method. Labels are used for jump, goto, and switch instructions,
|
||||
* and for try catch blocks. A label designates the <i>instruction</i> that is just after. Note however that there can
|
||||
* be other elements between a label and the instruction it designates (such as other labels, stack map frames, line
|
||||
* numbers, etc.).
|
||||
*
|
||||
* @author Eric Bruneton
|
||||
*/
|
||||
public class Label {
|
||||
|
||||
/**
|
||||
* Indicates if this label is only used for debug attributes. Such a label
|
||||
* is not the start of a basic block, the target of a jump instruction, or
|
||||
* an exception handler. It can be safely ignored in control flow graph
|
||||
* analysis algorithms (for optimization purposes).
|
||||
* Indicates if this label is only used for debug attributes. Such a label is not the start of a basic block, the
|
||||
* target of a jump instruction, or an exception handler. It can be safely ignored in control flow graph analysis
|
||||
* algorithms (for optimization purposes).
|
||||
*/
|
||||
static final int DEBUG = 1;
|
||||
|
||||
/**
|
||||
* Indicates if the position of this label is known.
|
||||
*/
|
||||
/** Indicates if the position of this label is known. */
|
||||
static final int RESOLVED = 2;
|
||||
|
||||
/**
|
||||
* Indicates if this label has been updated, after instruction resizing.
|
||||
*/
|
||||
/** Indicates if this label has been updated, after instruction resizing. */
|
||||
static final int RESIZED = 4;
|
||||
|
||||
/**
|
||||
* Indicates if this basic block has been pushed in the basic block stack.
|
||||
* See {@link MethodWriter#visitMaxs visitMaxs}.
|
||||
* Indicates if this basic block has been pushed in the basic block stack. See {@link MethodWriter#visitMaxs
|
||||
* visitMaxs}.
|
||||
*/
|
||||
static final int PUSHED = 8;
|
||||
|
||||
/**
|
||||
* Indicates if this label is the target of a jump instruction, or the start
|
||||
* of an exception handler.
|
||||
*/
|
||||
/** Indicates if this label is the target of a jump instruction, or the start of an exception handler. */
|
||||
static final int TARGET = 16;
|
||||
|
||||
/**
|
||||
* Indicates if a stack map frame must be stored for this label.
|
||||
*/
|
||||
/** Indicates if a stack map frame must be stored for this label. */
|
||||
static final int STORE = 32;
|
||||
|
||||
/**
|
||||
* Indicates if this label corresponds to a reachable basic block.
|
||||
*/
|
||||
/** Indicates if this label corresponds to a reachable basic block. */
|
||||
static final int REACHABLE = 64;
|
||||
|
||||
/**
|
||||
* Indicates if this basic block ends with a JSR instruction.
|
||||
*/
|
||||
/** Indicates if this basic block ends with a JSR instruction. */
|
||||
static final int JSR = 128;
|
||||
|
||||
/**
|
||||
* Indicates if this basic block ends with a RET instruction.
|
||||
*/
|
||||
/** Indicates if this basic block ends with a RET instruction. */
|
||||
static final int RET = 256;
|
||||
|
||||
/**
|
||||
* Indicates if this basic block is the start of a subroutine.
|
||||
*/
|
||||
/** Indicates if this basic block is the start of a subroutine. */
|
||||
static final int SUBROUTINE = 512;
|
||||
|
||||
/**
|
||||
* Indicates if this subroutine basic block has been visited by a
|
||||
* visitSubroutine(null, ...) call.
|
||||
*/
|
||||
/** Indicates if this subroutine basic block has been visited by a visitSubroutine(null, ...) call. */
|
||||
static final int VISITED = 1024;
|
||||
|
||||
/**
|
||||
* Indicates if this subroutine basic block has been visited by a
|
||||
* visitSubroutine(!null, ...) call.
|
||||
*/
|
||||
/** Indicates if this subroutine basic block has been visited by a visitSubroutine(!null, ...) call. */
|
||||
static final int VISITED2 = 2048;
|
||||
|
||||
/**
|
||||
* Field used to associate user information to a label. Warning: this field
|
||||
* is used by the ASM tree package. In order to use it with the ASM tree
|
||||
* package you must override the
|
||||
*
|
||||
* Field used to associate user information to a label. Warning: this field is used by the ASM tree package. In
|
||||
* order to use it with the ASM tree package you must override the
|
||||
*/
|
||||
public Object info;
|
||||
|
||||
@@ -160,36 +133,26 @@ public class Label {
|
||||
int status;
|
||||
|
||||
/**
|
||||
* The line number corresponding to this label, if known. If there are
|
||||
* several lines, each line is stored in a separate label, all linked via
|
||||
* their next field (these links are created in ClassReader and removed just
|
||||
* before visitLabel is called, so that this does not impact the rest of the
|
||||
* code).
|
||||
* The line number corresponding to this label, if known. If there are several lines, each line is stored in a
|
||||
* separate label, all linked via their next field (these links are created in ClassReader and removed just before
|
||||
* visitLabel is called, so that this does not impact the rest of the code).
|
||||
*/
|
||||
int line;
|
||||
|
||||
/**
|
||||
* The position of this label in the code, if known.
|
||||
*/
|
||||
/** The position of this label in the code, if known. */
|
||||
int position;
|
||||
|
||||
/**
|
||||
* Number of forward references to this label, times two.
|
||||
*/
|
||||
/** Number of forward references to this label, times two. */
|
||||
private int referenceCount;
|
||||
|
||||
/**
|
||||
* Informations about forward references. Each forward reference is
|
||||
* described by two consecutive integers in this array: the first one is the
|
||||
* position of the first byte of the bytecode instruction that contains the
|
||||
* forward reference, while the second is the position of the first byte of
|
||||
* the forward reference itself. In fact the sign of the first integer
|
||||
* indicates if this reference uses 2 or 4 bytes, and its absolute value
|
||||
* gives the position of the bytecode instruction. This array is also used
|
||||
* as a bitset to store the subroutines to which a basic block belongs. This
|
||||
* information is needed in {@linked MethodWriter#visitMaxs}, after all
|
||||
* forward references have been resolved. Hence the same array can be used
|
||||
* for both purposes without problems.
|
||||
* Informations about forward references. Each forward reference is described by two consecutive integers in this
|
||||
* array: the first one is the position of the first byte of the bytecode instruction that contains the forward
|
||||
* reference, while the second is the position of the first byte of the forward reference itself. In fact the sign
|
||||
* of the first integer indicates if this reference uses 2 or 4 bytes, and its absolute value gives the position of
|
||||
* the bytecode instruction. This array is also used as a bitset to store the subroutines to which a basic block
|
||||
* belongs. This information is needed in {@linked MethodWriter#visitMaxs}, after all forward references have been
|
||||
* resolved. Hence the same array can be used for both purposes without problems.
|
||||
*/
|
||||
private int[] srcAndRefPositions;
|
||||
|
||||
@@ -223,57 +186,48 @@ public class Label {
|
||||
*/
|
||||
|
||||
/**
|
||||
* Start of the output stack relatively to the input stack. The exact
|
||||
* semantics of this field depends on the algorithm that is used.
|
||||
* Start of the output stack relatively to the input stack. The exact semantics of this field depends on the
|
||||
* algorithm that is used.
|
||||
*
|
||||
* When only the maximum stack size is computed, this field is the number of
|
||||
* elements in the input stack.
|
||||
* <p>When only the maximum stack size is computed, this field is the number of elements in the input stack.
|
||||
*
|
||||
* When the stack map frames are completely computed, this field is the
|
||||
* offset of the first output stack element relatively to the top of the
|
||||
* input stack. This offset is always negative or null. A null offset means
|
||||
* that the output stack must be appended to the input stack. A -n offset
|
||||
* means that the first n output stack elements must replace the top n input
|
||||
* stack elements, and that the other elements must be appended to the input
|
||||
* stack.
|
||||
* <p>When the stack map frames are completely computed, this field is the offset of the first output stack element
|
||||
* relatively to the top of the input stack. This offset is always negative or null. A null offset means that the
|
||||
* output stack must be appended to the input stack. A -n offset means that the first n output stack elements must
|
||||
* replace the top n input stack elements, and that the other elements must be appended to the input stack.
|
||||
*/
|
||||
int inputStackTop;
|
||||
|
||||
/**
|
||||
* Maximum height reached by the output stack, relatively to the top of the
|
||||
* input stack. This maximum is always positive or null.
|
||||
* Maximum height reached by the output stack, relatively to the top of the input stack. This maximum is always
|
||||
* positive or null.
|
||||
*/
|
||||
int outputStackMax;
|
||||
|
||||
/**
|
||||
* Information about the input and output stack map frames of this basic
|
||||
* block. This field is only used when {@link ClassWriter#COMPUTE_FRAMES}
|
||||
* option is used.
|
||||
* Information about the input and output stack map frames of this basic block. This field is only used when
|
||||
* {@link ClassWriter#COMPUTE_FRAMES} option is used.
|
||||
*/
|
||||
Frame frame;
|
||||
|
||||
/**
|
||||
* The successor of this label, in the order they are visited. This linked
|
||||
* list does not include labels used for debug info only. If
|
||||
* {@link ClassWriter#COMPUTE_FRAMES} option is used then, in addition, it
|
||||
* does not contain successive labels that denote the same bytecode position
|
||||
* (in this case only the first label appears in this list).
|
||||
* The successor of this label, in the order they are visited. This linked list does not include labels used for
|
||||
* debug info only. If {@link ClassWriter#COMPUTE_FRAMES} option is used then, in addition, it does not contain
|
||||
* successive labels that denote the same bytecode position (in this case only the first label appears in this
|
||||
* list).
|
||||
*/
|
||||
Label successor;
|
||||
|
||||
/**
|
||||
* The successors of this node in the control flow graph. These successors
|
||||
* are stored in a linked list of {@link Edge Edge} objects, linked to each
|
||||
* other by their {@link Edge#next} field.
|
||||
* The successors of this node in the control flow graph. These successors are stored in a linked list of
|
||||
* {@link Edge Edge} objects, linked to each other by their {@link Edge#next} field.
|
||||
*/
|
||||
Edge successors;
|
||||
|
||||
/**
|
||||
* The next basic block in the basic block stack. This stack is used in the
|
||||
* main loop of the fix point algorithm used in the second step of the
|
||||
* control flow analysis algorithms. It is also used in
|
||||
* {@link #visitSubroutine} to avoid using a recursive method, and in
|
||||
* ClassReader to temporarily store multiple source lines for a label.
|
||||
* The next basic block in the basic block stack. This stack is used in the main loop of the fix point algorithm
|
||||
* used in the second step of the control flow analysis algorithms. It is also used in {@link #visitSubroutine} to
|
||||
* avoid using a recursive method, and in ClassReader to temporarily store multiple source lines for a label.
|
||||
*
|
||||
* @see MethodWriter#visitMaxs
|
||||
*/
|
||||
@@ -283,10 +237,9 @@ public class Label {
|
||||
// Constructor
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs a new label.
|
||||
*/
|
||||
/** Constructs a new label. */
|
||||
public Label() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -294,44 +247,33 @@ public class Label {
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the offset corresponding to this label. This offset is computed
|
||||
* from the start of the method's bytecode. <i>This method is intended for
|
||||
* {@link Attribute} sub classes, and is normally not needed by class
|
||||
* generators or adapters.</i>
|
||||
* Returns the offset corresponding to this label. This offset is computed from the start of the method's bytecode.
|
||||
* <i>This method is intended for {@link Attribute} sub classes, and is normally not needed by class generators or
|
||||
* adapters.</i>
|
||||
*
|
||||
* @return the offset corresponding to this label.
|
||||
* @throws IllegalStateException
|
||||
* if this label is not resolved yet.
|
||||
* @throws IllegalStateException if this label is not resolved yet.
|
||||
*/
|
||||
public int getOffset() {
|
||||
if ((status & RESOLVED) == 0) {
|
||||
throw new IllegalStateException(
|
||||
"Label offset position has not been resolved yet");
|
||||
throw new IllegalStateException("Label offset position has not been resolved yet");
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts a reference to this label in the bytecode of a method. If the
|
||||
* position of the label is known, the offset is computed and written
|
||||
* directly. Otherwise, a null offset is written and a new forward reference
|
||||
* is declared for this label.
|
||||
* Puts a reference to this label in the bytecode of a method. If the position of the label is known, the offset is
|
||||
* computed and written directly. Otherwise, a null offset is written and a new forward reference is declared for
|
||||
* this label.
|
||||
*
|
||||
* @param owner
|
||||
* the code writer that calls this method.
|
||||
* @param out
|
||||
* the bytecode of the method.
|
||||
* @param source
|
||||
* the position of first byte of the bytecode instruction that
|
||||
* contains this label.
|
||||
* @param wideOffset
|
||||
* <tt>true</tt> if the reference must be stored in 4 bytes, or
|
||||
* <tt>false</tt> if it must be stored with 2 bytes.
|
||||
* @throws IllegalArgumentException
|
||||
* if this label has not been created by the given code writer.
|
||||
* @param owner the code writer that calls this method.
|
||||
* @param out the bytecode of the method.
|
||||
* @param source the position of first byte of the bytecode instruction that contains this label.
|
||||
* @param wideOffset <tt>true</tt> if the reference must be stored in 4 bytes, or
|
||||
* <tt>false</tt> if it must be stored with 2 bytes.
|
||||
* @throws IllegalArgumentException if this label has not been created by the given code writer.
|
||||
*/
|
||||
void put(final MethodWriter owner, final ByteVector out, final int source,
|
||||
final boolean wideOffset) {
|
||||
void put(final MethodWriter owner, final ByteVector out, final int source, final boolean wideOffset) {
|
||||
if ((status & RESOLVED) == 0) {
|
||||
if (wideOffset) {
|
||||
addReference(-1 - source, out.length);
|
||||
@@ -350,27 +292,21 @@ public class Label {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a forward reference to this label. This method must be called only
|
||||
* for a true forward reference, i.e. only if this label is not resolved
|
||||
* yet. For backward references, the offset of the reference can be, and
|
||||
* must be, computed and stored directly.
|
||||
* Adds a forward reference to this label. This method must be called only for a true forward reference, i.e. only
|
||||
* if this label is not resolved yet. For backward references, the offset of the reference can be, and must be,
|
||||
* computed and stored directly.
|
||||
*
|
||||
* @param sourcePosition
|
||||
* the position of the referencing instruction. This position
|
||||
* will be used to compute the offset of this forward reference.
|
||||
* @param referencePosition
|
||||
* the position where the offset for this forward reference must
|
||||
* be stored.
|
||||
* @param sourcePosition the position of the referencing instruction. This position will be used to compute the
|
||||
* offset of this forward reference.
|
||||
* @param referencePosition the position where the offset for this forward reference must be stored.
|
||||
*/
|
||||
private void addReference(final int sourcePosition,
|
||||
final int referencePosition) {
|
||||
private void addReference(final int sourcePosition, final int referencePosition) {
|
||||
if (srcAndRefPositions == null) {
|
||||
srcAndRefPositions = new int[6];
|
||||
}
|
||||
if (referenceCount >= srcAndRefPositions.length) {
|
||||
int[] a = new int[srcAndRefPositions.length + 6];
|
||||
System.arraycopy(srcAndRefPositions, 0, a, 0,
|
||||
srcAndRefPositions.length);
|
||||
System.arraycopy(srcAndRefPositions, 0, a, 0, srcAndRefPositions.length);
|
||||
srcAndRefPositions = a;
|
||||
}
|
||||
srcAndRefPositions[referenceCount++] = sourcePosition;
|
||||
@@ -378,29 +314,21 @@ public class Label {
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves all forward references to this label. This method must be called
|
||||
* when this label is added to the bytecode of the method, i.e. when its
|
||||
* position becomes known. This method fills in the blanks that where left
|
||||
* in the bytecode by each forward reference previously added to this label.
|
||||
* Resolves all forward references to this label. This method must be called when this label is added to the
|
||||
* bytecode of the method, i.e. when its position becomes known. This method fills in the blanks that where left in
|
||||
* the bytecode by each forward reference previously added to this label.
|
||||
*
|
||||
* @param owner
|
||||
* the code writer that calls this method.
|
||||
* @param position
|
||||
* the position of this label in the bytecode.
|
||||
* @param data
|
||||
* the bytecode of the method.
|
||||
* @return <tt>true</tt> if a blank that was left for this label was too
|
||||
* small to store the offset. In such a case the corresponding jump
|
||||
* instruction is replaced with a pseudo instruction (using unused
|
||||
* opcodes) using an unsigned two bytes offset. These pseudo
|
||||
* instructions will be replaced with standard bytecode instructions
|
||||
* with wider offsets (4 bytes instead of 2), in ClassReader.
|
||||
* @throws IllegalArgumentException
|
||||
* if this label has already been resolved, or if it has not
|
||||
* been created by the given code writer.
|
||||
* @param owner the code writer that calls this method.
|
||||
* @param position the position of this label in the bytecode.
|
||||
* @param data the bytecode of the method.
|
||||
* @return <tt>true</tt> if a blank that was left for this label was too small to store the offset.
|
||||
* In such a case the corresponding jump instruction is replaced with a pseudo instruction (using unused
|
||||
* opcodes) using an unsigned two bytes offset. These pseudo instructions will be replaced with standard
|
||||
* bytecode instructions with wider offsets (4 bytes instead of 2), in ClassReader.
|
||||
* @throws IllegalArgumentException if this label has already been resolved, or if it has not been created by the
|
||||
* given code writer.
|
||||
*/
|
||||
boolean resolve(final MethodWriter owner, final int position,
|
||||
final byte[] data) {
|
||||
boolean resolve(final MethodWriter owner, final int position, final byte[] data) {
|
||||
boolean needUpdate = false;
|
||||
this.status |= RESOLVED;
|
||||
this.position = position;
|
||||
@@ -445,10 +373,9 @@ public class Label {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first label of the series to which this label belongs. For an
|
||||
* isolated label or for the first label in a series of successive labels,
|
||||
* this method returns the label itself. For other labels it returns the
|
||||
* first label of the series.
|
||||
* Returns the first label of the series to which this label belongs. For an isolated label or for the first label
|
||||
* in a series of successive labels, this method returns the label itself. For other labels it returns the first
|
||||
* label of the series.
|
||||
*
|
||||
* @return the first label of the series to which this label belongs.
|
||||
*/
|
||||
@@ -463,8 +390,7 @@ public class Label {
|
||||
/**
|
||||
* Returns true is this basic block belongs to the given subroutine.
|
||||
*
|
||||
* @param id
|
||||
* a subroutine id.
|
||||
* @param id a subroutine id.
|
||||
* @return true is this basic block belongs to the given subroutine.
|
||||
*/
|
||||
boolean inSubroutine(final long id) {
|
||||
@@ -475,13 +401,10 @@ public class Label {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this basic block and the given one belong to a common
|
||||
* subroutine.
|
||||
* Returns true if this basic block and the given one belong to a common subroutine.
|
||||
*
|
||||
* @param block
|
||||
* another basic block.
|
||||
* @return true if this basic block and the given one belong to a common
|
||||
* subroutine.
|
||||
* @param block another basic block.
|
||||
* @return true if this basic block and the given one belong to a common subroutine.
|
||||
*/
|
||||
boolean inSameSubroutine(final Label block) {
|
||||
if ((status & VISITED) == 0 || (block.status & VISITED) == 0) {
|
||||
@@ -498,10 +421,8 @@ public class Label {
|
||||
/**
|
||||
* Marks this basic block as belonging to the given subroutine.
|
||||
*
|
||||
* @param id
|
||||
* a subroutine id.
|
||||
* @param nbSubroutines
|
||||
* the total number of subroutines in the method.
|
||||
* @param id a subroutine id.
|
||||
* @param nbSubroutines the total number of subroutines in the method.
|
||||
*/
|
||||
void addToSubroutine(final long id, final int nbSubroutines) {
|
||||
if ((status & VISITED) == 0) {
|
||||
@@ -512,19 +433,14 @@ public class Label {
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the basic blocks that belong to a given subroutine, and marks these
|
||||
* blocks as belonging to this subroutine. This method follows the control
|
||||
* flow graph to find all the blocks that are reachable from the current
|
||||
* block WITHOUT following any JSR target.
|
||||
* Finds the basic blocks that belong to a given subroutine, and marks these blocks as belonging to this subroutine.
|
||||
* This method follows the control flow graph to find all the blocks that are reachable from the current block
|
||||
* WITHOUT following any JSR target.
|
||||
*
|
||||
* @param JSR
|
||||
* a JSR block that jumps to this subroutine. If this JSR is not
|
||||
* null it is added to the successor of the RET blocks found in
|
||||
* the subroutine.
|
||||
* @param id
|
||||
* the id of this subroutine.
|
||||
* @param nbSubroutines
|
||||
* the total number of subroutines in the method.
|
||||
* @param JSR a JSR block that jumps to this subroutine. If this JSR is not null it is added to the successor of the
|
||||
* RET blocks found in the subroutine.
|
||||
* @param id the id of this subroutine.
|
||||
* @param nbSubroutines the total number of subroutines in the method.
|
||||
*/
|
||||
void visitSubroutine(final Label JSR, final long id, final int nbSubroutines) {
|
||||
// user managed stack of labels, to avoid using a recursive method
|
||||
|
||||
@@ -1,274 +1,264 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.asm;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import static org.redkale.asm.Opcodes.*;
|
||||
|
||||
/**
|
||||
* MethodVisitor 的调试类
|
||||
* <p>
|
||||
* 详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
public class MethodDebugVisitor {
|
||||
|
||||
private final MethodVisitor visitor;
|
||||
|
||||
private boolean debug = false;
|
||||
|
||||
public MethodDebugVisitor setDebug(boolean d) {
|
||||
debug = d;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void debugLine() {
|
||||
if (!debug) return;
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
private final Map<Label, Integer> labels = new LinkedHashMap<>();
|
||||
|
||||
private static final String[] opcodes = new String[200]; //0 -18
|
||||
|
||||
static {
|
||||
try {
|
||||
for (java.lang.reflect.Field field : Opcodes.class.getFields()) {
|
||||
String name = field.getName();
|
||||
if (name.startsWith("ASM")) continue;
|
||||
if (name.startsWith("V1_")) continue;
|
||||
if (name.startsWith("ACC_")) continue;
|
||||
if (name.startsWith("T_")) continue;
|
||||
if (name.startsWith("H_")) continue;
|
||||
if (name.startsWith("F_")) continue;
|
||||
if (field.getType() != int.class) continue;
|
||||
opcodes[(int) (Integer) field.get(null)] = name;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex); //不可能会发生
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param visitor MethodVisitor
|
||||
*/
|
||||
public MethodDebugVisitor(MethodVisitor visitor) {
|
||||
//super(Opcodes.ASM5, visitor);
|
||||
this.visitor = visitor;
|
||||
}
|
||||
|
||||
public void visitTryCatchBlock(Label start, Label end, Label handler, String type) {
|
||||
visitor.visitTryCatchBlock(start, end, handler, type);
|
||||
if (debug) System.out.println("mv.visitTryCatchBlock(label0, label1, label2, \"" + type + "\");");
|
||||
}
|
||||
|
||||
public AnnotationVisitor visitParameterAnnotation(int i, String string, boolean bln) {
|
||||
AnnotationVisitor av = visitor.visitParameterAnnotation(i, string, bln);
|
||||
if (debug) System.out.println("mv.visitParameterAnnotation(" + i + ", \"" + string + "\", " + bln + ");");
|
||||
return av;
|
||||
}
|
||||
|
||||
public AnnotationVisitor visitAnnotation(String desc, boolean flag) {
|
||||
AnnotationVisitor av = visitor.visitAnnotation(desc, flag);
|
||||
if (debug) System.out.println("mv.visitAnnotation(\"" + desc + "\", " + flag + ");");
|
||||
return av;
|
||||
}
|
||||
|
||||
public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) {
|
||||
AnnotationVisitor av = visitor.visitTypeAnnotation(typeRef, typePath, desc, visible);
|
||||
if (debug) System.out.println("mv.visitTypeAnnotation(" + typeRef + ", " + typePath + ", \"" + desc + "\", " + visible + ");");
|
||||
return av;
|
||||
}
|
||||
|
||||
public void visitParameter(String name, int access) {
|
||||
visitor.visitParameter(name, access);
|
||||
if (debug) System.out.println("mv.visitParameter(" + name + ", " + access + ");");
|
||||
}
|
||||
|
||||
public void visitVarInsn(int opcode, int var) {
|
||||
visitor.visitVarInsn(opcode, var);
|
||||
if (debug) System.out.println("mv.visitVarInsn(" + opcodes[opcode] + ", " + var + ");");
|
||||
}
|
||||
|
||||
public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) {
|
||||
visitor.visitFrame(type, nLocal, local, nStack, stack);
|
||||
if (debug) {
|
||||
String typestr = "" + type;
|
||||
if (type == -1) {
|
||||
typestr = "Opcodes.F_NEW";
|
||||
} else if (type == 1) {
|
||||
typestr = "Opcodes.F_APPEND";
|
||||
} else if (type == 2) {
|
||||
typestr = "Opcodes.F_CHOP";
|
||||
} else if (type == 3) {
|
||||
typestr = "Opcodes.F_SAME";
|
||||
} else if (type == 4) {
|
||||
typestr = "Opcodes.F_SAME1";
|
||||
}
|
||||
System.out.println("mv.visitFrame(" + typestr + ", " + nLocal + ", " + Arrays.toString(local) + ", " + nStack + ", " + Arrays.toString(stack) + ");");
|
||||
}
|
||||
}
|
||||
|
||||
public void visitJumpInsn(int opcode, Label var) { //调用此方法的 ClassWriter 必须由 COMPUTE_FRAMES 构建
|
||||
visitor.visitJumpInsn(opcode, var);
|
||||
if (debug) {
|
||||
Integer index = labels.get(var);
|
||||
if (index == null) {
|
||||
index = labels.size();
|
||||
labels.put(var, index);
|
||||
System.out.println("Label l" + index + " = new Label();");
|
||||
}
|
||||
System.out.println("mv.visitJumpInsn(" + opcodes[opcode] + ", l" + index + ");");
|
||||
}
|
||||
}
|
||||
|
||||
public void visitCode() {
|
||||
visitor.visitCode();
|
||||
if (debug) System.out.println("mv.visitCode();");
|
||||
}
|
||||
|
||||
public void visitLabel(Label var) {
|
||||
visitor.visitLabel(var);
|
||||
if (debug) {
|
||||
Integer index = labels.get(var);
|
||||
if (index == null) {
|
||||
index = labels.size();
|
||||
labels.put(var, index);
|
||||
System.out.println("Label l" + index + " = new Label();");
|
||||
}
|
||||
System.out.println("mv.visitLabel(l" + index + ");");
|
||||
}
|
||||
}
|
||||
|
||||
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
|
||||
visitor.visitMethodInsn(opcode, owner, name, desc, itf);
|
||||
if (debug) System.out.println("mv.visitMethodInsn(" + opcodes[opcode] + ", \"" + owner + "\", \"" + name + "\", \"" + desc + "\", " + itf + ");");
|
||||
}
|
||||
|
||||
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
|
||||
visitor.visitFieldInsn(opcode, owner, name, desc);
|
||||
if (debug) System.out.println("mv.visitFieldInsn(" + opcodes[opcode] + ", \"" + owner + "\", \"" + name + "\", \"" + desc + "\");");
|
||||
}
|
||||
|
||||
public void visitTypeInsn(int opcode, String type) {
|
||||
visitor.visitTypeInsn(opcode, type);
|
||||
if (debug) System.out.println("mv.visitTypeInsn(" + opcodes[opcode] + ", \"" + type + "\");");
|
||||
}
|
||||
|
||||
public void visitInsn(int opcode) {
|
||||
visitor.visitInsn(opcode);
|
||||
if (debug) System.out.println("mv.visitInsn(" + opcodes[opcode] + ");");
|
||||
}
|
||||
|
||||
public void visitIntInsn(int opcode, int value) {
|
||||
visitor.visitIntInsn(opcode, value);
|
||||
if (debug) System.out.println("mv.visitIntInsn(" + opcodes[opcode] + ", " + value + ");");
|
||||
}
|
||||
|
||||
public void visitIincInsn(int opcode, int value) {
|
||||
visitor.visitIincInsn(opcode, value);
|
||||
if (debug) System.out.println("mv.visitIincInsn(" + opcode + ", " + value + ");");
|
||||
}
|
||||
|
||||
public void visitLdcInsn(Object o) {
|
||||
visitor.visitLdcInsn(o);
|
||||
if (debug) {
|
||||
if (o instanceof CharSequence) {
|
||||
System.out.println("mv.visitLdcInsn(\"" + o + "\");");
|
||||
} else if (o instanceof org.redkale.asm.Type) {
|
||||
System.out.println("mv.visitLdcInsn(Type.getType(\"" + o + "\"));");
|
||||
} else {
|
||||
System.out.println("mv.visitLdcInsn(" + o + ");");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void visitMaxs(int maxStack, int maxLocals) {
|
||||
visitor.visitMaxs(maxStack, maxLocals);
|
||||
if (debug) System.out.println("mv.visitMaxs(" + maxStack + ", " + maxLocals + ");");
|
||||
}
|
||||
|
||||
public void visitEnd() {
|
||||
visitor.visitEnd();
|
||||
if (debug) System.out.println("mv.visitEnd();\r\n\r\n\r\n");
|
||||
}
|
||||
|
||||
public static void pushInt(MethodDebugVisitor mv, int num) {
|
||||
if (num < 6) {
|
||||
mv.visitInsn(ICONST_0 + num);
|
||||
} else if (num <= Byte.MAX_VALUE) {
|
||||
mv.visitIntInsn(BIPUSH, num);
|
||||
} else if (num <= Short.MAX_VALUE) {
|
||||
mv.visitIntInsn(SIPUSH, num);
|
||||
} else {
|
||||
mv.visitLdcInsn(num);
|
||||
}
|
||||
}
|
||||
|
||||
public static void pushInt(MethodVisitor mv, int num) {
|
||||
if (num < 6) {
|
||||
mv.visitInsn(ICONST_0 + num);
|
||||
} else if (num <= Byte.MAX_VALUE) {
|
||||
mv.visitIntInsn(BIPUSH, num);
|
||||
} else if (num <= Short.MAX_VALUE) {
|
||||
mv.visitIntInsn(SIPUSH, num);
|
||||
} else {
|
||||
mv.visitLdcInsn(num);
|
||||
}
|
||||
}
|
||||
|
||||
public static void visitAnnotation(final AnnotationVisitor av, final Annotation ann) {
|
||||
try {
|
||||
for (Method anm : ann.annotationType().getMethods()) {
|
||||
final String mname = anm.getName();
|
||||
if ("equals".equals(mname) || "hashCode".equals(mname) || "toString".equals(mname) || "annotationType".equals(mname)) continue;
|
||||
final Object r = anm.invoke(ann);
|
||||
if (r instanceof String[]) {
|
||||
AnnotationVisitor av1 = av.visitArray(mname);
|
||||
for (String item : (String[]) r) {
|
||||
av1.visit(null, item);
|
||||
}
|
||||
av1.visitEnd();
|
||||
} else if (r instanceof Class[]) {
|
||||
AnnotationVisitor av1 = av.visitArray(mname);
|
||||
for (Class item : (Class[]) r) {
|
||||
av1.visit(null, Type.getType(item));
|
||||
}
|
||||
av1.visitEnd();
|
||||
} else if (r instanceof Enum[]) {
|
||||
AnnotationVisitor av1 = av.visitArray(mname);
|
||||
for (Enum item : (Enum[]) r) {
|
||||
av1.visitEnum(null, Type.getDescriptor(item.getClass()), ((Enum) item).name());
|
||||
}
|
||||
av1.visitEnd();
|
||||
} else if (r instanceof Annotation[]) {
|
||||
AnnotationVisitor av1 = av.visitArray(mname);
|
||||
for (Annotation item : (Annotation[]) r) {
|
||||
visitAnnotation(av1.visitAnnotation(null, Type.getDescriptor(((Annotation) item).annotationType())), item);
|
||||
}
|
||||
av1.visitEnd();
|
||||
} else if (r instanceof Class) {
|
||||
av.visit(mname, Type.getType((Class) r));
|
||||
} else if (r instanceof Enum) {
|
||||
av.visitEnum(mname, Type.getDescriptor(r.getClass()), ((Enum) r).name());
|
||||
} else if (r instanceof Annotation) {
|
||||
visitAnnotation(av.visitAnnotation(null, Type.getDescriptor(((Annotation) r).annotationType())), (Annotation) r);
|
||||
} else {
|
||||
av.visit(mname, r);
|
||||
}
|
||||
}
|
||||
av.visitEnd();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkale.asm;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* MethodVisitor 的调试类
|
||||
*
|
||||
* <p>详情见: https://redkale.org
|
||||
*
|
||||
* @author zhangjx
|
||||
*/
|
||||
public class MethodDebugVisitor extends MethodVisitor {
|
||||
|
||||
private final MethodVisitor visitor;
|
||||
|
||||
private boolean debug = false;
|
||||
|
||||
public MethodDebugVisitor setDebug(boolean d) {
|
||||
debug = d;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void debugLine() {
|
||||
if (!debug) {
|
||||
return;
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
private final Map<Label, Integer> labels = new LinkedHashMap<>();
|
||||
|
||||
private static final String[] opcodes = new String[200]; // 0 -18
|
||||
|
||||
static {
|
||||
try {
|
||||
for (java.lang.reflect.Field field : Opcodes.class.getFields()) {
|
||||
String name = field.getName();
|
||||
if (name.startsWith("ASM")) {
|
||||
continue;
|
||||
}
|
||||
if (name.startsWith("V1_")) {
|
||||
continue;
|
||||
}
|
||||
if (name.startsWith("ACC_")) {
|
||||
continue;
|
||||
}
|
||||
if (name.startsWith("T_")) {
|
||||
continue;
|
||||
}
|
||||
if (name.startsWith("H_")) {
|
||||
continue;
|
||||
}
|
||||
if (name.startsWith("F_")) {
|
||||
continue;
|
||||
}
|
||||
if (field.getType() != int.class) {
|
||||
continue;
|
||||
}
|
||||
opcodes[(int) (Integer) field.get(null)] = name;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex); // 不可能会发生
|
||||
}
|
||||
}
|
||||
|
||||
/** @param visitor MethodVisitor */
|
||||
public MethodDebugVisitor(MethodVisitor visitor) {
|
||||
super(Opcodes.ASM6, visitor);
|
||||
this.visitor = visitor;
|
||||
}
|
||||
|
||||
public void visitTryCatchBlock(Label start, Label end, Label handler, String type) {
|
||||
visitor.visitTryCatchBlock(start, end, handler, type);
|
||||
if (debug) {
|
||||
System.out.println("mv.visitTryCatchBlock(label0, label1, label2, \"" + type + "\");");
|
||||
}
|
||||
}
|
||||
|
||||
public AnnotationVisitor visitParameterAnnotation(int i, String string, boolean bln) {
|
||||
AnnotationVisitor av = visitor.visitParameterAnnotation(i, string, bln);
|
||||
if (debug) {
|
||||
System.out.println("mv.visitParameterAnnotation(" + i + ", \"" + string + "\", " + bln + ");");
|
||||
}
|
||||
return av;
|
||||
}
|
||||
|
||||
public AnnotationVisitor visitAnnotation(String desc, boolean flag) {
|
||||
AnnotationVisitor av = visitor.visitAnnotation(desc, flag);
|
||||
if (debug) {
|
||||
System.out.println("mv.visitAnnotation(\"" + desc + "\", " + flag + ");");
|
||||
}
|
||||
return av;
|
||||
}
|
||||
|
||||
public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) {
|
||||
AnnotationVisitor av = visitor.visitTypeAnnotation(typeRef, typePath, desc, visible);
|
||||
if (debug) {
|
||||
System.out.println(
|
||||
"mv.visitTypeAnnotation(" + typeRef + ", " + typePath + ", \"" + desc + "\", " + visible + ");");
|
||||
}
|
||||
return av;
|
||||
}
|
||||
|
||||
public void visitParameter(String name, int access) {
|
||||
visitor.visitParameter(name, access);
|
||||
if (debug) {
|
||||
System.out.println("mv.visitParameter(" + name + ", " + access + ");");
|
||||
}
|
||||
}
|
||||
|
||||
public void visitVarInsn(int opcode, int var) {
|
||||
visitor.visitVarInsn(opcode, var);
|
||||
if (debug) {
|
||||
System.out.println("mv.visitVarInsn(" + opcodes[opcode] + ", " + var + ");");
|
||||
}
|
||||
}
|
||||
|
||||
public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) {
|
||||
visitor.visitFrame(type, nLocal, local, nStack, stack);
|
||||
if (debug) {
|
||||
String typestr = "" + type;
|
||||
if (type == -1) {
|
||||
typestr = "Opcodes.F_NEW";
|
||||
} else if (type == 1) {
|
||||
typestr = "Opcodes.F_APPEND";
|
||||
} else if (type == 2) {
|
||||
typestr = "Opcodes.F_CHOP";
|
||||
} else if (type == 3) {
|
||||
typestr = "Opcodes.F_SAME";
|
||||
} else if (type == 4) {
|
||||
typestr = "Opcodes.F_SAME1";
|
||||
}
|
||||
System.out.println("mv.visitFrame(" + typestr + ", " + nLocal + ", " + Arrays.toString(local) + ", "
|
||||
+ nStack + ", " + Arrays.toString(stack) + ");");
|
||||
}
|
||||
}
|
||||
|
||||
public void visitJumpInsn(int opcode, Label var) { // 调用此方法的 ClassWriter 必须由 COMPUTE_FRAMES 构建
|
||||
visitor.visitJumpInsn(opcode, var);
|
||||
if (debug) {
|
||||
Integer index = labels.get(var);
|
||||
if (index == null) {
|
||||
index = labels.size();
|
||||
labels.put(var, index);
|
||||
System.out.println("Label l" + index + " = new Label();");
|
||||
}
|
||||
System.out.println("mv.visitJumpInsn(" + opcodes[opcode] + ", l" + index + ");");
|
||||
}
|
||||
}
|
||||
|
||||
public void visitCode() {
|
||||
visitor.visitCode();
|
||||
if (debug) {
|
||||
System.out.println("mv.visitCode();");
|
||||
}
|
||||
}
|
||||
|
||||
public void visitLabel(Label var) {
|
||||
visitor.visitLabel(var);
|
||||
if (debug) {
|
||||
Integer index = labels.get(var);
|
||||
if (index == null) {
|
||||
index = labels.size();
|
||||
labels.put(var, index);
|
||||
System.out.println("Label label" + index + " = new Label();");
|
||||
}
|
||||
System.out.println("mv.visitLabel(label" + index + ");");
|
||||
}
|
||||
}
|
||||
|
||||
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
|
||||
visitor.visitMethodInsn(opcode, owner, name, desc, itf);
|
||||
if (debug) {
|
||||
System.out.println("mv.visitMethodInsn(" + opcodes[opcode] + ", \"" + owner + "\", \"" + name + "\", \""
|
||||
+ desc + "\", " + itf + ");");
|
||||
}
|
||||
}
|
||||
|
||||
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) {
|
||||
visitor.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
|
||||
if (debug) {
|
||||
System.out.println("mv.visitInvokeDynamicInsn(\"" + name + "\", \"" + desc + "\", null, null);");
|
||||
}
|
||||
}
|
||||
|
||||
public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
|
||||
visitor.visitLocalVariable(name, desc, signature, start, end, index);
|
||||
if (debug) {
|
||||
String s = signature == null ? null : ("\"" + signature + "\"");
|
||||
System.out.println(
|
||||
"mv.visitLocalVariable(\"" + name + "\", \"" + desc + "\", " + s + ", null, null, " + index + ");");
|
||||
}
|
||||
}
|
||||
|
||||
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
|
||||
visitor.visitFieldInsn(opcode, owner, name, desc);
|
||||
if (debug) {
|
||||
System.out.println("mv.visitFieldInsn(" + opcodes[opcode] + ", \"" + owner + "\", \"" + name + "\", \""
|
||||
+ desc + "\");");
|
||||
}
|
||||
}
|
||||
|
||||
public void visitTypeInsn(int opcode, String type) {
|
||||
visitor.visitTypeInsn(opcode, type);
|
||||
if (debug) {
|
||||
System.out.println("mv.visitTypeInsn(" + opcodes[opcode] + ", \"" + type + "\");");
|
||||
}
|
||||
}
|
||||
|
||||
public void visitInsn(int opcode) {
|
||||
visitor.visitInsn(opcode);
|
||||
if (debug) {
|
||||
System.out.println("mv.visitInsn(" + opcodes[opcode] + ");");
|
||||
}
|
||||
}
|
||||
|
||||
public void visitIntInsn(int opcode, int value) {
|
||||
visitor.visitIntInsn(opcode, value);
|
||||
if (debug) {
|
||||
System.out.println("mv.visitIntInsn(" + opcodes[opcode] + ", " + value + ");");
|
||||
}
|
||||
}
|
||||
|
||||
public void visitIincInsn(int opcode, int value) {
|
||||
visitor.visitIincInsn(opcode, value);
|
||||
if (debug) {
|
||||
System.out.println("mv.visitIincInsn(" + opcode + ", " + value + ");");
|
||||
}
|
||||
}
|
||||
|
||||
public void visitLdcInsn(Object o) {
|
||||
visitor.visitLdcInsn(o);
|
||||
if (debug) {
|
||||
if (o instanceof CharSequence) {
|
||||
System.out.println("mv.visitLdcInsn(\"" + o + "\");");
|
||||
} else if (o instanceof org.redkale.asm.Type) {
|
||||
System.out.println("mv.visitLdcInsn(Type.getType(\"" + o + "\"));");
|
||||
} else {
|
||||
System.out.println("mv.visitLdcInsn(" + o + ");");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void visitMaxs(int maxStack, int maxLocals) {
|
||||
visitor.visitMaxs(maxStack, maxLocals);
|
||||
if (debug) {
|
||||
System.out.println("mv.visitMaxs(" + maxStack + ", " + maxLocals + ");");
|
||||
}
|
||||
}
|
||||
|
||||
public void visitEnd() {
|
||||
visitor.visitEnd();
|
||||
if (debug) {
|
||||
System.out.println("mv.visitEnd();\r\n\r\n\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,49 +59,42 @@
|
||||
package org.redkale.asm;
|
||||
|
||||
/**
|
||||
* A visitor to visit a Java method. The methods of this class must be called in
|
||||
* the following order: ( <tt>visitParameter</tt> )* [
|
||||
* <tt>visitAnnotationDefault</tt> ] ( <tt>visitAnnotation</tt> |
|
||||
* <tt>visitParameterAnnotation</tt> <tt>visitTypeAnnotation</tt> |
|
||||
* <tt>visitAttribute</tt> )* [ <tt>visitCode</tt> ( <tt>visitFrame</tt> |
|
||||
* <tt>visit<i>X</i>Insn</tt> | <tt>visitLabel</tt> |
|
||||
* <tt>visitInsnAnnotation</tt> | <tt>visitTryCatchBlock</tt> |
|
||||
* <tt>visitTryCatchAnnotation</tt> | <tt>visitLocalVariable</tt> |
|
||||
* <tt>visitLocalVariableAnnotation</tt> | <tt>visitLineNumber</tt> )*
|
||||
* <tt>visitMaxs</tt> ] <tt>visitEnd</tt>. In addition, the
|
||||
* <tt>visit<i>X</i>Insn</tt> and <tt>visitLabel</tt> methods must be called in
|
||||
* the sequential order of the bytecode instructions of the visited code,
|
||||
* <tt>visitInsnAnnotation</tt> must be called <i>after</i> the annotated
|
||||
* instruction, <tt>visitTryCatchBlock</tt> must be called <i>before</i> the
|
||||
* labels passed as arguments have been visited,
|
||||
* <tt>visitTryCatchBlockAnnotation</tt> must be called <i>after</i> the
|
||||
* corresponding try catch block has been visited, and the
|
||||
* <tt>visitLocalVariable</tt>, <tt>visitLocalVariableAnnotation</tt> and
|
||||
* <tt>visitLineNumber</tt> methods must be called <i>after</i> the labels
|
||||
* passed as arguments have been visited.
|
||||
* A visitor to visit a Java method. The methods of this class must be called in the following order: (
|
||||
* <tt>visitParameter</tt> )* [ <tt>visitAnnotationDefault</tt> ] (
|
||||
* <tt>visitAnnotation</tt> | <tt>visitParameterAnnotation</tt>
|
||||
* <tt>visitTypeAnnotation</tt> | <tt>visitAttribute</tt> )* [
|
||||
* <tt>visitCode</tt> ( <tt>visitFrame</tt> | <tt>visit<i>X</i>Insn</tt>
|
||||
* | <tt>visitLabel</tt> | <tt>visitInsnAnnotation</tt> |
|
||||
* <tt>visitTryCatchBlock</tt> | <tt>visitTryCatchAnnotation</tt> |
|
||||
* <tt>visitLocalVariable</tt> | <tt>visitLocalVariableAnnotation</tt> |
|
||||
* <tt>visitLineNumber</tt> )* <tt>visitMaxs</tt> ] <tt>visitEnd</tt>.
|
||||
* In addition, the <tt>visit<i>X</i>Insn</tt> and <tt>visitLabel</tt> methods must be
|
||||
* called in the sequential order of the bytecode instructions of the visited code,
|
||||
* <tt>visitInsnAnnotation</tt> must be called <i>after</i> the annotated instruction,
|
||||
* <tt>visitTryCatchBlock</tt> must be called <i>before</i> the labels passed as arguments have been
|
||||
* visited, <tt>visitTryCatchBlockAnnotation</tt> must be called <i>after</i> the corresponding try
|
||||
* catch block has been visited, and the <tt>visitLocalVariable</tt>,
|
||||
* <tt>visitLocalVariableAnnotation</tt> and <tt>visitLineNumber</tt> methods must be
|
||||
* called <i>after</i> the labels passed as arguments have been visited.
|
||||
*
|
||||
* @author Eric Bruneton
|
||||
*/
|
||||
public abstract class MethodVisitor {
|
||||
|
||||
/**
|
||||
* The ASM API version implemented by this visitor. The value of this field
|
||||
* must be one of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of {@link Opcodes#ASM4},
|
||||
* {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
*/
|
||||
protected final int api;
|
||||
|
||||
/**
|
||||
* The method visitor to which this visitor must delegate method calls. May
|
||||
* be null.
|
||||
*/
|
||||
/** The method visitor to which this visitor must delegate method calls. May be null. */
|
||||
protected MethodVisitor mv;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link MethodVisitor}.
|
||||
*
|
||||
* @param api
|
||||
* the ASM API version implemented by this visitor. Must be one
|
||||
* of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link Opcodes#ASM4},
|
||||
* {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
*/
|
||||
public MethodVisitor(final int api) {
|
||||
this(api, null);
|
||||
@@ -110,12 +103,9 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Constructs a new {@link MethodVisitor}.
|
||||
*
|
||||
* @param api
|
||||
* the ASM API version implemented by this visitor. Must be one
|
||||
* of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
* @param mv
|
||||
* the method visitor to which this visitor must delegate method
|
||||
* calls. May be null.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link Opcodes#ASM4},
|
||||
* {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
|
||||
* @param mv the method visitor to which this visitor must delegate method calls. May be null.
|
||||
*/
|
||||
public MethodVisitor(final int api, final MethodVisitor mv) {
|
||||
this.api = api;
|
||||
@@ -129,12 +119,10 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Visits a parameter of this method.
|
||||
*
|
||||
* @param name
|
||||
* parameter name or null if none is provided.
|
||||
* @param access
|
||||
* the parameter's access flags, only <tt>ACC_FINAL</tt>,
|
||||
* <tt>ACC_SYNTHETIC</tt> or/and <tt>ACC_MANDATED</tt> are
|
||||
* allowed (see {@link Opcodes}).
|
||||
* @param name parameter name or null if none is provided.
|
||||
* @param access the parameter's access flags, only <tt>ACC_FINAL</tt>,
|
||||
* <tt>ACC_SYNTHETIC</tt> or/and <tt>ACC_MANDATED</tt> are allowed (see
|
||||
* {@link Opcodes}).
|
||||
*/
|
||||
public void visitParameter(String name, int access) {
|
||||
if (mv != null) {
|
||||
@@ -145,12 +133,10 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Visits the default value of this annotation interface method.
|
||||
*
|
||||
* @return a visitor to the visit the actual default value of this
|
||||
* annotation interface method, or <tt>null</tt> if this visitor is
|
||||
* not interested in visiting this default value. The 'name'
|
||||
* parameters passed to the methods of this annotation visitor are
|
||||
* ignored. Moreover, exacly one visit method must be called on this
|
||||
* annotation visitor, followed by visitEnd.
|
||||
* @return a visitor to the visit the actual default value of this annotation interface method, or
|
||||
* <tt>null</tt> if this visitor is not interested in visiting this default value. The 'name'
|
||||
* parameters passed to the methods of this annotation visitor are ignored. Moreover, exacly one visit method
|
||||
* must be called on this annotation visitor, followed by visitEnd.
|
||||
*/
|
||||
public AnnotationVisitor visitAnnotationDefault() {
|
||||
if (mv != null) {
|
||||
@@ -162,12 +148,10 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Visits an annotation of this method.
|
||||
*
|
||||
* @param desc
|
||||
* the class descriptor of the annotation class.
|
||||
* @param visible
|
||||
* <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if
|
||||
* this visitor is not interested in visiting this annotation.
|
||||
* @param desc the class descriptor of the annotation class.
|
||||
* @param visible <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if this visitor is not
|
||||
* interested in visiting this annotation.
|
||||
*/
|
||||
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
|
||||
if (mv != null) {
|
||||
@@ -179,30 +163,20 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Visits an annotation on a type in the method signature.
|
||||
*
|
||||
* @param typeRef
|
||||
* a reference to the annotated type. The sort of this type
|
||||
* reference must be {@link TypeReference#METHOD_TYPE_PARAMETER
|
||||
* METHOD_TYPE_PARAMETER},
|
||||
* {@link TypeReference#METHOD_TYPE_PARAMETER_BOUND
|
||||
* METHOD_TYPE_PARAMETER_BOUND},
|
||||
* {@link TypeReference#METHOD_RETURN METHOD_RETURN},
|
||||
* {@link TypeReference#METHOD_RECEIVER METHOD_RECEIVER},
|
||||
* {@link TypeReference#METHOD_FORMAL_PARAMETER
|
||||
* METHOD_FORMAL_PARAMETER} or {@link TypeReference#THROWS
|
||||
* THROWS}. See {@link TypeReference}.
|
||||
* @param typePath
|
||||
* the path to the annotated type argument, wildcard bound, array
|
||||
* element type, or static inner type within 'typeRef'. May be
|
||||
* <tt>null</tt> if the annotation targets 'typeRef' as a whole.
|
||||
* @param desc
|
||||
* the class descriptor of the annotation class.
|
||||
* @param visible
|
||||
* <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if
|
||||
* this visitor is not interested in visiting this annotation.
|
||||
* @param typeRef a reference to the annotated type. The sort of this type reference must be
|
||||
* {@link TypeReference#METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER},
|
||||
* {@link TypeReference#METHOD_TYPE_PARAMETER_BOUND METHOD_TYPE_PARAMETER_BOUND},
|
||||
* {@link TypeReference#METHOD_RETURN METHOD_RETURN}, {@link TypeReference#METHOD_RECEIVER METHOD_RECEIVER},
|
||||
* {@link TypeReference#METHOD_FORMAL_PARAMETER METHOD_FORMAL_PARAMETER} or {@link TypeReference#THROWS THROWS}.
|
||||
* See {@link TypeReference}.
|
||||
* @param typePath the path to the annotated type argument, wildcard bound, array element type, or static inner type
|
||||
* within 'typeRef'. May be <tt>null</tt> if the annotation targets 'typeRef' as a whole.
|
||||
* @param desc the class descriptor of the annotation class.
|
||||
* @param visible <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if this visitor is not
|
||||
* interested in visiting this annotation.
|
||||
*/
|
||||
public AnnotationVisitor visitTypeAnnotation(int typeRef,
|
||||
TypePath typePath, String desc, boolean visible) {
|
||||
public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) {
|
||||
if (mv != null) {
|
||||
return mv.visitTypeAnnotation(typeRef, typePath, desc, visible);
|
||||
}
|
||||
@@ -212,17 +186,13 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Visits an annotation of a parameter this method.
|
||||
*
|
||||
* @param parameter
|
||||
* the parameter index.
|
||||
* @param desc
|
||||
* the class descriptor of the annotation class.
|
||||
* @param visible
|
||||
* <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if
|
||||
* this visitor is not interested in visiting this annotation.
|
||||
* @param parameter the parameter index.
|
||||
* @param desc the class descriptor of the annotation class.
|
||||
* @param visible <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if this visitor is not
|
||||
* interested in visiting this annotation.
|
||||
*/
|
||||
public AnnotationVisitor visitParameterAnnotation(int parameter,
|
||||
String desc, boolean visible) {
|
||||
public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) {
|
||||
if (mv != null) {
|
||||
return mv.visitParameterAnnotation(parameter, desc, visible);
|
||||
}
|
||||
@@ -232,8 +202,7 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Visits a non standard attribute of this method.
|
||||
*
|
||||
* @param attr
|
||||
* an attribute.
|
||||
* @param attr an attribute.
|
||||
*/
|
||||
public void visitAttribute(Attribute attr) {
|
||||
if (mv != null) {
|
||||
@@ -241,9 +210,7 @@ public abstract class MethodVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the visit of the method's code, if any (i.e. non abstract method).
|
||||
*/
|
||||
/** Starts the visit of the method's code, if any (i.e. non abstract method). */
|
||||
public void visitCode() {
|
||||
if (mv != null) {
|
||||
mv.visitCode();
|
||||
@@ -251,82 +218,57 @@ public abstract class MethodVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits the current state of the local variables and operand stack
|
||||
* elements. This method must(*) be called <i>just before</i> any
|
||||
* instruction <b>i</b> that follows an unconditional branch instruction
|
||||
* such as GOTO or THROW, that is the target of a jump instruction, or that
|
||||
* starts an exception handler block. The visited types must describe the
|
||||
* values of the local variables and of the operand stack elements <i>just
|
||||
* before</i> <b>i</b> is executed.<br>
|
||||
* Visits the current state of the local variables and operand stack elements. This method must(*) be called <i>just
|
||||
* before</i> any instruction <b>i</b> that follows an unconditional branch instruction such as GOTO or THROW, that
|
||||
* is the target of a jump instruction, or that starts an exception handler block. The visited types must describe
|
||||
* the values of the local variables and of the operand stack elements <i>just before</i> <b>i</b> is executed.<br>
|
||||
* <br>
|
||||
* (*) this is mandatory only for classes whose version is greater than or
|
||||
* equal to {@link Opcodes#V1_6 V1_6}. <br>
|
||||
* (*) this is mandatory only for classes whose version is greater than or equal to {@link Opcodes#V1_6 V1_6}. <br>
|
||||
* <br>
|
||||
* The frames of a method must be given either in expanded form, or in
|
||||
* compressed form (all frames must use the same format, i.e. you must not
|
||||
* mix expanded and compressed frames within a single method):
|
||||
* <ul>
|
||||
* <li>In expanded form, all frames must have the F_NEW type.</li>
|
||||
* <li>In compressed form, frames are basically "deltas" from the state of
|
||||
* the previous frame:
|
||||
* <ul>
|
||||
* <li>{@link Opcodes#F_SAME} representing frame with exactly the same
|
||||
* locals as the previous frame and with the empty stack.</li>
|
||||
* <li>{@link Opcodes#F_SAME1} representing frame with exactly the same
|
||||
* locals as the previous frame and with single value on the stack (
|
||||
* <code>nStack</code> is 1 and <code>stack[0]</code> contains value for the
|
||||
* type of the stack item).</li>
|
||||
* <li>{@link Opcodes#F_APPEND} representing frame with current locals are
|
||||
* the same as the locals in the previous frame, except that additional
|
||||
* locals are defined (<code>nLocal</code> is 1, 2 or 3 and
|
||||
* <code>local</code> elements contains values representing added types).</li>
|
||||
* <li>{@link Opcodes#F_CHOP} representing frame with current locals are the
|
||||
* same as the locals in the previous frame, except that the last 1-3 locals
|
||||
* are absent and with the empty stack (<code>nLocals</code> is 1, 2 or 3).</li>
|
||||
* <li>{@link Opcodes#F_FULL} representing complete frame data.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* </ul>
|
||||
* <br>
|
||||
* In both cases the first frame, corresponding to the method's parameters
|
||||
* and access flags, is implicit and must not be visited. Also, it is
|
||||
* illegal to visit two or more frames for the same code location (i.e., at
|
||||
* least one instruction must be visited between two calls to visitFrame).
|
||||
* The frames of a method must be given either in expanded form, or in compressed form (all frames must use the same
|
||||
* format, i.e. you must not mix expanded and compressed frames within a single method):
|
||||
*
|
||||
* @param type
|
||||
* the type of this stack map frame. Must be
|
||||
* {@link Opcodes#F_NEW} for expanded frames, or
|
||||
* {@link Opcodes#F_FULL}, {@link Opcodes#F_APPEND},
|
||||
* {@link Opcodes#F_CHOP}, {@link Opcodes#F_SAME} or
|
||||
* {@link Opcodes#F_APPEND}, {@link Opcodes#F_SAME1} for
|
||||
* compressed frames.
|
||||
* @param nLocal
|
||||
* the number of local variables in the visited frame.
|
||||
* @param local
|
||||
* the local variable types in this frame. This array must not be
|
||||
* modified. Primitive types are represented by
|
||||
* {@link Opcodes#TOP}, {@link Opcodes#INTEGER},
|
||||
* {@link Opcodes#FLOAT}, {@link Opcodes#LONG},
|
||||
* {@link Opcodes#DOUBLE},{@link Opcodes#NULL} or
|
||||
* {@link Opcodes#UNINITIALIZED_THIS} (long and double are
|
||||
* represented by a single element). Reference types are
|
||||
* represented by String objects (representing internal names),
|
||||
* and uninitialized types by Label objects (this label
|
||||
* designates the NEW instruction that created this uninitialized
|
||||
* value).
|
||||
* @param nStack
|
||||
* the number of operand stack elements in the visited frame.
|
||||
* @param stack
|
||||
* the operand stack types in this frame. This array must not be
|
||||
* modified. Its content has the same format as the "local"
|
||||
* array.
|
||||
* @throws IllegalStateException
|
||||
* if a frame is visited just after another one, without any
|
||||
* instruction between the two (unless this frame is a
|
||||
* Opcodes#F_SAME frame, in which case it is silently ignored).
|
||||
* <ul>
|
||||
* <li>In expanded form, all frames must have the F_NEW type.
|
||||
* <li>In compressed form, frames are basically "deltas" from the state of the previous frame:
|
||||
* <ul>
|
||||
* <li>{@link Opcodes#F_SAME} representing frame with exactly the same locals as the previous frame and with
|
||||
* the empty stack.
|
||||
* <li>{@link Opcodes#F_SAME1} representing frame with exactly the same locals as the previous frame and
|
||||
* with single value on the stack ( <code>nStack</code> is 1 and <code>stack[0]</code> contains value
|
||||
* for the type of the stack item).
|
||||
* <li>{@link Opcodes#F_APPEND} representing frame with current locals are the same as the locals in the
|
||||
* previous frame, except that additional locals are defined (<code>nLocal</code> is 1, 2 or 3 and
|
||||
* <code>local</code> elements contains values representing added types).
|
||||
* <li>{@link Opcodes#F_CHOP} representing frame with current locals are the same as the locals in the
|
||||
* previous frame, except that the last 1-3 locals are absent and with the empty stack (<code>nLocals
|
||||
* </code> is 1, 2 or 3).
|
||||
* <li>{@link Opcodes#F_FULL} representing complete frame data.
|
||||
* </ul>
|
||||
* </ul>
|
||||
*
|
||||
* <br>
|
||||
* In both cases the first frame, corresponding to the method's parameters and access flags, is implicit and must
|
||||
* not be visited. Also, it is illegal to visit two or more frames for the same code location (i.e., at least one
|
||||
* instruction must be visited between two calls to visitFrame).
|
||||
*
|
||||
* @param type the type of this stack map frame. Must be {@link Opcodes#F_NEW} for expanded frames, or
|
||||
* {@link Opcodes#F_FULL}, {@link Opcodes#F_APPEND}, {@link Opcodes#F_CHOP}, {@link Opcodes#F_SAME} or
|
||||
* {@link Opcodes#F_APPEND}, {@link Opcodes#F_SAME1} for compressed frames.
|
||||
* @param nLocal the number of local variables in the visited frame.
|
||||
* @param local the local variable types in this frame. This array must not be modified. Primitive types are
|
||||
* represented by {@link Opcodes#TOP}, {@link Opcodes#INTEGER}, {@link Opcodes#FLOAT}, {@link Opcodes#LONG},
|
||||
* {@link Opcodes#DOUBLE},{@link Opcodes#NULL} or {@link Opcodes#UNINITIALIZED_THIS} (long and double are
|
||||
* represented by a single element). Reference types are represented by String objects (representing internal
|
||||
* names), and uninitialized types by Label objects (this label designates the NEW instruction that created this
|
||||
* uninitialized value).
|
||||
* @param nStack the number of operand stack elements in the visited frame.
|
||||
* @param stack the operand stack types in this frame. This array must not be modified. Its content has the same
|
||||
* format as the "local" array.
|
||||
* @throws IllegalStateException if a frame is visited just after another one, without any instruction between the
|
||||
* two (unless this frame is a Opcodes#F_SAME frame, in which case it is silently ignored).
|
||||
*/
|
||||
public void visitFrame(int type, int nLocal, Object[] local, int nStack,
|
||||
Object[] stack) {
|
||||
public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) {
|
||||
if (mv != null) {
|
||||
mv.visitFrame(type, nLocal, local, nStack, stack);
|
||||
}
|
||||
@@ -339,22 +281,15 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Visits a zero operand instruction.
|
||||
*
|
||||
* @param opcode
|
||||
* the opcode of the instruction to be visited. This opcode is
|
||||
* either NOP, ACONST_NULL, ICONST_M1, ICONST_0, ICONST_1,
|
||||
* ICONST_2, ICONST_3, ICONST_4, ICONST_5, LCONST_0, LCONST_1,
|
||||
* FCONST_0, FCONST_1, FCONST_2, DCONST_0, DCONST_1, IALOAD,
|
||||
* LALOAD, FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, SALOAD,
|
||||
* IASTORE, LASTORE, FASTORE, DASTORE, AASTORE, BASTORE, CASTORE,
|
||||
* SASTORE, POP, POP2, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1,
|
||||
* DUP2_X2, SWAP, IADD, LADD, FADD, DADD, ISUB, LSUB, FSUB, DSUB,
|
||||
* IMUL, LMUL, FMUL, DMUL, IDIV, LDIV, FDIV, DDIV, IREM, LREM,
|
||||
* FREM, DREM, INEG, LNEG, FNEG, DNEG, ISHL, LSHL, ISHR, LSHR,
|
||||
* IUSHR, LUSHR, IAND, LAND, IOR, LOR, IXOR, LXOR, I2L, I2F, I2D,
|
||||
* L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F, I2B, I2C, I2S,
|
||||
* LCMP, FCMPL, FCMPG, DCMPL, DCMPG, IRETURN, LRETURN, FRETURN,
|
||||
* DRETURN, ARETURN, RETURN, ARRAYLENGTH, ATHROW, MONITORENTER,
|
||||
* or MONITOREXIT.
|
||||
* @param opcode the opcode of the instruction to be visited. This opcode is either NOP, ACONST_NULL, ICONST_M1,
|
||||
* ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, LCONST_0, LCONST_1, FCONST_0, FCONST_1, FCONST_2,
|
||||
* DCONST_0, DCONST_1, IALOAD, LALOAD, FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, SALOAD, IASTORE, LASTORE,
|
||||
* FASTORE, DASTORE, AASTORE, BASTORE, CASTORE, SASTORE, POP, POP2, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2,
|
||||
* SWAP, IADD, LADD, FADD, DADD, ISUB, LSUB, FSUB, DSUB, IMUL, LMUL, FMUL, DMUL, IDIV, LDIV, FDIV, DDIV, IREM,
|
||||
* LREM, FREM, DREM, INEG, LNEG, FNEG, DNEG, ISHL, LSHL, ISHR, LSHR, IUSHR, LUSHR, IAND, LAND, IOR, LOR, IXOR,
|
||||
* LXOR, I2L, I2F, I2D, L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F, I2B, I2C, I2S, LCMP, FCMPL, FCMPG, DCMPL,
|
||||
* DCMPG, IRETURN, LRETURN, FRETURN, DRETURN, ARETURN, RETURN, ARRAYLENGTH, ATHROW, MONITORENTER, or
|
||||
* MONITOREXIT.
|
||||
*/
|
||||
public void visitInsn(int opcode) {
|
||||
if (mv != null) {
|
||||
@@ -365,20 +300,13 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Visits an instruction with a single int operand.
|
||||
*
|
||||
* @param opcode
|
||||
* the opcode of the instruction to be visited. This opcode is
|
||||
* either BIPUSH, SIPUSH or NEWARRAY.
|
||||
* @param operand
|
||||
* the operand of the instruction to be visited.<br>
|
||||
* When opcode is BIPUSH, operand value should be between
|
||||
* Byte.MIN_VALUE and Byte.MAX_VALUE.<br>
|
||||
* When opcode is SIPUSH, operand value should be between
|
||||
* Short.MIN_VALUE and Short.MAX_VALUE.<br>
|
||||
* When opcode is NEWARRAY, operand value should be one of
|
||||
* {@link Opcodes#T_BOOLEAN}, {@link Opcodes#T_CHAR},
|
||||
* {@link Opcodes#T_FLOAT}, {@link Opcodes#T_DOUBLE},
|
||||
* {@link Opcodes#T_BYTE}, {@link Opcodes#T_SHORT},
|
||||
* {@link Opcodes#T_INT} or {@link Opcodes#T_LONG}.
|
||||
* @param opcode the opcode of the instruction to be visited. This opcode is either BIPUSH, SIPUSH or NEWARRAY.
|
||||
* @param operand the operand of the instruction to be visited.<br>
|
||||
* When opcode is BIPUSH, operand value should be between Byte.MIN_VALUE and Byte.MAX_VALUE.<br>
|
||||
* When opcode is SIPUSH, operand value should be between Short.MIN_VALUE and Short.MAX_VALUE.<br>
|
||||
* When opcode is NEWARRAY, operand value should be one of {@link Opcodes#T_BOOLEAN}, {@link Opcodes#T_CHAR},
|
||||
* {@link Opcodes#T_FLOAT}, {@link Opcodes#T_DOUBLE}, {@link Opcodes#T_BYTE}, {@link Opcodes#T_SHORT},
|
||||
* {@link Opcodes#T_INT} or {@link Opcodes#T_LONG}.
|
||||
*/
|
||||
public void visitIntInsn(int opcode, int operand) {
|
||||
if (mv != null) {
|
||||
@@ -387,16 +315,12 @@ public abstract class MethodVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a local variable instruction. A local variable instruction is an
|
||||
* instruction that loads or stores the value of a local variable.
|
||||
* Visits a local variable instruction. A local variable instruction is an instruction that loads or stores the
|
||||
* value of a local variable.
|
||||
*
|
||||
* @param opcode
|
||||
* the opcode of the local variable instruction to be visited.
|
||||
* This opcode is either ILOAD, LLOAD, FLOAD, DLOAD, ALOAD,
|
||||
* ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET.
|
||||
* @param var
|
||||
* the operand of the instruction to be visited. This operand is
|
||||
* the index of a local variable.
|
||||
* @param opcode the opcode of the local variable instruction to be visited. This opcode is either ILOAD, LLOAD,
|
||||
* FLOAD, DLOAD, ALOAD, ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET.
|
||||
* @param var the operand of the instruction to be visited. This operand is the index of a local variable.
|
||||
*/
|
||||
public void visitVarInsn(int opcode, int var) {
|
||||
if (mv != null) {
|
||||
@@ -405,16 +329,13 @@ public abstract class MethodVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a type instruction. A type instruction is an instruction that
|
||||
* takes the internal name of a class as parameter.
|
||||
* Visits a type instruction. A type instruction is an instruction that takes the internal name of a class as
|
||||
* parameter.
|
||||
*
|
||||
* @param opcode
|
||||
* the opcode of the type instruction to be visited. This opcode
|
||||
* is either NEW, ANEWARRAY, CHECKCAST or INSTANCEOF.
|
||||
* @param type
|
||||
* the operand of the instruction to be visited. This operand
|
||||
* must be the internal name of an object or array class (see
|
||||
* {@link Type#getInternalName() getInternalName}).
|
||||
* @param opcode the opcode of the type instruction to be visited. This opcode is either NEW, ANEWARRAY, CHECKCAST
|
||||
* or INSTANCEOF.
|
||||
* @param type the operand of the instruction to be visited. This operand must be the internal name of an object or
|
||||
* array class (see {@link Type#getInternalName() getInternalName}).
|
||||
*/
|
||||
public void visitTypeInsn(int opcode, String type) {
|
||||
if (mv != null) {
|
||||
@@ -423,47 +344,32 @@ public abstract class MethodVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a field instruction. A field instruction is an instruction that
|
||||
* loads or stores the value of a field of an object.
|
||||
* Visits a field instruction. A field instruction is an instruction that loads or stores the value of a field of an
|
||||
* object.
|
||||
*
|
||||
* @param opcode
|
||||
* the opcode of the type instruction to be visited. This opcode
|
||||
* is either GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD.
|
||||
* @param owner
|
||||
* the internal name of the field's owner class (see
|
||||
* {@link Type#getInternalName() getInternalName}).
|
||||
* @param name
|
||||
* the field's name.
|
||||
* @param desc
|
||||
* the field's descriptor (see {@link Type Type}).
|
||||
* @param opcode the opcode of the type instruction to be visited. This opcode is either GETSTATIC, PUTSTATIC,
|
||||
* GETFIELD or PUTFIELD.
|
||||
* @param owner the internal name of the field's owner class (see {@link Type#getInternalName() getInternalName}).
|
||||
* @param name the field's name.
|
||||
* @param desc the field's descriptor (see {@link Type Type}).
|
||||
*/
|
||||
public void visitFieldInsn(int opcode, String owner, String name,
|
||||
String desc) {
|
||||
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
|
||||
if (mv != null) {
|
||||
mv.visitFieldInsn(opcode, owner, name, desc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a method instruction. A method instruction is an instruction that
|
||||
* invokes a method.
|
||||
* Visits a method instruction. A method instruction is an instruction that invokes a method.
|
||||
*
|
||||
* @param opcode
|
||||
* the opcode of the type instruction to be visited. This opcode
|
||||
* is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or
|
||||
* INVOKEINTERFACE.
|
||||
* @param owner
|
||||
* the internal name of the method's owner class (see
|
||||
* {@link Type#getInternalName() getInternalName}).
|
||||
* @param name
|
||||
* the method's name.
|
||||
* @param desc
|
||||
* the method's descriptor (see {@link Type Type}).
|
||||
* @param itf
|
||||
* if the method's owner class is an interface.
|
||||
* @param opcode the opcode of the type instruction to be visited. This opcode is either INVOKEVIRTUAL,
|
||||
* INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE.
|
||||
* @param owner the internal name of the method's owner class (see {@link Type#getInternalName() getInternalName}).
|
||||
* @param name the method's name.
|
||||
* @param desc the method's descriptor (see {@link Type Type}).
|
||||
* @param itf if the method's owner class is an interface.
|
||||
*/
|
||||
public void visitMethodInsn(int opcode, String owner, String name,
|
||||
String desc, boolean itf) {
|
||||
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
|
||||
if (mv != null) {
|
||||
mv.visitMethodInsn(opcode, owner, name, desc, itf);
|
||||
}
|
||||
@@ -472,39 +378,27 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Visits an invokedynamic instruction.
|
||||
*
|
||||
* @param name
|
||||
* the method's name.
|
||||
* @param desc
|
||||
* the method's descriptor (see {@link Type Type}).
|
||||
* @param bsm
|
||||
* the bootstrap method.
|
||||
* @param bsmArgs
|
||||
* the bootstrap method constant arguments. Each argument must be
|
||||
* an {@link Integer}, {@link Float}, {@link Long},
|
||||
* {@link Double}, {@link String}, {@link Type} or {@link Handle}
|
||||
* value. This method is allowed to modify the content of the
|
||||
* array so a caller should expect that this array may change.
|
||||
* @param name the method's name.
|
||||
* @param desc the method's descriptor (see {@link Type Type}).
|
||||
* @param bsm the bootstrap method.
|
||||
* @param bsmArgs the bootstrap method constant arguments. Each argument must be an {@link Integer}, {@link Float},
|
||||
* {@link Long}, {@link Double}, {@link String}, {@link Type} or {@link Handle} value. This method is allowed to
|
||||
* modify the content of the array so a caller should expect that this array may change.
|
||||
*/
|
||||
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
|
||||
Object... bsmArgs) {
|
||||
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) {
|
||||
if (mv != null) {
|
||||
mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a jump instruction. A jump instruction is an instruction that may
|
||||
* jump to another instruction.
|
||||
* Visits a jump instruction. A jump instruction is an instruction that may jump to another instruction.
|
||||
*
|
||||
* @param opcode
|
||||
* the opcode of the type instruction to be visited. This opcode
|
||||
* is either IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ,
|
||||
* IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE,
|
||||
* IF_ACMPEQ, IF_ACMPNE, GOTO, JSR, IFNULL or IFNONNULL.
|
||||
* @param label
|
||||
* the operand of the instruction to be visited. This operand is
|
||||
* a label that designates the instruction to which the jump
|
||||
* instruction may jump.
|
||||
* @param opcode the opcode of the type instruction to be visited. This opcode is either IFEQ, IFNE, IFLT, IFGE,
|
||||
* IFGT, IFLE, IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ, IF_ACMPNE, GOTO,
|
||||
* JSR, IFNULL or IFNONNULL.
|
||||
* @param label the operand of the instruction to be visited. This operand is a label that designates the
|
||||
* instruction to which the jump instruction may jump.
|
||||
*/
|
||||
public void visitJumpInsn(int opcode, Label label) {
|
||||
if (mv != null) {
|
||||
@@ -513,11 +407,9 @@ public abstract class MethodVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a label. A label designates the instruction that will be visited
|
||||
* just after it.
|
||||
* Visits a label. A label designates the instruction that will be visited just after it.
|
||||
*
|
||||
* @param label
|
||||
* a {@link Label Label} object.
|
||||
* @param label a {@link Label Label} object.
|
||||
*/
|
||||
public void visitLabel(Label label) {
|
||||
if (mv != null) {
|
||||
@@ -530,10 +422,9 @@ public abstract class MethodVisitor {
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Visits a LDC instruction. Note that new constant types may be added in
|
||||
* future versions of the Java Virtual Machine. To easily detect new
|
||||
* constant types, implementations of this method should check for
|
||||
* unexpected constant types, like this:
|
||||
* Visits a LDC instruction. Note that new constant types may be added in future versions of the Java Virtual
|
||||
* Machine. To easily detect new constant types, implementations of this method should check for unexpected constant
|
||||
* types, like this:
|
||||
*
|
||||
* <pre>
|
||||
* if (cst instanceof Integer) {
|
||||
@@ -564,14 +455,10 @@ public abstract class MethodVisitor {
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @param cst
|
||||
* the constant to be loaded on the stack. This parameter must be
|
||||
* a non null {@link Integer}, a {@link Float}, a {@link Long}, a
|
||||
* {@link Double}, a {@link String}, a {@link Type} of OBJECT or
|
||||
* ARRAY sort for <tt>.class</tt> constants, for classes whose
|
||||
* version is 49.0, a {@link Type} of METHOD sort or a
|
||||
* {@link Handle} for MethodType and MethodHandle constants, for
|
||||
* classes whose version is 51.0.
|
||||
* @param cst the constant to be loaded on the stack. This parameter must be a non null {@link Integer}, a
|
||||
* {@link Float}, a {@link Long}, a {@link Double}, a {@link String}, a {@link Type} of OBJECT or ARRAY sort for
|
||||
* <tt>.class</tt> constants, for classes whose version is 49.0, a {@link Type} of METHOD sort
|
||||
* or a {@link Handle} for MethodType and MethodHandle constants, for classes whose version is 51.0.
|
||||
*/
|
||||
public void visitLdcInsn(Object cst) {
|
||||
if (mv != null) {
|
||||
@@ -582,10 +469,8 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Visits an IINC instruction.
|
||||
*
|
||||
* @param var
|
||||
* index of the local variable to be incremented.
|
||||
* @param increment
|
||||
* amount to increment the local variable by.
|
||||
* @param var index of the local variable to be incremented.
|
||||
* @param increment amount to increment the local variable by.
|
||||
*/
|
||||
public void visitIincInsn(int var, int increment) {
|
||||
if (mv != null) {
|
||||
@@ -596,18 +481,13 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Visits a TABLESWITCH instruction.
|
||||
*
|
||||
* @param min
|
||||
* the minimum key value.
|
||||
* @param max
|
||||
* the maximum key value.
|
||||
* @param dflt
|
||||
* beginning of the default handler block.
|
||||
* @param labels
|
||||
* beginnings of the handler blocks. <tt>labels[i]</tt> is the
|
||||
* beginning of the handler block for the <tt>min + i</tt> key.
|
||||
* @param min the minimum key value.
|
||||
* @param max the maximum key value.
|
||||
* @param dflt beginning of the default handler block.
|
||||
* @param labels beginnings of the handler blocks. <tt>labels[i]</tt> is the beginning of the
|
||||
* handler block for the <tt>min + i</tt> key.
|
||||
*/
|
||||
public void visitTableSwitchInsn(int min, int max, Label dflt,
|
||||
Label... labels) {
|
||||
public void visitTableSwitchInsn(int min, int max, Label dflt, Label... labels) {
|
||||
if (mv != null) {
|
||||
mv.visitTableSwitchInsn(min, max, dflt, labels);
|
||||
}
|
||||
@@ -616,13 +496,10 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Visits a LOOKUPSWITCH instruction.
|
||||
*
|
||||
* @param dflt
|
||||
* beginning of the default handler block.
|
||||
* @param keys
|
||||
* the values of the keys.
|
||||
* @param labels
|
||||
* beginnings of the handler blocks. <tt>labels[i]</tt> is the
|
||||
* beginning of the handler block for the <tt>keys[i]</tt> key.
|
||||
* @param dflt beginning of the default handler block.
|
||||
* @param keys the values of the keys.
|
||||
* @param labels beginnings of the handler blocks. <tt>labels[i]</tt> is the beginning of the
|
||||
* handler block for the <tt>keys[i]</tt> key.
|
||||
*/
|
||||
public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) {
|
||||
if (mv != null) {
|
||||
@@ -633,10 +510,8 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Visits a MULTIANEWARRAY instruction.
|
||||
*
|
||||
* @param desc
|
||||
* an array type descriptor (see {@link Type Type}).
|
||||
* @param dims
|
||||
* number of dimensions of the array to allocate.
|
||||
* @param desc an array type descriptor (see {@link Type Type}).
|
||||
* @param dims number of dimensions of the array to allocate.
|
||||
*/
|
||||
public void visitMultiANewArrayInsn(String desc, int dims) {
|
||||
if (mv != null) {
|
||||
@@ -645,38 +520,25 @@ public abstract class MethodVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an annotation on an instruction. This method must be called just
|
||||
* <i>after</i> the annotated instruction. It can be called several times
|
||||
* for the same instruction.
|
||||
* Visits an annotation on an instruction. This method must be called just <i>after</i> the annotated instruction.
|
||||
* It can be called several times for the same instruction.
|
||||
*
|
||||
* @param typeRef
|
||||
* a reference to the annotated type. The sort of this type
|
||||
* reference must be {@link TypeReference#INSTANCEOF INSTANCEOF},
|
||||
* {@link TypeReference#NEW NEW},
|
||||
* {@link TypeReference#CONSTRUCTOR_REFERENCE
|
||||
* CONSTRUCTOR_REFERENCE}, {@link TypeReference#METHOD_REFERENCE
|
||||
* METHOD_REFERENCE}, {@link TypeReference#CAST CAST},
|
||||
* {@link TypeReference#CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
|
||||
* CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT},
|
||||
* {@link TypeReference#METHOD_INVOCATION_TYPE_ARGUMENT
|
||||
* METHOD_INVOCATION_TYPE_ARGUMENT},
|
||||
* {@link TypeReference#CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
|
||||
* CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or
|
||||
* {@link TypeReference#METHOD_REFERENCE_TYPE_ARGUMENT
|
||||
* METHOD_REFERENCE_TYPE_ARGUMENT}. See {@link TypeReference}.
|
||||
* @param typePath
|
||||
* the path to the annotated type argument, wildcard bound, array
|
||||
* element type, or static inner type within 'typeRef'. May be
|
||||
* <tt>null</tt> if the annotation targets 'typeRef' as a whole.
|
||||
* @param desc
|
||||
* the class descriptor of the annotation class.
|
||||
* @param visible
|
||||
* <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if
|
||||
* this visitor is not interested in visiting this annotation.
|
||||
* @param typeRef a reference to the annotated type. The sort of this type reference must be
|
||||
* {@link TypeReference#INSTANCEOF INSTANCEOF}, {@link TypeReference#NEW NEW},
|
||||
* {@link TypeReference#CONSTRUCTOR_REFERENCE CONSTRUCTOR_REFERENCE}, {@link TypeReference#METHOD_REFERENCE
|
||||
* METHOD_REFERENCE}, {@link TypeReference#CAST CAST}, {@link TypeReference#CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
|
||||
* CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT}, {@link TypeReference#METHOD_INVOCATION_TYPE_ARGUMENT
|
||||
* METHOD_INVOCATION_TYPE_ARGUMENT}, {@link TypeReference#CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
|
||||
* CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or {@link TypeReference#METHOD_REFERENCE_TYPE_ARGUMENT
|
||||
* METHOD_REFERENCE_TYPE_ARGUMENT}. See {@link TypeReference}.
|
||||
* @param typePath the path to the annotated type argument, wildcard bound, array element type, or static inner type
|
||||
* within 'typeRef'. May be <tt>null</tt> if the annotation targets 'typeRef' as a whole.
|
||||
* @param desc the class descriptor of the annotation class.
|
||||
* @param visible <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if this visitor is not
|
||||
* interested in visiting this annotation.
|
||||
*/
|
||||
public AnnotationVisitor visitInsnAnnotation(int typeRef,
|
||||
TypePath typePath, String desc, boolean visible) {
|
||||
public AnnotationVisitor visitInsnAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) {
|
||||
if (mv != null) {
|
||||
return mv.visitInsnAnnotation(typeRef, typePath, desc, visible);
|
||||
}
|
||||
@@ -690,50 +552,35 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Visits a try catch block.
|
||||
*
|
||||
* @param start
|
||||
* beginning of the exception handler's scope (inclusive).
|
||||
* @param end
|
||||
* end of the exception handler's scope (exclusive).
|
||||
* @param handler
|
||||
* beginning of the exception handler's code.
|
||||
* @param type
|
||||
* internal name of the type of exceptions handled by the
|
||||
* handler, or <tt>null</tt> to catch any exceptions (for
|
||||
* "finally" blocks).
|
||||
* @throws IllegalArgumentException
|
||||
* if one of the labels has already been visited by this visitor
|
||||
* (by the {@link #visitLabel visitLabel} method).
|
||||
* @param start beginning of the exception handler's scope (inclusive).
|
||||
* @param end end of the exception handler's scope (exclusive).
|
||||
* @param handler beginning of the exception handler's code.
|
||||
* @param type internal name of the type of exceptions handled by the handler, or <tt>null</tt> to
|
||||
* catch any exceptions (for "finally" blocks).
|
||||
* @throws IllegalArgumentException if one of the labels has already been visited by this visitor (by the
|
||||
* {@link #visitLabel visitLabel} method).
|
||||
*/
|
||||
public void visitTryCatchBlock(Label start, Label end, Label handler,
|
||||
String type) {
|
||||
public void visitTryCatchBlock(Label start, Label end, Label handler, String type) {
|
||||
if (mv != null) {
|
||||
mv.visitTryCatchBlock(start, end, handler, type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an annotation on an exception handler type. This method must be
|
||||
* called <i>after</i> the {@link #visitTryCatchBlock} for the annotated
|
||||
* exception handler. It can be called several times for the same exception
|
||||
* handler.
|
||||
* Visits an annotation on an exception handler type. This method must be called <i>after</i> the
|
||||
* {@link #visitTryCatchBlock} for the annotated exception handler. It can be called several times for the same
|
||||
* exception handler.
|
||||
*
|
||||
* @param typeRef
|
||||
* a reference to the annotated type. The sort of this type
|
||||
* reference must be {@link TypeReference#EXCEPTION_PARAMETER
|
||||
* EXCEPTION_PARAMETER}. See {@link TypeReference}.
|
||||
* @param typePath
|
||||
* the path to the annotated type argument, wildcard bound, array
|
||||
* element type, or static inner type within 'typeRef'. May be
|
||||
* <tt>null</tt> if the annotation targets 'typeRef' as a whole.
|
||||
* @param desc
|
||||
* the class descriptor of the annotation class.
|
||||
* @param visible
|
||||
* <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if
|
||||
* this visitor is not interested in visiting this annotation.
|
||||
* @param typeRef a reference to the annotated type. The sort of this type reference must be
|
||||
* {@link TypeReference#EXCEPTION_PARAMETER EXCEPTION_PARAMETER}. See {@link TypeReference}.
|
||||
* @param typePath the path to the annotated type argument, wildcard bound, array element type, or static inner type
|
||||
* within 'typeRef'. May be <tt>null</tt> if the annotation targets 'typeRef' as a whole.
|
||||
* @param desc the class descriptor of the annotation class.
|
||||
* @param visible <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if this visitor is not
|
||||
* interested in visiting this annotation.
|
||||
*/
|
||||
public AnnotationVisitor visitTryCatchAnnotation(int typeRef,
|
||||
TypePath typePath, String desc, boolean visible) {
|
||||
public AnnotationVisitor visitTryCatchAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) {
|
||||
if (mv != null) {
|
||||
return mv.visitTryCatchAnnotation(typeRef, typePath, desc, visible);
|
||||
}
|
||||
@@ -743,28 +590,17 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Visits a local variable declaration.
|
||||
*
|
||||
* @param name
|
||||
* the name of a local variable.
|
||||
* @param desc
|
||||
* the type descriptor of this local variable.
|
||||
* @param signature
|
||||
* the type signature of this local variable. May be
|
||||
* <tt>null</tt> if the local variable type does not use generic
|
||||
* types.
|
||||
* @param start
|
||||
* the first instruction corresponding to the scope of this local
|
||||
* variable (inclusive).
|
||||
* @param end
|
||||
* the last instruction corresponding to the scope of this local
|
||||
* variable (exclusive).
|
||||
* @param index
|
||||
* the local variable's index.
|
||||
* @throws IllegalArgumentException
|
||||
* if one of the labels has not already been visited by this
|
||||
* visitor (by the {@link #visitLabel visitLabel} method).
|
||||
* @param name the name of a local variable.
|
||||
* @param desc the type descriptor of this local variable.
|
||||
* @param signature the type signature of this local variable. May be <tt>null</tt> if the local
|
||||
* variable type does not use generic types.
|
||||
* @param start the first instruction corresponding to the scope of this local variable (inclusive).
|
||||
* @param end the last instruction corresponding to the scope of this local variable (exclusive).
|
||||
* @param index the local variable's index.
|
||||
* @throws IllegalArgumentException if one of the labels has not already been visited by this visitor (by the
|
||||
* {@link #visitLabel visitLabel} method).
|
||||
*/
|
||||
public void visitLocalVariable(String name, String desc, String signature,
|
||||
Label start, Label end, int index) {
|
||||
public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
|
||||
if (mv != null) {
|
||||
mv.visitLocalVariable(name, desc, signature, start, end, index);
|
||||
}
|
||||
@@ -773,38 +609,25 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Visits an annotation on a local variable type.
|
||||
*
|
||||
* @param typeRef
|
||||
* a reference to the annotated type. The sort of this type
|
||||
* reference must be {@link TypeReference#LOCAL_VARIABLE
|
||||
* LOCAL_VARIABLE} or {@link TypeReference#RESOURCE_VARIABLE
|
||||
* RESOURCE_VARIABLE}. See {@link TypeReference}.
|
||||
* @param typePath
|
||||
* the path to the annotated type argument, wildcard bound, array
|
||||
* element type, or static inner type within 'typeRef'. May be
|
||||
* <tt>null</tt> if the annotation targets 'typeRef' as a whole.
|
||||
* @param start
|
||||
* the fist instructions corresponding to the continuous ranges
|
||||
* that make the scope of this local variable (inclusive).
|
||||
* @param end
|
||||
* the last instructions corresponding to the continuous ranges
|
||||
* that make the scope of this local variable (exclusive). This
|
||||
* array must have the same size as the 'start' array.
|
||||
* @param index
|
||||
* the local variable's index in each range. This array must have
|
||||
* the same size as the 'start' array.
|
||||
* @param desc
|
||||
* the class descriptor of the annotation class.
|
||||
* @param visible
|
||||
* <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if
|
||||
* this visitor is not interested in visiting this annotation.
|
||||
* @param typeRef a reference to the annotated type. The sort of this type reference must be
|
||||
* {@link TypeReference#LOCAL_VARIABLE LOCAL_VARIABLE} or {@link TypeReference#RESOURCE_VARIABLE
|
||||
* RESOURCE_VARIABLE}. See {@link TypeReference}.
|
||||
* @param typePath the path to the annotated type argument, wildcard bound, array element type, or static inner type
|
||||
* within 'typeRef'. May be <tt>null</tt> if the annotation targets 'typeRef' as a whole.
|
||||
* @param start the fist instructions corresponding to the continuous ranges that make the scope of this local
|
||||
* variable (inclusive).
|
||||
* @param end the last instructions corresponding to the continuous ranges that make the scope of this local
|
||||
* variable (exclusive). This array must have the same size as the 'start' array.
|
||||
* @param index the local variable's index in each range. This array must have the same size as the 'start' array.
|
||||
* @param desc the class descriptor of the annotation class.
|
||||
* @param visible <tt>true</tt> if the annotation is visible at runtime.
|
||||
* @return a visitor to visit the annotation values, or <tt>null</tt> if this visitor is not
|
||||
* interested in visiting this annotation.
|
||||
*/
|
||||
public AnnotationVisitor visitLocalVariableAnnotation(int typeRef,
|
||||
TypePath typePath, Label[] start, Label[] end, int[] index,
|
||||
String desc, boolean visible) {
|
||||
public AnnotationVisitor visitLocalVariableAnnotation(
|
||||
int typeRef, TypePath typePath, Label[] start, Label[] end, int[] index, String desc, boolean visible) {
|
||||
if (mv != null) {
|
||||
return mv.visitLocalVariableAnnotation(typeRef, typePath, start,
|
||||
end, index, desc, visible);
|
||||
return mv.visitLocalVariableAnnotation(typeRef, typePath, start, end, index, desc, visible);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -812,14 +635,10 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Visits a line number declaration.
|
||||
*
|
||||
* @param line
|
||||
* a line number. This number refers to the source file from
|
||||
* which the class was compiled.
|
||||
* @param start
|
||||
* the first instruction corresponding to this line number.
|
||||
* @throws IllegalArgumentException
|
||||
* if <tt>start</tt> has not already been visited by this
|
||||
* visitor (by the {@link #visitLabel visitLabel} method).
|
||||
* @param line a line number. This number refers to the source file from which the class was compiled.
|
||||
* @param start the first instruction corresponding to this line number.
|
||||
* @throws IllegalArgumentException if <tt>start</tt> has not already been visited by this visitor
|
||||
* (by the {@link #visitLabel visitLabel} method).
|
||||
*/
|
||||
public void visitLineNumber(int line, Label start) {
|
||||
if (mv != null) {
|
||||
@@ -828,13 +647,10 @@ public abstract class MethodVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits the maximum stack size and the maximum number of local variables
|
||||
* of the method.
|
||||
* Visits the maximum stack size and the maximum number of local variables of the method.
|
||||
*
|
||||
* @param maxStack
|
||||
* maximum stack size of the method.
|
||||
* @param maxLocals
|
||||
* maximum number of local variables for the method.
|
||||
* @param maxStack maximum stack size of the method.
|
||||
* @param maxLocals maximum number of local variables for the method.
|
||||
*/
|
||||
public void visitMaxs(int maxStack, int maxLocals) {
|
||||
if (mv != null) {
|
||||
@@ -843,9 +659,8 @@ public abstract class MethodVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits the end of the method. This method, which is the last one to be
|
||||
* called, is used to inform the visitor that all the annotations and
|
||||
* attributes of the method have been visited.
|
||||
* Visits the end of the method. This method, which is the last one to be called, is used to inform the visitor that
|
||||
* all the annotations and attributes of the method have been visited.
|
||||
*/
|
||||
public void visitEnd() {
|
||||
if (mv != null) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -59,36 +59,29 @@
|
||||
package org.redkale.asm;
|
||||
|
||||
/**
|
||||
* A visitor to visit a Java module. The methods of this class must be called in
|
||||
* the following order: <tt>visitMainClass</tt> | ( <tt>visitPackage</tt> |
|
||||
* A visitor to visit a Java module. The methods of this class must be called in the following order:
|
||||
* <tt>visitMainClass</tt> | ( <tt>visitPackage</tt> |
|
||||
* <tt>visitRequire</tt> | <tt>visitExport</tt> | <tt>visitOpen</tt> |
|
||||
* <tt>visitUse</tt> | <tt>visitProvide</tt> )* <tt>visitEnd</tt>.
|
||||
*
|
||||
* The methods {@link #visitRequire(String, int, String)}, {@link #visitExport(String, int, String...)},
|
||||
* {@link #visitOpen(String, int, String...)} and {@link #visitPackage(String)}
|
||||
* take as parameter a package name or a module name. Unlike the other names which are internal names
|
||||
* (names separated by slash), module and package names are qualified names (names separated by dot).
|
||||
* <p>The methods {@link #visitRequire(String, int, String)}, {@link #visitExport(String, int, String...)},
|
||||
* {@link #visitOpen(String, int, String...)} and {@link #visitPackage(String)} take as parameter a package name or a
|
||||
* module name. Unlike the other names which are internal names (names separated by slash), module and package names are
|
||||
* qualified names (names separated by dot).
|
||||
*
|
||||
* @author Remi Forax
|
||||
*/
|
||||
public abstract class ModuleVisitor {
|
||||
/**
|
||||
* The ASM API version implemented by this visitor. The value of this field
|
||||
* must be {@link Opcodes#ASM6}.
|
||||
*/
|
||||
/** The ASM API version implemented by this visitor. The value of this field must be {@link Opcodes#ASM6}. */
|
||||
protected final int api;
|
||||
|
||||
/**
|
||||
* The module visitor to which this visitor must delegate method calls. May
|
||||
* be null.
|
||||
*/
|
||||
/** The module visitor to which this visitor must delegate method calls. May be null. */
|
||||
protected ModuleVisitor mv;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link ModuleVisitor}.
|
||||
*
|
||||
* @param api
|
||||
* the ASM API version implemented by this visitor. Must be {@link Opcodes#ASM6}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be {@link Opcodes#ASM6}.
|
||||
*/
|
||||
public ModuleVisitor(final int api) {
|
||||
this(api, null);
|
||||
@@ -97,11 +90,8 @@ public abstract class ModuleVisitor {
|
||||
/**
|
||||
* Constructs a new {@link ModuleVisitor}.
|
||||
*
|
||||
* @param api
|
||||
* the ASM API version implemented by this visitor. Must be {@link Opcodes#ASM6}.
|
||||
* @param mv
|
||||
* the module visitor to which this visitor must delegate method
|
||||
* calls. May be null.
|
||||
* @param api the ASM API version implemented by this visitor. Must be {@link Opcodes#ASM6}.
|
||||
* @param mv the module visitor to which this visitor must delegate method calls. May be null.
|
||||
*/
|
||||
public ModuleVisitor(final int api, final ModuleVisitor mv) {
|
||||
if (api != Opcodes.ASM6) {
|
||||
@@ -137,9 +127,8 @@ public abstract class ModuleVisitor {
|
||||
* Visits a dependence of the current module.
|
||||
*
|
||||
* @param module the qualified name of the dependence.
|
||||
* @param access the access flag of the dependence among
|
||||
* ACC_TRANSITIVE, ACC_STATIC_PHASE, ACC_SYNTHETIC
|
||||
* and ACC_MANDATED.
|
||||
* @param access the access flag of the dependence among ACC_TRANSITIVE, ACC_STATIC_PHASE, ACC_SYNTHETIC and
|
||||
* ACC_MANDATED.
|
||||
* @param version the module version at compile time or null.
|
||||
*/
|
||||
public void visitRequire(String module, int access, String version) {
|
||||
@@ -152,12 +141,10 @@ public abstract class ModuleVisitor {
|
||||
* Visit an exported package of the current module.
|
||||
*
|
||||
* @param packaze the qualified name of the exported package.
|
||||
* @param access the access flag of the exported package,
|
||||
* valid values are among {@code ACC_SYNTHETIC} and
|
||||
* {@code ACC_MANDATED}.
|
||||
* @param modules the qualified names of the modules that can access to
|
||||
* the public classes of the exported package or
|
||||
* <tt>null</tt>.
|
||||
* @param access the access flag of the exported package, valid values are among {@code ACC_SYNTHETIC} and
|
||||
* {@code ACC_MANDATED}.
|
||||
* @param modules the qualified names of the modules that can access to the public classes of the exported package
|
||||
* or <tt>null</tt>.
|
||||
*/
|
||||
public void visitExport(String packaze, int access, String... modules) {
|
||||
if (mv != null) {
|
||||
@@ -169,12 +156,10 @@ public abstract class ModuleVisitor {
|
||||
* Visit an open package of the current module.
|
||||
*
|
||||
* @param packaze the qualified name of the opened package.
|
||||
* @param access the access flag of the opened package,
|
||||
* valid values are among {@code ACC_SYNTHETIC} and
|
||||
* {@code ACC_MANDATED}.
|
||||
* @param modules the qualified names of the modules that can use deep
|
||||
* reflection to the classes of the open package or
|
||||
* <tt>null</tt>.
|
||||
* @param access the access flag of the opened package, valid values are among {@code ACC_SYNTHETIC} and
|
||||
* {@code ACC_MANDATED}.
|
||||
* @param modules the qualified names of the modules that can use deep reflection to the classes of the open package
|
||||
* or <tt>null</tt>.
|
||||
*/
|
||||
public void visitOpen(String packaze, int access, String... modules) {
|
||||
if (mv != null) {
|
||||
@@ -183,8 +168,7 @@ public abstract class ModuleVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Visit a service used by the current module.
|
||||
* The name must be the internal name of an interface or a class.
|
||||
* Visit a service used by the current module. The name must be the internal name of an interface or a class.
|
||||
*
|
||||
* @param service the internal name of the service.
|
||||
*/
|
||||
@@ -198,8 +182,7 @@ public abstract class ModuleVisitor {
|
||||
* Visit an implementation of a service.
|
||||
*
|
||||
* @param service the internal name of the service
|
||||
* @param providers the internal names of the implementations
|
||||
* of the service (there is at least one provider).
|
||||
* @param providers the internal names of the implementations of the service (there is at least one provider).
|
||||
*/
|
||||
public void visitProvide(String service, String... providers) {
|
||||
if (mv != null) {
|
||||
@@ -208,8 +191,8 @@ public abstract class ModuleVisitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits the end of the module. This method, which is the last one to be
|
||||
* called, is used to inform the visitor that everything have been visited.
|
||||
* Visits the end of the module. This method, which is the last one to be called, is used to inform the visitor that
|
||||
* everything have been visited.
|
||||
*/
|
||||
public void visitEnd() {
|
||||
if (mv != null) {
|
||||
|
||||
@@ -59,122 +59,90 @@
|
||||
|
||||
package org.redkale.asm;
|
||||
|
||||
/**
|
||||
* @author Remi Forax
|
||||
*/
|
||||
/** @author Remi Forax */
|
||||
final class ModuleWriter extends ModuleVisitor {
|
||||
/**
|
||||
* The class writer to which this Module attribute must be added.
|
||||
*/
|
||||
/** The class writer to which this Module attribute must be added. */
|
||||
private final ClassWriter cw;
|
||||
|
||||
/**
|
||||
* size in byte of the Module attribute.
|
||||
*/
|
||||
/** size in byte of the Module attribute. */
|
||||
int size;
|
||||
|
||||
/**
|
||||
* Number of attributes associated with the current module
|
||||
* (Version, ConcealPackages, etc)
|
||||
*/
|
||||
/** Number of attributes associated with the current module (Version, ConcealPackages, etc) */
|
||||
int attributeCount;
|
||||
|
||||
/**
|
||||
* Size in bytes of the attributes associated with the current module
|
||||
*/
|
||||
/** Size in bytes of the attributes associated with the current module */
|
||||
int attributesSize;
|
||||
|
||||
/**
|
||||
* module name index in the constant pool
|
||||
*/
|
||||
/** module name index in the constant pool */
|
||||
private final int name;
|
||||
|
||||
/**
|
||||
* module access flags
|
||||
*/
|
||||
/** module access flags */
|
||||
private final int access;
|
||||
|
||||
/**
|
||||
* module version index in the constant pool or 0
|
||||
*/
|
||||
/** module version index in the constant pool or 0 */
|
||||
private final int version;
|
||||
|
||||
/**
|
||||
* module main class index in the constant pool or 0
|
||||
*/
|
||||
/** module main class index in the constant pool or 0 */
|
||||
private int mainClass;
|
||||
|
||||
/**
|
||||
* number of packages
|
||||
*/
|
||||
/** number of packages */
|
||||
private int packageCount;
|
||||
|
||||
/**
|
||||
* The packages in bytecode form. This byte vector only contains
|
||||
* the items themselves, the number of items is store in packageCount
|
||||
* The packages in bytecode form. This byte vector only contains the items themselves, the number of items is store
|
||||
* in packageCount
|
||||
*/
|
||||
private ByteVector packages;
|
||||
|
||||
/**
|
||||
* number of requires items
|
||||
*/
|
||||
/** number of requires items */
|
||||
private int requireCount;
|
||||
|
||||
/**
|
||||
* The requires items in bytecode form. This byte vector only contains
|
||||
* the items themselves, the number of items is store in requireCount
|
||||
* The requires items in bytecode form. This byte vector only contains the items themselves, the number of items is
|
||||
* store in requireCount
|
||||
*/
|
||||
private ByteVector requires;
|
||||
|
||||
/**
|
||||
* number of exports items
|
||||
*/
|
||||
/** number of exports items */
|
||||
private int exportCount;
|
||||
|
||||
/**
|
||||
* The exports items in bytecode form. This byte vector only contains
|
||||
* the items themselves, the number of items is store in exportCount
|
||||
* The exports items in bytecode form. This byte vector only contains the items themselves, the number of items is
|
||||
* store in exportCount
|
||||
*/
|
||||
private ByteVector exports;
|
||||
|
||||
/**
|
||||
* number of opens items
|
||||
*/
|
||||
/** number of opens items */
|
||||
private int openCount;
|
||||
|
||||
/**
|
||||
* The opens items in bytecode form. This byte vector only contains
|
||||
* the items themselves, the number of items is store in openCount
|
||||
* The opens items in bytecode form. This byte vector only contains the items themselves, the number of items is
|
||||
* store in openCount
|
||||
*/
|
||||
private ByteVector opens;
|
||||
|
||||
/**
|
||||
* number of uses items
|
||||
*/
|
||||
/** number of uses items */
|
||||
private int useCount;
|
||||
|
||||
/**
|
||||
* The uses items in bytecode form. This byte vector only contains
|
||||
* the items themselves, the number of items is store in useCount
|
||||
* The uses items in bytecode form. This byte vector only contains the items themselves, the number of items is
|
||||
* store in useCount
|
||||
*/
|
||||
private ByteVector uses;
|
||||
|
||||
/**
|
||||
* number of provides items
|
||||
*/
|
||||
/** number of provides items */
|
||||
private int provideCount;
|
||||
|
||||
/**
|
||||
* The uses provides in bytecode form. This byte vector only contains
|
||||
* the items themselves, the number of items is store in provideCount
|
||||
* The uses provides in bytecode form. This byte vector only contains the items themselves, the number of items is
|
||||
* store in provideCount
|
||||
*/
|
||||
private ByteVector provides;
|
||||
|
||||
ModuleWriter(final ClassWriter cw, final int name,
|
||||
final int access, final int version) {
|
||||
ModuleWriter(final ClassWriter cw, final int name, final int access, final int version) {
|
||||
super(Opcodes.ASM6);
|
||||
this.cw = cw;
|
||||
this.size = 16; // name + access + version + 5 counts
|
||||
this.size = 16; // name + access + version + 5 counts
|
||||
this.name = name;
|
||||
this.access = access;
|
||||
this.version = version;
|
||||
@@ -209,9 +177,7 @@ final class ModuleWriter extends ModuleVisitor {
|
||||
if (requires == null) {
|
||||
requires = new ByteVector();
|
||||
}
|
||||
requires.putShort(cw.newModule(module))
|
||||
.putShort(access)
|
||||
.putShort(version == null? 0: cw.newUTF8(version));
|
||||
requires.putShort(cw.newModule(module)).putShort(access).putShort(version == null ? 0 : cw.newUTF8(version));
|
||||
requireCount++;
|
||||
size += 6;
|
||||
}
|
||||
@@ -227,7 +193,7 @@ final class ModuleWriter extends ModuleVisitor {
|
||||
size += 6;
|
||||
} else {
|
||||
exports.putShort(modules.length);
|
||||
for(String module: modules) {
|
||||
for (String module : modules) {
|
||||
exports.putShort(cw.newModule(module));
|
||||
}
|
||||
size += 6 + 2 * modules.length;
|
||||
@@ -246,7 +212,7 @@ final class ModuleWriter extends ModuleVisitor {
|
||||
size += 6;
|
||||
} else {
|
||||
opens.putShort(modules.length);
|
||||
for(String module: modules) {
|
||||
for (String module : modules) {
|
||||
opens.putShort(cw.newModule(module));
|
||||
}
|
||||
size += 6 + 2 * modules.length;
|
||||
@@ -271,7 +237,7 @@ final class ModuleWriter extends ModuleVisitor {
|
||||
}
|
||||
provides.putShort(cw.newClass(service));
|
||||
provides.putShort(providers.length);
|
||||
for(String provider: providers) {
|
||||
for (String provider : providers) {
|
||||
provides.putShort(cw.newClass(provider));
|
||||
}
|
||||
provideCount++;
|
||||
@@ -289,9 +255,9 @@ final class ModuleWriter extends ModuleVisitor {
|
||||
}
|
||||
if (packages != null) {
|
||||
out.putShort(cw.newUTF8("ModulePackages"))
|
||||
.putInt(2 + 2 * packageCount)
|
||||
.putShort(packageCount)
|
||||
.putByteArray(packages.data, 0, packages.length);
|
||||
.putInt(2 + 2 * packageCount)
|
||||
.putShort(packageCount)
|
||||
.putByteArray(packages.data, 0, packages.length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,13 +59,10 @@
|
||||
package org.redkale.asm;
|
||||
|
||||
/**
|
||||
* Defines the JVM opcodes, access flags and array type codes. This interface
|
||||
* does not define all the JVM opcodes because some opcodes are automatically
|
||||
* handled. For example, the xLOAD and xSTORE opcodes are automatically replaced
|
||||
* by xLOAD_n and xSTORE_n opcodes when possible. The xLOAD_n and xSTORE_n
|
||||
* opcodes are therefore not defined in this interface. Likewise for LDC,
|
||||
* automatically replaced by LDC_W or LDC2_W when necessary, WIDE, GOTO_W and
|
||||
* JSR_W.
|
||||
* Defines the JVM opcodes, access flags and array type codes. This interface does not define all the JVM opcodes
|
||||
* because some opcodes are automatically handled. For example, the xLOAD and xSTORE opcodes are automatically replaced
|
||||
* by xLOAD_n and xSTORE_n opcodes when possible. The xLOAD_n and xSTORE_n opcodes are therefore not defined in this
|
||||
* interface. Likewise for LDC, automatically replaced by LDC_W or LDC2_W when necessary, WIDE, GOTO_W and JSR_W.
|
||||
*
|
||||
* @author Eric Bruneton
|
||||
* @author Eugene Kuleshov
|
||||
@@ -117,7 +114,6 @@ public interface Opcodes {
|
||||
int ACC_MANDATED = 0x8000; // parameter, module, module *
|
||||
int ACC_MODULE = 0x8000; // class
|
||||
|
||||
|
||||
// ASM specific pseudo access flags
|
||||
|
||||
int ACC_DEPRECATED = 0x20000; // class, field, method
|
||||
@@ -147,39 +143,30 @@ public interface Opcodes {
|
||||
|
||||
// stack map frame types
|
||||
|
||||
/**
|
||||
* Represents an expanded frame. See {@link ClassReader#EXPAND_FRAMES}.
|
||||
*/
|
||||
/** Represents an expanded frame. See {@link ClassReader#EXPAND_FRAMES}. */
|
||||
int F_NEW = -1;
|
||||
|
||||
/**
|
||||
* Represents a compressed frame with complete frame data.
|
||||
*/
|
||||
/** Represents a compressed frame with complete frame data. */
|
||||
int F_FULL = 0;
|
||||
|
||||
/**
|
||||
* Represents a compressed frame where locals are the same as the locals in
|
||||
* the previous frame, except that additional 1-3 locals are defined, and
|
||||
* with an empty stack.
|
||||
* Represents a compressed frame where locals are the same as the locals in the previous frame, except that
|
||||
* additional 1-3 locals are defined, and with an empty stack.
|
||||
*/
|
||||
int F_APPEND = 1;
|
||||
|
||||
/**
|
||||
* Represents a compressed frame where locals are the same as the locals in
|
||||
* the previous frame, except that the last 1-3 locals are absent and with
|
||||
* an empty stack.
|
||||
* Represents a compressed frame where locals are the same as the locals in the previous frame, except that the last
|
||||
* 1-3 locals are absent and with an empty stack.
|
||||
*/
|
||||
int F_CHOP = 2;
|
||||
|
||||
/**
|
||||
* Represents a compressed frame with exactly the same locals as the
|
||||
* previous frame and with an empty stack.
|
||||
*/
|
||||
/** Represents a compressed frame with exactly the same locals as the previous frame and with an empty stack. */
|
||||
int F_SAME = 3;
|
||||
|
||||
/**
|
||||
* Represents a compressed frame with exactly the same locals as the
|
||||
* previous frame and with a single value on the stack.
|
||||
* Represents a compressed frame with exactly the same locals as the previous frame and with a single value on the
|
||||
* stack.
|
||||
*/
|
||||
int F_SAME1 = 4;
|
||||
|
||||
@@ -187,13 +174,26 @@ public interface Opcodes {
|
||||
// these values are compared by reference and not by value
|
||||
// The constructor of Integer was deprecated in 9
|
||||
// but we are stuck with it by backward compatibility
|
||||
@SuppressWarnings("deprecation") Integer TOP = new Integer(0);
|
||||
@SuppressWarnings("deprecation") Integer INTEGER = new Integer(1);
|
||||
@SuppressWarnings("deprecation") Integer FLOAT = new Integer(2);
|
||||
@SuppressWarnings("deprecation") Integer DOUBLE = new Integer(3);
|
||||
@SuppressWarnings("deprecation") Integer LONG = new Integer(4);
|
||||
@SuppressWarnings("deprecation") Integer NULL = new Integer(5);
|
||||
@SuppressWarnings("deprecation") Integer UNINITIALIZED_THIS = new Integer(6);
|
||||
@SuppressWarnings("deprecation")
|
||||
Integer TOP = Integer.valueOf(0);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Integer INTEGER = Integer.valueOf(1);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Integer FLOAT = Integer.valueOf(2);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Integer DOUBLE = Integer.valueOf(3);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Integer LONG = Integer.valueOf(4);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Integer NULL = Integer.valueOf(5);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Integer UNINITIALIZED_THIS = Integer.valueOf(6);
|
||||
|
||||
// opcodes // visit method (- = idem)
|
||||
|
||||
|
||||
@@ -62,154 +62,94 @@ import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* A Java field or method type. This class can be used to make it easier to
|
||||
* manipulate type and method descriptors.
|
||||
* A Java field or method type. This class can be used to make it easier to manipulate type and method descriptors.
|
||||
*
|
||||
* @author Eric Bruneton
|
||||
* @author Chris Nokleberg
|
||||
*/
|
||||
public class Type {
|
||||
|
||||
/**
|
||||
* The sort of the <tt>void</tt> type. See {@link #getSort getSort}.
|
||||
*/
|
||||
/** The sort of the <tt>void</tt> type. See {@link #getSort getSort}. */
|
||||
public static final int VOID = 0;
|
||||
|
||||
/**
|
||||
* The sort of the <tt>boolean</tt> type. See {@link #getSort getSort}.
|
||||
*/
|
||||
/** The sort of the <tt>boolean</tt> type. See {@link #getSort getSort}. */
|
||||
public static final int BOOLEAN = 1;
|
||||
|
||||
/**
|
||||
* The sort of the <tt>char</tt> type. See {@link #getSort getSort}.
|
||||
*/
|
||||
/** The sort of the <tt>char</tt> type. See {@link #getSort getSort}. */
|
||||
public static final int CHAR = 2;
|
||||
|
||||
/**
|
||||
* The sort of the <tt>byte</tt> type. See {@link #getSort getSort}.
|
||||
*/
|
||||
/** The sort of the <tt>byte</tt> type. See {@link #getSort getSort}. */
|
||||
public static final int BYTE = 3;
|
||||
|
||||
/**
|
||||
* The sort of the <tt>short</tt> type. See {@link #getSort getSort}.
|
||||
*/
|
||||
/** The sort of the <tt>short</tt> type. See {@link #getSort getSort}. */
|
||||
public static final int SHORT = 4;
|
||||
|
||||
/**
|
||||
* The sort of the <tt>int</tt> type. See {@link #getSort getSort}.
|
||||
*/
|
||||
/** The sort of the <tt>int</tt> type. See {@link #getSort getSort}. */
|
||||
public static final int INT = 5;
|
||||
|
||||
/**
|
||||
* The sort of the <tt>float</tt> type. See {@link #getSort getSort}.
|
||||
*/
|
||||
/** The sort of the <tt>float</tt> type. See {@link #getSort getSort}. */
|
||||
public static final int FLOAT = 6;
|
||||
|
||||
/**
|
||||
* The sort of the <tt>long</tt> type. See {@link #getSort getSort}.
|
||||
*/
|
||||
/** The sort of the <tt>long</tt> type. See {@link #getSort getSort}. */
|
||||
public static final int LONG = 7;
|
||||
|
||||
/**
|
||||
* The sort of the <tt>double</tt> type. See {@link #getSort getSort}.
|
||||
*/
|
||||
/** The sort of the <tt>double</tt> type. See {@link #getSort getSort}. */
|
||||
public static final int DOUBLE = 8;
|
||||
|
||||
/**
|
||||
* The sort of array reference types. See {@link #getSort getSort}.
|
||||
*/
|
||||
/** The sort of array reference types. See {@link #getSort getSort}. */
|
||||
public static final int ARRAY = 9;
|
||||
|
||||
/**
|
||||
* The sort of object reference types. See {@link #getSort getSort}.
|
||||
*/
|
||||
/** The sort of object reference types. See {@link #getSort getSort}. */
|
||||
public static final int OBJECT = 10;
|
||||
|
||||
/**
|
||||
* The sort of method types. See {@link #getSort getSort}.
|
||||
*/
|
||||
/** The sort of method types. See {@link #getSort getSort}. */
|
||||
public static final int METHOD = 11;
|
||||
|
||||
/**
|
||||
* The <tt>void</tt> type.
|
||||
*/
|
||||
public static final Type VOID_TYPE = new Type(VOID, null, ('V' << 24)
|
||||
| (5 << 16) | (0 << 8) | 0, 1);
|
||||
/** The <tt>void</tt> type. */
|
||||
public static final Type VOID_TYPE = new Type(VOID, null, ('V' << 24) | (5 << 16) | (0 << 8) | 0, 1);
|
||||
|
||||
/**
|
||||
* The <tt>boolean</tt> type.
|
||||
*/
|
||||
public static final Type BOOLEAN_TYPE = new Type(BOOLEAN, null, ('Z' << 24)
|
||||
| (0 << 16) | (5 << 8) | 1, 1);
|
||||
/** The <tt>boolean</tt> type. */
|
||||
public static final Type BOOLEAN_TYPE = new Type(BOOLEAN, null, ('Z' << 24) | (0 << 16) | (5 << 8) | 1, 1);
|
||||
|
||||
/**
|
||||
* The <tt>char</tt> type.
|
||||
*/
|
||||
public static final Type CHAR_TYPE = new Type(CHAR, null, ('C' << 24)
|
||||
| (0 << 16) | (6 << 8) | 1, 1);
|
||||
/** The <tt>char</tt> type. */
|
||||
public static final Type CHAR_TYPE = new Type(CHAR, null, ('C' << 24) | (0 << 16) | (6 << 8) | 1, 1);
|
||||
|
||||
/**
|
||||
* The <tt>byte</tt> type.
|
||||
*/
|
||||
public static final Type BYTE_TYPE = new Type(BYTE, null, ('B' << 24)
|
||||
| (0 << 16) | (5 << 8) | 1, 1);
|
||||
/** The <tt>byte</tt> type. */
|
||||
public static final Type BYTE_TYPE = new Type(BYTE, null, ('B' << 24) | (0 << 16) | (5 << 8) | 1, 1);
|
||||
|
||||
/**
|
||||
* The <tt>short</tt> type.
|
||||
*/
|
||||
public static final Type SHORT_TYPE = new Type(SHORT, null, ('S' << 24)
|
||||
| (0 << 16) | (7 << 8) | 1, 1);
|
||||
/** The <tt>short</tt> type. */
|
||||
public static final Type SHORT_TYPE = new Type(SHORT, null, ('S' << 24) | (0 << 16) | (7 << 8) | 1, 1);
|
||||
|
||||
/**
|
||||
* The <tt>int</tt> type.
|
||||
*/
|
||||
public static final Type INT_TYPE = new Type(INT, null, ('I' << 24)
|
||||
| (0 << 16) | (0 << 8) | 1, 1);
|
||||
/** The <tt>int</tt> type. */
|
||||
public static final Type INT_TYPE = new Type(INT, null, ('I' << 24) | (0 << 16) | (0 << 8) | 1, 1);
|
||||
|
||||
/**
|
||||
* The <tt>float</tt> type.
|
||||
*/
|
||||
public static final Type FLOAT_TYPE = new Type(FLOAT, null, ('F' << 24)
|
||||
| (2 << 16) | (2 << 8) | 1, 1);
|
||||
/** The <tt>float</tt> type. */
|
||||
public static final Type FLOAT_TYPE = new Type(FLOAT, null, ('F' << 24) | (2 << 16) | (2 << 8) | 1, 1);
|
||||
|
||||
/**
|
||||
* The <tt>long</tt> type.
|
||||
*/
|
||||
public static final Type LONG_TYPE = new Type(LONG, null, ('J' << 24)
|
||||
| (1 << 16) | (1 << 8) | 2, 1);
|
||||
/** The <tt>long</tt> type. */
|
||||
public static final Type LONG_TYPE = new Type(LONG, null, ('J' << 24) | (1 << 16) | (1 << 8) | 2, 1);
|
||||
|
||||
/**
|
||||
* The <tt>double</tt> type.
|
||||
*/
|
||||
public static final Type DOUBLE_TYPE = new Type(DOUBLE, null, ('D' << 24)
|
||||
| (3 << 16) | (3 << 8) | 2, 1);
|
||||
/** The <tt>double</tt> type. */
|
||||
public static final Type DOUBLE_TYPE = new Type(DOUBLE, null, ('D' << 24) | (3 << 16) | (3 << 8) | 2, 1);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Fields
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The sort of this Java type.
|
||||
*/
|
||||
/** The sort of this Java type. */
|
||||
private final int sort;
|
||||
|
||||
/**
|
||||
* A buffer containing the internal name of this Java type. This field is
|
||||
* only used for reference types.
|
||||
*/
|
||||
/** A buffer containing the internal name of this Java type. This field is only used for reference types. */
|
||||
private final char[] buf;
|
||||
|
||||
/**
|
||||
* The offset of the internal name of this Java type in {@link #buf buf} or,
|
||||
* for primitive types, the size, descriptor and getOpcode offsets for this
|
||||
* type (byte 0 contains the size, byte 1 the descriptor, byte 2 the offset
|
||||
* for IALOAD or IASTORE, byte 3 the offset for all other instructions).
|
||||
* The offset of the internal name of this Java type in {@link #buf buf} or, for primitive types, the size,
|
||||
* descriptor and getOpcode offsets for this type (byte 0 contains the size, byte 1 the descriptor, byte 2 the
|
||||
* offset for IALOAD or IASTORE, byte 3 the offset for all other instructions).
|
||||
*/
|
||||
private final int off;
|
||||
|
||||
/**
|
||||
* The length of the internal name of this Java type.
|
||||
*/
|
||||
/** The length of the internal name of this Java type. */
|
||||
private final int len;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -219,14 +159,10 @@ public class Type {
|
||||
/**
|
||||
* Constructs a reference type.
|
||||
*
|
||||
* @param sort
|
||||
* the sort of the reference type to be constructed.
|
||||
* @param buf
|
||||
* a buffer containing the descriptor of the previous type.
|
||||
* @param off
|
||||
* the offset of this descriptor in the previous buffer.
|
||||
* @param len
|
||||
* the length of this descriptor.
|
||||
* @param sort the sort of the reference type to be constructed.
|
||||
* @param buf a buffer containing the descriptor of the previous type.
|
||||
* @param off the offset of this descriptor in the previous buffer.
|
||||
* @param len the length of this descriptor.
|
||||
*/
|
||||
private Type(final int sort, final char[] buf, final int off, final int len) {
|
||||
this.sort = sort;
|
||||
@@ -238,8 +174,7 @@ public class Type {
|
||||
/**
|
||||
* Returns the Java type corresponding to the given type descriptor.
|
||||
*
|
||||
* @param typeDescriptor
|
||||
* a field or method type descriptor.
|
||||
* @param typeDescriptor a field or method type descriptor.
|
||||
* @return the Java type corresponding to the given type descriptor.
|
||||
*/
|
||||
public static Type getType(final String typeDescriptor) {
|
||||
@@ -249,8 +184,7 @@ public class Type {
|
||||
/**
|
||||
* Returns the Java type corresponding to the given internal name.
|
||||
*
|
||||
* @param internalName
|
||||
* an internal name.
|
||||
* @param internalName an internal name.
|
||||
* @return the Java type corresponding to the given internal name.
|
||||
*/
|
||||
public static Type getObjectType(final String internalName) {
|
||||
@@ -259,11 +193,10 @@ public class Type {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Java type corresponding to the given method descriptor.
|
||||
* Equivalent to <code>Type.getType(methodDescriptor)</code>.
|
||||
* Returns the Java type corresponding to the given method descriptor. Equivalent to <code>
|
||||
* Type.getType(methodDescriptor)</code>.
|
||||
*
|
||||
* @param methodDescriptor
|
||||
* a method descriptor.
|
||||
* @param methodDescriptor a method descriptor.
|
||||
* @return the Java type corresponding to the given method descriptor.
|
||||
*/
|
||||
public static Type getMethodType(final String methodDescriptor) {
|
||||
@@ -271,26 +204,20 @@ public class Type {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Java method type corresponding to the given argument and
|
||||
* return types.
|
||||
* Returns the Java method type corresponding to the given argument and return types.
|
||||
*
|
||||
* @param returnType
|
||||
* the return type of the method.
|
||||
* @param argumentTypes
|
||||
* the argument types of the method.
|
||||
* @return the Java type corresponding to the given argument and return
|
||||
* types.
|
||||
* @param returnType the return type of the method.
|
||||
* @param argumentTypes the argument types of the method.
|
||||
* @return the Java type corresponding to the given argument and return types.
|
||||
*/
|
||||
public static Type getMethodType(final Type returnType,
|
||||
final Type... argumentTypes) {
|
||||
public static Type getMethodType(final Type returnType, final Type... argumentTypes) {
|
||||
return getType(getMethodDescriptor(returnType, argumentTypes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Java type corresponding to the given class.
|
||||
*
|
||||
* @param c
|
||||
* a class.
|
||||
* @param c a class.
|
||||
* @return the Java type corresponding to the given class.
|
||||
*/
|
||||
public static Type getType(final Class<?> c) {
|
||||
@@ -311,7 +238,7 @@ public class Type {
|
||||
return DOUBLE_TYPE;
|
||||
} else if (c == Float.TYPE) {
|
||||
return FLOAT_TYPE;
|
||||
} else /* if (c == Long.TYPE) */{
|
||||
} else /* if (c == Long.TYPE) */ {
|
||||
return LONG_TYPE;
|
||||
}
|
||||
} else {
|
||||
@@ -322,8 +249,7 @@ public class Type {
|
||||
/**
|
||||
* Returns the Java method type corresponding to the given constructor.
|
||||
*
|
||||
* @param c
|
||||
* a {@link Constructor Constructor} object.
|
||||
* @param c a {@link Constructor Constructor} object.
|
||||
* @return the Java method type corresponding to the given constructor.
|
||||
*/
|
||||
public static Type getType(final Constructor<?> c) {
|
||||
@@ -333,8 +259,7 @@ public class Type {
|
||||
/**
|
||||
* Returns the Java method type corresponding to the given method.
|
||||
*
|
||||
* @param m
|
||||
* a {@link Method Method} object.
|
||||
* @param m a {@link Method Method} object.
|
||||
* @return the Java method type corresponding to the given method.
|
||||
*/
|
||||
public static Type getType(final Method m) {
|
||||
@@ -342,13 +267,10 @@ public class Type {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Java types corresponding to the argument types of the given
|
||||
* method descriptor.
|
||||
* Returns the Java types corresponding to the argument types of the given method descriptor.
|
||||
*
|
||||
* @param methodDescriptor
|
||||
* a method descriptor.
|
||||
* @return the Java types corresponding to the argument types of the given
|
||||
* method descriptor.
|
||||
* @param methodDescriptor a method descriptor.
|
||||
* @return the Java types corresponding to the argument types of the given method descriptor.
|
||||
*/
|
||||
public static Type[] getArgumentTypes(final String methodDescriptor) {
|
||||
char[] buf = methodDescriptor.toCharArray();
|
||||
@@ -360,6 +282,7 @@ public class Type {
|
||||
break;
|
||||
} else if (car == 'L') {
|
||||
while (buf[off++] != ';') {
|
||||
// do nothing
|
||||
}
|
||||
++size;
|
||||
} else if (car != '[') {
|
||||
@@ -378,13 +301,10 @@ public class Type {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Java types corresponding to the argument types of the given
|
||||
* method.
|
||||
* Returns the Java types corresponding to the argument types of the given method.
|
||||
*
|
||||
* @param method
|
||||
* a method.
|
||||
* @return the Java types corresponding to the argument types of the given
|
||||
* method.
|
||||
* @param method a method.
|
||||
* @return the Java types corresponding to the argument types of the given method.
|
||||
*/
|
||||
public static Type[] getArgumentTypes(final Method method) {
|
||||
Class<?>[] classes = method.getParameterTypes();
|
||||
@@ -396,13 +316,10 @@ public class Type {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Java type corresponding to the return type of the given
|
||||
* method descriptor.
|
||||
* Returns the Java type corresponding to the return type of the given method descriptor.
|
||||
*
|
||||
* @param methodDescriptor
|
||||
* a method descriptor.
|
||||
* @return the Java type corresponding to the return type of the given
|
||||
* method descriptor.
|
||||
* @param methodDescriptor a method descriptor.
|
||||
* @return the Java type corresponding to the return type of the given method descriptor.
|
||||
*/
|
||||
public static Type getReturnType(final String methodDescriptor) {
|
||||
char[] buf = methodDescriptor.toCharArray();
|
||||
@@ -413,19 +330,17 @@ public class Type {
|
||||
return getType(buf, off);
|
||||
} else if (car == 'L') {
|
||||
while (buf[off++] != ';') {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Java type corresponding to the return type of the given
|
||||
* method.
|
||||
* Returns the Java type corresponding to the return type of the given method.
|
||||
*
|
||||
* @param method
|
||||
* a method.
|
||||
* @return the Java type corresponding to the return type of the given
|
||||
* method.
|
||||
* @param method a method.
|
||||
* @return the Java type corresponding to the return type of the given method.
|
||||
*/
|
||||
public static Type getReturnType(final Method method) {
|
||||
return getType(method.getReturnType());
|
||||
@@ -434,13 +349,11 @@ public class Type {
|
||||
/**
|
||||
* Computes the size of the arguments and of the return value of a method.
|
||||
*
|
||||
* @param desc
|
||||
* the descriptor of a method.
|
||||
* @return the size of the arguments of the method (plus one for the
|
||||
* implicit this argument), argSize, and the size of its return
|
||||
* value, retSize, packed into a single int i =
|
||||
* <tt>(argSize << 2) | retSize</tt> (argSize is therefore equal to
|
||||
* <tt>i >> 2</tt>, and retSize to <tt>i & 0x03</tt>).
|
||||
* @param desc the descriptor of a method.
|
||||
* @return the size of the arguments of the method (plus one for the implicit this argument), argSize, and the size
|
||||
* of its return value, retSize, packed into a single int i = <tt>(argSize << 2) |
|
||||
* retSize</tt> (argSize is therefore equal to <tt>i >> 2</tt>, and retSize to
|
||||
* <tt>i & 0x03</tt>).
|
||||
*/
|
||||
public static int getArgumentsAndReturnSizes(final String desc) {
|
||||
int n = 1;
|
||||
@@ -449,10 +362,10 @@ public class Type {
|
||||
char car = desc.charAt(c++);
|
||||
if (car == ')') {
|
||||
car = desc.charAt(c);
|
||||
return n << 2
|
||||
| (car == 'V' ? 0 : (car == 'D' || car == 'J' ? 2 : 1));
|
||||
return n << 2 | (car == 'V' ? 0 : (car == 'D' || car == 'J' ? 2 : 1));
|
||||
} else if (car == 'L') {
|
||||
while (desc.charAt(c++) != ';') {
|
||||
// do nothing
|
||||
}
|
||||
n += 1;
|
||||
} else if (car == '[') {
|
||||
@@ -471,58 +384,55 @@ public class Type {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Java type corresponding to the given type descriptor. For
|
||||
* method descriptors, buf is supposed to contain nothing more than the
|
||||
* descriptor itself.
|
||||
* Returns the Java type corresponding to the given type descriptor. For method descriptors, buf is supposed to
|
||||
* contain nothing more than the descriptor itself.
|
||||
*
|
||||
* @param buf
|
||||
* a buffer containing a type descriptor.
|
||||
* @param off
|
||||
* the offset of this descriptor in the previous buffer.
|
||||
* @param buf a buffer containing a type descriptor.
|
||||
* @param off the offset of this descriptor in the previous buffer.
|
||||
* @return the Java type corresponding to the given type descriptor.
|
||||
*/
|
||||
private static Type getType(final char[] buf, final int off) {
|
||||
int len;
|
||||
switch (buf[off]) {
|
||||
case 'V':
|
||||
return VOID_TYPE;
|
||||
case 'Z':
|
||||
return BOOLEAN_TYPE;
|
||||
case 'C':
|
||||
return CHAR_TYPE;
|
||||
case 'B':
|
||||
return BYTE_TYPE;
|
||||
case 'S':
|
||||
return SHORT_TYPE;
|
||||
case 'I':
|
||||
return INT_TYPE;
|
||||
case 'F':
|
||||
return FLOAT_TYPE;
|
||||
case 'J':
|
||||
return LONG_TYPE;
|
||||
case 'D':
|
||||
return DOUBLE_TYPE;
|
||||
case '[':
|
||||
len = 1;
|
||||
while (buf[off + len] == '[') {
|
||||
++len;
|
||||
}
|
||||
if (buf[off + len] == 'L') {
|
||||
++len;
|
||||
case 'V':
|
||||
return VOID_TYPE;
|
||||
case 'Z':
|
||||
return BOOLEAN_TYPE;
|
||||
case 'C':
|
||||
return CHAR_TYPE;
|
||||
case 'B':
|
||||
return BYTE_TYPE;
|
||||
case 'S':
|
||||
return SHORT_TYPE;
|
||||
case 'I':
|
||||
return INT_TYPE;
|
||||
case 'F':
|
||||
return FLOAT_TYPE;
|
||||
case 'J':
|
||||
return LONG_TYPE;
|
||||
case 'D':
|
||||
return DOUBLE_TYPE;
|
||||
case '[':
|
||||
len = 1;
|
||||
while (buf[off + len] == '[') {
|
||||
++len;
|
||||
}
|
||||
if (buf[off + len] == 'L') {
|
||||
++len;
|
||||
while (buf[off + len] != ';') {
|
||||
++len;
|
||||
}
|
||||
}
|
||||
return new Type(ARRAY, buf, off, len + 1);
|
||||
case 'L':
|
||||
len = 1;
|
||||
while (buf[off + len] != ';') {
|
||||
++len;
|
||||
}
|
||||
}
|
||||
return new Type(ARRAY, buf, off, len + 1);
|
||||
case 'L':
|
||||
len = 1;
|
||||
while (buf[off + len] != ';') {
|
||||
++len;
|
||||
}
|
||||
return new Type(OBJECT, buf, off + 1, len - 1);
|
||||
// case '(':
|
||||
default:
|
||||
return new Type(METHOD, buf, off, buf.length - off);
|
||||
return new Type(OBJECT, buf, off + 1, len - 1);
|
||||
// case '(':
|
||||
default:
|
||||
return new Type(METHOD, buf, off, buf.length - off);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,19 +443,16 @@ public class Type {
|
||||
/**
|
||||
* Returns the sort of this Java type.
|
||||
*
|
||||
* @return {@link #VOID VOID}, {@link #BOOLEAN BOOLEAN}, {@link #CHAR CHAR},
|
||||
* {@link #BYTE BYTE}, {@link #SHORT SHORT}, {@link #INT INT},
|
||||
* {@link #FLOAT FLOAT}, {@link #LONG LONG}, {@link #DOUBLE DOUBLE},
|
||||
* {@link #ARRAY ARRAY}, {@link #OBJECT OBJECT} or {@link #METHOD
|
||||
* METHOD}.
|
||||
* @return {@link #VOID VOID}, {@link #BOOLEAN BOOLEAN}, {@link #CHAR CHAR}, {@link #BYTE BYTE}, {@link #SHORT
|
||||
* SHORT}, {@link #INT INT}, {@link #FLOAT FLOAT}, {@link #LONG LONG}, {@link #DOUBLE DOUBLE}, {@link #ARRAY
|
||||
* ARRAY}, {@link #OBJECT OBJECT} or {@link #METHOD METHOD}.
|
||||
*/
|
||||
public int getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of dimensions of this array type. This method should
|
||||
* only be used for an array type.
|
||||
* Returns the number of dimensions of this array type. This method should only be used for an array type.
|
||||
*
|
||||
* @return the number of dimensions of this array type.
|
||||
*/
|
||||
@@ -558,8 +465,7 @@ public class Type {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the elements of this array type. This method should
|
||||
* only be used for an array type.
|
||||
* Returns the type of the elements of this array type. This method should only be used for an array type.
|
||||
*
|
||||
* @return Returns the type of the elements of this array type.
|
||||
*/
|
||||
@@ -568,49 +474,47 @@ public class Type {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the binary name of the class corresponding to this type. This
|
||||
* method must not be used on method types.
|
||||
* Returns the binary name of the class corresponding to this type. This method must not be used on method types.
|
||||
*
|
||||
* @return the binary name of the class corresponding to this type.
|
||||
*/
|
||||
public String getClassName() {
|
||||
switch (sort) {
|
||||
case VOID:
|
||||
return "void";
|
||||
case BOOLEAN:
|
||||
return "boolean";
|
||||
case CHAR:
|
||||
return "char";
|
||||
case BYTE:
|
||||
return "byte";
|
||||
case SHORT:
|
||||
return "short";
|
||||
case INT:
|
||||
return "int";
|
||||
case FLOAT:
|
||||
return "float";
|
||||
case LONG:
|
||||
return "long";
|
||||
case DOUBLE:
|
||||
return "double";
|
||||
case ARRAY:
|
||||
StringBuilder sb = new StringBuilder(getElementType().getClassName());
|
||||
for (int i = getDimensions(); i > 0; --i) {
|
||||
sb.append("[]");
|
||||
}
|
||||
return sb.toString();
|
||||
case OBJECT:
|
||||
return new String(buf, off, len).replace('/', '.');
|
||||
default:
|
||||
return null;
|
||||
case VOID:
|
||||
return "void";
|
||||
case BOOLEAN:
|
||||
return "boolean";
|
||||
case CHAR:
|
||||
return "char";
|
||||
case BYTE:
|
||||
return "byte";
|
||||
case SHORT:
|
||||
return "short";
|
||||
case INT:
|
||||
return "int";
|
||||
case FLOAT:
|
||||
return "float";
|
||||
case LONG:
|
||||
return "long";
|
||||
case DOUBLE:
|
||||
return "double";
|
||||
case ARRAY:
|
||||
StringBuilder sb = new StringBuilder(getElementType().getClassName());
|
||||
for (int i = getDimensions(); i > 0; --i) {
|
||||
sb.append("[]");
|
||||
}
|
||||
return sb.toString();
|
||||
case OBJECT:
|
||||
return new String(buf, off, len).replace('/', '.');
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the internal name of the class corresponding to this object or
|
||||
* array type. The internal name of a class is its fully qualified name (as
|
||||
* returned by Class.getName(), where '.' are replaced by '/'. This method
|
||||
* should only be used for an object or array type.
|
||||
* Returns the internal name of the class corresponding to this object or array type. The internal name of a class
|
||||
* is its fully qualified name (as returned by Class.getName(), where '.' are replaced by '/'. This method should
|
||||
* only be used for an object or array type.
|
||||
*
|
||||
* @return the internal name of the class corresponding to this object type.
|
||||
*/
|
||||
@@ -619,8 +523,7 @@ public class Type {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the argument types of methods of this type. This method should
|
||||
* only be used for method types.
|
||||
* Returns the argument types of methods of this type. This method should only be used for method types.
|
||||
*
|
||||
* @return the argument types of methods of this type.
|
||||
*/
|
||||
@@ -629,8 +532,7 @@ public class Type {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the return type of methods of this type. This method should only
|
||||
* be used for method types.
|
||||
* Returns the return type of methods of this type. This method should only be used for method types.
|
||||
*
|
||||
* @return the return type of methods of this type.
|
||||
*/
|
||||
@@ -639,15 +541,13 @@ public class Type {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the arguments and of the return value of methods of
|
||||
* this type. This method should only be used for method types.
|
||||
* Returns the size of the arguments and of the return value of methods of this type. This method should only be
|
||||
* used for method types.
|
||||
*
|
||||
* @return the size of the arguments (plus one for the implicit this
|
||||
* argument), argSize, and the size of the return value, retSize,
|
||||
* packed into a single
|
||||
* int i = <tt>(argSize << 2) | retSize</tt>
|
||||
* (argSize is therefore equal to <tt>i >> 2</tt>,
|
||||
* and retSize to <tt>i & 0x03</tt>).
|
||||
* @return the size of the arguments (plus one for the implicit this argument), argSize, and the size of the return
|
||||
* value, retSize, packed into a single int i = <tt>(argSize << 2) | retSize</tt> (argSize
|
||||
* is therefore equal to <tt>i >> 2</tt>, and retSize to <tt>i &
|
||||
* 0x03</tt>).
|
||||
*/
|
||||
public int getArgumentsAndReturnSizes() {
|
||||
return getArgumentsAndReturnSizes(getDescriptor());
|
||||
@@ -669,18 +569,13 @@ public class Type {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the descriptor corresponding to the given argument and return
|
||||
* types.
|
||||
* Returns the descriptor corresponding to the given argument and return types.
|
||||
*
|
||||
* @param returnType
|
||||
* the return type of the method.
|
||||
* @param argumentTypes
|
||||
* the argument types of the method.
|
||||
* @return the descriptor corresponding to the given argument and return
|
||||
* types.
|
||||
* @param returnType the return type of the method.
|
||||
* @param argumentTypes the argument types of the method.
|
||||
* @return the descriptor corresponding to the given argument and return types.
|
||||
*/
|
||||
public static String getMethodDescriptor(final Type returnType,
|
||||
final Type... argumentTypes) {
|
||||
public static String getMethodDescriptor(final Type returnType, final Type... argumentTypes) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append('(');
|
||||
for (int i = 0; i < argumentTypes.length; ++i) {
|
||||
@@ -692,11 +587,9 @@ public class Type {
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the descriptor corresponding to this Java type to the given
|
||||
* string buffer.
|
||||
* Appends the descriptor corresponding to this Java type to the given string buffer.
|
||||
*
|
||||
* @param buf
|
||||
* the string buffer to which the descriptor must be appended.
|
||||
* @param buf the string buffer to which the descriptor must be appended.
|
||||
*/
|
||||
private void getDescriptor(final StringBuilder buf) {
|
||||
if (this.buf == null) {
|
||||
@@ -718,12 +611,10 @@ public class Type {
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the internal name of the given class. The internal name of a
|
||||
* class is its fully qualified name, as returned by Class.getName(), where
|
||||
* '.' are replaced by '/'.
|
||||
* Returns the internal name of the given class. The internal name of a class is its fully qualified name, as
|
||||
* returned by Class.getName(), where '.' are replaced by '/'.
|
||||
*
|
||||
* @param c
|
||||
* an object or array class.
|
||||
* @param c an object or array class.
|
||||
* @return the internal name of the given class.
|
||||
*/
|
||||
public static String getInternalName(final Class<?> c) {
|
||||
@@ -733,8 +624,7 @@ public class Type {
|
||||
/**
|
||||
* Returns the descriptor corresponding to the given Java type.
|
||||
*
|
||||
* @param c
|
||||
* an object class, a primitive class or an array class.
|
||||
* @param c an object class, a primitive class or an array class.
|
||||
* @return the descriptor corresponding to the given class.
|
||||
*/
|
||||
public static String getDescriptor(final Class<?> c) {
|
||||
@@ -746,8 +636,7 @@ public class Type {
|
||||
/**
|
||||
* Returns the descriptor corresponding to the given constructor.
|
||||
*
|
||||
* @param c
|
||||
* a {@link Constructor Constructor} object.
|
||||
* @param c a {@link Constructor Constructor} object.
|
||||
* @return the descriptor of the given constructor.
|
||||
*/
|
||||
public static String getConstructorDescriptor(final Constructor<?> c) {
|
||||
@@ -763,8 +652,7 @@ public class Type {
|
||||
/**
|
||||
* Returns the descriptor corresponding to the given method.
|
||||
*
|
||||
* @param m
|
||||
* a {@link Method Method} object.
|
||||
* @param m a {@link Method Method} object.
|
||||
* @return the descriptor of the given method.
|
||||
*/
|
||||
public static String getMethodDescriptor(final Method m) {
|
||||
@@ -782,10 +670,8 @@ public class Type {
|
||||
/**
|
||||
* Appends the descriptor of the given class to the given string buffer.
|
||||
*
|
||||
* @param buf
|
||||
* the string buffer to which the descriptor must be appended.
|
||||
* @param c
|
||||
* the class whose descriptor must be computed.
|
||||
* @param buf the string buffer to which the descriptor must be appended.
|
||||
* @param c the class whose descriptor must be computed.
|
||||
*/
|
||||
private static void getDescriptor(final StringBuilder buf, final Class<?> c) {
|
||||
Class<?> d = c;
|
||||
@@ -808,7 +694,7 @@ public class Type {
|
||||
car = 'D';
|
||||
} else if (d == Float.TYPE) {
|
||||
car = 'F';
|
||||
} else /* if (d == Long.TYPE) */{
|
||||
} else /* if (d == Long.TYPE) */ {
|
||||
car = 'J';
|
||||
}
|
||||
buf.append(car);
|
||||
@@ -835,11 +721,10 @@ public class Type {
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the size of values of this type. This method must not be used for
|
||||
* method types.
|
||||
* Returns the size of values of this type. This method must not be used for method types.
|
||||
*
|
||||
* @return the size of values of this type, i.e., 2 for <tt>long</tt> and
|
||||
* <tt>double</tt>, 0 for <tt>void</tt> and 1 otherwise.
|
||||
* <tt>double</tt>, 0 for <tt>void</tt> and 1 otherwise.
|
||||
*/
|
||||
public int getSize() {
|
||||
// the size is in byte 0 of 'off' for primitive types (buf == null)
|
||||
@@ -847,16 +732,13 @@ public class Type {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a JVM instruction opcode adapted to this Java type. This method
|
||||
* must not be used for method types.
|
||||
* Returns a JVM instruction opcode adapted to this Java type. This method must not be used for method types.
|
||||
*
|
||||
* @param opcode
|
||||
* a JVM instruction opcode. This opcode must be one of ILOAD,
|
||||
* ISTORE, IALOAD, IASTORE, IADD, ISUB, IMUL, IDIV, IREM, INEG,
|
||||
* ISHL, ISHR, IUSHR, IAND, IOR, IXOR and IRETURN.
|
||||
* @return an opcode that is similar to the given opcode, but adapted to
|
||||
* this Java type. For example, if this type is <tt>float</tt> and
|
||||
* <tt>opcode</tt> is IRETURN, this method returns FRETURN.
|
||||
* @param opcode a JVM instruction opcode. This opcode must be one of ILOAD, ISTORE, IALOAD, IASTORE, IADD, ISUB,
|
||||
* IMUL, IDIV, IREM, INEG, ISHL, ISHR, IUSHR, IAND, IOR, IXOR and IRETURN.
|
||||
* @return an opcode that is similar to the given opcode, but adapted to this Java type. For example, if this type
|
||||
* is <tt>float</tt> and <tt>opcode</tt> is IRETURN, this method returns
|
||||
* FRETURN.
|
||||
*/
|
||||
public int getOpcode(final int opcode) {
|
||||
if (opcode == Opcodes.IALOAD || opcode == Opcodes.IASTORE) {
|
||||
@@ -877,8 +759,7 @@ public class Type {
|
||||
/**
|
||||
* Tests if the given object is equal to this type.
|
||||
*
|
||||
* @param o
|
||||
* the object to be compared to this type.
|
||||
* @param o the object to be compared to this type.
|
||||
* @return <tt>true</tt> if the given object is equal to this type.
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -60,55 +60,35 @@
|
||||
package org.redkale.asm;
|
||||
|
||||
/**
|
||||
* The path to a type argument, wildcard bound, array element type, or static
|
||||
* inner type within an enclosing type.
|
||||
* The path to a type argument, wildcard bound, array element type, or static inner type within an enclosing type.
|
||||
*
|
||||
* @author Eric Bruneton
|
||||
*/
|
||||
public class TypePath {
|
||||
|
||||
/**
|
||||
* A type path step that steps into the element type of an array type. See
|
||||
* {@link #getStep getStep}.
|
||||
*/
|
||||
public final static int ARRAY_ELEMENT = 0;
|
||||
/** A type path step that steps into the element type of an array type. See {@link #getStep getStep}. */
|
||||
public static final int ARRAY_ELEMENT = 0;
|
||||
|
||||
/**
|
||||
* A type path step that steps into the nested type of a class type. See
|
||||
* {@link #getStep getStep}.
|
||||
*/
|
||||
public final static int INNER_TYPE = 1;
|
||||
/** A type path step that steps into the nested type of a class type. See {@link #getStep getStep}. */
|
||||
public static final int INNER_TYPE = 1;
|
||||
|
||||
/**
|
||||
* A type path step that steps into the bound of a wildcard type. See
|
||||
* {@link #getStep getStep}.
|
||||
*/
|
||||
public final static int WILDCARD_BOUND = 2;
|
||||
/** A type path step that steps into the bound of a wildcard type. See {@link #getStep getStep}. */
|
||||
public static final int WILDCARD_BOUND = 2;
|
||||
|
||||
/**
|
||||
* A type path step that steps into a type argument of a generic type. See
|
||||
* {@link #getStep getStep}.
|
||||
*/
|
||||
public final static int TYPE_ARGUMENT = 3;
|
||||
/** A type path step that steps into a type argument of a generic type. See {@link #getStep getStep}. */
|
||||
public static final int TYPE_ARGUMENT = 3;
|
||||
|
||||
/**
|
||||
* The byte array where the path is stored, in Java class file format.
|
||||
*/
|
||||
/** The byte array where the path is stored, in Java class file format. */
|
||||
byte[] b;
|
||||
|
||||
/**
|
||||
* The offset of the first byte of the type path in 'b'.
|
||||
*/
|
||||
/** The offset of the first byte of the type path in 'b'. */
|
||||
int offset;
|
||||
|
||||
/**
|
||||
* Creates a new type path.
|
||||
*
|
||||
* @param b
|
||||
* the byte array containing the type path in Java class file
|
||||
* format.
|
||||
* @param offset
|
||||
* the offset of the first byte of the type path in 'b'.
|
||||
* @param b the byte array containing the type path in Java class file format.
|
||||
* @param offset the offset of the first byte of the type path in 'b'.
|
||||
*/
|
||||
TypePath(byte[] b, int offset) {
|
||||
this.b = b;
|
||||
@@ -127,37 +107,29 @@ public class TypePath {
|
||||
/**
|
||||
* Returns the value of the given step of this path.
|
||||
*
|
||||
* @param index
|
||||
* an index between 0 and {@link #getLength()}, exclusive.
|
||||
* @return {@link #ARRAY_ELEMENT ARRAY_ELEMENT}, {@link #INNER_TYPE
|
||||
* INNER_TYPE}, {@link #WILDCARD_BOUND WILDCARD_BOUND}, or
|
||||
* {@link #TYPE_ARGUMENT TYPE_ARGUMENT}.
|
||||
* @param index an index between 0 and {@link #getLength()}, exclusive.
|
||||
* @return {@link #ARRAY_ELEMENT ARRAY_ELEMENT}, {@link #INNER_TYPE INNER_TYPE}, {@link #WILDCARD_BOUND
|
||||
* WILDCARD_BOUND}, or {@link #TYPE_ARGUMENT TYPE_ARGUMENT}.
|
||||
*/
|
||||
public int getStep(int index) {
|
||||
return b[offset + 2 * index + 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the type argument that the given step is stepping
|
||||
* into. This method should only be used for steps whose value is
|
||||
* {@link #TYPE_ARGUMENT TYPE_ARGUMENT}.
|
||||
* Returns the index of the type argument that the given step is stepping into. This method should only be used for
|
||||
* steps whose value is {@link #TYPE_ARGUMENT TYPE_ARGUMENT}.
|
||||
*
|
||||
* @param index
|
||||
* an index between 0 and {@link #getLength()}, exclusive.
|
||||
* @return the index of the type argument that the given step is stepping
|
||||
* into.
|
||||
* @param index an index between 0 and {@link #getLength()}, exclusive.
|
||||
* @return the index of the type argument that the given step is stepping into.
|
||||
*/
|
||||
public int getStepArgument(int index) {
|
||||
return b[offset + 2 * index + 2];
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a type path in string form, in the format used by
|
||||
* {@link #toString()}, into a TypePath object.
|
||||
* Converts a type path in string form, in the format used by {@link #toString()}, into a TypePath object.
|
||||
*
|
||||
* @param typePath
|
||||
* a type path in string form, in the format used by
|
||||
* {@link #toString()}. May be null or empty.
|
||||
* @param typePath a type path in string form, in the format used by {@link #toString()}. May be null or empty.
|
||||
* @return the corresponding TypePath object, or null if the path is empty.
|
||||
*/
|
||||
public static TypePath fromString(final String typePath) {
|
||||
@@ -167,7 +139,7 @@ public class TypePath {
|
||||
int n = typePath.length();
|
||||
ByteVector out = new ByteVector(n);
|
||||
out.putByte(0);
|
||||
for (int i = 0; i < n;) {
|
||||
for (int i = 0; i < n; ) {
|
||||
char c = typePath.charAt(i++);
|
||||
if (c == '[') {
|
||||
out.put11(ARRAY_ELEMENT, 0);
|
||||
@@ -192,11 +164,9 @@ public class TypePath {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this type path. {@link #ARRAY_ELEMENT
|
||||
* ARRAY_ELEMENT} steps are represented with '[', {@link #INNER_TYPE
|
||||
* INNER_TYPE} steps with '.', {@link #WILDCARD_BOUND WILDCARD_BOUND} steps
|
||||
* with '*' and {@link #TYPE_ARGUMENT TYPE_ARGUMENT} steps with their type
|
||||
* argument index in decimal form followed by ';'.
|
||||
* Returns a string representation of this type path. {@link #ARRAY_ELEMENT ARRAY_ELEMENT} steps are represented
|
||||
* with '[', {@link #INNER_TYPE INNER_TYPE} steps with '.', {@link #WILDCARD_BOUND WILDCARD_BOUND} steps with '*'
|
||||
* and {@link #TYPE_ARGUMENT TYPE_ARGUMENT} steps with their type argument index in decimal form followed by ';'.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
@@ -204,20 +174,20 @@ public class TypePath {
|
||||
StringBuilder result = new StringBuilder(length * 2);
|
||||
for (int i = 0; i < length; ++i) {
|
||||
switch (getStep(i)) {
|
||||
case ARRAY_ELEMENT:
|
||||
result.append('[');
|
||||
break;
|
||||
case INNER_TYPE:
|
||||
result.append('.');
|
||||
break;
|
||||
case WILDCARD_BOUND:
|
||||
result.append('*');
|
||||
break;
|
||||
case TYPE_ARGUMENT:
|
||||
result.append(getStepArgument(i)).append(';');
|
||||
break;
|
||||
default:
|
||||
result.append('_');
|
||||
case ARRAY_ELEMENT:
|
||||
result.append('[');
|
||||
break;
|
||||
case INNER_TYPE:
|
||||
result.append('.');
|
||||
break;
|
||||
case WILDCARD_BOUND:
|
||||
result.append('*');
|
||||
break;
|
||||
case TYPE_ARGUMENT:
|
||||
result.append(getStepArgument(i)).append(';');
|
||||
break;
|
||||
default:
|
||||
result.append('_');
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
|
||||
@@ -60,160 +60,136 @@
|
||||
package org.redkale.asm;
|
||||
|
||||
/**
|
||||
* A reference to a type appearing in a class, field or method declaration, or
|
||||
* on an instruction. Such a reference designates the part of the class where
|
||||
* the referenced type is appearing (e.g. an 'extends', 'implements' or 'throws'
|
||||
* clause, a 'new' instruction, a 'catch' clause, a type cast, a local variable
|
||||
* declaration, etc).
|
||||
* A reference to a type appearing in a class, field or method declaration, or on an instruction. Such a reference
|
||||
* designates the part of the class where the referenced type is appearing (e.g. an 'extends', 'implements' or 'throws'
|
||||
* clause, a 'new' instruction, a 'catch' clause, a type cast, a local variable declaration, etc).
|
||||
*
|
||||
* @author Eric Bruneton
|
||||
*/
|
||||
public class TypeReference {
|
||||
|
||||
/**
|
||||
* The sort of type references that target a type parameter of a generic
|
||||
* class. See {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int CLASS_TYPE_PARAMETER = 0x00;
|
||||
/** The sort of type references that target a type parameter of a generic class. See {@link #getSort getSort}. */
|
||||
public static final int CLASS_TYPE_PARAMETER = 0x00;
|
||||
|
||||
/** The sort of type references that target a type parameter of a generic method. See {@link #getSort getSort}. */
|
||||
public static final int METHOD_TYPE_PARAMETER = 0x01;
|
||||
|
||||
/**
|
||||
* The sort of type references that target a type parameter of a generic
|
||||
* method. See {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int METHOD_TYPE_PARAMETER = 0x01;
|
||||
|
||||
/**
|
||||
* The sort of type references that target the super class of a class or one
|
||||
* of the interfaces it implements. See {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int CLASS_EXTENDS = 0x10;
|
||||
|
||||
/**
|
||||
* The sort of type references that target a bound of a type parameter of a
|
||||
* generic class. See {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int CLASS_TYPE_PARAMETER_BOUND = 0x11;
|
||||
|
||||
/**
|
||||
* The sort of type references that target a bound of a type parameter of a
|
||||
* generic method. See {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int METHOD_TYPE_PARAMETER_BOUND = 0x12;
|
||||
|
||||
/**
|
||||
* The sort of type references that target the type of a field. See
|
||||
* The sort of type references that target the super class of a class or one of the interfaces it implements. See
|
||||
* {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int FIELD = 0x13;
|
||||
public static final int CLASS_EXTENDS = 0x10;
|
||||
|
||||
/**
|
||||
* The sort of type references that target the return type of a method. See
|
||||
* The sort of type references that target a bound of a type parameter of a generic class. See {@link #getSort
|
||||
* getSort}.
|
||||
*/
|
||||
public static final int CLASS_TYPE_PARAMETER_BOUND = 0x11;
|
||||
|
||||
/**
|
||||
* The sort of type references that target a bound of a type parameter of a generic method. See {@link #getSort
|
||||
* getSort}.
|
||||
*/
|
||||
public static final int METHOD_TYPE_PARAMETER_BOUND = 0x12;
|
||||
|
||||
/** The sort of type references that target the type of a field. See {@link #getSort getSort}. */
|
||||
public static final int FIELD = 0x13;
|
||||
|
||||
/** The sort of type references that target the return type of a method. See {@link #getSort getSort}. */
|
||||
public static final int METHOD_RETURN = 0x14;
|
||||
|
||||
/** The sort of type references that target the receiver type of a method. See {@link #getSort getSort}. */
|
||||
public static final int METHOD_RECEIVER = 0x15;
|
||||
|
||||
/**
|
||||
* The sort of type references that target the type of a formal parameter of a method. See {@link #getSort getSort}.
|
||||
*/
|
||||
public static final int METHOD_FORMAL_PARAMETER = 0x16;
|
||||
|
||||
/**
|
||||
* The sort of type references that target the type of an exception declared in the throws clause of a method. See
|
||||
* {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int METHOD_RETURN = 0x14;
|
||||
public static final int THROWS = 0x17;
|
||||
|
||||
/**
|
||||
* The sort of type references that target the receiver type of a method.
|
||||
* See {@link #getSort getSort}.
|
||||
* The sort of type references that target the type of a local variable in a method. See {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int METHOD_RECEIVER = 0x15;
|
||||
public static final int LOCAL_VARIABLE = 0x40;
|
||||
|
||||
/**
|
||||
* The sort of type references that target the type of a formal parameter of
|
||||
* a method. See {@link #getSort getSort}.
|
||||
* The sort of type references that target the type of a resource variable in a method. See {@link #getSort
|
||||
* getSort}.
|
||||
*/
|
||||
public final static int METHOD_FORMAL_PARAMETER = 0x16;
|
||||
public static final int RESOURCE_VARIABLE = 0x41;
|
||||
|
||||
/**
|
||||
* The sort of type references that target the type of an exception declared
|
||||
* in the throws clause of a method. See {@link #getSort getSort}.
|
||||
* The sort of type references that target the type of the exception of a 'catch' clause in a method. See
|
||||
* {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int THROWS = 0x17;
|
||||
public static final int EXCEPTION_PARAMETER = 0x42;
|
||||
|
||||
/**
|
||||
* The sort of type references that target the type of a local variable in a
|
||||
* method. See {@link #getSort getSort}.
|
||||
* The sort of type references that target the type declared in an 'instanceof' instruction. See {@link #getSort
|
||||
* getSort}.
|
||||
*/
|
||||
public final static int LOCAL_VARIABLE = 0x40;
|
||||
public static final int INSTANCEOF = 0x43;
|
||||
|
||||
/**
|
||||
* The sort of type references that target the type of a resource variable
|
||||
* in a method. See {@link #getSort getSort}.
|
||||
* The sort of type references that target the type of the object created by a 'new' instruction. See
|
||||
* {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int RESOURCE_VARIABLE = 0x41;
|
||||
public static final int NEW = 0x44;
|
||||
|
||||
/**
|
||||
* The sort of type references that target the type of the exception of a
|
||||
* 'catch' clause in a method. See {@link #getSort getSort}.
|
||||
* The sort of type references that target the receiver type of a constructor reference. See {@link #getSort
|
||||
* getSort}.
|
||||
*/
|
||||
public final static int EXCEPTION_PARAMETER = 0x42;
|
||||
public static final int CONSTRUCTOR_REFERENCE = 0x45;
|
||||
|
||||
/**
|
||||
* The sort of type references that target the type declared in an
|
||||
* 'instanceof' instruction. See {@link #getSort getSort}.
|
||||
* The sort of type references that target the receiver type of a method reference. See {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int INSTANCEOF = 0x43;
|
||||
public static final int METHOD_REFERENCE = 0x46;
|
||||
|
||||
/**
|
||||
* The sort of type references that target the type of the object created by
|
||||
* a 'new' instruction. See {@link #getSort getSort}.
|
||||
* The sort of type references that target the type declared in an explicit or implicit cast instruction. See
|
||||
* {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int NEW = 0x44;
|
||||
public static final int CAST = 0x47;
|
||||
|
||||
/**
|
||||
* The sort of type references that target the receiver type of a
|
||||
* constructor reference. See {@link #getSort getSort}.
|
||||
* The sort of type references that target a type parameter of a generic constructor in a constructor call. See
|
||||
* {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int CONSTRUCTOR_REFERENCE = 0x45;
|
||||
public static final int CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT = 0x48;
|
||||
|
||||
/**
|
||||
* The sort of type references that target the receiver type of a method
|
||||
* reference. See {@link #getSort getSort}.
|
||||
* The sort of type references that target a type parameter of a generic method in a method call. See
|
||||
* {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int METHOD_REFERENCE = 0x46;
|
||||
public static final int METHOD_INVOCATION_TYPE_ARGUMENT = 0x49;
|
||||
|
||||
/**
|
||||
* The sort of type references that target the type declared in an explicit
|
||||
* or implicit cast instruction. See {@link #getSort getSort}.
|
||||
* The sort of type references that target a type parameter of a generic constructor in a constructor reference. See
|
||||
* {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int CAST = 0x47;
|
||||
public static final int CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT = 0x4A;
|
||||
|
||||
/**
|
||||
* The sort of type references that target a type parameter of a generic
|
||||
* constructor in a constructor call. See {@link #getSort getSort}.
|
||||
* The sort of type references that target a type parameter of a generic method in a method reference. See
|
||||
* {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT = 0x48;
|
||||
public static final int METHOD_REFERENCE_TYPE_ARGUMENT = 0x4B;
|
||||
|
||||
/**
|
||||
* The sort of type references that target a type parameter of a generic
|
||||
* method in a method call. See {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int METHOD_INVOCATION_TYPE_ARGUMENT = 0x49;
|
||||
|
||||
/**
|
||||
* The sort of type references that target a type parameter of a generic
|
||||
* constructor in a constructor reference. See {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT = 0x4A;
|
||||
|
||||
/**
|
||||
* The sort of type references that target a type parameter of a generic
|
||||
* method in a method reference. See {@link #getSort getSort}.
|
||||
*/
|
||||
public final static int METHOD_REFERENCE_TYPE_ARGUMENT = 0x4B;
|
||||
|
||||
/**
|
||||
* The type reference value in Java class file format.
|
||||
*/
|
||||
/** The type reference value in Java class file format. */
|
||||
private int value;
|
||||
|
||||
/**
|
||||
* Creates a new TypeReference.
|
||||
*
|
||||
* @param typeRef
|
||||
* the int encoded value of the type reference, as received in a
|
||||
* visit method related to type annotations, like
|
||||
* visitTypeAnnotation.
|
||||
* @param typeRef the int encoded value of the type reference, as received in a visit method related to type
|
||||
* annotations, like visitTypeAnnotation.
|
||||
*/
|
||||
public TypeReference(int typeRef) {
|
||||
this.value = typeRef;
|
||||
@@ -222,14 +198,10 @@ public class TypeReference {
|
||||
/**
|
||||
* Returns a type reference of the given sort.
|
||||
*
|
||||
* @param sort
|
||||
* {@link #FIELD FIELD}, {@link #METHOD_RETURN METHOD_RETURN},
|
||||
* {@link #METHOD_RECEIVER METHOD_RECEIVER},
|
||||
* {@link #LOCAL_VARIABLE LOCAL_VARIABLE},
|
||||
* {@link #RESOURCE_VARIABLE RESOURCE_VARIABLE},
|
||||
* {@link #INSTANCEOF INSTANCEOF}, {@link #NEW NEW},
|
||||
* {@link #CONSTRUCTOR_REFERENCE CONSTRUCTOR_REFERENCE}, or
|
||||
* {@link #METHOD_REFERENCE METHOD_REFERENCE}.
|
||||
* @param sort {@link #FIELD FIELD}, {@link #METHOD_RETURN METHOD_RETURN}, {@link #METHOD_RECEIVER METHOD_RECEIVER},
|
||||
* {@link #LOCAL_VARIABLE LOCAL_VARIABLE}, {@link #RESOURCE_VARIABLE RESOURCE_VARIABLE}, {@link #INSTANCEOF
|
||||
* INSTANCEOF}, {@link #NEW NEW}, {@link #CONSTRUCTOR_REFERENCE CONSTRUCTOR_REFERENCE}, or
|
||||
* {@link #METHOD_REFERENCE METHOD_REFERENCE}.
|
||||
* @return a type reference of the given sort.
|
||||
*/
|
||||
public static TypeReference newTypeReference(int sort) {
|
||||
@@ -239,45 +211,33 @@ public class TypeReference {
|
||||
/**
|
||||
* Returns a reference to a type parameter of a generic class or method.
|
||||
*
|
||||
* @param sort
|
||||
* {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER} or
|
||||
* {@link #METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER}.
|
||||
* @param paramIndex
|
||||
* the type parameter index.
|
||||
* @param sort {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER} or {@link #METHOD_TYPE_PARAMETER
|
||||
* METHOD_TYPE_PARAMETER}.
|
||||
* @param paramIndex the type parameter index.
|
||||
* @return a reference to the given generic class or method type parameter.
|
||||
*/
|
||||
public static TypeReference newTypeParameterReference(int sort,
|
||||
int paramIndex) {
|
||||
public static TypeReference newTypeParameterReference(int sort, int paramIndex) {
|
||||
return new TypeReference((sort << 24) | (paramIndex << 16));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to a type parameter bound of a generic class or
|
||||
* method.
|
||||
* Returns a reference to a type parameter bound of a generic class or method.
|
||||
*
|
||||
* @param sort
|
||||
* {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER} or
|
||||
* {@link #METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER}.
|
||||
* @param paramIndex
|
||||
* the type parameter index.
|
||||
* @param boundIndex
|
||||
* the type bound index within the above type parameters.
|
||||
* @return a reference to the given generic class or method type parameter
|
||||
* bound.
|
||||
* @param sort {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER} or {@link #METHOD_TYPE_PARAMETER
|
||||
* METHOD_TYPE_PARAMETER}.
|
||||
* @param paramIndex the type parameter index.
|
||||
* @param boundIndex the type bound index within the above type parameters.
|
||||
* @return a reference to the given generic class or method type parameter bound.
|
||||
*/
|
||||
public static TypeReference newTypeParameterBoundReference(int sort,
|
||||
int paramIndex, int boundIndex) {
|
||||
return new TypeReference((sort << 24) | (paramIndex << 16)
|
||||
| (boundIndex << 8));
|
||||
public static TypeReference newTypeParameterBoundReference(int sort, int paramIndex, int boundIndex) {
|
||||
return new TypeReference((sort << 24) | (paramIndex << 16) | (boundIndex << 8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the super class or to an interface of the
|
||||
* 'implements' clause of a class.
|
||||
* Returns a reference to the super class or to an interface of the 'implements' clause of a class.
|
||||
*
|
||||
* @param itfIndex
|
||||
* the index of an interface in the 'implements' clause of a
|
||||
* class, or -1 to reference the super class of the class.
|
||||
* @param itfIndex the index of an interface in the 'implements' clause of a class, or -1 to reference the super
|
||||
* class of the class.
|
||||
* @return a reference to the given super type of a class.
|
||||
*/
|
||||
public static TypeReference newSuperTypeReference(int itfIndex) {
|
||||
@@ -288,23 +248,17 @@ public class TypeReference {
|
||||
/**
|
||||
* Returns a reference to the type of a formal parameter of a method.
|
||||
*
|
||||
* @param paramIndex
|
||||
* the formal parameter index.
|
||||
*
|
||||
* @param paramIndex the formal parameter index.
|
||||
* @return a reference to the type of the given method formal parameter.
|
||||
*/
|
||||
public static TypeReference newFormalParameterReference(int paramIndex) {
|
||||
return new TypeReference((METHOD_FORMAL_PARAMETER << 24)
|
||||
| (paramIndex << 16));
|
||||
return new TypeReference((METHOD_FORMAL_PARAMETER << 24) | (paramIndex << 16));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the type of an exception, in a 'throws' clause of
|
||||
* a method.
|
||||
*
|
||||
* @param exceptionIndex
|
||||
* the index of an exception in a 'throws' clause of a method.
|
||||
* Returns a reference to the type of an exception, in a 'throws' clause of a method.
|
||||
*
|
||||
* @param exceptionIndex the index of an exception in a 'throws' clause of a method.
|
||||
* @return a reference to the type of the given exception.
|
||||
*/
|
||||
public static TypeReference newExceptionReference(int exceptionIndex) {
|
||||
@@ -312,37 +266,25 @@ public class TypeReference {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the type of the exception declared in a 'catch'
|
||||
* clause of a method.
|
||||
*
|
||||
* @param tryCatchBlockIndex
|
||||
* the index of a try catch block (using the order in which they
|
||||
* are visited with visitTryCatchBlock).
|
||||
* Returns a reference to the type of the exception declared in a 'catch' clause of a method.
|
||||
*
|
||||
* @param tryCatchBlockIndex the index of a try catch block (using the order in which they are visited with
|
||||
* visitTryCatchBlock).
|
||||
* @return a reference to the type of the given exception.
|
||||
*/
|
||||
public static TypeReference newTryCatchReference(int tryCatchBlockIndex) {
|
||||
return new TypeReference((EXCEPTION_PARAMETER << 24)
|
||||
| (tryCatchBlockIndex << 8));
|
||||
return new TypeReference((EXCEPTION_PARAMETER << 24) | (tryCatchBlockIndex << 8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the type of a type argument in a constructor or
|
||||
* method call or reference.
|
||||
*
|
||||
* @param sort
|
||||
* {@link #CAST CAST},
|
||||
* {@link #CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
|
||||
* CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT},
|
||||
* {@link #METHOD_INVOCATION_TYPE_ARGUMENT
|
||||
* METHOD_INVOCATION_TYPE_ARGUMENT},
|
||||
* {@link #CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
|
||||
* CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or
|
||||
* {@link #METHOD_REFERENCE_TYPE_ARGUMENT
|
||||
* METHOD_REFERENCE_TYPE_ARGUMENT}.
|
||||
* @param argIndex
|
||||
* the type argument index.
|
||||
* Returns a reference to the type of a type argument in a constructor or method call or reference.
|
||||
*
|
||||
* @param sort {@link #CAST CAST}, {@link #CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
|
||||
* CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT}, {@link #METHOD_INVOCATION_TYPE_ARGUMENT
|
||||
* METHOD_INVOCATION_TYPE_ARGUMENT}, {@link #CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
|
||||
* CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or {@link #METHOD_REFERENCE_TYPE_ARGUMENT
|
||||
* METHOD_REFERENCE_TYPE_ARGUMENT}.
|
||||
* @param argIndex the type argument index.
|
||||
* @return a reference to the type of the given type argument.
|
||||
*/
|
||||
public static TypeReference newTypeArgumentReference(int sort, int argIndex) {
|
||||
@@ -352,39 +294,27 @@ public class TypeReference {
|
||||
/**
|
||||
* Returns the sort of this type reference.
|
||||
*
|
||||
* @return {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER},
|
||||
* {@link #METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER},
|
||||
* {@link #CLASS_EXTENDS CLASS_EXTENDS},
|
||||
* {@link #CLASS_TYPE_PARAMETER_BOUND CLASS_TYPE_PARAMETER_BOUND},
|
||||
* {@link #METHOD_TYPE_PARAMETER_BOUND METHOD_TYPE_PARAMETER_BOUND},
|
||||
* {@link #FIELD FIELD}, {@link #METHOD_RETURN METHOD_RETURN},
|
||||
* {@link #METHOD_RECEIVER METHOD_RECEIVER},
|
||||
* {@link #METHOD_FORMAL_PARAMETER METHOD_FORMAL_PARAMETER},
|
||||
* {@link #THROWS THROWS}, {@link #LOCAL_VARIABLE LOCAL_VARIABLE},
|
||||
* {@link #RESOURCE_VARIABLE RESOURCE_VARIABLE},
|
||||
* {@link #EXCEPTION_PARAMETER EXCEPTION_PARAMETER},
|
||||
* {@link #INSTANCEOF INSTANCEOF}, {@link #NEW NEW},
|
||||
* {@link #CONSTRUCTOR_REFERENCE CONSTRUCTOR_REFERENCE},
|
||||
* {@link #METHOD_REFERENCE METHOD_REFERENCE}, {@link #CAST CAST},
|
||||
* {@link #CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
|
||||
* CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT},
|
||||
* {@link #METHOD_INVOCATION_TYPE_ARGUMENT
|
||||
* METHOD_INVOCATION_TYPE_ARGUMENT},
|
||||
* {@link #CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
|
||||
* CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or
|
||||
* {@link #METHOD_REFERENCE_TYPE_ARGUMENT
|
||||
* METHOD_REFERENCE_TYPE_ARGUMENT}.
|
||||
* @return {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER}, {@link #METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER},
|
||||
* {@link #CLASS_EXTENDS CLASS_EXTENDS}, {@link #CLASS_TYPE_PARAMETER_BOUND CLASS_TYPE_PARAMETER_BOUND},
|
||||
* {@link #METHOD_TYPE_PARAMETER_BOUND METHOD_TYPE_PARAMETER_BOUND}, {@link #FIELD FIELD}, {@link #METHOD_RETURN
|
||||
* METHOD_RETURN}, {@link #METHOD_RECEIVER METHOD_RECEIVER}, {@link #METHOD_FORMAL_PARAMETER
|
||||
* METHOD_FORMAL_PARAMETER}, {@link #THROWS THROWS}, {@link #LOCAL_VARIABLE LOCAL_VARIABLE},
|
||||
* {@link #RESOURCE_VARIABLE RESOURCE_VARIABLE}, {@link #EXCEPTION_PARAMETER EXCEPTION_PARAMETER},
|
||||
* {@link #INSTANCEOF INSTANCEOF}, {@link #NEW NEW}, {@link #CONSTRUCTOR_REFERENCE CONSTRUCTOR_REFERENCE},
|
||||
* {@link #METHOD_REFERENCE METHOD_REFERENCE}, {@link #CAST CAST}, {@link #CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
|
||||
* CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT}, {@link #METHOD_INVOCATION_TYPE_ARGUMENT
|
||||
* METHOD_INVOCATION_TYPE_ARGUMENT}, {@link #CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
|
||||
* CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or {@link #METHOD_REFERENCE_TYPE_ARGUMENT
|
||||
* METHOD_REFERENCE_TYPE_ARGUMENT}.
|
||||
*/
|
||||
public int getSort() {
|
||||
return value >>> 24;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the type parameter referenced by this type
|
||||
* reference. This method must only be used for type references whose sort
|
||||
* is {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER},
|
||||
* {@link #METHOD_TYPE_PARAMETER METHOD_TYPE_PARAMETER},
|
||||
* {@link #CLASS_TYPE_PARAMETER_BOUND CLASS_TYPE_PARAMETER_BOUND} or
|
||||
* Returns the index of the type parameter referenced by this type reference. This method must only be used for type
|
||||
* references whose sort is {@link #CLASS_TYPE_PARAMETER CLASS_TYPE_PARAMETER}, {@link #METHOD_TYPE_PARAMETER
|
||||
* METHOD_TYPE_PARAMETER}, {@link #CLASS_TYPE_PARAMETER_BOUND CLASS_TYPE_PARAMETER_BOUND} or
|
||||
* {@link #METHOD_TYPE_PARAMETER_BOUND METHOD_TYPE_PARAMETER_BOUND}.
|
||||
*
|
||||
* @return a type parameter index.
|
||||
@@ -394,11 +324,10 @@ public class TypeReference {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the type parameter bound, within the type parameter
|
||||
* {@link #getTypeParameterIndex}, referenced by this type reference. This
|
||||
* method must only be used for type references whose sort is
|
||||
* {@link #CLASS_TYPE_PARAMETER_BOUND CLASS_TYPE_PARAMETER_BOUND} or
|
||||
* {@link #METHOD_TYPE_PARAMETER_BOUND METHOD_TYPE_PARAMETER_BOUND}.
|
||||
* Returns the index of the type parameter bound, within the type parameter {@link #getTypeParameterIndex},
|
||||
* referenced by this type reference. This method must only be used for type references whose sort is
|
||||
* {@link #CLASS_TYPE_PARAMETER_BOUND CLASS_TYPE_PARAMETER_BOUND} or {@link #METHOD_TYPE_PARAMETER_BOUND
|
||||
* METHOD_TYPE_PARAMETER_BOUND}.
|
||||
*
|
||||
* @return a type parameter bound index.
|
||||
*/
|
||||
@@ -407,22 +336,19 @@ public class TypeReference {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the "super type" of a class that is referenced by
|
||||
* this type reference. This method must only be used for type references
|
||||
* whose sort is {@link #CLASS_EXTENDS CLASS_EXTENDS}.
|
||||
* Returns the index of the "super type" of a class that is referenced by this type reference. This method must only
|
||||
* be used for type references whose sort is {@link #CLASS_EXTENDS CLASS_EXTENDS}.
|
||||
*
|
||||
* @return the index of an interface in the 'implements' clause of a class,
|
||||
* or -1 if this type reference references the type of the super
|
||||
* class.
|
||||
* @return the index of an interface in the 'implements' clause of a class, or -1 if this type reference references
|
||||
* the type of the super class.
|
||||
*/
|
||||
public int getSuperTypeIndex() {
|
||||
return (short) ((value & 0x00FFFF00) >> 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the formal parameter whose type is referenced by
|
||||
* this type reference. This method must only be used for type references
|
||||
* whose sort is {@link #METHOD_FORMAL_PARAMETER METHOD_FORMAL_PARAMETER}.
|
||||
* Returns the index of the formal parameter whose type is referenced by this type reference. This method must only
|
||||
* be used for type references whose sort is {@link #METHOD_FORMAL_PARAMETER METHOD_FORMAL_PARAMETER}.
|
||||
*
|
||||
* @return a formal parameter index.
|
||||
*/
|
||||
@@ -431,9 +357,8 @@ public class TypeReference {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the exception, in a 'throws' clause of a method,
|
||||
* whose type is referenced by this type reference. This method must only be
|
||||
* used for type references whose sort is {@link #THROWS THROWS}.
|
||||
* Returns the index of the exception, in a 'throws' clause of a method, whose type is referenced by this type
|
||||
* reference. This method must only be used for type references whose sort is {@link #THROWS THROWS}.
|
||||
*
|
||||
* @return the index of an exception in the 'throws' clause of a method.
|
||||
*/
|
||||
@@ -442,10 +367,9 @@ public class TypeReference {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the try catch block (using the order in which they
|
||||
* are visited with visitTryCatchBlock), whose 'catch' type is referenced by
|
||||
* this type reference. This method must only be used for type references
|
||||
* whose sort is {@link #EXCEPTION_PARAMETER EXCEPTION_PARAMETER} .
|
||||
* Returns the index of the try catch block (using the order in which they are visited with visitTryCatchBlock),
|
||||
* whose 'catch' type is referenced by this type reference. This method must only be used for type references whose
|
||||
* sort is {@link #EXCEPTION_PARAMETER EXCEPTION_PARAMETER} .
|
||||
*
|
||||
* @return the index of an exception in the 'throws' clause of a method.
|
||||
*/
|
||||
@@ -454,13 +378,10 @@ public class TypeReference {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the type argument referenced by this type reference.
|
||||
* This method must only be used for type references whose sort is
|
||||
* {@link #CAST CAST}, {@link #CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
|
||||
* CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT},
|
||||
* {@link #METHOD_INVOCATION_TYPE_ARGUMENT METHOD_INVOCATION_TYPE_ARGUMENT},
|
||||
* {@link #CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT
|
||||
* CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or
|
||||
* Returns the index of the type argument referenced by this type reference. This method must only be used for type
|
||||
* references whose sort is {@link #CAST CAST}, {@link #CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT
|
||||
* CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT}, {@link #METHOD_INVOCATION_TYPE_ARGUMENT METHOD_INVOCATION_TYPE_ARGUMENT},
|
||||
* {@link #CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or
|
||||
* {@link #METHOD_REFERENCE_TYPE_ARGUMENT METHOD_REFERENCE_TYPE_ARGUMENT}.
|
||||
*
|
||||
* @return a type parameter index.
|
||||
@@ -470,8 +391,8 @@ public class TypeReference {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the int encoded value of this type reference, suitable for use in
|
||||
* visit methods related to type annotations, like visitTypeAnnotation.
|
||||
* Returns the int encoded value of this type reference, suitable for use in visit methods related to type
|
||||
* annotations, like visitTypeAnnotation.
|
||||
*
|
||||
* @return the int encoded value of this type reference.
|
||||
*/
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user