You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by GitBox <gi...@apache.org> on 2018/03/24 01:12:39 UTC
[GitHub] elans3 closed pull request #397: 3.0.x fixes
elans3 closed pull request #397: 3.0.x fixes
URL: https://github.com/apache/cxf/pull/397
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/.gitmergeinfo b/.gitmergeinfo
new file mode 100644
index 00000000000..cbc61bd9df2
--- /dev/null
+++ b/.gitmergeinfo
@@ -0,0 +1,449 @@
+origin/master
+
+B 004321a2e955665005b9c5bfe304feaf9cb622b0
+B 005ee936d42897f7083fd9fe26addec4779d4764
+B 015419bf394e219cbb07ca7706b4bd8e2942e856
+B 035154fb466fb9c833804d1bc747804df9e9992b
+B 03bd1b4f0beaddf4df112f7c08d5749862805dfa
+B 04f0ef2e32f55d51f14cfc6d7a14616b62a6cce5
+B 05a7ad32b06dc800d31cffbb39df5be16f847849
+B 07c6322a52c12077567a48c9a87e832ea9362886
+B 08d98fbb13440de2da3b19915d8dfe21531cb284
+B 0aaa2b5742a53bf31704939e4bc21906100bbc54
+B 0ab9416fda31298e485f2a6864c263447e4b32de
+B 0ba19453f17be19aa2e46848b1908f776a6abb64
+B 0c0555f4ac850ec8e38302d73207170affe4376a
+B 0d0bc938103b0ea9311c3b73f6c385aa3e12260c
+B 0de0309f28e1543660c763c158f4353d6d2189be
+B 0e639399027b2b43ece5b21f73effa6381a5bf0c
+B 11243052a6e1656657776bc3a0c586cba962c49f
+B 131c3fdba9c4825b739adc3d149d0297175b8a86
+B 13b9b012a31fdf1a7e35757a336fecc3c688848e
+B 13dfe0f9fcaa0aee4c603072436d85861a0ab734
+B 13e01e23ea87ea5b06953f18bef4b173fca55b4d
+B 159089a4c0bcf4d30ed819f064f0e31c6c3dc2af
+B 161e10bb2d87573974b8a1748f023c47ebbe5d49
+B 162bbb5ea63cfeb6c258d750627c77c9e694f928
+B 1674e7fb3353fc9e5d2b81deb2d02617cc09a373
+B 1805027c9ce9925fb875e92fc5314aa826632151
+B 18204e5bb0173ccea83c0afd10e4450f370287a0
+B 1824d9cae26c3b141d873d0d01036602ac339c37
+B 1a8fd7c02bc6a620e276086b665d430217116767
+B 1b3f01b4f640beea1f1247416ad9891e615f816c
+B 1c7a34e313062edff246c2c1943d43b71b0f8aa7
+B 1d29dfaa8e686570c1b2ec2da4c31ba380e0b9b0
+B 1d9e79ef36bf14e25d7cd2cccb0d804a048aef64
+B 1e927cdfaafb2efc8d29184cb5b7b05ce3c3ad7f
+B 1f02b3d4f2c9d341046ce35222c8f4d7674b10b2
+B 2004b1021ce0d0975eb49cae36416863bd8c59bb
+B 222137cb2ee577e6582a644b7ae73bbc0a75d4d1
+B 237ace40ea2c204f68848309b9483c322499b524
+B 23849faa6058427381cd3a737d2f37b551db9938
+B 2426a0879b06cf6dea32004af16f96f793d568eb
+B 24b4ed27bf096d657f11320b83ef8449ca366f63
+B 24e330c8b6be65c98cd3914f6fe7498e980f4568
+B 2616fd04151e5bb7b8a31428f8a9fd0c957dfb48
+B 26762a780f4dd498d9304f70072f1bd339223d8a
+B 27c2c25dc3c2c3019543e31afdca7b166911f278
+B 28e185b27e8c80cd773cac46d1b9b19529c4fab0
+B 28e8f04af96d3e353f0da5018a4531d45592c663
+B 29f0620a9a025afcd2057cdf97c7d93caf6c179f
+B 2a5d201be1b85344585094d0f044e9bf1b605fac
+B 2afb9d3cacb299bea854d1ff4824e4c981a41d6a
+B 2ba77327488a8446e6a92af137f644eaf3b06e2e
+B 2cb99eed19d1a8f097c4ae54967c6e45a7c03d67
+B 2cfa9011aaada9fe68bd0d9aad7ec86991ede43c
+B 2e19b7549462aa8aafc9df7684327375fd4cd673
+B 2f0b3e38212674883d610cfcfbd76b901bd3d997
+B 2f164ec218a1e850d8cc4a6a9ffdb6dba248895f
+B 2fd8103535c1246a3a243e0fd7bcea86947e6b14
+B 3019c331c0f069ed63611b5263df3ee4d427e4a7
+B 30853113b4c4d47200bcf5305e5e88735f32cc8f
+B 33083c0682d2bdf2f42df7f4021d18bd7ccc34a4
+B 3309231e467225b18b24d90d77153a0c572a17e0
+B 33c7781f4f847431a7bbdc9335657d3281cd525e
+B 3506302369c0a28647056c1da469bd9844e45826
+B 350b51632f4c5dbd4891636261909c73136981c6
+B 354ac95b70a98b4f2e8f9f33c534b3e885e9a935
+B 36fcf426a4946f57b051ce7a388c7190fc97aebd
+B 3834ba2ea50a164cf2b5ffe15229dcf512e110c6
+B 384ad75433037358ea1607c4ddcb0cd978fae10c
+B 388d6eaf045c0215c7cffc891526a402c70625ec
+B 38bb9fea460262ff2781cbfdf85032d3f4fb9fe1
+B 3913cbf504bb863e48ed5fcff25edc06e25f52c0
+B 39ac2b4eb848be0142d4f3e3da2bb6eb00ea55e5
+B 3a080015474d27075b0b03aa9ec74ab443504ebd
+B 3aec3e286e4732918589c239ea1b8f7e1d3a9836
+B 3b1a8cc3a8c1b213a8f6728ae9154cf14c9c1300
+B 3c2092b369f06d4f71134397240092a659bcbca1
+B 3d747fa0847db2798f6662a2540d4f3a79d83edd
+B 40c9bfd5ee0ba7cccd7abc7e7d19db531e212c97
+B 42b3ae5ec3ae398082e892d6c37acb0809876894
+B 42eba2f948a967d62dc0257a920715ae47ae4310
+B 431db5275e3a056d6cedf4608533197580cb6073
+B 43aa455461fb8a33b0e5844512b263a262c2420c
+B 43babb8fc1bfd034657eb44fe82fab960034c85d
+B 43c65b07658b8041f6689d16a34ff98132b8a424
+B 441cd2cecdd8a88d42e41324643f06a2fccf5a25
+B 449a10ca63d5b3507861eb4da9f56c215eddccfb
+B 44ddee3a98918261f18699b895295b53785bb9a7
+B 4534b29556a1da628c920c36e4245d0d35ca6905
+B 46838d8a346687e9f8ff2f6e279e3ba83f99c5f3
+B 46ce1778d9a4d6a30e38b393a08dd4ecae2dbb09
+B 46f0d5fff8a4d846831b5e9d7ac0405fe06d2ccd
+B 470bdcb40597dce5e5cf957000ab60b0b4c1fce4
+B 478de215af2da2c03f439bbbd8341b234bb7bee8
+B 47b1a4ae21cfc70cea3b48ebd2be72fd184f1370
+B 481466c7a42a57c87c992a02ab560be046bf5797
+B 494ff7640d78b1667547c8aacfc1d517fff00ef8
+B 49c35937c3a0813ed4ccf34dd03fd5fa2f41b86c
+B 4b44512d8c3fe76620dbac37d220038435c75ba5
+B 4b4a5151c83113bb53d65e0304b8c9fee524d28a
+B 4bc0c5e52615dac9db94b6fdcd73065a48eb1411
+B 4c9cc32f7bba136b3970c91f15a7f24c94c94c89
+B 4d49814ba85310599ee76e41742208383f3f6450
+B 4eec754b1bbd46e0142412cd37dbaf189c47f905
+B 4f61ca801deed173c648b2d424ac231663acd704
+B 4f70bdf4199a666829cf9c6c62c508d12afbe251
+B 4fe7844935f9b4ad797760613d143949f9448905
+B 504b427081cfc2213ce0a5c050b16af67ca7ff46
+B 51f433d54a1d11eac25c32b0dd69f12fef62c060
+B 54508131155cc71099f6f54c5ee531e159d79ca2
+B 5577461dfa57cb8c7c49d788276afbd9253d81c5
+B 55bda33699ea1c2e84a125253edd594cc2a32ea3
+B 577ccc51c269c66e7810eb4aad9f93cb23c78f8e
+B 578a51c1ba7f12b35730b0d66ac6b4ab880fb94c
+B 5891c0d23b776d41be02e74a3b98a3881970d08f
+B 593525139909e081ae809278d301688c0ba03697
+B 59b7fd7072a71498aecb1b5da6ec51ea89f7381b
+B 5b26ab08f19f6c55a45c0f1f7ddccd09b0a2ed23
+B 5bac26a132e7999bf0bd108d4cffb674873a56ca
+B 5c678face89e4d38b2879bc4679ce3b92ac3aeb0
+B 5d387616bc1787f3ae50dbe2a185c6abb0e9955b
+B 5e06ba0c4970700477484bd2409a226aa9ec7f0a
+B 5f94e273e7e8d99915eeda1189824f13488eb013
+B 5faf182264c64bd3c0abc0addc9746b64492c864
+B 5fbd407bac5af5e55bb280125405d75b7add872b
+B 5fc6229a6d289a6a4f23fac4f1d7750285c85d1a
+B 6168d90fab71f2a8811640bfbbf88bfd1eed1848
+B 6256b7c7c42bb01d2cc0d16d659ba1aa3042e7ae
+B 6359c930bb27b0ea589c7c2d7ed552babe4897ed
+B 6400b3cd1d87e52723fac2641b34a5f0289b908c
+B 64eee11a907d724373f80e38db24b7474ede7164
+B 64f232307444269286b7f14fc3838b07187d4c03
+B 652d821683f12031258f7727d33157f3ab6ccbe6
+B 654ad3ac53607d01875b99314c282f98e42d1072
+B 665eb259fced741f65de061bb026c3ab65a8d99c
+B 66cc4a4e3c0e92d9e6931a5d416f11c2f07f268c
+B 67432aef1adb8e330c054431de9d0955e3993472
+B 67755ea99b1baf4c567196ac6f1e00d342d38132
+B 68a567632a063c6f9bb27a73c151d21f6e855f50
+B 69176e3dd7c69901d03f6d93bb365df784f06525
+B 698cd0483b99f9638ce05557e1137ffce86d4185
+B 6994a35eaf0a71dc392dcb094a6f418ef37a12f4
+B 6bdc9257b691e140f435a567e0b4f566c71be6cf
+B 6c58f0c8861c9e9a922d337da4ea8282c75255c1
+B 6c9fb62220345bce0b19561d95b38d5507f75e71
+B 6d637dcb21bb4a17b9c581748e85bf5a82f6c9f8
+B 6e4f0f60785de1f5774644323edafb4741b9e4a4
+B 6efe475ad57f042ffc9547f1bb258ab4e16a3f3e
+B 702f27bc4a334b2d117262252632bf580f20f711
+B 71488c6fa7635c88285214a0479379aafef9ed3c
+B 716531d62eaa8b1dde566e59e2a5ff0be1b2b33c
+B 71ced4709dedf62264a4bb630aaf4780cb94ce48
+B 71dfb1f0e9636b7685482cd9aafb9ef6283d28ba
+B 71e9ada9b119ad8d960b9be15bc5689d718273ef
+B 72ba5f34d674012e2f8ca8ef5add0b022235ee06
+B 731d7df1181d717e2dc867c9e00118f974de6179
+B 7456089088a21620ec75dc83fbb4b89ebdfd290e
+B 74a2e6f2b1d9787cc9b5cff4cc84e43cfccbfe94
+B 74aea1227832d3000f2f9fe61d7cc3bcb8a60a79
+B 75c69b27a7688dfac281d4acdcff3b0acc4c8bee
+B 7737225402d3a7b2e669ee8ecf54de10af686f20
+B 799c5389f754eb588f023b646b8983b50dde00be
+B 7cd4cf67ba5b8a0ddc36c8008bf096b469408f48
+B 7d1f30f76d95f9eddf0bed995120c71bf1a393b3
+B 7e318c4fbfae35680965082a491ca842a23ffd8c
+B 7e8d0b4b1cd868272380ca5779e67a15e46cf799
+B 7e95279dd1170f5878687d7eea27f7d7f03a434b
+B 80014cf0e6fb1ba62ffdb3766acffd2130eef9d6
+B 80d7128a3ba1944a603c73e5e908d86c9bf27648
+B 857b55796dc7fc2b302e26d99f84df1712ff9c58
+B 85c06fc4d6a642627434785a2d228d3c08d68768
+B 85d6e1a63c95088917853436fe1adcce4863ce6c
+B 85fdb62d0a3bb7c2e1616702204c2bc33f7356e4
+B 87e146fd90e8f860eb7f2a8e99ad792e7fba175b
+B 88adfaf2ad97b4968b0dc47194b29c717b138d7a
+B 8ac2d4735a9254820ffdb5638f441c4dc051354e
+B 8c7e2493dc26e1df4a16168a5491ac96509549d6
+B 8e028a617f026fca2499f850bb680ada0692d681
+B 8e930bcfc6e68775db59957df8ee38d73499a6f4
+B 8ee1ce727f04099b2bbeea4164ad38005de769b3
+B 8f967643447ceec89e58b079d8d8fc00cf232a02
+B 8fd8c552f4c2a980a5138de19a2b74104776a4ba
+B 90312bc48f6e564bcafdaaebc3cd596c966ee674
+B 91d6630c53f222544e4bb512fb5c918d68518138
+B 92502a5e2af6e5d3c544f89396de2d05d539fd41
+B 92c4738f9e6b96fe0ce8586bb36b9c6444d6e225
+B 93039ab86bea4f2bdac4e5eec4229d3271f4c7ec
+B 9344b093b8081a68c9f83f0c740d60508e99fd5e
+B 944eb0ba1043bd4daf9cf087b66bc9cab10b8ff2
+B 94cfe7e48a50104b22457aa47b39d06329d16d32
+B 9511cd40a9701ee1b46ba28b61154f6f0833b7d9
+B 95c3d899174e39263a773e89a22efbd40be77d4b
+B 96ed80508cf15f7dc8c2d5a73225a36dbc096ee2
+B 970feeed0db20bfe9df5095b6b335146344c222c
+B 9896b920035a1d1be1aef28a1d1a5eb876445c82
+B 99963f9a08c9782b7c661f2b5ff8e9ce95ab3dbe
+B 9a2c82620001b76a2065960686f9bc8f384c4d58
+B 9ac66adffb73f3474fde064fab1013ecdd24be7c
+B 9ae69b3b323f48de033f62be9fc2780f11b0c761
+B 9b93ca4bda4ba8abce2e2248059f2ccfd35391b2
+B 9dd4194ce6af00377b0e1bdc6b15744fe03e29c9
+B 9de88cce894ca9ea746abf27943635467e23c153
+B 9dfb278c7739b9f4621f43b8146d057e21fafb64
+B 9ea935fcbf3869f5fa4fd1e75a0a2309cc780415
+B 9fce658c4611f790983a3d5cef7312eec8771461
+B 9fe4c04a1c875b3e8f402268cd9dfe18431b5cc9
+B a04a1e06f7fffc5f145e33c6832f31b04782516b
+B a16abff276542979aef91f7e56cd8e67a695db14
+B a2855695896d5084ea288b0fa47457e4b7bfac38
+B a2e1e40d3c185f53741c937e7b861bab2808d70f
+B a2e5fae3a093965b75361210ef475abb9e6abf56
+B a4222c930f7d69608f826c14e4bc7bc9f670097c
+B a4315cb442fa31960cbd47f11e95e81b4a71441d
+B a5aff3e7a43274b3d47cda706aaf8108bd7a9b07
+B a5f8a4dd4d9ecbfc1f8a1a8e5bcb4af17f561cc5
+B a79bb058aaf71e85dcb5c90e7b2f6e4ab8e63cba
+B a7b79ea692add4f9da0f1232e3bfb338099f4147
+B a7c6e78b491c4feb6797a6dddd32a6249189a552
+B a892678e5e2976d0c46ccdc44acb303e855aad9a
+B ab4eaac0be87291b7f053d144dc8fbf9d98634c3
+B ad5763ef8ea1ff3c8ddea2c3a6fabdaae6acddd6
+B ad700a5f6471f55680821f6d04b182f5d3a6054e
+B af100a919178b0938fcc04d9c8d1dd1269e351b9
+B afeb2ab056a4a4377db11d597c675108eb780d16
+B b08a6ba02f0e67ea29cc69fb5c878fc1e57dee75
+B b18a2bad64c343520795175cf377cdf1b981da2a
+B b19f59d369503a8676cb909e80af97e5814898a9
+B b1b3fc2e1b4a0637d85bb67eb0a59abde91b0f9a
+B b248d091551456c2fa8cfe0530dfdfc3632fe5e4
+B b4536602d376a36bcbd02d21d5ab42f19d4e5b22
+B b4872363fda49f205001d4385ecbc35133c2c755
+B b54fe0dfdf3c3d76df1e07fb3686d5d8a1061d48
+B b5fc90f09c6b039a54564e0825a264310453c550
+B b67537dbace0896073b55b375b8ccdc4cce83365
+B b7657a47aca211d46df04998bf79a9e2ca76a545
+B ba00202288bce9ba80692f151c2d73b101400c50
+B ba293c6e7456e80a5fe92f25a4893d3e45380bf0
+B ba2d7b85d44970cb4abd8cd18ac24178394ef404
+B ba8fc3d351121ec8eb2ce37cd12e014f722c741d
+B bb1edc5dd96c50ed2c3294f6834310e0a6d4381e
+B bb9b5d2e15c0e30d12a6dea3db1a6f720aaf07ad
+B bc752dc5bd89b5d70d00435fc1185e72659d7e4d
+B bcf0c9f825a7b8d1c86405403d7c089fea2955c0
+B bd94b4c8778e360d538d5acb3f6a3710af92e6f1
+B bea22d764138e365513856c23be760a7719530a0
+B bef3d8408feb07365e17ca6960db7b4b2f1436ec
+B bf6bba1082d030298df9b9f1c354da5f92833eae
+B bfbc0a25c377e43395fb1f7beee045e4412c4d8d
+B c044f726fae2a2f35ce5c6c3b9ebbfe54125ad11
+B c04c27200226b564108b4fe58b8ac70ca5ec7638
+B c1c9562bb13eeacdd9dae5a46c513e9e03625698
+B c4c969042edcbcd439faa0fc95c1f5130cf06c71
+B c5609a479c87ea75e016b61daeafe0021f693332
+B c5da4140da8fe63c4a10845b95258bbda9ab2058
+B cb19d05174a3bd078b391c4f6c151ee6e34e2956
+B cc9222b453b92f1115d5fc5df2cc11ccb3600940
+B cd7095c49ab2be4a5667450bf67e5e4be8ec84c1
+B cd809b8526fc5620c481d4ee5a8534ccf6babae4
+B d021b9041e00518099947274455b2027326a3c7c
+B d0c5c3defab6dbb9619f8fd291f2e06b685cb03c
+B d1c7f1f6be4ce14bd0e99ec9672d9c1957515f35
+B d391d9371d8505c7774308c4fbbb9bc57ffd34a6
+B d3e9295d3acfe3c970a325bbbafdba83a0d6e83c
+B d4f9674baa811936429271cbf64c4a558282c764
+B d50ffd09c30e606524fb6ed92119d85ccfa13491
+B d54a21628143bc15f51cbe5d63fa42c09d0ab8ac
+B d5b502a60d2934a42e32cb6225224ff75c66aa37
+B d5d87b8c7949bd0d8d8d5b5d5dc435e14aaf8fa4
+B d5ea460f20d60c0496c70a2cf0b7f0484d48c806
+B d68f140c76cf7e390dfce134ea5c5d97f129e65d
+B d8a6bdbd2c84b3fa0187de935e294d5f66974e46
+B d9f624e2eca8affa20243583ace087a8cbba3ac8
+B da4ccb008fcad909025cab0a00c56c00728c195b
+B db18a965fb238b8515ab74eb63d13c863c279476
+B df947cb1ca2b9e375f99e199ec65b1afece1c963
+B dfecaa60ea6082fda8f2959c083ba2f2f7a03112
+B e1246b3d0c00c9fe9489c0aacb683bf1de15d66b
+B e242307ad8bbe53788f3e03e9e2f0ca977d01340
+B e2bc8d8f31f6e3c6c6103dcf22e26726756bb39c
+B e441a15af9413bfb24ee1b4ce78e01bf543fc148
+B e4b2e746d6a70d02f64daab7aca79142e62709ca
+B e548a02fa04313fd1b6ec5d9ac78c774e8ad935a
+B e54e39740fdb360f84a74638db1d6ca71490b01a
+B e5637ffcc3a56923982c4254cffe54cc62130ee9
+B e5d98fd24b545920f2453e94a56cd9690582af59
+B e6fc7e50266d45c8b5afb002abdc44b69585cc69
+B e8514ea3f5fdf33b19d9ddc0639cc1aaf57e1f62
+B e8b8e2bc1b5afa4ad93294ebe1bd723a5a4a8f64
+B ea778c4f38f882dc97d23bd200683fd9d48b4718
+B eacd93f72c78bd28e9a3222ddfd4f0c33af6b8ec
+B eadb92c9d8af84f8754efe7f08c69fc60b82c9c3
+B eb4ea1fc03b17b7283b427cd4616507f934ef423
+B eba07e615684e475772a7a2d23d7e93a0b099485
+B ec4435d70cb0097e34f38bc0f47c0faca03b4bb0
+B ecbf4e78586870a507fe4cf91239d51c3f202aad
+B ed18c008f05af7063d5929d072b86048d12dab4c
+B ee64acf5f8370cd1e33719e4d9d4e9922e386602
+B eee2a947d867c403c212677cf942b3d07fa06fd7
+B effcaf3f6cfb4b3287d683285592f2693af42b29
+B f18acbcdfc48aca354610614c0ba3a46dcb8332a
+B f2c370690d62cbb9350aa3447ee1ab8336335074
+B f2f6aa016cdd1bb49698b319806a8369f149c8dd
+B f51fb332753e9600a6b6e6dd17b42c1a1494395a
+B f595ca026d56ec5e58a38780677598d8f9d9ded5
+B f71738d894d4143ed57b956ef1dd68aec5b1b41d
+B f7a091afedbc7ca809a7205d7c053a1f5386865e
+B f7a64ca9f12fa2523c35bc5add4be3e979a7604f
+B f942e1e15d6c4fa83e305eb7452dca8fc80cbdcf
+B f94861bd6745e92bc1f69acaa907761f3bcc0613
+B f97778f0c21a4dc0f083e840e8157fe2f8528d90
+B fa37d8722d154bbdec9d2acf4da16a04db0a34f1
+B fb94440f6f1d5c7c572b6c0163f275c95073b8ee
+B fb9d26581c364c62c7343847ebe4136b8c97700f
+B fc78cd31869a4e580c4d2a9e7864ae6dae8c311b
+B fcc8bcb38f33febf5c73c5f5f56d877272f27e20
+B fd3471e58e63ee672babc015ed0929f6cd6862dd
+B fd5abbd3793e232638e4d0793ebb9765e49c638a
+B fe416234bab8af30f1789c3164ac256af86e3b62
+B ff742436a3e177dc61106edf08f2509e727362dd
+B ffd429be404953874e141c52a9c8ba46812d73ca
+M 00a5a1d6b1da5f3b679c25d4bd988d1277ee62e7
+M 00b626af504d3d59419ec2d1eb5e39943ec5b8aa
+M 0cb64ee2bb66e4249c4a0f8d7ae62068e2a95dcd
+M 0d3d0bd91a8dd9e01e4716bc40dce28ed07c4325
+M 0d63846798b590255c45463359e2cb1a28e4d3cb
+M 10a8386fcef4b7f2220ceceaa6aedca60846f6d1
+M 10b043faa0652a6a06f5f020173162edef7fb0ca
+M 12d070f4392316cdfff03eb41abe22531ed64ee9
+M 16ffa0f10dac874cd5727d312ac56a78b13e5ca9
+M 1701e6c8d4e794f25d69781e3f69357723ad7fcf
+M 18a3d43cb0044fcb84d3cc89f138fd9e7110dd04
+M 1946e323a0df6e5f9748af82106cff39d7b5d01f
+M 19e912e8d4b6d3f3a4c2b88b1d53e691496d7dc0
+M 1b91b6e630bec0980d94bd04b016748af525d9bd
+M 1baae69592a128462ef252916bccfb67cd81095b
+M 1d07267bc4464e50dc9b5e81606958e3252873cd
+M 1dec7e3bd3956d5a0fba3c79a9a897e87941e9b6
+M 27c1bb5a19ea70ef1befccff22d72f1656247b0d
+M 2895b7b052e6c96d192abf39d472737b54fcd9c2
+M 2b4fe9966c46457177f6412525c57c64d07dbe69
+M 2d3ac551c8614516cbbf288195d2a99cadb79659
+M 2e701bcd1cabcc7ae4cb69346eacb8ab278e2827
+M 318cfdaeb15b8d230829d120f894bec6f15bc836
+M 3656b40f215f9904ea3649163bf2444eeab0c9cc
+M 3af7c785c642db6ae64276f92fb05450d7f9aba3
+M 3d3d495a2c58164abfb54b64208b3f72b4d235dd
+M 40a8c9247e0829ecac38764cf4b27d1e0102f7b3
+M 40c6734f96ca0a3d82eb37088f43221e93cbd6f2
+M 41812468cde977c25aae405814677555beadee1a
+M 431ade6fe85f4d13f56aa4bc530cb50353be0dd5
+M 43c8d500b04a13f72077751fdbfaab7bbcfbbf8f
+M 44bf65e6dd21fbbde4c24685b20dcbcb0f0ccc1d
+M 4640cf1ea20eee09ae650b706bce765a16affc8b
+M 4715a0ddce4864bbf6e1c34a7a1cd9508a52d9cd
+M 47b57d723f1468e9d9650617a6013edf4f965900
+M 4915ce370e5f1905f77ebecc8883cc86fcc3e4f4
+M 4a292c0cc49c0c4eef5d50efc78a499c7a5e1783
+M 4cd28267092129b3ea456fc436dd2a4f210b365f
+M 4e9b960f4eab531e6086fbe9f3373bf69efca7cd
+M 50f5cd8c3b7c6d174f59ee111646f2625b890a00
+M 51db79ca7bd2c703a4dbbd42d7761c97af3bad84
+M 52598eb9b31ea7dfc7b4b87048e4ded459fbeb87
+M 52b83045b6f7298117e9a66758c07fc9f1fba3af
+M 56c0db05126292a61a782f05848321b9b8b8b80c
+M 58e6563da54fd3237a9a1d21a2cf7115740795a2
+M 590313298b7a4d79c80b130357c5036adb6102c2
+M 591e5d9cb6ab1ba85a5d37da2fbbf9b53ce777ed
+M 5a9a2a09887c69cdfeff5eac22996ab35fbfc0cf
+M 5b20a3c909440bab1f0080a0b4b414fef6a6d4b9
+M 5e919271e2e92f9845d6454b37ab0b86cfc66591
+M 5e97d1e29e85d80f0679748cc4df0d8e0647ee16
+M 6129ec5f6735a986660a2d05c6b3b0c9230610d9
+M 6292346fb110f0517b791f91d03fd2515d575388
+M 64368a5ddad507fa5d7016cbd07f3e9b5b5fd594
+M 65654316c43ba94b97e9ad164224191561652f81
+M 67201fdde69488e511deb3d24794984afc01fe2d
+M 6d7ab22d5adcd15bfa3a086345a0b5851fe3e2b2
+M 6e3224606ecf56b821dac537241f18a59b44e3e3
+M 702a4c1759263d25ab62c0804ed61a77771f099a
+M 70b568a3390bec3498c427264a5f3f4cbcb7f1cc
+M 717018e84f3ed41f0c9ca5ca550593c6c3352866
+M 71a1d1425c7cbfb6d410e6655f3579131d1fab3e
+M 741ebc5d360db7b850401a4798f79a3996301885
+M 7431af236a19b5b5f899bad317a548a4c5c9cd49
+M 76c4df1bce5e71b439fb37fa5d9e1af12615786b
+M 79156d8a23497b9ed9bd912b64f684e610d49863
+M 7bf10fc3fb018d533409cc444c2d7b75144b9e23
+M 816e1a5ef4c0992a7d084a0529e42d9ad6a4a3c6
+M 824234e627f6205129b7f97e2fde7f1cf1f17093
+M 865eb64d44fd4e904f166cb03b0d15ca8b5f0ba5
+M 88a7cd850f0471d6e51f9045bf01f775a905cbf2
+M 89b87071f3dedd2cd5ed874e56f69ab7dcf7953d
+M 8bcb5133c602b1cbe642cfd5fbb46099a28b3016
+M 8d2b0180518fcec6274ac2f288e74ed1ff5ce76a
+M 8fc7bfa3d054e9aebcb43f51e083ff7cf3b47010
+M 9043011518147bbc2dac036681fd64d7ce578bc2
+M 94585ae070e62d08f0e064df8176fbdbdf1bb37b
+M 982bdbc9dc2127906d0a1ca06ae181c87c38bbfa
+M 98a578dbf4b7e19c4555bd2011f24c650d0f54c0
+M 98f65f2911e063e70e864e7614b062cc124a0f9d
+M 990f4b1d594c8f1446d42a516eaef82020df2747
+M 9c7b2bc668a8b1e1d620aa79c3c32927b06a3ff3
+M 9d25f9a0617bcb30e19d23fa4d5b4bd7948b8434
+M 9f18da888e37f203b1aa9a3240ed7b6aab3a4ef9
+M a088c793efd923a52f68044b02221f8b47569ef9
+M a3bf2a80bafa95ec2ccdd2b28ead26c13866acd7
+M a5b1c33534d83b4d0696263439d0d1a906b1afe6
+M a64265c29be124e9bffb46eb35a68b3504860c3a
+M a64ded455c40169665e438ae7a25f17bd4f8047a
+M a79158c70fb2c8cedf109e78eeec32691a32e306
+M a9555675b829acdfb1672bc2157d6f3c08fdd652
+M a97f886f36c8aea2a49860ec8cd33b0021b7b9e2
+M aaad96fdf931cdc619a60fbffe3c9c894ae8ea43
+M af2f7d3a52076f60d0f98a2635e2adef256a9efe
+M b9e4fcf44fc690c328afbfa166acca26ecb4c16a
+M bc5e828cd8a25c4c4107c76e1582f807e75c9a77
+M bd1d31f195caab56fbe565fbfb63d9170a0c9406
+M bd7babd656fc06f3e5839bf11e186ec12fdeb6fa
+M bee82ba7d1766b555d965a75b3846ead4686239e
+M c1c75b039df7bd1ca9f11ff21f16593fed0c8c16
+M c34bf7ad6bc55b6584dfd009f49a3f4eb8ececc9
+M c55664128b1223667dedacc2011ccd5945d9c8b9
+M c5dbb84ac4e5bf73555e85ae1e65a5065393c602
+M c72cac8cbd73d92a9e0264c816176c2a33dcbcf2
+M cda58270486b4d394b98a1a1a1d5bfcb366af2c1
+M d2dec5b87788b8cb5059d3719cf3dfd7135a1280
+M d4a35c40d53fde17fec3d08c25215c7533dcb667
+M d5315e072b8dd5222ede6f8e47c1e3e645209f59
+M d7945c77da4f438cd7f52b1a512e65c62409d0ef
+M d9f4142e87bc8a4f31c1bd1560a01a18b5c66407
+M da352523c42bf69ab743f75a5216a03e26a20bef
+M daac77b18e2693ef4ad424937aedc764229a63ee
+M dbc4a26cd47c2609c601dc3640b655ea0a2b60b9
+M e2225709c37cb289b99db015b3d8ba5b9b317615
+M e2ad037fbc74f42655ac968415fcb4bded87bb38
+M e47e394114d6a3bf06401960618e6bd556a904d7
+M e5a805853864e291626bdb913448fc4e2409cca0
+M e80d3da7612db41f7efe9c5d3128965ec7d2809b
+M ea4a8deb4f5cc994ab3896bd134c57783f2f8c51
+M eb3dd938052b3e853b0cf85dacf31ef7f802af38
+M eb9e13e2dd4a22b1d777095a5d92139829d550b8
+M efaf05170b4f76ad61ff423e30ece58bdd226ae5
+M f02b02934bf78504ffc462c364dc43e386e727b2
+M f74e2e060b93fbbfc05ace263fe7f4f588b63e4d
+M fb0520525f07041f42bc0562b4a15240bb757373
+M fe4deb5b67a1b3b595bc43e4176c9c311a08ed2f
+M fe5eedda59947924259ec3ce801f6905b9c5a010
+M fe611ce66d8d2b82cba0b48c3e9f5406da8b38ed
diff --git a/core/pom.xml b/core/pom.xml
index aecb3d374ea..0b6b32d66a5 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<properties>
@@ -65,7 +65,7 @@
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/blueprint/core",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/configuration/beans",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/configuration/parameterized-types",
- org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/configuration/security"
+ org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://cxf.apache.org/configuration/security",
org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace="http://schemas.xmlsoap.org/wsdl/",
</cxf.export.service>
</properties>
diff --git a/core/src/main/java/org/apache/cxf/annotations/SchemaValidation.java b/core/src/main/java/org/apache/cxf/annotations/SchemaValidation.java
index 2d338ad947e..eb78ea4025e 100644
--- a/core/src/main/java/org/apache/cxf/annotations/SchemaValidation.java
+++ b/core/src/main/java/org/apache/cxf/annotations/SchemaValidation.java
@@ -33,7 +33,7 @@
@Target({ ElementType.TYPE, ElementType.METHOD })
public @interface SchemaValidation {
public enum SchemaValidationType {
- IN, OUT, BOTH, NONE
+ IN, REQUEST, OUT, RESPONSE, BOTH, NONE
}
/**
* Schema Validation Type
diff --git a/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java b/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
index 35bdc5ba441..38e01cee3e4 100644
--- a/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
+++ b/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
@@ -320,7 +320,7 @@ public boolean hasNext() throws IOException {
private Map<String, List<String>> loadPartHeaders(InputStream in) throws IOException {
List<String> headerLines = new ArrayList<String>(10);
- StringBuffer buffer = new StringBuffer(128);
+ StringBuilder buffer = new StringBuilder(128);
String line;
// loop until we hit the end or a null line
while ((line = readLine(in)) != null) {
@@ -384,7 +384,7 @@ public boolean hasNext() throws IOException {
}
private String readLine(InputStream in) throws IOException {
- StringBuffer buffer = new StringBuffer(128);
+ StringBuilder buffer = new StringBuilder(128);
int c;
diff --git a/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java b/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
index 408db874840..24b476638b2 100644
--- a/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
+++ b/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
@@ -72,7 +72,6 @@ public void writeProlog() throws IOException {
bodyBoundary = AttachmentUtil.getUniqueBoundaryValue();
String bodyCt = (String) message.get(Message.CONTENT_TYPE);
- bodyCt = bodyCt.replaceAll("\"", "\\\"");
// The bodyCt string is used enclosed within "", so if it contains the character ", it
// should be adjusted, like in the following case:
@@ -107,17 +106,15 @@ public void writeProlog() throws IOException {
// type is a required parameter for multipart/related only
if (xopOrMultipartRelated
&& requestMimeType.indexOf("type=") == -1) {
- ct.append("; ");
if (xop) {
- ct.append("type=\"application/xop+xml\"");
+ ct.append("; type=\"application/xop+xml\"");
} else {
- ct.append("type=\"").append(bodyCt).append("\"");
+ ct.append("; type=\"").append(bodyCt).append("\"");
}
}
// boundary
- ct.append("; ")
- .append("boundary=\"")
+ ct.append("; boundary=\"")
.append(bodyBoundary)
.append("\"");
@@ -127,8 +124,7 @@ public void writeProlog() throws IOException {
// for simpler multipart/related payloads but is not needed for
// multipart/mixed, multipart/form-data
if (xopOrMultipartRelated) {
- ct.append("; ")
- .append("start=\"<")
+ ct.append("; start=\"<")
.append(checkAngleBrackets(rootContentId))
.append(">\"");
}
@@ -136,8 +132,7 @@ public void writeProlog() throws IOException {
// start-info is a required parameter for XOP/MTOM, may be needed for
// other WS cases but is redundant in simpler multipart/related cases
if (writeOptionalTypeParameters || xop) {
- ct.append("; ")
- .append("start-info=\"")
+ ct.append("; start-info=\"")
.append(bodyCt)
.append("\"");
}
@@ -159,7 +154,7 @@ public void writeProlog() throws IOException {
StringBuilder mimeBodyCt = new StringBuilder();
String bodyType = getHeaderValue("Content-Type", null);
if (bodyType == null) {
- mimeBodyCt.append((xop ? "application/xop+xml" : "text/xml") + "; charset=")
+ mimeBodyCt.append(xop ? "application/xop+xml; charset=" : "text/xml; charset=")
.append(encoding)
.append("; type=\"")
.append(bodyCt)
@@ -189,12 +184,9 @@ private String getHeaderValue(String name, String defaultValue) {
private static void writeHeaders(String contentType, String attachmentId,
Map<String, List<String>> headers, Writer writer) throws IOException {
- writer.write("\r\n");
- writer.write("Content-Type: ");
+ writer.write("\r\nContent-Type: ");
writer.write(contentType);
- writer.write("\r\n");
-
- writer.write("Content-Transfer-Encoding: binary\r\n");
+ writer.write("\r\nContent-Transfer-Encoding: binary\r\n");
if (attachmentId != null) {
attachmentId = checkAngleBrackets(attachmentId);
@@ -209,7 +201,8 @@ private static void writeHeaders(String contentType, String attachmentId,
|| "Content-Transfer-Encoding".equalsIgnoreCase(name)) {
continue;
}
- writer.write(name + ": ");
+ writer.write(name);
+ writer.write(": ");
List<String> values = entry.getValue();
for (int i = 0; i < values.size(); i++) {
writer.write(values.get(i));
@@ -238,8 +231,7 @@ public void writeAttachments() throws IOException {
if (message.getAttachments() != null) {
for (Attachment a : message.getAttachments()) {
StringWriter writer = new StringWriter();
- writer.write("\r\n");
- writer.write("--");
+ writer.write("\r\n--");
writer.write(bodyBoundary);
Map<String, List<String>> headers = null;
@@ -265,8 +257,7 @@ public void writeAttachments() throws IOException {
}
}
StringWriter writer = new StringWriter();
- writer.write("\r\n");
- writer.write("--");
+ writer.write("\r\n--");
writer.write(bodyBoundary);
writer.write("--");
out.write(writer.getBuffer().toString().getBytes(encoding));
diff --git a/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java b/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java
index c1ce0e773d2..1fdc4ee1a84 100644
--- a/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java
+++ b/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java
@@ -19,6 +19,7 @@
package org.apache.cxf.attachment;
+import java.io.UnsupportedEncodingException;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -26,45 +27,85 @@
import java.util.regex.Pattern;
public class ContentDisposition {
- private static final String CD_HEADER_PARAMS_EXPRESSION =
- "(([\\w]+( )?=( )?\"[^\"]+\")|([\\w]+( )?=( )?[^;]+))";
+ private static final String CD_HEADER_PARAMS_EXPRESSION =
+ "(([\\w]+( )?\\*?=( )?\"[^\"]+\")|([\\w]+( )?\\*?=( )?[^;]+))";
private static final Pattern CD_HEADER_PARAMS_PATTERN =
- Pattern.compile(CD_HEADER_PARAMS_EXPRESSION);
+ Pattern.compile(CD_HEADER_PARAMS_EXPRESSION);
+
+ private static final String CD_HEADER_EXT_PARAMS_EXPRESSION =
+ "(UTF-8|ISO-8859-1)''((?:%[0-9a-f]{2}|\\S)+)";
+ private static final Pattern CD_HEADER_EXT_PARAMS_PATTERN =
+ Pattern.compile(CD_HEADER_EXT_PARAMS_EXPRESSION);
+
private String value;
private String type;
private Map<String, String> params = new LinkedHashMap<String, String>();
-
+
public ContentDisposition(String value) {
this.value = value;
-
+
String tempValue = value;
-
+
int index = tempValue.indexOf(';');
if (index > 0 && !(tempValue.indexOf('=') < index)) {
type = tempValue.substring(0, index).trim();
tempValue = tempValue.substring(index + 1);
}
-
+
+ String extendedFilename = null;
Matcher m = CD_HEADER_PARAMS_PATTERN.matcher(tempValue);
while (m.find()) {
String[] pair = m.group().trim().split("=");
- params.put(pair[0].trim(),
- pair.length == 2 ? pair[1].trim().replace("\"", "") : "");
+ String paramName = pair[0].trim();
+ String paramValue = pair.length == 2 ? pair[1].trim().replace("\"", "") : "";
+ // filename* looks like the only CD param that is human readable
+ // and worthy of the extended encoding support. Other parameters
+ // can be supported if needed, see the complete list below
+ /*
+ http://www.iana.org/assignments/cont-disp/cont-disp.xhtml#cont-disp-2
+
+ filename name to be used when creating file [RFC2183]
+ creation-date date when content was created [RFC2183]
+ modification-date date when content was last modified [RFC2183]
+ read-date date when content was last read [RFC2183]
+ size approximate size of content in octets [RFC2183]
+ name original field name in form [RFC2388]
+ voice type or use of audio content [RFC2421]
+ handling whether or not processing is required [RFC3204]
+ */
+ if ("filename*".equals(paramName)) {
+ // try to decode the value if it matches the spec
+ try {
+ Matcher matcher = CD_HEADER_EXT_PARAMS_PATTERN.matcher(paramValue);
+ if (matcher.matches()) {
+ String encodingScheme = matcher.group(1);
+ String encodedValue = matcher.group(2);
+ paramValue = Rfc5987Util.decode(encodedValue, encodingScheme);
+ extendedFilename = paramValue;
+ }
+ } catch (UnsupportedEncodingException e) {
+ // would be odd not to support UTF-8 or 8859-1
+ }
+ }
+ params.put(paramName, paramValue);
+ }
+ if (extendedFilename != null) {
+ params.put("filename", extendedFilename);
}
}
-
+
public String getType() {
return type;
}
-
+
public String getParameter(String name) {
return params.get(name);
}
-
+
public Map<String, String> getParameters() {
return Collections.unmodifiableMap(params);
}
-
+
public String toString() {
return value;
}
diff --git a/core/src/main/java/org/apache/cxf/attachment/Rfc5987Util.java b/core/src/main/java/org/apache/cxf/attachment/Rfc5987Util.java
new file mode 100644
index 00000000000..8da87f7e697
--- /dev/null
+++ b/core/src/main/java/org/apache/cxf/attachment/Rfc5987Util.java
@@ -0,0 +1,88 @@
+/**
+ * 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.apache.cxf.attachment;
+
+import java.io.ByteArrayOutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Utility for encoding and decoding values according to RFC 5987. Assumes the
+ * caller already knows the encoding scheme for the value.
+ */
+public final class Rfc5987Util {
+
+ private static final Pattern ENCODED_VALUE_PATTERN = Pattern.compile("%[0-9a-f]{2}|\\S",
+ Pattern.CASE_INSENSITIVE);
+
+ private Rfc5987Util() {
+
+ }
+
+ public static String encode(final String s) throws UnsupportedEncodingException {
+ return encode(s, "UTF-8");
+ }
+
+ // http://stackoverflow.com/questions/11302361/ (continued next line)
+ // handling-filename-parameters-with-spaces-via-rfc-5987-results-in-in-filenam
+ public static String encode(final String s, String encoding) throws UnsupportedEncodingException {
+ final byte[] rawBytes = s.getBytes(encoding);
+ final int len = rawBytes.length;
+ final StringBuilder sb = new StringBuilder(len << 1);
+ final char[] digits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ 'a', 'b', 'c', 'd', 'e', 'f'};
+ final byte[] attributeChars = {'!', '#', '$', '&', '+', '-', '.', '0',
+ '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D',
+ 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
+ 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '^', '_', '`', 'a',
+ 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '|',
+ '~'};
+ for (final byte b : rawBytes) {
+ if (Arrays.binarySearch(attributeChars, b) >= 0) {
+ sb.append((char) b);
+ } else {
+ sb.append('%');
+ sb.append(digits[0x0f & (b >>> 4)]);
+ sb.append(digits[b & 0x0f]);
+ }
+ }
+
+ return sb.toString();
+ }
+
+ public static String decode(String s, String encoding)
+ throws UnsupportedEncodingException {
+ Matcher matcher = ENCODED_VALUE_PATTERN.matcher(s);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ while (matcher.find()) {
+ String matched = matcher.group();
+ if (matched.startsWith("%")) {
+ Integer value = Integer.parseInt(matched.substring(1), 16);
+ bos.write(value);
+ } else {
+ bos.write(matched.charAt(0));
+ }
+ }
+
+ return new String(bos.toByteArray(), encoding);
+ }
+}
diff --git a/core/src/main/java/org/apache/cxf/bus/ManagedBus.java b/core/src/main/java/org/apache/cxf/bus/ManagedBus.java
index 3dad9768f60..4371fb16f8e 100644
--- a/core/src/main/java/org/apache/cxf/bus/ManagedBus.java
+++ b/core/src/main/java/org/apache/cxf/bus/ManagedBus.java
@@ -23,6 +23,7 @@
import javax.management.ObjectName;
import org.apache.cxf.Bus;
+import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.management.ManagedComponent;
import org.apache.cxf.management.ManagementConstants;
import org.apache.cxf.management.annotation.ManagedOperation;
@@ -33,6 +34,7 @@
public class ManagedBus implements ManagedComponent {
private static final String TYPE_VALUE = "Bus";
+ private static final String INSTANCE_ID = "managed.bus.instance.id";
private final Bus bus;
public ManagedBus(Bus b) {
@@ -50,7 +52,11 @@ public ObjectName getObjectName() throws JMException {
buffer.append(ManagementConstants.BUS_ID_PROP).append('=').append(busId).append(',');
buffer.append(ManagementConstants.TYPE_PROP).append('=').append(TYPE_VALUE).append(',');
// Added the instance id to make the ObjectName unique
- buffer.append(ManagementConstants.INSTANCE_ID_PROP).append('=').append(bus.hashCode());
+ String instanceId = (String)bus.getProperties().get(INSTANCE_ID);
+ if (StringUtils.isEmpty(instanceId)) {
+ instanceId = new StringBuffer().append(bus.hashCode()).toString();
+ }
+ buffer.append(ManagementConstants.INSTANCE_ID_PROP).append('=').append(instanceId);
return new ObjectName(buffer.toString());
diff --git a/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java b/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
index 70b547ea53f..4db349d079b 100644
--- a/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
+++ b/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
@@ -123,7 +123,7 @@ private ComponentMetadata getComponentMetadata(String id) {
list.add(type.cast(container.getComponentInstance(s)));
}
}
- if (list.isEmpty()) {
+ if (list.isEmpty() && context != null) {
try {
ServiceReference refs[] = context.getServiceReferences(type.getName(), null);
if (refs != null) {
@@ -168,16 +168,18 @@ private ComponentMetadata getComponentMetadata(String id) {
}
try {
- ServiceReference refs[] = context.getServiceReferences(type.getName(), null);
- if (refs != null) {
- for (ServiceReference r : refs) {
- Object o2 = context.getService(r);
- Class<? extends T> t = o2.getClass().asSubclass(type);
- if (listener.loadBean(t.getName(), t)) {
- if (listener.beanLoaded(t.getName(), type.cast(o2))) {
- return true;
+ if (context != null) {
+ ServiceReference refs[] = context.getServiceReferences(type.getName(), null);
+ if (refs != null) {
+ for (ServiceReference r : refs) {
+ Object o2 = context.getService(r);
+ Class<? extends T> t = o2.getClass().asSubclass(type);
+ if (listener.loadBean(t.getName(), t)) {
+ if (listener.beanLoaded(t.getName(), type.cast(o2))) {
+ return true;
+ }
+ loaded = true;
}
- loaded = true;
}
}
}
diff --git a/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java b/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
index 9842ad3dc82..b6b68dcb978 100644
--- a/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
+++ b/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
@@ -67,10 +67,15 @@ public void setBlueprintContainer(BlueprintContainer con) {
setExtension(new BlueprintBeanLocator(getExtension(ConfiguredBeanLocator.class), container, context),
ConfiguredBeanLocator.class);
}
+ @Override
public String getId() {
if (id == null) {
- id = context.getBundle().getSymbolicName() + "-"
- + DEFAULT_BUS_ID + Integer.toString(this.hashCode());
+ if (context == null) {
+ id = super.getId();
+ } else {
+ id = context.getBundle().getSymbolicName() + "-"
+ + DEFAULT_BUS_ID + Integer.toString(this.hashCode());
+ }
}
return id;
}
diff --git a/core/src/main/java/org/apache/cxf/bus/extension/Extension.java b/core/src/main/java/org/apache/cxf/bus/extension/Extension.java
index 85e0860f377..81cd8aac071 100644
--- a/core/src/main/java/org/apache/cxf/bus/extension/Extension.java
+++ b/core/src/main/java/org/apache/cxf/bus/extension/Extension.java
@@ -37,8 +37,8 @@
protected String className;
protected ClassLoader classloader;
- protected Class<?> clazz;
- protected Class<?> intf;
+ protected volatile Class<?> clazz;
+ protected volatile Class<?> intf;
protected String interfaceName;
protected boolean deferred;
protected Collection<String> namespaces = new ArrayList<String>();
@@ -191,8 +191,13 @@ public void setArgs(Object a[]) {
if (notFound) {
return null;
}
- if (clazz == null) {
- clazz = tryClass(className, cl);
+ if (clazz != null) {
+ return clazz;
+ }
+ synchronized (this) {
+ if (clazz == null) {
+ clazz = tryClass(className, cl);
+ }
}
return clazz;
}
@@ -287,7 +292,11 @@ public Object load(ClassLoader cl, Bus b) {
if (intf != null || notFound) {
return intf;
}
- intf = tryClass(interfaceName, cl);
+ synchronized (this) {
+ if (intf == null) {
+ intf = tryClass(interfaceName, cl);
+ }
+ }
return intf;
}
diff --git a/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java b/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java
index bb5f1b96a09..fe80e427f52 100644
--- a/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java
+++ b/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java
@@ -20,7 +20,6 @@
import java.io.InputStream;
import java.util.Collection;
-import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -61,19 +60,28 @@
public class ExtensionManagerBus extends AbstractBasicInterceptorProvider implements Bus {
public static final String BUS_PROPERTY_NAME = "bus";
static final boolean FORCE_LOGGING;
+ static final boolean FORCE_PRETTY;
static {
boolean b = false;
+ boolean pretty = false;
try {
- b = Boolean.getBoolean("org.apache.cxf.logging.enabled");
- //treat these all the same
- b |= Boolean.getBoolean("com.sun.xml.ws.transport.local.LocalTransportPipe.dump");
- b |= Boolean.getBoolean("com.sun.xml.ws.util.pipe.StandaloneTubeAssembler.dump");
- b |= Boolean.getBoolean("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump");
- b |= Boolean.getBoolean("com.sun.xml.ws.transport.http.HttpAdapter.dump");
+ String prop = System.getProperty("org.apache.cxf.logging.enabled", "false");
+ if ("pretty".equals(prop)) {
+ b = true;
+ pretty = true;
+ } else {
+ b = Boolean.parseBoolean(prop);
+ //treat these all the same
+ b |= Boolean.getBoolean("com.sun.xml.ws.transport.local.LocalTransportPipe.dump");
+ b |= Boolean.getBoolean("com.sun.xml.ws.util.pipe.StandaloneTubeAssembler.dump");
+ b |= Boolean.getBoolean("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump");
+ b |= Boolean.getBoolean("com.sun.xml.ws.transport.http.HttpAdapter.dump");
+ }
} catch (Throwable t) {
//ignore
}
FORCE_LOGGING = b;
+ FORCE_PRETTY = pretty;
}
private static final String BUS_ID_PROPERTY_NAME = "org.apache.cxf.bus.id";
@@ -87,7 +95,7 @@
private final ExtensionManagerImpl extensionManager;
- public ExtensionManagerBus(Map<Class<?>, Object> extensions, Map<String, Object> properties,
+ public ExtensionManagerBus(Map<Class<?>, Object> extensions, Map<String, Object> props,
ClassLoader extensionClassLoader) {
if (extensions == null) {
extensions = new ConcurrentHashMap<Class<?>, Object>(16, 0.75f, 4);
@@ -102,10 +110,12 @@ public ExtensionManagerBus(Map<Class<?>, Object> extensions, Map<String, Object>
CXFBusFactory.possiblySetDefaultBus(this);
if (FORCE_LOGGING) {
- features.add(new LoggingFeature());
+ LoggingFeature feature = new LoggingFeature();
+ feature.setPrettyLogging(FORCE_PRETTY);
+ features.add(feature);
}
- if (null == properties) {
- properties = new HashMap<String, Object>();
+ if (null != props) {
+ properties.putAll(props);
}
Configurer configurer = (Configurer)extensions.get(Configurer.class);
@@ -208,10 +218,8 @@ public void setId(String i) {
} else {
//force loading
Collection<?> objs = loc.getBeansOfType(extensionType);
- if (objs != null) {
- for (Object o : objs) {
- extensions.put(extensionType, o);
- }
+ if (objs != null && objs.size() != 0) {
+ extensions.put(extensionType, objs.iterator().next());
}
obj = extensions.get(extensionType);
}
@@ -347,7 +355,9 @@ public synchronized void setFeatures(Collection<? extends Feature> features) {
this.features.clear();
this.features.addAll(features);
if (FORCE_LOGGING) {
- this.features.add(new LoggingFeature());
+ LoggingFeature feature = new LoggingFeature();
+ feature.setPrettyLogging(FORCE_PRETTY);
+ this.features.add(feature);
}
if (state == BusState.RUNNING) {
initializeFeatures();
diff --git a/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java b/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
index 79b88a6bf21..62d19449f5f 100644
--- a/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
+++ b/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
@@ -32,6 +32,7 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Logger;
import org.apache.cxf.Bus;
@@ -56,6 +57,7 @@
private final ClassLoader loader;
private ResourceManager resourceManager;
private Map<String, Extension> all = new ConcurrentHashMap<String, Extension>();
+ private List<Extension> ordered = new CopyOnWriteArrayList<Extension>();
private final Map<Class<?>, Object> activated;
private final Bus bus;
@@ -91,6 +93,7 @@ public ExtensionManagerImpl(String resources[],
for (Map.Entry<String, Extension> ext : ExtensionRegistry.getRegisteredExtensions().entrySet()) {
if (!all.containsKey(ext.getKey())) {
all.put(ext.getKey(), ext.getValue());
+ ordered.add(ext.getValue());
}
}
}
@@ -109,10 +112,11 @@ final void load(String resources[]) {
}
public void add(Extension ex) {
all.put(ex.getName(), ex);
+ ordered.add(ex);
}
public void initialize() {
- for (Extension e : all.values()) {
+ for (Extension e : ordered) {
if (!e.isDeferred() && e.getLoadedObject() == null) {
loadAndRegister(e);
}
@@ -121,22 +125,25 @@ public void initialize() {
public void removeBeansOfNames(List<String> names) {
for (String s : names) {
- all.remove(s);
+ Extension ex = all.remove(s);
+ if (ex != null) {
+ ordered.remove(ex);
+ }
}
}
public void activateAll() {
- for (Extension e : all.values()) {
+ for (Extension e : ordered) {
if (e.getLoadedObject() == null) {
loadAndRegister(e);
}
}
}
public <T> void activateAllByType(Class<T> type) {
- for (Extension e : all.values()) {
+ for (Extension e : ordered) {
if (e.getLoadedObject() == null) {
- synchronized (e) {
- Class<?> cls = e.getClassObject(loader);
- if (cls != null && type.isAssignableFrom(cls)) {
+ Class<?> cls = e.getClassObject(loader);
+ if (cls != null && type.isAssignableFrom(cls)) {
+ synchronized (e) {
loadAndRegister(e);
}
}
@@ -178,6 +185,7 @@ public InputStream run() throws Exception {
}
if (!all.containsKey(e.getName())) {
all.put(e.getName(), e);
+ ordered.add(e);
}
}
} finally {
@@ -191,18 +199,17 @@ public InputStream run() throws Exception {
}
final void loadAndRegister(Extension e) {
+ Class<?> cls = null;
+ if (null != e.getInterfaceName() && !"".equals(e.getInterfaceName())) {
+ cls = e.loadInterface(loader);
+ } else {
+ cls = e.getClassObject(loader);
+ }
+ if (null != activated && null != cls && null != activated.get(cls)) {
+ return;
+ }
+
synchronized (e) {
- Class<?> cls = null;
- if (null != e.getInterfaceName() && !"".equals(e.getInterfaceName())) {
- cls = e.loadInterface(loader);
- } else {
- cls = e.getClassObject(loader);
- }
-
- if (null != activated && null != cls && null != activated.get(cls)) {
- return;
- }
-
Object obj = e.load(loader, bus);
if (obj == null) {
return;
@@ -255,10 +262,9 @@ final void loadAndRegister(Extension e) {
}
Extension e = all.get(name);
if (e != null) {
- synchronized (e) {
- Class<?> cls = e.getClassObject(loader);
-
- if (cls != null && type.isAssignableFrom(e.getClassObject(loader))) {
+ Class<?> cls = e.getClassObject(loader);
+ if (cls != null && type.isAssignableFrom(cls)) {
+ synchronized (e) {
if (e.getLoadedObject() == null) {
loadAndRegister(e);
}
@@ -294,10 +300,10 @@ private void invokeSetterActivationNSMethod(Object target, Object value) {
}
public List<String> getBeanNamesOfType(Class<?> type) {
List<String> ret = new LinkedList<String>();
- for (Extension ex : all.values()) {
- synchronized (ex) {
- Class<?> cls = ex.getClassObject(loader);
- if (cls != null && type.isAssignableFrom(cls)) {
+ for (Extension ex : ordered) {
+ Class<?> cls = ex.getClassObject(loader);
+ if (cls != null && type.isAssignableFrom(cls)) {
+ synchronized (ex) {
ret.add(ex.getName());
}
}
@@ -321,25 +327,29 @@ private void invokeSetterActivationNSMethod(Object target, Object value) {
List<T> ret = new LinkedList<T>();
Extension ext = all.get(type.getName());
if (ext != null) {
- synchronized (ext) {
- Class<?> cls = ext.getClassObject(loader);
- if (cls != null && type.isAssignableFrom(cls)) {
+ Class<?> cls = ext.getClassObject(loader);
+ if (cls != null && type.isAssignableFrom(cls)) {
+ synchronized (ext) {
if (ext.getLoadedObject() == null) {
loadAndRegister(ext);
}
- ret.add(type.cast(ext.getLoadedObject()));
+ if (ext.getLoadedObject() != null) {
+ ret.add(type.cast(ext.getLoadedObject()));
+ }
}
}
}
- for (Extension ex : all.values()) {
+ for (Extension ex : ordered) {
if (ex != ext) {
- synchronized (ex) {
- Class<?> cls = ex.getClassObject(loader);
- if (cls != null && type.isAssignableFrom(cls)) {
+ Class<?> cls = ex.getClassObject(loader);
+ if (cls != null && type.isAssignableFrom(cls)) {
+ synchronized (ex) {
if (ex.getLoadedObject() == null) {
loadAndRegister(ex);
}
- ret.add(type.cast(ex.getLoadedObject()));
+ if (ex.getLoadedObject() != null) {
+ ret.add(type.cast(ex.getLoadedObject()));
+ }
}
}
}
@@ -348,19 +358,20 @@ private void invokeSetterActivationNSMethod(Object target, Object value) {
}
public <T> boolean loadBeansOfType(Class<T> type, BeanLoaderListener<T> listener) {
boolean loaded = false;
- for (Extension ex : all.values()) {
- synchronized (ex) {
- Class<?> cls = ex.getClassObject(loader);
- if (cls != null
- && type.isAssignableFrom(cls)
- && listener.loadBean(ex.getName(), cls.asSubclass(type))) {
- if (ex.getLoadedObject() == null) {
- loadAndRegister(ex);
- }
- if (listener.beanLoaded(ex.getName(), type.cast(ex.getLoadedObject()))) {
- return true;
+ for (Extension ex : ordered) {
+ Class<?> cls = ex.getClassObject(loader);
+ if (cls != null
+ && type.isAssignableFrom(cls)) {
+ synchronized (ex) {
+ if (listener.loadBean(ex.getName(), cls.asSubclass(type))) {
+ if (ex.getLoadedObject() == null) {
+ loadAndRegister(ex);
+ }
+ if (listener.beanLoaded(ex.getName(), type.cast(ex.getLoadedObject()))) {
+ return true;
+ }
+ loaded = true;
}
- loaded = true;
}
}
}
@@ -375,7 +386,7 @@ public boolean hasConfiguredPropertyValue(String beanName, String propertyName,
&& ex.getNamespaces().contains(value);
}
public void destroyBeans() {
- for (Extension ex : all.values()) {
+ for (Extension ex : ordered) {
if (ex.getLoadedObject() != null) {
ResourceInjector injector = new ResourceInjector(resourceManager);
injector.destroy(ex.getLoadedObject());
diff --git a/core/src/main/java/org/apache/cxf/bus/osgi/OSGIBusListener.java b/core/src/main/java/org/apache/cxf/bus/osgi/OSGIBusListener.java
index 42ae100ad18..ed4d2846a64 100644
--- a/core/src/main/java/org/apache/cxf/bus/osgi/OSGIBusListener.java
+++ b/core/src/main/java/org/apache/cxf/bus/osgi/OSGIBusListener.java
@@ -92,9 +92,9 @@ private void registerConfiguredBeanLocator() {
}
public void initComplete() {
- WorkQueueManager manager = bus.getExtension(WorkQueueManager.class);
ManagedWorkQueueList wqList = bus.getExtension(ManagedWorkQueueList.class);
if (wqList != null) {
+ WorkQueueManager manager = bus.getExtension(WorkQueueManager.class);
wqList.addAllToWorkQueueManager(manager);
}
registerBusAsService();
diff --git a/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java b/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
index d3f200d1a89..847ce28006d 100644
--- a/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
+++ b/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
@@ -168,30 +168,30 @@ public void setBus(Bus bb) {
if (bus == bb) {
return;
}
- bus = bb;
if (properties != null) {
- bus.setProperties(properties);
+ bb.setProperties(properties);
properties = null;
}
if (!getInInterceptors().isEmpty()) {
- bus.getInInterceptors().addAll(getInInterceptors());
+ bb.getInInterceptors().addAll(getInInterceptors());
}
if (!getOutInterceptors().isEmpty()) {
- bus.getOutInterceptors().addAll(getOutInterceptors());
+ bb.getOutInterceptors().addAll(getOutInterceptors());
}
if (!getInFaultInterceptors().isEmpty()) {
- bus.getInFaultInterceptors().addAll(getInFaultInterceptors());
+ bb.getInFaultInterceptors().addAll(getInFaultInterceptors());
}
if (!getOutFaultInterceptors().isEmpty()) {
- bus.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
+ bb.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
}
if (!StringUtils.isEmpty(id)) {
- bus.setId(id);
+ bb.setId(id);
}
if (features != null) {
- bus.setFeatures(features);
+ bb.setFeatures(features);
features = null;
}
+ bus = bb;
}
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
diff --git a/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java b/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
index 28294a427ed..d4b900ece2f 100644
--- a/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/jaxb/JAXBUtils.java
@@ -699,8 +699,10 @@ public static void logGeneratedClassNames(Logger logger, JCodeModel codeModel) {
}
return classes;
}
-
public static Object createFileCodeWriter(File f) throws JAXBException {
+ return createFileCodeWriter(f, "UTF-8");
+ }
+ public static Object createFileCodeWriter(File f, String encoding) throws JAXBException {
try {
Class<?> cls;
try {
@@ -710,6 +712,14 @@ public static Object createFileCodeWriter(File f) throws JAXBException {
cls = Class.forName("com.sun.codemodel.internal.writer.FileCodeWriter",
true, getXJCClassLoader());
}
+ if (encoding != null) {
+ try {
+ return cls.getConstructor(File.class, String.class)
+ .newInstance(f, encoding);
+ } catch (Exception ex) {
+ // try a single argument constructor
+ }
+ }
return cls.getConstructor(File.class).newInstance(f);
} catch (Exception ex) {
throw new JAXBException(ex);
diff --git a/core/src/main/java/org/apache/cxf/common/util/ASMHelper.java b/core/src/main/java/org/apache/cxf/common/util/ASMHelper.java
index b1839688e9d..bf1d692a00e 100644
--- a/core/src/main/java/org/apache/cxf/common/util/ASMHelper.java
+++ b/core/src/main/java/org/apache/cxf/common/util/ASMHelper.java
@@ -41,7 +41,9 @@
protected static final Map<Class<?>, String> NONPRIMITIVE_MAP = new HashMap<Class<?>, String>();
protected static final Map<Class<?>, Integer> PRIMITIVE_ZERO_MAP = new HashMap<Class<?>, Integer>();
- protected static final Map<Class<?>, WeakReference<TypeHelperClassLoader>> LOADER_MAP
+ protected static final Map<ClassLoader, WeakReference<TypeHelperClassLoader>> LOADER_MAP
+ = new WeakIdentityHashMap<ClassLoader, WeakReference<TypeHelperClassLoader>>();
+ protected static final Map<Class<?>, WeakReference<TypeHelperClassLoader>> CLASS_MAP
= new WeakIdentityHashMap<Class<?>, WeakReference<TypeHelperClassLoader>>();
protected static boolean badASM;
@@ -308,7 +310,7 @@ public ClassWriter createClassWriter() {
}
- public Class<?> loadClass(String className, Class<?> clz , byte[] bytes) {
+ public Class<?> loadClass(String className, Class<?> clz , byte[] bytes) {
TypeHelperClassLoader loader = getTypeHelperClassLoader(clz);
synchronized (loader) {
Class<?> cls = loader.lookupDefinedClass(className);
@@ -318,22 +320,47 @@ public ClassWriter createClassWriter() {
return cls;
}
}
+ public Class<?> loadClass(String className, ClassLoader l , byte[] bytes) {
+ TypeHelperClassLoader loader = getTypeHelperClassLoader(l);
+ synchronized (loader) {
+ Class<?> cls = loader.lookupDefinedClass(className);
+ if (cls == null) {
+ return loader.defineClass(className, bytes);
+ }
+ return cls;
+ }
+ }
public Class<?> findClass(String className, Class<?> clz) {
TypeHelperClassLoader loader = getTypeHelperClassLoader(clz);
return loader.lookupDefinedClass(className);
}
+ public Class<?> findClass(String className, ClassLoader l) {
+ TypeHelperClassLoader loader = getTypeHelperClassLoader(l);
+ return loader.lookupDefinedClass(className);
+ }
- private static synchronized TypeHelperClassLoader getTypeHelperClassLoader(Class<?> l) {
+ private static synchronized TypeHelperClassLoader getTypeHelperClassLoader(ClassLoader l) {
WeakReference<TypeHelperClassLoader> ref = LOADER_MAP.get(l);
TypeHelperClassLoader ret;
if (ref == null || ref.get() == null) {
- ret = new TypeHelperClassLoader(l.getClassLoader());
+ ret = new TypeHelperClassLoader(l);
LOADER_MAP.put(l, new WeakReference<TypeHelperClassLoader>(ret));
} else {
ret = ref.get();
}
return ret;
}
+ private static synchronized TypeHelperClassLoader getTypeHelperClassLoader(Class<?> cls) {
+ WeakReference<TypeHelperClassLoader> ref = CLASS_MAP.get(cls);
+ TypeHelperClassLoader ret;
+ if (ref == null || ref.get() == null) {
+ ret = new TypeHelperClassLoader(cls.getClassLoader());
+ CLASS_MAP.put(cls, new WeakReference<TypeHelperClassLoader>(ret));
+ } else {
+ ret = ref.get();
+ }
+ return ret;
+ }
public static class TypeHelperClassLoader extends ClassLoader {
ConcurrentHashMap<String, Class<?>> defined = new ConcurrentHashMap<String, Class<?>>();
diff --git a/core/src/main/java/org/apache/cxf/common/util/Base64OutputStream.java b/core/src/main/java/org/apache/cxf/common/util/Base64OutputStream.java
index 6ba8e95e75b..61724d8b57b 100644
--- a/core/src/main/java/org/apache/cxf/common/util/Base64OutputStream.java
+++ b/core/src/main/java/org/apache/cxf/common/util/Base64OutputStream.java
@@ -65,14 +65,14 @@ private void encodeAndWrite(byte[] b, int off, int len, boolean finalWrite) thro
@Override
public void flush() throws IOException {
- if (flushed) {
+ if (flushed || lastChunk == null) {
return;
}
try {
Base64Utility.encodeAndStream(lastChunk, 0, lastChunk.length, urlSafe, out);
lastChunk = null;
} catch (Exception ex) {
- throw new SecurityException();
+ throw new IOException(ex);
}
flushed = true;
}
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/Base64UrlOutputStream.java b/core/src/main/java/org/apache/cxf/common/util/Base64UrlOutputStream.java
similarity index 90%
rename from rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/Base64UrlOutputStream.java
rename to core/src/main/java/org/apache/cxf/common/util/Base64UrlOutputStream.java
index 549b06270bc..8b2a43ab262 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/Base64UrlOutputStream.java
+++ b/core/src/main/java/org/apache/cxf/common/util/Base64UrlOutputStream.java
@@ -16,12 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.cxf.rs.security.oauth2.utils;
+package org.apache.cxf.common.util;
import java.io.OutputStream;
-import org.apache.cxf.common.util.Base64OutputStream;
-
public class Base64UrlOutputStream extends Base64OutputStream {
public Base64UrlOutputStream(OutputStream out) {
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/Base64UrlUtility.java b/core/src/main/java/org/apache/cxf/common/util/Base64UrlUtility.java
similarity index 93%
rename from rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/Base64UrlUtility.java
rename to core/src/main/java/org/apache/cxf/common/util/Base64UrlUtility.java
index 9433b9731f1..25dc0df56e9 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/utils/Base64UrlUtility.java
+++ b/core/src/main/java/org/apache/cxf/common/util/Base64UrlUtility.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.cxf.rs.security.oauth2.utils;
+package org.apache.cxf.common.util;
/**
* Base64 URL Encoding/Decoding utility.
@@ -31,9 +31,6 @@
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
-import org.apache.cxf.common.util.Base64Exception;
-import org.apache.cxf.common.util.Base64Utility;
-
public final class Base64UrlUtility {
private Base64UrlUtility() {
diff --git a/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java b/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
index 645f7803811..68ea3b3a312 100644
--- a/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
+++ b/core/src/main/java/org/apache/cxf/common/util/ClassHelper.java
@@ -19,40 +19,53 @@
package org.apache.cxf.common.util;
+import java.lang.reflect.Proxy;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+
/**
*
*/
public class ClassHelper {
static final ClassHelper HELPER;
static {
- ClassHelper theHelper = null;
- try {
- theHelper = new SpringAopClassHelper();
- } catch (Throwable ex) {
- theHelper = new ClassHelper();
- }
- HELPER = theHelper;
+ HELPER = getClassHelper();
}
protected ClassHelper() {
}
+ private static ClassHelper getClassHelper() {
+ boolean useSpring = true;
+ String s = SystemPropertyAction.getPropertyOrNull("org.apache.cxf.useSpringClassHelpers");
+ if (!StringUtils.isEmpty(s)) {
+ useSpring = "1".equals(s) || Boolean.parseBoolean(s);
+ }
+ if (useSpring) {
+ try {
+ return new SpringAopClassHelper();
+ } catch (Throwable ex) {
+ // ignore
+ }
+ }
+ return new ClassHelper();
+ }
+
protected Class<?> getRealClassInternal(Object o) {
- return o.getClass();
+ return getRealObjectInternal(o).getClass();
}
protected Class<?> getRealClassFromClassInternal(Class<?> cls) {
return cls;
}
protected Object getRealObjectInternal(Object o) {
- return o;
+ return o instanceof Proxy ? Proxy.getInvocationHandler(o) : o;
}
-
-
public static Class<?> getRealClass(Object o) {
- return HELPER.getRealClassInternal(o);
+ return getRealClass(null, o);
}
public static Class<?> getRealClassFromClass(Class<?> cls) {
@@ -63,5 +76,14 @@ public static Object getRealObject(Object o) {
return HELPER.getRealObjectInternal(o);
}
+ public static Class<?> getRealClass(Bus bus, Object o) {
+ bus = bus == null ? BusFactory.getThreadDefaultBus() : bus;
+ if (bus != null && bus.getProperty(ClassUnwrapper.class.getName()) != null) {
+ ClassUnwrapper unwrapper = (ClassUnwrapper)bus.getProperty(ClassUnwrapper.class.getName());
+ return unwrapper.getRealClass(o);
+ } else {
+ return HELPER.getRealClassInternal(o);
+ }
+ }
}
diff --git a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweCryptoProperties.java b/core/src/main/java/org/apache/cxf/common/util/ClassUnwrapper.java
similarity index 88%
rename from rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweCryptoProperties.java
rename to core/src/main/java/org/apache/cxf/common/util/ClassUnwrapper.java
index 0553996f1fa..c3f8361e66d 100644
--- a/rt/rs/security/oauth-parent/oauth2-jwt/src/main/java/org/apache/cxf/rs/security/oauth2/jwe/JweCryptoProperties.java
+++ b/core/src/main/java/org/apache/cxf/common/util/ClassUnwrapper.java
@@ -16,7 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.cxf.rs.security.oauth2.jwe;
+package org.apache.cxf.common.util;
+
+public interface ClassUnwrapper {
+
+ Class<?> getRealClass(Object o);
-public class JweCryptoProperties {
}
diff --git a/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java b/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
index 870e7496667..68674a3d06c 100644
--- a/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
+++ b/core/src/main/java/org/apache/cxf/common/util/ClasspathScanner.java
@@ -32,18 +32,12 @@
public class ClasspathScanner {
public static final String ALL_FILES = "**/*";
public static final String ALL_CLASS_FILES = ALL_FILES + ".class";
- public static final String ALL_PACKAGES = "*";
+ public static final String WILDCARD = "*";
public static final String CLASSPATH_URL_SCHEME = "classpath:";
static final ClasspathScanner HELPER;
static {
- ClasspathScanner theHelper = null;
- try {
- theHelper = new SpringClasspathScanner();
- } catch (Throwable ex) {
- theHelper = new ClasspathScanner();
- }
- HELPER = theHelper;
+ HELPER = getClasspathScanner();
}
// Default packages list to ignore during classpath scanning
@@ -53,6 +47,22 @@
protected ClasspathScanner() {
}
+ private static ClasspathScanner getClasspathScanner() {
+ boolean useSpring = true;
+ String s = SystemPropertyAction.getPropertyOrNull("org.apache.cxf.useSpringClassHelpers");
+ if (!StringUtils.isEmpty(s)) {
+ useSpring = "1".equals(s) || Boolean.parseBoolean(s);
+ }
+ if (useSpring) {
+ try {
+ return new SpringClasspathScanner();
+ } catch (Throwable ex) {
+ // ignore
+ }
+ }
+ return new ClasspathScanner();
+ }
+
/**
* Scans list of base packages for all classes marked with specific annotations.
* @param basePackage base package
@@ -120,7 +130,19 @@ protected ClasspathScanner() {
*/
public static List<URL> findResources(String basePackage, String extension)
throws IOException {
- return findResources(Collections.singletonList(basePackage), extension);
+ return findResources(basePackage, extension, null);
+ }
+
+ /**
+ * Scans list of base packages for all resources with the given extension.
+ * @param basePackage base package
+ * @param extension the extension matching resources needs to have
+ * @return list of all discovered resource URLs
+ * @throws IOException resource is not accessible
+ */
+ public static List<URL> findResources(String basePackage, String extension, ClassLoader loader)
+ throws IOException {
+ return findResources(Collections.singletonList(basePackage), extension, loader);
}
/**
@@ -146,7 +168,7 @@ protected ClasspathScanner() {
final Set<String> basePackages = new HashSet<String>(values.length);
for (final String value : values) {
final String trimmed = value.trim();
- if (trimmed.equals(ClasspathScanner.ALL_PACKAGES)) {
+ if (trimmed.equals(WILDCARD)) {
basePackages.clear();
basePackages.add(trimmed);
break;
diff --git a/core/src/main/java/org/apache/cxf/common/util/MessageDigestInputStream.java b/core/src/main/java/org/apache/cxf/common/util/MessageDigestInputStream.java
new file mode 100644
index 00000000000..d08940367df
--- /dev/null
+++ b/core/src/main/java/org/apache/cxf/common/util/MessageDigestInputStream.java
@@ -0,0 +1,48 @@
+/**
+ * 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.apache.cxf.common.util;
+
+import java.io.InputStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+public class MessageDigestInputStream extends java.security.DigestInputStream {
+ public static final String ALGO_SHA_256 = "SHA-256";
+
+ public MessageDigestInputStream(InputStream is) {
+ super(is, getDigestInstance(ALGO_SHA_256));
+ }
+
+ private static MessageDigest getDigestInstance(String algo) {
+ try {
+ return MessageDigest.getInstance(algo);
+ } catch (NoSuchAlgorithmException ex) {
+ throw new SecurityException(ex);
+ }
+ }
+ public byte[] getDigestBytes() {
+ return super.getMessageDigest().digest();
+ }
+ public String getBase64Digest() {
+ return Base64Utility.encode(getDigestBytes());
+ }
+ public String getBase64UrlDigest() {
+ return Base64UrlUtility.encode(getDigestBytes());
+ }
+}
diff --git a/core/src/main/java/org/apache/cxf/common/util/ProxyHelper.java b/core/src/main/java/org/apache/cxf/common/util/ProxyHelper.java
index 27f2c56237d..89bdad3c58e 100644
--- a/core/src/main/java/org/apache/cxf/common/util/ProxyHelper.java
+++ b/core/src/main/java/org/apache/cxf/common/util/ProxyHelper.java
@@ -20,6 +20,7 @@
package org.apache.cxf.common.util;
import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
/**
@@ -73,6 +74,15 @@ private boolean canSeeAllInterfaces(ClassLoader loader, Class<?>[] interfaces) {
if (ifClass != currentInterface) {
return false;
}
+ //we need to check all the params/returns as well as the Proxy creation
+ //will try to create methods for all of this even if they aren't used
+ //by the client and not available in the clients classloader
+ for (Method m : ifClass.getMethods()) {
+ Class.forName(m.getReturnType().getName(), true, loader);
+ for (Class<?> p : m.getParameterTypes()) {
+ Class.forName(p.getName(), true, loader);
+ }
+ }
} catch (NoClassDefFoundError e) {
return false;
} catch (ClassNotFoundException e) {
diff --git a/core/src/main/java/org/apache/cxf/common/util/SpringClasspathScanner.java b/core/src/main/java/org/apache/cxf/common/util/SpringClasspathScanner.java
index b026c66d092..769d1f03056 100644
--- a/core/src/main/java/org/apache/cxf/common/util/SpringClasspathScanner.java
+++ b/core/src/main/java/org/apache/cxf/common/util/SpringClasspathScanner.java
@@ -70,11 +70,10 @@
}
for (final String basePackage: basePackages) {
- final boolean scanAllPackages = basePackage.equals(ALL_PACKAGES);
-
+ final boolean scanAllPackages = basePackage.equals(WILDCARD);
final String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
- + (scanAllPackages ? "" : ClassUtils.convertClassNameToResourcePath(basePackage))
- + ALL_CLASS_FILES;
+ + (scanAllPackages ? "" : basePackage.contains(WILDCARD) ? basePackage
+ : ClassUtils.convertClassNameToResourcePath(basePackage)) + ALL_CLASS_FILES;
final Resource[] resources = resolver.getResources(packageSearchPath);
@@ -136,7 +135,7 @@
ResourcePatternResolver resolver = getResolver(loader);
for (final String basePackage: basePackages) {
- final boolean scanAllPackages = basePackage.equals(ALL_PACKAGES);
+ final boolean scanAllPackages = basePackage.equals(WILDCARD);
String theBasePackage = basePackage;
if (theBasePackage.startsWith(CLASSPATH_URL_SCHEME)) {
@@ -144,8 +143,8 @@
}
final String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
- + (scanAllPackages ? "" : ClassUtils.convertClassNameToResourcePath(theBasePackage))
- + ALL_FILES + "." + extension;
+ + (scanAllPackages ? "" : basePackage.contains(WILDCARD) ? basePackage
+ : ClassUtils.convertClassNameToResourcePath(theBasePackage)) + ALL_FILES + "." + extension;
final Resource[] resources = resolver.getResources(packageSearchPath);
for (final Resource resource: resources) {
diff --git a/core/src/main/java/org/apache/cxf/common/util/StringUtils.java b/core/src/main/java/org/apache/cxf/common/util/StringUtils.java
index 9bcb79f341f..aa34a6cff72 100644
--- a/core/src/main/java/org/apache/cxf/common/util/StringUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/util/StringUtils.java
@@ -20,6 +20,7 @@
package org.apache.cxf.common.util;
import java.io.File;
+import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
@@ -197,4 +198,26 @@ public static String uncapitalize(String str) {
.append(str.substring(1))
.toString();
}
+
+ public static byte[] toBytesUTF8(String str) {
+ return toBytes(str, "UTF-8");
+ }
+ public static byte[] toBytesASCII(String str) {
+ return toBytes(str, "US-ASCII");
+ }
+ public static byte[] toBytes(String str, String enc) {
+ try {
+ return str.getBytes(enc);
+ } catch (UnsupportedEncodingException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public static String toHexString(byte[] bytes) {
+ StringBuilder hexString = new StringBuilder();
+ for (int i = 0; i < bytes.length; i++) {
+ hexString.append(Integer.toHexString(0xFF & bytes[i]));
+ }
+ return hexString.toString();
+ }
}
diff --git a/core/src/main/java/org/apache/cxf/common/util/UrlUtils.java b/core/src/main/java/org/apache/cxf/common/util/UrlUtils.java
index 1e16677f7a0..8b2518e599f 100644
--- a/core/src/main/java/org/apache/cxf/common/util/UrlUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/util/UrlUtils.java
@@ -20,13 +20,12 @@
package org.apache.cxf.common.util;
import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
-import java.util.logging.Logger;
-
-import org.apache.cxf.common.logging.LogUtils;
/**
* Utility class for decoding and encoding URLs
@@ -34,28 +33,89 @@
*/
public final class UrlUtils {
- private static final Logger LOG = LogUtils.getL7dLogger(UrlUtils.class);
-
- private static final String[] RESERVED_CHARS = {"+"};
- private static final String[] ENCODED_CHARS = {"%2b"};
+ private static final int RADIX = 16;
+ private static final byte ESCAPE_CHAR = '%';
+ private static final byte PLUS_CHAR = '+';
private UrlUtils() {
}
+ public static String urlEncode(String value) {
+
+ return urlEncode(value, "UTF-8");
+ }
+
+ public static String urlEncode(String value, String enc) {
+
+ try {
+ value = URLEncoder.encode(value, enc);
+ } catch (UnsupportedEncodingException ex) {
+ throw new RuntimeException(ex);
+ }
+
+ return value;
+ }
+
/**
* Decodes using URLDecoder - use when queries or form post values are decoded
* @param value value to decode
* @param enc encoding
*/
public static String urlDecode(String value, String enc) {
- try {
- value = URLDecoder.decode(value, enc);
- } catch (UnsupportedEncodingException e) {
- LOG.warning("UTF-8 encoding can not be used to decode " + value);
+ return urlDecode(value, enc, false);
+ }
+
+ private static String urlDecode(String value, String enc, boolean isPath) {
+
+ boolean needDecode = false;
+ int escapesCount = 0;
+ int i = 0;
+ while (i < value.length()) {
+ char ch = value.charAt(i++);
+ if (ch == ESCAPE_CHAR) {
+ escapesCount += 1;
+ i += 2;
+ needDecode = true;
+ } else if (!isPath && ch == PLUS_CHAR) {
+ needDecode = true;
+ }
+ }
+ if (needDecode) {
+ final byte[] valueBytes = StringUtils.toBytes(value, enc);
+ ByteBuffer in = ByteBuffer.wrap(valueBytes);
+ ByteBuffer out = ByteBuffer.allocate(in.capacity() - 2 * escapesCount);
+ while (in.hasRemaining()) {
+ final int b = in.get();
+ if (!isPath && b == PLUS_CHAR) {
+ out.put((byte) ' ');
+ } else if (b == ESCAPE_CHAR) {
+ try {
+ final int u = digit16((byte) in.get());
+ final int l = digit16((byte) in.get());
+ out.put((byte) ((u << 4) + l));
+ } catch (final ArrayIndexOutOfBoundsException e) {
+ throw new RuntimeException("Invalid URL encoding: ", e);
+ }
+ } else {
+ out.put((byte) b);
+ }
+ }
+ out.flip();
+ return Charset.forName(enc).decode(out).toString();
+ } else {
+ return value;
}
- return value;
}
+
+ private static int digit16(final byte b) {
+ final int i = Character.digit((char) b, RADIX);
+ if (i == -1) {
+ throw new RuntimeException("Invalid URL encoding: not a valid digit (radix " + RADIX + "): " + b);
+ }
+ return i;
+ }
+
public static String urlDecode(String value) {
return urlDecode(value, "UTF-8");
@@ -67,15 +127,7 @@ public static String urlDecode(String value) {
* @param value value to decode
*/
public static String pathDecode(String value) {
- // TODO: we actually need to do a proper URI analysis here according to
- // http://tools.ietf.org/html/rfc3986
- for (int i = 0; i < RESERVED_CHARS.length; i++) {
- if (value.indexOf(RESERVED_CHARS[i]) != -1) {
- value = value.replace(RESERVED_CHARS[i], ENCODED_CHARS[i]);
- }
- }
-
- return urlDecode(value);
+ return urlDecode(value, "UTF-8", true);
}
diff --git a/core/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java b/core/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
index 09329139d00..a9b6a1c7617 100644
--- a/core/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
+++ b/core/src/main/java/org/apache/cxf/common/xmlschema/SchemaCollection.java
@@ -43,7 +43,6 @@
import org.apache.ws.commons.schema.XmlSchemaContent;
import org.apache.ws.commons.schema.XmlSchemaContentModel;
import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.apache.ws.commons.schema.XmlSchemaObject;
import org.apache.ws.commons.schema.XmlSchemaParticle;
import org.apache.ws.commons.schema.XmlSchemaSequence;
import org.apache.ws.commons.schema.XmlSchemaSequenceMember;
@@ -54,6 +53,7 @@
import org.apache.ws.commons.schema.resolver.URIResolver;
import org.apache.ws.commons.schema.utils.NamespaceMap;
import org.apache.ws.commons.schema.utils.NamespacePrefixList;
+import org.apache.ws.commons.schema.utils.XmlSchemaObjectBase;
/**
* Wrapper class for XmlSchemaCollection that deals with various quirks and bugs.
@@ -312,7 +312,7 @@ private void addCrossImportsType(XmlSchema schema, XmlSchemaType schemaType) {
}
}
private void addCrossImports(XmlSchema schema, XmlSchemaAll all) {
- for (XmlSchemaObject seqMember : all.getItems()) {
+ for (XmlSchemaObjectBase seqMember : all.getItems()) {
if (seqMember instanceof XmlSchemaElement) {
addElementCrossImportsElement(schema, (XmlSchemaElement)seqMember);
}
@@ -320,7 +320,7 @@ private void addCrossImports(XmlSchema schema, XmlSchemaAll all) {
}
private void addCrossImports(XmlSchema schema, XmlSchemaChoice choice) {
- for (XmlSchemaObject seqMember : choice.getItems()) {
+ for (XmlSchemaObjectBase seqMember : choice.getItems()) {
if (seqMember instanceof XmlSchemaElement) {
addElementCrossImportsElement(schema, (XmlSchemaElement)seqMember);
}
diff --git a/core/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java b/core/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java
index 70f22002ba3..dbff0c0165c 100644
--- a/core/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/xmlschema/XmlSchemaUtils.java
@@ -238,8 +238,8 @@ public static QName getBaseType(XmlSchemaComplexType type) {
return ext.getAttributes();
}
- public static List<XmlSchemaAnnotated>
- getContentAttributes(XmlSchemaComplexType type, SchemaCollection collection) {
+ public static List<XmlSchemaAnnotated> getContentAttributes(XmlSchemaComplexType type,
+ SchemaCollection collection) {
List<XmlSchemaAnnotated> results = new ArrayList<XmlSchemaAnnotated>();
QName baseTypeName = getBaseType(type);
if (baseTypeName != null) {
diff --git a/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java b/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
index 6be1e3cc1b7..c71601c9673 100644
--- a/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
+++ b/core/src/main/java/org/apache/cxf/configuration/blueprint/AbstractBPBeanDefinitionParser.java
@@ -52,7 +52,6 @@
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.staxutils.StaxUtils;
-import org.osgi.framework.Bundle;
import org.osgi.service.blueprint.reflect.BeanMetadata;
import org.osgi.service.blueprint.reflect.CollectionMetadata;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
@@ -266,11 +265,7 @@ public static MutableBeanMetadata createObjectOfClass(ParserContext context, Str
protected MutableBeanMetadata getBus(ParserContext context, String name) {
ComponentDefinitionRegistry cdr = context.getComponentDefinitionRegistry();
ComponentMetadata meta = cdr.getComponentDefinition("blueprintBundle");
-
- Bundle blueprintBundle = null;
- if (meta instanceof PassThroughMetadata) {
- blueprintBundle = (Bundle) ((PassThroughMetadata) meta).getObject();
- }
+
if (!cdr.containsComponentDefinition(InterceptorTypeConverter.class.getName())) {
MutablePassThroughMetadata md = context.createMetadata(MutablePassThroughMetadata.class);
md.setObject(new InterceptorTypeConverter());
@@ -278,13 +273,16 @@ protected MutableBeanMetadata getBus(ParserContext context, String name) {
md.setId(InterceptorTypeConverter.class.getName());
context.getComponentDefinitionRegistry().registerTypeConverter(md);
}
- if (blueprintBundle != null && !cdr.containsComponentDefinition(name)) {
+ if (!cdr.containsComponentDefinition(name)) {
//Create a bus
MutableBeanMetadata bus = context.createMetadata(MutableBeanMetadata.class);
bus.setId(name);
bus.setRuntimeClass(BlueprintBus.class);
- bus.addProperty("bundleContext", createRef(context, "blueprintBundleContext"));
+ if (meta != null) {
+ //blueprint-no-osgi does not provide a bundleContext
+ bus.addProperty("bundleContext", createRef(context, "blueprintBundleContext"));
+ }
bus.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
bus.setDestroyMethod("shutdown");
bus.setInitMethod("initialize");
diff --git a/core/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java b/core/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java
index 09068187608..ebae85d22a6 100644
--- a/core/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java
+++ b/core/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java
@@ -22,6 +22,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
+import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.Method;
@@ -67,14 +68,18 @@
private static final boolean DEFAULT_REQUIRE_CLIENT_AUTHENTICATION = false;
private static final boolean DEFAULT_WANT_CLIENT_AUTHENTICATION = true;
- /**
- * By default, only include export-compatible ciphersuites.
- */
private static final List<String> DEFAULT_CIPHERSUITE_FILTERS_INCLUDE =
Arrays.asList(new String[] {".*"});
+ /**
+ * By default, exclude NULL, anon, EXPORT, DES ciphersuites
+ */
private static final List<String> DEFAULT_CIPHERSUITE_FILTERS_EXCLUDE =
Arrays.asList(new String[] {".*_NULL_.*",
- ".*_anon_.*"});
+ ".*_anon_.*",
+ ".*_EXPORT_.*",
+ ".*_DES_.*"});
+
+ private static volatile KeyManager[] defaultManagers;
private SSLUtils() {
}
@@ -147,23 +152,42 @@ private SSLUtils() {
}
public static KeyManager[] getDefaultKeyStoreManagers(Logger log) {
+ if (defaultManagers == null) {
+ loadDefaultKeyManagers(log);
+ }
+ if (defaultManagers.length == 0) {
+ return null;
+ }
+ return defaultManagers;
+ }
+ private static synchronized void loadDefaultKeyManagers(Logger log) {
+ if (defaultManagers != null) {
+ return;
+ }
+
String location = getKeystore(null, log);
String keyStorePassword = getKeystorePassword(null, log);
String keyPassword = getKeyPassword(null, log);
FileInputStream fis = null;
try {
- KeyManagerFactory kmf =
- KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
- KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
-
- fis = new FileInputStream(location);
- ks.load(fis, (keyStorePassword != null) ? keyStorePassword.toCharArray() : null);
- kmf.init(ks, (keyPassword != null) ? keyPassword.toCharArray() : null);
- return kmf.getKeyManagers();
+ File file = new File(location);
+ if (file.exists()) {
+ KeyManagerFactory kmf =
+ KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+ KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
+
+ fis = new FileInputStream(file);
+ ks.load(fis, (keyStorePassword != null) ? keyStorePassword.toCharArray() : null);
+ kmf.init(ks, (keyPassword != null) ? keyPassword.toCharArray() : null);
+ defaultManagers = kmf.getKeyManagers();
+ } else {
+ log.log(Level.FINER, "No default keystore {0}", location);
+ defaultManagers = new KeyManager[0];
+ }
} catch (Exception e) {
- log.warning("Default key managers cannot be initialized: " + e.getMessage());
- return null;
+ log.log(Level.WARNING, "Default key managers cannot be initialized: " + e.getMessage(), e);
+ defaultManagers = new KeyManager[0];
} finally {
if (fis != null) {
try {
@@ -430,17 +454,23 @@ public static SSLContext getSSLContext(String protocol,
String[] supportedCipherSuites,
FiltersType filters,
Logger log, boolean exclude) {
- String[] cipherSuites = null;
- if (!(cipherSuitesList == null || cipherSuitesList.isEmpty())) {
- cipherSuites = getCiphersFromList(cipherSuitesList, log, exclude);
- return cipherSuites;
- }
+
+ // First check the "include" case only. If we have defined explicit "cipherSuite"
+ // configuration, then just return these. Otherwise see if we have defined ciphersuites
+ // via a system property.
if (!exclude) {
- cipherSuites = getSystemCiphersuites(log);
- if (cipherSuites != null) {
- return cipherSuites;
+ if (!(cipherSuitesList == null || cipherSuitesList.isEmpty())) {
+ return getCiphersFromList(cipherSuitesList, log, exclude);
+ } else {
+ String[] cipherSuites = getSystemCiphersuites(log);
+ if (cipherSuites != null) {
+ return cipherSuites;
+ }
}
}
+
+ // Otherwise check the "include/exclude" cipherSuiteFilter configuration
+
LogUtils.log(log, Level.FINE, "CIPHERSUITES_NOT_SET");
if (filters == null) {
LogUtils.log(log, Level.FINE, "CIPHERSUITE_FILTERS_NOT_SET");
@@ -480,11 +510,10 @@ public static SSLContext getSSLContext(String protocol,
"CIPHERSUITES_EXCLUDED",
excludedCipherSuites);
if (exclude) {
- cipherSuites = getCiphersFromList(excludedCipherSuites, log, exclude);
+ return getCiphersFromList(excludedCipherSuites, log, exclude);
} else {
- cipherSuites = getCiphersFromList(filteredCipherSuites, log, exclude);
+ return getCiphersFromList(filteredCipherSuites, log, exclude);
}
- return cipherSuites;
}
private static String[] getSystemCiphersuites(Logger log) {
diff --git a/core/src/main/java/org/apache/cxf/configuration/jsse/TLSParameterJaxBUtils.java b/core/src/main/java/org/apache/cxf/configuration/jsse/TLSParameterJaxBUtils.java
index 8996c8bad15..65965e98fb0 100644
--- a/core/src/main/java/org/apache/cxf/configuration/jsse/TLSParameterJaxBUtils.java
+++ b/core/src/main/java/org/apache/cxf/configuration/jsse/TLSParameterJaxBUtils.java
@@ -225,8 +225,7 @@ private static KeyStore createTrustStore(final java.io.InputStream is)
/**
* load the certificates as X.509 certificates
*/
- private static Collection<? extends Certificate>
- loadCertificates(final java.io.InputStream is)
+ private static Collection<? extends Certificate> loadCertificates(final java.io.InputStream is)
throws IOException, CertificateException {
final CertificateFactory factory = CertificateFactory.getInstance("X.509");
@@ -298,7 +297,7 @@ private static KeyStore createTrustStore(final java.io.InputStream is)
String alg = tmc.isSetFactoryAlgorithm()
? tmc.getFactoryAlgorithm()
- : KeyManagerFactory.getDefaultAlgorithm();
+ : TrustManagerFactory.getDefaultAlgorithm();
TrustManagerFactory fac =
tmc.isSetProvider()
diff --git a/core/src/main/java/org/apache/cxf/configuration/jsse/TLSServerParameters.java b/core/src/main/java/org/apache/cxf/configuration/jsse/TLSServerParameters.java
index ab94d38f954..52884c3a8f5 100644
--- a/core/src/main/java/org/apache/cxf/configuration/jsse/TLSServerParameters.java
+++ b/core/src/main/java/org/apache/cxf/configuration/jsse/TLSServerParameters.java
@@ -18,6 +18,9 @@
*/
package org.apache.cxf.configuration.jsse;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.cxf.configuration.security.ClientAuthentication;
/**
@@ -28,6 +31,7 @@
public class TLSServerParameters extends TLSParameterBase {
ClientAuthentication clientAuthentication;
+ List<String> excludeProtocols = new ArrayList<String>();
/**
* This parameter configures the server side to request and/or
@@ -43,4 +47,22 @@ public final void setClientAuthentication(ClientAuthentication clientAuth) {
public ClientAuthentication getClientAuthentication() {
return clientAuthentication;
}
+
+ /**
+ * This parameter sets the protocol list to exclude.
+ */
+ public final void setExcludeProtocols(List<String> protocols) {
+ excludeProtocols = protocols;
+ }
+
+ /**
+ * Returns the protocols to exclude that are associated with this endpoint.
+ */
+ public List<String> getExcludeProtocols() {
+ if (excludeProtocols == null) {
+ excludeProtocols = new ArrayList<String>();
+ }
+ return excludeProtocols;
+ }
+
}
diff --git a/core/src/main/java/org/apache/cxf/configuration/jsse/TLSServerParametersConfig.java b/core/src/main/java/org/apache/cxf/configuration/jsse/TLSServerParametersConfig.java
index 13d84e8ef4d..a9c9cd61d2b 100644
--- a/core/src/main/java/org/apache/cxf/configuration/jsse/TLSServerParametersConfig.java
+++ b/core/src/main/java/org/apache/cxf/configuration/jsse/TLSServerParametersConfig.java
@@ -54,6 +54,9 @@ public TLSServerParametersConfig(TLSServerParametersType params)
if (params.isSetCipherSuites()) {
this.setCipherSuites(params.getCipherSuites().getCipherSuite());
}
+ if (params.isSetExcludeProtocols()) {
+ this.setExcludeProtocols(params.getExcludeProtocols().getExcludeProtocol());
+ }
if (params.isSetJsseProvider()) {
this.setJsseProvider(params.getJsseProvider());
}
diff --git a/core/src/main/java/org/apache/cxf/databinding/AbstractWrapperHelper.java b/core/src/main/java/org/apache/cxf/databinding/AbstractWrapperHelper.java
index dcc09c921cf..b597c5f1285 100644
--- a/core/src/main/java/org/apache/cxf/databinding/AbstractWrapperHelper.java
+++ b/core/src/main/java/org/apache/cxf/databinding/AbstractWrapperHelper.java
@@ -39,6 +39,8 @@
protected final Method setMethods[];
protected final Method getMethods[];
protected final Field fields[];
+ protected boolean validate;
+
protected AbstractWrapperHelper(Class<?> wt,
Method sets[],
@@ -50,6 +52,19 @@ protected AbstractWrapperHelper(Class<?> wt,
wrapperType = wt;
}
+ /**
+ * WrapperClassOutInterceptor may call this if the wrapper class needs to be validated.
+ * Implementations may choose to ignore this as the SchemaValidation that occurs later
+ * may catch the errors, but this allows quicker failures if the databinding
+ * can support it.
+ */
+ public void setValidate(boolean v) {
+ validate = v;
+ }
+ public boolean getValidate() {
+ return validate;
+ }
+
public String getSignature() {
return "" + System.identityHashCode(this);
}
diff --git a/core/src/main/java/org/apache/cxf/endpoint/AbstractConduitSelector.java b/core/src/main/java/org/apache/cxf/endpoint/AbstractConduitSelector.java
index 7a3f9899e7d..7f1efb52157 100644
--- a/core/src/main/java/org/apache/cxf/endpoint/AbstractConduitSelector.java
+++ b/core/src/main/java/org/apache/cxf/endpoint/AbstractConduitSelector.java
@@ -234,9 +234,7 @@ protected Conduit findCompatibleConduit(Message message) {
if (c != null) {
return c;
}
- boolean full = MessageUtils.getContextualBoolean(message,
- CONDUIT_COMPARE_FULL_URL,
- false);
+ ContextualBooleanGetter cbg = new ContextualBooleanGetter(message);
for (Conduit c2 : conduits) {
if (c2.getTarget() == null
|| c2.getTarget().getAddress() == null
@@ -253,14 +251,7 @@ protected Conduit findCompatibleConduit(Message message) {
actualAddress = messageAddress;
}
- if (!full) {
- int idx = conduitAddress.indexOf(':');
- conduitAddress = idx == -1 ? "" : conduitAddress.substring(0, idx);
- idx = actualAddress.indexOf(':');
- actualAddress = idx == -1 ? "" : actualAddress.substring(0, idx);
- }
-
- if (conduitAddress.equalsIgnoreCase(actualAddress)) {
+ if (matchAddresses(conduitAddress, actualAddress, cbg)) {
return c2;
}
}
@@ -273,4 +264,51 @@ protected Conduit findCompatibleConduit(Message message) {
}
return null;
}
+
+ private boolean matchAddresses(String conduitAddress, String actualAddress, ContextualBooleanGetter cbg) {
+ if (conduitAddress.length() == actualAddress.length()) {
+ //let's be optimistic and try full comparison first, regardless of CONDUIT_COMPARE_FULL_URL value,
+ //which can be expensive to fetch; as a matter of fact, anyway, if the addresses fully match,
+ //their hosts also match
+ if (conduitAddress.equalsIgnoreCase(actualAddress)) {
+ return true;
+ } else {
+ return cbg.isFullComparison() ? false : matchAddressSubstrings(conduitAddress, actualAddress);
+ }
+ } else {
+ return cbg.isFullComparison() ? false : matchAddressSubstrings(conduitAddress, actualAddress);
+ }
+ }
+
+ //smart address substring comparison that tries to avoid building and comparing substrings unless strictly required
+ private boolean matchAddressSubstrings(String conduitAddress, String actualAddress) {
+ int idx = conduitAddress.indexOf(':');
+ if (idx == actualAddress.indexOf(':')) {
+ if (idx <= 0) {
+ return true;
+ }
+ conduitAddress = conduitAddress.substring(0, idx);
+ actualAddress = actualAddress.substring(0, idx);
+ return conduitAddress.equalsIgnoreCase(actualAddress);
+ } else {
+ //no possible match as for sure the substrings before idx will be different
+ return false;
+ }
+ }
+
+ private static final class ContextualBooleanGetter {
+ private Boolean value;
+ private final Message message;
+
+ public ContextualBooleanGetter(Message message) {
+ this.message = message;
+ }
+
+ public boolean isFullComparison() {
+ if (value == null) {
+ value = MessageUtils.getContextualBoolean(message, CONDUIT_COMPARE_FULL_URL, false);
+ }
+ return value;
+ }
+ }
}
diff --git a/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java b/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
index 289e919549b..775170cfcad 100644
--- a/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
+++ b/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
@@ -325,7 +325,9 @@ public void setThreadLocalRequestContext(boolean b) {
try {
return invoke(oi, params, context, exchange);
} finally {
- responseContext.put(Thread.currentThread(), resp);
+ if (responseContext != null) {
+ responseContext.put(Thread.currentThread(), resp);
+ }
}
}
public Object[] invoke(BindingOperationInfo oi,
@@ -336,7 +338,7 @@ public void setThreadLocalRequestContext(boolean b) {
} finally {
if (context != null) {
Map<String, Object> resp = CastUtils.cast((Map<?, ?>)context.get(RESPONSE_CONTEXT));
- if (resp != null) {
+ if (resp != null && responseContext != null) {
responseContext.put(Thread.currentThread(), resp);
}
}
@@ -699,7 +701,9 @@ protected void setParameters(Object[] params, Message message) {
}
public void onMessage(Message message) {
-
+ if (bus == null) {
+ throw new IllegalStateException("Message received on a Client that has been closed or destroyed.");
+ }
Endpoint endpoint = message.getExchange().getEndpoint();
if (endpoint == null) {
// in this case correlation will occur outside the transport,
@@ -809,7 +813,7 @@ public void onMessage(Message message) {
.getOutMessage()
.get(Message.INVOCATION_CONTEXT));
resCtx = CastUtils.cast((Map<?, ?>)resCtx.get(RESPONSE_CONTEXT));
- if (resCtx != null) {
+ if (resCtx != null && responseContext != null) {
responseContext.put(Thread.currentThread(), resCtx);
}
try {
diff --git a/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java b/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
index bb9d7fc32a4..5180594d075 100644
--- a/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
+++ b/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
@@ -167,11 +167,12 @@ public void stop() {
MessageObserver mo = getDestination().getMessageObserver();
if (mo instanceof MultipleEndpointObserver) {
((MultipleEndpointObserver)mo).getEndpoints().remove(endpoint);
- if (!((MultipleEndpointObserver)mo).getEndpoints().isEmpty()) {
- return;
+ if (((MultipleEndpointObserver)mo).getEndpoints().isEmpty()) {
+ getDestination().setMessageObserver(null);
}
- }
- getDestination().setMessageObserver(null);
+ } else {
+ getDestination().setMessageObserver(null);
+ }
stopped = true;
}
diff --git a/core/src/main/java/org/apache/cxf/feature/StaxTransformFeature.java b/core/src/main/java/org/apache/cxf/feature/StaxTransformFeature.java
index eb1392a5216..2a9bf83bd95 100644
--- a/core/src/main/java/org/apache/cxf/feature/StaxTransformFeature.java
+++ b/core/src/main/java/org/apache/cxf/feature/StaxTransformFeature.java
@@ -59,7 +59,11 @@ protected void initializeProvider(InterceptorProvider provider, Bus bus) {
public void setOutTransformElements(Map<String, String> outElements) {
out.setOutTransformElements(outElements);
}
-
+
+ public void setOutTransformAttributes(Map<String, String> outAttributes) {
+ out.setOutTransformAttributes(outAttributes);
+ }
+
public void setAttributesToElements(boolean value) {
out.setAttributesToElements(value);
}
@@ -75,7 +79,7 @@ public void setOutAppendElements(Map<String, String> map) {
public void setOutDropElements(List<String> dropElementsSet) {
out.setOutDropElements(dropElementsSet);
}
-
+
public void setInAppendElements(Map<String, String> inElements) {
in.setInAppendElements(inElements);
}
@@ -88,6 +92,10 @@ public void setInTransformElements(Map<String, String> inElements) {
in.setInTransformElements(inElements);
}
+ public void setInTransformAttributes(Map<String, String> inAttributes) {
+ in.setInTransformAttributes(inAttributes);
+ }
+
public void setOutDefaultNamespace(String ns) {
out.setDefaultNamespace(ns);
}
diff --git a/core/src/main/java/org/apache/cxf/feature/transform/AbstractXSLTInterceptor.java b/core/src/main/java/org/apache/cxf/feature/transform/AbstractXSLTInterceptor.java
index 2b92505a688..b18ffcf675d 100644
--- a/core/src/main/java/org/apache/cxf/feature/transform/AbstractXSLTInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/feature/transform/AbstractXSLTInterceptor.java
@@ -1,88 +1,88 @@
-/**
- * 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.apache.cxf.feature.transform;
-
-
-import java.io.InputStream;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.transform.Templates;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-
-import org.w3c.dom.Document;
-
-import org.apache.cxf.common.classloader.ClassLoaderUtils;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.message.MessageUtils;
-import org.apache.cxf.phase.AbstractPhaseInterceptor;
-import org.apache.cxf.staxutils.StaxUtils;
-
-
-/**
- * Creates an XMLStreamReader from the InputStream on the Message.
- */
-public abstract class AbstractXSLTInterceptor extends AbstractPhaseInterceptor<Message> {
- private static final TransformerFactory TRANSFORM_FACTORIY = TransformerFactory.newInstance();
-
- private String contextPropertyName;
- private final Templates xsltTemplate;
-
- public AbstractXSLTInterceptor(String phase, Class<?> before, Class<?> after, String xsltPath) {
- super(phase);
- if (before != null) {
- addBefore(before.getName());
- }
- if (after != null) {
- addAfter(after.getName());
- }
-
- try {
- InputStream xsltStream = ClassLoaderUtils.getResourceAsStream(xsltPath, this.getClass());
- if (xsltStream == null) {
- throw new IllegalArgumentException("Cannot load XSLT from path: " + xsltPath);
- }
- Document doc = StaxUtils.read(xsltStream);
- xsltTemplate = TRANSFORM_FACTORIY.newTemplates(new DOMSource(doc));
- } catch (TransformerConfigurationException e) {
- throw new IllegalArgumentException(
- String.format("Cannot create XSLT template from path: %s, error: ",
- xsltPath, e.getException()), e);
- } catch (XMLStreamException e) {
- throw new IllegalArgumentException(
- String.format("Cannot create XSLT template from path: %s, error: ",
- xsltPath, e.getNestedException()), e);
- }
- }
-
- public void setContextPropertyName(String propertyName) {
- contextPropertyName = propertyName;
- }
-
- protected boolean checkContextProperty(Message message) {
- return contextPropertyName != null
- && !MessageUtils.getContextualBoolean(message, contextPropertyName, false);
- }
-
- protected Templates getXSLTTemplate() {
- return xsltTemplate;
- }
-}
+/**
+ * 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.apache.cxf.feature.transform;
+
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.transform.Templates;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+
+import org.w3c.dom.Document;
+
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.staxutils.StaxUtils;
+
+
+/**
+ * Creates an XMLStreamReader from the InputStream on the Message.
+ */
+public abstract class AbstractXSLTInterceptor extends AbstractPhaseInterceptor<Message> {
+ private static final TransformerFactory TRANSFORM_FACTORIY = TransformerFactory.newInstance();
+
+ private String contextPropertyName;
+ private final Templates xsltTemplate;
+
+ public AbstractXSLTInterceptor(String phase, Class<?> before, Class<?> after, String xsltPath) {
+ super(phase);
+ if (before != null) {
+ addBefore(before.getName());
+ }
+ if (after != null) {
+ addAfter(after.getName());
+ }
+
+ try {
+ InputStream xsltStream = ClassLoaderUtils.getResourceAsStream(xsltPath, this.getClass());
+ if (xsltStream == null) {
+ throw new IllegalArgumentException("Cannot load XSLT from path: " + xsltPath);
+ }
+ Document doc = StaxUtils.read(xsltStream);
+ xsltTemplate = TRANSFORM_FACTORIY.newTemplates(new DOMSource(doc));
+ } catch (TransformerConfigurationException e) {
+ throw new IllegalArgumentException(
+ String.format("Cannot create XSLT template from path: %s, error: ",
+ xsltPath, e.getException()), e);
+ } catch (XMLStreamException e) {
+ throw new IllegalArgumentException(
+ String.format("Cannot create XSLT template from path: %s, error: ",
+ xsltPath, e.getNestedException()), e);
+ }
+ }
+
+ public void setContextPropertyName(String propertyName) {
+ contextPropertyName = propertyName;
+ }
+
+ protected boolean checkContextProperty(Message message) {
+ return contextPropertyName != null
+ && !MessageUtils.getContextualBoolean(message, contextPropertyName, false);
+ }
+
+ protected Templates getXSLTTemplate() {
+ return xsltTemplate;
+ }
+}
diff --git a/core/src/main/java/org/apache/cxf/feature/transform/Messages.properties b/core/src/main/java/org/apache/cxf/feature/transform/Messages.properties
index a473717fa43..e6e31a9f844 100644
--- a/core/src/main/java/org/apache/cxf/feature/transform/Messages.properties
+++ b/core/src/main/java/org/apache/cxf/feature/transform/Messages.properties
@@ -1,25 +1,25 @@
-#
-#
-# 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.
-#
-#
-STAX_COPY=Could not copy XML stream: {0}.
-STREAM_COPY=Could not copy stream: {0}.
-READER_COPY=Could not copy reader: {0}.
-GET_CACHED_INPUT_STREAM=Could not get cached input stream: {0}.
-XML_TRANSFORM=XSL transformation error: {0}.
+#
+#
+# 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.
+#
+#
+STAX_COPY=Could not copy XML stream: {0}.
+STREAM_COPY=Could not copy stream: {0}.
+READER_COPY=Could not copy reader: {0}.
+GET_CACHED_INPUT_STREAM=Could not get cached input stream: {0}.
+XML_TRANSFORM=XSL transformation error: {0}.
diff --git a/core/src/main/java/org/apache/cxf/feature/transform/XSLTFeature.java b/core/src/main/java/org/apache/cxf/feature/transform/XSLTFeature.java
index 8c913acaabe..511a61cd56f 100644
--- a/core/src/main/java/org/apache/cxf/feature/transform/XSLTFeature.java
+++ b/core/src/main/java/org/apache/cxf/feature/transform/XSLTFeature.java
@@ -1,60 +1,60 @@
-/**
- * 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.apache.cxf.feature.transform;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.common.injection.NoJSR250Annotations;
-import org.apache.cxf.feature.AbstractFeature;
-import org.apache.cxf.interceptor.InterceptorProvider;
-
-/**
- * This class defines a feature is used to transform message using XSLT script.
- * If this feature is present and inXSLTPath/outXLSTPath are initialised,
- * client and endpoint will transform incoming and outgoing messages correspondingly.
- * Attention: actually the feature breaks streaming
- * (can be fixed in further versions when XSLT engine supports XML stream).
- */
-@NoJSR250Annotations
-public class XSLTFeature extends AbstractFeature {
- private String inXSLTPath;
- private String outXSLTPath;
-
- @Override
- protected void initializeProvider(InterceptorProvider provider, Bus bus) {
- if (inXSLTPath != null) {
- XSLTInInterceptor in = new XSLTInInterceptor(inXSLTPath);
- provider.getInInterceptors().add(in);
- }
-
- if (outXSLTPath != null) {
- XSLTOutInterceptor out = new XSLTOutInterceptor(outXSLTPath);
- provider.getOutInterceptors().add(out);
- provider.getOutFaultInterceptors().add(out);
- }
- }
-
- public void setInXSLTPath(String inXSLTPath) {
- this.inXSLTPath = inXSLTPath;
- }
-
- public void setOutXSLTPath(String outXSLTPath) {
- this.outXSLTPath = outXSLTPath;
- }
-
-}
+/**
+ * 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.apache.cxf.feature.transform;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.interceptor.InterceptorProvider;
+
+/**
+ * This class defines a feature is used to transform message using XSLT script.
+ * If this feature is present and inXSLTPath/outXLSTPath are initialised,
+ * client and endpoint will transform incoming and outgoing messages correspondingly.
+ * Attention: actually the feature breaks streaming
+ * (can be fixed in further versions when XSLT engine supports XML stream).
+ */
+@NoJSR250Annotations
+public class XSLTFeature extends AbstractFeature {
+ private String inXSLTPath;
+ private String outXSLTPath;
+
+ @Override
+ protected void initializeProvider(InterceptorProvider provider, Bus bus) {
+ if (inXSLTPath != null) {
+ XSLTInInterceptor in = new XSLTInInterceptor(inXSLTPath);
+ provider.getInInterceptors().add(in);
+ }
+
+ if (outXSLTPath != null) {
+ XSLTOutInterceptor out = new XSLTOutInterceptor(outXSLTPath);
+ provider.getOutInterceptors().add(out);
+ provider.getOutFaultInterceptors().add(out);
+ }
+ }
+
+ public void setInXSLTPath(String inXSLTPath) {
+ this.inXSLTPath = inXSLTPath;
+ }
+
+ public void setOutXSLTPath(String outXSLTPath) {
+ this.outXSLTPath = outXSLTPath;
+ }
+
+}
diff --git a/core/src/main/java/org/apache/cxf/feature/transform/XSLTInInterceptor.java b/core/src/main/java/org/apache/cxf/feature/transform/XSLTInInterceptor.java
index 45960096915..5430055fef7 100644
--- a/core/src/main/java/org/apache/cxf/feature/transform/XSLTInInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/feature/transform/XSLTInInterceptor.java
@@ -1,129 +1,129 @@
-/**
- * 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.apache.cxf.feature.transform;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.util.logging.Logger;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.interceptor.Fault;
-import org.apache.cxf.interceptor.StaxInInterceptor;
-import org.apache.cxf.io.CachedOutputStream;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.phase.Phase;
-import org.apache.cxf.staxutils.StaxUtils;
-
-
-/** Class provides XSLT transformation of incoming message.
- * Actually it breaks streaming (can be fixed in further versions when XSLT engine supports XML stream)
- */
-public class XSLTInInterceptor extends AbstractXSLTInterceptor {
- private static final Logger LOG = LogUtils.getL7dLogger(XSLTInInterceptor.class);
-
- public XSLTInInterceptor(String xsltPath) {
- super(Phase.POST_STREAM, StaxInInterceptor.class, null, xsltPath);
- }
-
- public XSLTInInterceptor(String phase, Class<?> before, Class<?> after, String xsltPath) {
- super(phase, before, after, xsltPath);
- }
-
- @Override
- public void handleMessage(Message message) {
- if (!isRequestor(message) && isGET(message) || checkContextProperty(message)) {
- return;
- }
-
- // 1. Try to get and transform XMLStreamReader message content
- XMLStreamReader xReader = message.getContent(XMLStreamReader.class);
- if (xReader != null) {
- transformXReader(message, xReader);
- } else {
- // 2. Try to get and transform InputStream message content
- InputStream is = message.getContent(InputStream.class);
- if (is != null) {
- transformIS(message, is);
- } else {
- // 3. Try to get and transform Reader message content (actually used for JMS TextMessage)
- Reader reader = message.getContent(Reader.class);
- if (reader != null) {
- transformReader(message, reader);
- }
- }
- }
- }
-
- protected void transformXReader(Message message, XMLStreamReader xReader) {
- CachedOutputStream cachedOS = new CachedOutputStream();
- try {
- StaxUtils.copy(xReader, cachedOS);
- InputStream transformedIS = XSLTUtils.transform(getXSLTTemplate(), cachedOS.getInputStream());
- XMLStreamReader transformedReader = StaxUtils.createXMLStreamReader(transformedIS);
- message.setContent(XMLStreamReader.class, transformedReader);
- } catch (XMLStreamException e) {
- throw new Fault("STAX_COPY", LOG, e, e.getMessage());
- } catch (IOException e) {
- throw new Fault("GET_CACHED_INPUT_STREAM", LOG, e, e.getMessage());
- } finally {
- try {
- StaxUtils.close(xReader);
- } catch (XMLStreamException ex) {
- throw new Fault(ex);
- }
- try {
- cachedOS.close();
- } catch (IOException e) {
- LOG.warning("Cannot close stream after transformation: " + e.getMessage());
- }
- }
- }
-
- protected void transformIS(Message message, InputStream is) {
- try {
- InputStream transformedIS = XSLTUtils.transform(getXSLTTemplate(), is);
- message.setContent(InputStream.class, transformedIS);
- } finally {
- try {
- is.close();
- } catch (IOException e) {
- LOG.warning("Cannot close stream after transformation: " + e.getMessage());
- }
- }
- }
-
- protected void transformReader(Message message, Reader reader) {
- try {
- Reader transformedReader = XSLTUtils.transform(getXSLTTemplate(), reader);
- message.setContent(Reader.class, transformedReader);
- } finally {
- try {
- reader.close();
- } catch (IOException e) {
- LOG.warning("Cannot close stream after transformation: " + e.getMessage());
- }
- }
- }
-}
+/**
+ * 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.apache.cxf.feature.transform;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.util.logging.Logger;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.StaxInInterceptor;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.staxutils.StaxUtils;
+
+
+/** Class provides XSLT transformation of incoming message.
+ * Actually it breaks streaming (can be fixed in further versions when XSLT engine supports XML stream)
+ */
+public class XSLTInInterceptor extends AbstractXSLTInterceptor {
+ private static final Logger LOG = LogUtils.getL7dLogger(XSLTInInterceptor.class);
+
+ public XSLTInInterceptor(String xsltPath) {
+ super(Phase.POST_STREAM, StaxInInterceptor.class, null, xsltPath);
+ }
+
+ public XSLTInInterceptor(String phase, Class<?> before, Class<?> after, String xsltPath) {
+ super(phase, before, after, xsltPath);
+ }
+
+ @Override
+ public void handleMessage(Message message) {
+ if (!isRequestor(message) && isGET(message) || checkContextProperty(message)) {
+ return;
+ }
+
+ // 1. Try to get and transform XMLStreamReader message content
+ XMLStreamReader xReader = message.getContent(XMLStreamReader.class);
+ if (xReader != null) {
+ transformXReader(message, xReader);
+ } else {
+ // 2. Try to get and transform InputStream message content
+ InputStream is = message.getContent(InputStream.class);
+ if (is != null) {
+ transformIS(message, is);
+ } else {
+ // 3. Try to get and transform Reader message content (actually used for JMS TextMessage)
+ Reader reader = message.getContent(Reader.class);
+ if (reader != null) {
+ transformReader(message, reader);
+ }
+ }
+ }
+ }
+
+ protected void transformXReader(Message message, XMLStreamReader xReader) {
+ CachedOutputStream cachedOS = new CachedOutputStream();
+ try {
+ StaxUtils.copy(xReader, cachedOS);
+ InputStream transformedIS = XSLTUtils.transform(getXSLTTemplate(), cachedOS.getInputStream());
+ XMLStreamReader transformedReader = StaxUtils.createXMLStreamReader(transformedIS);
+ message.setContent(XMLStreamReader.class, transformedReader);
+ } catch (XMLStreamException e) {
+ throw new Fault("STAX_COPY", LOG, e, e.getMessage());
+ } catch (IOException e) {
+ throw new Fault("GET_CACHED_INPUT_STREAM", LOG, e, e.getMessage());
+ } finally {
+ try {
+ StaxUtils.close(xReader);
+ } catch (XMLStreamException ex) {
+ throw new Fault(ex);
+ }
+ try {
+ cachedOS.close();
+ } catch (IOException e) {
+ LOG.warning("Cannot close stream after transformation: " + e.getMessage());
+ }
+ }
+ }
+
+ protected void transformIS(Message message, InputStream is) {
+ try {
+ InputStream transformedIS = XSLTUtils.transform(getXSLTTemplate(), is);
+ message.setContent(InputStream.class, transformedIS);
+ } finally {
+ try {
+ is.close();
+ } catch (IOException e) {
+ LOG.warning("Cannot close stream after transformation: " + e.getMessage());
+ }
+ }
+ }
+
+ protected void transformReader(Message message, Reader reader) {
+ try {
+ Reader transformedReader = XSLTUtils.transform(getXSLTTemplate(), reader);
+ message.setContent(Reader.class, transformedReader);
+ } finally {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ LOG.warning("Cannot close stream after transformation: " + e.getMessage());
+ }
+ }
+ }
+}
diff --git a/core/src/main/java/org/apache/cxf/feature/transform/XSLTOutInterceptor.java b/core/src/main/java/org/apache/cxf/feature/transform/XSLTOutInterceptor.java
index 3a12c3cda19..604449800ca 100644
--- a/core/src/main/java/org/apache/cxf/feature/transform/XSLTOutInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/feature/transform/XSLTOutInterceptor.java
@@ -1,205 +1,205 @@
-/**
- * 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.apache.cxf.feature.transform;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.logging.Logger;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import javax.xml.transform.Templates;
-import javax.xml.transform.stream.StreamSource;
-
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
-import org.apache.cxf.interceptor.Fault;
-import org.apache.cxf.interceptor.StaxOutInterceptor;
-import org.apache.cxf.io.CachedOutputStream;
-import org.apache.cxf.io.CachedOutputStreamCallback;
-import org.apache.cxf.io.CachedWriter;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.phase.Phase;
-import org.apache.cxf.staxutils.DelegatingXMLStreamWriter;
-import org.apache.cxf.staxutils.StaxUtils;
-
-/** Class provides XSLT transformation of outgoing message.
- * Actually it breaks streaming (can be fixed in further versions when XSLT engine supports XML stream)
- */
-public class XSLTOutInterceptor extends AbstractXSLTInterceptor {
- private static final Logger LOG = LogUtils.getL7dLogger(XSLTOutInterceptor.class);
-
- public XSLTOutInterceptor(String xsltPath) {
- super(Phase.PRE_STREAM, StaxOutInterceptor.class, null, xsltPath);
- }
-
- public XSLTOutInterceptor(String phase, Class<?> before, Class<?> after, String xsltPath) {
- super(phase, before, after, xsltPath);
- }
-
- @Override
- public void handleMessage(Message message) {
- if (checkContextProperty(message)) {
- return;
- }
-
- // 1. Try to get and transform XMLStreamWriter message content
- XMLStreamWriter xWriter = message.getContent(XMLStreamWriter.class);
- if (xWriter != null) {
- transformXWriter(message, xWriter);
- } else {
- // 2. Try to get and transform OutputStream message content
- OutputStream out = message.getContent(OutputStream.class);
- if (out != null) {
- transformOS(message, out);
- } else {
- // 3. Try to get and transform Writer message content (actually used for JMS TextMessage)
- Writer writer = message.getContent(Writer.class);
- if (writer != null) {
- transformWriter(message, writer);
- }
- }
- }
- }
-
- protected void transformXWriter(Message message, XMLStreamWriter xWriter) {
- CachedWriter writer = new CachedWriter();
- XMLStreamWriter delegate = StaxUtils.createXMLStreamWriter(writer);
- XSLTStreamWriter wrapper = new XSLTStreamWriter(getXSLTTemplate(), writer, delegate, xWriter);
- message.setContent(XMLStreamWriter.class, wrapper);
- message.put(AbstractOutDatabindingInterceptor.DISABLE_OUTPUTSTREAM_OPTIMIZATION,
- Boolean.TRUE);
- }
-
- protected void transformOS(Message message, OutputStream out) {
- CachedOutputStream wrapper = new CachedOutputStream();
- CachedOutputStreamCallback callback = new XSLTCachedOutputStreamCallback(getXSLTTemplate(), out);
- wrapper.registerCallback(callback);
- message.setContent(OutputStream.class, wrapper);
- }
-
- protected void transformWriter(Message message, Writer writer) {
- XSLTCachedWriter wrapper = new XSLTCachedWriter(getXSLTTemplate(), writer);
- message.setContent(Writer.class, wrapper);
- }
-
-
- public static class XSLTStreamWriter extends DelegatingXMLStreamWriter {
- private final Templates xsltTemplate;
- private final CachedWriter cachedWriter;
- private final XMLStreamWriter origXWriter;
-
- public XSLTStreamWriter(Templates xsltTemplate, CachedWriter cachedWriter,
- XMLStreamWriter delegateXWriter, XMLStreamWriter origXWriter) {
- super(delegateXWriter);
- this.xsltTemplate = xsltTemplate;
- this.cachedWriter = cachedWriter;
- this.origXWriter = origXWriter;
- }
-
- @Override
- public void close() {
- Reader transformedReader = null;
- try {
- super.flush();
- transformedReader = XSLTUtils.transform(xsltTemplate, cachedWriter.getReader());
- StaxUtils.copy(new StreamSource(transformedReader), origXWriter);
- } catch (XMLStreamException e) {
- throw new Fault("STAX_COPY", LOG, e, e.getMessage());
- } catch (IOException e) {
- throw new Fault("GET_CACHED_INPUT_STREAM", LOG, e, e.getMessage());
- } finally {
- try {
- if (transformedReader != null) {
- transformedReader.close();
- }
- cachedWriter.close();
- StaxUtils.close(origXWriter);
- super.close();
- } catch (Exception e) {
- LOG.warning("Cannot close stream after transformation: " + e.getMessage());
- }
- }
- }
- }
-
- public static class XSLTCachedOutputStreamCallback implements CachedOutputStreamCallback {
- private final Templates xsltTemplate;
- private final OutputStream origStream;
-
- public XSLTCachedOutputStreamCallback(Templates xsltTemplate, OutputStream origStream) {
- this.xsltTemplate = xsltTemplate;
- this.origStream = origStream;
- }
-
- @Override
- public void onFlush(CachedOutputStream wrapper) {
- }
-
- @Override
- public void onClose(CachedOutputStream wrapper) {
- InputStream transformedStream = null;
- try {
- transformedStream = XSLTUtils.transform(xsltTemplate, wrapper.getInputStream());
- IOUtils.copyAndCloseInput(transformedStream, origStream);
- } catch (IOException e) {
- throw new Fault("STREAM_COPY", LOG, e, e.getMessage());
- } finally {
- try {
- origStream.close();
- } catch (IOException e) {
- LOG.warning("Cannot close stream after transformation: " + e.getMessage());
- }
- }
- }
- }
-
- public static class XSLTCachedWriter extends CachedWriter {
- private final Templates xsltTemplate;
- private final Writer origWriter;
-
- public XSLTCachedWriter(Templates xsltTemplate, Writer origWriter) {
- this.xsltTemplate = xsltTemplate;
- this.origWriter = origWriter;
- }
-
- @Override
- protected void doClose() {
- Reader transformedReader = null;
- try {
- transformedReader = XSLTUtils.transform(xsltTemplate, getReader());
- IOUtils.copyAndCloseInput(transformedReader, origWriter, IOUtils.DEFAULT_BUFFER_SIZE);
- } catch (IOException e) {
- throw new Fault("READER_COPY", LOG, e, e.getMessage());
- } finally {
- try {
- origWriter.close();
- } catch (IOException e) {
- LOG.warning("Cannot close stream after transformation: " + e.getMessage());
- }
- }
- }
- }
-
-}
+/**
+ * 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.apache.cxf.feature.transform;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.logging.Logger;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.Templates;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.StaxOutInterceptor;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.io.CachedOutputStreamCallback;
+import org.apache.cxf.io.CachedWriter;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.staxutils.DelegatingXMLStreamWriter;
+import org.apache.cxf.staxutils.StaxUtils;
+
+/** Class provides XSLT transformation of outgoing message.
+ * Actually it breaks streaming (can be fixed in further versions when XSLT engine supports XML stream)
+ */
+public class XSLTOutInterceptor extends AbstractXSLTInterceptor {
+ private static final Logger LOG = LogUtils.getL7dLogger(XSLTOutInterceptor.class);
+
+ public XSLTOutInterceptor(String xsltPath) {
+ super(Phase.PRE_STREAM, StaxOutInterceptor.class, null, xsltPath);
+ }
+
+ public XSLTOutInterceptor(String phase, Class<?> before, Class<?> after, String xsltPath) {
+ super(phase, before, after, xsltPath);
+ }
+
+ @Override
+ public void handleMessage(Message message) {
+ if (checkContextProperty(message)) {
+ return;
+ }
+
+ // 1. Try to get and transform XMLStreamWriter message content
+ XMLStreamWriter xWriter = message.getContent(XMLStreamWriter.class);
+ if (xWriter != null) {
+ transformXWriter(message, xWriter);
+ } else {
+ // 2. Try to get and transform OutputStream message content
+ OutputStream out = message.getContent(OutputStream.class);
+ if (out != null) {
+ transformOS(message, out);
+ } else {
+ // 3. Try to get and transform Writer message content (actually used for JMS TextMessage)
+ Writer writer = message.getContent(Writer.class);
+ if (writer != null) {
+ transformWriter(message, writer);
+ }
+ }
+ }
+ }
+
+ protected void transformXWriter(Message message, XMLStreamWriter xWriter) {
+ CachedWriter writer = new CachedWriter();
+ XMLStreamWriter delegate = StaxUtils.createXMLStreamWriter(writer);
+ XSLTStreamWriter wrapper = new XSLTStreamWriter(getXSLTTemplate(), writer, delegate, xWriter);
+ message.setContent(XMLStreamWriter.class, wrapper);
+ message.put(AbstractOutDatabindingInterceptor.DISABLE_OUTPUTSTREAM_OPTIMIZATION,
+ Boolean.TRUE);
+ }
+
+ protected void transformOS(Message message, OutputStream out) {
+ CachedOutputStream wrapper = new CachedOutputStream();
+ CachedOutputStreamCallback callback = new XSLTCachedOutputStreamCallback(getXSLTTemplate(), out);
+ wrapper.registerCallback(callback);
+ message.setContent(OutputStream.class, wrapper);
+ }
+
+ protected void transformWriter(Message message, Writer writer) {
+ XSLTCachedWriter wrapper = new XSLTCachedWriter(getXSLTTemplate(), writer);
+ message.setContent(Writer.class, wrapper);
+ }
+
+
+ public static class XSLTStreamWriter extends DelegatingXMLStreamWriter {
+ private final Templates xsltTemplate;
+ private final CachedWriter cachedWriter;
+ private final XMLStreamWriter origXWriter;
+
+ public XSLTStreamWriter(Templates xsltTemplate, CachedWriter cachedWriter,
+ XMLStreamWriter delegateXWriter, XMLStreamWriter origXWriter) {
+ super(delegateXWriter);
+ this.xsltTemplate = xsltTemplate;
+ this.cachedWriter = cachedWriter;
+ this.origXWriter = origXWriter;
+ }
+
+ @Override
+ public void close() {
+ Reader transformedReader = null;
+ try {
+ super.flush();
+ transformedReader = XSLTUtils.transform(xsltTemplate, cachedWriter.getReader());
+ StaxUtils.copy(new StreamSource(transformedReader), origXWriter);
+ } catch (XMLStreamException e) {
+ throw new Fault("STAX_COPY", LOG, e, e.getMessage());
+ } catch (IOException e) {
+ throw new Fault("GET_CACHED_INPUT_STREAM", LOG, e, e.getMessage());
+ } finally {
+ try {
+ if (transformedReader != null) {
+ transformedReader.close();
+ }
+ cachedWriter.close();
+ StaxUtils.close(origXWriter);
+ super.close();
+ } catch (Exception e) {
+ LOG.warning("Cannot close stream after transformation: " + e.getMessage());
+ }
+ }
+ }
+ }
+
+ public static class XSLTCachedOutputStreamCallback implements CachedOutputStreamCallback {
+ private final Templates xsltTemplate;
+ private final OutputStream origStream;
+
+ public XSLTCachedOutputStreamCallback(Templates xsltTemplate, OutputStream origStream) {
+ this.xsltTemplate = xsltTemplate;
+ this.origStream = origStream;
+ }
+
+ @Override
+ public void onFlush(CachedOutputStream wrapper) {
+ }
+
+ @Override
+ public void onClose(CachedOutputStream wrapper) {
+ InputStream transformedStream = null;
+ try {
+ transformedStream = XSLTUtils.transform(xsltTemplate, wrapper.getInputStream());
+ IOUtils.copyAndCloseInput(transformedStream, origStream);
+ } catch (IOException e) {
+ throw new Fault("STREAM_COPY", LOG, e, e.getMessage());
+ } finally {
+ try {
+ origStream.close();
+ } catch (IOException e) {
+ LOG.warning("Cannot close stream after transformation: " + e.getMessage());
+ }
+ }
+ }
+ }
+
+ public static class XSLTCachedWriter extends CachedWriter {
+ private final Templates xsltTemplate;
+ private final Writer origWriter;
+
+ public XSLTCachedWriter(Templates xsltTemplate, Writer origWriter) {
+ this.xsltTemplate = xsltTemplate;
+ this.origWriter = origWriter;
+ }
+
+ @Override
+ protected void doClose() {
+ Reader transformedReader = null;
+ try {
+ transformedReader = XSLTUtils.transform(xsltTemplate, getReader());
+ IOUtils.copyAndCloseInput(transformedReader, origWriter, IOUtils.DEFAULT_BUFFER_SIZE);
+ } catch (IOException e) {
+ throw new Fault("READER_COPY", LOG, e, e.getMessage());
+ } finally {
+ try {
+ origWriter.close();
+ } catch (IOException e) {
+ LOG.warning("Cannot close stream after transformation: " + e.getMessage());
+ }
+ }
+ }
+ }
+
+}
diff --git a/core/src/main/java/org/apache/cxf/feature/transform/XSLTUtils.java b/core/src/main/java/org/apache/cxf/feature/transform/XSLTUtils.java
index 24078cfea06..0f495efec39 100644
--- a/core/src/main/java/org/apache/cxf/feature/transform/XSLTUtils.java
+++ b/core/src/main/java/org/apache/cxf/feature/transform/XSLTUtils.java
@@ -1,101 +1,123 @@
-/**
- * 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.apache.cxf.feature.transform;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.util.logging.Logger;
-
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.Source;
-import javax.xml.transform.Templates;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Document;
-
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.interceptor.Fault;
-import org.apache.cxf.io.CachedOutputStream;
-import org.apache.cxf.io.CachedWriter;
-import org.apache.cxf.staxutils.StaxSource;
-import org.apache.cxf.staxutils.StaxUtils;
-
-public final class XSLTUtils {
- private static final Logger LOG = LogUtils.getL7dLogger(XSLTUtils.class);
-
- private XSLTUtils() {
-
- }
-
- public static InputStream transform(Templates xsltTemplate, InputStream in) {
- try {
- XMLStreamReader reader = StaxUtils.createXMLStreamReader(in);
- Source beforeSource = new StaxSource(reader);
- CachedOutputStream out = new CachedOutputStream();
-
- Transformer trans = xsltTemplate.newTransformer();
- trans.transform(beforeSource, new StreamResult(out));
-
- return out.getInputStream();
- } catch (IOException e) {
- throw new Fault("GET_CACHED_INPUT_STREAM", LOG, e, e.getMessage());
- } catch (TransformerException e) {
- throw new Fault("XML_TRANSFORM", LOG, e, e.getMessage());
- }
- }
-
- public static Reader transform(Templates xsltTemplate, Reader inReader) {
- try {
- XMLStreamReader reader = StaxUtils.createXMLStreamReader(inReader);
- Source beforeSource = new StaxSource(reader);
- CachedWriter outWriter = new CachedWriter();
-
- Transformer trans = xsltTemplate.newTransformer();
- trans.transform(beforeSource, new StreamResult(outWriter));
-
- return outWriter.getReader();
- } catch (IOException e) {
- throw new Fault("GET_CACHED_INPUT_STREAM", LOG, e, e.getMessage());
- } catch (TransformerException e) {
- throw new Fault("XML_TRANSFORM", LOG, e, e.getMessage());
- }
- }
-
- public static Document transform(Templates xsltTemplate, Document in) {
- try {
- DOMSource beforeSource = new DOMSource(in);
-
- Document out = DOMUtils.createDocument();
-
- Transformer trans = xsltTemplate.newTransformer();
- trans.transform(beforeSource, new DOMResult(out));
-
- return out;
- } catch (TransformerException e) {
- throw new Fault("XML_TRANSFORM", LOG, e, e.getMessage());
- }
- }
-}
+/**
+ * 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.apache.cxf.feature.transform;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.util.logging.Logger;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Source;
+import javax.xml.transform.Templates;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Document;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.io.CachedWriter;
+import org.apache.cxf.staxutils.StaxSource;
+import org.apache.cxf.staxutils.StaxUtils;
+
+public final class XSLTUtils {
+ private static final Logger LOG = LogUtils.getL7dLogger(XSLTUtils.class);
+
+ private XSLTUtils() {
+
+ }
+
+ public static InputStream transform(Templates xsltTemplate, InputStream in) {
+ CachedOutputStream out = new CachedOutputStream();
+ try {
+ XMLStreamReader reader = StaxUtils.createXMLStreamReader(in);
+ Source beforeSource = new StaxSource(reader);
+
+ Transformer trans = xsltTemplate.newTransformer();
+ trans.transform(beforeSource, new StreamResult(out));
+
+ return out.getInputStream();
+ } catch (IOException e) {
+ throw new Fault("GET_CACHED_INPUT_STREAM", LOG, e, e.getMessage());
+ } catch (TransformerException e) {
+ throw new Fault("XML_TRANSFORM", LOG, e, e.getMessage());
+ } finally {
+ try {
+ in.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ try {
+ out.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+
+ public static Reader transform(Templates xsltTemplate, Reader inReader) {
+ CachedWriter outWriter = new CachedWriter();
+ try {
+ XMLStreamReader reader = StaxUtils.createXMLStreamReader(inReader);
+ Source beforeSource = new StaxSource(reader);
+
+ Transformer trans = xsltTemplate.newTransformer();
+ trans.transform(beforeSource, new StreamResult(outWriter));
+
+ return outWriter.getReader();
+ } catch (IOException e) {
+ throw new Fault("GET_CACHED_INPUT_STREAM", LOG, e, e.getMessage());
+ } catch (TransformerException e) {
+ throw new Fault("XML_TRANSFORM", LOG, e, e.getMessage());
+ } finally {
+ try {
+ inReader.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ try {
+ outWriter.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+
+ public static Document transform(Templates xsltTemplate, Document in) {
+ try {
+ DOMSource beforeSource = new DOMSource(in);
+
+ Document out = DOMUtils.createDocument();
+
+ Transformer trans = xsltTemplate.newTransformer();
+ trans.transform(beforeSource, new DOMResult(out));
+
+ return out;
+ } catch (TransformerException e) {
+ throw new Fault("XML_TRANSFORM", LOG, e, e.getMessage());
+ }
+ }
+}
diff --git a/core/src/main/java/org/apache/cxf/feature/validation/SchemaValidationFeature.java b/core/src/main/java/org/apache/cxf/feature/validation/SchemaValidationFeature.java
index 5eda79c7763..c314eaf17c9 100644
--- a/core/src/main/java/org/apache/cxf/feature/validation/SchemaValidationFeature.java
+++ b/core/src/main/java/org/apache/cxf/feature/validation/SchemaValidationFeature.java
@@ -51,7 +51,7 @@ private void initialise(Endpoint endpoint) {
for (BindingOperationInfo bop : endpoint.getEndpointInfo().getBinding().getOperations()) {
SchemaValidationType type = provider.getSchemaValidationType(bop.getOperationInfo());
if (type != null) {
- bop.getOperationInfo().setProperty(Message.SCHEMA_VALIDATION_ENABLED, type);
+ bop.getOperationInfo().setProperty(Message.SCHEMA_VALIDATION_TYPE, type);
}
}
}
diff --git a/core/src/main/java/org/apache/cxf/helpers/FileUtils.java b/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
index 2bafee27cfa..82444d1210c 100644
--- a/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
+++ b/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
@@ -38,12 +38,37 @@
public final class FileUtils {
private static final int RETRY_SLEEP_MILLIS = 10;
private static File defaultTempDir;
-
+ private static final char[] ILLEGAL_CHARACTERS
+ = {'/', '\n', '\r', '\t', '\0', '\f', '`', '?', '*', '\\', '<', '>', '|', '\"', ':'};
private FileUtils() {
}
+ public boolean isValidFileName(String name) {
+ for (int i = name.length(); i > 0; i--) {
+ char c = name.charAt(i - 1);
+ for (char c2 : ILLEGAL_CHARACTERS) {
+ if (c == c2) {
+ return false;
+ }
+ }
+ }
+ File file = new File(getDefaultTempDir(), name);
+ boolean isValid = true;
+ try {
+ if (file.exists()) {
+ return true;
+ }
+ if (file.createNewFile()) {
+ file.delete();
+ }
+ } catch (IOException e) {
+ isValid = false;
+ }
+ return isValid;
+ }
+
public static synchronized File getDefaultTempDir() {
if (defaultTempDir != null
&& defaultTempDir.exists()) {
diff --git a/core/src/main/java/org/apache/cxf/helpers/IOUtils.java b/core/src/main/java/org/apache/cxf/helpers/IOUtils.java
index 56c26c013cb..aab3ab9a29e 100644
--- a/core/src/main/java/org/apache/cxf/helpers/IOUtils.java
+++ b/core/src/main/java/org/apache/cxf/helpers/IOUtils.java
@@ -27,6 +27,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
+import java.io.PushbackInputStream;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
@@ -43,6 +44,40 @@ private IOUtils() {
}
+ public static boolean isEmpty(InputStream is) throws IOException {
+ if (is == null) {
+ return true;
+ }
+ final byte[] bytes = new byte[1];
+ try {
+ if (is.markSupported()) {
+ is.mark(1);
+ try {
+ return isEof(is.read(bytes));
+ } finally {
+ is.reset();
+ }
+ }
+ // if available is 0 it does not mean it is empty; it can also throw IOException
+ if (is.available() > 0) {
+ return false;
+ }
+ } catch (IOException ex) {
+ // ignore
+ }
+ // it may be an attachment stream
+ @SuppressWarnings("resource")
+ PushbackInputStream pbStream =
+ is instanceof PushbackInputStream ? (PushbackInputStream)is : new PushbackInputStream(is);
+ boolean isEmpty = isEof(pbStream.read(bytes));
+ if (!isEmpty) {
+ pbStream.unread(bytes);
+ }
+ return isEmpty;
+ }
+ private static boolean isEof(int result) {
+ return result == -1;
+ }
/**
* Use this function instead of new String(byte[], String) to avoid surprises from
* non-standard default encodings.
diff --git a/core/src/main/java/org/apache/cxf/helpers/ServiceUtils.java b/core/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
index 85d77d02148..7bac53c8e7a 100644
--- a/core/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
+++ b/core/src/main/java/org/apache/cxf/helpers/ServiceUtils.java
@@ -27,7 +27,14 @@
import javax.xml.namespace.QName;
import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
+import org.apache.cxf.service.model.AbstractPropertiesHolder;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.OperationInfo;
public final class ServiceUtils {
@@ -42,24 +49,96 @@ private ServiceUtils() {
* @param type
*/
public static boolean isSchemaValidationEnabled(SchemaValidationType type, Message message) {
- SchemaValidationType messageType = getSchemaValidationType(message);
+ SchemaValidationType validationType = getSchemaValidationType(message);
+
+ boolean isRequestor = MessageUtils.isRequestor(message);
+ if (SchemaValidationType.REQUEST.equals(validationType)) {
+ if (isRequestor) {
+ validationType = SchemaValidationType.OUT;
+ } else {
+ validationType = SchemaValidationType.IN;
+ }
+ } else if (SchemaValidationType.RESPONSE.equals(validationType)) {
+ if (isRequestor) {
+ validationType = SchemaValidationType.IN;
+ } else {
+ validationType = SchemaValidationType.OUT;
+ }
+ }
- return messageType.equals(type)
+ return validationType.equals(type)
|| ((SchemaValidationType.IN.equals(type) || SchemaValidationType.OUT.equals(type))
- && SchemaValidationType.BOTH.equals(messageType));
+ && SchemaValidationType.BOTH.equals(validationType));
}
-
/**
- * Determines the appropriate SchemaValidationType to return based on either
- * a Boolean (for backwards compatibility) or the selected Schema Validation Type.
- *
- * Package private as the isSchemaValidationEnabled method should be used instead. Only
- * visible for easier testing
+ * A convenience method to check for schema validation config in the message context, and then in the service model.
+ * Does not modify the Message context (other than what is done in the getContextualProperty itself)
*
* @param message
+ * @param type
*/
- static SchemaValidationType getSchemaValidationType(Message message) {
+ public static SchemaValidationType getSchemaValidationType(Message message) {
+ SchemaValidationType validationType = getOverrideSchemaValidationType(message);
+ if (validationType == null) {
+ validationType = getSchemaValidationTypeFromModel(message);
+ }
+
+ if (validationType == null) {
+ validationType = SchemaValidationType.NONE;
+ }
+
+ return validationType;
+ }
+
+ private static SchemaValidationType getOverrideSchemaValidationType(Message message) {
Object obj = message.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
+ if (obj != null) {
+ // this method will transform the legacy enabled as well
+ return getSchemaValidationType(obj);
+ } else {
+ return null;
+ }
+ }
+
+ private static SchemaValidationType getSchemaValidationTypeFromModel(Message message) {
+ Exchange exchange = message.getExchange();
+
+ if (exchange != null) {
+ BindingOperationInfo boi = exchange.getBindingOperationInfo();
+ Endpoint endpoint = exchange.getEndpoint();
+
+ if (boi != null && endpoint != null) {
+ SchemaValidationType validationType = null;
+ OperationInfo opInfo = boi.getOperationInfo();
+ EndpointInfo ep = endpoint.getEndpointInfo();
+
+ if (validationType == null && opInfo != null) {
+ validationType = getSchemaValidationTypeFromModel(message, opInfo);
+
+ if (validationType == null && ep != null) {
+ validationType = getSchemaValidationTypeFromModel(message, ep);
+ }
+ }
+
+ return validationType;
+ }
+ }
+
+ // else
+ return null;
+ }
+
+ private static SchemaValidationType getSchemaValidationTypeFromModel(
+ Message message, AbstractPropertiesHolder properties) {
+ Object obj = properties.getProperty(Message.SCHEMA_VALIDATION_TYPE);
+ if (obj != null) {
+ return getSchemaValidationType(obj);
+ } else {
+ return null;
+ }
+ }
+
+ public static SchemaValidationType getSchemaValidationType(Object obj) {
if (obj instanceof SchemaValidationType) {
return (SchemaValidationType)obj;
} else if (obj != null) {
diff --git a/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
index 472a426f706..fc3e5308999 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
@@ -38,6 +38,7 @@
import org.apache.cxf.helpers.ServiceUtils;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.service.Service;
import org.apache.cxf.service.model.BindingMessageInfo;
@@ -52,6 +53,7 @@
import org.apache.cxf.ws.addressing.EndpointReferenceUtils;
import org.apache.ws.commons.schema.constants.Constants;
+
public abstract class AbstractInDatabindingInterceptor extends AbstractPhaseInterceptor<Message> {
public static final String NO_VALIDATE_PARTS = AbstractInDatabindingInterceptor.class.getName()
+ ".novalidate-parts";
@@ -66,8 +68,9 @@ public AbstractInDatabindingInterceptor(String i, String phase) {
super(i, phase);
}
+ @Deprecated
protected boolean isRequestor(Message message) {
- return Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE));
+ return MessageUtils.isRequestor(message);
}
protected boolean supportsDataReader(Message message, Class<?> input) {
@@ -124,24 +127,9 @@ protected void setDataReaderValidation(Service service, Message message, DataRea
}
}
- /**
- * Where an operation level validation type has been set, copy it to the message, so it can be interrogated
- * by all downstream interceptors. It is expected that sub classes will call setDataReaderValidation subsequent
- * to this to ensure the DataReader schema reference is updated as appropriate.
- *
- * @param bop
- * @param message
- * @param reader
- * @see #setDataReaderValidation(Service, Message, DataReader)
- */
- protected void setOperationSchemaValidation(OperationInfo opInfo, Message message) {
- if (opInfo != null) {
- SchemaValidationType validationType =
- (SchemaValidationType) opInfo.getProperty(Message.SCHEMA_VALIDATION_ENABLED);
- if (validationType != null) {
- message.put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
- }
- }
+ protected void setOperationSchemaValidation(Message message) {
+ SchemaValidationType validationType = ServiceUtils.getSchemaValidationType(message);
+ message.put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
}
protected DepthXMLStreamReader getXMLStreamReader(Message message) {
@@ -246,7 +234,7 @@ protected MessageInfo setMessage(Message message, BindingOperationInfo operation
}
// configure endpoint and operation level schema validation
- setOperationSchemaValidation(operation.getOperationInfo(), message);
+ setOperationSchemaValidation(message);
QName serviceQName = si.getName();
message.put(Message.WSDL_SERVICE, serviceQName);
diff --git a/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
index 4ba54e591a6..d144154a7ce 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
@@ -43,7 +43,6 @@
import org.apache.cxf.service.model.BindingInfo;
import org.apache.cxf.service.model.BindingOperationInfo;
import org.apache.cxf.service.model.MessagePartInfo;
-import org.apache.cxf.service.model.OperationInfo;
import org.apache.cxf.staxutils.CachingXmlEventWriter;
import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.ws.addressing.EndpointReferenceUtils;
@@ -60,9 +59,11 @@ public AbstractOutDatabindingInterceptor(String id, String phase) {
super(id, phase);
}
+ @Deprecated
protected boolean isRequestor(Message message) {
- return Boolean.TRUE.equals(message.containsKey(Message.REQUESTOR_ROLE));
+ return MessageUtils.isRequestor(message);
}
+
protected boolean shouldBuffer(Message message) {
Object en = message.getContextualProperty(OUT_BUFFERING);
boolean allowBuffer = true;
@@ -85,7 +86,7 @@ protected void writeParts(Message message, Exchange exchange,
CachingXmlEventWriter cache = null;
// configure endpoint and operation level schema validation
- setOperationSchemaValidation(operation.getOperationInfo(), message);
+ setOperationSchemaValidation(message);
// need to cache the events in case validation fails or buffering is enabled
if (shouldBuffer(message)) {
@@ -159,22 +160,9 @@ protected void writeParts(Message message, Exchange exchange,
}
}
- /**
- * Where an operation level validation type has been set, copy it to the message, so it can be interrogated
- * by all downstream interceptors
- *
- * @param bop
- * @param message
- * @param reader
- */
- private void setOperationSchemaValidation(OperationInfo opInfo, Message message) {
- if (opInfo != null) {
- SchemaValidationType validationType =
- (SchemaValidationType) opInfo.getProperty(Message.SCHEMA_VALIDATION_ENABLED);
- if (validationType != null) {
- message.put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
- }
- }
+ protected void setOperationSchemaValidation(Message message) {
+ SchemaValidationType validationType = ServiceUtils.getSchemaValidationType(message);
+ message.put(Message.SCHEMA_VALIDATION_ENABLED, validationType);
}
protected boolean shouldValidate(Message m) {
diff --git a/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java b/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
index 9f2a178b9fb..3391779782a 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
@@ -260,8 +260,14 @@ private void setStackTrace(Fault fault, Message msg) {
if (!stackTraceList.isEmpty()) {
StackTraceElement[] stackTraceElement = new StackTraceElement[stackTraceList.size()];
e.setStackTrace(stackTraceList.toArray(stackTraceElement));
- }
- if (cause != null) {
+ } else if (cause != null
+ && cause.getMessage() != null
+ && cause.getMessage().startsWith(e.getClass().getName())) {
+ e.setStackTrace(cause.getStackTrace());
+ if (cause.getCause() != null) {
+ e.initCause(cause.getCause());
+ }
+ } else if (cause != null) {
e.initCause(cause);
}
}
@@ -273,7 +279,22 @@ private void setStackTrace(Fault fault, Message msg) {
private Throwable getCause(Iterator<String> linesIterator, String firstLine) {
// The actual exception class of the cause might be unavailable at the
// client -> use a standard throwable to represent the cause.
- Throwable res = new Throwable(firstLine.substring(firstLine.indexOf(":") + 2));
+ firstLine = firstLine.substring(firstLine.indexOf(":") + 1).trim();
+ Throwable res = null;
+ if (firstLine.indexOf(":") != -1) {
+ String cn = firstLine.substring(0, firstLine.indexOf(":")).trim();
+ if (cn.startsWith("java.lang")) {
+ try {
+ res = (Throwable)Class.forName(cn).getConstructor(String.class)
+ .newInstance(firstLine.substring(firstLine.indexOf(":") + 2));
+ } catch (Throwable t) {
+ //ignore, use the default
+ }
+ }
+ }
+ if (res == null) {
+ res = new Throwable(firstLine);
+ }
List<StackTraceElement> stackTraceList = new ArrayList<StackTraceElement>();
while (linesIterator.hasNext()) {
String oneLine = linesIterator.next();
diff --git a/core/src/main/java/org/apache/cxf/interceptor/FIStaxOutInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/FIStaxOutInterceptor.java
index 005a4949800..6c0d3cef969 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/FIStaxOutInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/FIStaxOutInterceptor.java
@@ -122,7 +122,7 @@ public void handleMessage(Message message) {
Boolean.TRUE);
String s = (String)message.get(Message.CONTENT_TYPE);
- if (s.contains("application/soap+xml")) {
+ if (s != null && s.contains("application/soap+xml")) {
s = s.replace("application/soap+xml", "application/soap+fastinfoset");
message.put(Message.CONTENT_TYPE, s);
} else {
diff --git a/core/src/main/java/org/apache/cxf/interceptor/FaultOutInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/FaultOutInterceptor.java
index ef9bf020fd5..b57e487dda9 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/FaultOutInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/FaultOutInterceptor.java
@@ -79,7 +79,7 @@ public void handleMessage(Message message) throws Fault {
Object bean = getFaultBean(cause, fi, message);
Service service = message.getExchange().get(Service.class);
- MessagePartInfo part = fi.getMessageParts().iterator().next();
+ MessagePartInfo part = fi.getFirstMessagePart();
DataBinding db = service.getDataBinding();
try {
diff --git a/core/src/main/java/org/apache/cxf/interceptor/security/AbstractAuthorizingInInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/security/AbstractAuthorizingInInterceptor.java
index d4f22f1730d..640edff9b6a 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/security/AbstractAuthorizingInInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/security/AbstractAuthorizingInInterceptor.java
@@ -41,9 +41,11 @@
private boolean allowAnonymousUsers = true;
public AbstractAuthorizingInInterceptor() {
- super(Phase.PRE_INVOKE);
+ this(true);
+ }
+ public AbstractAuthorizingInInterceptor(boolean uniqueId) {
+ super(null, Phase.PRE_INVOKE, uniqueId);
}
-
public void handleMessage(Message message) throws Fault {
Method method = getTargetMethod(message);
SecurityContext sc = message.get(SecurityContext.class);
diff --git a/core/src/main/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptor.java
index f7cba43ce27..00e3277be3c 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/security/SecureAnnotationsInterceptor.java
@@ -48,6 +48,13 @@
private String annotationClassName = DEFAULT_ANNOTATION_CLASS_NAME;
+ public SecureAnnotationsInterceptor() {
+ this(true);
+ }
+ public SecureAnnotationsInterceptor(boolean uniqueId) {
+ super(uniqueId);
+ }
+
public void setAnnotationClassName(String name) {
try {
ClassLoaderUtils.loadClass(name, SecureAnnotationsInterceptor.class);
diff --git a/core/src/main/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptor.java
index b6c3c338ed1..a3e6079b375 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptor.java
@@ -36,6 +36,13 @@
protected List<String> globalRoles = Collections.emptyList();
private boolean checkConfiguredRolesOnly;
+ public SimpleAuthorizingInterceptor() {
+ this(true);
+ }
+ public SimpleAuthorizingInterceptor(boolean uniqueId) {
+ super(uniqueId);
+ }
+
@Override
protected boolean isUserInRole(SecurityContext sc, List<String> roles, boolean deny) {
if (!checkConfiguredRolesOnly && !super.isUserInRole(sc, roles, deny)) {
diff --git a/core/src/main/java/org/apache/cxf/interceptor/transform/TransformInInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/transform/TransformInInterceptor.java
index a481f6af157..fab2026b4b1 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/transform/TransformInInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/transform/TransformInInterceptor.java
@@ -42,6 +42,7 @@
private List<String> inDropElements;
private Map<String, String> inElementsMap;
private Map<String, String> inAppendMap;
+ private Map<String, String> inAttributesMap;
private boolean blockOriginalReader = true;
private String contextPropertyName;
@@ -82,15 +83,16 @@ public void handleMessage(Message message) {
}
}
-
+
protected XMLStreamReader createTransformReaderIfNeeded(XMLStreamReader reader, InputStream is) {
return TransformUtils.createTransformReaderIfNeeded(reader, is,
inDropElements,
inElementsMap,
inAppendMap,
+ inAttributesMap,
blockOriginalReader);
}
-
+
public void setInAppendElements(Map<String, String> inElements) {
this.inAppendMap = inElements;
}
@@ -102,7 +104,11 @@ public void setInDropElements(List<String> dropElementsSet) {
public void setInTransformElements(Map<String, String> inElements) {
this.inElementsMap = inElements;
}
-
+
+ public void setInTransformAttributes(Map<String, String> inAttributes) {
+ this.inAttributesMap = inAttributes;
+ }
+
public void setBlockOriginalReader(boolean blockOriginalReader) {
this.blockOriginalReader = blockOriginalReader;
}
diff --git a/core/src/main/java/org/apache/cxf/interceptor/transform/TransformOutInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/transform/TransformOutInterceptor.java
index 49156d51072..a0fff5be5d5 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/transform/TransformOutInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/transform/TransformOutInterceptor.java
@@ -50,6 +50,7 @@
private Map<String, String> outElementsMap;
private Map<String, String> outAppendMap;
private List<String> outDropElements;
+ private Map<String, String> outAttributesMap;
private boolean attributesToElements;
private boolean skipOnFault;
private String contextPropertyName;
@@ -112,6 +113,7 @@ protected XMLStreamWriter createTransformWriterIfNeeded(XMLStreamWriter writer,
outElementsMap,
outDropElements,
outAppendMap,
+ outAttributesMap,
attributesToElements,
defaultNamespace);
}
@@ -128,6 +130,10 @@ public void setOutDropElements(List<String> dropElementsSet) {
this.outDropElements = dropElementsSet;
}
+ public void setOutTransformAttributes(Map<String, String> outAttributes) {
+ this.outAttributesMap = outAttributes;
+ }
+
public void setAttributesToElements(boolean value) {
this.attributesToElements = value;
}
diff --git a/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java b/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java
index 441ea835813..6bb597a7eaa 100644
--- a/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java
+++ b/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java
@@ -671,7 +671,12 @@ public void transferTo(File destinationFile) throws IOException {
if (!transfered) {
// Data is in memory, or we failed to rename the file, try copying
// the stream instead.
- IOUtils.transferTo(getInputStream(), destinationFile);
+ FileOutputStream fout = new FileOutputStream(destinationFile);
+ try {
+ IOUtils.copyAndCloseInput(this, fout);
+ } finally {
+ fout.close();
+ }
}
}
}
diff --git a/core/src/main/java/org/apache/cxf/message/AbstractWrappedMessage.java b/core/src/main/java/org/apache/cxf/message/AbstractWrappedMessage.java
index 03ce0f75c4b..6a82ce1763c 100644
--- a/core/src/main/java/org/apache/cxf/message/AbstractWrappedMessage.java
+++ b/core/src/main/java/org/apache/cxf/message/AbstractWrappedMessage.java
@@ -162,7 +162,14 @@ public Object getContextualProperty(String key) {
return message.getContextualProperty(key);
}
public void setContextualProperty(String key, Object v) {
- message.setContextualProperty(key, v);
+ if (message instanceof MessageImpl) {
+ ((MessageImpl)message).setContextualProperty(key, v);
+ } else if (message instanceof AbstractWrappedMessage) {
+ ((AbstractWrappedMessage)message).setContextualProperty(key, v);
+ } else {
+ //cannot set directly. Just invalidate the cache.
+ message.resetContextCache();
+ }
}
public Set<String> getContextualPropertyKeys() {
diff --git a/core/src/main/java/org/apache/cxf/message/ExchangeImpl.java b/core/src/main/java/org/apache/cxf/message/ExchangeImpl.java
index 587b8981c1e..99c4dbfe3a8 100644
--- a/core/src/main/java/org/apache/cxf/message/ExchangeImpl.java
+++ b/core/src/main/java/org/apache/cxf/message/ExchangeImpl.java
@@ -19,6 +19,9 @@
package org.apache.cxf.message;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
import org.apache.cxf.Bus;
import org.apache.cxf.binding.Binding;
import org.apache.cxf.endpoint.ConduitSelector;
@@ -30,7 +33,7 @@
import org.apache.cxf.transport.Destination;
import org.apache.cxf.transport.Session;
-public class ExchangeImpl extends StringMapImpl implements Exchange {
+public class ExchangeImpl extends ConcurrentHashMap<String, Object> implements Exchange {
private static final long serialVersionUID = -3112077559217623594L;
private Destination destination;
@@ -69,24 +72,6 @@ public ExchangeImpl(ExchangeImpl ex) {
this.bindingOp = ex.bindingOp;
}
- /*
- public <T> T get(Class<T> key) {
- if (key == Bus.class) {
- return (T)bus;
- } else if (key == Service.class) {
- return (T)service;
- } else if (key == Endpoint.class) {
- return (T)endpoint;
- } else if (key == BindingOperationInfo.class) {
- return (T)bindingOp;
- } else if (key == Binding.class) {
- return (T)binding;
- } else if (key == OperationInfo.class) {
- return super.get(key);
- }
- return super.get(key);
- }
- */
private void resetContextCaches() {
if (inMessage != null) {
inMessage.resetContextCache();
@@ -101,9 +86,26 @@ private void resetContextCaches() {
outFaultMessage.resetContextCache();
}
}
+
+ public <T> T get(Class<T> key) {
+ return key.cast(get(key.getName()));
+ }
+
+ public void putAll(Map<? extends String, ?> m) {
+ for (Map.Entry<? extends String, ?> e : m.entrySet()) {
+ // just skip the null value to void the NPE in JDK1.8
+ if (e.getValue() != null) {
+ super.put(e.getKey(), e.getValue());
+ }
+ }
+ }
public <T> void put(Class<T> key, T value) {
- super.put(key, value);
+ if (value == null) {
+ super.remove(key);
+ } else {
+ super.put(key.getName(), value);
+ }
if (key == Bus.class) {
resetContextCaches();
bus = (Bus)value;
@@ -119,22 +121,31 @@ private void resetContextCaches() {
binding = (Binding)value;
}
}
+
public Object put(String key, Object value) {
- if (inMessage != null) {
- inMessage.setContextualProperty(key, value);
- }
- if (outMessage != null) {
- outMessage.setContextualProperty(key, value);
- }
- if (inFaultMessage != null) {
- inFaultMessage.setContextualProperty(key, value);
- }
- if (outFaultMessage != null) {
- outFaultMessage.setContextualProperty(key, value);
+ setMessageContextProperty(inMessage, key, value);
+ setMessageContextProperty(outMessage, key, value);
+ setMessageContextProperty(inFaultMessage, key, value);
+ setMessageContextProperty(outFaultMessage, key, value);
+ if (value == null) {
+ return super.remove(key);
}
return super.put(key, value);
}
+ private void setMessageContextProperty(Message m, String key, Object value) {
+ if (m == null) {
+ return;
+ }
+ if (m instanceof MessageImpl) {
+ ((MessageImpl)m).setContextualProperty(key, value);
+ } else if (m instanceof AbstractWrappedMessage) {
+ ((AbstractWrappedMessage)m).setContextualProperty(key, value);
+ } else {
+ //cannot set directly. Just invalidate the cache.
+ m.resetContextCache();
+ }
+ }
public Destination getDestination() {
return destination;
diff --git a/core/src/main/java/org/apache/cxf/message/Message.java b/core/src/main/java/org/apache/cxf/message/Message.java
index 91af8e9fa87..372b7dce14e 100644
--- a/core/src/main/java/org/apache/cxf/message/Message.java
+++ b/core/src/main/java/org/apache/cxf/message/Message.java
@@ -112,8 +112,17 @@
*/
String MTOM_ENABLED = "mtom-enabled";
String MTOM_THRESHOLD = "mtom-threshold";
+
+ /**
+ * Runtime schema validation property
+ */
String SCHEMA_VALIDATION_ENABLED = "schema-validation-enabled";
-
+
+ /**
+ * The default values for schema validation will be set in the service model using this property
+ */
+ String SCHEMA_VALIDATION_TYPE = "schema-validation-type";
+
/**
* Boolean property specifying if the Java stack trace is returned as a
* SOAP fault message.
@@ -239,7 +248,16 @@
*/
Object getContextualProperty(String key);
+ /**
+ * Resets the cache of contextual properties that messages may contain. Subsequent
+ * calls to getContextualProperty will likely recalculate the cache.
+ */
void resetContextCache();
+
+ /**
+ * Don't call, will be made non-public in 3.1
+ */
+ @Deprecated
void setContextualProperty(String key, Object v);
/**
diff --git a/core/src/main/java/org/apache/cxf/message/MessageUtils.java b/core/src/main/java/org/apache/cxf/message/MessageUtils.java
index a6cf993196f..d8bbf0c4e4d 100644
--- a/core/src/main/java/org/apache/cxf/message/MessageUtils.java
+++ b/core/src/main/java/org/apache/cxf/message/MessageUtils.java
@@ -134,7 +134,7 @@ public static boolean getContextualBoolean(Message m, String key, boolean defaul
public static Object getContextualProperty(Message m, String propPreferred, String propDefault) {
Object prop = m.getContextualProperty(propPreferred);
if (prop == null && propDefault != null) {
- prop = (String)m.getContextualProperty(propDefault);
+ prop = m.getContextualProperty(propDefault);
}
return prop;
}
diff --git a/core/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java b/core/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
index 8ad2dc8f585..5287e9aaa44 100644
--- a/core/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
+++ b/core/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
@@ -318,58 +318,9 @@ public synchronized boolean doIntercept(Message message) {
pause();
throw ex;
} catch (RuntimeException ex) {
-
if (!faultOccurred) {
-
faultOccurred = true;
-
- StringBuilder description = new StringBuilder();
- if (message.getExchange() != null) {
- Exchange exchange = message.getExchange();
- Service service = exchange.get(Service.class);
- if (service != null) {
- description.append('\'');
- description.append(service.getName());
- OperationInfo opInfo = exchange.get(OperationInfo.class);
- if (opInfo != null) {
- description.append("#").append(opInfo.getName());
- }
- description.append("\' ");
- }
- }
-
- message.setContent(Exception.class, ex);
- unwind(message);
- Exception ex2 = message.getContent(Exception.class);
- if (ex2 == null) {
- ex2 = ex;
- }
-
- FaultListener flogger = (FaultListener)
- message.getContextualProperty(FaultListener.class.getName());
- boolean useDefaultLogging = true;
- if (flogger != null) {
- useDefaultLogging = flogger.faultOccurred(ex2, description.toString(), message);
- }
- if (useDefaultLogging) {
- doDefaultLogging(message, ex2, description);
- }
-
- boolean isOneWay = false;
- if (message.getExchange() != null) {
- if (message.getContent(Exception.class) != null) {
- message.getExchange().put(Exception.class, ex2);
- }
- isOneWay = message.getExchange().isOneWay()
- && !MessageUtils.isTrue(message.getContextualProperty(Message.ROBUST_ONEWAY));
- }
-
- if (faultObserver != null && !isOneWay) {
- // CXF-5629. when exchange is one way and robust, it becomes req-resp in order to
- // send the fault
- message.getExchange().setOneWay(false);
- faultObserver.onMessage(message);
- }
+ wrapExceptionAsFault(message, ex);
}
state = State.ABORTED;
}
@@ -383,7 +334,57 @@ public synchronized boolean doIntercept(Message message) {
}
}
- private void doDefaultLogging(Message message, Exception ex, StringBuilder description) {
+ private void wrapExceptionAsFault(Message message, RuntimeException ex) {
+ String description = getServiceInfo(message);
+
+ message.setContent(Exception.class, ex);
+ unwind(message);
+ Exception ex2 = message.getContent(Exception.class);
+ if (ex2 == null) {
+ ex2 = ex;
+ }
+
+ FaultListener flogger = (FaultListener)
+ message.getContextualProperty(FaultListener.class.getName());
+ boolean useDefaultLogging = true;
+ if (flogger != null) {
+ useDefaultLogging = flogger.faultOccurred(ex2, description, message);
+ }
+ if (useDefaultLogging) {
+ doDefaultLogging(message, ex2, description);
+ }
+
+ if (message.getExchange() != null && message.getContent(Exception.class) != null) {
+ message.getExchange().put(Exception.class, ex2);
+ }
+
+ if (faultObserver != null && !isOneWay(message)) {
+ // CXF-5629. when exchange is one way and robust, it becomes req-resp in order to
+ // send the fault
+ message.getExchange().setOneWay(false);
+ faultObserver.onMessage(message);
+ }
+ }
+
+ private String getServiceInfo(Message message) {
+ StringBuilder description = new StringBuilder();
+ if (message.getExchange() != null) {
+ Exchange exchange = message.getExchange();
+ Service service = exchange.get(Service.class);
+ if (service != null) {
+ description.append('\'');
+ description.append(service.getName());
+ OperationInfo opInfo = exchange.get(OperationInfo.class);
+ if (opInfo != null) {
+ description.append("#").append(opInfo.getName());
+ }
+ description.append("\' ");
+ }
+ }
+ return description.toString();
+ }
+
+ private void doDefaultLogging(Message message, Exception ex, String description) {
FaultMode mode = message.get(FaultMode.class);
if (mode == FaultMode.CHECKED_APPLICATION_FAULT) {
if (isFineLogging) {
@@ -415,6 +416,14 @@ private void doDefaultLogging(Message message, Exception ex, StringBuilder descr
}
}
}
+
+ private boolean isOneWay(Message message) {
+ return (message.getExchange() != null) ? message.getExchange().isOneWay() && !isRobustOneWay(message) : false;
+ }
+
+ private boolean isRobustOneWay(Message message) {
+ return MessageUtils.isTrue(message.getContextualProperty(Message.ROBUST_ONEWAY));
+ }
/**
* Intercept a message, invoking each phase's handlers in turn,
diff --git a/core/src/main/java/org/apache/cxf/resource/PropertiesResolver.java b/core/src/main/java/org/apache/cxf/resource/PropertiesResolver.java
index 4809b8161cb..b2d2419f821 100644
--- a/core/src/main/java/org/apache/cxf/resource/PropertiesResolver.java
+++ b/core/src/main/java/org/apache/cxf/resource/PropertiesResolver.java
@@ -35,6 +35,9 @@ public InputStream getAsStream(String name) {
}
public <T> T resolve(String resourceName, Class<T> resourceType) {
+ if (resourceName == null) {
+ return null;
+ }
Object obj = properties.get(resourceName);
if (null != obj) {
return resourceType.cast(properties.get(resourceName));
diff --git a/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java b/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
index 5c6a9ee4aad..09b75d3ae17 100644
--- a/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
+++ b/core/src/main/java/org/apache/cxf/service/factory/AnnotationsFactoryBeanListener.java
@@ -288,9 +288,7 @@ private void addGZipSupport(Endpoint ep, Bus bus, GZIP annotation) {
*/
private void addSchemaValidationSupport(Endpoint endpoint, SchemaValidation annotation) {
if (annotation != null) {
- // if someone has gone to the effort of specifying enabled=false, then we need to
- // handle that, otherwise we use the new SchemaValidationType type only
- endpoint.put(Message.SCHEMA_VALIDATION_ENABLED, annotation.type());
+ endpoint.getEndpointInfo().setProperty(Message.SCHEMA_VALIDATION_TYPE, annotation.type());
}
}
@@ -349,11 +347,8 @@ private void addBindingOperationDocs(Endpoint ep) {
}
private void addSchemaValidationSupport(OperationInfo inf, SchemaValidation annotation) {
- // Notice no support for deprecated enabled property here!
- // TODO - should we check for the use of this property and at least log the fact we are
- // ignoring it
if (annotation != null) {
- inf.setProperty(Message.SCHEMA_VALIDATION_ENABLED, annotation.type());
+ inf.setProperty(Message.SCHEMA_VALIDATION_TYPE, annotation.type());
}
}
diff --git a/core/src/main/java/org/apache/cxf/service/invoker/FactoryInvoker.java b/core/src/main/java/org/apache/cxf/service/invoker/FactoryInvoker.java
index d43e3027007..dec77c87c6d 100644
--- a/core/src/main/java/org/apache/cxf/service/invoker/FactoryInvoker.java
+++ b/core/src/main/java/org/apache/cxf/service/invoker/FactoryInvoker.java
@@ -33,7 +33,7 @@
public class FactoryInvoker extends AbstractInvoker {
static final ResourceBundle BUNDLE = BundleUtils.getBundle(FactoryInvoker.class);
- private Factory factory;
+ protected Factory factory;
/**
* Create a FactoryInvoker object.
diff --git a/core/src/main/java/org/apache/cxf/service/model/AbstractMessageContainer.java b/core/src/main/java/org/apache/cxf/service/model/AbstractMessageContainer.java
index 38d5bc3ca44..ba36e1b5cb5 100644
--- a/core/src/main/java/org/apache/cxf/service/model/AbstractMessageContainer.java
+++ b/core/src/main/java/org/apache/cxf/service/model/AbstractMessageContainer.java
@@ -221,6 +221,21 @@ public MessagePartInfo addOutOfBandMessagePart(QName name) {
parts.addAll(outOfBandParts);
return parts;
}
+ public int getMessagePartsNumber() {
+ if (outOfBandParts == null) {
+ return messageParts.size();
+ }
+ return messageParts.size() + outOfBandParts.size();
+ }
+ public MessagePartInfo getFirstMessagePart() {
+ if (!messageParts.isEmpty()) {
+ return messageParts.values().iterator().next();
+ } else if (outOfBandParts != null && !outOfBandParts.isEmpty()) {
+ return outOfBandParts.get(0);
+ } else {
+ return null;
+ }
+ }
public List<MessagePartInfo> getOutOfBandParts() {
if (outOfBandParts == null) {
return Collections.emptyList();
diff --git a/core/src/main/java/org/apache/cxf/service/model/EndpointInfo.java b/core/src/main/java/org/apache/cxf/service/model/EndpointInfo.java
index 5ad335f0cab..64a0d77e38f 100644
--- a/core/src/main/java/org/apache/cxf/service/model/EndpointInfo.java
+++ b/core/src/main/java/org/apache/cxf/service/model/EndpointInfo.java
@@ -89,7 +89,7 @@ public void setBinding(BindingInfo b) {
}
public String getAddress() {
- return (null != address) ? address.getAddress().getValue() : null;
+ return (null != address && null != address.getAddress()) ? address.getAddress().getValue() : null;
}
public void setAddress(String addr) {
diff --git a/core/src/main/java/org/apache/cxf/service/model/ServiceModelUtil.java b/core/src/main/java/org/apache/cxf/service/model/ServiceModelUtil.java
index 558aabd68be..d3fe66e9299 100644
--- a/core/src/main/java/org/apache/cxf/service/model/ServiceModelUtil.java
+++ b/core/src/main/java/org/apache/cxf/service/model/ServiceModelUtil.java
@@ -52,6 +52,9 @@ public static String getTargetNamespace(Exchange exchange) {
public static BindingOperationInfo getOperation(Exchange exchange, String opName) {
Endpoint ep = exchange.get(Endpoint.class);
+ if (ep == null) {
+ return null;
+ }
BindingInfo service = ep.getEndpointInfo().getBinding();
for (BindingOperationInfo b : service.getOperations()) {
diff --git a/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java b/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
index a9590fd9628..52b2246fe62 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
@@ -52,6 +52,7 @@
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.Characters;
import javax.xml.stream.events.DTD;
import javax.xml.stream.events.Namespace;
import javax.xml.stream.events.StartDocument;
@@ -229,10 +230,18 @@ private static long getLong(String prop, long def) {
}
public static void setInnerElementLevelThreshold(int i) {
+ if (i == -1) {
+ i = 500;
+ }
innerElementLevelThreshold = i;
+ setProperty(SAFE_INPUT_FACTORY, "com.ctc.wstx.maxElementDepth", i);
}
public static void setInnerElementCountThreshold(int i) {
+ if (i == -1) {
+ i = 50000;
+ }
innerElementCountThreshold = i;
+ setProperty(SAFE_INPUT_FACTORY, "com.ctc.wstx.maxChildrenPerElement", i);
}
/**
@@ -1345,45 +1354,302 @@ public static void readDocElements(Document doc, Node parent,
}
}
}
- private static boolean addLocation(Document doc, Node node,
- XMLStreamReader reader,
- boolean recordLoc) {
- if (recordLoc) {
- Location loc = reader.getLocation();
- if (loc != null && (loc.getColumnNumber() != 0 || loc.getLineNumber() != 0)) {
- try {
- final int charOffset = loc.getCharacterOffset();
- final int colNum = loc.getColumnNumber();
- final int linNum = loc.getLineNumber();
- final String pubId = loc.getPublicId() == null ? doc.getDocumentURI() : loc.getPublicId();
- final String sysId = loc.getSystemId() == null ? doc.getDocumentURI() : loc.getSystemId();
- Location loc2 = new Location() {
- public int getCharacterOffset() {
- return charOffset;
- }
- public int getColumnNumber() {
- return colNum;
- }
- public int getLineNumber() {
- return linNum;
- }
- public String getPublicId() {
- return pubId;
- }
- public String getSystemId() {
- return sysId;
- }
- };
- node.setUserData("location", loc2, LocationUserDataHandler.INSTANCE);
- } catch (Throwable ex) {
- //possibly not DOM level 3, won't be able to record this then
- return false;
+
+ public static class StreamToDOMContext {
+ private Stack<Node> stack = new Stack<Node>();
+ private int elementCount;
+ private boolean repairing;
+ private boolean recordLoc;
+ private boolean threshold;
+
+ public StreamToDOMContext(boolean repairing, boolean recordLoc, boolean threshold) {
+ this.repairing = repairing;
+ this.recordLoc = recordLoc;
+ this.threshold = threshold;
+ }
+
+ public void setRecordLoc(boolean recordLoc) {
+ this.recordLoc = recordLoc;
+ }
+
+ public boolean isRecordLoc() {
+ return this.recordLoc;
+ }
+
+ public boolean isRepairing() {
+ return this.repairing;
+ }
+
+ public boolean isThreshold() {
+ return this.threshold;
+ }
+
+ public int incrementCount() {
+ return ++elementCount;
+ }
+
+ public int decreaseCount() {
+ return --elementCount;
+ }
+
+ public int getCount() {
+ return elementCount;
+ }
+
+ public Node pushToStack(Node node) {
+ return stack.push(node);
+ }
+
+ public Node popFromStack() {
+ return stack.pop();
+ }
+
+ public int getStackSize() {
+ return stack.size();
+ }
+
+ public boolean isStackEmpty() {
+ return stack.isEmpty();
+ }
+ }
+
+ public static void readDocElements(Document doc, Node parent, XMLStreamReader reader, StreamToDOMContext context)
+ throws XMLStreamException {
+ int event = reader.getEventType();
+ while (reader.hasNext()) {
+ switch (event) {
+ case XMLStreamConstants.START_ELEMENT: {
+ context.incrementCount();
+ Element e;
+ if (!StringUtils.isEmpty(reader.getPrefix())) {
+ e = doc.createElementNS(reader.getNamespaceURI(),
+ reader.getPrefix() + ":" + reader.getLocalName());
+ } else {
+ e = doc.createElementNS(reader.getNamespaceURI(), reader.getLocalName());
+ }
+ e = (Element)parent.appendChild(e);
+ if (context.isRecordLoc()) {
+ context.setRecordLoc(addLocation(doc, e, reader.getLocation(), context.isRecordLoc()));
+ }
+
+ for (int ns = 0; ns < reader.getNamespaceCount(); ns++) {
+ String uri = reader.getNamespaceURI(ns);
+ String prefix = reader.getNamespacePrefix(ns);
+
+ declare(e, uri, prefix);
}
+
+ for (int att = 0; att < reader.getAttributeCount(); att++) {
+ String name = reader.getAttributeLocalName(att);
+ String prefix = reader.getAttributePrefix(att);
+ if (prefix != null && prefix.length() > 0) {
+ name = prefix + ":" + name;
+ }
+
+ Attr attr = doc.createAttributeNS(reader.getAttributeNamespace(att), name);
+ attr.setValue(reader.getAttributeValue(att));
+ e.setAttributeNode(attr);
+ }
+
+ if (context.isRepairing() && !isDeclared(e, reader.getNamespaceURI(), reader.getPrefix())) {
+ declare(e, reader.getNamespaceURI(), reader.getPrefix());
+ }
+ context.pushToStack(parent);
+ if (context.isThreshold() && innerElementLevelThreshold != -1
+ && context.getStackSize() >= innerElementLevelThreshold) {
+ throw new DepthExceededStaxException("reach the innerElementLevelThreshold:"
+ + innerElementLevelThreshold);
+ }
+ if (context.isThreshold() && innerElementCountThreshold != -1
+ && context.getCount() >= innerElementCountThreshold) {
+ throw new DepthExceededStaxException("reach the innerElementCountThreshold:"
+ + innerElementCountThreshold);
+ }
+ parent = e;
+ break;
+ }
+ case XMLStreamConstants.END_ELEMENT:
+ if (context.isStackEmpty()) {
+ return;
+ }
+ parent = context.popFromStack();
+ if (parent instanceof Document) {
+ return;
+ }
+ break;
+ case XMLStreamConstants.NAMESPACE:
+ break;
+ case XMLStreamConstants.ATTRIBUTE:
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ if (parent != null) {
+ context.setRecordLoc(addLocation(doc,
+ parent.appendChild(doc.createTextNode(reader.getText())),
+ reader.getLocation(), context.isRecordLoc()));
+ }
+ break;
+ case XMLStreamConstants.COMMENT:
+ if (parent != null) {
+ parent.appendChild(doc.createComment(reader.getText()));
+ }
+ break;
+ case XMLStreamConstants.CDATA:
+ context.setRecordLoc(addLocation(doc,
+ parent.appendChild(doc.createCDATASection(reader.getText())),
+ reader.getLocation(), context.isRecordLoc()));
+ break;
+ case XMLStreamConstants.PROCESSING_INSTRUCTION:
+ parent.appendChild(doc.createProcessingInstruction(reader.getPITarget(), reader.getPIData()));
+ break;
+ case XMLStreamConstants.ENTITY_REFERENCE:
+ parent.appendChild(doc.createProcessingInstruction(reader.getPITarget(), reader.getPIData()));
+ break;
+ default:
+ break;
+ }
+
+ if (reader.hasNext()) {
+ event = reader.next();
+ }
+ }
+ }
+
+ public static Node readDocElement(Document doc, Node parent, XMLEvent ev, StreamToDOMContext context)
+ throws XMLStreamException {
+ switch (ev.getEventType()) {
+ case XMLStreamConstants.START_ELEMENT: {
+ context.incrementCount();
+ Element e;
+ StartElement startElem = ev.asStartElement();
+ QName name = startElem.getName();
+ if (!StringUtils.isEmpty(name.getPrefix())) {
+ e = doc.createElementNS(name.getNamespaceURI(),
+ name.getPrefix() + ":" + name.getLocalPart());
+ } else {
+ e = doc.createElementNS(name.getNamespaceURI(), name.getLocalPart());
+ }
+ e = (Element)parent.appendChild(e);
+ if (context.isRecordLoc()) {
+ context.setRecordLoc(addLocation(doc, e, startElem.getLocation(), context.isRecordLoc()));
+ }
+
+ if (context.isRepairing() && !isDeclared(e, name.getNamespaceURI(), name.getPrefix())) {
+ declare(e, name.getNamespaceURI(), name.getPrefix());
+ }
+ context.pushToStack(parent);
+ if (context.isThreshold() && innerElementLevelThreshold != -1
+ && context.getStackSize() >= innerElementLevelThreshold) {
+ throw new DepthExceededStaxException("reach the innerElementLevelThreshold:"
+ + innerElementLevelThreshold);
+ }
+ if (context.isThreshold() && innerElementCountThreshold != -1
+ && context.getCount() >= innerElementCountThreshold) {
+ throw new DepthExceededStaxException("reach the innerElementCountThreshold:"
+ + innerElementCountThreshold);
+ }
+ parent = e;
+ break;
+ }
+ case XMLStreamConstants.END_ELEMENT:
+ if (context.isStackEmpty()) {
+ return parent;
+ }
+ parent = context.popFromStack();
+ if (parent instanceof Document) {
+ return parent;
+ }
+ break;
+ case XMLStreamConstants.NAMESPACE:
+ Namespace ns = (Namespace)ev;
+ declare((Element)parent, ns.getNamespaceURI(), ns.getPrefix());
+ break;
+ case XMLStreamConstants.ATTRIBUTE:
+ Attribute at = (Attribute)ev;
+ QName qname = at.getName();
+ String attName = qname.getLocalPart();
+ String attPrefix = qname.getPrefix();
+ if (attPrefix != null && attPrefix.length() > 0) {
+ attName = attPrefix + ":" + attName;
+ }
+ Attr attr = doc.createAttributeNS(qname.getNamespaceURI(), attName);
+ attr.setValue(at.getValue());
+ ((Element)parent).setAttributeNode(attr);
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ if (parent != null) {
+ Characters characters = ev.asCharacters();
+ context.setRecordLoc(addLocation(doc,
+ parent.appendChild(doc.createTextNode(characters.getData())),
+ characters.getLocation(), context.isRecordLoc()));
+ }
+ break;
+ case XMLStreamConstants.COMMENT:
+ if (parent != null) {
+ parent.appendChild(doc.createComment(((javax.xml.stream.events.Comment)ev).getText()));
+ }
+ break;
+ case XMLStreamConstants.CDATA:
+ Characters characters = ev.asCharacters();
+ context.setRecordLoc(addLocation(doc,
+ parent.appendChild(doc.createCDATASection(characters.getData())),
+ characters.getLocation(), context.isRecordLoc()));
+ break;
+ case XMLStreamConstants.PROCESSING_INSTRUCTION:
+ parent.appendChild(doc.createProcessingInstruction(((ProcessingInstruction)ev).getTarget(),
+ ((ProcessingInstruction)ev).getData()));
+ break;
+ case XMLStreamConstants.ENTITY_REFERENCE:
+ javax.xml.stream.events.EntityReference er = (javax.xml.stream.events.EntityReference)ev;
+ parent.appendChild(doc.createEntityReference(er.getName()));
+ break;
+ default:
+ break;
+ }
+ return parent;
+ }
+
+ private static boolean addLocation(Document doc, Node node,
+ Location loc,
+ boolean recordLoc) {
+ if (recordLoc && loc != null && (loc.getColumnNumber() != 0 || loc.getLineNumber() != 0)) {
+ try {
+ final int charOffset = loc.getCharacterOffset();
+ final int colNum = loc.getColumnNumber();
+ final int linNum = loc.getLineNumber();
+ final String pubId = loc.getPublicId() == null ? doc.getDocumentURI() : loc.getPublicId();
+ final String sysId = loc.getSystemId() == null ? doc.getDocumentURI() : loc.getSystemId();
+ Location loc2 = new Location() {
+ public int getCharacterOffset() {
+ return charOffset;
+ }
+ public int getColumnNumber() {
+ return colNum;
+ }
+ public int getLineNumber() {
+ return linNum;
+ }
+ public String getPublicId() {
+ return pubId;
+ }
+ public String getSystemId() {
+ return sysId;
+ }
+ };
+ node.setUserData("location", loc2, LocationUserDataHandler.INSTANCE);
+ } catch (Throwable ex) {
+ //possibly not DOM level 3, won't be able to record this then
+ return false;
}
}
return recordLoc;
}
+ private static boolean addLocation(Document doc, Node node,
+ XMLStreamReader reader,
+ boolean recordLoc) {
+ return addLocation(doc, node, reader.getLocation(), recordLoc);
+ }
+
private static class LocationUserDataHandler implements UserDataHandler {
public static final LocationUserDataHandler INSTANCE = new LocationUserDataHandler();
@@ -1844,6 +2110,20 @@ public static void close(XMLStreamWriter writer) {
}
}
+ public static boolean isSecureReader(XMLStreamReader reader, Message message) {
+ if (reader instanceof DocumentDepthProperties) {
+ return true;
+ }
+ try {
+ if (reader.getProperty("com.ctc.wstx.maxChildrenPerElement") != null) {
+ return true;
+ }
+ } catch (Exception ex) {
+ //ignore
+ }
+ return false;
+ }
+
public static XMLStreamReader configureReader(XMLStreamReader xreader, Message message) throws XMLStreamException {
Integer messageMaxChildElements = PropertyUtils.getInteger(message, MAX_CHILD_ELEMENTS);
Integer messageMaxElementDepth = PropertyUtils.getInteger(message, MAX_ELEMENT_DEPTH);
@@ -1890,7 +2170,7 @@ public static XMLStreamReader configureReader(XMLStreamReader reader, Integer ma
}
}
if (maxAttributeCount != null) {
- setProperty(reader, "com.ctc.wstx.maxAttributeCount", maxAttributeCount);
+ setProperty(reader, "com.ctc.wstx.maxAttributesPerElement", maxAttributeCount);
}
if (maxAttributeSize != null) {
setProperty(reader, "com.ctc.wstx.maxAttributeSize", maxAttributeSize);
diff --git a/core/src/main/java/org/apache/cxf/staxutils/transform/IgnoreNamespacesWriter.java b/core/src/main/java/org/apache/cxf/staxutils/transform/IgnoreNamespacesWriter.java
index ea558ed0362..c6187ba9831 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/transform/IgnoreNamespacesWriter.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/transform/IgnoreNamespacesWriter.java
@@ -24,13 +24,22 @@
import org.apache.cxf.staxutils.DelegatingXMLStreamWriter;
public class IgnoreNamespacesWriter extends DelegatingXMLStreamWriter {
-
+ private static final String XSI_PREFIX = "xsi";
+ private boolean ignoreXsiAttributes;
public IgnoreNamespacesWriter(XMLStreamWriter writer) {
+ this(writer, false);
+ }
+ public IgnoreNamespacesWriter(XMLStreamWriter writer, boolean ignoreXsiAttributes) {
super(writer);
+ this.ignoreXsiAttributes = ignoreXsiAttributes;
}
public void writeAttribute(String prefix, String uri,
String local, String value) throws XMLStreamException {
+ if (ignoreXsiAttributes && XSI_PREFIX.equals(prefix)
+ && ("type".equals(local) || "nil".equals(local))) {
+ return;
+ }
super.writeAttribute(local, value);
}
diff --git a/core/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java b/core/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
index 1553527a9b5..9dc2649393a 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
@@ -57,11 +57,30 @@ public static XMLStreamWriter createTransformWriterIfNeeded(XMLStreamWriter writ
|| outAppendMap != null || attributesToElements) {
writer = createNewWriterIfNeeded(writer, os);
writer = new OutTransformWriter(writer, outElementsMap, outAppendMap,
- outDropElements, attributesToElements, defaultNamespace);
+ outDropElements, null, attributesToElements, defaultNamespace);
}
return writer;
}
-
+
+ //CHECKSTYLE:OFF ParameterNumber
+ public static XMLStreamWriter createTransformWriterIfNeeded(XMLStreamWriter writer,
+ OutputStream os,
+ Map<String, String> outElementsMap,
+ List<String> outDropElements,
+ Map<String, String> outAppendMap,
+ Map<String, String> outAttributesMap,
+ boolean attributesToElements,
+ String defaultNamespace) {
+ if (outElementsMap != null || outDropElements != null
+ || outAppendMap != null || attributesToElements) {
+ writer = createNewWriterIfNeeded(writer, os);
+ writer = new OutTransformWriter(writer, outElementsMap, outAppendMap,
+ outDropElements, outAttributesMap, attributesToElements, defaultNamespace);
+ }
+ return writer;
+ }
+ //CHECKSTYLE:ON
+
public static XMLStreamReader createTransformReaderIfNeeded(XMLStreamReader reader,
InputStream is,
List<String> inDropElements,
diff --git a/core/src/main/java/org/apache/cxf/transport/AbstractObservable.java b/core/src/main/java/org/apache/cxf/transport/AbstractObservable.java
index fdda91479cb..35a2f168782 100644
--- a/core/src/main/java/org/apache/cxf/transport/AbstractObservable.java
+++ b/core/src/main/java/org/apache/cxf/transport/AbstractObservable.java
@@ -19,6 +19,7 @@
package org.apache.cxf.transport;
+import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.cxf.Bus;
@@ -43,7 +44,10 @@ public synchronized void setMessageObserver(MessageObserver observer) {
// the observer switch must take place before activation or after deactivation
if (observer != null) {
incomingObserver = observer;
- getLogger().fine("registering incoming observer: " + observer);
+ final Logger logger = getLogger();
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("registering incoming observer: " + observer);
+ }
if (old == null) {
try {
activate();
@@ -54,7 +58,10 @@ public synchronized void setMessageObserver(MessageObserver observer) {
}
} else {
if (old != null) {
- getLogger().fine("unregistering incoming observer: " + old);
+ final Logger logger = getLogger();
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("unregistering incoming observer: " + old);
+ }
deactivate();
}
incomingObserver = observer;
diff --git a/core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java b/core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java
index 6041df3fed0..dbce1c3523d 100644
--- a/core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/transport/common/gzip/GZIPOutInterceptor.java
@@ -40,6 +40,7 @@
import org.apache.cxf.io.AbstractThresholdOutputStream;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
@@ -131,7 +132,7 @@ public int getThreshold() {
}
public void handleMessage(Message message) throws Fault {
- UseGzip use = gzipPermitted(message);
+ UseGzip use = gzipPermitted(message, force);
if (use != UseGzip.NO) {
// remember the original output stream, we will write compressed
// data to this later
@@ -166,9 +167,9 @@ public void handleMessage(Message message) throws Fault {
* @throws Fault if the Accept-Encoding header does not allow any encoding
* that we can support (identity, gzip or x-gzip).
*/
- private UseGzip gzipPermitted(Message message) throws Fault {
+ public static UseGzip gzipPermitted(Message message, boolean force) throws Fault {
UseGzip permitted = UseGzip.NO;
- if (isRequestor(message)) {
+ if (MessageUtils.isRequestor(message)) {
LOG.fine("Requestor role, so gzip enabled");
Object o = message.getContextualProperty(USE_GZIP_KEY);
if (o instanceof UseGzip) {
diff --git a/core/src/main/java/org/apache/cxf/workqueue/OneShotAsyncExecutor.java b/core/src/main/java/org/apache/cxf/workqueue/OneShotAsyncExecutor.java
index 59203bff98c..f6d1545bd10 100644
--- a/core/src/main/java/org/apache/cxf/workqueue/OneShotAsyncExecutor.java
+++ b/core/src/main/java/org/apache/cxf/workqueue/OneShotAsyncExecutor.java
@@ -27,8 +27,8 @@
*/
public final class OneShotAsyncExecutor implements Executor {
- private static final OneShotAsyncExecutor INSTANCE = new
- OneShotAsyncExecutor();
+ private static final OneShotAsyncExecutor INSTANCE
+ = new OneShotAsyncExecutor();
private OneShotAsyncExecutor() {
}
diff --git a/core/src/main/java/org/apache/cxf/ws/addressing/EndpointReferenceUtils.java b/core/src/main/java/org/apache/cxf/ws/addressing/EndpointReferenceUtils.java
index 7ca7387b340..6155c50836f 100644
--- a/core/src/main/java/org/apache/cxf/ws/addressing/EndpointReferenceUtils.java
+++ b/core/src/main/java/org/apache/cxf/ws/addressing/EndpointReferenceUtils.java
@@ -21,7 +21,6 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
-import java.io.InputStreamReader;
import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
import java.net.MalformedURLException;
@@ -218,9 +217,7 @@ private LSInputImpl createInput(String newId, byte[] value) {
LSInputImpl impl = new LSInputImpl();
impl.setSystemId(newId);
impl.setBaseURI(newId);
- impl.setCharacterStream(
- new InputStreamReader(
- new ByteArrayInputStream(value)));
+ impl.setByteStream(new ByteArrayInputStream(value));
return impl;
}
}
@@ -669,9 +666,13 @@ public static Schema getSchema(ServiceInfo serviceInfo, Bus b) {
return null;
}
Schema schema = serviceInfo.getProperty(Schema.class.getName(), Schema.class);
- if (schema == null && !serviceInfo.hasProperty(Schema.class.getName())) {
- synchronized (serviceInfo) {
- return createSchema(serviceInfo, b);
+ if (schema == null && !serviceInfo.hasProperty(Schema.class.getName() + ".CHECKED")) {
+ try {
+ synchronized (serviceInfo) {
+ return createSchema(serviceInfo, b);
+ }
+ } finally {
+ serviceInfo.setProperty(Schema.class.getName() + ".CHECKED", Boolean.TRUE);
}
}
return schema;
@@ -908,8 +909,8 @@ public static Source convertToXML(EndpointReferenceType epr) {
javax.xml.bind.Marshaller jm = getJAXBContextForEPR().createMarshaller();
jm.setProperty(Marshaller.JAXB_FRAGMENT, true);
QName qname = new QName("http://www.w3.org/2005/08/addressing", "EndpointReference");
- JAXBElement<EndpointReferenceType>
- jaxEle = new JAXBElement<EndpointReferenceType>(qname, EndpointReferenceType.class, epr);
+ JAXBElement<EndpointReferenceType> jaxEle
+ = new JAXBElement<EndpointReferenceType>(qname, EndpointReferenceType.class, epr);
W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
diff --git a/core/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java b/core/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
index f13128fa975..588c83fbd61 100644
--- a/core/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
+++ b/core/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
@@ -112,6 +112,7 @@ public static AttributedURI convert(AttributedURIType internal) {
*/
public static org.apache.cxf.ws.addressing.v200403.AttributedURI
convertTo200403(AttributedURIType internal) {
+
org.apache.cxf.ws.addressing.v200403.AttributedURI exposed = Names200403.WSA_OBJECT_FACTORY
.createAttributedURI();
String exposedValue = Names.WSA_ANONYMOUS_ADDRESS.equals(internal.getValue())
@@ -264,8 +265,7 @@ public static EndpointReferenceType convert(
* @param exposed the 2004/03 EndpointReferenceType
* @return an equivalent 2005/08 EndpointReferenceType
*/
- public static EndpointReferenceType
- convert(org.apache.cxf.ws.addressing.v200403.EndpointReferenceType exposed) {
+ public static EndpointReferenceType convert(org.apache.cxf.ws.addressing.v200403.EndpointReferenceType exposed) {
EndpointReferenceType internal = ContextUtils.WSA_OBJECT_FACTORY.createEndpointReferenceType();
internal.setAddress(convert(exposed.getAddress()));
// TODO ref parameters not present in 2004/03
diff --git a/core/src/main/java/org/apache/cxf/ws/addressing/WSAContextUtils.java b/core/src/main/java/org/apache/cxf/ws/addressing/WSAContextUtils.java
index f8e3117e772..aa727e05312 100644
--- a/core/src/main/java/org/apache/cxf/ws/addressing/WSAContextUtils.java
+++ b/core/src/main/java/org/apache/cxf/ws/addressing/WSAContextUtils.java
@@ -29,6 +29,8 @@
public final class WSAContextUtils {
public static final String REPLYTO_PROPERTY =
"org.apache.cxf.ws.addressing.replyto";
+ public static final String DECOUPLED_ENDPOINT_BASE_PROPERTY =
+ "org.apache.cxf.ws.addressing.decoupled.endpoint.base";
private static final String USING_PROPERTY =
"org.apache.cxf.ws.addressing.using";
diff --git a/core/src/main/resources/schemas/configuration/security.xsd b/core/src/main/resources/schemas/configuration/security.xsd
index e68e65ab57a..56fe888bfdb 100644
--- a/core/src/main/resources/schemas/configuration/security.xsd
+++ b/core/src/main/resources/schemas/configuration/security.xsd
@@ -341,6 +341,18 @@
</xs:sequence>
</xs:complexType>
+ <xs:complexType name="ExcludeProtocols">
+ <xs:annotation>
+ <xs:documentation>
+ This structure holds a list of protocols that are to be excluded.
+ If this structure is not defined then SSLv3 is excluded by default
+ </xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="excludeProtocol" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
<xs:complexType name="SecureRandomParameters">
<xs:annotation>
<xs:documentation>
@@ -538,6 +550,13 @@
</xs:documentation>
</xs:annotation>
</xs:element>
+ <xs:element name="excludeProtocols" type="tns:ExcludeProtocols" minOccurs="0">
+ <xs:annotation>
+ <xs:documentation>
+ This element contains the the Protocols that will be excluded
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
<xs:element name="secureRandomParameters"
type="tns:SecureRandomParameters" minOccurs="0">
<xs:annotation>
diff --git a/core/src/main/resources/schemas/wsdl/mime-binding.xsd b/core/src/main/resources/schemas/wsdl/mime-binding.xsd
index 68fd9b3d953..77a7428dd00 100644
--- a/core/src/main/resources/schemas/wsdl/mime-binding.xsd
+++ b/core/src/main/resources/schemas/wsdl/mime-binding.xsd
@@ -11,7 +11,7 @@ Files in any medium without fee or royalty as long as this notice and
license are distributed with them. The originals of these files can
be located at:
-http://schemas.xmlsoap.org/wsdl/mime/2002-01-29.xsd
+http://schemas.xmlsoap.org/wsdl/mime/2004-08-24.xsd
THESE SCHEMA FILES ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS
OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THESE FILES, INCLUDING, BUT NOT
@@ -28,43 +28,50 @@ in these files will at all times remain with the Authors.
No other rights are granted by implication, estoppel or otherwise.
- -->
-<schema targetNamespace="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://www.w3.org/2001/XMLSchema">
+ -->
+<schema targetNamespace="http://schemas.xmlsoap.org/wsdl/mime/" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/">
- <import namespace="http://schemas.xmlsoap.org/wsdl/"/>
- <element name="content" type="mime:contentType"/>
- <complexType name="contentType">
+ <import namespace="http://schemas.xmlsoap.org/wsdl/" schemaLocation="http://schemas.xmlsoap.org/wsdl/" />
+
+ <element name="content" type="mime:contentType"/>
+ <complexType name="contentType">
<complexContent>
- <extension base="wsdl:tExtensibilityElement">
- <sequence/>
- <attribute name="type" type="string" use="optional"/>
- <attribute name="part" type="NMTOKEN" use="optional"/>
- </extension>
+ <extension base="wsdl:tExtensibilityElement">
+ <sequence/>
+ <attribute name="type" type="string" use="optional"/>
+ <attribute name="part" type="NMTOKEN" use="required"/>
+ </extension>
</complexContent>
- </complexType>
- <element name="multipartRelated" type="mime:multipartRelatedType"/>
- <complexType name="multipartRelatedType">
+ </complexType>
+
+ <element name="multipartRelated" type="mime:multipartRelatedType"/>
+ <complexType name="multipartRelatedType">
<complexContent>
- <extension base="wsdl:tExtensibilityElement">
- <sequence>
- <element name="part" type="mime:tPart" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </extension>
+ <extension base="wsdl:tExtensibilityElement">
+ <sequence>
+ <element ref="mime:part" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </extension>
</complexContent>
- </complexType>
- <complexType name="tPart">
+ </complexType>
+
+ <element name="part" type="mime:tPart"/>
+ <complexType name="tPart">
<sequence>
- <any namespace="##targetNamespace" minOccurs="0" maxOccurs="unbounded"/>
+ <any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
- <attribute name="name" type="NMTOKEN" use="required"/>
- </complexType>
- <element name="mimeXml" type="mime:tMimeXml"/>
- <complexType name="tMimeXml">
- <complexContent>
- <extension base="wsdl:tExtensibilityElement">
- <sequence/>
- <attribute name="part" type="NMTOKEN" use="optional"/>
- </extension>
- </complexContent>
- </complexType>
-</schema>
\ No newline at end of file
+ <attribute name="name" type="NMTOKEN" use="optional"/>
+ </complexType>
+
+ <element name="mimeXml" type="mime:tMimeXml" />
+ <complexType name="tMimeXml">
+ <complexContent>
+ <extension base="wsdl:tExtensibilityElement">
+ <sequence />
+ <attribute name="part" type="NMTOKEN" use="optional" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
+
diff --git a/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java b/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java
index 932dcfee4ed..6eeedd42e96 100644
--- a/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java
+++ b/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java
@@ -70,7 +70,13 @@ public void testContendDispositionFileNameWithQuotesAndSemicolon3() {
assertEquals("a;txt",
AttachmentUtil.getContentDispositionFileName("name=\"a\";filename=\"a;txt\""));
}
-
-
+
+ @Test
+ public void testContendDispositionFileNameKanjiChars() {
+ assertEquals("世界ーファイル.txt",
+ AttachmentUtil.getContentDispositionFileName(
+ "filename*=UTF-8''%e4%b8%96%e7%95%8c%e3%83%bc%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab.txt"));
+ }
+
}
diff --git a/core/src/test/java/org/apache/cxf/attachment/Rfc5987UtilTest.java b/core/src/test/java/org/apache/cxf/attachment/Rfc5987UtilTest.java
new file mode 100644
index 00000000000..741f3d0d41b
--- /dev/null
+++ b/core/src/test/java/org/apache/cxf/attachment/Rfc5987UtilTest.java
@@ -0,0 +1,56 @@
+/**
+ * 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.apache.cxf.attachment;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(Parameterized.class)
+public class Rfc5987UtilTest {
+ private final String input;
+ private final String expected;
+
+ public Rfc5987UtilTest(String input, String expected) {
+ this.input = input;
+ this.expected = expected;
+ }
+
+ @Parameterized.Parameters
+ public static List<Object[]> params() throws Exception {
+ List<Object[]> params = new ArrayList<Object[]>();
+ params.add(new Object[] {"foo-ä-€.html", "foo-%c3%a4-%e2%82%ac.html"});
+ params.add(new Object[]{"世界ーファイル 2.jpg",
+ "%e4%b8%96%e7%95%8c%e3%83%bc%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%202.jpg"});
+ params.add(new Object[]{"foo.jpg", "foo.jpg"});
+ return params;
+ }
+
+ @Test
+ public void test() throws Exception {
+ assertEquals(expected, Rfc5987Util.encode(input, "UTF-8"));
+
+ assertEquals(input, Rfc5987Util.decode(expected, "UTF-8"));
+ }
+}
diff --git a/core/src/test/java/org/apache/cxf/common/util/UrlUtilsTest.java b/core/src/test/java/org/apache/cxf/common/util/UrlUtilsTest.java
index 7cafc2a84b7..3989e9f47b1 100644
--- a/core/src/test/java/org/apache/cxf/common/util/UrlUtilsTest.java
+++ b/core/src/test/java/org/apache/cxf/common/util/UrlUtilsTest.java
@@ -30,6 +30,13 @@ public void testUrlDecode() {
assertEquals("+ ", UrlUtils.urlDecode("%2B+"));
}
+ @Test
+ public void testUrlDecodeSingleCharMultipleEscapes() {
+ String s = "ß";
+ String encoded = UrlUtils.urlEncode(s);
+ assertEquals(s, UrlUtils.urlDecode(encoded));
+ }
+
@Test
public void testUrlDecodeReserved() {
assertEquals("!$&'()*,;=", UrlUtils.urlDecode("!$&'()*,;="));
diff --git a/core/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java b/core/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
index b790880e10b..bb0d5ecc428 100644
--- a/core/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
+++ b/core/src/test/java/org/apache/cxf/helpers/ServiceUtilsTest.java
@@ -45,96 +45,130 @@ public void testmakeNamespaceFromClassName() throws Exception {
assertEquals("http://ws.example.com/", tns);
}
+
+ @Test
+ public void testRequestResponseTypes() {
+ // lets do server side first
+ setupSchemaValidationValue(SchemaValidationType.REQUEST, false);
+ assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
+
+ setupSchemaValidationValue(SchemaValidationType.REQUEST, false);
+ assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
+
+ setupSchemaValidationValue(SchemaValidationType.RESPONSE, false);
+ assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
+
+ setupSchemaValidationValue(SchemaValidationType.RESPONSE, false);
+ assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
+
+ // now client side
+ setupSchemaValidationValue(SchemaValidationType.REQUEST, true);
+ assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
+
+ setupSchemaValidationValue(SchemaValidationType.REQUEST, true);
+ assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
+
+ setupSchemaValidationValue(SchemaValidationType.RESPONSE, true);
+ assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
+
+ setupSchemaValidationValue(SchemaValidationType.RESPONSE, true);
+ assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
+ }
+
@Test
public void testIsSchemaValidationEnabled() {
- setupSchemaValidationValue(SchemaValidationType.NONE);
+ setupSchemaValidationValue(SchemaValidationType.NONE, false);
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
- setupSchemaValidationValue(SchemaValidationType.NONE);
+ setupSchemaValidationValue(SchemaValidationType.NONE, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.BOTH, msg));
- setupSchemaValidationValue(SchemaValidationType.NONE);
+ setupSchemaValidationValue(SchemaValidationType.NONE, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
- setupSchemaValidationValue(SchemaValidationType.NONE);
+ setupSchemaValidationValue(SchemaValidationType.NONE, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
- setupSchemaValidationValue(SchemaValidationType.IN);
+ setupSchemaValidationValue(SchemaValidationType.IN, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
- setupSchemaValidationValue(SchemaValidationType.IN);
+ setupSchemaValidationValue(SchemaValidationType.IN, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.BOTH, msg));
- setupSchemaValidationValue(SchemaValidationType.IN);
+ setupSchemaValidationValue(SchemaValidationType.IN, false);
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
- setupSchemaValidationValue(SchemaValidationType.IN);
+ setupSchemaValidationValue(SchemaValidationType.IN, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
- setupSchemaValidationValue(SchemaValidationType.OUT);
+ setupSchemaValidationValue(SchemaValidationType.OUT, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
- setupSchemaValidationValue(SchemaValidationType.OUT);
+ setupSchemaValidationValue(SchemaValidationType.OUT, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.BOTH, msg));
- setupSchemaValidationValue(SchemaValidationType.OUT);
+ setupSchemaValidationValue(SchemaValidationType.OUT, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
- setupSchemaValidationValue(SchemaValidationType.OUT);
+ setupSchemaValidationValue(SchemaValidationType.OUT, false);
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
- setupSchemaValidationValue(SchemaValidationType.BOTH);
+ setupSchemaValidationValue(SchemaValidationType.BOTH, false);
assertFalse(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.NONE, msg));
- setupSchemaValidationValue(SchemaValidationType.BOTH);
+ setupSchemaValidationValue(SchemaValidationType.BOTH, false);
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.BOTH, msg));
- setupSchemaValidationValue(SchemaValidationType.BOTH);
+ setupSchemaValidationValue(SchemaValidationType.BOTH, false);
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.IN, msg));
- setupSchemaValidationValue(SchemaValidationType.BOTH);
+ setupSchemaValidationValue(SchemaValidationType.BOTH, false);
assertTrue(ServiceUtils.isSchemaValidationEnabled(SchemaValidationType.OUT, msg));
}
@Test
public void testGetSchemaValidationTypeBoolean() {
- setupSchemaValidationValue(null);
+ setupSchemaValidationValue(null, false);
assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue("");
+ setupSchemaValidationValue("", false);
assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue(Boolean.FALSE);
+ setupSchemaValidationValue(Boolean.FALSE, false);
assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue("false");
+ setupSchemaValidationValue("false", false);
assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue("FALSE");
+ setupSchemaValidationValue("FALSE", false);
assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue("fAlse");
+ setupSchemaValidationValue("fAlse", false);
assertEquals(SchemaValidationType.NONE, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue(Boolean.TRUE);
+ setupSchemaValidationValue(Boolean.TRUE, false);
assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue("true");
+ setupSchemaValidationValue("true", false);
assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue("TRUE");
+ setupSchemaValidationValue("TRUE", false);
assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue("tRue");
+ setupSchemaValidationValue("tRue", false);
assertEquals(SchemaValidationType.BOTH, ServiceUtils.getSchemaValidationType(msg));
}
@Test
public void testGetSchemaValidationType() {
for (SchemaValidationType type : SchemaValidationType.values()) {
- setupSchemaValidationValue(type.name());
+ setupSchemaValidationValue(type.name(), false);
assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue(type.name().toLowerCase());
+ setupSchemaValidationValue(type.name().toLowerCase(), false);
assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
- setupSchemaValidationValue(StringUtils.capitalize(type.name()));
+ setupSchemaValidationValue(StringUtils.capitalize(type.name()), false);
assertEquals(type, ServiceUtils.getSchemaValidationType(msg));
}
}
- private void setupSchemaValidationValue(Object value) {
+ private void setupSchemaValidationValue(Object value, boolean isRequestor) {
control.reset();
msg.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
EasyMock.expectLastCall().andReturn(value);
+
+ msg.get(Message.REQUESTOR_ROLE);
+ EasyMock.expectLastCall().andReturn(isRequestor);
+
control.replay();
}
}
diff --git a/distribution/javadoc/pom.xml b/distribution/javadoc/pom.xml
index 681b17a6ff7..ab1451e8a8e 100644
--- a/distribution/javadoc/pom.xml
+++ b/distribution/javadoc/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../parent</relativePath>
</parent>
<dependencies>
@@ -370,6 +370,10 @@
<artifactId>logback-classic</artifactId>
<version>${cxf.logback.classic.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.hbase</groupId>
+ <artifactId>hbase-client</artifactId>
+ </dependency>
</dependencies>
<build>
<plugins>
@@ -409,7 +413,7 @@
<fileset dir="../../services">
<include name="**/src/main/java/**/*.java" />
-
+ <exclude name="**/wsn-osgi/**" />
<exclude name="**/systests/**" />
<exclude name="**/sts-war/**" />
<exclude name="**/xkms-war/**" />
diff --git a/distribution/manifest/pom.xml b/distribution/manifest/pom.xml
index 780a59541ac..2b52ebb2bda 100644
--- a/distribution/manifest/pom.xml
+++ b/distribution/manifest/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../parent</relativePath>
</parent>
<properties>
@@ -78,6 +78,11 @@
<artifactId>cxf-tools-wsdlto-frontend-javascript</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>cxf-tools-wadlto-jaxrs</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cxf-tools-java2ws</artifactId>
diff --git a/distribution/pom.xml b/distribution/pom.xml
index fc2b22973dc..3dc8efb6961 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<properties>
@@ -173,12 +173,22 @@
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.5_spec</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-codec-http</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cxf-rt-transports-http-netty-client</artifactId>
<version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-codec-http</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git a/distribution/src/main/appended-resources/META-INF/NOTICE b/distribution/src/main/appended-resources/META-INF/NOTICE
index 888ac892c12..ad95d9aeee9 100644
--- a/distribution/src/main/appended-resources/META-INF/NOTICE
+++ b/distribution/src/main/appended-resources/META-INF/NOTICE
@@ -1,4 +1,4 @@
-This product also includes schemas and specification developed by:
+This product also includes schemas and specification developed by or submitted to:
- the W3C consortium (http://www.w3c.org)
(http://www.w3.org/XML/1998/namespace)
diff --git a/distribution/src/main/release/release_notes.txt b/distribution/src/main/release/release_notes.txt
index 0a3c3726c35..78f926911fa 100644
--- a/distribution/src/main/release/release_notes.txt
+++ b/distribution/src/main/release/release_notes.txt
@@ -1,8 +1,8 @@
-Apache CXF 3.0.1 Release Notes
+Apache CXF 3.0.5 Release Notes
1. Overview
-The 3.0.1 version of Apache CXF is a significant new version of CXF
+The 3.0.x series of Apache CXF is a significant new version of CXF
that provides several new features and enhancements.
New features include:
@@ -22,7 +22,7 @@ Users are encourage to review the migration guide at:
http://cxf.apache.org/docs/30-migration-guide.html
for further information and requirements for upgrading from 2.7.x.
-3.0.1 fixes over 80 JIRA issues reported by users and the community.
+3.0.5 fixes over 70 JIRA issues reported by users and the community.
@@ -66,110 +66,83 @@ for caveats when upgrading from CXF 2.7.x to 3.0.0
7. Specific issues, features, and improvements fixed in this version
-** Sub-task
- * [CXF-5623] - Failed to invoke WSDLToJava - is already defined
+
** Bug
- * [CXF-3272] - WS-RM returns Fault for duplicate message received, should probably return acknowledgement instead
- * [CXF-5719] - NoSuchElementException in ClientFaultConverter when stack trace message contains * or #
- * [CXF-5735] - WS-RM does not handle AckRequested action, resulting in NPE
- * [CXF-5739] - FIQL: java.sql.Timestamp no taken into account
- * [CXF-5740] - CXF-5610 is preventing applications from using the same endpoint url for multiple hadlers
- * [CXF-5749] - Nullpointer on ClientProxyImpl
- * [CXF-5752] - Unable to find the target operation when using websocket transport without atmosphere
- * [CXF-5753] - Unmarshalling error is thrown with CXF 2.7.9 (and later versions) when a JAXWS handler is configured.
- * [CXF-5761] - InInterceptor throws exception with PrettyLogging and big message size
- * [CXF-5763] - ClassCast Exception in AsyncHTTPConduit$AsyncWrappedOutputStream.close() method when using async and HttpAsyncClient
- * [CXF-5765] - Response is invalid
- * [CXF-5766] - Caching nonces to disk may not work if the service QName is too long
- * [CXF-5778] - JMS Subscription: durableSubscriptionName is not propagated into AbstractMessageListenerContainer
- * [CXF-5781] - Port ou of Range: -1
- * [CXF-5783] - Port getter method not renamed in the generated Service class
- * [CXF-5790] - Response-Code is logged for the response sent over a decoupled endpoint
- * [CXF-5791] - Could not send a message. Caused by HTTP response '404: Not Found'
- * [CXF-5793] - wsdl2java NPE
- * [CXF-5794] - DynamicClientFactory createClient fails for Simple Rpc Service (java.lang.IllegalStateException: no source files )
- * [CXF-5798] - WebSocket transport fails to transport a large message
- * [CXF-5801] - Dynamic client invoke throws UnresolvedAddressException when proxied
- * [CXF-5805] - Invalid SOAP Envelope names are accepted
- * [CXF-5806] - FIQL: Problem with mapping on ManyToMany or OnToMany associations of 2nd level
- * [CXF-5807] - Fix STSClient configuration when Issuer EPR has an "anonymous" address
- * [CXF-5808] - jax_rs content_negotiation test fails on successive calls
- * [CXF-5810] - Empty response is returned when both security policy and handler chain are enabled
- * [CXF-5811] - Client fails with UnmarshalException if WSS4JInInterceptor is used
- * [CXF-5817] - CXF's STSClient does not handle additional Schemas properly when parsing a WS-MEX response
- * [CXF-5818] - StackOverflowError caused by HttpsURLConnectionFactory
- * [CXF-5822] - NullPointerException in PropertiesLoaderUtils
- * [CXF-5823] - Base64Utility encodeChunk method works only if the offset is zero
- * [CXF-5825] - ToolContext.isVerbose logic not correct resulting in -verbose flag not being honored
- * [CXF-5834] - WS-RM's JAXB marshalling/unmarshalling is not thread-safe
- * [CXF-5835] - Two issues in org.apache.cxf.jaxrs.provider.DataSourceProvider
- * [CXF-5836] - NullPointerException in AsyncHTTPConduit if http.noProxyHosts set
- * [CXF-5837] - Upload size limit status 500 for files twice bigger than the limit
- * [CXF-5838] - @QueryParam char return incorrect default value
- * [CXF-5839] - ResponseTimeCounter doesn't count the schema validation fault
- * [CXF-5840] - ResponseTimeCounter counts the one-way fault message twice
- * [CXF-5841] - PolicyReferences when using annotations and no separate Java Interface
- * [CXF-5842] - CacheSizeExceededException attachment tempfile leak
- * [CXF-5845] - HTTPTransportActivator does not clean up old configuration while updating
- * [CXF-5851] - JAX-RS proxy throws NPE if a null multipart parameter is passed
- * [CXF-5853] - Mutlipart JAXB model + InputStream using JacksonJsonProvider cause NPE
- * [CXF-5856] - NPE in SwaggerFeature
- * [CXF-5857] - jms examples do not work
- * [CXF-5860] - JAXRS ThreadLocalProxy not visible in OSGI
- * [CXF-5861] - JAX-RS ResourceContext beans get their context values injected too late
- * [CXF-5864] - Anonymous users are denied to call unprotected methods since 2.6.3
- * [CXF-5865] - WebClient.close should not auto-close Response
- * [CXF-5869] - Temporary file caching using encryption may get corrupted data in some ciphers
- * [CXF-5870] - wadl2java -inheritResourceParams generate parameter twice
- * [CXF-5871] - Dispatch.invokeAsync does not calculate operation
- * [CXF-5872] - JAXB Dispatch clients try to create a JAX-WS exception and NPE
- * [CXF-5873] - Exception in SoapOutInterceptor causes lots of warnings in log
- * [CXF-5876] - AtomPojoProvider generates warnings if atom handlers have no setMessageContext method
- * [CXF-5877] - SCT in a (SAML1.1 + SCT) scenario failing to renew ore reissue
+ * [CXF-6007] - WebClient does not resend request in Digest authentication for HTTP methods GET, HEAD, DELETE, OPTIONS (with no body).
+ * [CXF-6256] - Unexpected response code
+ * [CXF-6257] - Creating and Endpoint using JAX-WS API, getting the binding and then publishing causes a NullPointerException
+ * [CXF-6260] - JAXRS Async Client can not handle InvocationCallback TypeVariable
+ * [CXF-6272] - SCT Renew in Secure Conversation
+ * [CXF-6274] - NullPointerException in DestinationSequence because of RMCaptureInInterceptor not in interceptor chain
+ * [CXF-6276] - Some non-primitive properties lost during generating WADL
+ * [CXF-6284] - JAX-RS servlet run-time leaks additional strong references
+ * [CXF-6285] - NPE in SwaggerFeature.calculateDefaultResourcePackage
+ * [CXF-6295] - String cannot be cast to org.apache.ws.security.validate.Validator
+ * [CXF-6297] - JAX-RS BeanValidation feature fails with NPE in JAXRSBeanValidationOutInterceptor on sub-resource call
+ * [CXF-6300] - cipherSuite configuration does not work with HTTPJ servers
+ * [CXF-6302] - JAXRS endpoints with URL encoded addresses can not be located
+ * [CXF-6304] - AuthorizationCodeGrantHandler sets the approved scopes as the requested ones
+ * [CXF-6306] - AuthorizationCodeGrantService does not record a single pre-registered redirect uri in a session if current request has no redirect uri set
+ * [CXF-6309] - Client processing exception has its cause set to the original exception wrapped in Fault
+ * [CXF-6313] - SamlHeaderOutInterceptor does not set headers on the message if it had none
+ * [CXF-6314] - WebSocket transport should not require dependency to jetty
+ * [CXF-6315] - Optional WS-Addressing policy doesn't return required soap headers
+ * [CXF-6317] - Authorization not possible with multiple service beans
+ * [CXF-6319] - Regression: failing namespace resolution after CXF-5891
+ * [CXF-6320] - Zero-length entity should throw 400 on pre-packaged provider
+ * [CXF-6321] - Make sure global JAX-RS filters are applied once per request even if made to sub-resource
+ * [CXF-6322] - AbstractSearchConditionParser not working with UUID fields
+ * [CXF-6327] - Invalid Policy exception for EndorsingSupportingTokens with more than one token assertions
+ * [CXF-6331] - Wrap exceptions in JAXRSBeanValidationInvoker into Fault so that these exceptions are exposed to ExceptionMapper-s
+ * [CXF-6332] - Wadl Genertion: @Description cannot be bound to field
+ * [CXF-6336] - Client ParamConverterProvider may be lost if Client runs in the server scope
+ * [CXF-6338] - Reversed logic in AbstractJwtHandler#validateSignature
+ * [CXF-6340] - Return value of AsyncResponseImpl.cancel() not follow JAXRS 2.0 javadoc
+ * [CXF-6343] - EncryptedHeader not properly processed or generated
+ * [CXF-6352] - ContainerResponseContext.getLinks() loses links if they have no 'rel' parameter
+ * [CXF-6356] - NPE when calling ServiceUnavailableException.getRetryTime()
+ * [CXF-6357] - request matching on method matching issue with compareSortedConsumesMediaTypes
+ * [CXF-6359] - NullPointerException when certAlias specified but no keyManagers are configured
+ * [CXF-6361] - HttpCondiut is not detecting the redirect loop properly
+ * [CXF-6366] - JAX-RS Client runtime does not encode forward slashes in Matrix parameters
+ * [CXF-6367] - JAX-RS Client runtime does not check BeanParam bean fields
+ * [CXF-6368] - Unexpected response code
+ * [CXF-6369] - org.apache.cxf.jaxrs.impl.ConfigurationImpl does not comply with SPEC
+ * [CXF-6370] - wrong usages for System.arraycopy in org.apache.cxf.jaxrs.impl.AsyncResponseImpl
+ * [CXF-6371] - WADL Generator does not always correctly deal with generic types
+ * [CXF-6373] - CompletionCallback can not get the Throwable if error occurs in other interceptor (no serviceinvokerInterceptor)
+ * [CXF-6374] - If no OPTIONS defined , OPTIONS request will fail with 404
+ * [CXF-6375] - Providers.getMessageBodyReader throws NPE
+ * [CXF-6377] - Wrong media type of response
+ * [CXF-6378] - LinkBuilderImpl does not resolve relative links against baseUri
+ * [CXF-6379] - Separate HTTP headers for multiple header values not possible - bug in CXF-3714 fix
** Improvement
- * [CXF-3270] - WS-RM should send acknowledgements when messages are received out of order
- * [CXF-5311] - Support OAuth2 JWT token
- * [CXF-5746] - WebsocketConduit to use the id header so that it can correlate requests and responses
- * [CXF-5747] - Add a karaf feature for the websocket transport
- * [CXF-5748] - Improve WS-Security Kerberos configuration
- * [CXF-5750] - Support SpnegoContextTokens with the TransportBinding
- * [CXF-5751] - Support policy validation for SupportingToken SpnegoContextTokens
- * [CXF-5757] - WADL to Java code generator should optionally support linking arbitrary media types to the grammar
- * [CXF-5764] - AccessTokenService should allow the client authentication with a client id only
- * [CXF-5768] - Fallback to "Issue" if "Renew" fails in the STSClient
- * [CXF-5775] - Constraint Validation Exceptions Logging at Warn logging.LogUtils
- * [CXF-5780] - JMS pubsub: support different parameters for clientID and durableSubscriptionName
- * [CXF-5786] - isValid() in WSIBPValidator should check method signature
- * [CXF-5789] - Add methods to get input and output SOAP headers to SOAPBindingUtil
- * [CXF-5802] - Share an existing global ehcache manager for ws security replay caches
- * [CXF-5804] - Improvement Issue CXF 5781 and CXF 5791
- * [CXF-5809] - WebSocket transport supporting concurrent asynchronous calls
- * [CXF-5813] - add completers for cxf karaf shell commands
- * [CXF-5827] - Use only local name matching for inbound rpc/literal processing to support some older rpc/literal implementation
- * [CXF-5832] - JAX-WS Provider returning JAXBSource with attachment
- * [CXF-5843] - Allow define the ObjectName of ResponseTimeCounterMBean
- * [CXF-5847] - Add operation to enable/disable ResponseTimeCounter
- * [CXF-5868] - Establish Jaas login context using Subject.doAs
- * [CXF-5874] - Add ability to strictly enforce WSA Action values
+ * [CXF-6133] - Introduce Jwe and Jws exception classes to make it easier to provide dedicated JAX-RS exception mappers
+ * [CXF-6220] - JWA algorithm representation code needs to be cleaned up
+ * [CXF-6232] - Refactor CXF's Atmosphere based WebSocket transport for more flexible and extensible handling
+ * [CXF-6255] - WSS4JInInterceptor: "Security header, but it's a fault"
+ * [CXF-6268] - Make cxf-codegen-plugin toolchains aware during maven build
+ * [CXF-6277] - Enhance the X509TokenValidator to also validate X509Data DOM Elements
+ * [CXF-6283] - Support binary attributes in the LDAPClaimsHandler
+ * [CXF-6305] - Add an option to include or exclude specific response headers in WebSocket's transport
+ * [CXF-6308] - Make WebSocket transport's embedded jetty mode to use atmosphere if available
+ * [CXF-6329] - Allow multiple atmosphere interceptors to be configured for the websocket transport
+ * [CXF-6333] - Support Inclusive C14N via security policy
+ * [CXF-6335] - Explicitly set HTTPConduit on client inbound message
+ * [CXF-6337] - Support the redirection directly via the injected JAX-RS ServletContext context
+ * [CXF-6341] - Add atmosphere when installing feature cxf-transports-websocket-server
+ * [CXF-6342] - Undocumented feature to pass dates as Duration in JAX-RS-search
+ * [CXF-6344] - Support system file location for JexlClaimMapper scripts
+ * [CXF-6345] - Support Logging in JexlClaimMapper scripts
+ * [CXF-6353] - provide a not typed way to configure cxf jaxrs clients
+ * [CXF-6363] - Introduce JwsHeaders
** New Feature
- * [CXF-5792] - WSDLGetUtils Customization
- * [CXF-5849] - XSLTJaxbProvider document() resources and URIResolver
- * [CXF-5866] - Allow pre-processing of WSDL in WSDLManager
+ * [CXF-6264] - Provide Swagger to CXF UserResource converter
** Task
- * [CXF-5819] - Introduce HBaseQueryVisitor
-
-
-8. Known issues
-
-If you are using AES encryption with GCM for symmetric encryption in
-XML/WS-Security, there is a problem if you are using BouncyCastle < 1.49 or
-1.50. To circumvent this either of the following steps can be taken:
-
-a) Upgrade to BouncyCastle 1.49 (or 1.51 when it gets released) OR
-b) Set the system property "org.apache.xml.security.cipher.gcm.useIvParameterSpec" to "true".
-
-
+ * [CXF-6278] - Introduce MessageDigestInputStream utility class
+ * [CXF-6279] - Introduce X509 Certificate Path validation utility code
+ * [CXF-6280] - Consider providing a DirectAccessToken JAXRS service
diff --git a/distribution/src/main/release/samples/aegis/pom.xml b/distribution/src/main/release/samples/aegis/pom.xml
index 7c32d674d67..f99a8cd3460 100644
--- a/distribution/src/main/release/samples/aegis/pom.xml
+++ b/distribution/src/main/release/samples/aegis/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -99,24 +99,24 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-databinding-aegis</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- The server example in here launches the embedded jetty. Not needed
if you deploy a WAR. -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
diff --git a/distribution/src/main/release/samples/aegis_standalone/pom.xml b/distribution/src/main/release/samples/aegis_standalone/pom.xml
index 7917da7cf79..2f5617f3ea0 100644
--- a/distribution/src/main/release/samples/aegis_standalone/pom.xml
+++ b/distribution/src/main/release/samples/aegis_standalone/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -99,7 +99,7 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-databinding-aegis</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.java.dev.stax-utils</groupId>
diff --git a/distribution/src/main/release/samples/callback/pom.xml b/distribution/src/main/release/samples/callback/pom.xml
index beab21aff75..9a69d64652c 100644
--- a/distribution/src/main/release/samples/callback/pom.xml
+++ b/distribution/src/main/release/samples/callback/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -125,17 +125,17 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
diff --git a/distribution/src/main/release/samples/configuration_interceptor/pom.xml b/distribution/src/main/release/samples/configuration_interceptor/pom.xml
index 69ec76ca5bd..51a4787f429 100644
--- a/distribution/src/main/release/samples/configuration_interceptor/pom.xml
+++ b/distribution/src/main/release/samples/configuration_interceptor/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -128,22 +128,22 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-management</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
diff --git a/distribution/src/main/release/samples/corba/bank/pom.xml b/distribution/src/main/release/samples/corba/bank/pom.xml
index 2b4b2a67621..dd959b5cad1 100644
--- a/distribution/src/main/release/samples/corba/bank/pom.xml
+++ b/distribution/src/main/release/samples/corba/bank/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<properties>
@@ -129,17 +129,17 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-corba</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-tools-common</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
diff --git a/distribution/src/main/release/samples/corba/bank_ws_addressing/pom.xml b/distribution/src/main/release/samples/corba/bank_ws_addressing/pom.xml
index c66d5c434f5..a8d60f2484e 100644
--- a/distribution/src/main/release/samples/corba/bank_ws_addressing/pom.xml
+++ b/distribution/src/main/release/samples/corba/bank_ws_addressing/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<properties>
@@ -232,17 +232,17 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-corba</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-tools-common</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
diff --git a/distribution/src/main/release/samples/corba/hello_world/pom.xml b/distribution/src/main/release/samples/corba/hello_world/pom.xml
index b0ed8aee52d..71e5ec93aa4 100644
--- a/distribution/src/main/release/samples/corba/hello_world/pom.xml
+++ b/distribution/src/main/release/samples/corba/hello_world/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<properties>
@@ -277,17 +277,17 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-corba</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-tools-common</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
diff --git a/distribution/src/main/release/samples/groovy_spring_support/pom.xml b/distribution/src/main/release/samples/groovy_spring_support/pom.xml
index 8c11b30ba44..74eb212e905 100644
--- a/distribution/src/main/release/samples/groovy_spring_support/pom.xml
+++ b/distribution/src/main/release/samples/groovy_spring_support/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -108,18 +108,18 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
diff --git a/distribution/src/main/release/samples/in_jvm_transport/pom.xml b/distribution/src/main/release/samples/in_jvm_transport/pom.xml
index 926438db002..e05f53140d3 100644
--- a/distribution/src/main/release/samples/in_jvm_transport/pom.xml
+++ b/distribution/src/main/release/samples/in_jvm_transport/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -95,23 +95,23 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-coloc</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
diff --git a/distribution/src/main/release/samples/java_first_jaxws/pom.xml b/distribution/src/main/release/samples/java_first_jaxws/pom.xml
index 724d210fa6d..5bb484d2ffb 100644
--- a/distribution/src/main/release/samples/java_first_jaxws/pom.xml
+++ b/distribution/src/main/release/samples/java_first_jaxws/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -120,12 +120,12 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
diff --git a/distribution/src/main/release/samples/java_first_jaxws_factory_bean/pom.xml b/distribution/src/main/release/samples/java_first_jaxws_factory_bean/pom.xml
index b4b409af267..80baafc601c 100644
--- a/distribution/src/main/release/samples/java_first_jaxws_factory_bean/pom.xml
+++ b/distribution/src/main/release/samples/java_first_jaxws_factory_bean/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -93,18 +93,18 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
diff --git a/distribution/src/main/release/samples/java_first_jms/pom.xml b/distribution/src/main/release/samples/java_first_jms/pom.xml
index c61c2071ad3..111b7b83ea4 100644
--- a/distribution/src/main/release/samples/java_first_jms/pom.xml
+++ b/distribution/src/main/release/samples/java_first_jms/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -112,12 +112,12 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-jms</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
diff --git a/distribution/src/main/release/samples/java_first_jms/src/main/java/demo/client/ClientJMS.java b/distribution/src/main/release/samples/java_first_jms/src/main/java/demo/client/ClientJMS.java
index 43ecb894276..86b16b942bb 100644
--- a/distribution/src/main/release/samples/java_first_jms/src/main/java/demo/client/ClientJMS.java
+++ b/distribution/src/main/release/samples/java_first_jms/src/main/java/demo/client/ClientJMS.java
@@ -30,7 +30,8 @@
public final class ClientJMS {
private static final String JMS_ENDPOINT_URI = "jms:queue:test.cxf.jmstransport.queue?timeToLive=1000"
+ "&jndiConnectionFactoryName=ConnectionFactory" + "&jndiInitialContextFactory"
- + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory";
+ + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+ + "&jndiURL=tcp://localhost:61616";
private static final QName SERVICE_QNAME =
new QName("http://impl.service.demo/", "HelloWorldImplService");
diff --git a/distribution/src/main/release/samples/java_first_jms/src/main/java/demo/server/ServerJMS.java b/distribution/src/main/release/samples/java_first_jms/src/main/java/demo/server/ServerJMS.java
index 6d03861cff2..8da3b9faafe 100644
--- a/distribution/src/main/release/samples/java_first_jms/src/main/java/demo/server/ServerJMS.java
+++ b/distribution/src/main/release/samples/java_first_jms/src/main/java/demo/server/ServerJMS.java
@@ -19,6 +19,7 @@
package demo.server;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.xml.ws.Endpoint;
@@ -34,7 +35,8 @@
private static final String JMS_ENDPOINT_URI = "jms:queue:test.cxf.jmstransport.queue?timeToLive=1000"
+ "&jndiConnectionFactoryName=ConnectionFactory"
+ "&jndiInitialContextFactory"
- + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory";
+ + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+ + "&jndiURL=tcp://localhost:61616";
private ServerJMS() {
//
@@ -55,23 +57,7 @@ public static void main(String args[]) throws Exception {
}
if (launchAmqBroker) {
- /*
- * The following make it easier to run this against something other than ActiveMQ. You will have
- * to get a JMS broker onto the right port of localhost.
- */
- Class<?> brokerClass = ServerJMS.class.getClassLoader()
- .loadClass("org.apache.activemq.broker.BrokerService");
- if (brokerClass == null) {
- System.err.println("ActiveMQ is not in the classpath, cannot launch broker.");
- return;
- }
- Object broker = brokerClass.newInstance();
- Method addConnectorMethod = brokerClass.getMethod("addConnector", String.class);
- addConnectorMethod.invoke(broker, "tcp://localhost:61616");
- Method setDataDirectory = brokerClass.getMethod("setDataDirectory", String.class);
- setDataDirectory.invoke(broker, "target/activemq-data");
- Method startMethod = brokerClass.getMethod("start");
- startMethod.invoke(broker);
+ launchAMQBroker();
}
if (jaxws) {
@@ -86,6 +72,27 @@ public static void main(String args[]) throws Exception {
System.exit(0);
}
+ private static void launchAMQBroker() throws ClassNotFoundException, InstantiationException,
+ IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+ /*
+ * The following make it easier to run this against something other than ActiveMQ. You will have
+ * to get a JMS broker onto the right port of localhost.
+ */
+ Class<?> brokerClass = ServerJMS.class.getClassLoader()
+ .loadClass("org.apache.activemq.broker.BrokerService");
+ if (brokerClass == null) {
+ System.err.println("ActiveMQ is not in the classpath, cannot launch broker.");
+ return;
+ }
+ Object broker = brokerClass.newInstance();
+ Method addConnectorMethod = brokerClass.getMethod("addConnector", String.class);
+ addConnectorMethod.invoke(broker, "tcp://localhost:61616");
+ Method setDataDirectory = brokerClass.getMethod("setDataDirectory", String.class);
+ setDataDirectory.invoke(broker, "target/activemq-data");
+ Method startMethod = brokerClass.getMethod("start");
+ startMethod.invoke(broker);
+ }
+
private static void launchCxfApi() {
Object implementor = new HelloWorldImpl();
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
diff --git a/distribution/src/main/release/samples/java_first_pojo/pom.xml b/distribution/src/main/release/samples/java_first_pojo/pom.xml
index 390a9dc1f7d..94b9a2fcc87 100644
--- a/distribution/src/main/release/samples/java_first_pojo/pom.xml
+++ b/distribution/src/main/release/samples/java_first_pojo/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -93,18 +93,18 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
diff --git a/distribution/src/main/release/samples/java_first_spring_support/pom.xml b/distribution/src/main/release/samples/java_first_spring_support/pom.xml
index 9c09ddedbaf..7b681104076 100644
--- a/distribution/src/main/release/samples/java_first_spring_support/pom.xml
+++ b/distribution/src/main/release/samples/java_first_spring_support/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -96,17 +96,17 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
diff --git a/distribution/src/main/release/samples/jax_rs/basic/pom.xml b/distribution/src/main/release/samples/jax_rs/basic/pom.xml
index fdc972ffa4e..6d017383861 100644
--- a/distribution/src/main/release/samples/jax_rs/basic/pom.xml
+++ b/distribution/src/main/release/samples/jax_rs/basic/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<properties>
@@ -95,18 +95,18 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- This dependency is needed if you're using the Jetty container -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
diff --git a/distribution/src/main/release/samples/jax_rs/basic_https/pom.xml b/distribution/src/main/release/samples/jax_rs/basic_https/pom.xml
index 5d5c88bb006..1e463213cd3 100644
--- a/distribution/src/main/release/samples/jax_rs/basic_https/pom.xml
+++ b/distribution/src/main/release/samples/jax_rs/basic_https/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<properties>
diff --git a/distribution/src/main/release/samples/jax_rs/basic_https/src/main/resources/ServerConfig.xml b/distribution/src/main/release/samples/jax_rs/basic_https/src/main/resources/ServerConfig.xml
index 6368c60ec2e..d0100c1a86d 100644
--- a/distribution/src/main/release/samples/jax_rs/basic_https/src/main/resources/ServerConfig.xml
+++ b/distribution/src/main/release/samples/jax_rs/basic_https/src/main/resources/ServerConfig.xml
@@ -30,18 +30,6 @@
<sec:trustManagers>
<sec:keyStore file="src/main/config/serviceKeystore.jks" password="sspass" type="JKS"/>
</sec:trustManagers>
- <sec:cipherSuitesFilter>
- <!-- these filters ensure that a ciphersuite with
- export-suitable or null encryption is used,
- but exclude anonymous Diffie-Hellman key change as
- this is vulnerable to man-in-the-middle attacks -->
- <sec:include>.*_EXPORT_.*</sec:include>
- <sec:include>.*_EXPORT1024_.*</sec:include>
- <sec:include>.*_WITH_DES_.*</sec:include>
- <sec:include>.*_WITH_AES_.*</sec:include>
- <sec:include>.*_WITH_NULL_.*</sec:include>
- <sec:exclude>.*_DH_anon_.*</sec:exclude>
- </sec:cipherSuitesFilter>
<sec:clientAuthentication want="true" required="true"/>
</httpj:tlsServerParameters>
</httpj:engine>
diff --git a/distribution/src/main/release/samples/jax_rs/content_negotiation/pom.xml b/distribution/src/main/release/samples/jax_rs/content_negotiation/pom.xml
index 01d428ac31e..2e46129bf1e 100644
--- a/distribution/src/main/release/samples/jax_rs/content_negotiation/pom.xml
+++ b/distribution/src/main/release/samples/jax_rs/content_negotiation/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<properties>
@@ -95,23 +95,23 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- This dependency is needed if you're using the Jetty container -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-extension-providers</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.codehaus.jettison</groupId>
diff --git a/distribution/src/main/release/samples/jax_rs/minimal_osgi/pom.xml b/distribution/src/main/release/samples/jax_rs/minimal_osgi/pom.xml
index b67cce7f746..968e6e80cf0 100644
--- a/distribution/src/main/release/samples/jax_rs/minimal_osgi/pom.xml
+++ b/distribution/src/main/release/samples/jax_rs/minimal_osgi/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<properties>
diff --git a/distribution/src/main/release/samples/jax_rs/spring_security/pom.xml b/distribution/src/main/release/samples/jax_rs/spring_security/pom.xml
index 09c71dc2789..61626b667fd 100644
--- a/distribution/src/main/release/samples/jax_rs/spring_security/pom.xml
+++ b/distribution/src/main/release/samples/jax_rs/spring_security/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<properties>
@@ -88,18 +88,18 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- This dependency is needed if you're using the Jetty container -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
@@ -131,7 +131,15 @@
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
- <artifactId>spring-security-core-tiger</artifactId>
+ <artifactId>spring-security-config</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-core</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
diff --git a/distribution/src/main/release/samples/jax_rs/spring_security/src/main/java/demo/jaxrs/service/CustomerServiceSecured.java b/distribution/src/main/release/samples/jax_rs/spring_security/src/main/java/demo/jaxrs/service/CustomerServiceSecured.java
index 56bab234a15..f7e421247b1 100644
--- a/distribution/src/main/release/samples/jax_rs/spring_security/src/main/java/demo/jaxrs/service/CustomerServiceSecured.java
+++ b/distribution/src/main/release/samples/jax_rs/spring_security/src/main/java/demo/jaxrs/service/CustomerServiceSecured.java
@@ -19,8 +19,7 @@
package demo.jaxrs.service;
import javax.ws.rs.core.Response;
-import org.springframework.security.annotation.Secured;
-
+import org.springframework.security.access.annotation.Secured;
public interface CustomerServiceSecured {
diff --git a/distribution/src/main/release/samples/jax_rs/spring_security/src/main/webapp/WEB-INF/beans.xml b/distribution/src/main/release/samples/jax_rs/spring_security/src/main/webapp/WEB-INF/beans.xml
index 0b7afa6be56..3a62cefd4f5 100644
--- a/distribution/src/main/release/samples/jax_rs/spring_security/src/main/webapp/WEB-INF/beans.xml
+++ b/distribution/src/main/release/samples/jax_rs/spring_security/src/main/webapp/WEB-INF/beans.xml
@@ -17,7 +17,7 @@
specific language governing permissions and limitations
under the License.
-->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:security="http://www.springframework.org/schema/security" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:security="http://www.springframework.org/schema/security" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<jaxrs:server id="bookservice" address="/">
@@ -33,19 +33,21 @@
<bean id="customerservice" class="demo.jaxrs.service.CustomerServiceSecuredImpl"/>
-->
<security:global-method-security secured-annotations="enabled">
- <security:protect-pointcut expression="execution(* demo.jaxrs.service.CustomerService.getCustomer(*))" access="ROLE_CUSTOMER, ROLE_ADMIN"/>
+ <security:protect-pointcut expression="execution(* demo.jaxrs.service.CustomerService.getCustomer(*))" access="ROLE_CUSTOMER,ROLE_ADMIN"/>
<security:protect-pointcut expression="execution(* demo.jaxrs.service.CustomerService.addCustomer(*))" access="ROLE_ADMIN"/>
<security:protect-pointcut expression="execution(* demo.jaxrs.service.CustomerService.updateCustomer(Long,demo.jaxrs.service.Customer))" access="ROLE_ADMIN"/>
<security:protect-pointcut expression="execution(* demo.jaxrs.service.CustomerService.deleteCustomer(*))" access="ROLE_ADMIN"/>
- <security:protect-pointcut expression="execution(* demo.jaxrs.service.CustomerService.getOrder(*))" access="ROLE_CUSTOMER, ROLE_ADMIN"/>
+ <security:protect-pointcut expression="execution(* demo.jaxrs.service.CustomerService.getOrder(*))" access="ROLE_CUSTOMER,ROLE_ADMIN"/>
</security:global-method-security>
<security:http auto-config="true">
<security:http-basic/>
</security:http>
- <security:authentication-provider>
- <security:user-service>
- <security:user name="bob" password="bobspassword" authorities="ROLE_CUSTOMER"/>
- <security:user name="fred" password="fredspassword" authorities="ROLE_CUSTOMER, ROLE_ADMIN"/>
- </security:user-service>
- </security:authentication-provider>
+ <security:authentication-manager>
+ <security:authentication-provider>
+ <security:user-service>
+ <security:user name="bob" password="bobspassword" authorities="ROLE_CUSTOMER"/>
+ <security:user name="fred" password="fredspassword" authorities="ROLE_CUSTOMER,ROLE_ADMIN"/>
+ </security:user-service>
+ </security:authentication-provider>
+ </security:authentication-manager>
</beans>
diff --git a/distribution/src/main/release/samples/jax_rs/websocket/README.txt b/distribution/src/main/release/samples/jax_rs/websocket/README.txt
index 19d8ecb2dcc..09c43e87f4f 100644
--- a/distribution/src/main/release/samples/jax_rs/websocket/README.txt
+++ b/distribution/src/main/release/samples/jax_rs/websocket/README.txt
@@ -75,14 +75,24 @@ with the data:
updates the customer instance whose id is 123
-A GET request to path /monitor
+A GET request to path /monitor with id monitor-12345
------------------------------------------------------------------------
GET /customerservice/monitor
+requestId: monitor-12345
------------------------------------------------------------------------
returns a continuous event stream on the customer
-activities.
+activities. Try invoking some customer related operations.
+
+A GET request to path /unmonitor with id monitor-12345
+
+------------------------------------------------------------------------
+GET /customerservice/unmonitor/monitor-12345
+------------------------------------------------------------------------
+
+unregisters the event stream and returns its status.
+
The client code demonstrates how to send GET/POST/PUT/DELETE requests over
a websocket.
diff --git a/distribution/src/main/release/samples/jax_rs/websocket/pom.xml b/distribution/src/main/release/samples/jax_rs/websocket/pom.xml
index 5c9f1174ab6..d7939d8ca48 100644
--- a/distribution/src/main/release/samples/jax_rs/websocket/pom.xml
+++ b/distribution/src/main/release/samples/jax_rs/websocket/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<properties>
@@ -97,18 +97,23 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- This dependency is needed if you're using the Jetty container -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-websocket</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http-jetty</artifactId>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
diff --git a/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/client/WebSocketTestClient.java b/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/client/WebSocketTestClient.java
index 5db967c9bb3..ba5a7e862c4 100644
--- a/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/client/WebSocketTestClient.java
+++ b/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/client/WebSocketTestClient.java
@@ -216,18 +216,21 @@ private static void writePrintable(StringBuilder buf, int b) {
public Response(Object data) {
this.data = data;
- String line = readLine();
- if (line != null) {
- statusCode = Integer.parseInt(line);
- while ((line = readLine()) != null) {
- if (line.length() > 0) {
- int del = line.indexOf(':');
- String h = line.substring(0, del).trim();
- String v = line.substring(del + 1).trim();
- if ("Content-Type".equalsIgnoreCase(h)) {
- contentType = v;
- }
- }
+ String line;
+ boolean first = true;
+ while ((line = readLine()) != null) {
+ if (first && isStatusCode(line)) {
+ statusCode = Integer.parseInt(line);
+ continue;
+ } else {
+ first = false;
+ }
+
+ int del = line.indexOf(':');
+ String h = line.substring(0, del).trim();
+ String v = line.substring(del + 1).trim();
+ if ("Content-Type".equalsIgnoreCase(h)) {
+ contentType = v;
}
}
if (data instanceof String) {
@@ -237,8 +240,11 @@ public Response(Object data) {
System.arraycopy((byte[])data, pos, (byte[])entity, 0, ((byte[])entity).length);
}
}
-
-
+
+ private static boolean isStatusCode(String line) {
+ char c = line.charAt(0);
+ return '0' <= c && c <= '9';
+ }
public int getStatusCode() {
return statusCode;
diff --git a/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/server/CustomerService.java b/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/server/CustomerService.java
index 9ba3e0542bc..442124ba747 100644
--- a/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/server/CustomerService.java
+++ b/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/server/CustomerService.java
@@ -21,15 +21,14 @@
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
-import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
@@ -39,6 +38,8 @@
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
+import org.apache.cxf.transport.websocket.WebSocketConstants;
+
@Path("/customerservice/")
@Produces("text/xml")
public class CustomerService {
@@ -47,7 +48,7 @@
long currentId = 123;
Map<Long, Customer> customers = new HashMap<Long, Customer>();
Map<Long, Order> orders = new HashMap<Long, Order>();
- Set<OutputStream> monitors = new HashSet<OutputStream>();
+ Map<String, OutputStream> monitors = new HashMap<String, OutputStream>();
public CustomerService() {
init();
@@ -123,21 +124,30 @@ public Order getOrder(@PathParam("orderId") String orderId) {
@GET
@Path("/monitor")
@Produces("text/*")
- public StreamingOutput getBookBought() {
+ public StreamingOutput monitorCustomers(@HeaderParam(WebSocketConstants.DEFAULT_REQUEST_ID_KEY)
+ String reqid) {
+ final String key = reqid == null ? "*" : reqid;
return new StreamingOutput() {
public void write(final OutputStream out) throws IOException, WebApplicationException {
- monitors.add(out);
+ monitors.put(key, out);
out.write(("Subscribed at " + new java.util.Date()).getBytes());
}
};
}
+ @GET
+ @Path("/unmonitor/{key}")
+ @Produces("text/*")
+ public String unmonitorCustomers(@PathParam("key") String key) {
+ return (monitors.remove(key) != null ? "Removed: " : "Already removed: ") + key;
+ }
+
private void sendCustomerEvent(final String msg, final Customer customer) {
executor.execute(new Runnable() {
public void run() {
try {
String t = msg + ": " + customer.getId() + "/" + customer.getName();
- for (Iterator<OutputStream> it = monitors.iterator(); it.hasNext();) {
+ for (Iterator<OutputStream> it = monitors.values().iterator(); it.hasNext();) {
OutputStream out = it.next();
try {
out.write(t.getBytes());
diff --git a/distribution/src/main/release/samples/jax_rs/websocket/src/main/resources/index.html b/distribution/src/main/release/samples/jax_rs/websocket/src/main/resources/index.html
index 2b1cc18124a..87c8eaf638a 100644
--- a/distribution/src/main/release/samples/jax_rs/websocket/src/main/resources/index.html
+++ b/distribution/src/main/release/samples/jax_rs/websocket/src/main/resources/index.html
@@ -29,18 +29,18 @@ <h2>CXF JAX-RS WebSocket Sample</h2>
<div id="output">
<div id="config" style="float: left;">
<strong>Service Endpoint URL:</strong><br />
- <input id="wsUri" size="72" style="width: 450px" value="ws://localhost:9000/"/>
+ <input id="wsUri" size="72" style="width: 100%" value="ws://localhost:9000/"/>
<br/>
<button id="connect">Connect</button>
<button id="disconnect">Disconnect</button>
<br />
<br />
<strong>Request:</strong><br />
- <textarea id="request" rows="10" cols="72" style="width: 450px;">GET /customerservice/customers/123</textarea>
+ <textarea id="request" rows="10" cols="72" style="width: 100%;">GET /customerservice/customers/123</textarea>
<br/>
<button id="send">Send</button>
</div>
- <div id="log" style="float: left; margin-left: 20px; padding-left: 20px; width: 450px; height: 500px; border-left: solid 1px #cccccc;">
+ <div id="log" style="float: left; margin-left: 20px; padding-left: 20px; width: 60%; height: 500px; border-left: solid 1px #cccccc;">
<strong>Log:</strong><br />
<button id="clearLogBut" style="position: relative; top: 3px;">Clear log</button>
<div id="consoleLog" style="margin-top: 5px; border: solid 1px #aaaaaa; overflow-y: scroll; height:100%"></div>
@@ -122,7 +122,7 @@ <h2>CXF JAX-RS WebSocket Sample</h2>
writeToLog('<span style="color:red; font-size:75%; font-style:italic">ERROR</span><span style="color: red;"><pre>' + evt.data + '</pre></span>');
}
- function doSend(message) {
+ function doSend(evt) {
var reqmsg = document.getElementById("request");
writeToLog('<span style="color:green; font-size:75%; font-style:italic">SENT</span><span style="color: green;"><pre>' + createMessage(reqmsg.value) + '</pre></span>');
websocket.send(reqmsg.value);
diff --git a/distribution/src/main/release/samples/jax_server_aegis_client/pom.xml b/distribution/src/main/release/samples/jax_server_aegis_client/pom.xml
index af7ae59d844..8c006dbc3e0 100644
--- a/distribution/src/main/release/samples/jax_server_aegis_client/pom.xml
+++ b/distribution/src/main/release/samples/jax_server_aegis_client/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -93,23 +93,23 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-databinding-aegis</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
diff --git a/distribution/src/main/release/samples/jaxws_async/pom.xml b/distribution/src/main/release/samples/jaxws_async/pom.xml
index 9a9bfaafe85..0ca66576477 100644
--- a/distribution/src/main/release/samples/jaxws_async/pom.xml
+++ b/distribution/src/main/release/samples/jaxws_async/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -135,17 +135,17 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-hc</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
@@ -157,7 +157,7 @@
<!-- Not needed if deploying to a Servlet 3 based container or non-jetty container -->
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
diff --git a/distribution/src/main/release/samples/jaxws_dispatch_provider/pom.xml b/distribution/src/main/release/samples/jaxws_dispatch_provider/pom.xml
index c84e4d7aaea..70ac7d04649 100644
--- a/distribution/src/main/release/samples/jaxws_dispatch_provider/pom.xml
+++ b/distribution/src/main/release/samples/jaxws_dispatch_provider/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -122,18 +122,18 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
diff --git a/distribution/src/main/release/samples/jaxws_handlers/pom.xml b/distribution/src/main/release/samples/jaxws_handlers/pom.xml
index fcd937e5669..10ccd472625 100644
--- a/distribution/src/main/release/samples/jaxws_handlers/pom.xml
+++ b/distribution/src/main/release/samples/jaxws_handlers/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -122,18 +122,18 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
diff --git a/distribution/src/main/release/samples/jms_pubsub/pom.xml b/distribution/src/main/release/samples/jms_pubsub/pom.xml
index d553352c116..ff7812d7105 100644
--- a/distribution/src/main/release/samples/jms_pubsub/pom.xml
+++ b/distribution/src/main/release/samples/jms_pubsub/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -43,7 +43,7 @@
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<executions>
<execution>
<id>generate-sources</id>
@@ -145,12 +145,12 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-jms</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
diff --git a/distribution/src/main/release/samples/jms_queue/pom.xml b/distribution/src/main/release/samples/jms_queue/pom.xml
index bd0fea0ed99..c6acba247b2 100644
--- a/distribution/src/main/release/samples/jms_queue/pom.xml
+++ b/distribution/src/main/release/samples/jms_queue/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -145,12 +145,12 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-jms</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
diff --git a/distribution/src/main/release/samples/jms_spec_demo/pom.xml b/distribution/src/main/release/samples/jms_spec_demo/pom.xml
index 9a421455c37..4a02c2cbb02 100644
--- a/distribution/src/main/release/samples/jms_spec_demo/pom.xml
+++ b/distribution/src/main/release/samples/jms_spec_demo/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -145,12 +145,12 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-jms</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
diff --git a/distribution/src/main/release/samples/jms_spring_config/pom.xml b/distribution/src/main/release/samples/jms_spring_config/pom.xml
index dac945aa966..c0955c8b6da 100644
--- a/distribution/src/main/release/samples/jms_spring_config/pom.xml
+++ b/distribution/src/main/release/samples/jms_spring_config/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -159,12 +159,12 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-jms</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf.xjc-utils</groupId>
diff --git a/distribution/src/main/release/samples/js_browser_client_java_first/pom.xml b/distribution/src/main/release/samples/js_browser_client_java_first/pom.xml
index ba2f12ac705..e6bbd442913 100644
--- a/distribution/src/main/release/samples/js_browser_client_java_first/pom.xml
+++ b/distribution/src/main/release/samples/js_browser_client_java_first/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -70,22 +70,22 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-javascript</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
diff --git a/distribution/src/main/release/samples/js_browser_client_simple/pom.xml b/distribution/src/main/release/samples/js_browser_client_simple/pom.xml
index d2f288b2c7c..8fb5366aee0 100644
--- a/distribution/src/main/release/samples/js_browser_client_simple/pom.xml
+++ b/distribution/src/main/release/samples/js_browser_client_simple/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -119,22 +119,22 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-javascript</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
diff --git a/distribution/src/main/release/samples/js_client/pom.xml b/distribution/src/main/release/samples/js_client/pom.xml
index a8750b4193b..3b32b0ec70a 100644
--- a/distribution/src/main/release/samples/js_client/pom.xml
+++ b/distribution/src/main/release/samples/js_client/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -121,22 +121,22 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-javascript</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>rhino</groupId>
diff --git a/distribution/src/main/release/samples/js_provider/pom.xml b/distribution/src/main/release/samples/js_provider/pom.xml
index b51efa832ea..11fa4645b16 100644
--- a/distribution/src/main/release/samples/js_provider/pom.xml
+++ b/distribution/src/main/release/samples/js_provider/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -140,18 +140,18 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-js</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
diff --git a/distribution/src/main/release/samples/logbrowser-blueprint/README.txt b/distribution/src/main/release/samples/logbrowser-blueprint/README.txt
new file mode 100644
index 00000000000..80bf7e3855a
--- /dev/null
+++ b/distribution/src/main/release/samples/logbrowser-blueprint/README.txt
@@ -0,0 +1,39 @@
+Building and running the logbrowser-blueprint demo on Karaf
+----------------------------------------------------
+
+From the base directory of this sample (i.e., where this README file is
+located), the pom.xml file is used to build and run the demo.
+
+Using either UNIX or Windows:
+
+0) Build the project by typing:
+ mvn clean install
+
+This sample project generates a bundle file which can be used in an OSGi container.
+
+Assuming you have a freshly intalled Apache Karaf-3.x,
+1) Start Karaf and at its console, type(*Note)
+ feature:repo-add cxf 3.0.2
+ feature:install cxf-management-web
+ install -s mvn:org.apache.cxf.samples/logbrowser-blueprint/3.0.2
+
+2) Open browser and go to:
+ http://localhost:8181/cxf/samples/logbrowser/browser/LogBrowser.html
+
+3) Add a new endpoint with URL:
+ http://localhost:8181/cxf/samples/logbrowser/logs
+
+4) To generate custom log entry, run some CXF scenarios that write some logs.
+
+Additional features
+5) Open the Log-Browser(PlainView) page by opening file test/resources/index_plain.html in the browser.
+
+6) Click on the Connect button to open a WebSocket connection to the log browser service.
+Once the connection is open, click on the Subscribe button to subscribe to the logging feed.
+When there are new log entries, they will be pushed to the socket and displayed on the Log text area.
+
+*Note:
+- CXF version 3.0.2 is used in this example, but any verions that include this
+sample code may be used.
+- The default logging setting is set to org.apache.cxf:INFO. This can be changed
+in the configuration file org.apache.cxf.samples.logbrowser.cfg file in etc/.
diff --git a/distribution/src/main/release/samples/logbrowser-blueprint/pom.xml b/distribution/src/main/release/samples/logbrowser-blueprint/pom.xml
new file mode 100644
index 00000000000..8d4d77c908a
--- /dev/null
+++ b/distribution/src/main/release/samples/logbrowser-blueprint/pom.xml
@@ -0,0 +1,109 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>logbrowser-blueprint</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache CXF Samples LogBrowser Blueprint</name>
+ <description>Apacher CXF Samples LogBrowser Blueprint</description>
+ <parent>
+ <groupId>org.apache.cxf.samples</groupId>
+ <artifactId>cxf-samples</artifactId>
+ <version>3.0.6-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.groupId}.${project.artifactId};blueprint.aries.xml-validation:=false</Bundle-SymbolicName>
+ <Import-Package>
+ org.apache.cxf.jaxrs.servlet,
+ org.apache.abdera.parser.stax,
+ org.apache.abdera,
+ com.ctc.wstx.stax,
+ org.eclipse.jetty.continuation;resolution:=optional;version="[7.6,9)",
+ org.eclipse.jetty.websocket;resolution:=optional;version="[7.6,9)",
+ org.eclipse.jetty.websocket.api;resolution:=optional;version="[9.1,10)",
+ org.eclipse.jetty.websocket.server;resolution:=optional;version="[9.1,10)",
+ org.eclipse.jetty.websocket.servlet;resolution:=optional;version="[9.1,10)",
+ org.apache.catalina;resolution:=optional;version="[6.0,9)",
+ org.apache.catalina.comet;resolution:=optional;version="[6.0,9)",
+ org.apache.catalina.connector;resolution:=optional;version="[6.0,9)",
+ org.apache.catalina.util;resolution:=optional;version="[6.0,9)",
+ org.apache.catalina.websocket;resolution:=optional;version="[6.0,9)",
+ org.apache.coyote.http11.upgrade;resolution:=optional,
+ *
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-management-web</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-extension-providers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-extension-search</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http-jetty</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-websocket</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-parser</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.james</groupId>
+ <artifactId>apache-mime4j-core</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-webapp</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/distribution/src/main/release/samples/logbrowser-blueprint/src/main/resources/OSGI-INF/blueprint/context.xml b/distribution/src/main/release/samples/logbrowser-blueprint/src/main/resources/OSGI-INF/blueprint/context.xml
new file mode 100644
index 00000000000..54c9c948404
--- /dev/null
+++ b/distribution/src/main/release/samples/logbrowser-blueprint/src/main/resources/OSGI-INF/blueprint/context.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:cxf="http://cxf.apache.org/blueprint/core"
+ xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
+
+ xsi:schemaLocation="
+ http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
+ http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd
+ http://cxf.apache.org/blueprint/jaxrs http://cxf.apache.org/schemas/blueprint/jaxrs.xsd
+ http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd">
+
+ <cm:property-placeholder id="props" persistent-id="org.apache.cxf.samples.logbrowser" update-strategy="reload">
+ <cm:default-properties>
+ <cm:property name="logger" value="org.apache.cxf:INFO" />
+ </cm:default-properties>
+ </cm:property-placeholder>
+
+ <bean id="bs-sxs" class="org.apache.cxf.management.web.browser.bootstrapping.SimpleXMLSettingsStorage" />
+
+ <bean id="bs" class="org.apache.cxf.management.web.browser.bootstrapping.BootstrapStorage">
+ <argument ref="bs-sxs" index="0"/>
+ </bean>
+
+ <bean id="bs-sfp" class="org.apache.cxf.management.web.browser.bootstrapping.BootstrapStorage$StaticFileProvider" />
+
+ <bean id="bs-sp" class="org.apache.cxf.management.web.browser.bootstrapping.BootstrapStorage$SettingsProvider" />
+
+ <bean id="scp" class="org.apache.cxf.jaxrs.ext.search.SearchContextProvider" />
+
+ <bean id="aps" class="org.apache.cxf.management.web.logging.atom.AtomPullServer" init-method="init">
+ <property name="loggers" value="${logger}"/>
+ </bean>
+
+ <bean id="afp" class="org.apache.cxf.jaxrs.provider.atom.AtomFeedProvider" />
+
+ <bean id="aep" class="org.apache.cxf.jaxrs.provider.atom.AtomEntryProvider" />
+
+ <bean id="srp" class="org.apache.cxf.jaxrs.provider.StreamingResponseProvider" />
+
+ <jaxrs:server id="serviceEndpoint" address="/samples/logbrowser" transportId="http://cxf.apache.org/transports/websocket">
+ <jaxrs:serviceBeans>
+ <ref component-id="aps" />
+ <ref component-id="bs" />
+ </jaxrs:serviceBeans>
+ <jaxrs:providers>
+ <ref component-id="bs-sfp" />
+ <ref component-id="bs-sp" />
+ <ref component-id="scp" />
+ <ref component-id="afp" />
+ <ref component-id="aep" />
+ <ref component-id="srp" />
+ </jaxrs:providers>
+ </jaxrs:server>
+</blueprint>
diff --git a/distribution/src/main/release/samples/logbrowser-blueprint/src/test/resources/index_plain.html b/distribution/src/main/release/samples/logbrowser-blueprint/src/test/resources/index_plain.html
new file mode 100644
index 00000000000..f30ecf64b3e
--- /dev/null
+++ b/distribution/src/main/release/samples/logbrowser-blueprint/src/test/resources/index_plain.html
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+
+ 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.
+
+-->
+<html>
+<head>
+<meta charset="utf-8"/>
+<title>CXF Log-Browser using WebSocket (PlainView)</title>
+</head>
+<body>
+<h2>CXF Log-Browser using WebSocket (PlainView)</h2>
+<p>The purpose of this page is simply show how the log-feed can be subscribed and the log records are pushed over the WebSocket.</p>
+<div id="output">
+ <div id="config" style="float: left; width: 600px">
+ <strong>Log-Browser Endpoint URL:</strong><br />
+ <input id="wsUri" size="72" style="width: 100%" value="ws://localhost:8181/cxf/samples/logbrowser"/>
+ <br/>
+ <button id="connect">Connect</button>
+ <button id="disconnect">Disconnect</button>
+ <br />
+ <br />
+ <button id="subscribe">Subscribe</button>
+ <button id="unsubscribe">Unsubscribe</button>
+ <br />
+ <br />
+ <input id="modeatom" type="checkbox" name="mode" value="atom"/>Atom<br/>
+ <br />
+ <br />
+ </div>
+ <div id="log" style="float: left; width: 90%; height: 500px">
+ <strong>Log:</strong><br />
+ <button id="clearLogBut" style="position: relative; top: 3px;">Clear log</button>
+ <div id="consoleLog" style="margin-top: 5px; border: solid 1px #aaaaaa; overflow-y: scroll; height:100%"></div>
+ </div>
+ <div class="clearfix"></div>
+</div>
+<script language="javascript" type="text/javascript">
+ var output;
+
+ var connectBut = document.getElementById("connect");
+ connectBut.onclick = doConnect;
+
+ var disconnectBut = document.getElementById("disconnect");
+ disconnectBut.onclick = doDisconnect;
+
+ var subBut = document.getElementById("subscribe");
+ subBut.onclick = doSub;
+
+ var unsubBut = document.getElementById("unsubscribe");
+ unsubBut.onclick = doUnsub;
+
+ var modeatomCB = document.getElementById("modeatom");
+
+ var consoleLog = document.getElementById("consoleLog");
+
+ var clearLogBut = document.getElementById("clearLogBut");
+ clearLogBut.onclick = clearLog;
+
+ function init() {
+ output = document.getElementById("output");
+ setGuiConnected(false);
+ }
+
+ function doConnect() {
+ var wsUri = document.getElementById("wsUri");
+
+ websocket = new WebSocket(wsUri.value);
+ websocket.binaryType = 'arraybuffer';
+
+ websocket.onopen = function(evt) {
+ onOpen(evt)
+ };
+
+ websocket.onclose = function(evt) {
+ onClose(evt)
+ };
+
+ websocket.onmessage = function(evt) {
+ onMessage(evt)
+ };
+
+ websocket.onerror = function(evt) {
+ onError(evt)
+ };
+ }
+
+ function doDisconnect() {
+ // unsubscribe
+ websocket.close()
+ }
+
+ function clearLog() {
+ while (consoleLog.childNodes.length > 0) {
+ consoleLog.removeChild(consoleLog.lastChild);
+ }
+ }
+
+ function onOpen(evt) {
+ writeToLog('<span style="color:black; font-size:75%; font-style:italic">CONNECTED</span>');
+ setGuiConnected(true);
+ }
+
+ function onClose(evt) {
+ writeToLog('<span style="color:black; font-size:75%; font-style:italic">DISCONNECTED</span>');
+ setGuiConnected(false);
+ }
+
+ function onMessage(evt) {
+ writeToLog(createMessage(extractBody(evt.data)), true);
+ }
+
+ function onError(evt) {
+ writeToLog('<span style="color:red; font-size:75%; font-style:italic">ERROR</span><span style="color: red;"><pre>' + evt.data + '</pre></span>');
+ }
+
+ function doSub(evt) {
+ var msg = modeatomCB.checked ? "GET /cxf/samples/logbrowser/logs/subscribe" : "GET /cxf/samples/logbrowser/logs/subscribe/alternate";
+ writeToLog('<span style="color:green; font-size:75%; font-style:italic">SENT</span><span style="color: green;"><pre>' + createMessage(msg) + '</pre></span>');
+ websocket.send(msg);
+ setGuiSubscribed(true);
+ }
+
+ function doUnsub(evt) {
+ var msg = "GET /cxf/samples/logbrowser/logs/unsubscribe/*";
+ writeToLog('<span style="color:green; font-size:75%; font-style:italic">SENT</span><span style="color: green;"><pre>' + createMessage(msg) + '</pre></span>');
+ websocket.send(msg);
+ setGuiSubscribed(false);
+ }
+
+ function setGuiConnected(isConnected) {
+ wsUri.disabled = isConnected;
+ connectBut.disabled = isConnected;
+ disconnectBut.disabled = !isConnected;
+ subBut.disabled = !isConnected;
+ unsubBut.disabled = true;
+ modeatomCB.disabled = !isConnected;
+ }
+
+ function setGuiSubscribed(isSubscribed) {
+ subBut.disabled = isSubscribed;
+ unsubBut.disabled = !isSubscribed;
+ modeatomCB.disabled = isSubscribed;
+ }
+
+ // painfully extracting the body by finding the \n delimiter
+ function extractBody(data) {
+ var ba = new Uint8Array(data);
+ var aa = new Array(ba.length);
+ var skipping = true;
+ var maystart = true;
+ for (i = 0; i < ba.length; i++) {
+ if (skipping) {
+ if (ba[i] == 10) {
+ if (maystart) {
+ skipping = false;
+ } else {
+ maystart = true;
+ }
+ } else {
+ if (ba[i] != 13) {
+ maystart = false;
+ }
+ continue;
+ }
+ }
+ aa[i] = String.fromCharCode(ba[i]);
+ }
+ return Array.prototype.slice.call(aa).join("");
+ }
+
+ function createMessage(data) {
+ return data.replace(/&/g, '&').replace(/</g, '<');
+ }
+
+ function writeToLog(message, raw) {
+ var pre = document.createElement(raw ? "code" : "p");
+ pre.wordWrap = "break-word";
+ pre.innerHTML = message;
+ consoleLog.appendChild(pre);
+ if (raw) {
+ consoleLog.appendChild(document.createElement("br"));
+ consoleLog.appendChild(document.createElement("br"));
+ }
+ while (consoleLog.childNodes.length > 100) {
+ consoleLog.removeChild(consoleLog.firstChild);
+ }
+
+ consoleLog.scrollTop = consoleLog.scrollHeight;
+ }
+
+ window.addEventListener("load", init, false);
+
+ </script>
+</body>
+</html>
diff --git a/distribution/src/main/release/samples/logbrowser/README.txt b/distribution/src/main/release/samples/logbrowser/README.txt
index 467becff197..454838f2ce3 100644
--- a/distribution/src/main/release/samples/logbrowser/README.txt
+++ b/distribution/src/main/release/samples/logbrowser/README.txt
@@ -6,7 +6,7 @@ located), the pom.xml file is used to build and run the demo.
Using either UNIX or Windows:
-1) Build the project by typing:
+0) Build the project by typing:
mvn clean install
1) Start the server:
mvn -Pserver
@@ -18,3 +18,32 @@ Using either UNIX or Windows:
http://localhost:9002/customer-service.html
To remove the .class files, run "mvn clean".
+
+
+This sample project generates a war file which can be used in a servlet container
+or even in an OSGi container.
+
+Assuming you have a freshly intalled Apache Karaf-3.x,
+1) Start Karaf and at its console, type(*Note)
+ feature:repo-add cxf 3.0.2
+ feature:install war
+ feature:install cxf-management-web
+ install -s mvn:org.apache.cxf.samples/logbrowser/3.0.2/war
+
+2) Open browser and go to:
+ http://localhost:8181/cxf-samples-logbrowser/log/browser/LogBrowser.html
+3) Add new endpoint with URL:
+ http://localhost:8181/cxf-samples-logbrowser/log/logs
+4) To generate custom log entry open new browser's window and go to:
+ http://localhost:8181/cxf-samples-logbrowser/customer-service.html
+
+*Note:
+- CXF version 3.0.2 is used in this example, but any verions that include this
+sample code may be used.
+- As this web.xml registers two CXFServlets (one for the browsing the log and
+the other for providing the test service), OSGi system property
+org.apache.cxf.osgi.http.transport.disable must be set to false
+(in etc/system.properties) to allow these two servlets to be started.
+However, this will disable the auto-registration of normal CXF endpoints.
+To avoid this issue, use samples/logbrowser-blueprint which is compatible
+with the normal CXF endpoints.
diff --git a/distribution/src/main/release/samples/logbrowser/pom.xml b/distribution/src/main/release/samples/logbrowser/pom.xml
index 09332a376b0..b0925008beb 100644
--- a/distribution/src/main/release/samples/logbrowser/pom.xml
+++ b/distribution/src/main/release/samples/logbrowser/pom.xml
@@ -20,14 +20,72 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>logbrowser</artifactId>
- <name>LogBrowser</name>
- <description>LogBrowser</description>
+ <packaging>war</packaging>
+ <name>Apache CXF Samples LogBrowser</name>
+ <description>Apacher CXF Samples LogBrowser</description>
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <!-- excluding libs and classes/META-INF for OSGi -->
+ <packagingExcludes>WEB-INF/lib/,WEB-INF/classes/META-INF/</packagingExcludes>
+ <archive>
+ <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>bundle-manifest</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ </execution>
+ </executions>
+ <extensions>true</extensions>
+ <configuration>
+ <supportedProjectTypes>
+ <supportedProjectType>jar</supportedProjectType>
+ <supportedProjectType>bundle</supportedProjectType>
+ <supportedProjectType>war</supportedProjectType>
+ </supportedProjectTypes>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Bundle-Description>${project.description}</Bundle-Description>
+ <Web-ContextPath>/cxf-samples-logbrowser</Web-ContextPath>
+ <Bundle-ClassPath>.,WEB-INF/classes</Bundle-ClassPath>
+ <Export-Package />
+ <Import-Package>
+ org.apache.cxf.jaxrs.servlet,
+ org.apache.abdera.parser.stax,
+ com.ctc.wstx.stax,
+ org.apache.abdera,
+ *
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
<profiles>
<profile>
<id>server</id>
@@ -59,17 +117,6 @@
</build>
</profile>
</profiles>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
@@ -98,6 +145,12 @@
<dependency>
<groupId>org.apache.abdera</groupId>
<artifactId>abdera-parser</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.james</groupId>
+ <artifactId>apache-mime4j-core</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
diff --git a/distribution/src/main/release/samples/logbrowser/src/main/java/demo/service/Server.java b/distribution/src/main/release/samples/logbrowser/src/main/java/demo/service/Server.java
index 23734339fc2..53aed963f35 100644
--- a/distribution/src/main/release/samples/logbrowser/src/main/java/demo/service/Server.java
+++ b/distribution/src/main/release/samples/logbrowser/src/main/java/demo/service/Server.java
@@ -47,7 +47,7 @@ protected Server() throws Exception {
WebAppContext webappcontext = new WebAppContext();
webappcontext.setContextPath("/");
- webappcontext.setWar("webapp");
+ webappcontext.setWar("src/main/webapp");
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {webappcontext, new DefaultHandler()});
diff --git a/distribution/src/main/release/samples/logbrowser/webapp/WEB-INF/web.xml b/distribution/src/main/release/samples/logbrowser/src/main/webapp/WEB-INF/web.xml
similarity index 91%
rename from distribution/src/main/release/samples/logbrowser/webapp/WEB-INF/web.xml
rename to distribution/src/main/release/samples/logbrowser/src/main/webapp/WEB-INF/web.xml
index cd164ea0389..eaa0d993255 100644
--- a/distribution/src/main/release/samples/logbrowser/webapp/WEB-INF/web.xml
+++ b/distribution/src/main/release/samples/logbrowser/src/main/webapp/WEB-INF/web.xml
@@ -17,10 +17,13 @@
specific language governing permissions and limitations
under the License.
-->
-<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ version="2.5"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
- <servlet-name>CustomerService</servlet-name>
<display-name>CustomerService</display-name>
+ <servlet-name>CustomerService</servlet-name>
<servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
@@ -41,8 +44,8 @@
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
- <servlet-name>BrowserServlet</servlet-name>
<display-name>BrowserServlet</display-name>
+ <servlet-name>BrowserServlet</servlet-name>
<servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
diff --git a/distribution/src/main/release/samples/logbrowser/webapp/customer-service.html b/distribution/src/main/release/samples/logbrowser/src/main/webapp/customer-service.html
similarity index 95%
rename from distribution/src/main/release/samples/logbrowser/webapp/customer-service.html
rename to distribution/src/main/release/samples/logbrowser/src/main/webapp/customer-service.html
index 4d660fdc8a0..97c2cebda87 100644
--- a/distribution/src/main/release/samples/logbrowser/webapp/customer-service.html
+++ b/distribution/src/main/release/samples/logbrowser/src/main/webapp/customer-service.html
@@ -41,6 +41,10 @@
<script type="text/javascript" src="./jquery-1.4.2.min.js"></script>
<script type="text/javascript">
+
+ var wloc = window.location.pathname;
+ wloc = wloc.substring(0, wloc.lastIndexOf('/'));
+
function buildCustomerAsString(id, name) {
return "{ \"Customer\" : { \"id\" : \"" + id + "\", \"name\" : \"" + name +"\" } }";
}
@@ -67,7 +71,7 @@
$.ajax({
type: "POST",
- url : "/service/customers/",
+ url : wloc + "/service/customers/",
contentType : "application/json",
data : buildCustomerAsString(id, name),
complete : function(xhr) {
@@ -89,7 +93,7 @@
$.ajax({
type: "GET",
- url : "/service/customers/" + id,
+ url : wloc + "/service/customers/" + id,
dataType : "text",
complete : function(xhr) {
if (xhr.status == 200) {
@@ -112,7 +116,7 @@
$.ajax({
type: "DELETE",
- url : "/service/customers/" + id,
+ url : wloc + "/service/customers/" + id,
complete : function(xhr) {
if (xhr.status == 200) {
alert("Customer deleted successfully");
diff --git a/distribution/src/main/release/samples/logbrowser/webapp/jquery-1.4.2.min.js b/distribution/src/main/release/samples/logbrowser/src/main/webapp/jquery-1.4.2.min.js
similarity index 100%
rename from distribution/src/main/release/samples/logbrowser/webapp/jquery-1.4.2.min.js
rename to distribution/src/main/release/samples/logbrowser/src/main/webapp/jquery-1.4.2.min.js
diff --git a/distribution/src/main/release/samples/mtom/pom.xml b/distribution/src/main/release/samples/mtom/pom.xml
index 0d25dc295d8..3d3d5b44c7c 100644
--- a/distribution/src/main/release/samples/mtom/pom.xml
+++ b/distribution/src/main/release/samples/mtom/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -123,18 +123,18 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
diff --git a/distribution/src/main/release/samples/oauth/client/pom.xml b/distribution/src/main/release/samples/oauth/client/pom.xml
index 14232a0521e..a6cde561eb3 100644
--- a/distribution/src/main/release/samples/oauth/client/pom.xml
+++ b/distribution/src/main/release/samples/oauth/client/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<build>
diff --git a/distribution/src/main/release/samples/oauth/server/pom.xml b/distribution/src/main/release/samples/oauth/server/pom.xml
index 6ee6207e043..c97c61eb4f2 100644
--- a/distribution/src/main/release/samples/oauth/server/pom.xml
+++ b/distribution/src/main/release/samples/oauth/server/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<build>
diff --git a/distribution/src/main/release/samples/pom.xml b/distribution/src/main/release/samples/pom.xml
index 3cb46fc3e4b..55e78f1a697 100644
--- a/distribution/src/main/release/samples/pom.xml
+++ b/distribution/src/main/release/samples/pom.xml
@@ -22,7 +22,7 @@
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
<packaging>pom</packaging>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<name>Apache CXF Samples</name>
<description>Apache CXF Samples</description>
<url>http://cxf.apache.org</url>
@@ -89,6 +89,7 @@
<module>jms_pubsub</module>
<module>jax_rs/spring_security</module>
<module>logbrowser</module>
+ <module>logbrowser-blueprint</module>
<module>ws_notification</module>
<module>sts</module>
<module>corba/bank</module>
diff --git a/distribution/src/main/release/samples/restful_dispatch/pom.xml b/distribution/src/main/release/samples/restful_dispatch/pom.xml
index 1f099094c57..92f24a10e8e 100644
--- a/distribution/src/main/release/samples/restful_dispatch/pom.xml
+++ b/distribution/src/main/release/samples/restful_dispatch/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -94,23 +94,23 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
diff --git a/distribution/src/main/release/samples/ruby_spring_support/pom.xml b/distribution/src/main/release/samples/ruby_spring_support/pom.xml
index 6e55a9182c3..7c1e0e44945 100644
--- a/distribution/src/main/release/samples/ruby_spring_support/pom.xml
+++ b/distribution/src/main/release/samples/ruby_spring_support/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -108,18 +108,18 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
diff --git a/distribution/src/main/release/samples/soap_header/pom.xml b/distribution/src/main/release/samples/soap_header/pom.xml
index 4f1cfceb24b..aca321dcf0d 100644
--- a/distribution/src/main/release/samples/soap_header/pom.xml
+++ b/distribution/src/main/release/samples/soap_header/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -122,18 +122,18 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
diff --git a/distribution/src/main/release/samples/sts/pom.xml b/distribution/src/main/release/samples/sts/pom.xml
index b89caa81fbb..5709a109414 100644
--- a/distribution/src/main/release/samples/sts/pom.xml
+++ b/distribution/src/main/release/samples/sts/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<properties>
@@ -65,44 +65,6 @@
</plugins>
</build>
<profiles>
- <profile>
- <id>jdk15</id>
- <activation>
- <jdk>1.5</jdk>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>create-endorsed-dir</id>
- <phase>validate</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- <outputDirectory>${basedir}/target/endorsed</outputDirectory>
- </artifactItem>
- <artifactItem>
- <groupId>xml-apis</groupId>
- <artifactId>xml-apis</artifactId>
- <version>1.3.04</version>
- <outputDirectory>${basedir}/target/endorsed</outputDirectory>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
<profile>
<id>sts</id>
<build>
diff --git a/distribution/src/main/release/samples/ws_addressing/pom.xml b/distribution/src/main/release/samples/ws_addressing/pom.xml
index 8803e4f7e22..2c286930b72 100644
--- a/distribution/src/main/release/samples/ws_addressing/pom.xml
+++ b/distribution/src/main/release/samples/ws_addressing/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -126,17 +126,17 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
diff --git a/distribution/src/main/release/samples/ws_discovery/pom.xml b/distribution/src/main/release/samples/ws_discovery/pom.xml
index 7deba2138d8..9113a80c99a 100644
--- a/distribution/src/main/release/samples/ws_discovery/pom.xml
+++ b/distribution/src/main/release/samples/ws_discovery/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -38,22 +38,22 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf.services.ws-discovery</groupId>
<artifactId>cxf-services-ws-discovery-api</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf.services.ws-discovery</groupId>
<artifactId>cxf-services-ws-discovery-service</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
diff --git a/distribution/src/main/release/samples/ws_eventing/pom.xml b/distribution/src/main/release/samples/ws_eventing/pom.xml
index 2b4888ac6e1..ba854347cba 100644
--- a/distribution/src/main/release/samples/ws_eventing/pom.xml
+++ b/distribution/src/main/release/samples/ws_eventing/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
diff --git a/distribution/src/main/release/samples/ws_notification/pom.xml b/distribution/src/main/release/samples/ws_notification/pom.xml
index ca672b546f6..57f11a9e159 100644
--- a/distribution/src/main/release/samples/ws_notification/pom.xml
+++ b/distribution/src/main/release/samples/ws_notification/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -93,32 +93,32 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-addr</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-policy</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf.services.wsn</groupId>
<artifactId>cxf-services-wsn-core</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
diff --git a/distribution/src/main/release/samples/ws_policy/pom.xml b/distribution/src/main/release/samples/ws_policy/pom.xml
index df6e53191b6..3599b552d53 100644
--- a/distribution/src/main/release/samples/ws_policy/pom.xml
+++ b/distribution/src/main/release/samples/ws_policy/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -121,17 +121,17 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
diff --git a/distribution/src/main/release/samples/ws_rm/pom.xml b/distribution/src/main/release/samples/ws_rm/pom.xml
index 76a01335630..145968b2a11 100644
--- a/distribution/src/main/release/samples/ws_rm/pom.xml
+++ b/distribution/src/main/release/samples/ws_rm/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -116,23 +116,23 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-rm</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
diff --git a/distribution/src/main/release/samples/ws_security/sign_enc/pom.xml b/distribution/src/main/release/samples/ws_security/sign_enc/pom.xml
index 706ac0da986..4ba88afe248 100644
--- a/distribution/src/main/release/samples/ws_security/sign_enc/pom.xml
+++ b/distribution/src/main/release/samples/ws_security/sign_enc/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<properties>
@@ -173,38 +173,38 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-rm</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-addr</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-policy</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
diff --git a/distribution/src/main/release/samples/ws_security/ut/pom.xml b/distribution/src/main/release/samples/ws_security/ut/pom.xml
index b0f14ce1719..9af98a06af8 100644
--- a/distribution/src/main/release/samples/ws_security/ut/pom.xml
+++ b/distribution/src/main/release/samples/ws_security/ut/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<properties>
@@ -162,23 +162,23 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
diff --git a/distribution/src/main/release/samples/ws_security/ut_policy/pom.xml b/distribution/src/main/release/samples/ws_security/ut_policy/pom.xml
index 0113dd99830..9e0d55868bf 100644
--- a/distribution/src/main/release/samples/ws_security/ut_policy/pom.xml
+++ b/distribution/src/main/release/samples/ws_security/ut_policy/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<build>
diff --git a/distribution/src/main/release/samples/ws_security/ut_policy/src/main/resources/ClientConfig.xml b/distribution/src/main/release/samples/ws_security/ut_policy/src/main/resources/ClientConfig.xml
index a87ef2d0691..6ba062e3d5f 100644
--- a/distribution/src/main/release/samples/ws_security/ut_policy/src/main/resources/ClientConfig.xml
+++ b/distribution/src/main/release/samples/ws_security/ut_policy/src/main/resources/ClientConfig.xml
@@ -34,18 +34,6 @@
<sec:trustManagers>
<sec:keyStore file="src/main/config/clientKeystore.jks" password="cspass" type="JKS"/>
</sec:trustManagers>
- <sec:cipherSuitesFilter>
- <!-- these filters ensure that a ciphersuite with
- export-suitable or null encryption is used,
- but exclude anonymous Diffie-Hellman key change as
- this is vulnerable to man-in-the-middle attacks -->
- <sec:include>.*_EXPORT_.*</sec:include>
- <sec:include>.*_EXPORT1024_.*</sec:include>
- <sec:include>.*_WITH_DES_.*</sec:include>
- <sec:include>.*_WITH_AES_.*</sec:include>
- <sec:include>.*_WITH_NULL_.*</sec:include>
- <sec:exclude>.*_DH_anon_.*</sec:exclude>
- </sec:cipherSuitesFilter>
</http:tlsClientParameters>
</http:conduit>
<jaxws:client name="{http://apache.org/hello_world_soap_http}SoapPort" createdFromAPI="true">
diff --git a/distribution/src/main/release/samples/ws_security/ut_policy/src/main/resources/ClientConfigStax.xml b/distribution/src/main/release/samples/ws_security/ut_policy/src/main/resources/ClientConfigStax.xml
index b9c97bdda68..b3ff0264962 100644
--- a/distribution/src/main/release/samples/ws_security/ut_policy/src/main/resources/ClientConfigStax.xml
+++ b/distribution/src/main/release/samples/ws_security/ut_policy/src/main/resources/ClientConfigStax.xml
@@ -34,18 +34,6 @@
<sec:trustManagers>
<sec:keyStore file="src/main/config/clientKeystore.jks" password="cspass" type="JKS"/>
</sec:trustManagers>
- <sec:cipherSuitesFilter>
- <!-- these filters ensure that a ciphersuite with
- export-suitable or null encryption is used,
- but exclude anonymous Diffie-Hellman key change as
- this is vulnerable to man-in-the-middle attacks -->
- <sec:include>.*_EXPORT_.*</sec:include>
- <sec:include>.*_EXPORT1024_.*</sec:include>
- <sec:include>.*_WITH_DES_.*</sec:include>
- <sec:include>.*_WITH_AES_.*</sec:include>
- <sec:include>.*_WITH_NULL_.*</sec:include>
- <sec:exclude>.*_DH_anon_.*</sec:exclude>
- </sec:cipherSuitesFilter>
</http:tlsClientParameters>
</http:conduit>
<jaxws:client name="{http://apache.org/hello_world_soap_http}SoapPort" createdFromAPI="true">
diff --git a/distribution/src/main/release/samples/ws_security/ut_policy/src/main/resources/ServiceConfig.xml b/distribution/src/main/release/samples/ws_security/ut_policy/src/main/resources/ServiceConfig.xml
index 6a213d43aee..0eaa16a254e 100644
--- a/distribution/src/main/release/samples/ws_security/ut_policy/src/main/resources/ServiceConfig.xml
+++ b/distribution/src/main/release/samples/ws_security/ut_policy/src/main/resources/ServiceConfig.xml
@@ -51,18 +51,6 @@
<sec:trustManagers>
<sec:keyStore file="src/main/config/serviceKeystore.jks" password="sspass" type="JKS"/>
</sec:trustManagers>
- <sec:cipherSuitesFilter>
- <!-- these filters ensure that a ciphersuite with
- export-suitable or null encryption is used,
- but exclude anonymous Diffie-Hellman key change as
- this is vulnerable to man-in-the-middle attacks -->
- <sec:include>.*_EXPORT_.*</sec:include>
- <sec:include>.*_EXPORT1024_.*</sec:include>
- <sec:include>.*_WITH_DES_.*</sec:include>
- <sec:include>.*_WITH_AES_.*</sec:include>
- <sec:include>.*_WITH_NULL_.*</sec:include>
- <sec:exclude>.*_DH_anon_.*</sec:exclude>
- </sec:cipherSuitesFilter>
<sec:clientAuthentication want="true" required="true"/>
</httpj:tlsServerParameters>
</httpj:engine>
diff --git a/distribution/src/main/release/samples/ws_security/ut_policy/src/main/resources/ServiceConfigStax.xml b/distribution/src/main/release/samples/ws_security/ut_policy/src/main/resources/ServiceConfigStax.xml
index e8a92111700..c5f72494303 100644
--- a/distribution/src/main/release/samples/ws_security/ut_policy/src/main/resources/ServiceConfigStax.xml
+++ b/distribution/src/main/release/samples/ws_security/ut_policy/src/main/resources/ServiceConfigStax.xml
@@ -52,18 +52,6 @@
<sec:trustManagers>
<sec:keyStore file="src/main/config/serviceKeystore.jks" password="sspass" type="JKS"/>
</sec:trustManagers>
- <sec:cipherSuitesFilter>
- <!-- these filters ensure that a ciphersuite with
- export-suitable or null encryption is used,
- but exclude anonymous Diffie-Hellman key change as
- this is vulnerable to man-in-the-middle attacks -->
- <sec:include>.*_EXPORT_.*</sec:include>
- <sec:include>.*_EXPORT1024_.*</sec:include>
- <sec:include>.*_WITH_DES_.*</sec:include>
- <sec:include>.*_WITH_AES_.*</sec:include>
- <sec:include>.*_WITH_NULL_.*</sec:include>
- <sec:exclude>.*_DH_anon_.*</sec:exclude>
- </sec:cipherSuitesFilter>
<sec:clientAuthentication want="true" required="true"/>
</httpj:tlsServerParameters>
</httpj:engine>
diff --git a/distribution/src/main/release/samples/wsdl_first/pom.xml b/distribution/src/main/release/samples/wsdl_first/pom.xml
index bb3d066f2ca..60b6b85c05d 100644
--- a/distribution/src/main/release/samples/wsdl_first/pom.xml
+++ b/distribution/src/main/release/samples/wsdl_first/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -227,12 +227,12 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf.xjc-utils</groupId>
diff --git a/distribution/src/main/release/samples/wsdl_first_dynamic_client/pom.xml b/distribution/src/main/release/samples/wsdl_first_dynamic_client/pom.xml
index dae62a5803b..b9e670dc668 100644
--- a/distribution/src/main/release/samples/wsdl_first_dynamic_client/pom.xml
+++ b/distribution/src/main/release/samples/wsdl_first_dynamic_client/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -120,18 +120,18 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
diff --git a/distribution/src/main/release/samples/wsdl_first_https/pom.xml b/distribution/src/main/release/samples/wsdl_first_https/pom.xml
index 38d88eaee22..ba838ed812c 100644
--- a/distribution/src/main/release/samples/wsdl_first_https/pom.xml
+++ b/distribution/src/main/release/samples/wsdl_first_https/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<wsdl.location>${basedir}/src/main/config/hello_world.wsdl</wsdl.location>
diff --git a/distribution/src/main/release/samples/wsdl_first_https/src/main/resources/SecureClient.xml b/distribution/src/main/release/samples/wsdl_first_https/src/main/resources/SecureClient.xml
index b831896108d..d69644bd4c2 100644
--- a/distribution/src/main/release/samples/wsdl_first_https/src/main/resources/SecureClient.xml
+++ b/distribution/src/main/release/samples/wsdl_first_https/src/main/resources/SecureClient.xml
@@ -29,18 +29,6 @@
<sec:trustManagers>
<sec:keyStore file="src/main/config/clientKeystore.jks" password="cspass" type="JKS"/>
</sec:trustManagers>
- <sec:cipherSuitesFilter>
- <!-- these filters ensure that a ciphersuite with
- export-suitable or null encryption is used,
- but exclude anonymous Diffie-Hellman key change as
- this is vulnerable to man-in-the-middle attacks -->
- <sec:include>.*_EXPORT_.*</sec:include>
- <sec:include>.*_EXPORT1024_.*</sec:include>
- <sec:include>.*_WITH_DES_.*</sec:include>
- <sec:include>.*_WITH_AES_.*</sec:include>
- <sec:include>.*_WITH_NULL_.*</sec:include>
- <sec:exclude>.*_DH_anon_.*</sec:exclude>
- </sec:cipherSuitesFilter>
</http:tlsClientParameters>
</http:conduit>
</beans>
diff --git a/distribution/src/main/release/samples/wsdl_first_https/src/main/resources/ServerConfig.xml b/distribution/src/main/release/samples/wsdl_first_https/src/main/resources/ServerConfig.xml
index 64ab7597b7a..454c39b2689 100644
--- a/distribution/src/main/release/samples/wsdl_first_https/src/main/resources/ServerConfig.xml
+++ b/distribution/src/main/release/samples/wsdl_first_https/src/main/resources/ServerConfig.xml
@@ -32,18 +32,6 @@
<sec:trustManagers>
<sec:keyStore file="src/main/config/serviceKeystore.jks" password="sspass" type="JKS"/>
</sec:trustManagers>
- <sec:cipherSuitesFilter>
- <!-- these filters ensure that a ciphersuite with
- export-suitable or null encryption is used,
- but exclude anonymous Diffie-Hellman key change as
- this is vulnerable to man-in-the-middle attacks -->
- <sec:include>.*_EXPORT_.*</sec:include>
- <sec:include>.*_EXPORT1024_.*</sec:include>
- <sec:include>.*_WITH_DES_.*</sec:include>
- <sec:include>.*_WITH_AES_.*</sec:include>
- <sec:include>.*_WITH_NULL_.*</sec:include>
- <sec:exclude>.*_DH_anon_.*</sec:exclude>
- </sec:cipherSuitesFilter>
<sec:clientAuthentication want="true" required="true"/>
</httpj:tlsServerParameters>
</httpj:engine>
diff --git a/distribution/src/main/release/samples/wsdl_first_pure_xml/pom.xml b/distribution/src/main/release/samples/wsdl_first_pure_xml/pom.xml
index 89e0d2420dc..71aa8bed4fd 100644
--- a/distribution/src/main/release/samples/wsdl_first_pure_xml/pom.xml
+++ b/distribution/src/main/release/samples/wsdl_first_pure_xml/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -122,18 +122,18 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
diff --git a/distribution/src/main/release/samples/wsdl_first_pure_xml/src/main/java/demo/hw/client/Get.java b/distribution/src/main/release/samples/wsdl_first_pure_xml/src/main/java/demo/hw/client/Get.java
deleted file mode 100644
index caae05e360b..00000000000
--- a/distribution/src/main/release/samples/wsdl_first_pure_xml/src/main/java/demo/hw/client/Get.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * 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 demo.hw.client;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.Properties;
-
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-public final class Get {
-
- private Get() {
- }
-
- public static void main(String args[]) throws Exception {
- // Sent HTTP GET request to invoke sayHi
- String target = "http://localhost:9000/XMLService/XMLPort/sayHi";
- URL url = new URL(target);
- HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
- httpConnection.connect();
- System.out.println("Invoking server through HTTP GET to invoke sayHi");
-
- InputStream in = httpConnection.getInputStream();
- StreamSource source = new StreamSource(in);
- printSource(source);
-
- // Sent HTTP GET request to invoke greetMe FAULT
- target = "http://localhost:9000/XMLService/XMLPort/greetMe/me/CXF";
- url = new URL(target);
- httpConnection = (HttpURLConnection) url.openConnection();
- httpConnection.connect();
- System.out.println("Invoking server through HTTP GET to invoke greetMe");
-
- try {
- in = httpConnection.getInputStream();
- source = new StreamSource(in);
- printSource(source);
- } catch (Exception e) {
- System.err.println("GreetMe Fault: " + e.getMessage());
- }
- InputStream err = httpConnection.getErrorStream();
- source = new StreamSource(err);
- printSource(source);
-
- // Sent HTTP GET request to invoke greetMe
- target = "http://localhost:9000/XMLService/XMLPort/greetMe/requestType/CXF";
- url = new URL(target);
- httpConnection = (HttpURLConnection) url.openConnection();
- httpConnection.connect();
- System.out.println("Invoking server through HTTP GET to invoke greetMe");
-
- in = httpConnection.getInputStream();
- source = new StreamSource(in);
- printSource(source);
- }
-
- private static void printSource(Source source) {
- try {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- StreamResult sr = new StreamResult(bos);
- Transformer trans = TransformerFactory.newInstance().newTransformer();
- Properties oprops = new Properties();
- oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
- trans.setOutputProperties(oprops);
- trans.transform(source, sr);
- System.out.println();
- System.out.println("**** Response ******");
- System.out.println();
- System.out.println(bos.toString());
- bos.close();
- System.out.println();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/distribution/src/main/release/samples/wsdl_first_rpclit/pom.xml b/distribution/src/main/release/samples/wsdl_first_rpclit/pom.xml
index b4b8fa1686e..d19a4989724 100644
--- a/distribution/src/main/release/samples/wsdl_first_rpclit/pom.xml
+++ b/distribution/src/main/release/samples/wsdl_first_rpclit/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -122,18 +122,18 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
diff --git a/distribution/src/main/release/samples/wsdl_first_rpclit/src/main/java/demo/hwRPCLit/client/Get.java b/distribution/src/main/release/samples/wsdl_first_rpclit/src/main/java/demo/hwRPCLit/client/Get.java
deleted file mode 100644
index 26d3cb98113..00000000000
--- a/distribution/src/main/release/samples/wsdl_first_rpclit/src/main/java/demo/hwRPCLit/client/Get.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * 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 demo.hwRPCLit.client;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.Properties;
-
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-public final class Get {
-
- private Get() {
- }
-
- public static void main(String args[]) throws Exception {
- // Sent HTTP GET request to invoke sayHi
- String target = "http://localhost:9000/SoapContext/SoapPort/sayHi";
- URL url = new URL(target);
- HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
- httpConnection.connect();
- System.out.println("Invoking server through HTTP GET to invoke sayHi");
-
- InputStream in = httpConnection.getInputStream();
- StreamSource source = new StreamSource(in);
- printSource(source);
-
- // Sent HTTP GET request to invoke greetMe FAULT
- target = "http://localhost:9000/SoapContext/SoapPort/greetMe/me/CXF";
- url = new URL(target);
- httpConnection = (HttpURLConnection) url.openConnection();
- httpConnection.connect();
- System.out.println("Invoking server through HTTP GET to invoke greetMe");
-
- try {
- in = httpConnection.getInputStream();
- source = new StreamSource(in);
- printSource(source);
- } catch (Exception e) {
- System.err.println("GreetMe Fault: " + e.getMessage());
- }
- InputStream err = httpConnection.getErrorStream();
- source = new StreamSource(err);
- printSource(source);
-
- // Sent HTTP GET request to invoke greetMe
- target = "http://localhost:9000/SoapContext/SoapPort/greetMe/in/CXF";
- url = new URL(target);
- httpConnection = (HttpURLConnection) url.openConnection();
- httpConnection.connect();
- System.out.println("Invoking server through HTTP GET to invoke greetMe");
-
- in = httpConnection.getInputStream();
- source = new StreamSource(in);
- printSource(source);
- }
-
- private static void printSource(Source source) {
- try {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- StreamResult sr = new StreamResult(bos);
- Transformer trans = TransformerFactory.newInstance().newTransformer();
- Properties oprops = new Properties();
- oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
- trans.setOutputProperties(oprops);
- trans.transform(source, sr);
- System.out.println();
- System.out.println("**** Response ******");
- System.out.println();
- System.out.println(bos.toString());
- bos.close();
- System.out.println();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/distribution/src/main/release/samples/wsdl_first_soap12/README.txt b/distribution/src/main/release/samples/wsdl_first_soap12/README.txt
index 1cf07265d3b..9143ec72607 100644
--- a/distribution/src/main/release/samples/wsdl_first_soap12/README.txt
+++ b/distribution/src/main/release/samples/wsdl_first_soap12/README.txt
@@ -18,7 +18,6 @@ Using either UNIX or Windows:
mvn install (builds the demo)
mvn -Pserver (from one command line window)
mvn -Pclient (from a second command line window)
- mvn -Pclient.get (client uses http GET)
To remove the code generated from the WSDL file and the .class
files, run "mvn clean".
diff --git a/distribution/src/main/release/samples/wsdl_first_soap12/pom.xml b/distribution/src/main/release/samples/wsdl_first_soap12/pom.xml
index d13d829ff1c..56ba21239d7 100644
--- a/distribution/src/main/release/samples/wsdl_first_soap12/pom.xml
+++ b/distribution/src/main/release/samples/wsdl_first_soap12/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -117,49 +117,23 @@
</plugins>
</build>
</profile>
- <profile>
- <id>client.get</id>
- <build>
- <defaultGoal>test</defaultGoal>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <phase>test</phase>
- <goals>
- <goal>java</goal>
- </goals>
- <configuration>
- <mainClass>demo.hw.client.Get</mainClass>
- <arguments>
- <argument>${basedir}/wsdl/hello_world_soap12.wsdl</argument>
- </arguments>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
diff --git a/distribution/src/main/release/samples/wsdl_first_soap12/src/main/java/demo/hw/client/Get.java b/distribution/src/main/release/samples/wsdl_first_soap12/src/main/java/demo/hw/client/Get.java
deleted file mode 100644
index 85b83d0bab7..00000000000
--- a/distribution/src/main/release/samples/wsdl_first_soap12/src/main/java/demo/hw/client/Get.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * 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 demo.hw.client;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.Properties;
-
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-public final class Get {
-
- private Get() {
- }
-
- public static void main(String args[]) throws Exception {
- // Sent HTTP GET request to invoke sayHi
- String target = "http://localhost:9000/SoapContext/SoapPort/sayHi";
- URL url = new URL(target);
- HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
- httpConnection.connect();
- System.out.println("Invoking server through HTTP GET to invoke sayHi");
-
- InputStream in = httpConnection.getInputStream();
- StreamSource source = new StreamSource(in);
- printSource(source);
-
- // Sent HTTP GET request to invoke greetMe FAULT
- target = "http://localhost:9000/SoapContext/SoapPort/greetMe/me/CXF";
- url = new URL(target);
- httpConnection = (HttpURLConnection) url.openConnection();
- httpConnection.connect();
- System.out.println("Invoking server through HTTP GET to invoke greetMe");
-
- try {
- in = httpConnection.getInputStream();
- source = new StreamSource(in);
- printSource(source);
- } catch (Exception e) {
- System.err.println("GreetMe Fault: " + e.getMessage());
- }
- InputStream err = httpConnection.getErrorStream();
- source = new StreamSource(err);
- printSource(source);
-
- // Sent HTTP GET request to invoke greetMe
- target = "http://localhost:9000/SoapContext/SoapPort/greetMe/requestType/CXF";
- url = new URL(target);
- httpConnection = (HttpURLConnection) url.openConnection();
- httpConnection.connect();
- System.out.println("Invoking server through HTTP GET to invoke greetMe");
-
- in = httpConnection.getInputStream();
- source = new StreamSource(in);
- printSource(source);
-
- // Sent HTTP GET request to invoke pingMe
- target = "http://localhost:9000/SoapContext/SoapPort/pingMe";
- url = new URL(target);
- httpConnection = (HttpURLConnection) url.openConnection();
- httpConnection.connect();
- System.out.println("Invoking server through HTTP GET to invoke pingMe");
-
- try {
- in = httpConnection.getInputStream();
- } catch (Exception e) {
- System.out.println("PingMe fault raised");
- }
- err = httpConnection.getErrorStream();
- source = new StreamSource(err);
- printSource(source);
- }
-
- private static void printSource(Source source) {
- try {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- StreamResult sr = new StreamResult(bos);
- Transformer trans = TransformerFactory.newInstance().newTransformer();
- Properties oprops = new Properties();
- oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
- trans.setOutputProperties(oprops);
- trans.transform(source, sr);
- System.out.println();
- System.out.println("**** Response ******");
- System.out.println();
- System.out.println(bos.toString());
- bos.close();
- System.out.println();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/distribution/src/main/release/samples/wsdl_first_xml_wrapped/README.txt b/distribution/src/main/release/samples/wsdl_first_xml_wrapped/README.txt
index acdad6ec51e..ed741fa6fd5 100644
--- a/distribution/src/main/release/samples/wsdl_first_xml_wrapped/README.txt
+++ b/distribution/src/main/release/samples/wsdl_first_xml_wrapped/README.txt
@@ -17,8 +17,6 @@ Using either UNIX or Windows:
mvn install (builds the demo)
mvn -Pserver (from one command line window)
mvn -Pclient (from a second command line window)
- mvn -Pclient.get (client uses http GET)
-
To remove the code generated from the WSDL file and the .class
files, run "mvn clean".
diff --git a/distribution/src/main/release/samples/wsdl_first_xml_wrapped/pom.xml b/distribution/src/main/release/samples/wsdl_first_xml_wrapped/pom.xml
index 72586b1d76b..031a56101fc 100644
--- a/distribution/src/main/release/samples/wsdl_first_xml_wrapped/pom.xml
+++ b/distribution/src/main/release/samples/wsdl_first_xml_wrapped/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -117,49 +117,23 @@
</plugins>
</build>
</profile>
- <profile>
- <id>client.get</id>
- <build>
- <defaultGoal>test</defaultGoal>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <phase>test</phase>
- <goals>
- <goal>java</goal>
- </goals>
- <configuration>
- <mainClass>demo.hw.client.Get</mainClass>
- <arguments>
- <argument>${basedir}/wsdl/hello_world.wsdl</argument>
- </arguments>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
diff --git a/distribution/src/main/release/samples/wsdl_first_xml_wrapped/src/main/java/demo/hw/client/Get.java b/distribution/src/main/release/samples/wsdl_first_xml_wrapped/src/main/java/demo/hw/client/Get.java
deleted file mode 100644
index 4464a618d75..00000000000
--- a/distribution/src/main/release/samples/wsdl_first_xml_wrapped/src/main/java/demo/hw/client/Get.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * 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 demo.hw.client;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.Properties;
-
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-public final class Get {
-
- private Get() {
- }
-
- public static void main(String args[]) throws Exception {
- // Sent HTTP GET request to invoke sayHi
- String target = "http://localhost:9000/XMLService/XMLPort/sayHi";
- URL url = new URL(target);
- HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
- httpConnection.connect();
- System.out.println("Invoking server through HTTP GET to invoke sayHi");
-
- InputStream in = httpConnection.getInputStream();
- StreamSource source = new StreamSource(in);
- printSource(source);
-
- // Sent HTTP GET request to invoke greetMe FAULT
- target = "http://localhost:9000/XMLService/XMLPort/greetMe/me/CXF";
- url = new URL(target);
- httpConnection = (HttpURLConnection) url.openConnection();
- httpConnection.connect();
- System.out.println("Invoking server through HTTP GET to invoke greetMe");
-
- try {
- in = httpConnection.getInputStream();
- source = new StreamSource(in);
- printSource(source);
- } catch (Exception e) {
- System.err.println("GreetMe Fault: " + e.getMessage());
- }
- InputStream err = httpConnection.getErrorStream();
- source = new StreamSource(err);
- printSource(source);
-
- // Sent HTTP GET request to invoke greetMe
- target = "http://localhost:9000/XMLService/XMLPort/greetMe/requestType/CXF";
- url = new URL(target);
- httpConnection = (HttpURLConnection) url.openConnection();
- httpConnection.connect();
- System.out.println("Invoking server through HTTP GET to invoke greetMe");
-
- in = httpConnection.getInputStream();
- source = new StreamSource(in);
- printSource(source);
-
- // Sent HTTP GET request to invoke pingMe
- target = "http://localhost:9000/XMLService/XMLPort/pingMe";
- url = new URL(target);
- httpConnection = (HttpURLConnection) url.openConnection();
- httpConnection.connect();
- System.out.println("Invoking server through HTTP GET to invoke pingMe");
-
- try {
- in = httpConnection.getInputStream();
- } catch (Exception e) {
- System.out.println("PingMe fault raised");
- }
- err = httpConnection.getErrorStream();
- source = new StreamSource(err);
- printSource(source);
- }
-
- private static void printSource(Source source) {
- try {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- StreamResult sr = new StreamResult(bos);
- Transformer trans = TransformerFactory.newInstance().newTransformer();
- Properties oprops = new Properties();
- oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
- trans.setOutputProperties(oprops);
- trans.transform(source, sr);
- System.out.println();
- System.out.println("**** Response ******");
- System.out.println();
- System.out.println(bos.toString());
- bos.close();
- System.out.println();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/distribution/src/main/release/samples/wsdl_first_xmlbeans/pom.xml b/distribution/src/main/release/samples/wsdl_first_xmlbeans/pom.xml
index d26dd6b6c54..f3a1340585f 100644
--- a/distribution/src/main/release/samples/wsdl_first_xmlbeans/pom.xml
+++ b/distribution/src/main/release/samples/wsdl_first_xmlbeans/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.samples</groupId>
<artifactId>cxf-samples</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.version>${project.version}</cxf.version>
@@ -53,6 +53,13 @@
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${project.version}</version>
+ <dependencies>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ </dependencies>
<executions>
<execution>
<id>generate-sources</id>
@@ -130,23 +137,23 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-databinding-xmlbeans</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<!-- Jetty is needed if you're using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
diff --git a/distribution/src/main/release/samples/wsdl_first_xmlbeans/src/main/java/demo/hw/client/Get.java b/distribution/src/main/release/samples/wsdl_first_xmlbeans/src/main/java/demo/hw/client/Get.java
deleted file mode 100644
index 85b83d0bab7..00000000000
--- a/distribution/src/main/release/samples/wsdl_first_xmlbeans/src/main/java/demo/hw/client/Get.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * 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 demo.hw.client;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.Properties;
-
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-public final class Get {
-
- private Get() {
- }
-
- public static void main(String args[]) throws Exception {
- // Sent HTTP GET request to invoke sayHi
- String target = "http://localhost:9000/SoapContext/SoapPort/sayHi";
- URL url = new URL(target);
- HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
- httpConnection.connect();
- System.out.println("Invoking server through HTTP GET to invoke sayHi");
-
- InputStream in = httpConnection.getInputStream();
- StreamSource source = new StreamSource(in);
- printSource(source);
-
- // Sent HTTP GET request to invoke greetMe FAULT
- target = "http://localhost:9000/SoapContext/SoapPort/greetMe/me/CXF";
- url = new URL(target);
- httpConnection = (HttpURLConnection) url.openConnection();
- httpConnection.connect();
- System.out.println("Invoking server through HTTP GET to invoke greetMe");
-
- try {
- in = httpConnection.getInputStream();
- source = new StreamSource(in);
- printSource(source);
- } catch (Exception e) {
- System.err.println("GreetMe Fault: " + e.getMessage());
- }
- InputStream err = httpConnection.getErrorStream();
- source = new StreamSource(err);
- printSource(source);
-
- // Sent HTTP GET request to invoke greetMe
- target = "http://localhost:9000/SoapContext/SoapPort/greetMe/requestType/CXF";
- url = new URL(target);
- httpConnection = (HttpURLConnection) url.openConnection();
- httpConnection.connect();
- System.out.println("Invoking server through HTTP GET to invoke greetMe");
-
- in = httpConnection.getInputStream();
- source = new StreamSource(in);
- printSource(source);
-
- // Sent HTTP GET request to invoke pingMe
- target = "http://localhost:9000/SoapContext/SoapPort/pingMe";
- url = new URL(target);
- httpConnection = (HttpURLConnection) url.openConnection();
- httpConnection.connect();
- System.out.println("Invoking server through HTTP GET to invoke pingMe");
-
- try {
- in = httpConnection.getInputStream();
- } catch (Exception e) {
- System.out.println("PingMe fault raised");
- }
- err = httpConnection.getErrorStream();
- source = new StreamSource(err);
- printSource(source);
- }
-
- private static void printSource(Source source) {
- try {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- StreamResult sr = new StreamResult(bos);
- Transformer trans = TransformerFactory.newInstance().newTransformer();
- Properties oprops = new Properties();
- oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
- trans.setOutputProperties(oprops);
- trans.transform(source, sr);
- System.out.println();
- System.out.println("**** Response ******");
- System.out.println();
- System.out.println(bos.toString());
- bos.close();
- System.out.println();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/integration/cdi/pom.xml b/integration/cdi/pom.xml
index f1d2e765ec8..1ecfd1262b9 100644
--- a/integration/cdi/pom.xml
+++ b/integration/cdi/pom.xml
@@ -20,16 +20,21 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>cxf-integration-cdi</artifactId>
- <packaging>jar</packaging>
+ <packaging>bundle</packaging>
<name>Apache CXF CDI Integration</name>
<description>Apache CXF CDI Integration</description>
<url>http://cxf.apache.org</url>
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
+ <properties>
+ <cxf.osgi.import>
+ javax.servlet*;version="${cxf.osgi.javax.servlet.version}",
+ </cxf.osgi.import>
+ </properties>
<dependencies>
<dependency>
<groupId>javax.enterprise</groupId>
diff --git a/integration/jca/pom.xml b/integration/jca/pom.xml
index 37e9ddf7e2e..83219d0dfd5 100644
--- a/integration/jca/pom.xml
+++ b/integration/jca/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
<dependencies>
diff --git a/integration/pom.xml b/integration/pom.xml
index 7b9d7942d55..b99d1923569 100644
--- a/integration/pom.xml
+++ b/integration/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<modules>
<module>jca</module>
diff --git a/maven-plugins/archetypes/cxf-jaxrs-service/pom.xml b/maven-plugins/archetypes/cxf-jaxrs-service/pom.xml
index 6e4bff490ea..405b7315692 100644
--- a/maven-plugins/archetypes/cxf-jaxrs-service/pom.xml
+++ b/maven-plugins/archetypes/cxf-jaxrs-service/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
<groupId>org.apache.cxf.archetype</groupId>
diff --git a/maven-plugins/archetypes/cxf-jaxrs-service/src/main/resources/archetype-resources/pom.xml b/maven-plugins/archetypes/cxf-jaxrs-service/src/main/resources/archetype-resources/pom.xml
index 6282ebdf88a..df43ae24e35 100644
--- a/maven-plugins/archetypes/cxf-jaxrs-service/src/main/resources/archetype-resources/pom.xml
+++ b/maven-plugins/archetypes/cxf-jaxrs-service/src/main/resources/archetype-resources/pom.xml
@@ -16,6 +16,11 @@
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
diff --git a/maven-plugins/archetypes/cxf-jaxws-javafirst/pom.xml b/maven-plugins/archetypes/cxf-jaxws-javafirst/pom.xml
index bd62db0205a..4cdb69e4d84 100644
--- a/maven-plugins/archetypes/cxf-jaxws-javafirst/pom.xml
+++ b/maven-plugins/archetypes/cxf-jaxws-javafirst/pom.xml
@@ -22,12 +22,12 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
<groupId>org.apache.cxf.archetype</groupId>
<artifactId>cxf-jaxws-javafirst</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<packaging>maven-archetype</packaging>
<name>Apache CXF Archetype - Simple JAX-WS Java First</name>
<description>Creates a project for developing a Web service starting from Java code</description>
diff --git a/maven-plugins/archetypes/pom.xml b/maven-plugins/archetypes/pom.xml
index 287694361d0..a4c02b75712 100644
--- a/maven-plugins/archetypes/pom.xml
+++ b/maven-plugins/archetypes/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-maven-plugins</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<modules>
<module>cxf-jaxws-javafirst</module>
diff --git a/maven-plugins/codegen-plugin/pom.xml b/maven-plugins/codegen-plugin/pom.xml
index 7ebe5039b36..458bdab95e8 100644
--- a/maven-plugins/codegen-plugin/pom.xml
+++ b/maven-plugins/codegen-plugin/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-maven-plugins</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
@@ -55,6 +55,11 @@
<artifactId>maven-plugin-api</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-toolchain</artifactId>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
@@ -136,6 +141,43 @@
<optional>true</optional>
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-install-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>install-to-integration-repo</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>install</goal>
+ </goals>
+ <configuration>
+ <localRepositoryPath>${project.build.directory}/it/repo</localRepositoryPath>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <version>1.9</version>
+ <executions>
+ <execution>
+ <id>test-toolchains-integration</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>integration-test</goal>
+ </goals>
+ <configuration>
+ <settingsFile>src/it/settings.xml</settingsFile>
+ <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
<profiles>
<profile>
<id>ibmjdk</id>
diff --git a/maven-plugins/codegen-plugin/src/it/README.md b/maven-plugins/codegen-plugin/src/it/README.md
new file mode 100644
index 00000000000..b202becda5e
--- /dev/null
+++ b/maven-plugins/codegen-plugin/src/it/README.md
@@ -0,0 +1,12 @@
+toolchain-integration-tests
+===========================
+
+jdk6-cxf-with-toolchain
+-----------------------
+
+This project contains sample maven module using `cxf-codegen-plugin` to generate java from WSDL file.
+
+- it enforces usage of JDK 1.7 or higher to run the `mvn` command
+- it configures `maven-toolchains-plugins` to target JDK 6
+- cxf `fork` parameter if set to true to enable toolchain detection
+- if the toolchain wasn't correctly used by the cxf-codegen-plugin`, the the build should fail during the _compile_ phase
diff --git a/maven-plugins/codegen-plugin/src/it/jdk6-cxf-with-toolchain/pom.xml b/maven-plugins/codegen-plugin/src/it/jdk6-cxf-with-toolchain/pom.xml
new file mode 100644
index 00000000000..1dd949f006d
--- /dev/null
+++ b/maven-plugins/codegen-plugin/src/it/jdk6-cxf-with-toolchain/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0"?>
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.cxf.it</groupId>
+ <artifactId>jdk6-cxf-with-toolchain</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <properties>
+ <project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>1.4</version>
+ <executions>
+ <execution>
+ <id>enforce-jdk7-of-higher</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireJavaVersion>
+ <version>[1.7,)</version>
+ </requireJavaVersion>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-toolchains-plugin</artifactId>
+ <version>1.1</version>
+ <configuration>
+ <toolchains>
+ <jdk>
+ <version>6</version>
+ </jdk>
+ </toolchains>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>toolchain</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-codegen-plugin</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <id>wsdl2java</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>wsdl2java</goal>
+ </goals>
+ <configuration>
+ <fork>true</fork>
+ <wsdlOptions>
+ <wsdlOption>
+ <wsdl>src/main/wsdl/HelloWorld.wsdl</wsdl>
+ </wsdlOption>
+ </wsdlOptions>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.9.1</version>
+ <executions>
+ <execution>
+ <id>add-wsdl-source</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/generated-sources/cxf</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/maven-plugins/codegen-plugin/src/it/jdk6-cxf-with-toolchain/src/main/wsdl/HelloWorld.wsdl b/maven-plugins/codegen-plugin/src/it/jdk6-cxf-with-toolchain/src/main/wsdl/HelloWorld.wsdl
new file mode 100644
index 00000000000..21dd8def02b
--- /dev/null
+++ b/maven-plugins/codegen-plugin/src/it/jdk6-cxf-with-toolchain/src/main/wsdl/HelloWorld.wsdl
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+## 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.
+-->
+<wsdl:definitions name="HelloWorld" targetNamespace="http://www.apache.org/contract/HelloWorld"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://www.apache.org/contract/HelloWorld"
+ xmlns:x1="http://www.apache.org/schema/HelloWorld"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <wsdl:types>
+ <schema targetNamespace="http://www.apache.org/schema/HelloWorld"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://www.apache.org/schema/HelloWorld"
+ elementFormDefault="qualified">
+ <element name="sayHi">
+ <complexType>
+ <sequence>
+ <element name="requestType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="sayHiResponse">
+ <complexType>
+ <sequence>
+ <element name="responseType" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+ </wsdl:types>
+ <wsdl:message name="sayHiRequest">
+ <wsdl:part element="x1:sayHi" name="in"/>
+ </wsdl:message>
+ <wsdl:message name="sayHiResponse">
+ <wsdl:part element="x1:sayHiResponse" name="out"/>
+ </wsdl:message>
+ <wsdl:portType name="HelloWorldPortType">
+ <wsdl:operation name="sayHi">
+ <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/>
+ <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="HelloWorldBinding" type="tns:HelloWorldPortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="sayHi">
+ <soap:operation soapAction="" style="document"/>
+ <wsdl:input name="sayHiRequest">
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="sayHiResponse">
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="HelloWorldService">
+ <wsdl:port name="HelloWorldPort" binding="tns:HelloWorldBinding">
+ <!-- Actual soap:address value is dynamically generated after deployment -->
+ <soap:address location="http://dummy.value"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
+
diff --git a/maven-plugins/codegen-plugin/src/it/settings.xml b/maven-plugins/codegen-plugin/src/it/settings.xml
new file mode 100644
index 00000000000..d29dc39671b
--- /dev/null
+++ b/maven-plugins/codegen-plugin/src/it/settings.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<settings>
+ <profiles>
+ <profile>
+ <id>it-repo</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <repositories>
+ <repository>
+ <id>local.central</id>
+ <url>@localRepositoryUrl@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>local.central</id>
+ <url>@localRepositoryUrl@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ <pluginRepository>
+ <id>local.it</id>
+ <url>file://@project.build.directory@/it/repo</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+ </profiles>
+</settings>
diff --git a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
index 03c0a1c00e8..68cc9d76a96 100644
--- a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
+++ b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
@@ -57,6 +57,8 @@
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectUtils;
import org.apache.maven.settings.Proxy;
+import org.apache.maven.toolchain.Toolchain;
+import org.apache.maven.toolchain.ToolchainManager;
import org.codehaus.plexus.archiver.jar.JarArchiver;
import org.codehaus.plexus.archiver.jar.Manifest;
import org.codehaus.plexus.archiver.jar.Manifest.Attribute;
@@ -206,7 +208,7 @@
/**
* Sets the Java executable to use when fork parameter is <code>true</code>.
*
- * @parameter default-value="${java.home}/bin/java"
+ * @parameter
* @since 2.4
*/
private String javaExecutable;
@@ -226,6 +228,12 @@
* @required
*/
private ArtifactRepositoryFactory artifactRepositoryFactory;
+ /**
+ * The toolchain manager.
+ * @component
+ */
+ private ToolchainManager toolchainManager;
+
/**
* The Maven session.
*
@@ -838,17 +846,28 @@ protected void downloadRemoteWsdls(List<GenericWsdlOption> effectiveWsdlOptions)
}
private File getJavaExecutable() throws IOException {
+ if (javaExecutable != null) {
+ getLog().debug("Plugin configuration set the 'javaExecutable' parameter to " + javaExecutable);
+ } else {
+ Toolchain tc = toolchainManager.getToolchainFromBuildContext("jdk", mavenSession);
+ if (tc != null) {
+ getLog().info("Using toolchain " + tc + " to find the java executable");
+ javaExecutable = tc.findTool("java");
+ } else {
+ getLog().debug("The java executable is set to default value");
+ javaExecutable = SystemUtils.getJavaHome() + File.separator + "bin" + File.separator + "java";
+ }
+ }
String exe = SystemUtils.IS_OS_WINDOWS && !javaExecutable.endsWith(".exe") ? ".exe" : "";
File javaExe = new File(javaExecutable + exe);
-
if (!javaExe.isFile()) {
throw new IOException(
"The java executable '"
+ javaExe
+ "' doesn't exist or is not a file."
- + "Verify the <javaExecutable/> parameter.");
+ + "Verify the <javaExecutable/> parameter or toolchain configuration.");
}
-
+ getLog().info("The java executable is " + javaExe.getAbsolutePath());
return javaExe;
}
diff --git a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOptionLoader.java b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOptionLoader.java
index 8628c9a0708..9cee2aeeb42 100644
--- a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOptionLoader.java
+++ b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WsdlOptionLoader.java
@@ -41,9 +41,8 @@
private WsdlOptionLoader() {
}
- public static List<GenericWsdlOption>
- loadWsdlOptionsFromDependencies(MavenProject project,
- File outputDir) {
+ public static List<GenericWsdlOption> loadWsdlOptionsFromDependencies(MavenProject project,
+ File outputDir) {
List<GenericWsdlOption> options = new ArrayList<GenericWsdlOption>();
Set<Artifact> dependencies = CastUtils.cast(project.getDependencyArtifacts());
for (Artifact artifact : dependencies) {
@@ -76,10 +75,10 @@ private static WsdlOption generateWsdlOptionFromArtifact(Artifact artifact, File
* @return list of one WsdlOption object for each wsdl found
* @throws MojoExecutionException
*/
- public static List<GenericWsdlOption>
- loadWsdlOptionsFromFiles(File wsdlBasedir, String includes[],
- String excludes[],
- File defaultOutputDir)
+ public static List<GenericWsdlOption> loadWsdlOptionsFromFiles(File wsdlBasedir,
+ String includes[],
+ String excludes[],
+ File defaultOutputDir)
throws MojoExecutionException {
if (wsdlBasedir == null) {
diff --git a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.java b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.java
index 1ba97e30462..836daa4f6e5 100644
--- a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.java
+++ b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2js/WSDL2JavaScriptMojo.java
@@ -256,10 +256,9 @@ protected void mergeOptions(List<GenericWsdlOption> effectiveWsdlOptions) {
return options;
}
- public static List<GenericWsdlOption>
- loadWsdlOptionsFromDependencies(MavenProject project,
- Option defaultOptions,
- File outputDir) {
+ public static List<GenericWsdlOption> loadWsdlOptionsFromDependencies(MavenProject project,
+ Option defaultOptions,
+ File outputDir) {
List<GenericWsdlOption> options
= new ArrayList<GenericWsdlOption>();
Set<Artifact> dependencies = CastUtils.cast(project.getDependencyArtifacts());
diff --git a/maven-plugins/corba/pom.xml b/maven-plugins/corba/pom.xml
index ef2ccd0e45e..248c8443636 100644
--- a/maven-plugins/corba/pom.xml
+++ b/maven-plugins/corba/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-maven-plugins</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
diff --git a/maven-plugins/java2wadl-plugin/pom.xml b/maven-plugins/java2wadl-plugin/pom.xml
index 22184b372a3..494676331ab 100644
--- a/maven-plugins/java2wadl-plugin/pom.xml
+++ b/maven-plugins/java2wadl-plugin/pom.xml
@@ -22,7 +22,7 @@
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-java2wadl-plugin</artifactId>
<packaging>maven-plugin</packaging>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<name>Apache CXF Java2WADL Maven2 Plugin</name>
<description>Apache CXF Java2WADL Maven2 Plugin</description>
<url>http://cxf.apache.org</url>
@@ -31,7 +31,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-maven-plugins</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.manifest.location />
diff --git a/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/Java2WADLMojo.java b/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/Java2WADLMojo.java
index 58cc578e4b6..63d318c1bfa 100644
--- a/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/Java2WADLMojo.java
+++ b/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/Java2WADLMojo.java
@@ -159,6 +159,11 @@
*/
private boolean checkAbsolutePathSlash;
+ /**
+ * @parameter default-value="false"
+ */
+ private boolean ignoreOverloadedMethods;
+
/**
* @parameter
*/
@@ -179,6 +184,11 @@
*/
private String outputFileExtension;
+ /**
+ * @parameter
+ */
+ private String stylesheetReference;
+
private ClassLoader resourceClassLoader;
public void execute() throws MojoExecutionException {
@@ -210,13 +220,14 @@ private void setExtraProperties(WadlGenerator wg) {
wg.setAddResourceAndMethodIds(addResourceAndMethodIds);
wg.setLinkAnyMediaTypeToXmlSchema(linkAnyMediaTypeToXmlSchema);
wg.setCheckAbsolutePathSlash(checkAbsolutePathSlash);
-
+ wg.setIgnoreOverloadedMethods(ignoreOverloadedMethods);
if (applicationTitle != null) {
wg.setApplicationTitle(applicationTitle);
}
if (namespacePrefix != null) {
wg.setNamespacePrefix(namespacePrefix);
}
+ wg.setStylesheetReference(stylesheetReference);
}
private void generateWadl(List<Class<?>> resourceClasses, String wadl) throws MojoExecutionException {
diff --git a/maven-plugins/java2ws-plugin/pom.xml b/maven-plugins/java2ws-plugin/pom.xml
index 0030a7586ec..9b0b5359073 100644
--- a/maven-plugins/java2ws-plugin/pom.xml
+++ b/maven-plugins/java2ws-plugin/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-maven-plugins</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
diff --git a/maven-plugins/pom.xml b/maven-plugins/pom.xml
index 3d4a50fa025..47e60cf9fbe 100644
--- a/maven-plugins/pom.xml
+++ b/maven-plugins/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<modules>
diff --git a/maven-plugins/wadl2java-plugin/pom.xml b/maven-plugins/wadl2java-plugin/pom.xml
index 313a7c9f3e6..3377fc5e1af 100644
--- a/maven-plugins/wadl2java-plugin/pom.xml
+++ b/maven-plugins/wadl2java-plugin/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-maven-plugins</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
diff --git a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java
index 311a52d0b50..9b06164ce23 100644
--- a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java
+++ b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/AbstractCodeGeneratorMojo.java
@@ -25,6 +25,7 @@
import java.io.PrintWriter;
import java.net.URI;
import java.net.URL;
+import java.net.URLClassLoader;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.LinkedList;
@@ -48,6 +49,7 @@
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.execution.MavenSession;
+import org.apache.maven.model.Resource;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
@@ -89,7 +91,7 @@
MavenProject project;
/**
- * Default options to be used when a wsdl has not had it's options explicitly specified.
+ * Default options to be used when a wadl has not had it's options explicitly specified.
*
* @parameter
*/
@@ -107,7 +109,7 @@
/**
* Use the compile classpath rather than the test classpath for execution useful if the test dependencies
- * clash with those of wsdl2java
+ * clash with those of wadl2java
*
* @parameter expression="${cxf.useCompileClasspath}" default-value="false"
*/
@@ -115,16 +117,16 @@
/**
- * Disables the scanning of the wsdlRoot/testWsdlRoot directories configured above.
- * By default, we scan for *.wsdl (see include/exclude params as well) in the wsdlRoot
- * directories and run wsdl2java on all the wsdl's we find. This disables that scan
- * and requires an explicit wsdlOption to be set for each wsdl that needs to be processed.
+ * Disables the scanning of the wadlRoot/testWadlRoot directories configured above.
+ * By default, we scan for *.wadl (see include/exclude params as well) in the wadlRoot
+ * directories and run wadl2java on all the wadl's we find. This disables that scan
+ * and requires an explicit wadlOption to be set for each wadl that needs to be processed.
* @parameter expression="${cxf.disableDirectoryScan}" default-value="false"
*/
boolean disableDirectoryScan;
/**
- * By default all maven dependencies of type "wsdl" are added to the effective wsdlOptions. Setting this
+ * By default all maven dependencies of type "wadl" are added to the effective wadlOptions. Setting this
* parameter to true disables this functionality
*
* @parameter expression="${cxf.disableDependencyScan}" default-value="false"
@@ -132,15 +134,15 @@
boolean disableDependencyScan;
/**
- * A list of wsdl files to include. Can contain ant-style wildcards and double wildcards. Defaults to
- * *.wsdl
+ * A list of wadl files to include. Can contain ant-style wildcards and double wildcards. Defaults to
+ * *.wadl
*
* @parameter
*/
String includes[];
/**
- * A list of wsdl files to exclude. Can contain ant-style wildcards and double wildcards.
+ * A list of wadl files to exclude. Can contain ant-style wildcards and double wildcards.
*
* @parameter
*/
@@ -234,15 +236,17 @@
*/
private String additionalJvmArgs;
+ private ClassLoader resourceClassLoader;
+
/**
- * Merge WsdlOptions that point to the same file by adding the extraargs to the first option and deleting
+ * Merge WadlOptions that point to the same file by adding the extraargs to the first option and deleting
* the second from the options list
*
* @param options
*/
@SuppressWarnings("unchecked")
- private Artifact resolveRemoteWsdlArtifact(List<?> remoteRepos, Artifact artifact)
+ private Artifact resolveRemoteWadlArtifact(List<?> remoteRepos, Artifact artifact)
throws MojoExecutionException {
/**
@@ -269,7 +273,7 @@ private Artifact resolveRemoteWsdlArtifact(List<?> remoteRepos, Artifact artifac
try {
artifactResolver.resolve(artifact, remoteRepos, localRepository);
} catch (ArtifactResolutionException e) {
- throw new MojoExecutionException("Error downloading wsdl artifact.", e);
+ throw new MojoExecutionException("Error downloading wadl artifact.", e);
} catch (ArtifactNotFoundException e) {
throw new MojoExecutionException("Resource can not be found.", e);
}
@@ -283,21 +287,21 @@ protected void downloadRemoteDocs(List<WadlOption> effectiveOptions) throws Mojo
remoteRepos = ProjectUtils.buildArtifactRepositories(repositories, artifactRepositoryFactory,
mavenSession.getContainer());
} catch (InvalidRepositoryException e) {
- throw new MojoExecutionException("Error build repositories for remote wsdls", e);
+ throw new MojoExecutionException("Error build repositories for remote wadls", e);
}
for (WadlOption option : effectiveOptions) {
- DocumentArtifact wsdlA = option.getWadlArtifact();
- if (wsdlA == null) {
+ DocumentArtifact wadlA = option.getWadlArtifact();
+ if (wadlA == null) {
return;
}
- Artifact wsdlArtifact = artifactFactory.createArtifact(wsdlA.getGroupId(), wsdlA.getArtifactId(),
- wsdlA.getVersion(),
- Artifact.SCOPE_COMPILE, wsdlA.getType());
- wsdlArtifact = resolveRemoteWsdlArtifact(remoteRepos, wsdlArtifact);
- if (wsdlArtifact != null) {
- String path = wsdlArtifact.getFile().getAbsolutePath();
- getLog().info("Resolved WSDL artifact to file " + path);
+ Artifact wadlArtifact = artifactFactory.createArtifact(wadlA.getGroupId(), wadlA.getArtifactId(),
+ wadlA.getVersion(),
+ Artifact.SCOPE_COMPILE, wadlA.getType());
+ wadlArtifact = resolveRemoteWadlArtifact(remoteRepos, wadlArtifact);
+ if (wadlArtifact != null) {
+ String path = wadlArtifact.getFile().getAbsolutePath();
+ getLog().info("Resolved WADL artifact to file " + path);
option.setWadl(path);
}
}
@@ -341,18 +345,19 @@ protected void forkOnce(Set<URI> classPath, List<WadlOption> effectiveOptions)
File outputDirFile = option.getOutputDir();
outputDirFile.mkdirs();
URI basedir = project.getBasedir().toURI();
- URI wadlURI = option.getWadlURI(basedir);
- File doneFile = getDoneFile(basedir, wadlURI);
-
- if (!shouldRun(option, doneFile, wadlURI)) {
- continue;
+ for (URI wadlURI : option.getWadlURIs(basedir, getResourceLoader())) {
+ File doneFile = getDoneFile(basedir, wadlURI);
+
+ if (!shouldRun(option, doneFile, wadlURI)) {
+ continue;
+ }
+ doneFile.delete();
+
+ toDo.add(option);
+
+ wargs.add(option.generateCommandLine(outputDirFile, basedir, wadlURI, getLog()
+ .isDebugEnabled()));
}
- doneFile.delete();
-
- toDo.add(option);
-
- wargs.add(option.generateCommandLine(outputDirFile, basedir, wadlURI, getLog()
- .isDebugEnabled()));
}
if (wargs.isEmpty()) {
return;
@@ -382,13 +387,14 @@ protected void forkOnce(Set<URI> classPath, List<WadlOption> effectiveOptions)
}
}
URI basedir = project.getBasedir().toURI();
- URI wadlURI = option.getWadlURI(basedir);
- File doneFile = getDoneFile(basedir, wadlURI);
- try {
- doneFile.createNewFile();
- } catch (Throwable e) {
- getLog().warn("Could not create marker file " + doneFile.getAbsolutePath());
- getLog().debug(e);
+ for (URI wadlURI : option.getWadlURIs(basedir, getResourceLoader())) {
+ File doneFile = getDoneFile(basedir, wadlURI);
+ try {
+ doneFile.createNewFile();
+ } catch (Throwable e) {
+ getLog().warn("Could not create marker file " + doneFile.getAbsolutePath());
+ getLog().debug(e);
+ }
}
}
}
@@ -411,60 +417,91 @@ protected void forkOnce(Set<URI> classPath, List<WadlOption> effectiveOptions)
}
}
+ private ClassLoader getResourceLoader() throws MojoExecutionException {
+ if (resourceClassLoader == null) {
+ try {
+ List<?> runtimeClasspathElements = project.getRuntimeClasspathElements();
+ List<?> resources = project.getResources();
+ List<?> testResources = project.getTestResources();
+ URL[] runtimeUrls = new URL[runtimeClasspathElements.size() + resources.size() + testResources.size()];
+ for (int i = 0; i < runtimeClasspathElements.size(); i++) {
+ String element = (String)runtimeClasspathElements.get(i);
+ runtimeUrls[i] = new File(element).toURI().toURL();
+ }
+ for (int i = 0, j = runtimeClasspathElements.size(); i < resources.size(); i++, j++) {
+ Resource r = (Resource)resources.get(i);
+ runtimeUrls[j] = new File(r.getDirectory()).toURI().toURL();
+ }
+ for (int i = 0, j = runtimeClasspathElements.size() + resources.size(); i < testResources.size();
+ i++, j++) {
+ Resource r = (Resource)testResources.get(i);
+ runtimeUrls[j] = new File(r.getDirectory()).toURI().toURL();
+ }
+ resourceClassLoader = new URLClassLoader(runtimeUrls, Thread.currentThread()
+ .getContextClassLoader());
+ } catch (Exception e) {
+ throw new MojoExecutionException(e.getMessage(), e);
+ }
+ }
+ return resourceClassLoader;
+ }
+
protected Bus callCodeGenerator(WadlOption option,
Bus bus,
Set<URI> classPath) throws MojoExecutionException {
File outputDirFile = option.getOutputDir();
outputDirFile.mkdirs();
URI basedir = project.getBasedir().toURI();
- URI wadlURI = option.getWadlURI(basedir);
- File doneFile = getDoneFile(basedir, wadlURI);
-
- if (!shouldRun(option, doneFile, wadlURI)) {
- return bus;
- }
- doneFile.delete();
-
- List<String> list = option.generateCommandLine(outputDirFile, basedir, wadlURI, getLog()
- .isDebugEnabled());
- String[] args = list.toArray(new String[list.size()]);
- getLog().debug("Calling wadl2java with args: " + Arrays.toString(args));
- if (!"false".equals(fork)) {
- Set<URI> artifactsPath = new LinkedHashSet<URI>();
- for (Artifact a : pluginArtifacts) {
- File file = a.getFile();
- if (file == null) {
- throw new MojoExecutionException("Unable to find file for artifact "
- + a.getGroupId() + ":" + a.getArtifactId()
- + ":" + a.getVersion());
- }
- artifactsPath.add(file.toURI());
+ for (URI wadlURI : option.getWadlURIs(basedir, getResourceLoader())) {
+ File doneFile = getDoneFile(basedir, wadlURI);
+
+ if (!shouldRun(option, doneFile, wadlURI)) {
+ return bus;
}
- addPluginArtifact(artifactsPath);
- artifactsPath.addAll(classPath);
+ doneFile.delete();
+
+ List<String> list = option.generateCommandLine(outputDirFile, basedir, wadlURI, getLog()
+ .isDebugEnabled());
+ String[] args = list.toArray(new String[list.size()]);
+ getLog().debug("Calling wadl2java with args: " + Arrays.toString(args));
- runForked(artifactsPath, WADLToJava.class, args);
-
- } else {
- if (bus == null) {
- bus = BusFactory.newInstance().createBus();
- BusFactory.setThreadDefaultBus(bus);
+ if (!"false".equals(fork)) {
+ Set<URI> artifactsPath = new LinkedHashSet<URI>();
+ for (Artifact a : pluginArtifacts) {
+ File file = a.getFile();
+ if (file == null) {
+ throw new MojoExecutionException("Unable to find file for artifact "
+ + a.getGroupId() + ":" + a.getArtifactId()
+ + ":" + a.getVersion());
+ }
+ artifactsPath.add(file.toURI());
+ }
+ addPluginArtifact(artifactsPath);
+ artifactsPath.addAll(classPath);
+
+ runForked(artifactsPath, WADLToJava.class, args);
+
+ } else {
+ if (bus == null) {
+ bus = BusFactory.newInstance().createBus();
+ BusFactory.setThreadDefaultBus(bus);
+ }
+ try {
+ new WADLToJava(args).run(new ToolContext());
+ } catch (Throwable e) {
+ getLog().debug(e);
+ throw new MojoExecutionException(e.getMessage(), e);
+ }
}
+
+
try {
- new WADLToJava(args).run(new ToolContext());
+ doneFile.createNewFile();
} catch (Throwable e) {
+ getLog().warn("Could not create marker file " + doneFile.getAbsolutePath());
getLog().debug(e);
- throw new MojoExecutionException(e.getMessage(), e);
- }
- }
-
-
- try {
- doneFile.createNewFile();
- } catch (Throwable e) {
- getLog().warn("Could not create marker file " + doneFile.getAbsolutePath());
- getLog().debug(e);
+ }
}
return bus;
}
@@ -481,7 +518,7 @@ private File getJavaExecutable() throws IOException {
}
private void runForked(Set<URI> classPath, Class<?> cls, String[] args) throws MojoExecutionException {
- getLog().info("Running wsdl2java in fork mode...");
+ getLog().info("Running wadl2java in fork mode...");
Commandline cmd = new Commandline();
cmd.getShell().setQuotedArgumentsEnabled(true); // for JVM args
@@ -565,7 +602,7 @@ private void runForked(Set<URI> classPath, Class<?> cls, String[] args) throws M
if (file != null) {
file.delete();
}
- if (StringUtils.isNotEmpty(err.getOutput()) && err.getOutput().contains("WSDL2Java Error")) {
+ if (StringUtils.isNotEmpty(err.getOutput()) && err.getOutput().contains("WADL2Java Error")) {
StringBuffer msg = new StringBuffer();
msg.append(err.getOutput());
msg.append('\n');
@@ -575,15 +612,15 @@ private void runForked(Set<URI> classPath, Class<?> cls, String[] args) throws M
}
- private File getDoneFile(URI basedir, URI wsdlURI) {
- String doneFileName = wsdlURI.toString();
+ private File getDoneFile(URI basedir, URI wadlURI) {
+ String doneFileName = wadlURI.toString();
// Strip the basedir from the doneFileName
if (doneFileName.startsWith(basedir.toString())) {
doneFileName = doneFileName.substring(basedir.toString().length());
}
- // If URL to WSDL, replace ? and & since they're invalid chars for file names
+ // If URL to WADL, replace ? and & since they're invalid chars for file names
// Not to mention slashes.
doneFileName = doneFileName.replace('?', '_').replace('&', '_').replace('/', '_').replace('\\', '_')
.replace(':', '_');
@@ -592,20 +629,20 @@ private File getDoneFile(URI basedir, URI wsdlURI) {
}
/**
- * Determine if code should be generated from the given wsdl
+ * Determine if code should be generated from the given wadl
*
- * @param wsdlOption
+ * @param wadlOption
* @param doneFile
- * @param wsdlURI
+ * @param wadlURI
* @return
*/
- private boolean shouldRun(WadlOption wsdlOption, File doneFile, URI wsdlURI) {
+ private boolean shouldRun(WadlOption wadlOption, File doneFile, URI wadlURI) {
long timestamp = 0;
- if ("file".equals(wsdlURI.getScheme())) {
- timestamp = new File(wsdlURI).lastModified();
+ if ("file".equals(wadlURI.getScheme())) {
+ timestamp = new File(wadlURI).lastModified();
} else {
try {
- timestamp = wsdlURI.toURL().openConnection().getDate();
+ timestamp = wadlURI.toURL().openConnection().getDate();
} catch (Exception e) {
// ignore
}
@@ -616,7 +653,7 @@ private boolean shouldRun(WadlOption wsdlOption, File doneFile, URI wsdlURI) {
} else if (timestamp > doneFile.lastModified()) {
doWork = true;
} else {
- File files[] = wsdlOption.getDependencies();
+ File files[] = wadlOption.getDependencies();
if (files != null) {
for (int z = 0; z < files.length; ++z) {
if (files[z].lastModified() > doneFile.lastModified()) {
diff --git a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java
index 9dbe432cbd8..c94e7afb418 100644
--- a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java
+++ b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/OptionLoader.java
@@ -35,6 +35,7 @@
public final class OptionLoader {
private static final String WADL_TYPE = "wadl";
+ private static final String WADL_OPTIONS = "-options$";
private static final String WADL_BINDINGS = "-binding-?\\d*.xml$";
private OptionLoader() {
@@ -73,39 +74,41 @@ private static WadlOption generateWsdlOptionFromArtifact(Artifact artifact, File
}
/**
- * Scan files in a directory and generate one wsdlOption per file found. Extra args for code generation
- * can be defined in a file that is named like the wsdl file and ends in -options. Binding files can be
- * defined in files named like the wsdl file and end in -binding-*.xml
+ * Scan files in a directory and generate one wadlOption per file found. Extra args for code generation
+ * can be defined in a file that is named like the wadl file and ends in -options. Binding files can be
+ * defined in files named like the wadl file and end in -binding-*.xml
*
- * @param wsdlBasedir
+ * @param wadlBasedir
* @param includes file name patterns to include
* @param excludes file name patterns to exclude
* @param defaultOptions options that should be used if no special file is given
- * @return list of one WsdlOption object for each wsdl found
+ * @return list of one WadlOption object for each wadl found
* @throws MojoExecutionException
*/
- public static List<WadlOption> loadWsdlOptionsFromFiles(File wsdlBasedir, String includes[],
- String excludes[], Option defaultOptions,
+ public static List<WadlOption> loadWadlOptionsFromFile(File wadlBasedir,
+ String includes[],
+ String excludes[],
+ Option defaultOptions,
File defaultOutputDir)
throws MojoExecutionException {
- if (wsdlBasedir == null) {
+ if (wadlBasedir == null) {
return new ArrayList<WadlOption>();
}
- if (!wsdlBasedir.exists()) {
- throw new MojoExecutionException(wsdlBasedir + " does not exist");
+ if (!wadlBasedir.exists()) {
+ throw new MojoExecutionException(wadlBasedir + " does not exist");
}
- List<File> wsdlFiles = getWsdlFiles(wsdlBasedir, includes, excludes);
- List<WadlOption> wsdlOptions = new ArrayList<WadlOption>();
- for (File wsdl : wsdlFiles) {
- WadlOption wsdlOption = generateWsdlOptionFromFile(wsdl, defaultOptions, defaultOutputDir);
- if (wsdlOption != null) {
- wsdlOptions.add(wsdlOption);
+ List<File> wadlFiles = getWadlFiles(wadlBasedir, includes, excludes);
+ List<WadlOption> wadlOptions = new ArrayList<WadlOption>();
+ for (File wadl : wadlFiles) {
+ WadlOption wadlOption = generateWadlOptionFromFile(wadl, defaultOptions, defaultOutputDir);
+ if (wadlOption != null) {
+ wadlOptions.add(wadlOption);
}
}
- return wsdlOptions;
+ return wadlOptions;
}
private static String joinWithComma(String[] arr) {
@@ -123,7 +126,7 @@ private static String joinWithComma(String[] arr) {
return str.toString();
}
- private static List<File> getWsdlFiles(File dir, String includes[], String excludes[])
+ private static List<File> getWadlFiles(File dir, String includes[], String excludes[])
throws MojoExecutionException {
List<String> exList = new ArrayList<String>();
@@ -144,7 +147,8 @@ private static String joinWithComma(String[] arr) {
}
- protected static WadlOption generateWsdlOptionFromFile(final File wadl, final Option defaultOptions,
+ protected static WadlOption generateWadlOptionFromFile(final File wadl,
+ final Option defaultOptions,
File defaultOutputDir)
throws MojoExecutionException {
@@ -161,21 +165,53 @@ protected static WadlOption generateWsdlOptionFromFile(final File wadl, final Op
return null;
}
- final WadlOption wsdlOption = new WadlOption();
+ final WadlOption wadlOption = new WadlOption();
+ if (defaultOptions != null) {
+ wadlOption.merge(defaultOptions);
+ }
+
+
final String wadlName = wadlFileName.substring(0, idx);
+ final String[] options = readOptionsFromFile(wadl.getParentFile(), wadlName);
+ if (options.length > 0) {
+ wadlOption.getExtraargs().addAll(Arrays.asList(options));
+ }
+
List<File> bindingFiles = FileUtils.getFiles(wadl.getParentFile(), wadlName + WADL_BINDINGS);
if (bindingFiles != null) {
for (File binding : bindingFiles) {
- wsdlOption.addBindingFile(binding);
+ wadlOption.addBindingFile(binding);
}
}
- wsdlOption.setWadl(wadl.toURI().toString());
-
- if (wsdlOption.getOutputDir() == null) {
- wsdlOption.setOutputDir(defaultOutputDir);
+ wadlOption.setWadl(wadl.toURI().toString());
+
+ if (wadlOption.getOutputDir() == null) {
+ wadlOption.setOutputDir(defaultOutputDir);
}
- return wsdlOption;
+ return wadlOption;
+ }
+
+ private static String[] readOptionsFromFile(File dir, String wsdlName) throws MojoExecutionException {
+ String[] noOptions = new String[] {};
+ List<File> files = FileUtils.getFiles(dir, wsdlName + WADL_OPTIONS);
+ if (files.size() <= 0) {
+ return noOptions;
+ }
+ File optionsFile = files.iterator().next();
+ if (optionsFile == null || !optionsFile.exists()) {
+ return noOptions;
+ }
+ try {
+ List<String> lines = FileUtils.readLines(optionsFile);
+ if (lines.size() <= 0) {
+ return noOptions;
+ }
+ return lines.iterator().next().split(" ");
+ } catch (Exception e) {
+ throw new MojoExecutionException("Error reading options from file "
+ + optionsFile.getAbsolutePath(), e);
+ }
}
}
diff --git a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java
index c4b536aef6e..071135cdb26 100644
--- a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java
+++ b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WADL2JavaMojo.java
@@ -71,16 +71,11 @@ private void mergeOptions(List<WadlOption> effectiveOptions) {
}
public void execute() throws MojoExecutionException {
- if (includes == null) {
- includes = new String[] {
- "*.wadl"
- };
- }
File classesDir = new File(classesDirectory);
classesDir.mkdirs();
markerDirectory.mkdirs();
- List<WadlOption> effectiveWsdlOptions = createWsdlOptionsFromScansAndExplicitWsdlOptions();
+ List<WadlOption> effectiveWsdlOptions = createWadlOptionsFromScansAndExplicitWadlOptions(classesDir);
if (effectiveWsdlOptions.size() == 0) {
getLog().info("Nothing to generate");
@@ -129,12 +124,25 @@ public void execute() throws MojoExecutionException {
* @return effective WsdlOptions
* @throws MojoExecutionException
*/
- private List<WadlOption> createWsdlOptionsFromScansAndExplicitWsdlOptions()
+ private List<WadlOption> createWadlOptionsFromScansAndExplicitWadlOptions(File classesDir)
throws MojoExecutionException {
List<WadlOption> effectiveOptions = new ArrayList<WadlOption>();
-
mergeOptions(effectiveOptions);
downloadRemoteDocs(effectiveOptions);
+ if (effectiveOptions.isEmpty()) {
+ if (includes == null) {
+ includes = new String[] {
+ "*.wadl"
+ };
+ }
+ File defaultRoot = wadlRoot != null && wadlRoot.exists() ? wadlRoot : testWadlRoot;
+ effectiveOptions.addAll(
+ OptionLoader.loadWadlOptionsFromFile(defaultRoot,
+ includes,
+ excludes,
+ defaultOptions,
+ classesDir));
+ }
return effectiveOptions;
}
diff --git a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WadlOption.java b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WadlOption.java
index b707bf667a4..85989e2ce39 100644
--- a/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WadlOption.java
+++ b/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/wadlto/WadlOption.java
@@ -21,9 +21,13 @@
import java.io.File;
import java.net.URI;
+import java.net.URL;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
import java.util.List;
+import org.apache.cxf.common.util.ClasspathScanner;
import org.apache.cxf.common.util.URIParserUtil;
import org.apache.cxf.maven_plugin.common.DocumentArtifact;
@@ -34,11 +38,17 @@
*/
String wadl;
+ String wadlFileExtension = "wadl";
+
/**
- * Alternatively to the wsdl string an artifact can be specified
+ * Alternatively to the wadl string an artifact can be specified
*/
DocumentArtifact wadlArtifact;
+ public WadlOption() {
+ super();
+ }
+
public String getWadl() {
return wadl;
}
@@ -83,8 +93,23 @@ public File getDocumentFile(File baseDir) {
return file;
}
- public URI getWadlURI(URI baseURI) {
+ public List<URI> getWadlURIs(URI baseURI, ClassLoader resourceLoader) {
String wadlLocation = getWadl();
+ if (wadlLocation.contains(".") && !wadlLocation.contains("*")) {
+ return Collections.singletonList(getWadlURI(baseURI, wadlLocation));
+ }
+ List<URI> uris = new LinkedList<URI>();
+ try {
+ for (URL nextLocation : ClasspathScanner.findResources(wadlLocation, wadlFileExtension, resourceLoader)) {
+ uris.add(getWadlURI(baseURI, nextLocation.toURI().getPath()));
+ }
+ } catch (Exception ex) {
+ // ignore
+ }
+ return uris;
+ }
+
+ private URI getWadlURI(URI baseURI, String wadlLocation) {
File wadlFile = new File(wadlLocation);
return wadlFile.exists() ? wadlFile.toURI()
: baseURI.resolve(URIParserUtil.escapeChars(wadlLocation));
@@ -115,7 +140,7 @@ public String toString() {
return builder.toString();
}
- public List<String> generateCommandLine(File outputDirFile, URI basedir, URI wsdlURI, boolean debug) {
+ public List<String> generateCommandLine(File outputDirFile, URI basedir, URI wadlURI, boolean debug) {
List<String> list = new ArrayList<String>();
addIfNotNull(list, outputDirFile, "-d");
for (String binding : getBindingFiles()) {
@@ -131,7 +156,7 @@ public String toString() {
addIfTrue(list, isImpl(), "-impl");
addIfTrue(list, isInterface(), "-interface");
addList(list, "", false, getExtraargs());
- list.add(wsdlURI.toString());
+ list.add(wadlURI.toString());
return list;
}
@@ -167,4 +192,12 @@ private static void addIfTrue(List<String> list, boolean expression, String key)
list.add(key);
}
}
+
+ public String getWadlFileExtension() {
+ return wadlFileExtension;
+ }
+
+ public void setWadlFileExtension(String wadlFileExtension) {
+ this.wadlFileExtension = wadlFileExtension;
+ }
}
diff --git a/maven-plugins/wsdl-validator-plugin/pom.xml b/maven-plugins/wsdl-validator-plugin/pom.xml
index 96fae24f87b..8fea071320e 100644
--- a/maven-plugins/wsdl-validator-plugin/pom.xml
+++ b/maven-plugins/wsdl-validator-plugin/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-maven-plugins</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
diff --git a/osgi/bundle/compatible/pom.xml b/osgi/bundle/compatible/pom.xml
index 9e10180efbc..d6208f7e800 100644
--- a/osgi/bundle/compatible/pom.xml
+++ b/osgi/bundle/compatible/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<properties>
<cxf.osgi.symbolic.name>${project.groupId}.bundle</cxf.osgi.symbolic.name>
@@ -195,7 +195,6 @@
<Import-Package>
org.apache.cxf.*,
META-INF.cxf,
- META-INF.cxf.osgi,
antlr*;resolution:=optional,
com.sun*;resolution:=optional,
com.ctc.wstx.msv*;resolution:=optional,
diff --git a/osgi/bundle/pom.xml b/osgi/bundle/pom.xml
index bd75f204863..3fbc6d744bd 100644
--- a/osgi/bundle/pom.xml
+++ b/osgi/bundle/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../parent</relativePath>
</parent>
<properties>
diff --git a/osgi/itests-felix/pom.xml b/osgi/itests-felix/pom.xml
index 9f39608220b..4884de25465 100644
--- a/osgi/itests-felix/pom.xml
+++ b/osgi/itests-felix/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
<groupId>org.apache.cxf.osgi.itests</groupId>
@@ -29,7 +29,6 @@
<name>Apache CXF :: OSGi :: Integration Tests pure felix</name>
<packaging>jar</packaging>
<properties>
- <pax.exam.version>3.4.0</pax.exam.version>
<pax.url.version>1.2.8</pax.url.version>
</properties>
<dependencies>
@@ -72,6 +71,10 @@
<artifactId>cxf-rt-bindings-soap</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-servlet_3.0_spec</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
@@ -91,19 +94,19 @@
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-native</artifactId>
- <version>${pax.exam.version}</version>
+ <version>${cxf.pax.exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit4</artifactId>
- <version>${pax.exam.version}</version>
+ <version>${cxf.pax.exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-link-mvn</artifactId>
- <version>${pax.exam.version}</version>
+ <version>${cxf.pax.exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -112,17 +115,25 @@
<version>1.6.0</version>
<scope>test</scope>
</dependency>
-
+
+ <!--Updated the felix and osgi version to support JDK8 -->
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
- <version>3.2.2</version>
+ <version>4.4.0</version>
<scope>test</scope>
</dependency>
-
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.3.0</version>
+ </dependency>
+
<dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>4.3.0</version>
</dependency>
<dependency>
diff --git a/osgi/itests-felix/src/test/java/org/apache/cxf/osgi/itests/NoAriesBlueprintTest.java b/osgi/itests-felix/src/test/java/org/apache/cxf/osgi/itests/NoAriesBlueprintTest.java
index 58f5e2202fb..de3ed846436 100644
--- a/osgi/itests-felix/src/test/java/org/apache/cxf/osgi/itests/NoAriesBlueprintTest.java
+++ b/osgi/itests-felix/src/test/java/org/apache/cxf/osgi/itests/NoAriesBlueprintTest.java
@@ -18,9 +18,9 @@
*/
package org.apache.cxf.osgi.itests;
+
import org.junit.Test;
import org.junit.runner.RunWith;
-
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
@@ -28,8 +28,9 @@
import org.ops4j.pax.exam.spi.reactors.PerClass;
import static org.ops4j.pax.exam.CoreOptions.junitBundles;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.when;
+
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
@@ -48,21 +49,26 @@ public void testCXFBundles() throws Exception {
@Configuration
public Option[] config() {
+ String localRepo = System.getProperty("localRepository");
+ if (localRepo == null) {
+ localRepo = "";
+ }
+
return new Option[]{
systemProperty("java.awt.headless").value("true"),
- systemProperty("org.ops4j.pax.url.mvn.localRepository")
- .value(System.getProperty("localRepository")),
- mavenBundle().groupId("org.apache.ws.xmlschema").artifactId("xmlschema-core").versionAsInProject(),
- mavenBundle().groupId("org.apache.cxf").artifactId("cxf-core").versionAsInProject(),
- mavenBundle().groupId("org.apache.servicemix.bundles")
- .artifactId("org.apache.servicemix.bundles.wsdl4j").versionAsInProject(),
- mavenBundle().groupId("org.apache.cxf").artifactId("cxf-rt-wsdl").versionAsInProject(),
- mavenBundle().groupId("org.apache.cxf").artifactId("cxf-rt-databinding-jaxb").versionAsInProject(),
- mavenBundle().groupId("org.apache.cxf").artifactId("cxf-rt-bindings-xml").versionAsInProject(),
- mavenBundle().groupId("org.apache.cxf").artifactId("cxf-rt-bindings-soap").versionAsInProject(),
- mavenBundle().groupId("org.apache.cxf").artifactId("cxf-rt-frontend-simple").versionAsInProject(),
- mavenBundle().groupId("org.apache.cxf").artifactId("cxf-rt-transports-http").versionAsInProject(),
- mavenBundle().groupId("org.apache.cxf").artifactId("cxf-rt-frontend-jaxws").versionAsInProject(),
+ when(!"".equals(localRepo))
+ .useOptions(systemProperty("org.ops4j.pax.url.mvn.localRepository").value(localRepo)),
+ mvnBundle("org.apache.ws.xmlschema", "xmlschema-core"),
+ mvnBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.wsdl4j"),
+ mvnBundle("org.apache.cxf", "cxf-core"),
+ mvnBundle("org.apache.cxf", "cxf-rt-wsdl"),
+ mvnBundle("org.apache.cxf", "cxf-rt-databinding-jaxb"),
+ mvnBundle("org.apache.cxf", "cxf-rt-bindings-xml"),
+ mvnBundle("org.apache.cxf", "cxf-rt-bindings-soap"),
+ mvnBundle("org.apache.cxf", "cxf-rt-frontend-simple"),
+ mvnBundle("org.apache.geronimo.specs", "geronimo-servlet_3.0_spec"),
+ mvnBundle("org.apache.cxf", "cxf-rt-transports-http"),
+ mvnBundle("org.apache.cxf", "cxf-rt-frontend-jaxws"),
junitBundles()
};
}
diff --git a/osgi/itests-felix/src/test/java/org/apache/cxf/osgi/itests/OSGiTestSupport.java b/osgi/itests-felix/src/test/java/org/apache/cxf/osgi/itests/OSGiTestSupport.java
index 933348a82ff..5d842ff73df 100644
--- a/osgi/itests-felix/src/test/java/org/apache/cxf/osgi/itests/OSGiTestSupport.java
+++ b/osgi/itests-felix/src/test/java/org/apache/cxf/osgi/itests/OSGiTestSupport.java
@@ -23,6 +23,8 @@
import javax.inject.Inject;
import org.junit.Assert;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -49,4 +51,7 @@ protected Bundle findBundleByName(String symbolicName) {
return null;
}
+ public MavenArtifactProvisionOption mvnBundle(String groupId, String artifactId) {
+ return CoreOptions.mavenBundle().groupId(groupId).artifactId(artifactId).versionAsInProject();
+ }
}
diff --git a/osgi/itests/pom.xml b/osgi/itests/pom.xml
index 338e95beb9b..2757c53810a 100644
--- a/osgi/itests/pom.xml
+++ b/osgi/itests/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
<groupId>org.apache.cxf.osgi.itests</groupId>
@@ -29,7 +29,6 @@
<name>Apache CXF :: OSGi :: Integration Tests</name>
<packaging>jar</packaging>
<properties>
- <pax.exam.version>3.4.0</pax.exam.version>
<cxf.surefire.fork.mode>once</cxf.surefire.fork.mode>
</properties>
<dependencies>
@@ -44,6 +43,11 @@
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-testutils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-jms</artifactId>
@@ -61,8 +65,8 @@
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-karaf</artifactId>
- <version>5.9.1</version>
<type>xml</type>
+ <version>${cxf.activemq.version}</version>
<classifier>features</classifier>
</dependency>
@@ -100,28 +104,28 @@
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit4</artifactId>
- <version>${pax.exam.version}</version>
+ <version>${cxf.pax.exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam</artifactId>
- <version>${pax.exam.version}</version>
+ <version>${cxf.pax.exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-karaf</artifactId>
- <version>${pax.exam.version}</version>
+ <version>${cxf.pax.exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-link-mvn</artifactId>
- <version>${pax.exam.version}</version>
+ <version>${cxf.pax.exam.version}</version>
<scope>test</scope>
</dependency>
@@ -129,7 +133,36 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
-
+
+ <dependency>
+ <groupId>org.apache.karaf</groupId>
+ <artifactId>apache-karaf</artifactId>
+ <version>${cxf.karaf.version}</version>
+ <type>tar.gz</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.dev</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.karaf</groupId>
+ <artifactId>org.apache.karaf.client</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.framework</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
<build>
<plugins>
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
index 468f4cb42a1..94fbf6d9a6a 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/CXFOSGiTestSupport.java
@@ -24,6 +24,7 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.io.PrintStream;
import java.net.DatagramSocket;
import java.net.ServerSocket;
@@ -32,6 +33,7 @@
import java.util.Collections;
import java.util.Dictionary;
import java.util.Enumeration;
+import java.util.Properties;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -43,7 +45,9 @@
import org.apache.felix.service.command.CommandProcessor;
import org.apache.felix.service.command.CommandSession;
import org.apache.karaf.features.FeaturesService;
+
import org.junit.Assert;
+
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.ProbeBuilder;
import org.ops4j.pax.exam.TestProbeBuilder;
@@ -59,6 +63,7 @@
import static org.ops4j.pax.exam.CoreOptions.composite;
import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
import static org.ops4j.pax.exam.CoreOptions.when;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
@@ -69,7 +74,6 @@
*
*/
public class CXFOSGiTestSupport {
- static final String KARAF_VERSION = "2.3.5";
static final Long COMMAND_TIMEOUT = 10000L;
static final Long DEFAULT_TIMEOUT = 20000L;
static final Long SERVICE_TIMEOUT = 30000L;
@@ -95,31 +99,66 @@ public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) {
return probe;
}
+ private static String getKarafVersion() {
+ InputStream ins = CXFOSGiTestSupport.class.getResourceAsStream("/META-INF/maven/dependencies.properties");
+ Properties p = new Properties();
+ try {
+ p.load(ins);
+ } catch (Throwable t) {
+ //
+ }
+ String karafVersion = p.getProperty("org.apache.karaf/apache-karaf/version");
+ if (karafVersion == null) {
+ karafVersion = System.getProperty("cxf.karaf.version");
+ }
+ if (karafVersion == null) {
+ karafVersion = System.getProperty("karaf.version");
+ }
+ if (karafVersion == null) {
+ // setup the default version of it
+ karafVersion = "2.3.6";
+ }
+ return karafVersion;
+ }
/**
* Create an {@link org.ops4j.pax.exam.Option} for using a .
*
* @return
*/
- protected Option cxfBaseConfig() {
- karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf").version(KARAF_VERSION)
+ protected Option cxfBaseConfig(boolean testUtils) {
+ karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf").version(getKarafVersion())
.type("tar.gz");
cxfUrl = maven().groupId("org.apache.cxf.karaf").artifactId("apache-cxf").versionAsInProject()
.type("xml").classifier("features");
String localRepo = System.getProperty("localRepository");
+ Object urp = System.getProperty("cxf.useRandomFirstPort");
return composite(karafDistributionConfiguration()
.frameworkUrl(karafUrl)
- .karafVersion(KARAF_VERSION)
+ .karafVersion(getKarafVersion())
.name("Apache Karaf")
.useDeployFolder(false)
.unpackDirectory(new File("target/paxexam/")),
+ //DO NOT COMMIT WITH THIS LINE ENABLED!!!
+ //org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder(),
features(cxfUrl, "cxf-core", "cxf-jaxws"),
systemProperty("java.awt.headless").value("true"),
+ when(testUtils).useOptions(mavenBundle()
+ .groupId("org.apache.cxf")
+ .artifactId("cxf-testutils")
+ .versionAsInProject()),
when(localRepo != null)
.useOptions(editConfigurationFilePut("etc/org.ops4j.pax.url.mvn.cfg",
"org.ops4j.pax.url.mvn.localRepository",
- localRepo)));
+ localRepo)),
+ when(urp != null).useOptions(systemProperty("cxf.useRandomFirstPort").value("true")));
}
-
+ protected Option cxfBaseConfig() {
+ return cxfBaseConfig(false);
+ }
+ protected Option cxfBaseConfigWithTestUtils() {
+ return cxfBaseConfig(true);
+ }
+
/**
* Executes a shell command and returns output as a String. Commands have a default timeout of 10 seconds.
*
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java
index 8420a6aa2c9..731a40d8f00 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpServiceTest.java
@@ -22,9 +22,11 @@
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.osgi.itests.CXFOSGiTestSupport;
+
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
+
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
@@ -33,6 +35,7 @@
import org.ops4j.pax.exam.spi.reactors.PerClass;
import org.ops4j.pax.tinybundles.core.TinyBundles;
import org.osgi.framework.Constants;
+
import static org.ops4j.pax.exam.CoreOptions.provision;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
@@ -43,24 +46,30 @@
@Test
public void testHttpEndpoint() throws Exception {
- Greeter greeter = greeterHttp();
+ Greeter greeter = greeterHttp("8181");
+ String res = greeter.greetMe("Chris");
+ Assert.assertEquals("Hi Chris", res);
+ }
+ @Test
+ public void testHttpEndpointJetty() throws Exception {
+ Greeter greeter = greeterHttp(HttpTestActivator.PORT);
String res = greeter.greetMe("Chris");
Assert.assertEquals("Hi Chris", res);
}
- private Greeter greeterHttp() {
+ private Greeter greeterHttp(String port) {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(Greeter.class);
- factory.setAddress("http://localhost:8181/cxf/greeter");
+ factory.setAddress("http://localhost:" + port + "/cxf/greeter");
return factory.create(Greeter.class);
}
@Configuration
public Option[] config() {
return new Option[] {
- cxfBaseConfig(),
+ cxfBaseConfigWithTestUtils(),
logLevel(LogLevel.INFO),
- features(cxfUrl, "cxf-http"),
+ features(cxfUrl, "cxf-http", "cxf-http-jetty"),
provision(serviceBundle())
};
}
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpTestActivator.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpTestActivator.java
index 5082508ed8b..6fa72260aec 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpTestActivator.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/HttpTestActivator.java
@@ -20,12 +20,14 @@
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.testutil.common.TestUtil;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class HttpTestActivator implements BundleActivator {
-
+ public static final String PORT = TestUtil.getPortNumber(HttpTestActivator.class);
private Server server;
+ private Server serverJetty;
@Override
public void start(BundleContext arg0) throws Exception {
@@ -34,11 +36,20 @@ public void start(BundleContext arg0) throws Exception {
factory.setAddress("/greeter");
factory.setServiceBean(new GreeterImpl());
server = factory.create();
+
+ factory = new JaxWsServerFactoryBean();
+ factory.setServiceClass(Greeter.class);
+ factory.setAddress("http://localhost:" + PORT + "/cxf/greeter");
+ factory.setServiceBean(new GreeterImpl());
+ serverJetty = factory.create();
}
@Override
public void stop(BundleContext arg0) throws Exception {
+ server.stop();
server.destroy();
+ serverJetty.stop();
+ serverJetty.destroy();
}
}
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java
index 797f89ecffb..0916b1cd2b6 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsServiceTest.java
@@ -23,7 +23,7 @@
import javax.jms.ConnectionFactory;
-import org.apache.activemq.spring.ActiveMQConnectionFactory;
+import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.osgi.itests.CXFOSGiTestSupport;
import org.apache.cxf.transport.jms.ConnectionFactoryFeature;
@@ -65,7 +65,8 @@ private Greeter greeterJms() {
}
private ActiveMQConnectionFactory createConnectionFactory() {
- ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
+ ActiveMQConnectionFactory connectionFactory
+ = new ActiveMQConnectionFactory("vm://JmsServiceTest");
connectionFactory.setUserName("karaf");
connectionFactory.setPassword("karaf");
return connectionFactory;
@@ -76,8 +77,8 @@ private ActiveMQConnectionFactory createConnectionFactory() {
MavenUrlReference activeMQFeature = maven().groupId("org.apache.activemq")
.artifactId("activemq-karaf").type("xml").classifier("features").versionAsInProject();
return new Option[] {
- cxfBaseConfig(),
- logLevel(LogLevel.INFO),
+ cxfBaseConfigWithTestUtils(),
+ logLevel(LogLevel.WARN),
features(activeMQFeature, "activemq-broker-noweb"),
features(cxfUrl, "cxf-transports-jms"),
provision(serviceBundle())
diff --git a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsTestActivator.java b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsTestActivator.java
index f1d3f4c305b..213b623e3fe 100644
--- a/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsTestActivator.java
+++ b/osgi/itests/src/test/java/org/apache/cxf/osgi/itests/soap/JmsTestActivator.java
@@ -22,14 +22,16 @@
import javax.jms.ConnectionFactory;
-import org.apache.activemq.spring.ActiveMQConnectionFactory;
+import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.testutil.common.TestUtil;
import org.apache.cxf.transport.jms.ConnectionFactoryFeature;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class JmsTestActivator implements BundleActivator {
+ public static final String PORT = TestUtil.getPortNumber(JmsTestActivator.class);
private Server server;
@Override
@@ -48,7 +50,8 @@ private Server publishService(ConnectionFactory connectionFactory) {
}
private ActiveMQConnectionFactory createConnectionFactory() {
- ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
+ ActiveMQConnectionFactory connectionFactory
+ = new ActiveMQConnectionFactory("vm://JmsServiceTest");
connectionFactory.setUserName("karaf");
connectionFactory.setPassword("karaf");
return connectionFactory;
diff --git a/osgi/karaf/commands/pom.xml b/osgi/karaf/commands/pom.xml
index e6cc5dcf451..58cc60c744c 100644
--- a/osgi/karaf/commands/pom.xml
+++ b/osgi/karaf/commands/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.cxf.karaf</groupId>
<artifactId>karaf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<artifactId>cxf-karaf-commands</artifactId>
<packaging>bundle</packaging>
@@ -56,10 +56,9 @@
<instructions>
<Import-Package>
!org.apache.cxf.karaf.commands,
- org.apache.felix.service.command;version="[0.6,1)",
- org.apache.felix.gogo.commands;version="[0.6,1)",
org.apache.cxf*;version="[3,4)",
- org.apache.karaf.shell.console;version="[2.2,4)",
+ org.apache.karaf.shell*;version="[2.3,5)",
+ org.apache.felix.gogo.commands*;version="[0.6,1)",
*
</Import-Package>
<_nouses>true</_nouses>
diff --git a/osgi/karaf/features/pom.xml b/osgi/karaf/features/pom.xml
index fb3ec3f2fd7..fbae9292873 100644
--- a/osgi/karaf/features/pom.xml
+++ b/osgi/karaf/features/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.cxf.karaf</groupId>
<artifactId>karaf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<artifactId>apache-cxf</artifactId>
<packaging>pom</packaging>
diff --git a/osgi/karaf/features/src/main/resources/features.xml b/osgi/karaf/features/src/main/resources/features.xml
index ccc20614c5a..ec5a9496471 100644
--- a/osgi/karaf/features/src/main/resources/features.xml
+++ b/osgi/karaf/features/src/main/resources/features.xml
@@ -57,6 +57,7 @@
<bundle start-level="25" dependency="true">mvn:commons-codec/commons-codec/${cxf.commons-codec.version}</bundle>
<bundle start-level="25" dependency="true">mvn:org.apache.santuario/xmlsec/${cxf.xmlsec.bundle.version}</bundle>
<bundle start-level="25" dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.opensaml/${cxf.opensaml.osgi.version}</bundle>
+ <bundle start-level="25">mvn:org.jvnet.staxex/stax-ex/${cxf.stax-ex.version}</bundle>
<bundle start-level="25">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.saaj-impl/${cxf.saaj-impl.bundle.version}</bundle>
<bundle start-level="25">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xmlresolver/${cxf.xmlresolver.bundle.version}</bundle>
<bundle start-level="30" dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xerces/${cxf.xerces.bundle.version}</bundle>
@@ -124,7 +125,7 @@
</feature>
<feature name="cxf-http" version="${project.version}" resolver="(obr)">
<feature version="${project.version}">cxf-core</feature>
- <feature version="[2,4)">http-whiteboard</feature>
+ <feature version="[2,5)">http-whiteboard</feature>
<bundle start-level="40">mvn:org.apache.cxf/cxf-rt-transports-http/${project.version}</bundle>
</feature>
<feature name="cxf-http-jetty" version="${project.version}" resolver="(obr)">
@@ -184,7 +185,7 @@
</feature>
<feature name="cxf-rs-security-xml" version="${project.version}" resolver="(obr)">
<feature version="${project.version}">cxf-jaxrs</feature>
- <feature version="${cxf.wss4j.version}">wss4j</feature>
+ <feature version="${project.version}">cxf-rt-security</feature>
<bundle start-level="40">mvn:org.apache.cxf/cxf-rt-rs-security-xml/${project.version}</bundle>
</feature>
<feature name="cxf-rs-security-sso-saml" version="${project.version}" resolver="(obr)">
@@ -200,8 +201,13 @@
<bundle start-level="30" dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.oauth-provider/${cxf.oauth.bundle.version}</bundle>
<bundle start-level="40">mvn:org.apache.cxf/cxf-rt-rs-security-oauth/${project.version}</bundle>
</feature>
- <feature name="cxf-rs-security-oauth2" version="${project.version}" resolver="(obr)">
+ <feature name="cxf-rs-security-jose" version="${project.version}" resolver="(obr)">
<feature version="${project.version}">cxf-jaxrs</feature>
+ <feature version="${project.version}">cxf-rt-security</feature>
+ <bundle start-level="40">mvn:org.apache.cxf/cxf-rt-rs-security-jose/${project.version}</bundle>
+ </feature>
+ <feature name="cxf-rs-security-oauth2" version="${project.version}" resolver="(obr)">
+ <feature version="${project.version}">cxf-rs-security-jose</feature>
<bundle start-level="40">mvn:org.apache.cxf/cxf-rt-rs-security-oauth2/${project.version}</bundle>
</feature>
<feature name="cxf-databinding-aegis" version="${project.version}" resolver="(obr)">
@@ -272,6 +278,7 @@
</feature>
<feature name="cxf-transports-websocket-server" version="${project.version}" resolver="(obr)">
<feature version="[3,4)">cxf-http</feature>
+ <bundle dependency='true'>mvn:org.atmosphere/atmosphere-runtime/${cxf.atmosphere.version}</bundle>
<bundle start-level="40">mvn:org.apache.cxf/cxf-rt-transports-websocket/${project.version}</bundle>
</feature>
<feature name="cxf-javascript" version="${project.version}" resolver="(obr)">
@@ -364,6 +371,8 @@
cxf.wsn.activemq = vm:localhost
cxf.wsn.rootUrl = http://0.0.0.0:8182
cxf.wsn.context = /wsn
+ cxf.wsn.activemq.username = karaf
+ cxf.wsn.activemq.password = karaf
</config>
<feature version="[5.4,6)">activemq</feature>
<feature version="${project.version}">cxf-wsn-api</feature>
@@ -394,8 +403,19 @@
<feature name="cxf-bean-validation-java6" version="${project.version}" resolver="(obr)">
<feature version="${project.version}">cxf-bean-validation-core</feature>
- <bundle start-level="30" dependency="true">mvn:javax.el/javax.el-api/3.0-b2</bundle>
- <bundle start-level="30" dependency="true">mvn:org.glassfish/javax.el/3.0-b1</bundle>
+ <bundle start-level="30" dependency="true">mvn:javax.el/javax.el-api/3.0-b02</bundle>
+ <bundle start-level="30" dependency="true">mvn:org.glassfish/javax.el/3.0-b01</bundle>
</feature>
+ <feature name="cxf-management-web" version="${project.version}" resolver="(obr)">
+ <feature version="${project.version}">cxf-core</feature>
+ <feature version="${project.version}">cxf-jaxrs</feature>
+ <bundle start-level="35" dependency="true">mvn:commons-lang/commons-lang/${cxf.commons-lang.version}</bundle>
+ <bundle start-level="35" dependency="true">mvn:commons-codec/commons-codec/${cxf.commons-codec.version}</bundle>
+ <bundle start-level="35">mvn:org.apache.abdera/abdera-core/${cxf.abdera.version}</bundle>
+ <bundle start-level="35">mvn:org.apache.abdera/abdera-i18n/${cxf.abdera.version}</bundle>
+ <bundle start-level="35">mvn:org.apache.james/apache-mime4j-core/${cxf.james.mim4j.version}</bundle>
+ <bundle start-level="35">mvn:org.apache.abdera/abdera-parser/${cxf.abdera.version}</bundle>
+ <bundle start-level="40">mvn:org.apache.cxf/cxf-rt-management-web/${project.version}</bundle>
+ </feature>
</features>
diff --git a/osgi/karaf/pom.xml b/osgi/karaf/pom.xml
index c0a192b2d06..126dbf8b5c7 100644
--- a/osgi/karaf/pom.xml
+++ b/osgi/karaf/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../parent</relativePath>
</parent>
<groupId>org.apache.cxf.karaf</groupId>
diff --git a/osgi/pom.xml b/osgi/pom.xml
index f5724d149b9..b572e40fc7d 100644
--- a/osgi/pom.xml
+++ b/osgi/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<modules>
<module>bundle</module>
diff --git a/parent/pom.xml b/parent/pom.xml
index b32f4a1e805..1814f50565f 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -6,9 +6,9 @@
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
-
+
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
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cxf-parent</artifactId>
@@ -75,29 +75,31 @@
<cxf.abdera.version>1.1.3</cxf.abdera.version>
<cxf.activemq.version>5.9.1</cxf.activemq.version>
<cxf.ahc.version>1.8.5</cxf.ahc.version>
- <cxf.atmosphere.version>2.2.0</cxf.atmosphere.version>
+ <cxf.apacheds.version>2.0.0-M19</cxf.apacheds.version>
+ <cxf.atmosphere.version>2.2.7</cxf.atmosphere.version>
<cxf.atmosphere.version.range>[2.0,3.0)</cxf.atmosphere.version.range>
<cxf.axiom.version>1.2.14</cxf.axiom.version>
- <cxf.bcprov.version>1.50</cxf.bcprov.version>
+ <cxf.bcprov.version>1.52</cxf.bcprov.version>
<cxf.cglib.bundle.version>2.2_2</cxf.cglib.bundle.version>
<cxf.cglib.osgi.version>[2.1.3,3.0.0)</cxf.cglib.osgi.version>
- <cxf.commons-codec.version>1.9</cxf.commons-codec.version>
+ <cxf.commons-codec.version>1.10</cxf.commons-codec.version>
<cxf.commons-collections.version>3.2.1</cxf.commons-collections.version>
<cxf.commons-lang.version>2.6</cxf.commons-lang.version>
<cxf.derby.version>10.2.2.0</cxf.derby.version>
- <cxf.ehcache.version>2.8.3</cxf.ehcache.version>
+ <cxf.ehcache.version>2.8.5</cxf.ehcache.version>
<cxf.fastinfoset.bundle.version>1.2.13_1</cxf.fastinfoset.bundle.version>
<cxf.hazelcast.version>1.9.4</cxf.hazelcast.version>
- <cxf.httpcomponents.asyncclient.version>4.0.1</cxf.httpcomponents.asyncclient.version>
+ <cxf.httpcomponents.asyncclient.version>4.0.2</cxf.httpcomponents.asyncclient.version>
<cxf.httpcomponents.asyncclient.version.range>[4.0,4.1)</cxf.httpcomponents.asyncclient.version.range>
- <cxf.httpcomponents.client.version>4.3.3</cxf.httpcomponents.client.version>
- <cxf.httpcomponents.core.version>4.3.2</cxf.httpcomponents.core.version>
+ <cxf.httpcomponents.client.version>4.3.5</cxf.httpcomponents.client.version>
+ <cxf.httpcomponents.core.version>4.3.3</cxf.httpcomponents.core.version>
<cxf.httpcomponents.core.version.range>[4.3,4.4.0)</cxf.httpcomponents.core.version.range>
+ <cxf.jackson.version>2.4.1</cxf.jackson.version>
<cxf.james.mim4j.version>0.7.2</cxf.james.mim4j.version>
<cxf.logback.classic.version>1.0.13</cxf.logback.classic.version>
<cxf.log4j.version>1.2.17</cxf.log4j.version>
<cxf.lucene.version>4.0.0-BETA</cxf.lucene.version>
- <cxf.mina.version>2.0.7</cxf.mina.version>
+ <cxf.mina.version>2.0.9</cxf.mina.version>
<cxf.javax.annotation-api.version>1.2</cxf.javax.annotation-api.version>
<cxf.geronimo.jms.version>1.1.1</cxf.geronimo.jms.version>
<cxf.geronimo.j2ee.management.version>1.0.1</cxf.geronimo.j2ee.management.version>
@@ -106,15 +108,15 @@
<cxf.geronimo.servlet25.version>1.2</cxf.geronimo.servlet25.version>
<cxf.geronimo.transaction.version>1.1.1</cxf.geronimo.transaction.version>
<cxf.jasypt.bundle.version>1.9.0_1</cxf.jasypt.bundle.version>
- <cxf.javax.ws.rs.version>2.0</cxf.javax.ws.rs.version>
+ <cxf.javax.ws.rs.version>2.0.1</cxf.javax.ws.rs.version>
<cxf.jaxb21.version>2.1</cxf.jaxb21.version>
<cxf.jaxb21.impl.version>2.1.14</cxf.jaxb21.impl.version>
<cxf.jaxb21.core.version>2.1.14</cxf.jaxb21.core.version>
<cxf.jaxb21.xjc.version>2.1.14</cxf.jaxb21.xjc.version>
<cxf.jaxb22.version>2.2.11</cxf.jaxb22.version>
- <cxf.jaxb22.impl.version>2.2.10-b140310.1920</cxf.jaxb22.impl.version>
- <cxf.jaxb22.core.version>2.2.10-b140310.1920</cxf.jaxb22.core.version>
- <cxf.jaxb22.xjc.version>2.2.10-b140310.1920</cxf.jaxb22.xjc.version>
+ <cxf.jaxb22.impl.version>${cxf.jaxb22.version}</cxf.jaxb22.impl.version>
+ <cxf.jaxb22.core.version>${cxf.jaxb22.version}</cxf.jaxb22.core.version>
+ <cxf.jaxb22.xjc.version>${cxf.jaxb22.version}</cxf.jaxb22.xjc.version>
<!-- by default, we use jaxb 2.1, but java5 profile will override to 2.2 -->
<cxf.jaxb.version>${cxf.jaxb21.version}</cxf.jaxb.version>
<cxf.jaxb.impl.version>${cxf.jaxb21.impl.version}</cxf.jaxb.impl.version>
@@ -122,15 +124,15 @@
<cxf.jaxb.xjc.version>${cxf.jaxb21.xjc.version}</cxf.jaxb.xjc.version>
<cxf.joda.time.version>2.2</cxf.joda.time.version>
<cxf.jdom.version>1.0</cxf.jdom.version>
- <cxf.jettison.version>1.3.5</cxf.jettison.version>
+ <cxf.jettison.version>1.3.7</cxf.jettison.version>
<cxf.jetty.version>8.1.15.v20140411</cxf.jetty.version>
<cxf.jetty.osgi.version>[7.6,8.2)</cxf.jetty.osgi.version>
- <cxf.jibx.version>1.2.5</cxf.jibx.version>
- <cxf.junit.version>4.11</cxf.junit.version>
+ <cxf.jibx.version>1.2.6</cxf.jibx.version>
+ <cxf.junit.version>4.12</cxf.junit.version>
<cxf.maven.core.version>2.2.1</cxf.maven.core.version>
<cxf.msv.version>2011.1</cxf.msv.version>
<cxf.neethi.version>3.0.3</cxf.neethi.version>
- <cxf.netty.version>4.0.18.Final</cxf.netty.version>
+ <cxf.netty.version>4.0.19.Final</cxf.netty.version>
<cxf.netty3.version>3.9.1.Final</cxf.netty3.version>
<cxf.netty.version.range>[4,5)</cxf.netty.version.range>
<cxf.oauth.bundle.version>20100527_1</cxf.oauth.bundle.version>
@@ -146,22 +148,22 @@
<cxf.servlet-api.version>1.0</cxf.servlet-api.version>
<cxf.servlet-api-2.5.artifact>geronimo-servlet_2.5_spec</cxf.servlet-api-2.5.artifact>
<cxf.servlet-api-2.5.version>1.1.2</cxf.servlet-api-2.5.version>
- <cxf.slf4j.version>1.7.7</cxf.slf4j.version>
+ <cxf.slf4j.version>1.7.9</cxf.slf4j.version>
<cxf.specs.jaxws.api.version>1.2</cxf.specs.jaxws.api.version>
<cxf.spring.version>3.2.6.RELEASE</cxf.spring.version>
<cxf.spring.security.version>3.1.4.RELEASE</cxf.spring.security.version>
<cxf.spring.osgi.version>1.2.1</cxf.spring.osgi.version>
<cxf.spring.ldap.version>1.3.1.RELEASE</cxf.spring.ldap.version>
<cxf.spring.mock>spring-test</cxf.spring.mock>
- <cxf.swagger.version>1.3.4</cxf.swagger.version>
+ <cxf.swagger.version>1.3.11</cxf.swagger.version>
<cxf.velocity.version>1.7</cxf.velocity.version>
- <cxf.woodstox.core.version>4.4.0</cxf.woodstox.core.version>
+ <cxf.woodstox.core.version>4.4.1</cxf.woodstox.core.version>
<cxf.woodstox.stax2-api.version>3.1.4</cxf.woodstox.stax2-api.version>
<cxf.wsdl4j.version>1.6.3</cxf.wsdl4j.version>
- <cxf.wss4j.version>2.0.2-SNAPSHOT</cxf.wss4j.version>
+ <cxf.wss4j.version>2.0.4</cxf.wss4j.version>
<cxf.xerces.version>2.11.0</cxf.xerces.version>
<cxf.xmlbeans.version>2.6.0</cxf.xmlbeans.version>
- <cxf.xmlschema.version>2.1.0</cxf.xmlschema.version>
+ <cxf.xmlschema.version>2.2.1</cxf.xmlschema.version>
<cxf.xpp3.bundle.version>1.1.4c_6</cxf.xpp3.bundle.version>
<cxf.validation.api.version>1.1.0.Final</cxf.validation.api.version>
<cxf.cdi.api.version>1.1</cxf.cdi.api.version>
@@ -171,23 +173,25 @@
<cxf.hibernate.validator.version>5.0.2.Final</cxf.hibernate.validator.version>
<cxf.glassfish.json.version>1.0.4</cxf.glassfish.json.version>
<cxf.javax.el.version>3.0.0</cxf.javax.el.version>
- <cxf.hibernate-validator.bundle.version>5.0.2.Final_1</cxf.hibernate-validator.bundle.version>
+ <cxf.hibernate-validator.bundle.version>5.0.2.Final_1</cxf.hibernate-validator.bundle.version>
<!-- various OSGi related versions -->
<cxf.aries.version>1.0.0</cxf.aries.version>
<cxf.aries.version.range>[1.0,2)</cxf.aries.version.range>
<cxf.osgi.version>4.2.0</cxf.osgi.version>
- <cxf.karaf.version>2.3.3</cxf.karaf.version>
+ <cxf.karaf.version>2.4.0</cxf.karaf.version>
<cxf.pax.logging.version>1.6.0</cxf.pax.logging.version>
+ <cxf.pax.exam.version>3.4.0</cxf.pax.exam.version>
<cxf.felix.framework.version>2.0.5</cxf.felix.framework.version>
<cxf.felix.configadmin.version>1.2.4</cxf.felix.configadmin.version>
<cxf.xmlbeans.bundle.version>2.6.0_2</cxf.xmlbeans.bundle.version>
<cxf.servicemix.specs.version>2.4.0</cxf.servicemix.specs.version>
<cxf.servicemix.specs.version.jaxrs>2.4.0</cxf.servicemix.specs.version.jaxrs>
<cxf.javax.mail.version>1.4.4</cxf.javax.mail.version>
- <cxf.jaxb.bundle.version>2.2.1.1_2</cxf.jaxb.bundle.version>
- <cxf.saaj-impl.bundle.version>1.3.23_1</cxf.saaj-impl.bundle.version>
+ <cxf.jaxb.bundle.version>2.2.11_1</cxf.jaxb.bundle.version>
+ <cxf.saaj-impl.bundle.version>1.3.23_2</cxf.saaj-impl.bundle.version>
+ <cxf.stax-ex.version>1.7.6</cxf.stax-ex.version>
<cxf.wsdl4j.bundle.version>1.6.3_1</cxf.wsdl4j.bundle.version>
- <cxf.xmlsec.bundle.version>2.0.1</cxf.xmlsec.bundle.version>
+ <cxf.xmlsec.bundle.version>2.0.4</cxf.xmlsec.bundle.version>
<cxf.rhino.bundle.version>1.7R2_3</cxf.rhino.bundle.version>
<cxf.xmlresolver.bundle.version>1.2_5</cxf.xmlresolver.bundle.version>
<cxf.xerces.bundle.version>2.11.0_1</cxf.xerces.bundle.version>
@@ -198,6 +202,7 @@
<cxf.jdom.bundle.version>1.1_4</cxf.jdom.bundle.version>
<cxf.olingo.version>1.2.0</cxf.olingo.version>
<cxf.tika.version>1.5</cxf.tika.version>
+ <cxf.jexl.version>2.1.1</cxf.jexl.version>
<cxf.checkstyle.extension />
<cxf.jaxb.context.class />
<cxf.spring.validation.mode>VALIDATION_AUTO</cxf.spring.validation.mode>
@@ -256,6 +261,11 @@
</testResources>
<pluginManagement>
<plugins>
+ <plugin>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>depends-maven-plugin</artifactId>
+ <version>1.2</version>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
@@ -337,7 +347,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
- <version>3.1</version>
+ <version>3.2</version>
<dependencies>
<dependency>
<groupId>org.apache.cxf.build-utils</groupId>
@@ -407,7 +417,7 @@
<derby.system.home>${basedir}/target/derby</derby.system.home>
<spring.validation.mode>${cxf.spring.validation.mode}</spring.validation.mode>
<server.launcher.vmargs>${cxf.server.launcher.vmargs}</server.launcher.vmargs>
- <org.apache.cxf.transport.http.async.usePolicy>ALWAYS</org.apache.cxf.transport.http.async.usePolicy>
+ <org.apache.cxf.transport.http.async.usePolicy>ASYNC_ONLY</org.apache.cxf.transport.http.async.usePolicy>
<javax.xml.bind.JAXBContext>${cxf.jaxb.context.class}</javax.xml.bind.JAXBContext>
<!--javax.xml.bind.JAXBContext>org.eclipse.persistence.jaxb.JAXBContextFactory</javax.xml.bind.JAXBContext-->
</systemPropertyVariables>
@@ -631,6 +641,54 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.hbase</groupId>
+ <artifactId>hbase-client</artifactId>
+ <version>0.98.3-hadoop2</version>
+ <exclusions>
+ <exclusion>
+ <groupId>io.netty</groupId>
+ <artifactId>netty</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-server</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-json</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.jersey.contribs</groupId>
+ <artifactId>jersey-guice</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.google.inject</groupId>
+ <artifactId>guice</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.google.inject.extensions</groupId>
+ <artifactId>guice-servlet</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -697,6 +755,12 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-toolchain</artifactId>
+ <version>${cxf.maven.core.version}</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
@@ -839,19 +903,19 @@
<artifactId>cdi-api</artifactId>
<version>${cxf.cdi.api.version}</version>
<optional>true</optional>
- </dependency>
+ </dependency>
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>${cxf.json.api.version}</version>
<optional>true</optional>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>${cxf.glassfish.json.version}</version>
<optional>true</optional>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
@@ -892,10 +956,25 @@
<artifactId>jetty-servlet</artifactId>
<version>${cxf.jetty.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-io</artifactId>
+ <version>${cxf.jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-plus</artifactId>
+ <version>${cxf.jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-security</artifactId>
+ <version>${cxf.jetty.version}</version>
+ </dependency>
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
- <version>2.7.1</version>
+ <version>2.7.2</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
@@ -1311,9 +1390,14 @@
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
- <version>3.1</version>
+ <version>3.3</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-json-provider</artifactId>
+ <version>${cxf.jackson.version}</version>
+ </dependency>
<dependency>
<groupId>${cxf.asm.groupId}</groupId>
<artifactId>${cxf.asm.artifactId}</artifactId>
@@ -1721,7 +1805,7 @@
<artifactId>tika-parsers</artifactId>
<version>${cxf.tika.version}</version>
</dependency>
-
+
</dependencies>
</dependencyManagement>
<profiles>
diff --git a/pom.xml b/pom.xml
index ca4312bff81..01504aca447 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<name>Apache CXF</name>
<description>Apache CXF is an open-source services framework that aids in
the development of services using front-end programming APIs, like JAX-WS
@@ -43,7 +43,7 @@
<properties>
<cxf.compiler.fork>false</cxf.compiler.fork>
<cxf.build-utils.version>3.0.0</cxf.build-utils.version>
- <cxf.xjc-utils.version>3.0.1</cxf.xjc-utils.version>
+ <cxf.xjc-utils.version>3.0.2</cxf.xjc-utils.version>
<cxf.jdk.version>1.6</cxf.jdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<site.deploy.url>scp://people.apache.org/www/cxf.apache.org/maven-site</site.deploy.url>
@@ -216,7 +216,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
+ <version>3.3</version>
<configuration>
<source>${cxf.jdk.version}</source>
<target>${cxf.jdk.version}</target>
@@ -439,7 +439,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
- <version>1.8</version>
+ <version>1.9.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
@@ -459,17 +459,17 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
- <version>2.2</version>
+ <version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
- <version>2.5.1</version>
+ <version>2.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
- <version>2.5</version>
+ <version>2.5.2</version>
<configuration>
<useReleaseProfile>false</useReleaseProfile>
<preparationGoals>clean install</preparationGoals>
@@ -502,12 +502,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
- <version>2.2.1</version>
+ <version>2.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
+ <version>3.3</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
@@ -547,7 +547,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
- <version>2.4</version>
+ <version>2.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -560,7 +560,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
- <version>2.4</version>
+ <version>2.4.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -570,12 +570,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
- <version>2.8.1</version>
+ <version>2.8.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
- <version>2.16</version>
+ <version>2.17</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -585,7 +585,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
- <version>3.2</version>
+ <version>3.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -602,7 +602,7 @@
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
- <version>0.10</version>
+ <version>0.11</version>
<configuration>
<numUnapprovedLicenses>350</numUnapprovedLicenses>
<excludeSubProjects>false</excludeSubProjects>
@@ -624,7 +624,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
- <version>3.3</version>
+ <version>3.4</version>
<configuration>
<chmod>true</chmod>
<dependencyDetailsEnabled>false</dependencyDetailsEnabled>
diff --git a/rt/bindings/coloc/pom.xml b/rt/bindings/coloc/pom.xml
index 03ee3dd7cd4..c0c322a2c18 100644
--- a/rt/bindings/coloc/pom.xml
+++ b/rt/bindings/coloc/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
<properties>
diff --git a/rt/bindings/corba/pom.xml b/rt/bindings/corba/pom.xml
index b078860c5fc..c25aadbf5a5 100644
--- a/rt/bindings/corba/pom.xml
+++ b/rt/bindings/corba/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
<properties>
diff --git a/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/CorbaDestination.java b/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/CorbaDestination.java
index 44fbae69619..cc8a0a1bbaa 100644
--- a/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/CorbaDestination.java
+++ b/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/CorbaDestination.java
@@ -52,6 +52,7 @@
import org.omg.PortableServer.POA;
import org.omg.PortableServer.POAHelper;
import org.omg.PortableServer.POAManager;
+import org.omg.PortableServer.POAPackage.ObjectNotActive;
import org.omg.PortableServer.RequestProcessingPolicyValue;
import org.omg.PortableServer.Servant;
import org.omg.PortableServer.ThreadPolicyValue;
@@ -354,6 +355,9 @@ public void deactivate() {
try {
bindingPOA.deactivate_object(objectId);
+ } catch (ObjectNotActive ona) {
+ LOG.info("Caught ObjectNotActive exception: " + ona
+ + " during deactivate_object() call on POA: " + bindingPOA);
} catch (Exception ex) {
throw new CorbaBindingException("Unable to deactivate CORBA servant", ex);
}
diff --git a/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/wsdl/WSDLExtensionRegister.java b/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/wsdl/WSDLExtensionRegister.java
index ef006d2394f..f50f78099b8 100644
--- a/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/wsdl/WSDLExtensionRegister.java
+++ b/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/wsdl/WSDLExtensionRegister.java
@@ -70,7 +70,9 @@ private void createExtensor(WSDLManager manager,
try {
JAXBExtensionHelper.addExtensions(manager.getExtensionRegistry(),
parentType,
- elementType);
+ elementType,
+ null,
+ this.getClass().getClassLoader());
} catch (JAXBException e) {
//ignore, won't support CORBA
}
diff --git a/rt/bindings/object/pom.xml b/rt/bindings/object/pom.xml
index 38366728c76..b0364f17603 100644
--- a/rt/bindings/object/pom.xml
+++ b/rt/bindings/object/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
<properties>
diff --git a/rt/bindings/pom.xml b/rt/bindings/pom.xml
index f83b6ab7f17..749d2bb706e 100644
--- a/rt/bindings/pom.xml
+++ b/rt/bindings/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
</parent>
<modules>
<module>soap</module>
diff --git a/rt/bindings/soap/pom.xml b/rt/bindings/soap/pom.xml
index d8e569949ef..8aefd87f539 100644
--- a/rt/bindings/soap/pom.xml
+++ b/rt/bindings/soap/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
<properties>
diff --git a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
index 18999ff67b1..096ca0254bf 100644
--- a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
+++ b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
@@ -72,6 +72,8 @@ protected void prepareStackTrace(SoapMessage message, SoapFault fault) throws Ex
if (config && fault.getCause() != null) {
StringBuilder sb = new StringBuilder();
Throwable throwable = fault.getCause();
+ sb.append("Caused by: ").append(throwable.getClass().getCanonicalName())
+ .append(": " + throwable.getMessage() + "\n").append(Message.EXCEPTION_CAUSE_SUFFIX);
while (throwable != null) {
for (StackTraceElement ste : throwable.getStackTrace()) {
sb.append(ste.getClassName() + "!" + ste.getMethodName() + "!" + ste.getFileName() + "!"
diff --git a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties
index 9b1a7c2985e..bf5622ba261 100644
--- a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties
+++ b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Messages.properties
@@ -30,7 +30,7 @@ INVALID_VERSION="{0}", the namespace on the "{1}" element, is not a valid SOAP v
INVALID_11_VERSION=A SOAP 1.2 message is not valid when sent to a SOAP 1.1 only endpoint.
INVALID_ENVELOPE=Invalid SOAP Envelope name
INVALID_FAULT=Invalid SOAP fault content
-NO_NAMESPACE=No namespace on "{0}" element. You must send a SOAP request.
+NO_NAMESPACE=No namespace on "{0}" element. You must send a SOAP message.
BP_2211_RPCLIT_CANNOT_BE_NULL=Cannot write part {0}. RPC/Literal parts cannot be null. (WS-I BP R2211)
UNKNOWN_RPC_LIT_PART=Found element {0} but could not find matching RPC/Literal part
SOAP_ACTION_MISMATCH=The given SOAPAction {0} does not match an operation.
diff --git a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java
index 37120a8ebeb..cad50aff411 100644
--- a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java
+++ b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java
@@ -224,6 +224,6 @@ private void setMessage(Message message,
message.put(Message.WSDL_DESCRIPTION, wsdlDescription);
// configure endpoint and operation level schema validation
- setOperationSchemaValidation(operation.getOperationInfo(), message);
+ setOperationSchemaValidation(message);
}
}
diff --git a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCOutInterceptor.java b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCOutInterceptor.java
index a6fcdcb81aa..01649d67896 100644
--- a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCOutInterceptor.java
+++ b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCOutInterceptor.java
@@ -145,9 +145,12 @@ protected String addOperationNode(NSStack nsStack, Message message,
body = boi.getOutput().getExtensor(SoapBody.class);
} else {
body = boi.getInput().getExtensor(SoapBody.class);
- }
- if (body != null && !StringUtils.isEmpty(body.getNamespaceURI())) {
- ns = body.getNamespaceURI();
+ }
+ if (body != null) {
+ final String nsUri = body.getNamespaceURI(); //do it once, as it might internally use reflection...
+ if (!StringUtils.isEmpty(nsUri)) {
+ ns = nsUri;
+ }
}
nsStack.add(ns);
diff --git a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
index 478e2b083b1..88709a19bf3 100644
--- a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
+++ b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
@@ -20,20 +20,25 @@
package org.apache.cxf.binding.soap.interceptor;
import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.events.XMLEvent;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
-//import org.w3c.dom.NodeList;
import org.apache.cxf.Bus;
import org.apache.cxf.annotations.SchemaValidation.SchemaValidationType;
@@ -53,13 +58,18 @@
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.helpers.ServiceUtils;
import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.MessageUtils;
import org.apache.cxf.phase.Phase;
import org.apache.cxf.staxutils.PartialXMLStreamReader;
import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.staxutils.StaxUtils.StreamToDOMContext;
import org.apache.cxf.staxutils.W3CDOMStreamWriter;
public class ReadHeadersInterceptor extends AbstractSoapInterceptor {
+
+ public static final String ENVELOPE_EVENTS = "envelope.events";
+ public static final String BODY_EVENTS = "body.events";
/**
*
*/
@@ -126,7 +136,8 @@ public static SoapVersion readVersion(XMLStreamReader xmlReader, SoapMessage mes
message.setVersion(soapVersion);
return soapVersion;
}
-
+
+ //CHECKSTYLE:OFF MethodLength
public void handleMessage(SoapMessage message) {
if (isGET(message)) {
LOG.fine("ReadHeadersInterceptor skipped in HTTP GET method");
@@ -179,75 +190,88 @@ public void handleMessage(SoapMessage message) {
doc = (Document)nd;
StaxUtils.readDocElements(doc, doc, filteredReader, false, false);
} else {
- doc = StaxUtils.read(filteredReader);
- message.setContent(Node.class, doc);
+ final boolean addNC =
+ MessageUtils.getContextualBoolean(
+ message, "org.apache.cxf.binding.soap.addNamespaceContext", false);
+ Map<String, String> bodyNC = addNC ? new HashMap<String, String>() : null;
+ if (addNC) {
+ // add the Envelope-Level declarations
+ addCurrentNamespaceDecls(xmlReader, bodyNC);
+ }
+ HeadersProcessor processor = new HeadersProcessor(soapVersion);
+ doc = processor.process(filteredReader);
+ if (doc != null) {
+ message.setContent(Node.class, doc);
+ } else {
+ message.put(ENVELOPE_EVENTS, processor.getEnvAttributeAndNamespaceEvents());
+ message.put(BODY_EVENTS, processor.getBodyAttributeAndNamespaceEvents());
+ }
+ if (addNC) {
+ // add the Body-level declarations
+ addCurrentNamespaceDecls(xmlReader, bodyNC);
+ message.put("soap.body.ns.context", bodyNC);
+ }
}
// Find header
- // TODO - we could stream read the "known" headers and just DOM read the
- // unknown ones
- Element element = doc.getDocumentElement();
- QName header = soapVersion.getHeader();
- List<Element> elemList =
- DOMUtils.findAllElementsByTagNameNS(element,
- header.getNamespaceURI(),
- header.getLocalPart());
- for (Element elem : elemList) {
- Element hel = DOMUtils.getFirstElement(elem);
- while (hel != null) {
- // Need to add any attributes that are present on the parent element
- // which otherwise would be lost.
- if (elem.hasAttributes()) {
- NamedNodeMap nnp = elem.getAttributes();
- for (int ct = 0; ct < nnp.getLength(); ct++) {
- Node attr = nnp.item(ct);
- Node headerAttrNode = hel.hasAttributes()
- ? hel.getAttributes().getNamedItemNS(
- attr.getNamespaceURI(), attr.getLocalName())
- : null;
-
- if (headerAttrNode == null) {
- Attr attribute = hel.getOwnerDocument().createAttributeNS(
- attr.getNamespaceURI(),
- attr.getNodeName());
- attribute.setNodeValue(attr.getNodeValue());
- hel.setAttributeNodeNS(attribute);
+ if (doc != null) {
+ Element element = doc.getDocumentElement();
+ QName header = soapVersion.getHeader();
+ List<Element> elemList = DOMUtils.findAllElementsByTagNameNS(element,
+ header.getNamespaceURI(),
+ header.getLocalPart());
+ for (Element elem : elemList) {
+ Element hel = DOMUtils.getFirstElement(elem);
+ while (hel != null) {
+ // Need to add any attributes that are present on the parent element
+ // which otherwise would be lost.
+ if (elem.hasAttributes()) {
+ NamedNodeMap nnp = elem.getAttributes();
+ for (int ct = 0; ct < nnp.getLength(); ct++) {
+ Node attr = nnp.item(ct);
+ Node headerAttrNode = hel.hasAttributes() ? hel.getAttributes()
+ .getNamedItemNS(attr.getNamespaceURI(), attr.getLocalName()) : null;
+
+ if (headerAttrNode == null) {
+ Attr attribute = hel.getOwnerDocument()
+ .createAttributeNS(attr.getNamespaceURI(), attr.getNodeName());
+ attribute.setNodeValue(attr.getNodeValue());
+ hel.setAttributeNodeNS(attribute);
+ }
}
}
+
+ HeaderProcessor p = bus == null ? null : bus.getExtension(HeaderManager.class)
+ .getHeaderProcessor(hel.getNamespaceURI());
+
+ Object obj;
+ DataBinding dataBinding = null;
+ if (p == null || p.getDataBinding() == null) {
+ obj = hel;
+ } else {
+ dataBinding = p.getDataBinding();
+ obj = dataBinding.createReader(Node.class).read(hel);
+ }
+ // TODO - add the interceptors
+
+ SoapHeader shead = new SoapHeader(new QName(hel.getNamespaceURI(),
+ hel.getLocalName()), obj, dataBinding);
+ String mu = hel.getAttributeNS(soapVersion.getNamespace(),
+ soapVersion.getAttrNameMustUnderstand());
+ String act = hel.getAttributeNS(soapVersion.getNamespace(),
+ soapVersion.getAttrNameRole());
+
+ if (!StringUtils.isEmpty(act)) {
+ shead.setActor(act);
+ }
+ shead.setMustUnderstand(Boolean.valueOf(mu) || "1".equals(mu));
+ // mark header as inbound header.(for distinguishing between the direction to
+ // avoid piggybacking of headers from request->server->response.
+ shead.setDirection(SoapHeader.Direction.DIRECTION_IN);
+ message.getHeaders().add(shead);
+
+ hel = DOMUtils.getNextElement(hel);
}
-
- HeaderProcessor p = bus == null ? null : bus.getExtension(HeaderManager.class)
- .getHeaderProcessor(hel.getNamespaceURI());
-
- Object obj;
- DataBinding dataBinding = null;
- if (p == null || p.getDataBinding() == null) {
- obj = hel;
- } else {
- dataBinding = p.getDataBinding();
- obj = dataBinding.createReader(Node.class).read(hel);
- }
- //TODO - add the interceptors
-
- SoapHeader shead = new SoapHeader(new QName(hel.getNamespaceURI(),
- hel.getLocalName()),
- obj,
- dataBinding);
- String mu = hel.getAttributeNS(soapVersion.getNamespace(),
- soapVersion.getAttrNameMustUnderstand());
- String act = hel.getAttributeNS(soapVersion.getNamespace(),
- soapVersion.getAttrNameRole());
-
- if (!StringUtils.isEmpty(act)) {
- shead.setActor(act);
- }
- shead.setMustUnderstand(Boolean.valueOf(mu) || "1".equals(mu));
- //mark header as inbound header.(for distinguishing between the direction to
- //avoid piggybacking of headers from request->server->response.
- shead.setDirection(SoapHeader.Direction.DIRECTION_IN);
- message.getHeaders().add(shead);
-
- hel = DOMUtils.getNextElement(hel);
}
}
@@ -269,4 +293,157 @@ public void handleMessage(SoapMessage message) {
}
}
}
+ //CHECKSTYLE:ON
+
+ private void addCurrentNamespaceDecls(XMLStreamReader xmlReader, Map<String, String> bodyNsMap) {
+ for (int i = 0; i < xmlReader.getNamespaceCount(); i++) {
+ String nsuri = xmlReader.getNamespaceURI(i);
+ if ("".equals(nsuri)) {
+ bodyNsMap.remove("");
+ } else {
+ bodyNsMap.put(xmlReader.getNamespacePrefix(i), nsuri);
+ }
+ }
+ }
+
+ /**
+ * A convenient class for parsing the message header stream into a DOM document;
+ * the document is created only if a SOAP Header is actually found, keeping the
+ * memory usage as low as possible (there's no reason for building the DOM doc
+ * here if there's actually no header in the message, but we need to figure that
+ * out while parsing the stream).
+ */
+ private static class HeadersProcessor {
+ private static final XMLEventFactory FACTORY = XMLEventFactory.newInstance();
+ private final String ns;
+ private final String header;
+ private final String body;
+ private final String envelope;
+ private final List<XMLEvent> events = new ArrayList<XMLEvent>(8);
+ private List<XMLEvent> envEvents;
+ private List<XMLEvent> bodyEvents;
+ private StreamToDOMContext context;
+ private Document doc;
+ private Node parent;
+ private QName lastStartElementQName;
+
+ public HeadersProcessor(SoapVersion version) {
+ this.header = version.getHeader().getLocalPart();
+ this.ns = version.getEnvelope().getNamespaceURI();
+ this.envelope = version.getEnvelope().getLocalPart();
+ this.body = version.getBody().getLocalPart();
+ }
+
+ public Document process(XMLStreamReader reader) throws XMLStreamException {
+ // number of elements read in
+ int read = 0;
+ int event = reader.getEventType();
+ while (reader.hasNext()) {
+ switch (event) {
+ case XMLStreamConstants.START_ELEMENT:
+ read++;
+ addEvent(FACTORY.createStartElement(new QName(reader.getNamespaceURI(), reader
+ .getLocalName(), reader.getPrefix()), null, null));
+ for (int i = 0; i < reader.getNamespaceCount(); i++) {
+ addEvent(FACTORY.createNamespace(reader.getNamespacePrefix(i),
+ reader.getNamespaceURI(i)));
+ }
+ for (int i = 0; i < reader.getAttributeCount(); i++) {
+ addEvent(FACTORY.createAttribute(reader.getAttributePrefix(i),
+ reader.getAttributeNamespace(i),
+ reader.getAttributeLocalName(i),
+ reader.getAttributeValue(i)));
+ }
+ if (doc != null) {
+ //go on parsing the stream directly till the end and stop generating events
+ StaxUtils.readDocElements(doc, parent, reader, context);
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ if (read > 0) {
+ addEvent(FACTORY.createEndElement(new QName(reader.getNamespaceURI(), reader
+ .getLocalName(), reader.getPrefix()), null));
+ }
+ read--;
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ String s = reader.getText();
+ if (s != null) {
+ addEvent(FACTORY.createCharacters(s));
+ }
+ break;
+ case XMLStreamConstants.COMMENT:
+ addEvent(FACTORY.createComment(reader.getText()));
+ break;
+ case XMLStreamConstants.CDATA:
+ addEvent(FACTORY.createCData(reader.getText()));
+ break;
+ case XMLStreamConstants.START_DOCUMENT:
+ case XMLStreamConstants.END_DOCUMENT:
+ case XMLStreamConstants.ATTRIBUTE:
+ case XMLStreamConstants.NAMESPACE:
+ break;
+ default:
+ break;
+ }
+ event = reader.next();
+ }
+
+ return doc;
+ }
+
+ private void addEvent(XMLEvent event) {
+ if (event.isStartElement()) {
+ lastStartElementQName = event.asStartElement().getName();
+ if (header.equals(lastStartElementQName.getLocalPart())
+ && ns.equals(lastStartElementQName.getNamespaceURI())) {
+ // process all events recorded so far
+ context = new StreamToDOMContext(true, false, false);
+ doc = DOMUtils.createDocument();
+ parent = doc;
+ try {
+ for (XMLEvent ev : events) {
+ parent = StaxUtils.readDocElement(doc, parent, ev, context);
+ }
+ } catch (XMLStreamException e) {
+ throw new Fault(e);
+ }
+ } else {
+ events.add(event);
+ }
+ } else {
+ if (event.isNamespace() || event.isAttribute()) {
+ final String lastEl = lastStartElementQName.getLocalPart();
+ if (body.equals(lastEl) && ns.equals(lastStartElementQName.getNamespaceURI())) {
+ if (bodyEvents == null) {
+ bodyEvents = new ArrayList<XMLEvent>();
+ }
+ bodyEvents.add(event);
+ } else if (envelope.equals(lastEl) && ns.equals(lastStartElementQName.getNamespaceURI())) {
+ if (envEvents == null) {
+ envEvents = new ArrayList<XMLEvent>();
+ }
+ envEvents.add(event);
+ }
+ }
+ events.add(event);
+ }
+ }
+
+ public List<XMLEvent> getBodyAttributeAndNamespaceEvents() {
+ if (bodyEvents == null) {
+ return Collections.emptyList();
+ } else {
+ return Collections.unmodifiableList(bodyEvents);
+ }
+ }
+
+ public List<XMLEvent> getEnvAttributeAndNamespaceEvents() {
+ if (envEvents == null) {
+ return Collections.emptyList();
+ } else {
+ return Collections.unmodifiableList(envEvents);
+ }
+ }
+ }
}
diff --git a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java
index ff0b05a1af3..2943f77f7f1 100644
--- a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java
+++ b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultInInterceptor.java
@@ -32,6 +32,7 @@
import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.common.i18n.Message;
import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.interceptor.ClientFaultConverter;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.phase.Phase;
@@ -57,12 +58,13 @@ public static SoapFault unmarshalFault(SoapMessage message,
QName faultCode = null;
String role = null;
Element detail = null;
-
+ String lang = null;
try {
while (reader.nextTag() == XMLStreamReader.START_ELEMENT) {
if (reader.getLocalName().equals("faultcode")) {
faultCode = StaxUtils.readQName(reader);
} else if (reader.getLocalName().equals("faultstring")) {
+ lang = reader.getAttributeValue("http://www.w3.org/XML/1998/namespace", "lang");
exMessage = reader.getElementText();
} else if (reader.getLocalName().equals("faultactor")) {
role = reader.getElementText();
@@ -84,6 +86,9 @@ public static SoapFault unmarshalFault(SoapMessage message,
SoapFault fault = new SoapFault(exMessage, faultCode);
fault.setDetail(detail);
fault.setRole(role);
+ if (!StringUtils.isEmpty(lang)) {
+ fault.setLang(lang);
+ }
return fault;
}
}
diff --git a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
index b7a9bd19cf0..45ad4ad3e3f 100644
--- a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
+++ b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap11FaultOutInterceptor.java
@@ -33,6 +33,7 @@
import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.binding.soap.interceptor.Soap12FaultOutInterceptor.Soap12FaultOutInterceptorInternal;
import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.phase.Phase;
import org.apache.cxf.staxutils.StaxUtils;
@@ -90,6 +91,10 @@ public void handleMessage(SoapMessage message) throws Fault {
writer.writeEndElement();
writer.writeStartElement("faultstring");
+ String lang = f.getLang();
+ if (!StringUtils.isEmpty(lang)) {
+ writer.writeAttribute("xml", "http://www.w3.org/XML/1998/namespace", "lang", lang);
+ }
writer.writeCharacters(getFaultMessage(message, fault));
writer.writeEndElement();
prepareStackTrace(message, fault);
diff --git a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java
index ea0cf4ba7b6..e0affa9cf0b 100644
--- a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java
+++ b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/Soap12FaultOutInterceptor.java
@@ -112,7 +112,7 @@ public void handleMessage(SoapMessage message) throws Fault {
writer.writeStartElement(defaultPrefix, "Reason", ns);
writer.writeStartElement(defaultPrefix, "Text", ns);
String lang = f.getLang();
- if (lang == null || lang.equalsIgnoreCase("")) {
+ if (StringUtils.isEmpty(lang)) {
lang = getLangCode();
}
writer.writeAttribute("xml", "http://www.w3.org/XML/1998/namespace", "lang", lang);
diff --git a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderOutFilterInterceptor.java b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderOutFilterInterceptor.java
index 0a5a4e7d5e1..48e47a6c605 100644
--- a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderOutFilterInterceptor.java
+++ b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderOutFilterInterceptor.java
@@ -34,13 +34,12 @@ public SoapHeaderOutFilterInterceptor() {
}
public void handleMessage(SoapMessage message) throws Fault {
- // TODO Auto-generated method stub
Iterator<Header> iter = message.getHeaders().iterator();
while (iter.hasNext()) {
Header hdr = iter.next();
//Only remove inbound marked headers..
- if (hdr.getDirection() == Header.Direction.DIRECTION_IN) {
+ if (hdr == null || hdr.getDirection() == Header.Direction.DIRECTION_IN) {
iter.remove();
}
}
diff --git a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
index df1763122ee..6666c2a6574 100644
--- a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
+++ b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
@@ -214,8 +214,7 @@ private boolean handleHeaderPart(boolean preexistingHeaders, SoapMessage message
return endedHeader;
}
- List<MessagePartInfo> parts = wrappedBmi.getMessageInfo().getMessageParts();
- if (parts.size() > 0) {
+ if (wrappedBmi.getMessageInfo().getMessagePartsNumber() > 0) {
MessageContentsList objs = MessageContentsList.getContentsList(message);
if (objs == null) {
return endedHeader;
diff --git a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
index 0cca461c23d..1f12f8f2298 100644
--- a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
+++ b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
@@ -30,6 +30,9 @@
import javax.xml.namespace.QName;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
@@ -37,6 +40,9 @@
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.events.Attribute;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.XMLEvent;
import javax.xml.transform.dom.DOMSource;
import org.w3c.dom.Document;
@@ -159,6 +165,7 @@ public synchronized MessageFactory getFactory(SoapMessage message) throws SOAPEx
+ @SuppressWarnings("unchecked")
public void handleMessage(SoapMessage message) throws Fault {
if (isGET(message)) {
return;
@@ -184,6 +191,13 @@ public void handleMessage(SoapMessage message) throws Fault {
Document node = (Document) message.getContent(Node.class);
if (node != part && node != null) {
StaxUtils.copy(node, new SAAJStreamWriter(part));
+ } else {
+ SOAPEnvelope env = soapMessage.getSOAPPart().getEnvelope();
+ List<XMLEvent> events = (List<XMLEvent>)message.get(ReadHeadersInterceptor.ENVELOPE_EVENTS);
+ applyEvents(events, env);
+ SOAPBody body = soapMessage.getSOAPBody();
+ events = (List<XMLEvent>)message.get(ReadHeadersInterceptor.BODY_EVENTS);
+ applyEvents(events, body);
}
message.setContent(Node.class, soapMessage.getSOAPPart());
@@ -220,10 +234,15 @@ public void handleMessage(SoapMessage message) throws Fault {
soapMessage.getSOAPPart().getEnvelope().addHeader();
}
+ //If we have an xmlReader that already is counting the attributes and such
+ //then we don't want to rely on the system level defaults in StaxUtils.copy
+ //CXF-6173
+ boolean secureReader = StaxUtils.isSecureReader(xmlReader, message);
StaxUtils.copy(xmlReader,
new SAAJStreamWriter(soapMessage.getSOAPPart(),
soapMessage.getSOAPPart().getEnvelope().getBody()),
- true, true);
+ true,
+ !secureReader);
DOMSource bodySource = new DOMSource(soapMessage.getSOAPPart().getEnvelope().getBody());
xmlReader = StaxUtils.createXMLStreamReader(bodySource);
xmlReader.nextTag();
@@ -240,6 +259,18 @@ public void handleMessage(SoapMessage message) throws Fault {
}
}
+ private static void applyEvents(List<XMLEvent> events, SOAPElement el) throws SOAPException {
+ if (events != null) {
+ for (XMLEvent ev : events) {
+ if (ev.isNamespace()) {
+ el.addNamespaceDeclaration(((Namespace)ev).getPrefix(), ((Namespace)ev).getNamespaceURI());
+ } else if (ev.isAttribute()) {
+ el.addAttribute(((Attribute)ev).getName(), ((Attribute)ev).getValue());
+ }
+ }
+ }
+ }
+
public static void replaceHeaders(SOAPMessage soapMessage, SoapMessage message) throws SOAPException {
SOAPHeader header = SAAJUtils.getHeader(soapMessage);
if (header == null) {
diff --git a/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptorTest.java b/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptorTest.java
new file mode 100644
index 00000000000..e2fd16cb782
--- /dev/null
+++ b/rt/bindings/soap/src/test/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptorTest.java
@@ -0,0 +1,83 @@
+/**
+ * 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.apache.cxf.binding.soap.interceptor;
+
+import java.io.ByteArrayInputStream;
+import java.util.Map;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.cxf.binding.soap.Soap11;
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.staxutils.StaxUtils;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class ReadHeadersInterceptorTest extends Assert {
+ private static final byte[] TEST_SOAP =
+ ("<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"
+ + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"
+ + " xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:bar='tmp:bar'>"
+ + "<soap:Body>"
+ + "<ns2:payload xmlns:ns2='urn:tmp:foo'/>"
+ + "</soap:Body>"
+ + "</soap:Envelope>").getBytes();
+
+ private ReadHeadersInterceptor interceptor;
+
+ @Before
+ public void setUp() {
+ interceptor = new ReadHeadersInterceptor(null);
+ }
+
+ @Test
+ public void testNotAddNSContext() throws Exception {
+ SoapMessage message = setUpMessage();
+ interceptor.handleMessage(message);
+ Map<String, String> nsc = CastUtils.cast((Map<?, ?>)message.get("soap.body.ns.context"));
+ assertNull(nsc);
+ }
+
+ @Test
+ public void testAddNSContext() throws Exception {
+ SoapMessage message = setUpMessage();
+ message.put("org.apache.cxf.binding.soap.addNamespaceContext", "true");
+ interceptor.handleMessage(message);
+ Map<String, String> nsc = CastUtils.cast((Map<?, ?>)message.get("soap.body.ns.context"));
+ assertNotNull(nsc);
+ assertEquals("http://www.w3.org/2001/XMLSchema-instance", nsc.get("xsi"));
+ assertEquals("http://www.w3.org/2001/XMLSchema", nsc.get("xs"));
+ assertEquals("tmp:bar", nsc.get("bar"));
+
+ }
+
+ private SoapMessage setUpMessage() throws Exception {
+ SoapMessage message = new SoapMessage(Soap11.getInstance());
+ message.setContent(XMLStreamReader.class, StaxUtils.createXMLStreamReader(new ByteArrayInputStream(TEST_SOAP)));
+ return message;
+ }
+
+}
diff --git a/rt/bindings/xml/pom.xml b/rt/bindings/xml/pom.xml
index 7744f0e8387..156b8867a0d 100644
--- a/rt/bindings/xml/pom.xml
+++ b/rt/bindings/xml/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
<dependencies>
diff --git a/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLFormatValidator.java b/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLFormatValidator.java
index b8f34dcecbc..38ad1108b0e 100644
--- a/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLFormatValidator.java
+++ b/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/XMLFormatValidator.java
@@ -67,8 +67,8 @@ private boolean checkXMLFormat(BindingInfo binding) {
for (BindingOperationInfo bo : bos) {
OperationInfo op = binding.getInterface().getOperation(bo.getName());
needRootNode = false;
- if (op.getInput().getMessageParts().size() == 0
- || op.getInput().getMessageParts().size() > 1) {
+ final int inputPartsNum = op.getInput().getMessagePartsNumber();
+ if (inputPartsNum == 0 || inputPartsNum > 1) {
needRootNode = true;
}
if (needRootNode) {
@@ -86,8 +86,8 @@ private boolean checkXMLFormat(BindingInfo binding) {
// Input check correct, continue to check output binding
if (op.getOutput() != null) {
needRootNode = false;
- if (op.getOutput().getMessageParts().size() == 0
- || op.getOutput().getMessageParts().size() > 1) {
+ final int outputPartsNum = op.getOutput().getMessagePartsNumber();
+ if (outputPartsNum == 0 || outputPartsNum > 1) {
needRootNode = true;
}
if (needRootNode) {
diff --git a/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageOutInterceptor.java b/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageOutInterceptor.java
index 9daf6af2f93..ed3a8e1469c 100644
--- a/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageOutInterceptor.java
+++ b/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageOutInterceptor.java
@@ -67,8 +67,9 @@ public void handleMessage(Message message) throws Fault {
if (xmf != null) {
rootInModel = xmf.getRootNode();
}
+ final int mpn = mi.getMessagePartsNumber();
if (boi.isUnwrapped()
- || mi.getMessageParts().size() == 1) {
+ || mpn == 1) {
// wrapper out interceptor created the wrapper
// or if bare-one-param
new BareOutInterceptor().handleMessage(message);
@@ -76,7 +77,7 @@ public void handleMessage(Message message) throws Fault {
if (rootInModel == null) {
rootInModel = boi.getName();
}
- if (mi.getMessageParts().size() == 0 && !boi.isUnwrapped()) {
+ if (mpn == 0 && !boi.isUnwrapped()) {
// write empty operation qname
writeMessage(message, rootInModel, false);
} else {
diff --git a/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/wsdl11/XMLWSDLExtensionLoader.java b/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/wsdl11/XMLWSDLExtensionLoader.java
index 62de12704a4..2e4e451c291 100644
--- a/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/wsdl11/XMLWSDLExtensionLoader.java
+++ b/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/wsdl11/XMLWSDLExtensionLoader.java
@@ -56,7 +56,9 @@ public static void createExtensor(WSDLManager manager,
try {
JAXBExtensionHelper.addExtensions(manager.getExtensionRegistry(),
parentType,
- elementType);
+ elementType,
+ null,
+ XMLWSDLExtensionLoader.class.getClassLoader());
} catch (JAXBException e) {
//ignore, won't support XML
}
diff --git a/rt/databinding/aegis/pom.xml b/rt/databinding/aegis/pom.xml
index 24decdeaece..06a6d8a8c09 100644
--- a/rt/databinding/aegis/pom.xml
+++ b/rt/databinding/aegis/pom.xml
@@ -27,9 +27,17 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
+
+ <properties>
+ <cxf.osgi.import>
+ javax.xml.bind*;version="${cxf.osgi.javax.bind.version}",
+ javax.activation;version="${cxf.osgi.javax.activation.version}",
+ javax.xml.stream*;version="${cxf.osgi.javax.stream.version}"
+ </cxf.osgi.import>
+ </properties>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
diff --git a/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java b/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
index ec16f821805..7bc803ed1cc 100644
--- a/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
+++ b/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
@@ -340,7 +340,7 @@ public static DefaultTypeMapping createSoap11TypeMapping(boolean defaultNillable
}
public static DefaultTypeMapping createDefaultTypeMapping(boolean defaultNillable,
- boolean enableMtomXmime) {
+ boolean enableMtomXmime) {
return createDefaultTypeMapping(
defaultNillable,
enableMtomXmime,
diff --git a/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/AnnotationReader.java b/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/AnnotationReader.java
index bf06ed12e2d..66299a05f9b 100644
--- a/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/AnnotationReader.java
+++ b/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/AnnotationReader.java
@@ -21,26 +21,22 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.cxf.aegis.type.AegisType;
-import org.apache.cxf.common.logging.LogUtils;
public class AnnotationReader {
- private static final Logger LOG = LogUtils.getL7dLogger(AnnotationReader.class);
- private static final Class<? extends Annotation> WEB_PARAM = load("javax.jws.WebParam");
- private static final Class<? extends Annotation> WEB_RESULT = load("javax.jws.WebResult");
+ private static final Class<? extends Annotation> WEB_PARAM = javax.jws.WebParam.class;
+ private static final Class<? extends Annotation> WEB_RESULT = javax.jws.WebResult.class;
private static final Class<? extends Annotation> XML_ATTRIBUTE =
- load("javax.xml.bind.annotation.XmlAttribute");
+ javax.xml.bind.annotation.XmlAttribute.class;
private static final Class<? extends Annotation> XML_ELEMENT =
- load("javax.xml.bind.annotation.XmlElement");
+ javax.xml.bind.annotation.XmlElement.class;
private static final Class<? extends Annotation> XML_SCHEMA =
- load("javax.xml.bind.annotation.XmlSchema");
+ javax.xml.bind.annotation.XmlSchema.class;
private static final Class<? extends Annotation> XML_TYPE =
- load("javax.xml.bind.annotation.XmlType");
+ javax.xml.bind.annotation.XmlType.class;
private static final Class<? extends Annotation> XML_TRANSIENT =
- load("javax.xml.bind.annotation.XmlTransient");
+ javax.xml.bind.annotation.XmlTransient.class;
@SuppressWarnings("unchecked")
public boolean isIgnored(AnnotatedElement element) {
@@ -378,15 +374,6 @@ private static Annotation getAnnotation(Method method, int index, Class<? extend
return null;
}
- private static Class<? extends Annotation> load(String name) {
- try {
- return AnnotationReader.class.getClassLoader().loadClass(name).asSubclass(Annotation.class);
- } catch (Throwable e) {
- LOG.log(Level.FINE, "Error loading annotation class " + name + ".", e);
- return null;
- }
- }
-
public boolean isFlat(Annotation[] annotations) {
if (annotations != null) {
for (Annotation a : annotations) {
diff --git a/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/service/ServiceImpl.java b/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/service/ServiceImpl.java
index 2c4ef2323f7..109bc26c7c1 100644
--- a/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/service/ServiceImpl.java
+++ b/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/service/ServiceImpl.java
@@ -52,6 +52,7 @@
public Map<NoDefaultConstructorBeanKey, Collection<NoDefaultConstructorBean>>
getByNames(Collection<NoDefaultConstructorBeanKey> keys) {
+
if (keys == null) {
throw new IllegalArgumentException("keys is null");
}
diff --git a/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/ExplicitPrefixTest.java b/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/ExplicitPrefixTest.java
index 7e8c4e0ba1a..e32730f78cf 100644
--- a/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/ExplicitPrefixTest.java
+++ b/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/namespaces/ExplicitPrefixTest.java
@@ -117,8 +117,7 @@ private ServiceAndMapping setupService(Class<?> seiClass, Map<String, String> na
* @param node
* @return
*/
- private Map<String, String>
- getNodeNamespaceDeclarations(Node node) {
+ private Map<String, String> getNodeNamespaceDeclarations(Node node) {
Map<String, String> result = new HashMap<String, String>();
NamedNodeMap attributes = node.getAttributes();
for (int x = 0; x < attributes.getLength(); x++) {
diff --git a/rt/databinding/jaxb/pom.xml b/rt/databinding/jaxb/pom.xml
index ac5614070b3..3ed07df6632 100644
--- a/rt/databinding/jaxb/pom.xml
+++ b/rt/databinding/jaxb/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
<properties>
diff --git a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
index a95a3d2ddfa..27f7a743500 100644
--- a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
+++ b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
@@ -105,7 +105,7 @@ public void begin(MessagePartInfo part) {
inf = op.getOutput();
}
if (inf != null
- && inf.getMessagePart(0).getTypeClass() != null) {
+ && inf.getFirstMessagePart().getTypeClass() != null) {
//if the wrapper has a type class, we don't need to do anything
//as everything would have been discovered when walking the
//wrapper type (unless it's a header which wouldn't be in the wrapper)
diff --git a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
index cbca739fd5d..a034deff689 100644
--- a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
+++ b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
@@ -47,6 +47,7 @@
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.ValidationEventHandler;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
@@ -58,9 +59,7 @@
import org.w3c.dom.Document;
import org.w3c.dom.Node;
-
import org.xml.sax.InputSource;
-
import org.apache.cxf.common.injection.NoJSR250Annotations;
import org.apache.cxf.common.jaxb.JAXBBeanInfo;
import org.apache.cxf.common.jaxb.JAXBContextCache;
@@ -95,6 +94,11 @@
public class JAXBDataBinding extends AbstractInterceptorProvidingDataBinding
implements WrapperCapableDatabinding, InterceptorProvider {
+ public static final String READER_VALIDATION_EVENT_HANDLER = "jaxb-reader-validation-event-handler";
+ public static final String VALIDATION_EVENT_HANDLER = "jaxb-validation-event-handler";
+ public static final String SET_VALIDATION_EVENT_HANDLER = "set-jaxb-validation-event-handler";
+ public static final String WRITER_VALIDATION_EVENT_HANDLER = "jaxb-writer-validation-event-handler";
+
public static final String SCHEMA_RESOURCE = "SCHEMRESOURCE";
public static final String MTOM_THRESHOLD = "org.apache.cxf.jaxb.mtomThreshold";
@@ -191,9 +195,10 @@ public synchronized Node getNode() {
Class<?> cls;
- private Map<String, Object> contextProperties = Collections.emptyMap();
- private Map<String, Object> marshallerProperties = Collections.emptyMap();
- private Map<String, Object> unmarshallerProperties = Collections.emptyMap();
+ private Map<String, Object> contextProperties = new HashMap<String, Object>();
+ private List<XmlAdapter<?, ?>> adapters = new ArrayList<XmlAdapter<?, ?>>();
+ private Map<String, Object> marshallerProperties = new HashMap<String, Object>();
+ private Map<String, Object> unmarshallerProperties = new HashMap<String, Object>();
private Unmarshaller.Listener unmarshallerListener;
private Marshaller.Listener marshallerListener;
private ValidationEventHandler validationEventHandler;
@@ -304,8 +309,12 @@ public synchronized void initialize(Service service) {
contextClasses = new LinkedHashSet<Class<?>>();
- Map<String, Object> unmarshallerProps = new HashMap<String, Object>();
- this.setUnmarshallerProperties(unmarshallerProps);
+
+ if (this.getUnmarshallerProperties() == null || this.getUnmarshallerProperties().isEmpty()) {
+ Map<String, Object> unmarshallerProps = new HashMap<String, Object>();
+ this.setUnmarshallerProperties(unmarshallerProps);
+ }
+
for (ServiceInfo serviceInfo : service.getServiceInfos()) {
JAXBContextInitializer initializer
@@ -514,6 +523,14 @@ public void setContextProperties(Map<String, Object> contextProperties) {
this.contextProperties = contextProperties;
}
+ public List<XmlAdapter<?, ?>> getConfiguredXmlAdapters() {
+ return adapters;
+ }
+
+ public void setConfiguredXmlAdapters(List<XmlAdapter<?, ?>> adpters) {
+ this.adapters = adpters;
+ }
+
/**
* Return a map of properties. These properties are set into the JAXB
* Marshaller (via Marshaller.setProperty(...) when the marshaller is
diff --git a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
index bc70625ac58..b7b04782def 100644
--- a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
+++ b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
@@ -608,12 +608,21 @@ public static Exception unmarshallException(Unmarshaller u,
private static void writeObject(Marshaller u, Object source, Object mObj) throws Fault, JAXBException {
if (source instanceof XMLStreamWriter) {
+ // allows the XML Stream Writer to adjust it's behaviour based on the state of the unmarshaller
+ if (source instanceof MarshallerAwareXMLWriter) {
+ ((MarshallerAwareXMLWriter) source).setMarshaller(u);
+ }
u.marshal(mObj, (XMLStreamWriter)source);
} else if (source instanceof OutputStream) {
u.marshal(mObj, (OutputStream)source);
} else if (source instanceof Node) {
u.marshal(mObj, (Node)source);
} else if (source instanceof XMLEventWriter) {
+ // allows the XML Event Writer to adjust it's behaviour based on the state of the unmarshaller
+ if (source instanceof MarshallerAwareXMLWriter) {
+ ((MarshallerAwareXMLWriter) source).setMarshaller(u);
+ }
+
u.marshal(mObj, (XMLEventWriter)source);
} else {
throw new Fault(new Message("UNKNOWN_SOURCE", LOG, source.getClass().getName()));
@@ -836,6 +845,12 @@ private static Object doUnmarshal(final Unmarshaller u,
DepthXMLStreamReader dr = (DepthXMLStreamReader)source;
XMLStreamReader reader = dr.getReader();
+
+ // allows the XML Stream Reader to adjust it's behaviour based on the state of the unmarshaller
+ if (reader instanceof UnmarshallerAwareXMLReader) {
+ ((UnmarshallerAwareXMLReader) reader).setUnmarshaller(u);
+ }
+
if (u.getSchema() != null) {
//validating, but we may need more namespaces
reader = findExtraNamespaces(reader);
@@ -844,6 +859,12 @@ private static Object doUnmarshal(final Unmarshaller u,
.unmarshal(dr.getReader());
} else if (source instanceof XMLStreamReader) {
XMLStreamReader reader = (XMLStreamReader)source;
+
+ // allows the XML Stream Reader to adjust it's behaviour based on the state of the unmarshaller
+ if (reader instanceof UnmarshallerAwareXMLReader) {
+ ((UnmarshallerAwareXMLReader) reader).setUnmarshaller(u);
+ }
+
if (u.getSchema() != null) {
//validating, but we may need more namespaces
reader = findExtraNamespaces(reader);
@@ -851,6 +872,11 @@ private static Object doUnmarshal(final Unmarshaller u,
obj = unmarshalWithClass ? u.unmarshal(reader, clazz) : u
.unmarshal((XMLStreamReader)source);
} else if (source instanceof XMLEventReader) {
+ // allows the XML Event Reader to adjust it's behaviour based on the state of the unmarshaller
+ if (source instanceof UnmarshallerAwareXMLReader) {
+ ((UnmarshallerAwareXMLReader) source).setUnmarshaller(u);
+ }
+
obj = unmarshalWithClass ? u.unmarshal((XMLEventReader)source, clazz) : u
.unmarshal((XMLEventReader)source);
} else if (source == null) {
diff --git a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
index f48cc0688b5..64baa93abc4 100644
--- a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
+++ b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
@@ -42,6 +42,7 @@
import javax.xml.bind.annotation.XmlAccessorOrder;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlList;
+import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -381,7 +382,7 @@ private XmlSchemaElement createXsElement(XmlSchema schema,
}
public void end(FaultInfo fault) {
- MessagePartInfo part = fault.getMessageParts().get(0);
+ MessagePartInfo part = fault.getFirstMessagePart();
Class<?> cls = part.getTypeClass();
Class<?> cl2 = (Class<?>)fault.getProperty(Class.class.getName());
if (cls != cl2) {
@@ -583,12 +584,7 @@ private void buildExceptionType(MessagePartInfo part, Class<?> cls) {
}
// Create element in xsd:sequence for Exception.class
if (Exception.class.isAssignableFrom(cls)) {
- JAXBBeanInfo beanInfo = getBeanInfo(java.lang.String.class);
- XmlSchemaElement exEle = new XmlSchemaElement(schema, false);
- exEle.setName("message");
- exEle.setSchemaTypeName(getTypeName(beanInfo));
- exEle.setMinOccurs(0);
- seq.getItems().add(exEle);
+ addExceptionMessage(cls, schema, seq);
}
if (propertyOrder != null) {
@@ -609,6 +605,23 @@ private void buildExceptionType(MessagePartInfo part, Class<?> cls) {
schemas.addCrossImports();
part.setProperty(JAXBDataBinding.class.getName() + ".CUSTOM_EXCEPTION", Boolean.TRUE);
}
+ private void addExceptionMessage(Class<?> cls, XmlSchema schema, XmlSchemaSequence seq) {
+ try {
+ //a subclass could mark the message method as transient
+ Method m = cls.getMethod("getMessage");
+ if (!m.isAnnotationPresent(XmlTransient.class)
+ && m.getDeclaringClass().equals(Throwable.class)) {
+ JAXBBeanInfo beanInfo = getBeanInfo(java.lang.String.class);
+ XmlSchemaElement exEle = new XmlSchemaElement(schema, false);
+ exEle.setName("message");
+ exEle.setSchemaTypeName(getTypeName(beanInfo));
+ exEle.setMinOccurs(0);
+ seq.getItems().add(exEle);
+ }
+ } catch (Exception e) {
+ //ignore, just won't have the message element
+ }
+ }
private boolean generateGenericType(Type type) {
if (type instanceof ParameterizedType) {
diff --git a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/MarshallerAwareXMLWriter.java b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/MarshallerAwareXMLWriter.java
new file mode 100644
index 00000000000..ef6bce90731
--- /dev/null
+++ b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/MarshallerAwareXMLWriter.java
@@ -0,0 +1,29 @@
+/**
+ * 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.apache.cxf.jaxb;
+
+import javax.xml.bind.Marshaller;
+
+/*
+ * A XML Writer that adjusts it's behaviour based on the state of the marshaller.
+ */
+public interface MarshallerAwareXMLWriter {
+ void setMarshaller(Marshaller marshaller);
+}
diff --git a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/MarshallerEventHandler.java b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/MarshallerEventHandler.java
new file mode 100644
index 00000000000..91071d6827f
--- /dev/null
+++ b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/MarshallerEventHandler.java
@@ -0,0 +1,25 @@
+/**
+ * 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.apache.cxf.jaxb;
+
+import javax.xml.bind.MarshalException;
+
+public interface MarshallerEventHandler {
+ void onMarshalComplete() throws MarshalException;
+}
diff --git a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/UnmarshallerAwareXMLReader.java b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/UnmarshallerAwareXMLReader.java
new file mode 100644
index 00000000000..27ed146e079
--- /dev/null
+++ b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/UnmarshallerAwareXMLReader.java
@@ -0,0 +1,29 @@
+/**
+ * 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.apache.cxf.jaxb;
+
+import javax.xml.bind.Unmarshaller;
+
+/*
+ * A XML Reader that adjusts it's behaviour based on the state of the unmarshaller.
+ */
+public interface UnmarshallerAwareXMLReader {
+ void setUnmarshaller(Unmarshaller unmarshaller);
+}
diff --git a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/UnmarshallerEventHandler.java b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/UnmarshallerEventHandler.java
new file mode 100644
index 00000000000..f48be5b3ff7
--- /dev/null
+++ b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/UnmarshallerEventHandler.java
@@ -0,0 +1,25 @@
+/**
+ * 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.apache.cxf.jaxb;
+
+import javax.xml.bind.UnmarshalException;
+
+public interface UnmarshallerEventHandler {
+ void onUnmarshalComplete() throws UnmarshalException;
+}
diff --git a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
index 31676a3a648..de130290911 100644
--- a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
+++ b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
@@ -26,9 +26,11 @@
import javax.xml.bind.JAXBException;
import javax.xml.bind.PropertyException;
+import javax.xml.bind.UnmarshalException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.ValidationEvent;
import javax.xml.bind.ValidationEventHandler;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.namespace.QName;
import org.apache.cxf.common.i18n.Message;
@@ -38,6 +40,7 @@
import org.apache.cxf.jaxb.JAXBDataBase;
import org.apache.cxf.jaxb.JAXBDataBinding;
import org.apache.cxf.jaxb.JAXBEncoderDecoder;
+import org.apache.cxf.jaxb.UnmarshallerEventHandler;
import org.apache.cxf.message.MessageUtils;
import org.apache.cxf.service.model.MessagePartInfo;
@@ -65,34 +68,39 @@ public Object read(T input) {
}
public boolean handleEvent(ValidationEvent event) {
- String msg = event.getMessage();
- if (msg != null
- && msg.contains(":Id")
- && (msg.startsWith("cvc-type.3.1.1: ")
- || msg.startsWith("cvc-type.3.2.2: ")
- || msg.startsWith("cvc-complex-type.3.1.1: ")
- || msg.startsWith("cvc-complex-type.3.2.2: "))) {
+ // if the original handler has already handled the event, no need for us
+ // to do anything, otherwise if not yet handled, then do this 'hack'
+ if (origHandler != null && origHandler.handleEvent(event)) {
return true;
+ } else {
+ // hack for CXF-3453
+ String msg = event.getMessage();
+ return msg != null
+ && msg.contains(":Id")
+ && (msg.startsWith("cvc-type.3.1.1: ")
+ || msg.startsWith("cvc-type.3.2.2: ")
+ || msg.startsWith("cvc-complex-type.3.1.1: ")
+ || msg.startsWith("cvc-complex-type.3.2.2: "));
}
- if (origHandler != null) {
- return origHandler.handleEvent(event);
- }
- return false;
}
}
+
public void setProperty(String prop, Object value) {
if (prop.equals(JAXBDataBinding.UNWRAP_JAXB_ELEMENT)) {
unwrapJAXBElement = Boolean.TRUE.equals(value);
} else if (prop.equals(org.apache.cxf.message.Message.class.getName())) {
org.apache.cxf.message.Message m = (org.apache.cxf.message.Message)value;
- veventHandler = (ValidationEventHandler)m.getContextualProperty("jaxb-reader-validation-event-handler");
+ veventHandler = (ValidationEventHandler)m.getContextualProperty(
+ JAXBDataBinding.READER_VALIDATION_EVENT_HANDLER);
if (veventHandler == null) {
- veventHandler = (ValidationEventHandler)m.getContextualProperty("jaxb-validation-event-handler");
+ veventHandler = (ValidationEventHandler)m.getContextualProperty(
+ JAXBDataBinding.VALIDATION_EVENT_HANDLER);
}
if (veventHandler == null) {
veventHandler = databinding.getValidationEventHandler();
}
- setEventHandler = MessageUtils.getContextualBoolean(m, "set-jaxb-validation-event-handler", true);
+ setEventHandler = MessageUtils.getContextualBoolean(m,
+ JAXBDataBinding.SET_VALIDATION_EVENT_HANDLER, true);
Object unwrapProperty = m.get(JAXBDataBinding.UNWRAP_JAXB_ELEMENT);
if (unwrapProperty == null) {
@@ -103,6 +111,7 @@ public void setProperty(String prop, Object value) {
}
}
}
+
private Unmarshaller createUnmarshaller() {
try {
Unmarshaller um = null;
@@ -125,6 +134,9 @@ private Unmarshaller createUnmarshaller() {
}
um.setSchema(schema);
um.setAttachmentUnmarshaller(getAttachmentUnmarshaller());
+ for (XmlAdapter<?, ?> adapter : databinding.getConfiguredXmlAdapters()) {
+ um.setAdapter(adapter);
+ }
return um;
} catch (JAXBException ex) {
if (ex instanceof javax.xml.bind.UnmarshalException) {
@@ -148,23 +160,47 @@ public Object read(MessagePartInfo part, T reader) {
// TODO:Cache the JAXBRIContext
QName qname = new QName(null, part.getConcreteName().getLocalPart());
- return JAXBEncoderDecoder.unmarshalWithBridge(qname,
+ Object obj = JAXBEncoderDecoder.unmarshalWithBridge(qname,
part.getTypeClass(),
anns,
databinding.getContextClasses(),
reader,
getAttachmentUnmarshaller());
+
+ onCompleteUnmarshalling();
+
+ return obj;
}
}
- return JAXBEncoderDecoder.unmarshall(createUnmarshaller(), reader, part,
+ Object obj = JAXBEncoderDecoder.unmarshall(createUnmarshaller(), reader, part,
unwrapJAXBElement);
+ onCompleteUnmarshalling();
+
+ return obj;
}
public Object read(QName name, T input, Class<?> type) {
- return JAXBEncoderDecoder.unmarshall(createUnmarshaller(), input,
+ Object obj = JAXBEncoderDecoder.unmarshall(createUnmarshaller(), input,
name, type,
unwrapJAXBElement);
+ onCompleteUnmarshalling();
+
+ return obj;
}
+ private void onCompleteUnmarshalling() {
+ if (setEventHandler && veventHandler instanceof UnmarshallerEventHandler) {
+ try {
+ ((UnmarshallerEventHandler) veventHandler).onUnmarshalComplete();
+ } catch (UnmarshalException e) {
+ if (e.getLinkedException() != null) {
+ throw new Fault(new Message("UNMARSHAL_ERROR", LOG,
+ e.getLinkedException().getMessage()), e);
+ } else {
+ throw new Fault(new Message("UNMARSHAL_ERROR", LOG, e.getMessage()), e);
+ }
+ }
+ }
+ }
}
diff --git a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
index 3479108b319..0c26166d383 100644
--- a/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
+++ b/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
@@ -30,10 +30,12 @@
import java.util.logging.Logger;
import javax.xml.bind.JAXBException;
+import javax.xml.bind.MarshalException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.PropertyException;
import javax.xml.bind.ValidationEvent;
import javax.xml.bind.ValidationEventHandler;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.bind.attachment.AttachmentMarshaller;
import org.apache.cxf.common.i18n.Message;
@@ -45,6 +47,7 @@
import org.apache.cxf.jaxb.JAXBDataBase;
import org.apache.cxf.jaxb.JAXBDataBinding;
import org.apache.cxf.jaxb.JAXBEncoderDecoder;
+import org.apache.cxf.jaxb.MarshallerEventHandler;
import org.apache.cxf.jaxb.attachment.JAXBAttachmentMarshaller;
import org.apache.cxf.message.MessageUtils;
import org.apache.cxf.service.model.MessagePartInfo;
@@ -70,7 +73,8 @@ public void setProperty(String prop, Object value) {
if (prop.equals(org.apache.cxf.message.Message.class.getName())) {
org.apache.cxf.message.Message m = (org.apache.cxf.message.Message)value;
veventHandler = (ValidationEventHandler)m.getContextualProperty(
- "jaxb-writer-validation-event-handler");
+ JAXBDataBinding.WRITER_VALIDATION_EVENT_HANDLER);
+
if (veventHandler == null) {
veventHandler = (ValidationEventHandler)m.getContextualProperty(
"jaxb-validation-event-handler");
@@ -78,7 +82,8 @@ public void setProperty(String prop, Object value) {
if (veventHandler == null) {
veventHandler = databinding.getValidationEventHandler();
}
- setEventHandler = MessageUtils.getContextualBoolean(m, "set-jaxb-validation-event-handler", true);
+ setEventHandler = MessageUtils.getContextualBoolean(m,
+ JAXBDataBinding.SET_VALIDATION_EVENT_HANDLER, true);
}
}
@@ -92,11 +97,13 @@ public MtomValidationHandler(ValidationEventHandler v,
}
public boolean handleEvent(ValidationEvent event) {
+ // CXF-1194 this hack is specific to MTOM, so pretty safe to leave in here before calling the origHandler.
String msg = event.getMessage();
if (msg.startsWith("cvc-type.3.1.2: ")
&& msg.contains(marshaller.getLastMTOMElementName().getLocalPart())) {
return true;
}
+
if (origHandler != null) {
return origHandler.handleEvent(event);
}
@@ -104,6 +111,7 @@ public boolean handleEvent(ValidationEvent event) {
}
}
+
public Marshaller createMarshaller(Object elValue, MessagePartInfo part) {
Class<?> cls = null;
if (part != null) {
@@ -179,6 +187,9 @@ public boolean handleEvent(ValidationEvent event) {
throw new Fault(new Message("MARSHAL_ERROR", LOG, ex.getMessage()), ex);
}
}
+ for (XmlAdapter<?, ?> adapter : databinding.getConfiguredXmlAdapters()) {
+ marshaller.setAdapter(adapter);
+ }
return marshaller;
}
@@ -218,11 +229,13 @@ public void write(Object obj, MessagePartInfo part, T output) {
JAXBEncoderDecoder.marshallException(createMarshaller(obj, part),
(Exception)obj,
part,
- output);
+ output);
+ onCompleteMarshalling();
} else {
Annotation[] anns = getJAXBAnnotation(part);
if (!honorJaxbAnnotation || anns.length == 0) {
JAXBEncoderDecoder.marshall(createMarshaller(obj, part), obj, part, output);
+ onCompleteMarshalling();
} else if (honorJaxbAnnotation && anns.length > 0) {
//RpcLit will use the JAXB Bridge to marshall part message when it is
//annotated with @XmlList,@XmlAttachmentRef,@XmlJavaTypeAdapter
@@ -240,6 +253,8 @@ public void write(Object obj, MessagePartInfo part, T output) {
} else if (needToRender(part)) {
JAXBEncoderDecoder.marshallNullElement(createMarshaller(null, part),
output, part);
+
+ onCompleteMarshalling();
}
}
@@ -288,4 +303,18 @@ private boolean needToRender(MessagePartInfo part) {
return false;
}
+ private void onCompleteMarshalling() {
+ if (setEventHandler && veventHandler instanceof MarshallerEventHandler) {
+ try {
+ ((MarshallerEventHandler) veventHandler).onMarshalComplete();
+ } catch (MarshalException e) {
+ if (e.getLinkedException() != null) {
+ throw new Fault(new Message("MARSHAL_ERROR", LOG,
+ e.getLinkedException().getMessage()), e);
+ } else {
+ throw new Fault(new Message("MARSHAL_ERROR", LOG, e.getMessage()), e);
+ }
+ }
+ }
+ }
}
diff --git a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/DataBindingMarshallerPropertiesTest.java b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/DataBindingMarshallerPropertiesTest.java
new file mode 100644
index 00000000000..82b594bda0b
--- /dev/null
+++ b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/DataBindingMarshallerPropertiesTest.java
@@ -0,0 +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 org.apache.cxf.jaxb;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+public class DataBindingMarshallerPropertiesTest extends TestBase {
+ @Test
+ public void testInitializeUnmarshallerProperties() throws Exception {
+ JAXBDataBinding db = new JAXBDataBinding();
+ Map<String, Object> unmarshallerProperties = new HashMap<String, Object>();
+ unmarshallerProperties.put("someproperty", "somevalue");
+ db.setUnmarshallerProperties(unmarshallerProperties);
+
+ db.initialize(service);
+
+ assertTrue("somevalue".equals(db.getUnmarshallerProperties().get("someproperty")));
+ }
+}
diff --git a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/FixNamespacesXMLEventReader.java b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/FixNamespacesXMLEventReader.java
new file mode 100644
index 00000000000..9845ffc75fe
--- /dev/null
+++ b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/FixNamespacesXMLEventReader.java
@@ -0,0 +1,41 @@
+/**
+ * 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.apache.cxf.jaxb;
+
+import javax.xml.bind.Unmarshaller;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.util.EventReaderDelegate;
+
+public class FixNamespacesXMLEventReader extends EventReaderDelegate implements UnmarshallerAwareXMLReader {
+ private Unmarshaller unmarshaller;
+
+ public FixNamespacesXMLEventReader(final XMLEventReader delegate) {
+ super(delegate);
+ }
+
+ @Override
+ public void setUnmarshaller(Unmarshaller unmarshaller) {
+ this.unmarshaller = unmarshaller;
+ }
+
+ public Unmarshaller getUnmarshaller() {
+ return unmarshaller;
+ }
+}
diff --git a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/FixNamespacesXMLEventWriter.java b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/FixNamespacesXMLEventWriter.java
new file mode 100644
index 00000000000..cae032b9642
--- /dev/null
+++ b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/FixNamespacesXMLEventWriter.java
@@ -0,0 +1,81 @@
+/**
+ * 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.apache.cxf.jaxb;
+
+import javax.xml.bind.Marshaller;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.XMLEvent;
+
+public class FixNamespacesXMLEventWriter implements XMLEventWriter, MarshallerAwareXMLWriter {
+ private final XMLEventWriter delegate;
+ private Marshaller marshaller;
+
+ public FixNamespacesXMLEventWriter(XMLEventWriter delegate) {
+ this.delegate = delegate;
+ }
+
+ public void flush() throws XMLStreamException {
+ delegate.flush();
+ }
+
+ public void close() throws XMLStreamException {
+ delegate.close();
+ }
+
+ public void add(XMLEvent event) throws XMLStreamException {
+ delegate.add(event);
+ }
+
+ public void add(XMLEventReader reader) throws XMLStreamException {
+ delegate.add(reader);
+ }
+
+ public String getPrefix(String uri) throws XMLStreamException {
+ return delegate.getPrefix(uri);
+ }
+
+ public void setPrefix(String prefix, String uri) throws XMLStreamException {
+ delegate.setPrefix(prefix, uri);
+ }
+
+ public void setDefaultNamespace(String uri) throws XMLStreamException {
+ delegate.setDefaultNamespace(uri);
+ }
+
+ public void setNamespaceContext(NamespaceContext context) throws XMLStreamException {
+ delegate.setNamespaceContext(context);
+ }
+
+ public NamespaceContext getNamespaceContext() {
+ return delegate.getNamespaceContext();
+ }
+
+ @Override
+ public void setMarshaller(Marshaller marshaller) {
+ this.marshaller = marshaller;
+ }
+
+ public Marshaller getMarshaller() {
+ return marshaller;
+ }
+}
diff --git a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/FixNamespacesXMLStreamReader.java b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/FixNamespacesXMLStreamReader.java
new file mode 100644
index 00000000000..200f9cf819d
--- /dev/null
+++ b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/FixNamespacesXMLStreamReader.java
@@ -0,0 +1,41 @@
+/**
+ * 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.apache.cxf.jaxb;
+
+import javax.xml.bind.Unmarshaller;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.util.StreamReaderDelegate;
+
+public class FixNamespacesXMLStreamReader extends StreamReaderDelegate implements UnmarshallerAwareXMLReader {
+ private Unmarshaller unmarshaller;
+
+ public FixNamespacesXMLStreamReader(final XMLStreamReader delegate) {
+ super(delegate);
+ }
+
+ @Override
+ public void setUnmarshaller(Unmarshaller unmarshaller) {
+ this.unmarshaller = unmarshaller;
+ }
+
+ public Unmarshaller getUnmarshaller() {
+ return unmarshaller;
+ }
+}
diff --git a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/FixNamespacesXMLStreamWriter.java b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/FixNamespacesXMLStreamWriter.java
new file mode 100644
index 00000000000..10c5a18db12
--- /dev/null
+++ b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/FixNamespacesXMLStreamWriter.java
@@ -0,0 +1,42 @@
+/**
+ * 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.apache.cxf.jaxb;
+
+import javax.xml.bind.Marshaller;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.codehaus.stax2.util.StreamWriterDelegate;
+
+public class FixNamespacesXMLStreamWriter extends StreamWriterDelegate implements MarshallerAwareXMLWriter {
+ private Marshaller marshaller;
+
+ public FixNamespacesXMLStreamWriter(final XMLStreamWriter delegate) {
+ super(delegate);
+ }
+
+ @Override
+ public void setMarshaller(Marshaller marshaller) {
+ this.marshaller = marshaller;
+ }
+
+ public Marshaller getMarshaller() {
+ return marshaller;
+ }
+}
diff --git a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java
index 791525f4e58..4621481c37b 100644
--- a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java
+++ b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java
@@ -20,7 +20,9 @@
package org.apache.cxf.jaxb;
+import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
+import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
@@ -36,8 +38,13 @@
import javax.wsdl.Service;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
@@ -241,5 +248,84 @@ public void testResursiveType() throws Exception {
}
public interface Addressable<T extends AddressEntity<T>> {
- }
+ }
+
+ @Test
+ public void testConfiguredXmlAdapter() throws Exception {
+ Language dutch = new Language("nl_NL", "Dutch");
+ Language americanEnglish = new Language("en_US", "Americanish");
+
+ Person person = new Person(dutch);
+ JAXBDataBinding binding = new JAXBDataBinding(Person.class, Language.class);
+ binding.setConfiguredXmlAdapters(Arrays.<XmlAdapter<?, ?>>asList(new LanguageAdapter(dutch, americanEnglish)));
+ DataWriter<OutputStream> writer = binding.createWriter(OutputStream.class);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ writer.write(person, baos);
+ String output = baos.toString();
+ String xml = "<person motherTongue=\"nl_NL\"/>";
+
+ assertEquals(xml, output);
+
+ DataReader<XMLStreamReader> reader = binding.createReader(XMLStreamReader.class);
+ Person read = (Person) reader.read(XMLInputFactory.newFactory().createXMLStreamReader(new StringReader(xml)));
+
+ assertEquals(dutch, read.getMotherTongue());
+
+ }
+
+ @XmlRootElement
+ public static class Person {
+ @XmlAttribute
+ @XmlJavaTypeAdapter(LanguageAdapter.class)
+ private final Language motherTongue;
+ public Person() {
+ this(null);
+ }
+ public Person(Language motherTongue) {
+ this.motherTongue = motherTongue;
+ }
+ public Language getMotherTongue() {
+ return motherTongue;
+ }
+ }
+
+ public static class Language {
+ private final String code;
+ private final String name;
+ public Language() {
+ this(null, null);
+ }
+ public Language(String code, String name) {
+ this.code = code;
+ this.name = name;
+ }
+ public String getCode() {
+ return code;
+ }
+ public String getName() {
+ return name;
+ }
+ }
+
+ public static class LanguageAdapter extends XmlAdapter<String, Language> {
+
+ private Map<String, Language> knownLanguages = new HashMap<String, Language>();
+
+ public LanguageAdapter(Language... languages) {
+ for (Language language : languages) {
+ knownLanguages.put(language.getCode(), language);
+ }
+ }
+
+ @Override
+ public String marshal(Language language) throws Exception {
+ return language.getCode();
+ }
+
+ @Override
+ public Language unmarshal(String code) throws Exception {
+ return knownLanguages.get(code);
+ }
+
+ }
}
diff --git a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java
index c4b89e78d9c..d4cabb946f2 100644
--- a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java
+++ b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java
@@ -66,7 +66,6 @@
import org.apache.hello_world_soap_http.types.GreetMe;
import org.apache.hello_world_soap_http.types.GreetMeResponse;
import org.apache.hello_world_soap_http.types.StringStruct;
-
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -256,7 +255,7 @@ public void testCustomNamespaces() throws Exception {
}
@Test
- public void testMarshallIntoStax() throws Exception {
+ public void testMarshallIntoStaxStreamWriter() throws Exception {
GreetMe obj = new GreetMe();
obj.setRequestType("Hello");
QName elName = new QName(wrapperAnnotation.targetNamespace(),
@@ -268,11 +267,50 @@ public void testMarshallIntoStax() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLOutputFactory opFactory = XMLOutputFactory.newInstance();
opFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
- XMLEventWriter writer = opFactory.createXMLEventWriter(baos);
-
+ FixNamespacesXMLStreamWriter writer = new FixNamespacesXMLStreamWriter(opFactory.createXMLStreamWriter(baos));
+
+ assertNull(writer.getMarshaller());
+
+ Marshaller m = context.createMarshaller();
+ JAXBEncoderDecoder.marshall(m, obj, part, writer);
+ assertEquals(m, writer.getMarshaller());
+ writer.flush();
+ writer.close();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ XMLInputFactory ipFactory = XMLInputFactory.newInstance();
+ XMLEventReader reader = ipFactory.createXMLEventReader(bais);
+
+ Unmarshaller um = context.createUnmarshaller();
+ Object val = um.unmarshal(reader, GreetMe.class);
+ assertTrue(val instanceof JAXBElement);
+ val = ((JAXBElement<?>)val).getValue();
+ assertTrue(val instanceof GreetMe);
+ assertEquals(obj.getRequestType(),
+ ((GreetMe)val).getRequestType());
+ }
+
+ @Test
+ public void testMarshallIntoStaxEventWriter() throws Exception {
+ GreetMe obj = new GreetMe();
+ obj.setRequestType("Hello");
+ QName elName = new QName(wrapperAnnotation.targetNamespace(),
+ wrapperAnnotation.localName());
+ MessagePartInfo part = new MessagePartInfo(elName, null);
+ part.setElement(true);
+ part.setElementQName(elName);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ XMLOutputFactory opFactory = XMLOutputFactory.newInstance();
+ opFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+ FixNamespacesXMLEventWriter writer = new FixNamespacesXMLEventWriter(opFactory.createXMLEventWriter(baos));
+ assertNull(writer.getMarshaller());
+
//STARTDOCUMENT/ENDDOCUMENT is not required
- //writer.add(eFactory.createStartDocument("utf-8", "1.0"));
- JAXBEncoderDecoder.marshall(context.createMarshaller(), obj, part, writer);
+ //writer.add(eFactory.createStartDocument("utf-8", "1.0"));
+ Marshaller m = context.createMarshaller();
+ JAXBEncoderDecoder.marshall(m, obj, part, writer);
+ assertEquals(m, writer.getMarshaller());
//writer.add(eFactory.createEndDocument());
writer.flush();
writer.close();
@@ -293,24 +331,52 @@ public void testMarshallIntoStax() throws Exception {
}
@Test
- public void testUnmarshallFromStax() throws Exception {
+ public void testUnmarshallFromStaxStreamReader() throws Exception {
QName elName = new QName(wrapperAnnotation.targetNamespace(),
wrapperAnnotation.localName());
MessagePartInfo part = new MessagePartInfo(elName, null);
InputStream is = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml");
XMLInputFactory factory = XMLInputFactory.newInstance();
- XMLStreamReader reader =
- factory.createXMLStreamReader(is);
-
+ XMLStreamReader reader = factory.createXMLStreamReader(is);
+
QName[] tags = {SOAP_ENV, SOAP_BODY};
StaxStreamFilter filter = new StaxStreamFilter(tags);
- reader = factory.createFilteredReader(reader, filter);
+ FixNamespacesXMLStreamReader filteredReader = new FixNamespacesXMLStreamReader(
+ factory.createFilteredReader(reader, filter));
+ assertNull(filteredReader.getUnmarshaller());
+
//Remove START_DOCUMENT & START_ELEMENT pertaining to Envelope and Body Tags.
part.setTypeClass(GreetMe.class);
- Object val = JAXBEncoderDecoder.unmarshall(context.createUnmarshaller(), reader, part, true);
+ Unmarshaller um = context.createUnmarshaller();
+ Object val = JAXBEncoderDecoder.unmarshall(um, filteredReader, part, true);
+ assertEquals(um, filteredReader.getUnmarshaller());
+ assertNotNull(val);
+ assertTrue(val instanceof GreetMe);
+ assertEquals("TestSOAPInputPMessage",
+ ((GreetMe)val).getRequestType());
+
+ is.close();
+ }
+
+ @Test
+ public void testUnmarshallFromStaxEventReader() throws Exception {
+ QName elName = new QName(wrapperAnnotation.targetNamespace(),
+ wrapperAnnotation.localName());
+ MessagePartInfo part = new MessagePartInfo(elName, null);
+
+ InputStream is = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml");
+ XMLInputFactory factory = XMLInputFactory.newInstance();
+ FixNamespacesXMLEventReader reader = new FixNamespacesXMLEventReader(factory.createXMLEventReader(is));
+
+ assertNull(reader.getUnmarshaller());
+
+ part.setTypeClass(GreetMe.class);
+ Unmarshaller um = context.createUnmarshaller();
+ Object val = JAXBEncoderDecoder.unmarshall(um, reader, part, true);
+ assertEquals(um, reader.getUnmarshaller());
assertNotNull(val);
assertTrue(val instanceof GreetMe);
assertEquals("TestSOAPInputPMessage",
diff --git a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/MyCustomMarshallerHandler.java b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/MyCustomMarshallerHandler.java
new file mode 100644
index 00000000000..c494dfab0d5
--- /dev/null
+++ b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/MyCustomMarshallerHandler.java
@@ -0,0 +1,72 @@
+/**
+ * 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.apache.cxf.jaxb.io;
+
+import javax.xml.bind.MarshalException;
+import javax.xml.bind.UnmarshalException;
+import javax.xml.bind.ValidationEvent;
+import javax.xml.bind.util.ValidationEventCollector;
+
+import org.apache.cxf.jaxb.MarshallerEventHandler;
+import org.apache.cxf.jaxb.UnmarshallerEventHandler;
+
+public class MyCustomMarshallerHandler extends ValidationEventCollector implements
+ UnmarshallerEventHandler, MarshallerEventHandler {
+ private boolean used;
+ private boolean onMarshalComplete;
+ private boolean onUnmarshalComplete;
+
+ public boolean getUsed() {
+ return used;
+ }
+
+ public boolean isOnMarshalComplete() {
+ return onMarshalComplete;
+ }
+
+ public boolean isOnUnmarshalComplete() {
+ return onUnmarshalComplete;
+ }
+
+ public boolean handleEvent(ValidationEvent event) {
+ super.handleEvent(event);
+
+ used = true;
+ return true;
+ }
+
+ @Override
+ public void onUnmarshalComplete() throws UnmarshalException {
+ this.onUnmarshalComplete = true;
+
+ if (hasEvents()) {
+ throw new UnmarshalException("My unmarshalling exception");
+ }
+ }
+
+ @Override
+ public void onMarshalComplete() throws MarshalException {
+ this.onMarshalComplete = true;
+
+ if (hasEvents()) {
+ throw new MarshalException("My marshalling exception");
+ }
+ }
+}
\ No newline at end of file
diff --git a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/XMLStreamDataReaderTest.java b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/XMLStreamDataReaderTest.java
index b178764e386..f4d3405d8ab 100644
--- a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/XMLStreamDataReaderTest.java
+++ b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/XMLStreamDataReaderTest.java
@@ -23,11 +23,13 @@
import java.io.InputStream;
import javax.xml.bind.JAXBContext;
+import javax.xml.bind.ValidationEventHandler;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import org.apache.cxf.databinding.DataReader;
+import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.jaxb.JAXBDataBinding;
import org.apache.cxf.service.model.MessagePartInfo;
import org.apache.cxf.staxutils.StaxStreamFilter;
@@ -58,6 +60,39 @@ public void tearDown() throws IOException {
@Test
public void testSetProperty() throws Exception {
+ MyCustomHandler handler = new MyCustomHandler();
+
+ DataReaderImpl<XMLStreamReader> dr = newDataReader(handler);
+
+ // Should fail if custom handler doesn't skip formatting error
+ Object val = dr.read(reader);
+ assertTrue(val instanceof GreetMe);
+ assertEquals("TestSOAPInputPMessage", ((GreetMe)val).getRequestType());
+
+ assertTrue(handler.getUsed());
+ }
+
+ @Test
+ public void testSetPropertyWithCustomExceptionHandling() throws Exception {
+ MyCustomMarshallerHandler handler = new MyCustomMarshallerHandler();
+
+ DataReaderImpl<XMLStreamReader> dr = newDataReader(handler);
+
+ // Should fail if custom handler doesn't skip formatting error
+ try {
+ dr.read(reader);
+ fail("Expected exception");
+ } catch (Fault f) {
+ assertTrue(f.getMessage().contains("My unmarshalling exception"));
+ }
+
+ // Check handler used
+ assertTrue(handler.getUsed());
+ assertFalse(handler.isOnMarshalComplete());
+ assertTrue(handler.isOnUnmarshalComplete());
+ }
+
+ private DataReaderImpl<XMLStreamReader> newDataReader(ValidationEventHandler handler) throws Exception {
JAXBDataBinding db = getDataBinding(GreetMe.class);
reader = getTestReader("../resources/SetPropertyValidationFailureReq.xml");
@@ -68,18 +103,12 @@ public void testSetProperty() throws Exception {
// Build message to set custom event handler
org.apache.cxf.message.Message message = new org.apache.cxf.message.MessageImpl();
- message.put("jaxb-validation-event-handler", new MyCustomHandler());
+ message.put(JAXBDataBinding.READER_VALIDATION_EVENT_HANDLER, handler);
message.put("unwrap.jaxb.element", true);
dr.setProperty("org.apache.cxf.message.Message", message);
- // Should fail if custom handler doesn't skip formatting error
- Object val = dr.read(reader);
- assertTrue(val instanceof GreetMe);
- assertEquals("TestSOAPInputPMessage", ((GreetMe)val).getRequestType());
-
- // Check handler used
- assertTrue(((MyCustomHandler)dr.veventHandler).getUsed());
+ return dr;
}
@Test
diff --git a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/XMLStreamDataWriterTest.java b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/XMLStreamDataWriterTest.java
index 95c6c9844f2..420c84393b0 100644
--- a/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/XMLStreamDataWriterTest.java
+++ b/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/io/XMLStreamDataWriterTest.java
@@ -26,6 +26,7 @@
import java.util.Map;
import javax.xml.bind.JAXBContext;
+import javax.xml.bind.ValidationEventHandler;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
@@ -33,6 +34,7 @@
import javax.xml.stream.XMLStreamWriter;
import org.apache.cxf.databinding.DataWriter;
+import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.jaxb.JAXBDataBinding;
import org.apache.cxf.service.model.MessagePartInfo;
import org.apache.cxf.staxutils.DepthXMLStreamReader;
@@ -48,7 +50,6 @@
import org.junit.Test;
public class XMLStreamDataWriterTest extends Assert {
-
private ByteArrayOutputStream baos;
private XMLStreamWriter streamWriter;
private XMLInputFactory inFactory;
@@ -66,7 +67,73 @@ public void setUp() throws Exception {
public void tearDown() throws Exception {
baos.close();
}
+
+ @Test
+ public void testSetProperty() throws Exception {
+ MyCustomHandler handler = new MyCustomHandler();
+
+ DataWriterImpl<XMLStreamWriter> dw = newDataWriter(handler);
+ // Write Stuff
+ TradePriceData val = new TradePriceData();
+ val.setTickerSymbol("This is a symbol");
+ val.setTickerPrice(1.0f);
+
+ QName elName = new QName("http://apache.org/hello_world_doc_lit_bare/types", "inout");
+ MessagePartInfo part = new MessagePartInfo(elName, null);
+ part.setElement(true);
+ part.setElementQName(elName);
+ dw.write(val, part, streamWriter);
+ streamWriter.flush();
+
+ // Test MyCustomHandler
+ assertTrue(handler.getUsed());
+ }
+
+ @Test
+ public void testSetPropertyWithCustomExceptionHandling() throws Exception {
+ MyCustomMarshallerHandler handler = new MyCustomMarshallerHandler();
+
+ DataWriterImpl<XMLStreamWriter> dw = newDataWriter(handler);
+ // Write Stuff
+ TradePriceData val = new TradePriceData();
+ val.setTickerSymbol("This is a symbol");
+ val.setTickerPrice(1.0f);
+
+ QName elName = new QName("http://apache.org/hello_world_doc_lit_bare/types", "inout");
+ MessagePartInfo part = new MessagePartInfo(elName, null);
+ part.setElement(true);
+ part.setElementQName(elName);
+
+ try {
+ dw.write(val, part, streamWriter);
+ streamWriter.flush();
+ fail("Expected exception");
+ } catch (Fault f) {
+ assertTrue(f.getMessage().contains("My marshalling exception"));
+ }
+
+ // Test MyCustomHandler
+ assertTrue(handler.getUsed());
+ assertTrue(handler.isOnMarshalComplete());
+ assertFalse(handler.isOnUnmarshalComplete());
+ }
+
+ private DataWriterImpl<XMLStreamWriter> newDataWriter(ValidationEventHandler handler) throws Exception {
+ JAXBDataBinding db = getTestWriterFactory();
+
+ DataWriterImpl<XMLStreamWriter> dw = (DataWriterImpl<XMLStreamWriter>)db.createWriter(XMLStreamWriter.class);
+ assertNotNull(dw);
+
+ // Build message to set custom event handler
+ org.apache.cxf.message.Message message = new org.apache.cxf.message.MessageImpl();
+ message.put(JAXBDataBinding.WRITER_VALIDATION_EVENT_HANDLER, handler);
+
+ dw.setProperty("org.apache.cxf.message.Message", message);
+
+ return dw;
+ }
+
@Test
public void testWriteRPCLit1() throws Exception {
JAXBDataBinding db = getTestWriterFactory();
diff --git a/rt/databinding/jibx/pom.xml b/rt/databinding/jibx/pom.xml
index 9396e54d925..26e759ce509 100644
--- a/rt/databinding/jibx/pom.xml
+++ b/rt/databinding/jibx/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
<dependencies>
diff --git a/rt/databinding/sdo/pom.xml b/rt/databinding/sdo/pom.xml
index 723d0a7d6de..449ff929564 100644
--- a/rt/databinding/sdo/pom.xml
+++ b/rt/databinding/sdo/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
<properties>
diff --git a/rt/databinding/xmlbeans/pom.xml b/rt/databinding/xmlbeans/pom.xml
index bdcdbe586d0..6684a7b88ef 100644
--- a/rt/databinding/xmlbeans/pom.xml
+++ b/rt/databinding/xmlbeans/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
<properties>
diff --git a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansWrapperHelper.java b/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansWrapperHelper.java
index 55ed32a6dc6..6b41ebe08ce 100644
--- a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansWrapperHelper.java
+++ b/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansWrapperHelper.java
@@ -28,20 +28,10 @@
public class XmlBeansWrapperHelper extends AbstractWrapperHelper {
- private boolean validate;
-
public XmlBeansWrapperHelper(Class<?> wt, Method[] sets, Method[] gets, Field[] f) {
super(wt, sets, gets, f);
}
-
- public void setValidate(boolean v) {
- validate = v;
- }
-
- public boolean getValidate() {
- return validate;
- }
@Override
protected Object createWrapperObject(Class<?> typeClass) throws Exception {
diff --git a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java b/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
index a1a99baaa17..3bbedcf03f0 100644
--- a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
+++ b/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
@@ -42,6 +42,7 @@
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
+import org.apache.cxf.common.jaxb.JAXBUtils;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.tools.common.ToolConstants;
@@ -50,6 +51,7 @@
import org.apache.cxf.tools.common.model.DefaultValueWriter;
import org.apache.cxf.tools.util.ClassCollector;
import org.apache.cxf.tools.wsdlto.core.DataBindingProfile;
+import org.apache.ws.commons.schema.constants.Constants;
import org.apache.xmlbeans.SchemaGlobalElement;
import org.apache.xmlbeans.SchemaProperty;
import org.apache.xmlbeans.SchemaType;
@@ -144,6 +146,9 @@ public String getType(QName qn, boolean element) {
if (type == null) {
type = typeLoader.findDocumentType(qn);
}
+ if (type == null) {
+ return null;
+ }
ret = type.getFullJavaName();
if (ret.contains("$")) {
@@ -157,6 +162,13 @@ public String getType(QName qn, boolean element) {
type = typeLoader.findType(qn);
}
+ if (type == null
+ && Constants.URI_2001_SCHEMA_XSD.equals(qn.getNamespaceURI())) {
+ return JAXBUtils.builtInTypeToJavaType(qn.getLocalPart());
+ }
+ if (type == null) {
+ return null;
+ }
ret = type.getFullJavaName();
return ret.replace('$', '.');
}
diff --git a/rt/features/clustering/pom.xml b/rt/features/clustering/pom.xml
index 231cbd6aa0c..d236aa592c5 100644
--- a/rt/features/clustering/pom.xml
+++ b/rt/features/clustering/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
<properties>
diff --git a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/blueprint/ClusteringBPNamespaceHandler.java b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/blueprint/ClusteringBPNamespaceHandler.java
index 8e67e51a64c..a98aa9e8827 100644
--- a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/blueprint/ClusteringBPNamespaceHandler.java
+++ b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/blueprint/ClusteringBPNamespaceHandler.java
@@ -27,7 +27,7 @@
import org.apache.aries.blueprint.NamespaceHandler;
import org.apache.aries.blueprint.ParserContext;
import org.apache.cxf.clustering.FailoverFeature;
-import org.apache.cxf.clustering.LoadDistributorTargetSelector;
+import org.apache.cxf.clustering.LoadDistributorFeature;
import org.apache.cxf.configuration.blueprint.SimpleBPBeanDefinitionParser;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
import org.osgi.service.blueprint.reflect.Metadata;
@@ -36,22 +36,22 @@
public ComponentMetadata decorate(Node node, ComponentMetadata component, ParserContext context) {
return null;
}
-
+
public Metadata parse(Element element, ParserContext context) {
String s = element.getLocalName();
if ("failover".equals(s)) {
return new SimpleBPBeanDefinitionParser(FailoverFeature.class).parse(element, context);
} else if ("loadDistributor".equals(s)) {
- return new SimpleBPBeanDefinitionParser(LoadDistributorTargetSelector.class).parse(element, context);
+ return new SimpleBPBeanDefinitionParser(LoadDistributorFeature.class).parse(element, context);
}
return null;
}
-
+
@SuppressWarnings("rawtypes")
public Set<Class> getManagedClasses() {
return null;
}
-
+
public URL getSchemaLocation(String namespace) {
return getClass().getClassLoader().getResource("schemas/clustering.xsd");
}
diff --git a/rt/frontend/jaxrs/pom.xml b/rt/frontend/jaxrs/pom.xml
index 08650dc249d..7a4ed668423 100644
--- a/rt/frontend/jaxrs/pom.xml
+++ b/rt/frontend/jaxrs/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
- <version>3.0.2-SNAPSHOT</version>
+ <version>3.0.6-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
<properties>
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
index 4ee01272f17..b9dfbbf6047 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
@@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -70,6 +71,7 @@
protected List<String> schemaLocations;
protected JAXRSServiceFactoryBean serviceFactory;
protected List<Object> entityProviders = new LinkedList<Object>();
+ private Comparator<?> providerComparator;
protected AbstractJAXRSFactoryBean(JAXRSServiceFactoryBean serviceFactory) {
this.serviceFactory = serviceFactory;
@@ -302,8 +304,7 @@ protected void checkResources(boolean server) {
if (server) {
for (Iterator<ClassResourceInfo> it = list.iterator(); it.hasNext();) {
ClassResourceInfo cri = it.next();
- if (cri.isCreatedFromModel() && cri.getServiceClass() == cri.getResourceClass()
- && !InjectionUtils.isConcreteClass(cri.getServiceClass())) {
+ if (!isValidClassResourceInfo(cri)) {
it.remove();
}
}
@@ -317,7 +318,16 @@ protected void checkResources(boolean server) {
}
}
+ protected boolean isValidClassResourceInfo(ClassResourceInfo cri) {
+ Class<?> serviceCls = cri.getServiceClass();
+ return !(cri.isCreatedFromModel() && serviceCls == cri.getResourceClass()
+ && !InjectionUtils.isConcreteClass(serviceCls));
+ }
+
protected void setupFactory(ProviderFactory factory, Endpoint ep) {
+ if (providerComparator != null) {
+ factory.setProviderComparator(providerComparator);
+ }
if (entityProviders != null) {
factory.setUserProviders(entityProviders);
}
@@ -421,6 +431,10 @@ public void setModelRefWithServiceClass(String modelRef, Class<?>... sClasses) {
serviceFactory.setUserResourcesWithServiceClass(resources, sClasses);
}
}
+
+ public void setProviderComparator(Comparator<?> providerComparator) {
+ this.providerComparator = providerComparator;
+ }
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSBinding.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSBinding.java
index 1f74030c848..92687e82bce 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSBinding.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSBinding.java
@@ -52,9 +52,6 @@ public BindingInfo getBindingInfo() {
if (exchange != null) {
ct = (String)exchange.get(org.apache.cxf.message.Message.CONTENT_TYPE);
}
- if (ct == null) {
- ct = "text/xml";
- }
m.put(org.apache.cxf.message.Message.CONTENT_TYPE, ct);
}
return m;
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
index 135ac8d41ed..086300da13c 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
@@ -235,7 +235,7 @@ public Object invoke(Exchange exchange, Object request, Object resourceObject) {
result = checkResultObject(result, subResourcePath);
subCri = cri.getSubResource(methodToInvoke.getReturnType(),
- ClassHelper.getRealClass(result), result);
+ ClassHelper.getRealClass(exchange.getBus(), result), result);
if (subCri == null) {
org.apache.cxf.common.i18n.Message errorM =
new org.apache.cxf.common.i18n.Message("NO_SUBRESOURCE_FOUND",
@@ -255,11 +255,11 @@ public Object invoke(Exchange exchange, Object request, Object resourceObject) {
exchange.put(OperationResourceInfo.class, subOri);
inMessage.put(URITemplate.TEMPLATE_PARAMETERS, values);
- if (JAXRSUtils.runContainerRequestFilters(providerFactory,
- inMessage,
- false,
- subOri.getNameBindings(),
- true)) {
+ if (!subOri.isSubResourceLocator()
+ && JAXRSUtils.runContainerRequestFilters(providerFactory,
+ inMessage,
+ false,
+ subOri.getNameBindings())) {
return new MessageContentsList(exchange.get(Response.class));
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
index a49e0a35689..1c3564704d3 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
@@ -44,8 +44,8 @@
import org.apache.cxf.jaxrs.impl.RequestPreprocessor;
import org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider;
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
+import org.apache.cxf.jaxrs.model.ApplicationInfo;
import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.jaxrs.model.ProviderInfo;
import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
import org.apache.cxf.jaxrs.utils.AnnotationUtils;
import org.apache.cxf.jaxrs.utils.InjectionUtils;
@@ -81,7 +81,7 @@
private Map<Object, Object> languageMappings;
private Map<Object, Object> extensionMappings;
private ResourceComparator rc;
- private ProviderInfo<Application> appProvider;
+ private ApplicationInfo appProvider;
private String documentLocation;
public JAXRSServerFactoryBean() {
@@ -97,8 +97,13 @@ public JAXRSServerFactoryBean(JAXRSServiceFactoryBean sf) {
* @param app
*/
public void setApplication(Application app) {
- appProvider = new ProviderInfo<Application>(app, getBus());
- Set<String> appNameBindings = AnnotationUtils.getNameBindings(app.getClass().getAnnotations());
+ setApplication(new ApplicationInfo(app, getBus()));
+ }
+
+ public void setApplication(ApplicationInfo provider) {
+ appProvider = provider;
+ Set<String> appNameBindings = AnnotationUtils.getNameBindings(provider.getProvider()
+ .getClass().getAnnotations());
for (ClassResourceInfo cri : getServiceFactory().getClassResourceInfo()) {
Set<String> clsNameBindings = new LinkedHashSet<String>(appNameBindings);
clsNameBindings.addAll(AnnotationUtils.getNameBindings(cri.getServiceClass().getAnnotations()));
@@ -393,7 +398,7 @@ public void setStart(boolean start) {
this.start = start;
}
- private void injectContexts() {
+ protected void injectContexts() {
Application application = appProvider == null ? null : appProvider.getProvider();
for (ClassResourceInfo cri : serviceFactory.getClassResourceInfo()) {
if (cri.isSingleton()) {
@@ -408,7 +413,7 @@ private void injectContexts() {
}
}
- private void updateClassResourceProviders() {
+ protected void updateClassResourceProviders() {
for (ClassResourceInfo cri : serviceFactory.getClassResourceInfo()) {
if (cri.getResourceProvider() != null) {
continue;
@@ -418,14 +423,16 @@ private void updateClassResourceProviders() {
if (rp != null) {
cri.setResourceProvider(rp);
} else {
- //default lifecycle is per-request
- rp = new PerRequestResourceProvider(cri.getResourceClass());
- cri.setResourceProvider(rp);
+ setDefaultResourceProvider(cri);
}
}
injectContexts();
}
+ protected void setDefaultResourceProvider(ClassResourceInfo cri) {
+ cri.setResourceProvider(new PerRequestResourceProvider(cri.getResourceClass()));
+ }
+
/**
* Set the reference to the document (WADL, etc) describing the endpoint
* @param documentLocation document location
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
index b9da272786e..b6741852a47 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
@@ -57,6 +57,8 @@
private Executor executor;
private boolean enableStatic;
private QName serviceName;
+
+ private Class<?> defaultModelClass;
public JAXRSServiceFactoryBean() {
}
@@ -171,7 +173,10 @@ public void setUserResources(List<UserResource> resources) {
Map<String, UserResource> map = userResourcesAsMap(resources);
for (UserResource ur : resources) {
if (ur.getPath() != null) {
- ClassResourceInfo cri = ResourceUtils.createClassResourceInfo(map, ur, true, enableStatic,
+ ClassResourceInfo cri = ResourceUtils.createClassResourceInfo(map, ur,
+ defaultModelClass,
+ true,
+ enableStatic,
getBus());
if (cri != null) {
classResourceInfos.add(cri);
@@ -215,7 +220,7 @@ public void setResourceClasses(Class<?>... classes) {
public void setResourceClassesFromBeans(List<Object> beans) {
for (Object bean : beans) {
- Class<?> realClass = ClassHelper.getRealClass(bean);
+ Class<?> realClass = ClassHelper.getRealClass(getBus(), bean);
ClassResourceInfo cri = getCreatedFromModel(realClass);
if (cri != null) {
@@ -265,4 +270,12 @@ protected Invoker createInvoker() {
public void setService(Service service) {
super.setService(service);
}
+
+ public Class<?> getDefaultModelClass() {
+ return defaultModelClass;
+ }
+
+ public void setDefaultModelClass(Class<?> defaultModelClass) {
+ this.defaultModelClass = defaultModelClass;
+ }
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/DefaultMethod.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/DefaultMethod.java
new file mode 100644
index 00000000000..c996a157937
--- /dev/null
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/DefaultMethod.java
@@ -0,0 +1,33 @@
+/**
+ * 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.apache.cxf.jaxrs.ext;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.ws.rs.HttpMethod;
+
+@Target({ElementType.METHOD })
+@Retention(RetentionPolicy.RUNTIME)
+@HttpMethod("DefaultMethod")
+public @interface DefaultMethod {
+
+}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ResourceContextProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ResourceContextProvider.java
new file mode 100644
index 00000000000..0f2cc7ecb95
--- /dev/null
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ResourceContextProvider.java
@@ -0,0 +1,25 @@
+/**
+ * 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.apache.cxf.jaxrs.ext;
+
+import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
+
+public interface ResourceContextProvider {
+ ResourceProvider getResourceProvider(Class<?> cls);
+}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ResponseStatus.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ResponseStatus.java
new file mode 100644
index 00000000000..dc1f8ed9a36
--- /dev/null
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ResponseStatus.java
@@ -0,0 +1,33 @@
+/**
+ * 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.apache.cxf.jaxrs.ext;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.ws.rs.core.Response;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD })
+public @interface ResponseStatus {
+ Response.Status[] value();
+}
+
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AsyncResponseImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AsyncResponseImpl.java
index 69ba8380ba8..773faaf831e 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AsyncResponseImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AsyncResponseImpl.java
@@ -54,6 +54,7 @@
private volatile boolean done;
private boolean resumedByApplication;
private TimeoutHandler timeoutHandler;
+ private Long pendingTimeout;
private List<CompletionCallback> completionCallbacks = new LinkedList<CompletionCallback>();
private List<ConnectionCallback> connectionCallbacks = new LinkedList<ConnectionCallback>();
@@ -85,6 +86,9 @@ private synchronized boolean doResume(Object response) {
if (isCancelledOrNotSuspended()) {
return false;
}
+ return doResumeFinal(response);
+ }
+ private synchronized boolean doResumeFinal(Object response) {
inMessage.getExchange().put(AsyncResponse.class, this);
cont.setObject(response);
resumedByApplication = true;
@@ -112,6 +116,9 @@ public boolean cancel(Date retryAfter) {
}
private synchronized boolean doCancel(String retryAfterHeader) {
+ if (cancelled) {
+ return true;
+ }
if (!isSuspended()) {
return false;
}
@@ -119,13 +126,16 @@ private synchronized boolean doCancel(String retryAfterHeader) {
if (retryAfterHeader != null) {
rb.header(HttpHeaders.RETRY_AFTER, retryAfterHeader);
}
- doResume(rb.build());
cancelled = true;
+ doResumeFinal(rb.build());
return cancelled;
}
@Override
public synchronized boolean isSuspended() {
+ if (cancelled || resumedByApplication) {
+ return false;
+ }
return initialSuspend || cont.isPending();
}
@@ -144,13 +154,22 @@ public synchronized boolean setTimeout(long time, TimeUnit unit) throws IllegalS
if (isCancelledOrNotSuspended()) {
return false;
}
- inMessage.getExchange().put(AsyncResponse.class, this);
+ setAsyncResponseOnExchange();
long timeout = TimeUnit.MILLISECONDS.convert(time, unit);
initialSuspend = false;
- cont.suspend(timeout);
+ if (!cont.isPending()) {
+ cont.suspend(timeout);
+ } else {
+ pendingTimeout = timeout;
+ cont.resume();
+ }
return true;
}
+ private void setAsyncResponseOnExchange() {
+ inMessage.getExchange().put(AsyncResponse.class, this);
+ }
+
@Override
public void setTimeoutHandler(TimeoutHandler handler) {
timeoutHandler = handler;
@@ -170,6 +189,8 @@ public void setTimeoutHandler(TimeoutHandler handler) {
extraCallbacks[i] = callbacks[i].newInstance();
}
return register(callback.newInstance(), extraCallbacks);
+ } catch (NullPointerException e) {
+ throw e;
} catch (Throwable t) {
return Collections.emptyMap();
}
@@ -189,7 +210,7 @@ public void setTimeoutHandler(TimeoutHandler handler) {
Object[] allCallbacks = new Object[1 + callbacks.length];
allCallbacks[0] = callback;
- System.arraycopy(allCallbacks, 1, callbacks, 0, callbacks.length);
+ System.arraycopy(callbacks, 0, allCallbacks, 1, callbacks.length);
for (int i = 0; i < allCallbacks.length; i++) {
if (allCallbacks[i] == null) {
@@ -262,7 +283,11 @@ public synchronized boolean isResumedByApplication() {
public synchronized void handleTimeout() {
if (!resumedByApplication) {
- if (timeoutHandler != null) {
+ if (pendingTimeout != null) {
+ setAsyncResponseOnExchange();
+ cont.suspend(pendingTimeout);
+ pendingTimeout = null;
+ } else if (timeoutHandler != null) {
timeoutHandler.handleTimeout(this);
} else {
cont.setObject(new ServiceUnavailableException());
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java
index fadb0980628..57b65c87a81 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ConfigurationImpl.java
@@ -22,21 +22,25 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
+import java.util.logging.Logger;
import javax.ws.rs.RuntimeType;
import javax.ws.rs.core.Configuration;
import javax.ws.rs.core.Feature;
+import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.jaxrs.utils.AnnotationUtils;
public class ConfigurationImpl implements Configuration {
+ private static final Logger LOG = LogUtils.getL7dLogger(ConfigurationImpl.class);
private Map<String, Object> props = new HashMap<String, Object>();
private RuntimeType runtimeType;
private Map<Object, Map<Class<?>, Integer>> providers =
- new HashMap<Object, Map<Class<?>, Integer>>();
- private Map<Feature, Boolean> features = new HashMap<Feature, Boolean>();
+ new LinkedHashMap<Object, Map<Class<?>, Integer>>();
+ private Map<Feature, Boolean> features = new LinkedHashMap<Feature, Boolean>();
public ConfigurationImpl(RuntimeType rt) {
this.runtimeType = rt;
@@ -137,13 +141,13 @@ public boolean isEnabled(Class<? extends Feature> f) {
@Override
public boolean isRegistered(Object obj) {
- return providers.containsKey(obj);
+ return isRegistered(obj.getClass());
}
@Override
public boolean isRegistered(Class<?> cls) {
for (Object o : getInstances()) {
- if (cls.isAssignableFrom(o.getClass())) {
+ if (cls == o.getClass()) {
return true;
}
}
@@ -167,10 +171,15 @@ private void register(Object provider, int bindingPriority, Class<?>... contract
register(provider, initContractsMap(bindingPriority, contracts));
}
- public void register(Object provider, Map<Class<?>, Integer> contracts) {
+ public boolean register(Object provider, Map<Class<?>, Integer> contracts) {
if (provider.getClass() == Class.class) {
provider = createProvider((Class<?>)provider);
}
+ if (isRegistered(provider)) {
+ LOG.warning("Provider " + provider.getClass().getName() + " has already been registered");
+ return false;
+ }
+
Map<Class<?>, Integer> metadata = providers.get(provider);
if (metadata == null) {
metadata = new HashMap<Class<?>, Integer>();
@@ -181,6 +190,7 @@ public void register(Object provider, Map<Class<?>, Integer> contracts) {
metadata.put(contract, contracts.get(contract));
}
}
+ return true;
}
public static Map<Class<?>, Integer> initContractsMap(int bindingPriority, Class<?>... contracts) {
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
index 3bdc16758e3..039b68c81f3 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
@@ -18,16 +18,18 @@
*/
package org.apache.cxf.jaxrs.impl;
+import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
-import javax.ws.rs.HttpMethod;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.core.UriInfo;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
import org.apache.cxf.jaxrs.utils.HttpUtils;
import org.apache.cxf.message.Message;
@@ -66,8 +68,11 @@ public UriInfo getUriInfo() {
@Override
public boolean hasEntity() {
- InputStream is = getEntityStream();
- return is != null && !HttpMethod.GET.equals(getMethod());
+ try {
+ return !IOUtils.isEmpty(getEntityStream());
+ } catch (IOException ex) {
+ throw ExceptionUtils.toInternalServerErrorException(ex, null);
+ }
}
@Override
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/DateHeaderProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/DateHeaderProvider.java
new file mode 100644
index 00000000000..2d2e0465224
--- /dev/null
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/DateHeaderProvider.java
@@ -0,0 +1,43 @@
+/**
+ * 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.apache.cxf.jaxrs.impl;
+
+import java.util.Date;
+
+import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
+
+import org.apache.cxf.jaxrs.utils.HttpUtils;
+
+public class DateHeaderProvider implements HeaderDelegate<Date> {
+
+ public Date fromString(String value) {
+
+ if (value == null) {
+ throw new IllegalArgumentException("Date value can not be null");
+ }
+ return HttpUtils.getHttpDate(value);
+ }
+
+ public String toString(Date date) {
+ return HttpUtils.toHttpDate(date);
+ }
+
+
+}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java
index 15c324392f2..2363a7ac668 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/LinkBuilderImpl.java
@@ -57,8 +57,12 @@ public Link buildRelativized(URI requestUri, Object... values) {
private URI getResolvedUri(Object... values) {
URI uri = ub.build(values);
- return baseUri != null
- ? HttpUtils.resolve(UriBuilder.fromUri(baseUri), uri) : uri;
+ if (!uri.isAbsolute() && baseUri != null) {
+ UriBuilder linkUriBuilder = UriBuilder.fromUri(baseUri);
+ return HttpUtils.resolve(linkUriBuilder, uri);
+ } else {
+ return uri;
+ }
}
@Override
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
index 1b91687f753..89ea9985b2c 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
@@ -43,7 +43,7 @@
private static final String STRICT_MEDIA_TYPE_CHECK =
"org.apache.cxf.jaxrs.mediaTypeCheck.strict";
private static final Pattern COMPLEX_PARAMETERS =
- Pattern.compile("(([\\w-]+=\"[^\"]*\")|([\\w-]+=[\\w-/]+))");
+ Pattern.compile("(([\\w-]+=\"[^\"]*\")|([\\w-]+=[\\w-/\\+]+))");
public MediaType fromString(String mType) {
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java
index 702c7205dc1..a050b86048e 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/NewCookieHeaderProvider.java
@@ -33,7 +33,7 @@
private static final String COMMENT = "Comment";
private static final String SECURE = "Secure";
private static final String EXPIRES = "Expires";
-
+
public NewCookie fromString(String c) {
if (c == null) {
@@ -51,27 +51,27 @@ public NewCookie fromString(String c) {
String[] tokens = StringUtils.split(c, ";");
for (String token : tokens) {
String theToken = token.trim();
- if (theToken.startsWith(VERSION)) {
- // should we throw an exception if it's not == 1 ?
- } else if (theToken.startsWith(MAX_AGE)) {
- maxAge = Integer.parseInt(theToken.substring(MAX_AGE.length() + 1));
- } else if (theToken.startsWith(PATH)) {
- path = theToken.substring(PATH.length() + 1);
- } else if (theToken.startsWith(DOMAIN)) {
- domain = theToken.substring(DOMAIN.length() + 1);
- } else if (theToken.startsWith(COMMENT)) {
- comment = theToken.substring(COMMENT.length() + 1);
- } else if (theToken.startsWith(SECURE)) {
+
+ int sepIndex = theToken.indexOf('=');
+ String paramName = sepIndex != -1 ? theToken.substring(0, sepIndex) : theToken;
+ String paramValue = sepIndex == theToken.length() + 1 ? null : theToken.substring(sepIndex + 1);
+
+ if (paramName.equalsIgnoreCase(MAX_AGE)) {
+ maxAge = Integer.parseInt(paramValue);
+ } else if (paramName.equalsIgnoreCase(PATH)) {
+ path = paramValue;
+ } else if (paramName.equalsIgnoreCase(DOMAIN)) {
+ domain = paramValue;
+ } else if (paramName.equalsIgnoreCase(COMMENT)) {
+ comment = paramValue;
+ } else if (paramName.equalsIgnoreCase(SECURE)) {
isSecure = true;
- } else if (theToken.startsWith(EXPIRES)) {
+ } else if (paramName.equalsIgnoreCase(EXPIRES) || paramName.equalsIgnoreCase(VERSION)) {
// ignore
continue;
} else {
- int i = theToken.indexOf('=');
- if (i != -1) {
- name = theToken.substring(0, i);
- value = i == theToken.length() + 1 ? "" : theToken.substring(i + 1);
- }
+ name = paramName;
+ value = paramValue;
}
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PropertyHolderFactory.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PropertyHolderFactory.java
index dc35dc4055e..215adb816bd 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PropertyHolderFactory.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PropertyHolderFactory.java
@@ -49,7 +49,7 @@ public static PropertyHolder getPropertyHolder(Message m) {
public MessagePropertyHolder(Message m) {
this.m = m;
- this.props = CastUtils.cast((Map<?, ?>)m.get(PROPERTY_KEY));
+ this.props = CastUtils.cast((Map<?, ?>)m.getExchange().get(PROPERTY_KEY));
}
public Object getProperty(String name) {
return props == null ? null : props.get(name);
@@ -65,7 +65,7 @@ public void removeProperty(String name) {
public void setProperty(String name, Object value) {
if (props == null) {
props = new HashMap<String, Object>();
- m.put(PROPERTY_KEY, props);
+ m.getExchange().put(PROPERTY_KEY, props);
}
if (value == null) {
removeProperty(name);
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ProvidersImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ProvidersImpl.java
index d7566378ca3..feba99e3c4e 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ProvidersImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ProvidersImpl.java
@@ -43,13 +43,13 @@ public ProvidersImpl(Message m) {
public <T> MessageBodyReader<T> getMessageBodyReader(
Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
return ProviderFactory.getInstance(m).createMessageBodyReader(
- type, genericType, annotations, mediaType, m);
+ type, getGenericType(type, genericType), annotations, mediaType, m);
}
public <T> MessageBodyWriter<T> getMessageBodyWriter(
Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
return ProviderFactory.getInstance(m).createMessageBodyWriter(
- type, genericType, annotations, mediaType, m);
+ type, getGenericType(type, genericType), annotations, mediaType, m);
}
public <T> ContextResolver<T> getContextResolver(Class<T> contextType, MediaType mediaType) {
@@ -59,5 +59,7 @@ public ProvidersImpl(Message m) {
public <T extends Throwable> ExceptionMapper<T> getExceptionMapper(Class<T> type) {
return ServerProviderFactory.getInstance(m).createExceptionMapper(type, m);
}
-
+ private Type getGenericType(Class<?> type, Type genericType) {
+ return genericType == null ? type : genericType;
+ }
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
index d9fa6fb1035..1a9e00f9987 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
@@ -147,7 +147,10 @@ private void handleMethod(Message m,
HttpHeaders headers) {
String method = queries.getFirst(METHOD_QUERY);
if (method == null) {
- method = headers.getHeaderString(METHOD_HEADER);
+ List<String> list = headers.getRequestHeader(METHOD_HEADER);
+ if (list != null && list.size() == 1) {
+ method = list.get(0);
+ }
}
if (method != null) {
m.put(Message.HTTP_REQUEST_METHOD, method);
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResourceContextImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResourceContextImpl.java
index 60b70aadd1e..5e43f1199c5 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResourceContextImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResourceContextImpl.java
@@ -20,14 +20,16 @@
import javax.ws.rs.container.ResourceContext;
+import org.apache.cxf.jaxrs.ext.ResourceContextProvider;
import org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider;
+import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
import org.apache.cxf.jaxrs.model.ClassResourceInfo;
import org.apache.cxf.jaxrs.model.OperationResourceInfo;
import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
import org.apache.cxf.message.Message;
public class ResourceContextImpl implements ResourceContext {
-
+ private static final String CONTEXT_PROVIDER_PROP = "org.apache.cxf.jaxrs.resource.context.provider";
private ClassResourceInfo cri;
private Class<?> subClass;
private Message m;
@@ -39,7 +41,15 @@ public ResourceContextImpl(Message m, OperationResourceInfo ori) {
@Override
public <T> T getResource(Class<T> cls) {
- T resource = cls.cast(new PerRequestResourceProvider(cls).getInstance(m));
+ ResourceProvider rp = null;
+
+ Object propValue = m.getContextualProperty(CONTEXT_PROVIDER_PROP);
+ if (propValue instanceof ResourceContextProvider) {
+ rp = ((ResourceContextProvider)propValue).getResourceProvider(cls);
+ } else {
+ rp = new PerRequestResourceProvider(cls);
+ }
+ T resource = cls.cast(rp.getInstance(m));
return doInitResource(cls, resource);
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
index 14a398c49ba..cee5d367f98 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseBuilderImpl.java
@@ -42,7 +42,7 @@
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.PhaseInterceptorChain;
-public final class ResponseBuilderImpl extends ResponseBuilder implements Cloneable {
+public class ResponseBuilderImpl extends ResponseBuilder implements Cloneable {
private int status = 200;
private boolean statusSet;
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
index 51ff48dec7f..681142a2233 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
@@ -31,7 +31,7 @@
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -269,10 +269,10 @@ public boolean hasLink(String relation) {
}
public Link getLink(String relation) {
- Set<Map.Entry<String, Link>> entries = getAllLinks().entrySet();
- for (Map.Entry<String, Link> entry : entries) {
- if (entry.getKey().contains(relation)) {
- return entry.getValue();
+ Set<Link> links = getAllLinks();
+ for (Link link : links) {
+ if (link.getRel() != null && link.getRel().equals(relation)) {
+ return link;
}
}
return null;
@@ -284,22 +284,22 @@ public Link getLink(String relation) {
}
public Set<Link> getLinks() {
- return new HashSet<Link>(getAllLinks().values());
+ return new HashSet<Link>(getAllLinks());
}
- private Map<String, Link> getAllLinks() {
+ private Set<Link> getAllLinks() {
List<Object> linkValues = metadata.get(HttpHeaders.LINK);
if (linkValues == null) {
- return Collections.emptyMap();
+ return Collections.emptySet();
} else {
- Map<String, Link> links = new LinkedHashMap<String, Link>();
+ Set<Link> links = new LinkedHashSet<Link>();
for (Object o : linkValues) {
Link link = o instanceof Link ? (Link)o : Link.valueOf(o.toString());
if (!link.getUri().isAbsolute()) {
URI requestURI = URI.create((String)outMessage.get(Message.REQUEST_URI));
link = Link.fromLink(link).baseUri(requestURI).build();
}
- links.put(link.getRel(), link);
+ links.add(link);
}
return links;
}
@@ -354,7 +354,7 @@ public Link getLink(String relation) {
}
// we need to check for readers even if no IS is set - the readers may still do it
- List<ReaderInterceptor> readers = ProviderFactory.getInstance(outMessage)
+ List<ReaderInterceptor> readers = outMessage == null ? null : ProviderFactory.getInstance(outMessage)
.createMessageBodyReaderInterceptor(cls, t, anns, mediaType, outMessage, entityStreamAvailable, null);
if (readers != null) {
@@ -385,7 +385,7 @@ public Link getLink(String relation) {
}
throw new IllegalStateException("The entity is not backed by an input stream, entity class is : "
- + (entity != null ? entity.getClass().getName() : null));
+ + (entity != null ? entity.getClass().getName() : cls.getName()));
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java
index aadd3b27056..dcd5946827f 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RuntimeDelegateImpl.java
@@ -19,6 +19,7 @@
package org.apache.cxf.jaxrs.impl;
+import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -51,6 +52,7 @@ public RuntimeDelegateImpl() {
headerProviders.put(Cookie.class, new CookieHeaderProvider());
headerProviders.put(NewCookie.class, new NewCookieHeaderProvider());
headerProviders.put(Link.class, new LinkHeaderProvider());
+ headerProviders.put(Date.class, new DateHeaderProvider());
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
index 53ca8fea63c..ae10a1ba072 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
@@ -632,7 +632,7 @@ private void setUriParts(URI uri) {
}
String rawQuery = uri.getRawQuery();
if (rawQuery != null) {
- query = JAXRSUtils.getStructuredParams(rawQuery, "&", false, false);
+ query = JAXRSUtils.getStructuredParams(rawQuery, "&", false, true);
}
userInfo = uri.getUserInfo();
schemeSpecificPart = null;
@@ -689,9 +689,9 @@ public UriBuilder matrixParam(String name, Object... values) throws IllegalArgum
}
List<String> list = matrix.get(name);
if (list == null) {
- matrix.put(name, toStringList(values));
+ matrix.put(name, toStringList(true, values));
} else {
- list.addAll(toStringList(values));
+ list.addAll(toStringList(true, values));
}
return this;
}
@@ -703,9 +703,9 @@ public UriBuilder queryParam(String name, Object... values) throws IllegalArgume
}
List<String> list = query.get(name);
if (list == null) {
- query.put(name, toStringList(values));
+ query.put(name, toStringList(false, values));
} else {
- list.addAll(toStringList(values));
+ list.addAll(toStringList(false, values));
}
return this;
}
@@ -723,7 +723,7 @@ public UriBuilder replaceMatrixParam(String name, Object... values) throws Illeg
throw new IllegalArgumentException("name is null");
}
if (values != null && values.length >= 1 && values[0] != null) {
- matrix.put(name, toStringList(values));
+ matrix.put(name, toStringList(true, values));
} else {
matrix.remove(name);
}
@@ -779,7 +779,7 @@ public UriBuilder replaceQueryParam(String name, Object... values) throws Illega
throw new IllegalArgumentException("name is null");
}
if (values != null && values.length >= 1 && values[0] != null) {
- query.put(name, toStringList(values));
+ query.put(name, toStringList(false, values));
} else {
query.remove(name);
}
@@ -805,7 +805,7 @@ public UriBuilder segment(String... segments) throws IllegalArgumentException {
* @return list of strings
* @throws IllegalArgumentException when one of values is null
*/
- private List<String> toStringList(Object... values) throws IllegalArgumentException {
+ private List<String> toStringList(boolean encodeSlash, Object... values) throws IllegalArgumentException {
List<String> list = new ArrayList<String>();
if (values != null) {
for (int i = 0; i < values.length; i++) {
@@ -813,7 +813,11 @@ public UriBuilder segment(String... segments) throws IllegalArgumentException {
if (value == null) {
throw new IllegalArgumentException("Null value on " + i + " position");
}
- list.add(value.toString());
+ String strValue = value.toString();
+ if (encodeSlash) {
+ strValue = strValue.replaceAll("/", "%2F");
+ }
+ list.add(strValue);
}
}
if (list.isEmpty()) {
@@ -840,6 +844,9 @@ private String buildParams(MultivaluedMap<String, String> map, char separator) {
boolean templateValue = val.startsWith("{") && val.endsWith("}");
if (!templateValue) {
val = HttpUtils.encodePartiallyEncoded(val, isQuery);
+ if (!isQuery) {
+ val = val.replaceAll("/", "%2F");
+ }
} else {
val = new URITemplate(val).encodeLiteralCharacters(isQuery);
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java
index 609eba11720..46238cf2c04 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java
@@ -223,6 +223,9 @@ private String getAbsolutePathAsString() {
if (path.startsWith("/") && address.endsWith("/")) {
address = address.substring(0, address.length() - 1);
}
+ if (!path.isEmpty() && !path.startsWith("/") && !address.endsWith("/")) {
+ address = address + "/";
+ }
return address + path;
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java
index 723edd048a2..bbc0bfca045 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java
@@ -19,8 +19,6 @@
package org.apache.cxf.jaxrs.impl;
-import java.io.PrintWriter;
-import java.io.StringWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -30,6 +28,7 @@
import javax.ws.rs.ext.ExceptionMapper;
import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
import org.apache.cxf.jaxrs.utils.JAXRSUtils;
import org.apache.cxf.logging.FaultListener;
import org.apache.cxf.message.Message;
@@ -70,7 +69,7 @@ public Response toResponse(WebApplicationException ex) {
if (flogger == null
|| !flogger.faultOccurred(ex, errorMessage, msg)) {
Level level = printStackTrace ? Level.WARNING : Level.FINE;
- LOG.log(level, getStackTrace(ex));
+ LOG.log(level, ExceptionUtils.getStackTrace(ex));
}
if (doAddMessage) {
@@ -95,12 +94,6 @@ protected String buildErrorMessage(Response r, WebApplicationException ex) {
return sb.toString();
}
- private static String getStackTrace(Exception ex) {
- StringWriter sw = new StringWriter();
- ex.printStackTrace(new PrintWriter(sw));
- return sw.toString();
- }
-
/**
* Control whether to log at WARN or FINE level.
* Note this property is ignored if a registered {@link FaultListener}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/RequestDispatcherImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/RequestDispatcherImpl.java
new file mode 100644
index 00000000000..fd6000e4096
--- /dev/null
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/RequestDispatcherImpl.java
@@ -0,0 +1,49 @@
+/**
+ * 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.apache.cxf.jaxrs.impl.tl;
+
+import java.io.IOException;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+
+class RequestDispatcherImpl implements RequestDispatcher {
+ private RequestDispatcher rd;
+
+ RequestDispatcherImpl(RequestDispatcher rd) {
+ this.rd = rd;
+ }
+
+ @Override
+ public void forward(ServletRequest request, ServletResponse response) throws ServletException,
+ IOException {
+ rd.forward(request, response);
+ JAXRSUtils.getCurrentMessage().getExchange().put("http.request.redirected", Boolean.TRUE);
+ }
+
+ @Override
+ public void include(ServletRequest request, ServletResponse response) throws ServletException,
+ IOException {
+ rd.include(request, response);
+ }
+}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalServletContext.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalServletContext.java
index 54734c3f714..b1c6eafe0f6 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalServletContext.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalServletContext.java
@@ -79,7 +79,11 @@ public int getMinorVersion() {
}
public RequestDispatcher getNamedDispatcher(String name) {
- return get().getNamedDispatcher(name);
+ return getDispatcher(get().getNamedDispatcher(name));
+ }
+
+ private RequestDispatcher getDispatcher(RequestDispatcher rd) {
+ return rd == null ? null : new RequestDispatcherImpl(rd);
}
public String getRealPath(String path) {
@@ -87,7 +91,7 @@ public String getRealPath(String path) {
}
public RequestDispatcher getRequestDispatcher(String path) {
- return get().getRequestDispatcher(path);
+ return getDispatcher(get().getRequestDispatcher(path));
}
public URL getResource(String path) throws MalformedURLException {
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSDefaultFaultOutInterceptor.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSDefaultFaultOutInterceptor.java
index dbb7d867670..b53ac0ee5b5 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSDefaultFaultOutInterceptor.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSDefaultFaultOutInterceptor.java
@@ -28,6 +28,7 @@
import org.w3c.dom.Node;
import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.util.PropertyUtils;
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.helpers.NSStack;
import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
@@ -52,12 +53,18 @@ public JAXRSDefaultFaultOutInterceptor(String phase) {
}
public void handleMessage(Message message) throws Fault {
+ if (PropertyUtils.isTrue(message.getExchange().get(JAXRSUtils.SECOND_JAXRS_EXCEPTION))) {
+ return;
+ }
final Fault f = (Fault) message.getContent(Exception.class);
Response r = JAXRSUtils.convertFaultToResponse(f.getCause(), message);
if (r != null) {
JAXRSUtils.setMessageContentType(message, r);
message.setContent(List.class, new MessageContentsList(r));
+ if (message.getExchange().getOutMessage() == null && message.getExchange().getOutFaultMessage() != null) {
+ message.getExchange().setOutMessage(message.getExchange().getOutFaultMessage());
+ }
new JAXRSOutInterceptor().handleMessage(message);
return;
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
index 68452414bad..e32f05cc316 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
@@ -103,7 +103,7 @@ private void processRequest(Message message, Exchange exchange) {
}
// Global pre-match request filters
- if (JAXRSUtils.runContainerRequestFilters(providerFactory, message, true, null, false)) {
+ if (JAXRSUtils.runContainerRequestFilters(providerFactory, message, true, null)) {
return;
}
// HTTP method
@@ -198,11 +198,11 @@ private void processRequest(Message message, Exchange exchange) {
}
// Global and name-bound post-match request filters
- if (JAXRSUtils.runContainerRequestFilters(providerFactory,
- message,
- false,
- ori.getNameBindings(),
- false)) {
+ if (!ori.isSubResourceLocator()
+ && JAXRSUtils.runContainerRequestFilters(providerFactory,
+ message,
+ false,
+ ori.getNameBindings())) {
return;
}
@@ -271,6 +271,9 @@ private Message createOutMessage(Message inMessage, Response r) {
mout.setInterceptorChain(
OutgoingChainInterceptor.getOutInterceptorChain(inMessage.getExchange()));
inMessage.getExchange().setOutMessage(mout);
+ if (r.getStatus() >= Response.Status.BAD_REQUEST.getStatusCode()) {
+ inMessage.getExchange().put("cxf.io.cacheinput", Boolean.FALSE);
+ }
return mout;
}
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
index d0b4baa752d..73e8d969f8f 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
@@ -34,6 +34,7 @@
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.HttpMethod;
+import javax.ws.rs.NotAcceptableException;
import javax.ws.rs.Produces;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
@@ -148,7 +149,7 @@ private void serializeMessage(ServerProviderFactory providerFactory,
? ori.getAnnotatedMethod() : ori.getMethodToInvoke();
Annotation[] annotations = null;
- Annotation[] staticAnns = invoked != null ? invoked.getAnnotations() : new Annotation[]{};
+ Annotation[] staticAnns = ori != null ? ori.getOutAnnotations() : new Annotation[]{};
Annotation[] responseAnns = response.getEntityAnnotations();
if (responseAnns != null) {
annotations = new Annotation[staticAnns.length + responseAnns.length];
@@ -173,8 +174,6 @@ private void serializeMessage(ServerProviderFactory providerFactory,
if (initialResponseContentType != null && !responseHeaders.containsKey(HttpHeaders.CONTENT_TYPE)) {
responseHeaders.putSingle(HttpHeaders.CONTENT_TYPE, initialResponseContentType);
}
- } else {
- message.remove(Message.CONTENT_TYPE);
}
message.put(Message.PROTOCOL_HEADERS, responseHeaders);
@@ -195,8 +194,10 @@ private void serializeMessage(ServerProviderFactory providerFactory,
if (entity == null) {
if (!headResponse) {
responseHeaders.putSingle(HttpHeaders.CONTENT_LENGTH, "0");
- responseHeaders.remove(HttpHeaders.CONTENT_TYPE);
- message.remove(Message.CONTENT_TYPE);
+ if (MessageUtils.getContextualBoolean(message, "remove.content.type.for.empty.response", false)) {
+ responseHeaders.remove(HttpHeaders.CONTENT_TYPE);
+ message.remove(Message.CONTENT_TYPE);
+ }
}
HttpUtils.convertHeaderValuesToString(responseHeaders, true);
return;
@@ -229,7 +230,12 @@ private void serializeMessage(ServerProviderFactory providerFactory,
writeResponseErrorMessage(message, outOriginal, "NO_MSG_WRITER", targetType, responseMediaType);
return;
}
- responseMediaType = checkFinalContentType(responseMediaType, writers);
+ try {
+ responseMediaType = checkFinalContentType(responseMediaType, writers);
+ } catch (Throwable ex) {
+ handleWriteException(providerFactory, message, ex, firstTry);
+ return;
+ }
String finalResponseContentType = JAXRSUtils.mediaTypeToString(responseMediaType);
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Response content type is: " + finalResponseContentType);
@@ -357,6 +363,8 @@ private void handleWriteException(ServerProviderFactory pf,
Response excResponse = null;
if (firstTry) {
excResponse = JAXRSUtils.convertFaultToResponse(ex, message);
+ } else {
+ message.getExchange().put(JAXRSUtils.SECOND_JAXRS_EXCEPTION, Boolean.TRUE);
}
if (excResponse == null) {
setResponseStatus(message, 500);
@@ -384,7 +392,7 @@ private void writeResponseErrorMessage(Message message, OutputStream out,
private MediaType checkFinalContentType(MediaType mt, List<WriterInterceptor> writers) {
- if (mt.isWildcardType() || mt.isWildcardSubtype()) {
+ if (mt.isWildcardSubtype()) {
int mbwIndex = writers.size() == 1 ? 0 : writers.size() - 1;
MessageBodyWriter<Object> writer = ((WriterInterceptorMBW)writers.get(mbwIndex)).getMBW();
Produces pm = writer.getClass().getAnnotation(Produces.class);
@@ -392,11 +400,13 @@ private MediaType checkFinalContentType(MediaType mt, List<WriterInterceptor> wr
List<MediaType> sorted =
JAXRSUtils.sortMediaTypes(JAXRSUtils.getMediaTypes(pm.value()), JAXRSUtils.MEDIA_TYPE_QS_PARAM);
mt = JAXRSUtils.intersectMimeTypes(sorted, mt).get(0);
- if (mt.isWildcardType() || mt.isWildcardSubtype()) {
- return MediaType.APPLICATION_OCTET_STREAM_TYPE;
- }
+ }
+ }
+ if (mt.isWildcardType() || mt.isWildcardSubtype()) {
+ if ("application".equals(mt.getType()) || mt.isWildcardType()) {
+ mt = MediaType.APPLICATION_OCTET_STREAM_TYPE;
} else {
- return MediaType.APPLICATION_OCTET_STREAM_TYPE;
+ throw new NotAcceptableException();
}
}
return mt;
@@ -418,8 +428,8 @@ private boolean isResponseAlreadyCommited(Message m) {
return Boolean.TRUE.equals(m.getExchange().get(AbstractHTTPDestination.RESPONSE_COMMITED));
}
- private boolean isResponseRedirected(Message outMessage) {
- return Boolean.TRUE.equals(outMessage.get(AbstractHTTPDestination.REQUEST_REDIRECTED));
+ private boolean isResponseRedirected(Message m) {
+ return Boolean.TRUE.equals(m.getExchange().get(AbstractHTTPDestination.REQUEST_REDIRECTED));
}
private void writeResponseToStream(OutputStream os, Object responseObj) {
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
index 13113dd02d6..fb62c19c06b 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/AbstractResourceInfo.java
@@ -25,23 +25,53 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.WeakHashMap;
+import java.util.logging.Logger;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.Providers;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.jaxrs.impl.tl.ThreadLocalProxy;
import org.apache.cxf.jaxrs.utils.InjectionUtils;
public abstract class AbstractResourceInfo {
public static final String CONSTRUCTOR_PROXY_MAP = "jaxrs-constructor-proxy-map";
+ private static final Logger LOG = LogUtils.getL7dLogger(AbstractResourceInfo.class);
private static final String FIELD_PROXY_MAP = "jaxrs-field-proxy-map";
private static final String SETTER_PROXY_MAP = "jaxrs-setter-proxy-map";
+ private static final Set<String> STANDARD_CONTEXT_CLASSES = new HashSet<String>();
+ static {
+ // JAX-RS 1.0-1.1
+ STANDARD_CONTEXT_CLASSES.add(Application.class.getName());
+ STANDARD_CONTEXT_CLASSES.add(UriInfo.class.getName());
+ STANDARD_CONTEXT_CLASSES.add(HttpHeaders.class.getName());
+ STANDARD_CONTEXT_CLASSES.add(Request.class.getName());
+ STANDARD_CONTEXT_CLASSES.add(SecurityContext.class.getName());
+ STANDARD_CONTEXT_CLASSES.add(Providers.class.getName());
+ STANDARD_CONTEXT_CLASSES.add(ContextResolver.class.getName());
+ STANDARD_CONTEXT_CLASSES.add("javax.servlet.http.HttpServletRequest");
+ STANDARD_CONTEXT_CLASSES.add("javax.servlet.http.HttpServletResponse");
+ STANDARD_CONTEXT_CLASSES.add("javax.servlet.ServletContext");
+ // JAX-RS 2.0
+ STANDARD_CONTEXT_CLASSES.add("javax.ws.rs.container.ResourceContext");
+ STANDARD_CONTEXT_CLASSES.add("javax.ws.rs.container.ResourceInfo");
+ STANDARD_CONTEXT_CLASSES.add("javax.ws.rs.core.Configuration");
+ }
+
protected boolean root;
protected Class<?> resourceClass;
protected Class<?> serviceClass;
@@ -120,7 +150,8 @@ private void findContextFields(Class<?> cls, Object provider) {
for (Annotation a : f.getAnnotations()) {
if (a.annotationType() == Context.class) {
contextFields = addContextField(contextFields, f);
- if (f.getType() != Application.class) {
+ if (f.getType().isInterface()) {
+ checkContextClass(f.getType());
addToMap(getFieldProxyMap(true), f, getFieldThreadLocalProxy(f, provider));
}
}
@@ -240,10 +271,17 @@ private void findContextSetterMethods(Class<?> cls, Object provider) {
private void checkContextMethod(Method m, Object provider) {
Class<?> type = m.getParameterTypes()[0];
- if (m.getName().equals("set" + type.getSimpleName())) {
+ if (type.isInterface() || type == Application.class) {
+ checkContextClass(type);
addContextMethod(type, m, provider);
}
}
+ private void checkContextClass(Class<?> type) {
+ if (!STANDARD_CONTEXT_CLASSES.contains(type.getName())) {
+ LOG.fine("Injecting a custom context " + type.getName()
+ + ", ContextProvider is required for this type");
+ }
+ }
@SuppressWarnings("unchecked")
public Map<Class<?>, Method> getContextMethods() {
@@ -342,7 +380,7 @@ public void clearThreadLocalProxies() {
V proxy) {
Map<T, V> proxies = proxyMap.get(serviceClass);
if (proxies == null) {
- proxies = new HashMap<T, V>();
+ proxies = Collections.synchronizedMap(new WeakHashMap<T, V>());
proxyMap.put(serviceClass, proxies);
}
if (!proxies.containsKey(f)) {
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ApplicationInfo.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ApplicationInfo.java
new file mode 100644
index 00000000000..d60b3191ea1
--- /dev/null
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ApplicationInfo.java
@@ -0,0 +1,54 @@
+/**
+ * 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.apache.cxf.jaxrs.model;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.core.Application;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.jaxrs.impl.tl.ThreadLocalProxy;
+
+public class ApplicationInfo extends ProviderInfo<Application> {
+ private Map<String, Object> overridingProps = Collections.emptyMap();
+ public ApplicationInfo(Application provider, Bus bus) {
+ this(provider, null, bus);
+ }
+ public ApplicationInfo(Application provider,
+ Map<Class<?>, ThreadLocalProxy<?>> constructorProxies,
+ Bus bus) {
+ super(provider, constructorProxies, bus);
+ }
+
+ public Map<String, Object> getProperties() {
+ Map<String, Object> appProps = super.getProvider().getProperties();
+ if (overridingProps.isEmpty()) {
+ return appProps;
+ } else {
+ Map<String, Object> props = new HashMap<String, Object>(appProps);
+ props.putAll(overridingProps);
+ return props;
+ }
+ }
+ public void setOverridingProps(Map<String, Object> overridingProps) {
+ this.overridingProps = overridingProps;
+ }
+}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
index d6a5686e490..9889084de37 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
@@ -19,7 +19,9 @@
package org.apache.cxf.jaxrs.model;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
+import java.lang.reflect.Type;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -48,7 +50,11 @@
private List<Parameter> parameters;
private boolean oneway;
private Set<String> nameBindings = new LinkedHashSet<String>();
-
+ private Class<?>[] actualInParamTypes;
+ private Type[] actualInGenericParamTypes;
+ private Annotation[][] actualInParamAnnotations;
+ private Annotation[] actualOutParamAnnotations;
+
public OperationResourceInfo(Method mInvoke, ClassResourceInfo cri) {
this(mInvoke, mInvoke, cri);
}
@@ -66,6 +72,7 @@ public OperationResourceInfo(Method mInvoke, ClassResourceInfo cri) {
this.oneway = ori.oneway;
this.classResourceInfo = cri;
this.nameBindings = ori.nameBindings;
+ initActualMethodProperties();
}
public OperationResourceInfo(Method mInvoke, Method mAnnotated, ClassResourceInfo cri) {
@@ -80,6 +87,7 @@ public OperationResourceInfo(Method mInvoke, Method mAnnotated, ClassResourceInf
checkEncoded();
checkDefaultParameterValue();
checkOneway();
+ initActualMethodProperties();
}
//CHECKSTYLE:OFF
@@ -100,6 +108,30 @@ public OperationResourceInfo(Method m,
checkMediaTypes(consumeMediaTypes, produceMediaTypes);
parameters = params;
this.oneway = oneway;
+ initActualMethodProperties();
+ }
+
+ private void initActualMethodProperties() {
+ Method actualMethod = annotatedMethod == null ? methodToInvoke : annotatedMethod;
+ actualInParamTypes = actualMethod.getParameterTypes();
+ actualInGenericParamTypes = actualMethod.getGenericParameterTypes();
+ actualInParamAnnotations = actualMethod.getParameterAnnotations();
+
+ // out annotations
+ Annotation[] invokedAnns = methodToInvoke.getAnnotations();
+ if (methodToInvoke != annotatedMethod && annotatedMethod != null) {
+ Annotation[] superAnns = annotatedMethod.getAnnotations();
+ if (invokedAnns.length > 0) {
+ Annotation[] merged = new Annotation[superAnns.length + invokedAnns.length];
+ System.arraycopy(superAnns, 0, merged, 0, superAnns.length);
+ System.arraycopy(invokedAnns, 0, merged, superAnns.length, invokedAnns.length);
+ actualOutParamAnnotations = merged;
+ } else {
+ actualOutParamAnnotations = superAnns;
+ }
+ } else {
+ actualOutParamAnnotations = invokedAnns;
+ }
}
public void addNameBindings(List<String> names) {
@@ -235,4 +267,17 @@ private void checkDefaultParameterValue() {
defaultParamValue = dv.value();
}
}
+ public Annotation[][] getInParameterAnnotations() {
+ return actualInParamAnnotations;
+ }
+ public Type[] getInGenericParameterTypes() {
+ return actualInGenericParamTypes;
+ }
+ public Class<?>[] getInParameterTypes() {
+ return actualInParamTypes;
+ }
+ public Annotation[] getOutAnnotations() {
+ return actualOutParamAnnotations;
+ }
+
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java
index 74073eb594e..5def5a23967 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java
@@ -27,6 +27,7 @@
import javax.ws.rs.core.MediaType;
import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.jaxrs.ext.DefaultMethod;
import org.apache.cxf.jaxrs.ext.ResourceComparator;
import org.apache.cxf.jaxrs.utils.JAXRSUtils;
import org.apache.cxf.message.Message;
@@ -63,28 +64,32 @@ public OperationResourceInfoComparator(Message m,
}
public int compare(OperationResourceInfo e1, OperationResourceInfo e2) {
-
+ if (e1 == e2) {
+ return 0;
+ }
if (rc != null) {
int result = rc.compare(e1, e2, message);
if (result != 0) {
return result;
}
}
+ String e1HttpMethod = e1.getHttpMethod();
+ String e2HttpMethod = e2.getHttpMethod();
+ int result = 0;
if (!getMethod && HttpMethod.HEAD.equals(httpMethod)) {
- if (HttpMethod.HEAD.equals(e1.getHttpMethod())) {
- return -1;
- } else if (HttpMethod.HEAD.equals(e2.getHttpMethod())) {
- return 1;
+ result = compareWithHead(e1HttpMethod, e2HttpMethod);
+ if (result != 0) {
+ return result;
}
}
- int result = URITemplate.compareTemplates(
+ result = URITemplate.compareTemplates(
e1.getURITemplate(),
e2.getURITemplate());
- if (result == 0 && (e1.getHttpMethod() != null && e2.getHttpMethod() == null
- || e1.getHttpMethod() == null && e2.getHttpMethod() != null)) {
+ if (result == 0 && (e1HttpMethod != null && e2HttpMethod == null
+ || e1HttpMethod == null && e2HttpMethod != null)) {
// resource method takes precedence over a subresource locator
return e1.getHttpMethod() != null ? -1 : 1;
}
@@ -103,7 +108,25 @@ public int compare(OperationResourceInfo e1, OperationResourceInfo e2) {
acceptTypes);
}
+ if (result == 0 && e1HttpMethod != null && e2HttpMethod != null) {
+ boolean e1IsDefault = DefaultMethod.class.getSimpleName().equals(e1HttpMethod);
+ boolean e2IsDefault = DefaultMethod.class.getSimpleName().equals(e2HttpMethod);
+ if (e1IsDefault && !e2IsDefault) {
+ result = 1;
+ } else if (!e1IsDefault && e2IsDefault) {
+ result = -1;
+ }
+ }
+
return result;
}
+ private static int compareWithHead(String e1HttpMethod, String e2HttpMethod) {
+ if (HttpMethod.HEAD.equals(e1HttpMethod)) {
+ return -1;
+ } else if (HttpMethod.HEAD.equals(e2HttpMethod)) {
+ return 1;
+ }
+ return 0;
+ }
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/Parameter.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/Parameter.java
index d681a47bc91..d2fbe40809d 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/Parameter.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/Parameter.java
@@ -19,6 +19,8 @@
package org.apache.cxf.jaxrs.model;
+import java.io.InputStream;
+
public class Parameter {
private ParameterType type;
@@ -26,6 +28,7 @@
private String aValue;
private boolean isEncoded;
private String defaultValue;
+ private Class<?> javaType;
public Parameter() {
@@ -89,4 +92,14 @@ public String getDefaultValue() {
public void setDefaultValue(String dValue) {
defaultValue = dValue;
}
+ public void setJavaType(Class<?> jType) {
+ this.javaType = jType;
+ }
+ public Class<?> getJavaType() {
+ if (javaType == null) {
+ return type == ParameterType.REQUEST_BODY ? InputStream.class : String.class;
+ } else {
+ return javaType;
+ }
+ }
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java
index 0070367f982..afabd3cd01d 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java
@@ -29,13 +29,24 @@
private T provider;
public ProviderInfo(T provider, Bus bus) {
- this(provider, null, bus);
+ this(provider, bus, true);
+ }
+
+ public ProviderInfo(T provider, Bus bus, boolean checkContexts) {
+ this(provider, null, bus, checkContexts);
}
public ProviderInfo(T provider,
Map<Class<?>, ThreadLocalProxy<?>> constructorProxies,
Bus bus) {
- super(provider.getClass(), provider.getClass(), true, true, constructorProxies, bus, provider);
+ this(provider, constructorProxies, bus, true);
+ }
+
+ public ProviderInfo(T provider,
+ Map<Class<?>, ThreadLocalProxy<?>> constructorProxies,
+ Bus bus,
+ boolean checkContexts) {
+ super(provider.getClass(), provider.getClass(), true, checkContexts, constructorProxies, bus, provider);
this.provider = provider;
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserResource.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserResource.java
index c8d1ec389aa..39e241761ff 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserResource.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserResource.java
@@ -23,6 +23,7 @@
import java.util.List;
import java.util.Map;
+import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.helpers.CastUtils;
public class UserResource {
@@ -59,13 +60,13 @@ public String getProduces() {
}
public void setConsumes(String types) {
- if (!"".equals(types)) {
+ if (!StringUtils.isEmpty(types)) {
consumesTypes = types;
}
}
public void setProduces(String types) {
- if (!"".equals(types)) {
+ if (!StringUtils.isEmpty(types)) {
producesTypes = types;
}
}
@@ -75,7 +76,7 @@ public String getName() {
}
public void setName(String name) {
- if (!"".equals(name)) {
+ if (!StringUtils.isEmpty(name)) {
className = name;
}
}
@@ -85,7 +86,7 @@ public String getPath() {
}
public void setPath(String path) {
- if (!"".equals(path)) {
+ if (!StringUtils.isEmpty(path)) {
pathValue = path;
}
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractConfigurableProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractConfigurableProvider.java
index b24c6479dc1..ae201a69ac3 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractConfigurableProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractConfigurableProvider.java
@@ -20,16 +20,23 @@
package org.apache.cxf.jaxrs.provider;
import java.util.List;
+import java.util.ResourceBundle;
+import java.util.logging.Logger;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.NoContentException;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.jaxrs.model.ClassResourceInfo;
public abstract class AbstractConfigurableProvider {
-
+ protected static final ResourceBundle BUNDLE = BundleUtils.getBundle(AbstractJAXBProvider.class);
+ protected static final Logger LOG = LogUtils.getL7dLogger(AbstractJAXBProvider.class);
+
private List<String> consumeMediaTypes;
private List<String> produceMediaTypes;
private boolean enableBuffering;
@@ -170,4 +177,9 @@ protected boolean isPayloadEmpty(MultivaluedMap<String, String> headers) {
return false;
}
+ protected void reportEmptyContentLength() throws NoContentException {
+ String message = new org.apache.cxf.common.i18n.Message("EMPTY_BODY", BUNDLE).toString();
+ LOG.warning(message);
+ throw new NoContentException(message);
+ }
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
index 74646a6dbf7..b456916ebb3 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
@@ -22,8 +22,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
import java.lang.annotation.Annotation;
import java.lang.reflect.Array;
import java.lang.reflect.Type;
@@ -35,14 +33,11 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.ResourceBundle;
import java.util.Set;
-import java.util.logging.Logger;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.NoContentException;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.MessageBodyReader;
@@ -69,9 +64,7 @@
import org.xml.sax.helpers.DefaultHandler;
import org.apache.cxf.annotations.SchemaValidation;
-import org.apache.cxf.common.i18n.BundleUtils;
import org.apache.cxf.common.jaxb.JAXBUtils;
-import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.PackageUtils;
import org.apache.cxf.jaxrs.ext.MessageContext;
import org.apache.cxf.jaxrs.model.ClassResourceInfo;
@@ -92,9 +85,6 @@
public abstract class AbstractJAXBProvider<T> extends AbstractConfigurableProvider
implements MessageBodyReader<T>, MessageBodyWriter<T> {
- protected static final ResourceBundle BUNDLE = BundleUtils.getBundle(AbstractJAXBProvider.class);
-
- protected static final Logger LOG = LogUtils.getL7dLogger(AbstractJAXBProvider.class);
protected static final String NS_MAPPER_PROPERTY_RI = "com.sun.xml.bind.namespacePrefixMapper";
protected static final String NS_MAPPER_PROPERTY_RI_INT = "com.sun.xml.internal.bind.namespacePrefixMapper";
private static final String JAXB_DEFAULT_NAMESPACE = "##default";
@@ -271,12 +261,6 @@ public void setJaxbElementClassMap(Map<String, String> map) {
jaxbElementClassMap = map;
}
- protected void reportEmptyContentLength() throws NoContentException {
- String message = new org.apache.cxf.common.i18n.Message("EMPTY_BODY", BUNDLE).toString();
- LOG.warning(message);
- throw new NoContentException(message);
- }
-
protected <X> X getStreamHandlerFromCurrentMessage(Class<X> staxCls) {
Message m = PhaseInterceptorChain.getCurrentMessage();
if (m != null) {
@@ -410,7 +394,7 @@ protected QName getJaxbQName(Class<?> cls, Type type, Object object, boolean plu
}
}
- private QName getQNameFromNamespaceAndName(String ns, String localName, Class<?> cls, boolean plural) {
+ private static QName getQNameFromNamespaceAndName(String ns, String localName, Class<?> cls, boolean plural) {
String name = getLocalName(localName, cls.getSimpleName() , plural);
String namespace = getNamespace(ns);
if ("".equals(namespace)) {
@@ -419,7 +403,7 @@ private QName getQNameFromNamespaceAndName(String ns, String localName, Class<?>
return new QName(namespace, name);
}
- private String getLocalName(String name, String clsName, boolean pluralName) {
+ private static String getLocalName(String name, String clsName, boolean pluralName) {
if (JAXB_DEFAULT_NAME.equals(name)) {
name = clsName;
if (name.length() > 1) {
@@ -434,12 +418,12 @@ private String getLocalName(String name, String clsName, boolean pluralName) {
return name;
}
- private String getPackageNamespace(Class<?> cls) {
+ private static String getPackageNamespace(Class<?> cls) {
String packageNs = JAXBUtils.getPackageNamespace(cls);
return packageNs != null ? getNamespace(packageNs) : "";
}
- private String getNamespace(String namespace) {
+ private static String getNamespace(String namespace) {
if (JAXB_DEFAULT_NAMESPACE.equals(namespace)) {
return "";
}
@@ -700,14 +684,9 @@ public void clearContexts() {
packageContexts.clear();
}
- protected static String getStackTrace(Exception ex) {
- StringWriter sw = new StringWriter();
- ex.printStackTrace(new PrintWriter(sw));
- return sw.toString();
- }
//TODO: move these methods into the dedicated utility class
protected static StringBuilder handleExceptionStart(Exception e) {
- LOG.warning(getStackTrace(e));
+ LOG.warning(ExceptionUtils.getStackTrace(e));
StringBuilder sb = new StringBuilder();
if (e.getMessage() != null) {
sb.append(e.getMessage()).append(". ");
@@ -883,7 +862,10 @@ public void setList(List<?> list) {
}
@SuppressWarnings("unchecked")
- public <T> Object getCollectionOrArray(Unmarshaller unm, Class<T> type, Class<?> origType,
+ public <T> Object getCollectionOrArray(Unmarshaller unm,
+ Class<T> type,
+ Class<?> collectionType,
+ Type genericType,
XmlJavaTypeAdapter adapter) throws JAXBException {
List<?> theList = getList();
boolean adapterChecked = false;
@@ -893,14 +875,17 @@ public void setList(List<?> list) {
if (first instanceof Element) {
List<Object> newList = new ArrayList<Object>(theList.size());
for (Object o : theList) {
- newList.add(unm.unmarshal((Element)o));
+ newList.add(unm.unmarshal((Element)o, type));
}
theList = newList;
}
first = theList.get(0);
+ Type[] types = InjectionUtils.getActualTypes(genericType);
+ boolean isJaxbElement = types != null && types.length > 0
+ && InjectionUtils.getRawType(types[0]) == JAXBElement.class;
- if (first instanceof JAXBElement && !JAXBElement.class.isAssignableFrom(type)) {
+ if (first instanceof JAXBElement && !isJaxbElement && !JAXBElement.class.isAssignableFrom(type)) {
adapterChecked = true;
List<Object> newList = new ArrayList<Object>(theList.size());
for (Object o : theList) {
@@ -908,9 +893,19 @@ public void setList(List<?> list) {
((JAXBElement<?>)o).getValue(), adapter, false));
}
theList = newList;
+ } else if (!(first instanceof JAXBElement) && isJaxbElement) {
+ List<Object> newList = new ArrayList<Object>(theList.size());
+ XmlRootElement root = type.getAnnotation(XmlRootElement.class);
+ QName qname = getQNameFromNamespaceAndName(root.namespace(), root.name(), type, false);
+ @SuppressWarnings("rawtypes")
+ Class theType = type;
+ for (Object o : theList) {
+ newList.add(new JAXBElement<Object>(qname, theType, null, o));
+ }
+ theList = newList;
}
}
- if (origType.isArray()) {
+ if (collectionType.isArray()) {
T[] values = (T[])Array.newInstance(type, theList.size());
for (int i = 0; i < theList.size(); i++) {
values[i] = (T)org.apache.cxf.jaxrs.utils.JAXBUtils.useAdapter(
@@ -925,7 +920,7 @@ public void setList(List<?> list) {
}
theList = newList;
}
- if (origType == Set.class) {
+ if (collectionType == Set.class) {
return new HashSet<Object>(theList);
} else {
return theList;
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java
index 704ec8e3b5d..6394735eef1 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java
@@ -33,6 +33,7 @@
import java.io.Writer;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
+import java.security.DigestInputStream;
import java.util.UUID;
import java.util.logging.Logger;
@@ -44,9 +45,11 @@
import javax.ws.rs.ext.MessageBodyWriter;
import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.MessageDigestInputStream;
import org.apache.cxf.helpers.FileUtils;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.jaxrs.impl.HttpHeadersImpl;
+import org.apache.cxf.jaxrs.utils.ExceptionUtils;
import org.apache.cxf.message.Message;
import org.apache.cxf.message.MessageUtils;
import org.apache.cxf.phase.PhaseInterceptorChain;
@@ -57,46 +60,69 @@
private static final String HTTP_RANGE_PROPERTY = "http.range.support";
private static final Logger LOG = LogUtils.getL7dLogger(BinaryDataProvider.class);
- private static final int BUFFER_SIZE = 4096;
+ private int bufferSize = IOUtils.DEFAULT_BUFFER_SIZE;
private boolean reportByteArraySize;
-
+ private boolean closeResponseInputStream = true;
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mt) {
return byte[].class.isAssignableFrom(type)
|| InputStream.class.isAssignableFrom(type)
|| Reader.class.isAssignableFrom(type)
- || File.class.isAssignableFrom(type);
+ || File.class.isAssignableFrom(type)
+ || StreamingOutput.class.isAssignableFrom(type);
+ }
+
+ private static final class ReadingStreamingOutput implements StreamingOutput {
+ private final InputStream inputStream;
+ private ReadingStreamingOutput(InputStream inputStream) {
+ this.inputStream = inputStream;
+ }
+ public void write(OutputStream outputStream) throws IOException {
+ IOUtils.copy(inputStream, outputStream);
+ }
}
public T readFrom(Class<T> clazz, Type genericType, Annotation[] annotations, MediaType type,
MultivaluedMap<String, String> headers, InputStream is)
throws IOException {
- if (InputStream.class.isAssignableFrom(clazz)) {
- return clazz.cast(is);
- }
- if (Reader.class.isAssignableFrom(clazz)) {
- return clazz.cast(new InputStreamReader(is, getEncoding(type)));
- }
- if (byte[].class.isAssignableFrom(clazz)) {
- String enc = getCharset(type);
- if (enc == null) {
- return clazz.cast(IOUtils.readBytesFromStream(is));
- } else {
- return clazz.cast(IOUtils.toString(is, enc).getBytes(enc));
+ try {
+ if (InputStream.class.isAssignableFrom(clazz)) {
+ if (DigestInputStream.class.isAssignableFrom(clazz)) {
+ is = new MessageDigestInputStream(is);
+ }
+ return clazz.cast(is);
}
- }
- if (File.class.isAssignableFrom(clazz)) {
- LOG.warning("Reading data into File objects with the help of pre-packaged"
- + " providers is not recommended - use InputStream or custom File reader");
- // create a temp file, delete on exit
- File f = FileUtils.createTempFile("File" + UUID.randomUUID().toString(),
- "jaxrs",
- null,
- true);
- FileOutputStream fos = new FileOutputStream(f);
- IOUtils.copy(is, fos);
- fos.close();
- return clazz.cast(f);
- }
+ if (Reader.class.isAssignableFrom(clazz)) {
+ return clazz.cast(new InputStreamReader(is, getEncoding(type)));
+ }
+ if (byte[].class.isAssignableFrom(clazz)) {
+ String enc = getCharset(type);
+ if (enc == null) {
+ return clazz.cast(IOUtils.readBytesFromStream(is));
+ } else {
+ return clazz.cast(IOUtils.toString(is, bufferSize, enc).getBytes(enc));
+ }
+ }
+ if (File.class.isAssignableFrom(clazz)) {
+ LOG.warning("Reading data into File objects with the help of pre-packaged"
+ + " providers is not recommended - use InputStream or custom File reader");
+ // create a temp file, delete on exit
+ File f = FileUtils.createTempFile("File" + UUID.randomUUID().toString(),
+ "jaxrs",
+ null,
+ true);
+ FileOutputStream fos = new FileOutputStream(f);
+ IOUtils.copy(is, fos, bufferSize);
+ fos.close();
+ return clazz.cast(f);
+ }
+ if (StreamingOutput.class.isAssignableFrom(clazz)) {
+ return clazz.cast(new ReadingStreamingOutput(is));
+ }
+ } catch (ClassCastException e) {
+ String msg = "Unsupported class: " + clazz.getName();
+ LOG.warning(msg);
+ throw ExceptionUtils.toInternalServerErrorException(null, null);
+ }
throw new IOException("Unrecognized class");
}
@@ -133,7 +159,7 @@ public void writeTo(T o, Class<?> clazz, Type genericType, Annotation[] annotati
Writer writer = new OutputStreamWriter(os, getEncoding(type));
IOUtils.copy((Reader)o,
writer,
- BUFFER_SIZE);
+ bufferSize);
writer.flush();
} finally {
((Reader)o).close();
@@ -161,7 +187,11 @@ protected void copyInputToOutput(InputStream is, OutputStream os,
Message inMessage = PhaseInterceptorChain.getCurrentMessage().getExchange().getInMessage();
handleRangeRequest(is, os, new HttpHeadersImpl(inMessage), outHeaders);
} else {
- IOUtils.copyAndCloseInput(is, os);
+ if (closeResponseInputStream) {
+ IOUtils.copyAndCloseInput(is, os, bufferSize);
+ } else {
+ IOUtils.copy(is, os, bufferSize);
+ }
}
}
@@ -171,7 +201,7 @@ protected void handleRangeRequest(InputStream is,
MultivaluedMap<String, Object> outHeaders) throws IOException {
String range = inHeaders.getRequestHeaders().getFirst("Range");
if (range == null) {
- IOUtils.copyAndCloseInput(is, os);
+ IOUtils.copyAndCloseInput(is, os, bufferSize);
} else {
// implement
}
@@ -190,4 +220,12 @@ protected boolean isRangeSupported() {
public void setReportByteArraySize(boolean report) {
this.reportByteArraySize = report;
}
+
+ public void setCloseResponseInputStream(boolean closeResponseInputStream) {
+ this.closeResponseInputStream = closeResponseInputStream;
+ }
+
+ public void setBufferSize(int bufferSize) {
+ this.bufferSize = bufferSize;
+ }
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java
index dda79beec00..1968763d751 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java
@@ -52,8 +52,8 @@
@Produces({"application/x-www-form-urlencoded", "multipart/form-data" })
@Consumes({"application/x-www-form-urlencoded", "multipart/form-data" })
@Provider
-public class FormEncodingProvider<T> implements
- MessageBodyReader<T>, MessageBodyWriter<T> {
+public class FormEncodingProvider<T> extends AbstractConfigurableProvider
+ implements MessageBodyReader<T>, MessageBodyWriter<T> {
private FormValidator validator;
@Context private MessageContext mc;
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
index 6da794b3515..f17c93b6f58 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
@@ -195,7 +195,7 @@ public T readFrom(Class<T> type, Type genericType, Annotation[] anns, MediaType
}
if (isCollection) {
response = ((CollectionWrapper)response).getCollectionOrArray(
- unmarshaller, theType, type,
+ unmarshaller, theType, type, genericType,
org.apache.cxf.jaxrs.utils.JAXBUtils.getAdapter(theGenericType, anns));
} else {
response = checkAdapter(response, type, anns, false);
@@ -209,7 +209,7 @@ public T readFrom(Class<T> type, Type genericType, Annotation[] anns, MediaType
} catch (WebApplicationException e) {
throw e;
} catch (Exception e) {
- LOG.warning(getStackTrace(e));
+ LOG.warning(ExceptionUtils.getStackTrace(e));
throw ExceptionUtils.toBadRequestException(e, null);
} finally {
try {
@@ -322,7 +322,7 @@ public void writeTo(T obj, Class<?> cls, Type genericType, Annotation[] anns,
} catch (WebApplicationException e) {
throw e;
} catch (Exception e) {
- e.printStackTrace();
+ LOG.warning(ExceptionUtils.getStackTrace(e));
throw ExceptionUtils.toInternalServerErrorException(e, null);
}
}
@@ -400,12 +400,10 @@ protected void marshalCollectionMember(Object obj,
MediaType mt,
String ns) throws Exception {
//CHECKSTYLE:ON
- if (obj instanceof JAXBElement) {
- obj = ((JAXBElement<?>)obj).getValue();
- } else {
+ if (!(obj instanceof JAXBElement)) {
obj = convertToJaxbElementIfNeeded(obj, cls, genericType);
}
-
+
if (obj instanceof JAXBElement && cls != JAXBElement.class) {
cls = JAXBElement.class;
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
index 43b0c75cd9b..91e2c965d6f 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
@@ -77,8 +77,8 @@
public class MultipartProvider extends AbstractConfigurableProvider
implements MessageBodyReader<Object>, MessageBodyWriter<Object> {
- private static final String ACTIVE_JAXRS_PROVIDER_KEY = "active.jaxrs.provider";
private static final String SUPPORT_TYPE_AS_MULTIPART = "support.type.as.multipart";
+ private static final String SINGLE_PART_IS_COLLECTION = "single.multipart.is.collection";
private static final Logger LOG = LogUtils.getL7dLogger(MultipartProvider.class);
private static final ResourceBundle BUNDLE = BundleUtils.getBundle(MultipartProvider.class);
private static final Set<Class<?>> WELL_KNOWN_MULTIPART_CLASSES;
@@ -171,7 +171,9 @@ public Object readFrom(Class<Object> c, Type t, Annotation[] anns, MediaType mt,
Multipart id = AnnotationUtils.getAnnotation(anns, Multipart.class);
Attachment multipart = AttachmentUtils.getMultipart(id, mt, infos);
if (multipart != null) {
- if (collectionExpected && !mediaTypeSupported(multipart.getContentType())) {
+ if (collectionExpected
+ && !mediaTypeSupported(multipart.getContentType())
+ && !MessageUtils.isTrue(mc.getContextualProperty(SINGLE_PART_IS_COLLECTION))) {
List<Attachment> allMultiparts = AttachmentUtils.getMatchingAttachments(id, infos);
return getAttachmentCollection(t, allMultiparts, anns);
} else {
@@ -379,13 +381,13 @@ private String getContentId(Annotation[] anns, int id) {
Annotation[] anns,
String mimeType, int id) {
MediaType mt = JAXRSUtils.toMediaType(mimeType);
- mc.put(ACTIVE_JAXRS_PROVIDER_KEY, this);
+ mc.put(ProviderFactory.ACTIVE_JAXRS_PROVIDER_KEY, this);
MessageBodyWriter<T> r = null;
try {
r = mc.getProviders().getMessageBodyWriter(cls, genericType, anns, mt);
} finally {
- mc.put("active.jaxrs.provider", null);
+ mc.put(ProviderFactory.ACTIVE_JAXRS_PROVIDER_KEY, null);
}
if (r == null) {
org.apache.cxf.common.i18n.Message message =
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
index 97561f5f288..31721b0cea8 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
@@ -24,6 +24,8 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.MessageBodyReader;
@@ -35,28 +37,35 @@
import org.apache.cxf.jaxrs.utils.HttpUtils;
import org.apache.cxf.jaxrs.utils.InjectionUtils;
-public class PrimitiveTextProvider<T>
+@Consumes("text/plain")
+@Produces("text/plain")
+public class PrimitiveTextProvider<T> extends AbstractConfigurableProvider
implements MessageBodyReader<T>, MessageBodyWriter<T> {
-
- private static boolean isSupported(Class<?> type) {
- return InjectionUtils.isPrimitive(type);
+
+ private static boolean isSupported(Class<?> type, MediaType mt) {
+ boolean isPrimitive = InjectionUtils.isPrimitiveOnly(type);
+ return isPrimitive && mt.isCompatible(MediaType.TEXT_PLAIN_TYPE);
}
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mt) {
- return isSupported(type);
+ return isSupported(type, mt);
}
public T readFrom(Class<T> type, Type genType, Annotation[] anns, MediaType mt,
MultivaluedMap<String, String> headers, InputStream is) throws IOException {
String string = IOUtils.toString(is, HttpUtils.getEncoding(mt, "UTF-8"));
+ if (StringUtils.isEmpty(string)) {
+ reportEmptyContentLength();
+ }
if (type == Character.class) {
- char character = StringUtils.isEmpty(string) ? ' ' : string.charAt(0);
+ char character = string.charAt(0);
return type.cast(Character.valueOf(character));
}
return InjectionUtils.handleParameter(
string,
false,
type,
+ genType,
anns,
ParameterType.REQUEST_BODY, null);
@@ -67,14 +76,16 @@ public long getSize(T t, Class<?> type, Type genericType, Annotation[] annotatio
}
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mt) {
- return isSupported(type);
+ return isSupported(type, mt);
}
public void writeTo(T obj, Class<?> type, Type genType, Annotation[] anns,
MediaType mt, MultivaluedMap<String, Object> headers,
OutputStream os) throws IOException {
String encoding = HttpUtils.getSetEncoding(mt, headers, "UTF-8");
- os.write(obj.toString().getBytes(encoding));
+ byte[] bytes = obj.toString().getBytes(encoding);
+ os.write(bytes);
+
}
-
+
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
index 2a0fed822a8..b59d7e3ce21 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
@@ -42,7 +42,6 @@
import javax.ws.rs.Produces;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Configuration;
-import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.ContextResolver;
@@ -61,12 +60,12 @@
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.jaxrs.ext.ContextProvider;
-import org.apache.cxf.jaxrs.impl.HttpHeadersImpl;
import org.apache.cxf.jaxrs.impl.MetadataMap;
import org.apache.cxf.jaxrs.impl.ReaderInterceptorMBR;
import org.apache.cxf.jaxrs.impl.WriterInterceptorMBW;
import org.apache.cxf.jaxrs.impl.tl.ThreadLocalProxy;
import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
+import org.apache.cxf.jaxrs.model.ApplicationInfo;
import org.apache.cxf.jaxrs.model.ClassResourceInfo;
import org.apache.cxf.jaxrs.model.FilterProviderInfo;
import org.apache.cxf.jaxrs.model.ProviderInfo;
@@ -80,12 +79,12 @@
public abstract class ProviderFactory {
public static final String DEFAULT_FILTER_NAME_BINDING = "org.apache.cxf.filter.binding";
public static final String PROVIDER_SELECTION_PROPERTY_CHANGED = "provider.selection.property.changed";
+ public static final String ACTIVE_JAXRS_PROVIDER_KEY = "active.jaxrs.provider";
protected static final String SERVER_FACTORY_NAME = "org.apache.cxf.jaxrs.provider.ServerProviderFactory";
protected static final String CLIENT_FACTORY_NAME = "org.apache.cxf.jaxrs.client.ClientProviderFactory";
protected static final String IGNORE_TYPE_VARIABLES = "org.apache.cxf.jaxrs.providers.ignore.typevars";
- private static final String ACTIVE_JAXRS_PROVIDER_KEY = "active.jaxrs.provider";
private static final Logger LOG = LogUtils.getL7dLogger(ProviderFactory.class);
private static final String JAXB_PROVIDER_NAME = "org.apache.cxf.jaxrs.provider.JAXBElementProvider";
@@ -96,8 +95,6 @@
new NameKeyMap<ProviderInfo<ReaderInterceptor>>(true);
protected Map<NameKey, ProviderInfo<WriterInterceptor>> writerInterceptors =
new NameKeyMap<ProviderInfo<WriterInterceptor>>(true);
- private Configuration dynamicConfiguration;
-
private List<ProviderInfo<MessageBodyReader<?>>> messageReaders =
new ArrayList<ProviderInfo<MessageBodyReader<?>>>();
@@ -117,6 +114,7 @@
private Bus bus;
private ProviderFactory baseFactory;
+ private Comparator<?> providerComparator;
protected ProviderFactory(ProviderFactory baseFactory, Bus bus) {
this.baseFactory = baseFactory;
@@ -140,6 +138,7 @@ protected static void initBaseFactory(ProviderFactory factory) {
new SourceProvider<Object>(),
new DataSourceProvider<Object>(),
new FormEncodingProvider<Object>(),
+ new StringTextProvider(),
new PrimitiveTextProvider<Object>(),
createProvider(JAXB_PROVIDER_NAME),
createProvider(JSON_PROVIDER_NAME),
@@ -162,42 +161,25 @@ protected static Object createProvider(String className) {
return null;
}
- public void setDynamicConfiguration(Configuration config) {
- // Whatever is set inside Configuration is also set in this ProviderFactory
- // We use it only to support Configuration injection at a basic level
- this.dynamicConfiguration = config;
- }
-
- public Configuration getDynamicConfiguration() {
- return dynamicConfiguration;
- }
+ public abstract Configuration getConfiguration(Message message);
public <T> ContextResolver<T> createContextResolver(Type contextType,
Message m) {
boolean isRequestor = MessageUtils.isRequestor(m);
Message requestMessage = isRequestor ? m.getExchange().getOutMessage()
: m.getExchange().getInMessage();
- HttpHeaders requestHeaders = new HttpHeadersImpl(requestMessage);
- MediaType mt = null;
Message responseMessage = isRequestor ? m.getExchange().getInMessage()
: m.getExchange().getOutMessage();
+ Object ctProperty = null;
if (responseMessage != null) {
- Object ctProperty = responseMessage.get(Message.CONTENT_TYPE);
- if (ctProperty == null) {
- List<MediaType> accepts = requestHeaders.getAcceptableMediaTypes();
- if (accepts.size() > 0) {
- mt = accepts.get(0);
- }
- } else {
- mt = JAXRSUtils.toMediaType(ctProperty.toString());
- }
+ ctProperty = responseMessage.get(Message.CONTENT_TYPE);
} else {
- mt = requestHeaders.getMediaType();
+ ctProperty = requestMessage.get(Message.CONTENT_TYPE);
}
-
- return createContextResolver(contextType, m,
- mt == null ? MediaType.WILDCARD_TYPE : mt);
+ MediaType mt = ctProperty != null ? JAXRSUtils.toMediaType(ctProperty.toString())
+ : MediaType.WILDCARD_TYPE;
+ return createContextResolver(contextType, m, mt);
}
@@ -268,12 +250,14 @@ public Configuration getDynamicConfiguration() {
return null;
}
- public <T> ParamConverter<T> createParameterHandler(Class<T> paramType, Annotation[] anns) {
+ public <T> ParamConverter<T> createParameterHandler(Class<T> paramType,
+ Type genericType,
+ Annotation[] anns) {
if (newParamConverters != null) {
anns = anns != null ? anns : new Annotation[]{};
for (ParamConverterProvider newParamConverter : newParamConverters) {
- ParamConverter<T> converter = newParamConverter.getConverter(paramType, paramType, anns);
+ ParamConverter<T> converter = newParamConverter.getConverter(paramType, genericType, anns);
if (converter != null) {
return converter;
}
@@ -289,7 +273,7 @@ public Configuration getDynamicConfiguration() {
Class<?> providerClass,
boolean injectContext) {
- Class<?> mapperClass = ClassHelper.getRealClass(em.getProvider());
+ Class<?> mapperClass = ClassHelper.getRealClass(bus, em.getProvider());
Type[] types = null;
if (m != null && MessageUtils.isTrue(m.getContextualProperty(IGNORE_TYPE_VARIABLES))) {
types = new Type[]{mapperClass};
@@ -474,7 +458,7 @@ public Configuration getDynamicConfiguration() {
protected void setBusProviders() {
List<Object> extensions = new LinkedList<Object>();
- final String alreadySetProp = "bus.providers.set";
+ final String alreadySetProp = "bus.providers.set." + this.hashCode();
if (bus.getProperty(alreadySetProp) == null) {
addBusExtension(extensions,
MessageBodyReader.class,
@@ -512,7 +496,7 @@ protected void setCommonProviders(List<ProviderInfo<? extends Object>> theProvid
List<ProviderInfo<WriterInterceptor>> writeInts =
new LinkedList<ProviderInfo<WriterInterceptor>>();
for (ProviderInfo<? extends Object> provider : theProviders) {
- Class<?> providerCls = ClassHelper.getRealClass(provider.getProvider());
+ Class<?> providerCls = ClassHelper.getRealClass(bus, provider.getProvider());
if (MessageBodyReader.class.isAssignableFrom(providerCls)) {
addProviderToList(messageReaders, provider);
@@ -567,7 +551,7 @@ protected void injectContextValues(ProviderInfo<?> pi, Message m) {
protected void addProviderToList(List<?> list, ProviderInfo<?> provider) {
List<ProviderInfo<?>> list2 = CastUtils.cast(list);
for (ProviderInfo<?> pi : list2) {
- if (pi.getProvider().getClass() == provider.getProvider().getClass()) {
+ if (pi.getProvider() == provider.getProvider()) {
return;
}
}
@@ -602,11 +586,26 @@ void injectContextProxiesIntoProvider(ProviderInfo<?> pi, Application app) {
* x/y;q=1.0 < x/y;q=0.7.
*/
private void sortReaders() {
- Collections.sort(messageReaders, new MessageBodyReaderComparator());
+ if (providerComparator == null) {
+ Collections.sort(messageReaders, new MessageBodyReaderComparator());
+ } else {
+ doCustomSort(messageReaders);
+ }
+ }
+ private <T> void sortWriters() {
+ if (providerComparator == null) {
+ Collections.sort(messageWriters, new MessageBodyWriterComparator());
+ } else {
+ doCustomSort(messageWriters);
+ }
}
- private void sortWriters() {
- Collections.sort(messageWriters, new MessageBodyWriterComparator());
+ private <T> void doCustomSort(List<?> listOfProviders) {
+ @SuppressWarnings("unchecked")
+ List<T> theProviders = (List<T>)messageReaders;
+ @SuppressWarnings("unchecked")
+ Comparator<? super T> theComparator = (Comparator<? super T>)providerComparator;
+ Collections.sort((List<T>)theProviders, theComparator);
}
private void sortContextResolvers() {
@@ -762,17 +761,16 @@ public int compare(ProviderInfo<MessageBodyReader<?>> p1,
MessageBodyReader<?> e1 = p1.getProvider();
MessageBodyReader<?> e2 = p2.getProvider();
- int result = compareClasses(e1, e2);
- if (result != 0) {
- return result;
- }
-
List<MediaType> types1 = JAXRSUtils.getProviderConsumeTypes(e1);
types1 = JAXRSUtils.sortMediaTypes(types1, null);
List<MediaType> types2 = JAXRSUtils.getProviderConsumeTypes(e2);
types2 = JAXRSUtils.sortMediaTypes(types2, null);
- return JAXRSUtils.compareSortedMediaTypes(types1, types2, null);
+ int result = JAXRSUtils.compareSortedMediaTypes(types1, types2, null);
+ if (result != 0) {
+ return result;
+ }
+ return compareClasses(e1, e2);
}
}
@@ -961,11 +959,11 @@ protected static int compareClasses(Object o1, Object o2) {
protected static int compareClasses(Class<?> expectedCls, Object o1, Object o2) {
Class<?> cl1 = ClassHelper.getRealClass(o1);
Class<?> cl2 = ClassHelper.getRealClass(o2);
-
Type[] types1 = getGenericInterfaces(cl1, expectedCls);
Type[] types2 = getGenericInterfaces(cl2, expectedCls);
-
- if (types1.length == 0 && types2.length > 0) {
+ if (types1.length == 0 && types2.length == 0) {
+ return 0;
+ } else if (types1.length == 0 && types2.length > 0) {
return 1;
} else if (types1.length > 0 && types2.length == 0) {
return -1;
@@ -991,9 +989,9 @@ protected static int compareClasses(Class<?> expectedCls, Object o1, Object o2)
Type genericSuperType = cls.getGenericSuperclass();
if (genericSuperType instanceof ParameterizedType) {
Class<?> actualType = InjectionUtils.getActualType(genericSuperType);
- if (expectedClass == actualType) {
+ if (actualType != null && actualType.isAssignableFrom(expectedClass)) {
return new Type[]{genericSuperType};
- } else if (actualType != null && expectedClass.isAssignableFrom(actualType)) {
+ } else if (expectedClass.isAssignableFrom(actualType)) {
return new Type[]{};
}
}
@@ -1056,12 +1054,14 @@ public T getContext(Class<?> cls) {
}
}
- protected ProviderInfo<? extends Object> createProviderFromConstructor(Constructor<?> c,
- Map<Class<?>, Object> values) {
+ public static ProviderInfo<? extends Object> createProviderFromConstructor(Constructor<?> c,
+ Map<Class<?>, Object> values,
+ Bus theBus,
+ boolean checkContexts) {
Map<Class<?>, Map<Class<?>, ThreadLocalProxy<?>>> proxiesMap =
- CastUtils.cast((Map<?, ?>)getBus().getProperty(AbstractResourceInfo.CONSTRUCTOR_PROXY_MAP));
+ CastUtils.cast((Map<?, ?>)theBus.getProperty(AbstractResourceInfo.CONSTRUCTOR_PROXY_MAP));
Map<Class<?>, ThreadLocalProxy<?>> existingProxies = null;
if (proxiesMap != null) {
existingProxies = proxiesMap.get(c.getDeclaringClass());
@@ -1091,7 +1091,12 @@ public T getContext(Class<?> cls) {
proxies.put(paramTypes[i], proxy);
}
}
- return new ProviderInfo<Object>(instance, proxies, getBus());
+ boolean isApplication = Application.class.isAssignableFrom(c.getDeclaringClass());
+ if (isApplication) {
+ return new ApplicationInfo((Application)instance, proxies, theBus);
+ } else {
+ return new ProviderInfo<Object>(instance, proxies, theBus, checkContexts);
+ }
}
protected static class NameKey {
@@ -1220,14 +1225,18 @@ protected static boolean filterContractSupported(ProviderInfo<?> provider,
if (o == null) {
continue;
}
- if (o instanceof Constructor) {
+ Object provider = o;
+ if (provider.getClass() == Class.class) {
+ provider = ResourceUtils.createProviderInstance((Class<?>)provider);
+ }
+ if (provider instanceof Constructor) {
Map<Class<?>, Object> values = CastUtils.cast(application == null ? null
: Collections.singletonMap(Application.class, application.getProvider()));
- theProviders.add(createProviderFromConstructor((Constructor<?>)o, values));
- } else if (o instanceof ProviderInfo) {
- theProviders.add((ProviderInfo<?>)o);
+ theProviders.add(createProviderFromConstructor((Constructor<?>)provider, values, getBus(), true));
+ } else if (provider instanceof ProviderInfo) {
+ theProviders.add((ProviderInfo<?>)provider);
} else {
- theProviders.add(new ProviderInfo<Object>(o, getBus()));
+ theProviders.add(new ProviderInfo<Object>(provider, getBus()));
}
}
return theProviders;
@@ -1243,4 +1252,12 @@ protected static boolean filterContractSupported(ProviderInfo<?> provider,
}
return null;
}
+
+ public Comparator<?> getProviderComparator() {
+ return providerComparator;
+ }
+
+ public void setProviderComparator(Comparator<?> providerComparator) {
+ this.providerComparator = providerComparator;
+ }
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
index dfcb3a82186..c7b33e656c3 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
@@ -91,6 +91,7 @@
private boolean strictPathCheck;
private String locationPrefix;
private String resourceExtension;
+ private boolean includeResource;
private MessageContext mc;
@@ -191,7 +192,9 @@ public void writeTo(Object o, Class<?> clazz, Type genericType, Annotation[] ann
RequestDispatcher rd = getRequestDispatcher(sc, clazz, theServletPath + path);
try {
- mc.put(AbstractHTTPDestination.REQUEST_REDIRECTED, Boolean.TRUE);
+ if (!includeResource) {
+ mc.put(AbstractHTTPDestination.REQUEST_REDIRECTED, Boolean.TRUE);
+ }
HttpServletRequestFilter requestFilter = new HttpServletRequestFilter(
servletRequest, path, theServletPath, saveParametersAsAttributes);
@@ -203,10 +206,14 @@ public void writeTo(Object o, Class<?> clazz, Type genericType, Annotation[] ann
}
setRequestParameters(requestFilter);
logRedirection(path, attributeName, o);
- rd.forward(requestFilter, mc.getHttpServletResponse());
+ if (includeResource) {
+ rd.include(requestFilter, mc.getHttpServletResponse());
+ } else {
+ rd.forward(requestFilter, mc.getHttpServletResponse());
+ }
} catch (Throwable ex) {
mc.put(AbstractHTTPDestination.REQUEST_REDIRECTED, Boolean.FALSE);
- ex.printStackTrace();
+ LOG.warning(ExceptionUtils.getStackTrace(ex));
throw ExceptionUtils.toInternalServerErrorException(ex, null);
}
}
@@ -395,6 +402,18 @@ public void setUseCurrentServlet(boolean useCurrentServlet) {
this.useCurrentServlet = useCurrentServlet;
}
+ public void setIncludeResource(boolean includeResource) {
+ this.includeResource = includeResource;
+ }
+
+ public void setLocationPrefix(String locationPrefix) {
+ this.locationPrefix = locationPrefix;
+ }
+
+ public void setResourceExtension(String resourceExtension) {
+ this.resourceExtension = resourceExtension;
+ }
+
protected static class HttpServletRequestFilter extends HttpServletRequestWrapper {
private Map<String, String[]> params;
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
index d04272abe62..0094ace7369 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ServerProviderFactory.java
@@ -30,14 +30,14 @@
import java.util.Map;
import java.util.Set;
+import javax.ws.rs.Priorities;
import javax.ws.rs.RuntimeType;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.ContainerResponseFilter;
import javax.ws.rs.container.DynamicFeature;
import javax.ws.rs.container.PreMatching;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.Configurable;
import javax.ws.rs.core.Configuration;
+import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.ReaderInterceptor;
@@ -47,11 +47,13 @@
import org.apache.cxf.BusFactory;
import org.apache.cxf.common.util.ClassHelper;
import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.jaxrs.impl.ConfigurableImpl;
import org.apache.cxf.jaxrs.impl.RequestPreprocessor;
import org.apache.cxf.jaxrs.impl.ResourceInfoImpl;
import org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper;
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
+import org.apache.cxf.jaxrs.model.ApplicationInfo;
import org.apache.cxf.jaxrs.model.BeanParamInfo;
import org.apache.cxf.jaxrs.model.ClassResourceInfo;
import org.apache.cxf.jaxrs.model.FilterProviderInfo;
@@ -78,10 +80,10 @@
new ArrayList<ProviderInfo<ContainerRequestFilter>>(1);
private Map<NameKey, ProviderInfo<ContainerRequestFilter>> postMatchContainerRequestFilters =
new NameKeyMap<ProviderInfo<ContainerRequestFilter>>(true);
- private Map<NameKey, ProviderInfo<ContainerResponseFilter>> postMatchContainerResponseFilters =
+ private Map<NameKey, ProviderInfo<ContainerResponseFilter>> containerResponseFilters =
new NameKeyMap<ProviderInfo<ContainerResponseFilter>>(false);
private RequestPreprocessor requestPreprocessor;
- private ProviderInfo<Application> application;
+ private ApplicationInfo application;
private Set<DynamicFeature> dynamicFeatures = new LinkedHashSet<DynamicFeature>();
private Map<Class<?>, BeanParamInfo> beanParams = new HashMap<Class<?>, BeanParamInfo>();
@@ -132,6 +134,8 @@ private static synchronized ServerProviderFactory initBaseFactory(Bus bus) {
factory.setProviders(new WebApplicationExceptionMapper());
bus.setProperty(SHARED_SERVER_FACTORY, factory);
+
+
return factory;
}
@@ -167,8 +171,7 @@ private static synchronized ServerProviderFactory initBaseFactory(Bus bus) {
}
public List<ProviderInfo<ContainerResponseFilter>> getContainerResponseFilters(Set<String> names) {
- return getBoundFilters(postMatchContainerResponseFilters,
- names);
+ return getBoundFilters(containerResponseFilters, names);
}
public void addBeanParamInfo(BeanParamInfo bpi) {
@@ -217,7 +220,7 @@ protected void setProviders(Object... providers) {
prepareProviders((Object[])providers, application);
super.setCommonProviders(theProviders);
for (ProviderInfo<? extends Object> provider : theProviders) {
- Class<?> providerCls = ClassHelper.getRealClass(provider.getProvider());
+ Class<?> providerCls = ClassHelper.getRealClass(getBus(), provider.getProvider());
if (filterContractSupported(provider, providerCls, ContainerRequestFilter.class)) {
addContainerRequestFilter(postMatchRequestFilters,
@@ -245,12 +248,12 @@ protected void setProviders(Object... providers) {
new BindingPriorityComparator(ContainerRequestFilter.class, true));
mapInterceptorFilters(postMatchContainerRequestFilters, postMatchRequestFilters,
ContainerRequestFilter.class, true);
- mapInterceptorFilters(postMatchContainerResponseFilters, postMatchResponseFilters,
+ mapInterceptorFilters(containerResponseFilters, postMatchResponseFilters,
ContainerResponseFilter.class, false);
injectContextProxies(exceptionMappers,
postMatchContainerRequestFilters.values(), preMatchContainerRequestFilters,
- postMatchContainerResponseFilters.values());
+ containerResponseFilters.values());
}
@Override
@@ -299,11 +302,11 @@ public RequestPreprocessor getRequestPreprocessor() {
return requestPreprocessor;
}
- public void setApplicationProvider(ProviderInfo<Application> app) {
+ public void setApplicationProvider(ApplicationInfo app) {
application = app;
}
- public ProviderInfo<Application> getApplicationProvider() {
+ public ApplicationInfo getApplicationProvider() {
return application;
}
@@ -319,9 +322,9 @@ public void clearExceptionMapperProxies() {
public void clearProviders() {
super.clearProviders();
exceptionMappers.clear();
- postMatchContainerRequestFilters.clear();
- postMatchContainerResponseFilters.clear();
preMatchContainerRequestFilters.clear();
+ postMatchContainerRequestFilters.clear();
+ containerResponseFilters.clear();
}
@Override
@@ -340,13 +343,16 @@ public void applyDynamicFeatures(List<ClassResourceInfo> list) {
}
}
+ public Configuration getConfiguration(Message m) {
+ return new ServerConfigurationImpl();
+ }
+
private void doApplyDynamicFeatures(ClassResourceInfo cri) {
Set<OperationResourceInfo> oris = cri.getMethodDispatcher().getOperationResourceInfos();
for (OperationResourceInfo ori : oris) {
for (DynamicFeature feature : dynamicFeatures) {
FeatureContext featureContext = new MethodFeatureContextImpl(ori);
feature.configure(new ResourceInfoImpl(ori), featureContext);
- super.setDynamicConfiguration(featureContext.getConfiguration());
}
}
Collection<ClassResourceInfo> subs = cri.getSubResources();
@@ -364,17 +370,23 @@ protected static boolean isPrematching(Class<?> filterCls) {
private class MethodFeatureContextImpl implements FeatureContext {
- private Configurable<FeatureContext> configImpl;
+ private MethodFeatureContextConfigurable configImpl;
private OperationResourceInfo ori;
private String nameBinding;
public MethodFeatureContextImpl(OperationResourceInfo ori) {
this.ori = ori;
configImpl = new MethodFeatureContextConfigurable(this);
+ if (application != null) {
+ Map<String, Object> appProps = application.getProvider().getProperties();
+ for (Map.Entry<String, Object> entry : appProps.entrySet()) {
+ configImpl.property(entry.getKey(), entry.getValue());
+ }
+ }
nameBinding = DEFAULT_FILTER_NAME_BINDING
+ ori.getClassResourceInfo().getServiceClass().getName()
+ "."
- + ori.getMethodToInvoke().getName();
+ + ori.getMethodToInvoke().toString();
}
@@ -495,6 +507,130 @@ public static void releaseRequestState(ServerProviderFactory factory, Message me
}
-
+ private class ServerConfigurationImpl implements Configuration {
+ public ServerConfigurationImpl() {
+
+ }
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ return application != null ? application.getProvider().getClasses()
+ : Collections.<Class<?>>emptySet();
+ }
+
+ @Override
+ public Set<Object> getInstances() {
+ return application != null ? application.getProvider().getSingletons()
+ : Collections.emptySet();
+ }
+
+ @Override
+ public boolean isEnabled(Feature f) {
+ return dynamicFeatures.contains(f);
+ }
+
+ @Override
+ public boolean isEnabled(Class<? extends Feature> featureCls) {
+ for (DynamicFeature f : dynamicFeatures) {
+ if (featureCls.isAssignableFrom(f.getClass())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isRegistered(Object o) {
+ return isRegistered(preMatchContainerRequestFilters, o)
+ || isRegistered(postMatchContainerRequestFilters.values(), o)
+ || isRegistered(containerResponseFilters.values(), o)
+ || isRegistered(readerInterceptors.values(), o)
+ || isRegistered(writerInterceptors.values(), o);
+ }
+
+ @Override
+ public boolean isRegistered(Class<?> cls) {
+ return isRegistered(preMatchContainerRequestFilters, cls)
+ || isRegistered(postMatchContainerRequestFilters.values(), cls)
+ || isRegistered(containerResponseFilters.values(), cls)
+ || isRegistered(readerInterceptors.values(), cls)
+ || isRegistered(writerInterceptors.values(), cls);
+ }
+
+ @Override
+ public Map<Class<?>, Integer> getContracts(Class<?> cls) {
+ Map<Class<?>, Integer> map = new HashMap<Class<?>, Integer>();
+ if (isRegistered(cls)) {
+ if (ContainerRequestFilter.class.isAssignableFrom(cls)) {
+ boolean isPreMatch = cls.getAnnotation(PreMatching.class) != null;
+ map.put(ContainerRequestFilter.class,
+ getPriority(isPreMatch ? preMatchContainerRequestFilters
+ : postMatchContainerRequestFilters.values(), cls, ContainerRequestFilter.class));
+ }
+ if (ContainerResponseFilter.class.isAssignableFrom(cls)) {
+ map.put(ContainerResponseFilter.class,
+ getPriority(containerResponseFilters.values(), cls, ContainerResponseFilter.class));
+ }
+ if (WriterInterceptor.class.isAssignableFrom(cls)) {
+ map.put(WriterInterceptor.class,
+ getPriority(writerInterceptors.values(), cls, WriterInterceptor.class));
+ }
+ if (ReaderInterceptor.class.isAssignableFrom(cls)) {
+ map.put(ReaderInterceptor.class,
+ getPriority(readerInterceptors.values(), cls, ReaderInterceptor.class));
+ }
+ }
+ return map;
+ }
+
+ @Override
+ public Map<String, Object> getProperties() {
+ return application != null ? application.getProperties()
+ : Collections.<String, Object>emptyMap();
+ }
+
+ @Override
+ public Object getProperty(String name) {
+ return getProperties().get(name);
+ }
+
+ @Override
+ public Collection<String> getPropertyNames() {
+ return getProperties().keySet();
+ }
+
+ @Override
+ public RuntimeType getRuntimeType() {
+ return RuntimeType.SERVER;
+ }
+
+ private boolean isRegistered(Collection<?> list, Object o) {
+ Collection<ProviderInfo<?>> list2 = CastUtils.cast(list);
+ for (ProviderInfo<?> pi : list2) {
+ if (pi.getProvider() == o) {
+ return true;
+ }
+ }
+ return false;
+ }
+ private boolean isRegistered(Collection<?> list, Class<?> cls) {
+ Collection<ProviderInfo<?>> list2 = CastUtils.cast(list);
+ for (ProviderInfo<?> pi : list2) {
+ if (cls.isAssignableFrom(pi.getProvider().getClass())) {
+ return true;
+ }
+ }
+ return false;
+ }
+ private Integer getPriority(Collection<?> list, Class<?> cls, Class<?> filterClass) {
+ Collection<ProviderInfo<?>> list2 = CastUtils.cast(list);
+ for (ProviderInfo<?> pi : list2) {
+ if (pi instanceof FilterProviderInfo && pi.getProvider().getClass().isAssignableFrom(cls)) {
+ return ((FilterProviderInfo<?>)pi).getPriority(filterClass);
+ }
+ }
+ return Priorities.USER;
+ }
+ }
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
index ab3a6e28bdd..789fb438a2a 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
@@ -24,6 +24,7 @@
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
+import java.util.logging.Logger;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
@@ -43,6 +44,7 @@
import org.w3c.dom.Document;
+import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.io.CachedOutputStream;
import org.apache.cxf.jaxrs.ext.MessageContext;
import org.apache.cxf.jaxrs.ext.xml.XMLSource;
@@ -62,6 +64,7 @@
MessageBodyReader<T>, MessageBodyWriter<T> {
private static final String PREFERRED_FORMAT = "source-preferred-format";
+ private static final Logger LOG = LogUtils.getL7dLogger(BinaryDataProvider.class);
@Context
private MessageContext context;
@@ -88,41 +91,46 @@ public T readFrom(Class<T> source, Type genericType, Annotation[] annotations, M
theSource = SAXSource.class;
}
}
-
- if (DOMSource.class.isAssignableFrom(theSource) || Document.class.isAssignableFrom(theSource)) {
-
- boolean docRequired = Document.class.isAssignableFrom(theSource);
- XMLStreamReader reader = getReader(is);
- try {
- Document doc = StaxUtils.read(reader);
- return source.cast(docRequired ? doc : new DOMSource(doc));
- } catch (DepthExceededStaxException e) {
- throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413));
- } catch (XMLStreamException e) {
- if (e.getMessage() != null && e.getMessage().startsWith("Maximum Number")) {
- throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413));
- } else {
- throw ExceptionUtils.toBadRequestException(e, null);
- }
- } catch (Exception e) {
- IOException ioex = new IOException("Problem creating a Source object");
- ioex.setStackTrace(e.getStackTrace());
- throw ioex;
- } finally {
+ try {
+ if (DOMSource.class.isAssignableFrom(theSource) || Document.class.isAssignableFrom(theSource)) {
+
+ boolean docRequired = Document.class.isAssignableFrom(theSource);
+ XMLStreamReader reader = getReader(is);
try {
- reader.close();
+ Document doc = StaxUtils.read(reader);
+ return source.cast(docRequired ? doc : new DOMSource(doc));
+ } catch (DepthExceededStaxException e) {
+ throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413));
} catch (XMLStreamException e) {
- //ignore
+ if (e.getMessage() != null && e.getMessage().startsWith("Maximum Number")) {
+ throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413));
+ } else {
+ throw ExceptionUtils.toBadRequestException(e, null);
+ }
+ } catch (Exception e) {
+ IOException ioex = new IOException("Problem creating a Source object");
+ ioex.setStackTrace(e.getStackTrace());
+ throw ioex;
+ } finally {
+ try {
+ reader.close();
+ } catch (XMLStreamException e) {
+ //ignore
+ }
}
+ } else if (SAXSource.class.isAssignableFrom(theSource)
+ || StaxSource.class.isAssignableFrom(theSource)) {
+ return source.cast(new StaxSource(getReader(is)));
+ } else if (StreamSource.class.isAssignableFrom(theSource)
+ || Source.class.isAssignableFrom(theSource)) {
+ return source.cast(new StreamSource(getRealStream(is)));
+ } else if (XMLSource.class.isAssignableFrom(theSource)) {
+ return source.cast(new XMLSource(getRealStream(is)));
}
- } else if (SAXSource.class.isAssignableFrom(theSource)
- || StaxSource.class.isAssignableFrom(theSource)) {
- return source.cast(new StaxSource(getReader(is)));
- } else if (StreamSource.class.isAssignableFrom(theSource)
- || Source.class.isAssignableFrom(theSource)) {
- return source.cast(new StreamSource(getRealStream(is)));
- } else if (XMLSource.class.isAssignableFrom(theSource)) {
- return source.cast(new XMLSource(getRealStream(is)));
+ } catch (ClassCastException e) {
+ String msg = "Unsupported class: " + source.getName();
+ LOG.warning(msg);
+ throw ExceptionUtils.toInternalServerErrorException(null, null);
}
throw new IOException("Unrecognized source");
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/StringTextProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/StringTextProvider.java
new file mode 100644
index 00000000000..e6e25dab109
--- /dev/null
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/StringTextProvider.java
@@ -0,0 +1,78 @@
+/**
+ * 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.apache.cxf.jaxrs.provider;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.jaxrs.utils.HttpUtils;
+
+public class StringTextProvider extends AbstractConfigurableProvider
+ implements MessageBodyReader<String>, MessageBodyWriter<String> {
+ private int bufferSize = IOUtils.DEFAULT_BUFFER_SIZE;
+ public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mt) {
+ return String.class == type;
+ }
+
+ public String readFrom(Class<String> type, Type genType, Annotation[] anns, MediaType mt,
+ MultivaluedMap<String, String> headers, InputStream is) throws IOException {
+ return IOUtils.toString(is, HttpUtils.getEncoding(mt, "UTF-8"));
+ }
+
+ public long getSize(String t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mt) {
+ return -1;
+ }
+
+ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mt) {
+ return String.class == type;
+ }
+
+ public void writeTo(String obj, Class<?> type, Type genType, Annotation[] anns,
+ MediaType mt, MultivaluedMap<String, Object> headers,
+ OutputStream os) throws IOException {
+ String encoding = HttpUtils.getSetEncoding(mt, headers, "UTF-8");
+ //REVISIT try to avoid instantiating the whole byte array
+ byte[] bytes = obj.getBytes(encoding);
+ if (bytes.length > bufferSize) {
+ int pos = 0;
+ while (pos < bytes.length) {
+ int bl = bytes.length - pos;
+ if (bl > bufferSize) {
+ bl = bufferSize;
+ }
+ os.write(bytes, pos, bl);
+ pos += bl;
+ }
+ } else {
+ os.write(bytes);
+ }
+ }
+ public void setBufferSize(int bufferSize) {
+ this.bufferSize = bufferSize;
+ }
+}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
index 304f595c3c8..528ad800d6f 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
@@ -87,7 +87,7 @@
private static final String ABSOLUTE_PATH_PARAMETER = "absolute.path";
private static final String BASE_PATH_PARAMETER = "base.path";
private static final String RELATIVE_PATH_PARAMETER = "relative.path";
-
+ private static final String XSLT_TEMPLATE_PROPERTY = "xslt.template";
private SAXTransformerFactory factory;
private Templates inTemplates;
private Templates outTemplates;
@@ -106,6 +106,7 @@
private String systemId;
private boolean supportJaxbOnly;
+ private boolean refreshTemplates;
public void setSupportJaxbOnly(boolean support) {
this.supportJaxbOnly = support;
@@ -170,7 +171,7 @@ protected Templates getTemplatesFromAnnotation(Class<?> cls,
XSLTTransform ann = getXsltTransformAnn(anns, mt);
if (ann != null) {
t = annotationTemplates.get(ann.value());
- if (t == null) {
+ if (t == null || refreshTemplates) {
String path = ann.value();
final String cp = "classpath:";
if (!path.startsWith(cp)) {
@@ -181,7 +182,7 @@ protected Templates getTemplatesFromAnnotation(Class<?> cls,
createTemplates(ClassLoaderUtils.getResource(ann.value(), cls));
}
if (t != null) {
- annotationTemplates.putIfAbsent(ann.value(), t);
+ annotationTemplates.put(ann.value(), t);
}
}
}
@@ -218,7 +219,11 @@ protected XSLTTransform getXsltTransformAnn(Annotation[] anns, MediaType mt) {
protected Templates getInTemplates(Annotation[] anns, MediaType mt) {
- Templates t = inTemplates != null ? inTemplates
+ Templates t = createTemplatesFromContext();
+ if (t != null) {
+ return t;
+ }
+ t = inTemplates != null ? inTemplates
: inMediaTemplates != null ? inMediaTemplates.get(mt.getType() + "/" + mt.getSubtype()) : null;
if (t == null) {
t = getAnnotationTemplates(anns);
@@ -227,7 +232,11 @@ protected Templates getInTemplates(Annotation[] anns, MediaType mt) {
}
protected Templates getOutTemplates(Annotation[] anns, MediaType mt) {
- Templates t = outTemplates != null ? outTemplates
+ Templates t = createTemplatesFromContext();
+ if (t != null) {
+ return t;
+ }
+ t = outTemplates != null ? outTemplates
: outMediaTemplates != null ? outMediaTemplates.get(mt.getType() + "/" + mt.getSubtype()) : null;
if (t == null) {
t = getAnnotationTemplates(anns);
@@ -487,6 +496,17 @@ protected Templates createTemplates(String loc) {
return null;
}
+ protected Templates createTemplatesFromContext() {
+ MessageContext mc = getContext();
+ if (mc != null) {
+ String template = (String)mc.getContextualProperty(XSLT_TEMPLATE_PROPERTY);
+ if (template != null) {
+ return createTemplates(template);
+ }
+ }
+ return null;
+ }
+
protected Templates createTemplates(URL urlStream) {
try {
if (urlStream == null) {
@@ -511,6 +531,10 @@ protected Templates createTemplates(URL urlStream) {
return null;
}
+ public void setRefreshTemplates(boolean refresh) {
+ this.refreshTemplates = refresh;
+ }
+
private static class TemplatesImpl implements Templates {
private Templates templates;
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/KerberosAuthenticationFilter.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/KerberosAuthenticationFilter.java
index abc2bf4fac1..c23739b07dd 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/KerberosAuthenticationFilter.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/KerberosAuthenticationFilter.java
@@ -73,7 +73,7 @@ public void filter(ContainerRequestContext context) {
List<String> authHeaders = messageContext.getHttpHeaders()
.getRequestHeader(HttpHeaders.AUTHORIZATION);
- if (authHeaders.size() != 1) {
+ if (authHeaders == null || authHeaders.size() != 1) {
LOG.fine("No Authorization header is available");
throw ExceptionUtils.toNotAuthorizedException(null, getFaultResponse());
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
index 0b3e516ad6b..db9ff27d2a5 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
@@ -23,10 +23,12 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.logging.Logger;
import javax.servlet.ServletConfig;
@@ -38,12 +40,16 @@
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.PrimitiveUtils;
import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.feature.Feature;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.interceptor.Interceptor;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider;
import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import org.apache.cxf.jaxrs.model.ApplicationInfo;
+import org.apache.cxf.jaxrs.model.ProviderInfo;
+import org.apache.cxf.jaxrs.provider.ProviderFactory;
import org.apache.cxf.jaxrs.utils.InjectionUtils;
import org.apache.cxf.jaxrs.utils.ResourceUtils;
import org.apache.cxf.message.Message;
@@ -62,6 +68,7 @@
private static final String IGNORE_APP_PATH_PARAM = "jaxrs.application.address.ignore";
private static final String SERVICE_CLASSES_PARAM = "jaxrs.serviceClasses";
private static final String PROVIDERS_PARAM = "jaxrs.providers";
+ private static final String FEATURES_PARAM = "jaxrs.features";
private static final String OUT_INTERCEPTORS_PARAM = "jaxrs.outInterceptors";
private static final String OUT_FAULT_INTERCEPTORS_PARAM = "jaxrs.outFaultInterceptors";
private static final String IN_INTERCEPTORS_PARAM = "jaxrs.inInterceptors";
@@ -83,11 +90,32 @@
private static final String JAXRS_APPLICATION_PARAM = "javax.ws.rs.Application";
private ClassLoader classLoader;
+ private Application application;
+
+ public CXFNonSpringJaxrsServlet() {
+
+ }
+
+ public CXFNonSpringJaxrsServlet(Application app) {
+ this.application = app;
+ }
+
+ public CXFNonSpringJaxrsServlet(Object singletonService) {
+ this(Collections.singleton(singletonService));
+ }
+ public CXFNonSpringJaxrsServlet(Set<Object> applicationSingletons) {
+ this(new ApplicationImpl(applicationSingletons));
+ }
@Override
public void init(ServletConfig servletConfig) throws ServletException {
super.init(servletConfig);
+ if (getApplication() != null) {
+ createServerFromApplication(servletConfig);
+ return;
+ }
+
String applicationClass = servletConfig.getInitParameter(JAXRS_APPLICATION_PARAM);
if (applicationClass != null) {
createServerFromApplication(applicationClass, servletConfig);
@@ -128,10 +156,32 @@ public void init(ServletConfig servletConfig) throws ServletException {
bean.setResourceProvider(entry.getKey(), entry.getValue());
}
setExtensions(bean, servletConfig);
-
+ List<? extends Feature> features = getFeatures(servletConfig, splitChar);
+ bean.setFeatures(features);
bean.create();
}
+ protected List<? extends Feature> getFeatures(ServletConfig servletConfig, String splitChar)
+ throws ServletException {
+
+ String featuresList = servletConfig.getInitParameter(FEATURES_PARAM);
+ if (featuresList == null) {
+ return Collections.< Feature >emptyList();
+ }
+ String[] classNames = StringUtils.split(featuresList, splitChar);
+ List< Feature > features = new ArrayList< Feature >();
+ for (String cName : classNames) {
+ Map<String, List<String>> props = new HashMap<String, List<String>>();
+ String theName = getClassNameAndProperties(cName, props);
+ if (theName.length() != 0) {
+ Class<?> cls = loadClass(theName);
+ if (Feature.class.isAssignableFrom(cls)) {
+ features.add((Feature)createSingletonInstance(cls, props, servletConfig));
+ }
+ }
+ }
+ return features;
+ }
protected String getParameterSplitChar(ServletConfig servletConfig) {
String param = servletConfig.getInitParameter(PARAMETER_SPLIT_CHAR);
if (!StringUtils.isEmpty(param) && SPACE_PARAMETER_SPLIT_CHAR.equals(param.trim())) {
@@ -369,20 +419,25 @@ protected Object createSingletonInstance(Class<?> cls, Map<String, List<String>>
if (c == null) {
throw new ServletException("No valid constructor found for " + cls.getName());
}
- boolean isDefault = c.getParameterTypes().length == 0;
- if (!isDefault && (c.getParameterTypes().length != 1
- || c.getParameterTypes()[0] != ServletConfig.class
- && c.getParameterTypes()[0] != ServletContext.class)) {
- throw new ServletException("Resource classes with singleton scope can only have "
- + "ServletConfig or ServletContext instances injected through their constructors");
- }
- Object[] values = isDefault ? new Object[]{}
- : new Object[]{c.getParameterTypes()[0] == ServletConfig.class ? sc : sc.getServletContext()};
+ boolean isApplication = Application.class.isAssignableFrom(c.getDeclaringClass());
try {
- Object instance = c.newInstance(values);
+ ProviderInfo<? extends Object> provider = null;
+ if (c.getParameterTypes().length == 0) {
+ if (isApplication) {
+ provider = new ApplicationInfo((Application)c.newInstance(), getBus());
+ } else {
+ provider = new ProviderInfo<Object>(c.newInstance(), getBus(), false);
+ }
+ } else {
+ Map<Class<?>, Object> values = new HashMap<Class<?>, Object>();
+ values.put(ServletContext.class, sc.getServletContext());
+ values.put(ServletConfig.class, sc);
+ provider = ProviderFactory.createProviderFromConstructor(c, values, getBus(), isApplication);
+ }
+ Object instance = provider.getProvider();
injectProperties(instance, props);
configureSingleton(instance);
- return instance;
+ return isApplication ? provider : instance;
} catch (InstantiationException ex) {
ex.printStackTrace();
throw new ServletException("Resource class " + cls.getName()
@@ -430,8 +485,7 @@ protected void configureSingleton(Object instance) {
protected void createServerFromApplication(String applicationNames, ServletConfig servletConfig)
throws ServletException {
- String ignoreParam = servletConfig.getInitParameter(IGNORE_APP_PATH_PARAM);
- boolean ignoreApplicationPath = ignoreParam == null || MessageUtils.isTrue(ignoreParam);
+ boolean ignoreApplicationPath = isIgnoreApplicationPath(servletConfig);
String[] classNames = StringUtils.split(applicationNames, getParameterSplitChar(servletConfig));
@@ -441,9 +495,9 @@ protected void createServerFromApplication(String applicationNames, ServletConfi
}
for (String cName : classNames) {
- Application app = createApplicationInstance(cName, servletConfig);
+ ApplicationInfo providerApp = createApplicationInfo(cName, servletConfig);
- JAXRSServerFactoryBean bean = ResourceUtils.createApplication(app,
+ JAXRSServerFactoryBean bean = ResourceUtils.createApplication(providerApp.getProvider(),
ignoreApplicationPath,
getStaticSubResolutionValue(servletConfig));
String splitChar = getParameterSplitChar(servletConfig);
@@ -452,18 +506,55 @@ protected void createServerFromApplication(String applicationNames, ServletConfi
setExtensions(bean, servletConfig);
setDocLocation(bean, servletConfig);
setSchemasLocations(bean, servletConfig);
-
bean.setBus(getBus());
+ bean.setApplication(providerApp);
bean.create();
}
}
- protected Application createApplicationInstance(String appClassName, ServletConfig servletConfig)
+ protected boolean isIgnoreApplicationPath(ServletConfig servletConfig) {
+ String ignoreParam = servletConfig.getInitParameter(IGNORE_APP_PATH_PARAM);
+ return ignoreParam == null || MessageUtils.isTrue(ignoreParam);
+ }
+
+ protected void createServerFromApplication(ServletConfig servletConfig)
+ throws ServletException {
+
+ JAXRSServerFactoryBean bean = ResourceUtils.createApplication(getApplication(),
+ isIgnoreApplicationPath(servletConfig),
+ getStaticSubResolutionValue(servletConfig));
+ bean.setBus(getBus());
+ bean.setApplication(getApplication());
+ bean.create();
+ }
+
+ protected Application createApplicationInstance(String appClassName, ServletConfig servletConfig)
+ throws ServletException {
+ return null;
+ }
+ protected ApplicationInfo createApplicationInfo(String appClassName, ServletConfig servletConfig)
throws ServletException {
+
+ Application customApp = createApplicationInstance(appClassName, servletConfig);
+ if (customApp != null) {
+ return new ApplicationInfo(customApp, getBus());
+ }
Map<String, List<String>> props = new HashMap<String, List<String>>();
appClassName = getClassNameAndProperties(appClassName, props);
Class<?> appClass = loadApplicationClass(appClassName);
- return (Application)createSingletonInstance(appClass, props, servletConfig);
+ ApplicationInfo appInfo = (ApplicationInfo)createSingletonInstance(appClass, props, servletConfig);
+ Map<String, Object> servletProps = new HashMap<String, Object>();
+ ServletContext servletContext = servletConfig.getServletContext();
+ for (Enumeration<String> names = servletContext.getInitParameterNames(); names.hasMoreElements();) {
+ String name = names.nextElement();
+ servletProps.put(name, servletContext.getInitParameter(name));
+ }
+ for (Enumeration<String> names = servletConfig.getInitParameterNames(); names.hasMoreElements();) {
+ String name = names.nextElement();
+ servletProps.put(name, servletConfig.getInitParameter(name));
+ }
+ appInfo.setOverridingProps(servletProps);
+ return appInfo;
}
protected Class<?> loadApplicationClass(String appClassName) throws ServletException {
@@ -492,4 +583,18 @@ protected Application createApplicationInstance(String appClassName, ServletConf
public void setClassLoader(ClassLoader loader) {
this.classLoader = loader;
}
+
+ protected Application getApplication() {
+ return application;
+ }
+
+ private static class ApplicationImpl extends Application {
+ private Set<Object> applicationSingletons;
+ public ApplicationImpl(Set<Object> applicationSingletons) {
+ this.applicationSingletons = applicationSingletons;
+ }
+ public Set<Object> getSingletons() {
+ return applicationSingletons;
+ }
+ }
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/AbstractSpringComponentScanServer.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/AbstractSpringComponentScanServer.java
index cb05d1cbb1b..31284aa5c2b 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/AbstractSpringComponentScanServer.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/AbstractSpringComponentScanServer.java
@@ -37,23 +37,31 @@
private List<ResourceProvider> resourceProviders = new LinkedList<ResourceProvider>();
private List<Object> jaxrsProviders = new LinkedList<Object>();
-
-
- protected void setRootResources(JAXRSServerFactoryBean factory) {
+ private Class<? extends Annotation> serviceAnnotation;
+ protected AbstractSpringComponentScanServer() {
+
+ }
+ protected AbstractSpringComponentScanServer(Class<? extends Annotation> serviceAnnotation) {
+ this.serviceAnnotation = serviceAnnotation;
+ }
+ protected void setJaxrsResources(JAXRSServerFactoryBean factory) {
boolean checkJaxrsRoots = checkJaxrsRoots();
boolean checkJaxrsProviders = checkJaxrsProviders();
for (String beanName : applicationContext.getBeanDefinitionNames()) {
- if (checkJaxrsRoots && isAnnotationAvailable(beanName, Path.class)) {
+ if (checkJaxrsRoots && isAnnotationAvailable(beanName, Path.class)
+ && (serviceAnnotation == null || isAnnotationAvailable(beanName, serviceAnnotation))) {
SpringResourceFactory resourceFactory = new SpringResourceFactory(beanName);
resourceFactory.setApplicationContext(applicationContext);
resourceProviders.add(resourceFactory);
- } else if (checkJaxrsProviders && isAnnotationAvailable(beanName, Provider.class)) {
+ } else if (checkJaxrsProviders && isAnnotationAvailable(beanName, Provider.class)
+ && (serviceAnnotation == null || isAnnotationAvailable(beanName, serviceAnnotation))) {
jaxrsProviders.add(applicationContext.getBean(beanName));
}
}
factory.setResourceProviders(getResourceProviders());
+ factory.setProviders(getJaxrsProviders());
}
protected <A extends Annotation> boolean isAnnotationAvailable(String beanName, Class<A> annClass) {
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/AbstractSpringConfigurationFactory.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/AbstractSpringConfigurationFactory.java
index f8f827e6f50..1ee09fa2bf9 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/AbstractSpringConfigurationFactory.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/AbstractSpringConfigurationFactory.java
@@ -44,8 +44,8 @@ protected Server createJaxRsServer() {
factory.setTransportId(getTransportId());
factory.setBus(applicationContext.getBean(SpringBus.class));
- setRootResources(factory);
- factory.setProviders(getJaxrsProviders());
+ setJaxrsResources(factory);
+
factory.setInInterceptors(getInInterceptors());
factory.setOutInterceptors(getOutInterceptors());
factory.setOutFaultInterceptors(getOutFaultInterceptors());
@@ -59,7 +59,7 @@ public void setApplicationContext(ApplicationContext ac) throws BeansException {
applicationContext = ac;
}
- protected abstract void setRootResources(JAXRSServerFactoryBean factory);
+ protected abstract void setJaxrsResources(JAXRSServerFactoryBean factory);
protected List<Object> getJaxrsProviders() {
return Collections.emptyList();
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java
index 7adfaa58319..b9a1ae3151e 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java
@@ -32,6 +32,7 @@
import org.w3c.dom.Element;
import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.apache.cxf.common.util.ClasspathScanner;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
@@ -44,6 +45,7 @@
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
@@ -77,6 +79,8 @@ protected void mapAttribute(BeanDefinitionBuilder bean, Element e, String name,
bean.addPropertyValue(name, q);
} else if ("basePackages".equals(name)) {
bean.addPropertyValue("basePackages", ClasspathScanner.parsePackages(val));
+ } else if ("serviceAnnotation".equals(name)) {
+ bean.addPropertyValue("serviceAnnotation", val);
} else {
mapToProperty(bean, name, val);
}
@@ -150,7 +154,12 @@ protected boolean hasBusProperty() {
private List<SpringResourceFactory> tempFactories;
private List<String> basePackages;
+ private String serviceAnnotation;
private ApplicationContext context;
+ private boolean serviceBeansAvailable;
+ private boolean providerBeansAvailable;
+ private boolean resourceProvidersAvailable;
+
public SpringJAXRSServerFactoryBean() {
super();
}
@@ -165,11 +174,28 @@ public void destroy() {
server.destroy();
}
}
-
+ @Override
+ public void setServiceBeans(List<Object> beans) {
+ super.setServiceBeans(beans);
+ this.serviceBeansAvailable = true;
+ }
+ @Override
+ public void setProviders(List<? extends Object> beans) {
+ super.setProviders(beans);
+ this.providerBeansAvailable = true;
+ }
+ public void setResourceProviders(List<ResourceProvider> rps) {
+ super.setResourceProviders(rps);
+ this.resourceProvidersAvailable = true;
+ }
public void setBasePackages(List<String> basePackages) {
this.basePackages = basePackages;
}
+ public void setServiceAnnotation(String serviceAnnotation) {
+ this.serviceAnnotation = serviceAnnotation;
+ }
+
public void setTempResourceProviders(List<SpringResourceFactory> providers) {
tempFactories = providers;
}
@@ -186,32 +212,64 @@ public void setApplicationContext(ApplicationContext ctx) throws BeansException
factories.add(factory);
}
tempFactories.clear();
- super.setResourceProviders(factories);
+ setResourceProviders(factories);
}
-
- try {
- if (basePackages != null) {
+ Class<? extends Annotation> serviceAnnotationClass = loadServiceAnnotationClass();
+ if (basePackages != null) {
+ try {
@SuppressWarnings("unchecked")
final Map< Class< ? extends Annotation >, Collection< Class< ? > > > classes =
ClasspathScanner.findClasses(basePackages, Provider.class, Path.class);
- this.setProviders(createBeans(classes.get(Provider.class)));
- this.setServiceBeans(createBeans(classes.get(Path.class)));
+ this.setServiceBeans(createBeansFromDiscoveredClasses(classes.get(Path.class),
+ serviceAnnotationClass));
+ this.setProviders(createBeansFromDiscoveredClasses(classes.get(Provider.class),
+ serviceAnnotationClass));
+ } catch (IOException ex) {
+ throw new BeanDefinitionStoreException("I/O failure during classpath scanning", ex);
+ } catch (ClassNotFoundException ex) {
+ throw new BeanCreationException("Failed to create bean from classfile", ex);
}
- } catch (IOException ex) {
- throw new BeanDefinitionStoreException("I/O failure during classpath scanning", ex);
- } catch (ClassNotFoundException ex) {
- throw new BeanCreationException("Failed to create bean from classfile", ex);
+ } else if (serviceAnnotationClass != null
+ || !serviceBeansAvailable && !providerBeansAvailable && !resourceProvidersAvailable) {
+ discoverContextResources(serviceAnnotationClass);
}
-
if (bus == null) {
setBus(BusWiringBeanFactoryPostProcessor.addDefaultBus(ctx));
}
}
- private List<Object> createBeans(Collection<Class<?>> classes) {
+ private void discoverContextResources(Class<? extends Annotation> serviceAnnotationClass) {
+ AbstractSpringComponentScanServer scanServer =
+ new AbstractSpringComponentScanServer(serviceAnnotationClass) { };
+ scanServer.setApplicationContext(context);
+ scanServer.setJaxrsResources(this);
+ }
+ @SuppressWarnings("unchecked")
+ private Class<? extends Annotation> loadServiceAnnotationClass() {
+ if (serviceAnnotation != null) {
+ try {
+ return (Class<? extends Annotation>)ClassLoaderUtils.loadClass(serviceAnnotation, this.getClass());
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ return null;
+ }
+ private List<Object> createBeansFromDiscoveredClasses(Collection<Class<?>> classes,
+ Class<? extends Annotation> serviceClassAnnotation) {
+ AutowireCapableBeanFactory beanFactory = context.getAutowireCapableBeanFactory();
final List< Object > providers = new ArrayList< Object >();
for (final Class< ? > clazz: classes) {
- providers.add(context.getAutowireCapableBeanFactory().createBean(clazz));
+ if (serviceClassAnnotation != null && clazz.getAnnotation(serviceClassAnnotation) == null) {
+ continue;
+ }
+ Object bean = null;
+ try {
+ bean = beanFactory.createBean(clazz, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true);
+ } catch (Exception ex) {
+ bean = beanFactory.createBean(clazz);
+ }
+ providers.add(bean);
}
return providers;
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java
index 99f496cf7fb..826f619d868 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/SpringResourceFactory.java
@@ -54,6 +54,7 @@
private boolean callPreDestroy = true;
private String postConstructMethodName;
private String preDestroyMethodName;
+ private Object singletonInstance;
public SpringResourceFactory() {
@@ -78,21 +79,32 @@ private void init() {
isSingleton = ac.isSingleton(beanId);
if (!isSingleton) {
isPrototype = ac.isPrototype(beanId);
+ } else {
+ try {
+ singletonInstance = ac.getBean(beanId);
+ } catch (BeansException ex) {
+ // ignore for now, can be to do with no default constructor available
+ }
}
+
}
/**
* {@inheritDoc}
*/
public Object getInstance(Message m) {
- ProviderInfo<?> application = m == null ? null
- : (ProviderInfo<?>)m.getExchange().getEndpoint().get(Application.class.getName());
- Map<Class<?>, Object> mapValues = CastUtils.cast(application == null ? null
- : Collections.singletonMap(Application.class, application.getProvider()));
- Object[] values = ResourceUtils.createConstructorArguments(c, m, !isSingleton(), mapValues);
- Object instance = values.length > 0 ? ac.getBean(beanId, values) : ac.getBean(beanId);
- initInstance(m, instance);
- return instance;
+ if (singletonInstance != null) {
+ return singletonInstance;
+ } else {
+ ProviderInfo<?> application = m == null ? null
+ : (ProviderInfo<?>)m.getExchange().getEndpoint().get(Application.class.getName());
+ Map<Class<?>, Object> mapValues = CastUtils.cast(application == null ? null
+ : Collections.singletonMap(Application.class, application.getProvider()));
+ Object[] values = ResourceUtils.createConstructorArguments(c, m, !isSingleton(), mapValues);
+ Object instance = values.length > 0 ? ac.getBean(beanId, values) : ac.getBean(beanId);
+ initInstance(m, instance);
+ return instance;
+ }
}
protected void initInstance(Message m, Object instance) {
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
index 345fa7c8130..27f8cafc4ed 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
@@ -151,52 +151,65 @@ public static String getAnnotationValue(Annotation a) {
return null;
}
- public static Method getAnnotatedMethod(Method m) {
- Method annotatedMethod = doGetAnnotatedMethod(m);
+ public static Method getAnnotatedMethod(Class<?> serviceClass, Method m) {
+ Method annotatedMethod = doGetAnnotatedMethod(serviceClass, m);
return annotatedMethod == null ? m : annotatedMethod;
}
- private static Method doGetAnnotatedMethod(Method m) {
+ private static Method doGetAnnotatedMethod(Class<?> serviceClass, Method m) {
- if (m == null) {
- return m;
- }
-
- for (Annotation a : m.getAnnotations()) {
- if (AnnotationUtils.isMethodAnnotation(a)) {
- return m;
+ if (m != null) {
+ for (Annotation a : m.getAnnotations()) {
+ if (AnnotationUtils.isMethodAnnotation(a)) {
+ return m;
+ }
}
- }
- for (Annotation[] paramAnnotations : m.getParameterAnnotations()) {
- if (isValidParamAnnotations(paramAnnotations)) {
- LOG.warning("Method " + m.getName() + " in " + m.getDeclaringClass().getName()
- + " has no JAX-RS Path or HTTP Method annotations");
- return m;
+ for (Annotation[] paramAnnotations : m.getParameterAnnotations()) {
+ if (isValidParamAnnotations(paramAnnotations)) {
+ LOG.warning("Method " + m.getName() + " in " + m.getDeclaringClass().getName()
+ + " has no JAX-RS Path or HTTP Method annotations");
+ return m;
+ }
}
- }
-
- Class<?> superC = m.getDeclaringClass().getSuperclass();
- if (superC != null && Object.class != superC) {
- try {
- Method method = doGetAnnotatedMethod(superC.getMethod(m.getName(), m.getParameterTypes()));
- if (method != null) {
- return method;
+
+ Class<?> declaringClass = m.getDeclaringClass();
+ Class<?> superC = declaringClass.getSuperclass();
+ if (superC != null && Object.class != superC) {
+ try {
+ Method method = doGetAnnotatedMethod(serviceClass,
+ superC.getMethod(m.getName(), m.getParameterTypes()));
+ if (method != null) {
+ return method;
+ }
+ } catch (NoSuchMethodException ex) {
+ // ignore
}
- } catch (NoSuchMethodException ex) {
- // ignore
}
- }
- for (Class<?> i : m.getDeclaringClass().getInterfaces()) {
- try {
- Method method = doGetAnnotatedMethod(i.getMethod(m.getName(), m.getParameterTypes()));
- if (method != null) {
- return method;
+ for (Class<?> i : declaringClass.getInterfaces()) {
+ try {
+ Method method = doGetAnnotatedMethod(serviceClass,
+ i.getMethod(m.getName(), m.getParameterTypes()));
+ if (method != null) {
+ return method;
+ }
+ } catch (NoSuchMethodException ex) {
+ // ignore
}
- } catch (NoSuchMethodException ex) {
- // ignore
+ }
+ if (declaringClass != serviceClass && !declaringClass.isInterface()) {
+ for (Class<?> i : serviceClass.getInterfaces()) {
+ try {
+ Method method = doGetAnnotatedMethod(serviceClass,
+ i.getMethod(m.getName(), m.getParameterTypes()));
+ if (method != null) {
+ return method;
+ }
+ } catch (NoSuchMethodException ex) {
+ // ignore
+ }
+ }
}
}
-
return null;
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ExceptionUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ExceptionUtils.java
index 079310ea9e7..20977eea85b 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ExceptionUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ExceptionUtils.java
@@ -19,6 +19,9 @@
package org.apache.cxf.jaxrs.utils;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
@@ -34,6 +37,12 @@
private ExceptionUtils() {
}
+ public static String getStackTrace(Throwable ex) {
+ StringWriter sw = new StringWriter();
+ ex.printStackTrace(new PrintWriter(sw));
+ return sw.toString();
+ }
+
public static Class<?> getWebApplicationExceptionClass(Response exResponse,
Class<?> defaultExceptionType) {
return SpecExceptions.getWebApplicationExceptionClass(exResponse, defaultExceptionType);
@@ -79,7 +88,7 @@ public static boolean propogateException(Message m) {
if (mapper != null) {
try {
response = mapper.toResponse(ex);
- } catch (Exception mapperEx) {
+ } catch (Throwable mapperEx) {
inMessage.getExchange().put(JAXRSUtils.EXCEPTION_FROM_MAPPER, "true");
mapperEx.printStackTrace();
return Response.serverError().build();
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
index ac4dbca9021..76c66e9fb51 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
@@ -22,7 +22,6 @@
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -72,7 +71,9 @@
private static final String HTTP_SCHEME = "http";
private static final String LOCAL_HOST_IP_ADDRESS = "127.0.0.1";
+ private static final String LOCAL_HOST_IP_ADDRESS_SCHEME = "://" + LOCAL_HOST_IP_ADDRESS;
private static final String ANY_IP_ADDRESS = "0.0.0.0";
+ private static final String ANY_IP_ADDRESS_SCHEME = "://" + ANY_IP_ADDRESS;
private static final int DEFAULT_HTTP_PORT = 80;
private static final Pattern ENCODE_PATTERN = Pattern.compile("%[0-9a-fA-F][0-9a-fA-F]");
@@ -134,13 +135,7 @@ public static String urlEncode(String value) {
public static String urlEncode(String value, String enc) {
- try {
- value = URLEncoder.encode(value, enc);
- } catch (UnsupportedEncodingException ex) {
- throw new RuntimeException(ex);
- }
-
- return value;
+ return UrlUtils.urlEncode(value, enc);
}
public static String pathEncode(String value) {
@@ -205,7 +200,7 @@ public static RuntimeDelegate getOtherRuntimeDelegate() {
}
public static HeaderDelegate<Object> getHeaderDelegate(Object o) {
- return getHeaderDelegate(getOtherRuntimeDelegate(), o);
+ return getHeaderDelegate(RuntimeDelegate.getInstance(), o);
}
@SuppressWarnings("unchecked")
@@ -226,6 +221,9 @@ public static RuntimeDelegate getOtherRuntimeDelegate() {
}
public static void convertHeaderValuesToString(Map<String, List<Object>> headers, boolean delegateOnly) {
+ if (headers == null) {
+ return;
+ }
RuntimeDelegate rd = getOtherRuntimeDelegate();
if (rd == null && delegateOnly) {
return;
@@ -343,7 +341,8 @@ public static URI toAbsoluteUri(URI u, Message message) {
HttpServletRequest request =
(HttpServletRequest)message.get(AbstractHTTPDestination.HTTP_REQUEST);
boolean absolute = u.isAbsolute();
- if (request != null && (!absolute || isLocalHostOrAnyIpAddress(u))) {
+ StringBuilder uriBuf = new StringBuilder();
+ if (request != null && (!absolute || isLocalHostOrAnyIpAddress(u, uriBuf))) {
String serverAndPort = request.getServerName();
boolean localAddressUsed = false;
if (absolute) {
@@ -367,7 +366,7 @@ public static URI toAbsoluteUri(URI u, Message message) {
u = URI.create(base + u.toString());
} else {
int originalPort = u.getPort();
- String hostValue = u.getHost().equals(ANY_IP_ADDRESS)
+ String hostValue = uriBuf.toString().contains(ANY_IP_ADDRESS_SCHEME)
? ANY_IP_ADDRESS : LOCAL_HOST_IP_ADDRESS;
String replaceValue = originalPort == -1 ? hostValue : hostValue + ":" + originalPort;
u = URI.create(u.toString().replace(replaceValue, serverAndPort));
@@ -376,9 +375,12 @@ public static URI toAbsoluteUri(URI u, Message message) {
return u;
}
- private static boolean isLocalHostOrAnyIpAddress(URI u) {
- String host = u.getHost();
- return host != null && (LOCAL_HOST_IP_ADDRESS.equals(host)) || ANY_IP_ADDRESS.equals(host);
+ private static boolean isLocalHostOrAnyIpAddress(URI u, StringBuilder uriStringBuffer) {
+ String uriString = u.toString();
+ boolean result = uriString.contains(LOCAL_HOST_IP_ADDRESS_SCHEME)
+ || uriString.contains(ANY_IP_ADDRESS_SCHEME);
+ uriStringBuffer.append(uriString);
+ return result;
}
public static void resetRequestURI(Message m, String requestURI) {
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
index 7cbfea97b7b..2d95659c655 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
@@ -38,6 +38,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -335,6 +336,7 @@ public static Object extractFromMethod(Object requestObject,
public static <T> T handleParameter(String value,
boolean decoded,
Class<T> pClass,
+ Type genericType,
Annotation[] paramAnns,
ParameterType pType,
Message message) {
@@ -352,11 +354,15 @@ public static Object extractFromMethod(Object requestObject,
value = decodeValue(value, decoded, pType);
- Object result = createFromParameterHandler(value, pClass, paramAnns, message);
+ Object result = null;
+ try {
+ result = createFromParameterHandler(value, pClass, genericType, paramAnns, message);
+ } catch (IllegalArgumentException nfe) {
+ throw createParamConversionException(pType, nfe);
+ }
if (result != null) {
return pClass.cast(result);
}
-
if (pClass.isPrimitive()) {
try {
@SuppressWarnings("unchecked")
@@ -366,15 +372,7 @@ public static Object extractFromMethod(Object requestObject,
// the object is a Boolean object
return ret;
} catch (NumberFormatException nfe) {
- //
- // For path, query & matrix parameters this is 404,
- // for others 400...
- //
- if (pType == ParameterType.PATH || pType == ParameterType.QUERY
- || pType == ParameterType.MATRIX) {
- throw ExceptionUtils.toNotFoundException(nfe, null);
- }
- throw ExceptionUtils.toBadRequestException(nfe, null);
+ throw createParamConversionException(pType, nfe);
}
}
@@ -429,14 +427,26 @@ public static Object extractFromMethod(Object requestObject,
return pClass.cast(result);
}
+ private static RuntimeException createParamConversionException(ParameterType pType, Exception ex) {
+ //
+ // For path, query & matrix parameters this is 404,
+ // for others 400...
+ //
+ if (pType == ParameterType.PATH || pType == ParameterType.QUERY
+ || pType == ParameterType.MATRIX) {
+ return ExceptionUtils.toNotFoundException(ex, null);
+ }
+ return ExceptionUtils.toBadRequestException(ex, null);
+ }
public static <T> T createFromParameterHandler(String value,
Class<T> pClass,
+ Type genericType,
Annotation[] anns,
Message message) {
T result = null;
if (message != null) {
ServerProviderFactory pf = ServerProviderFactory.getInstance(message);
- ParamConverter<T> pm = pf.createParameterHandler(pClass, anns);
+ ParamConverter<T> pm = pf.createParameterHandler(pClass, genericType, anns);
if (pm != null) {
result = pm.fromString(value);
}
@@ -628,7 +638,7 @@ public static Object handleBean(Class<?> paramType, Annotation[] paramAnns,
} else {
paramValue = InjectionUtils.handleParameter(
processedValues.values().iterator().next().get(0),
- decoded, type, paramAnns, pType, message);
+ decoded, type, type, paramAnns, pType, message);
}
if (paramValue != null) {
@@ -678,7 +688,7 @@ private static Object injectIntoMap(Class<?> rawType, Type genericType,
List<String> valuesList = processedValuesEntry.getValue();
for (String value : valuesList) {
Object o = InjectionUtils.handleParameter(value,
- decoded, valueType, paramAnns, pathParam, message);
+ decoded, valueType, valueType, paramAnns, pathParam, message);
theValues.add(convertStringToPrimitive(processedValuesEntry.getKey(), keyType), o);
}
}
@@ -691,7 +701,7 @@ private static Object injectIntoMap(Class<?> rawType, Type genericType,
List<String> valuesList = processedValuesEntry.getValue();
for (String value : valuesList) {
Object o = InjectionUtils.handleParameter(value,
- decoded, valueType, paramAnns, pathParam, message);
+ decoded, valueType, valueType, paramAnns, pathParam, message);
theValues.put(
convertStringToPrimitive(processedValuesEntry.getKey(), keyType),
o);
@@ -860,7 +870,7 @@ private static Object injectIntoCollectionOrArray(Class<?> rawType,
valuesList = checkPathSegment(valuesList, realType, pathParam);
for (int ind = 0; ind < valuesList.size(); ind++) {
Object o = InjectionUtils.handleParameter(valuesList.get(ind), decoded,
- realType, paramAnns, pathParam, message);
+ realType, realType, paramAnns, pathParam, message);
addToCollectionValues(theValues, o, ind);
}
}
@@ -941,7 +951,7 @@ public static Object createParameterObject(List<String> paramValues,
: paramValues.get(0);
}
if (result != null) {
- value = InjectionUtils.handleParameter(result, decoded, paramType,
+ value = InjectionUtils.handleParameter(result, decoded, paramType, genericType,
paramAnns, pathParam, message);
}
}
@@ -1177,7 +1187,7 @@ public static void fillInValuesFromBean(Object bean, String baseName,
if (value == null) {
continue;
}
- if (isPrimitive(value.getClass())) {
+ if (isPrimitive(value.getClass()) || Date.class.isAssignableFrom(value.getClass())) {
values.putSingle(propertyName, value);
} else if (value.getClass().isEnum()) {
values.putSingle(propertyName, value.toString());
@@ -1221,7 +1231,7 @@ public static void fillInValuesFromBean(Object bean, String baseName,
if (methodName.length() <= minLen) {
continue;
}
- String propertyName = methodName.substring(minLen).toLowerCase();
+ String propertyName = StringUtils.uncapitalize(methodName.substring(minLen));
if (m.getReturnType() == Class.class
|| checkIgnorable && canPropertyBeIgnored(m, propertyName)) {
continue;
@@ -1242,13 +1252,15 @@ private static boolean canPropertyBeIgnored(Method m, String propertyName) {
}
return false;
}
-
public static boolean isPrimitive(Class<?> type) {
+ return String.class == type
+ || isPrimitiveOnly(type);
+ }
+ public static boolean isPrimitiveOnly(Class<?> type) {
return type.isPrimitive()
|| Number.class.isAssignableFrom(type)
- || Boolean.class.isAssignableFrom(type)
- || Character.class.isAssignableFrom(type)
- || String.class == type;
+ || Boolean.class == type
+ || Character.class == type;
}
public static String decodeValue(String value, boolean decode, ParameterType param) {
@@ -1284,7 +1296,7 @@ public static Object convertStringToPrimitive(String value, Class<?> cls) {
}
public static Object convertStringToPrimitive(String value, Class<?> cls, Annotation[] anns) {
Message m = JAXRSUtils.getCurrentMessage();
- Object obj = createFromParameterHandler(value, cls, anns, m);
+ Object obj = createFromParameterHandler(value, cls, cls, anns, m);
if (obj != null) {
return obj;
}
@@ -1293,10 +1305,21 @@ public static Object convertStringToPrimitive(String value, Class<?> cls, Annota
} else if (cls.isPrimitive()) {
return PrimitiveUtils.read(value, cls);
} else if (cls.isEnum()) {
- if (m == null || !MessageUtils.getContextualBoolean(m, ENUM_CONVERSION_CASE_SENSITIVE, false)) {
- value = value.toUpperCase();
+ if (m != null && !MessageUtils.getContextualBoolean(m, ENUM_CONVERSION_CASE_SENSITIVE, false)) {
+ obj = invokeValueOf(value.toUpperCase(), cls);
}
- return invokeValueOf(value, cls);
+ if (obj == null) {
+ try {
+ obj = invokeValueOf(value, cls);
+ } catch (RuntimeException ex) {
+ if (m == null) {
+ obj = invokeValueOf(value.toUpperCase(), cls);
+ } else {
+ throw ex;
+ }
+ }
+ }
+ return obj;
} else {
try {
Constructor<?> c = cls.getConstructor(new Class<?>[]{String.class});
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
index 7f4d1f856fc..55f6b1fbde3 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
@@ -82,16 +82,17 @@
import javax.ws.rs.ext.WriterInterceptorContext;
import javax.xml.namespace.QName;
-import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.apache.cxf.common.i18n.BundleUtils;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.PackageUtils;
+import org.apache.cxf.common.util.PropertyUtils;
import org.apache.cxf.common.util.ReflectionUtil;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.jaxrs.JAXRSServiceImpl;
import org.apache.cxf.jaxrs.ext.ContextProvider;
+import org.apache.cxf.jaxrs.ext.DefaultMethod;
import org.apache.cxf.jaxrs.ext.MessageContext;
import org.apache.cxf.jaxrs.ext.MessageContextImpl;
import org.apache.cxf.jaxrs.ext.ProtocolHeaders;
@@ -148,6 +149,7 @@
public static final String ROOT_INSTANCE = "service.root.instance";
public static final String ROOT_PROVIDER = "service.root.provider";
public static final String EXCEPTION_FROM_MAPPER = "exception.from.mapper";
+ public static final String SECOND_JAXRS_EXCEPTION = "second.jaxrs.exception";
public static final String PARTIAL_HIERARCHICAL_MEDIA_SUBTYPE_CHECK =
"media.subtype.partial.check";
public static final String DOC_LOCATION = "wadl.location";
@@ -161,6 +163,8 @@
private static final String PATH_SEGMENT_SEP = "/";
private static final String REPORT_FAULT_MESSAGE_PROPERTY = "org.apache.cxf.jaxrs.report-fault-message";
private static final String NO_CONTENT_EXCEPTION = "javax.ws.rs.core.NoContentException";
+ private static final String HTTP_CHARSET_PARAM = "charset";
+ private static final Annotation[] EMPTY_ANNOTATIONS = new Annotation[0];
private JAXRSUtils() {
}
@@ -390,7 +394,6 @@ public static OperationResourceInfo findTargetMethod(
int methodMatched = 0;
int consumeMatched = 0;
- boolean resourceMethodsAdded = false;
List<OperationResourceInfo> finalPathSubresources = null;
for (Map.Entry<ClassResourceInfo, MultivaluedMap<String, String>> rEntry : matchedResources.entrySet()) {
ClassResourceInfo resource = rEntry.getKey();
@@ -435,7 +438,6 @@ public static OperationResourceInfo findTargetMethod(
if (matchProduceTypes(acceptType, ori)) {
candidateList.put(ori, map);
added = true;
- resourceMethodsAdded = true;
break;
}
}
@@ -455,7 +457,7 @@ public static OperationResourceInfo findTargetMethod(
}
}
}
- if (finalPathSubresources != null && resourceMethodsAdded
+ if (finalPathSubresources != null && pathMatched > 0
&& !MessageUtils.getContextualBoolean(message, KEEP_SUBRESOURCE_CANDIDATES, false)) {
for (OperationResourceInfo key : finalPathSubresources) {
candidateList.remove(key);
@@ -620,7 +622,8 @@ public static Response createResponse(List<ClassResourceInfo> cris, Message msg,
private static boolean matchHttpMethod(String expectedMethod, String httpMethod) {
if (expectedMethod.equalsIgnoreCase(httpMethod)
- || headMethodPossible(expectedMethod, httpMethod)) {
+ || headMethodPossible(expectedMethod, httpMethod)
+ || expectedMethod.equals(DefaultMethod.class.getSimpleName())) {
return true;
}
return false;
@@ -757,28 +760,37 @@ public static float getMediaTypeQualityFactor(String q) {
Message message)
throws IOException, WebApplicationException {
+ Class<?>[] parameterTypes = ori.getInParameterTypes();
+ List<Parameter> paramsInfo = ori.getParameters();
+ boolean preferModelParams = paramsInfo.size() > parameterTypes.length
+ && !PropertyUtils.isTrue(message.getContextualProperty("org.apache.cxf.preferMethodParameters"));
- Method method = ori.getMethodToInvoke();
- Method annotatedMethod = ori.getAnnotatedMethod();
- Method actualMethod = annotatedMethod == null ? method : annotatedMethod;
+ int parameterTypesLengh = preferModelParams ? paramsInfo.size() : parameterTypes.length;
- Class<?>[] parameterTypes = actualMethod.getParameterTypes();
- Parameter[] paramsInfo = ori.getParameters().toArray(new Parameter[ori.getParameters().size()]);
-
- Type[] genericParameterTypes = actualMethod.getGenericParameterTypes();
- Annotation[][] anns = actualMethod.getParameterAnnotations();
- List<Object> params = new ArrayList<Object>(parameterTypes.length);
+ Type[] genericParameterTypes = ori.getInGenericParameterTypes();
+ Annotation[][] anns = ori.getInParameterAnnotations();
+ List<Object> params = new ArrayList<Object>(parameterTypesLengh);
- for (int i = 0; i < parameterTypes.length; i++) {
- Class<?> param = parameterTypes[i];
- Type genericParam = InjectionUtils.processGenericTypeIfNeeded(
- ori.getClassResourceInfo().getServiceClass(), param, genericParameterTypes[i]);
- param = InjectionUtils.updateParamClassToTypeIfNeeded(param, genericParam);
+ for (int i = 0; i < parameterTypesLengh; i++) {
+ Class<?> param = null;
+ Type genericParam = null;
+ Annotation[] paramAnns = null;
+ if (!preferModelParams) {
+ param = parameterTypes[i];
+ genericParam = InjectionUtils.processGenericTypeIfNeeded(
+ ori.getClassResourceInfo().getServiceClass(), param, genericParameterTypes[i]);
+ param = InjectionUtils.updateParamClassToTypeIfNeeded(param, genericParam);
+ paramAnns = anns == null ? EMPTY_ANNOTATIONS : anns[i];
+ } else {
+ param = paramsInfo.get(i).getJavaType();
+ genericParam = param;
+ paramAnns = EMPTY_ANNOTATIONS;
+ }
Object paramValue = processParameter(param,
genericParam,
- anns == null ? new Annotation[0] : anns[i],
- paramsInfo[i],
+ paramAnns,
+ paramsInfo.get(i),
values,
message,
ori);
@@ -1042,7 +1054,7 @@ public static Object createBeanParamValue(Message m, Class<?> clazz, OperationRe
}
Object instance;
try {
- instance = ClassLoaderUtils.loadClass(clazz.getName(), JAXRSUtils.class).newInstance();
+ instance = clazz.newInstance();
} catch (Throwable t) {
throw ExceptionUtils.toInternalServerErrorException(t, null);
}
@@ -1081,7 +1093,7 @@ public static Object createBeanParamValue(Message m, Class<?> clazz, OperationRe
} else if (ContextResolver.class.isAssignableFrom(clazz)) {
o = createContextResolver(genericType, contextMessage);
} else if (Configuration.class.isAssignableFrom(clazz)) {
- o = ProviderFactory.getInstance(contextMessage).getDynamicConfiguration();
+ o = ProviderFactory.getInstance(contextMessage).getConfiguration(contextMessage);
} else if (Application.class.isAssignableFrom(clazz)) {
ProviderInfo<?> providerInfo =
(ProviderInfo<?>)contextMessage.getExchange().getEndpoint().get(Application.class.getName());
@@ -1241,7 +1253,10 @@ public static void getStructuredParams(MultivaluedMap<String, String> queries,
} else {
name = part.substring(0, index);
value = index < part.length() ? part.substring(index + 1) : "";
- if (decode || (decodePlus && value.contains("+"))) {
+ if (decodePlus && value.contains("+")) {
+ value = value.replace('+', ' ');
+ }
+ if (decode) {
value = (";".equals(sep))
? HttpUtils.pathDecode(value) : HttpUtils.urlDecode(value);
}
@@ -1439,6 +1454,10 @@ public static boolean matchMimeTypes(MediaType requestContentType,
for (Map.Entry<String, String> entry : userType.getParameters().entrySet()) {
String value = requiredType.getParameters().get(entry.getKey());
if (value != null && !value.equals(entry.getValue())) {
+ if (HTTP_CHARSET_PARAM.equals(entry.getKey())
+ && value.equalsIgnoreCase(entry.getValue())) {
+ continue;
+ }
parametersMatched = false;
break;
}
@@ -1615,8 +1634,7 @@ public static QName convertStringToQName(String name) {
public static boolean runContainerRequestFilters(ServerProviderFactory pf,
Message m,
boolean preMatch,
- Set<String> names,
- boolean sub) {
+ Set<String> names) {
List<ProviderInfo<ContainerRequestFilter>> containerFilters = preMatch
? pf.getPreMatchContainerRequestFilters() : pf.getPostMatchContainerRequestFilters(names);
if (!containerFilters.isEmpty()) {
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
index 90aac02af2f..314caaf53d3 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
@@ -39,6 +39,7 @@
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.Set;
+import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
@@ -74,9 +75,11 @@
import org.apache.cxf.common.i18n.BundleUtils;
import org.apache.cxf.common.jaxb.JAXBUtils;
import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.ext.DefaultMethod;
import org.apache.cxf.jaxrs.ext.xml.ElementClass;
import org.apache.cxf.jaxrs.ext.xml.XMLName;
import org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider;
@@ -180,17 +183,13 @@ public static Method findPreDestroyMethod(Class<?> c, String name) {
return null;
}
- public static ClassResourceInfo createClassResourceInfo(Map<String, UserResource> resources,
- UserResource model, boolean isRoot, boolean enableStatic) {
- return createClassResourceInfo(resources, model, isRoot, enableStatic,
- BusFactory.getThreadDefaultBus());
- }
-
public static ClassResourceInfo createClassResourceInfo(
- Map<String, UserResource> resources, UserResource model, boolean isRoot, boolean enableStatic,
+ Map<String, UserResource> resources, UserResource model,
+ Class<?> defaultClass,
+ boolean isRoot, boolean enableStatic,
Bus bus) {
-
- Class<?> sClass = loadClass(model.getName());
+ final boolean isDefaultClass = defaultClass != null;
+ Class<?> sClass = !isDefaultClass ? loadClass(model.getName()) : defaultClass;
return createServiceClassResourceInfo(resources, model, sClass, isRoot, enableStatic, bus);
}
@@ -205,33 +204,50 @@ public static ClassResourceInfo createServiceClassResourceInfo(
model.getConsumes(), model.getProduces(), bus);
URITemplate t = URITemplate.createTemplate(model.getPath());
cri.setURITemplate(t);
+
MethodDispatcher md = new MethodDispatcher();
Map<String, UserOperation> ops = model.getOperationsAsMap();
+
+ Method defaultMethod = null;
+ Map<String, Method> methodNames = new HashMap<String, Method>();
for (Method m : cri.getServiceClass().getMethods()) {
- UserOperation op = ops.get(m.getName());
- if (op == null || op.getName() == null) {
+ if (m.getAnnotation(DefaultMethod.class) != null) {
+ // if needed we can also support multiple default methods
+ defaultMethod = m;
+ }
+ methodNames.put(m.getName(), m);
+ }
+
+ for (Map.Entry<String, UserOperation> entry : ops.entrySet()) {
+ UserOperation op = entry.getValue();
+ Method actualMethod = methodNames.get(op.getName());
+ if (actualMethod == null) {
+ actualMethod = defaultMethod;
+ }
+ if (actualMethod == null) {
continue;
}
OperationResourceInfo ori =
- new OperationResourceInfo(m, cri, URITemplate.createTemplate(op.getPath()),
+ new OperationResourceInfo(actualMethod, cri, URITemplate.createTemplate(op.getPath()),
op.getVerb(), op.getConsumes(), op.getProduces(),
op.getParameters(),
op.isOneway());
- String rClassName = m.getReturnType().getName();
+ String rClassName = actualMethod.getReturnType().getName();
if (op.getVerb() == null) {
if (resources.containsKey(rClassName)) {
ClassResourceInfo subCri = rClassName.equals(model.getName()) ? cri
: createServiceClassResourceInfo(resources, resources.get(rClassName),
- m.getReturnType(), false, enableStatic, bus);
+ actualMethod.getReturnType(), false, enableStatic, bus);
if (subCri != null) {
cri.addSubClassResourceInfo(subCri);
- md.bind(ori, m);
+ md.bind(ori, actualMethod);
}
}
} else {
- md.bind(ori, m);
+ md.bind(ori, actualMethod);
}
}
+
cri.setMethodDispatcher(md);
return checkMethodDispatcher(cri) ? cri : null;
@@ -273,9 +289,10 @@ public static ClassResourceInfo createClassResourceInfo(final Class<?> rClass,
private static void evaluateResourceClass(ClassResourceInfo cri, boolean enableStatic) {
MethodDispatcher md = new MethodDispatcher();
- for (Method m : cri.getServiceClass().getMethods()) {
+ Class<?> serviceClass = cri.getServiceClass();
+ for (Method m : serviceClass.getMethods()) {
- Method annotatedMethod = AnnotationUtils.getAnnotatedMethod(m);
+ Method annotatedMethod = AnnotationUtils.getAnnotatedMethod(serviceClass, m);
String httpMethod = AnnotationUtils.getHttpMethodValue(annotatedMethod);
Path path = AnnotationUtils.getMethodAnnotation(annotatedMethod, Path.class);
@@ -572,7 +589,7 @@ private static void getAllTypesForResource(ClassResourceInfo resource,
}
Type type = method.getGenericReturnType();
if (jaxbOnly) {
- checkJaxbType(cls, realReturnType == Response.class ? cls : type, types,
+ checkJaxbType(resource.getServiceClass(), cls, realReturnType == Response.class ? cls : type, types,
method.getAnnotations(), jaxbWriter);
} else {
types.getAllTypes().put(cls, type);
@@ -583,7 +600,7 @@ private static void getAllTypesForResource(ClassResourceInfo resource,
Class<?> inType = method.getParameterTypes()[pm.getIndex()];
Type paramType = method.getGenericParameterTypes()[pm.getIndex()];
if (jaxbOnly) {
- checkJaxbType(inType, paramType, types,
+ checkJaxbType(resource.getServiceClass(), inType, paramType, types,
method.getParameterAnnotations()[pm.getIndex()], jaxbWriter);
} else {
types.getAllTypes().put(inType, paramType);
@@ -611,7 +628,8 @@ private static boolean isRecursiveSubResource(ClassResourceInfo parent, ClassRes
return isRecursiveSubResource(parent.getParent(), sub);
}
- private static void checkJaxbType(Class<?> type,
+ private static void checkJaxbType(Class<?> serviceClass,
+ Class<?> type,
Type genericType,
ResourceTypes types,
Annotation[] anns,
@@ -621,6 +639,12 @@ private static void checkJaxbType(Class<?> type,
type = InjectionUtils.getActualType(genericType);
isCollection = true;
}
+ if (type == Object.class && !(genericType instanceof Class)) {
+ Type theType = InjectionUtils.processGenericTypeIfNeeded(serviceClass,
+ Object.class,
+ genericType);
+ type = InjectionUtils.getActualType(theType);
+ }
if (type == null
|| InjectionUtils.isPrimitive(type)
|| JAXBElement.class.isAssignableFrom(type)
@@ -688,6 +712,14 @@ private static UserOperation getOperationFromElement(Element e) {
Parameter p = new Parameter(paramEl.getAttribute("type"), i, paramEl.getAttribute("name"));
p.setEncoded(Boolean.valueOf(paramEl.getAttribute("encoded")));
p.setDefaultValue(paramEl.getAttribute("defaultValue"));
+ String pClass = paramEl.getAttribute("class");
+ if (!StringUtils.isEmpty(pClass)) {
+ try {
+ p.setJavaType(ClassLoaderUtils.loadClass(pClass, ResourceUtils.class));
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
params.add(p);
}
op.setParameters(params);
@@ -751,16 +783,7 @@ public static JAXRSServerFactoryBean createApplication(Application app, boolean
for (Class<?> cls : app.getClasses()) {
if (isValidApplicationClass(cls, singletons)) {
if (isValidProvider(cls)) {
- try {
- Constructor<?> c = ResourceUtils.findResourceConstructor(cls, false);
- if (c.getParameterTypes().length == 0) {
- providers.add(c.newInstance());
- } else {
- providers.add(c);
- }
- } catch (Throwable ex) {
- throw new RuntimeException("Provider " + cls.getName() + " can not be created", ex);
- }
+ providers.add(createProviderInstance(cls));
} else {
resourceClasses.add(cls);
map.put(cls, new PerRequestResourceProvider(cls));
@@ -804,6 +827,18 @@ public static JAXRSServerFactoryBean createApplication(Application app, boolean
return bean;
}
+ public static Object createProviderInstance(Class<?> cls) {
+ try {
+ Constructor<?> c = ResourceUtils.findResourceConstructor(cls, false);
+ if (c.getParameterTypes().length == 0) {
+ return c.newInstance();
+ } else {
+ return c;
+ }
+ } catch (Throwable ex) {
+ throw new RuntimeException("Provider " + cls.getName() + " can not be created", ex);
+ }
+ }
private static boolean isValidProvider(Class<?> c) {
if (c == null || c == Object.class) {
@@ -871,7 +906,7 @@ public static JAXBContext createJaxbContext(Set<Class<?>> classes, Class<?>[] ex
contextProperties);
return ctx;
} catch (JAXBException ex) {
- LOG.fine("No JAXB context can be created");
+ LOG.log(Level.WARNING, "No JAXB context can be created", ex);
}
return null;
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
index e694eb569c2..f085535609f 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
@@ -88,7 +88,7 @@ public static Schema createSchema(List<String> locations, String catalogLocation
for (String loc : locations) {
List<URL> schemaURLs = new LinkedList<URL>();
- if (loc.lastIndexOf(".") == -1) {
+ if (loc.lastIndexOf(".") == -1 || loc.lastIndexOf('*') != -1) {
schemaURLs = ClasspathScanner.findResources(loc, "xsd");
} else {
URL url = ResourceUtils.getResourceURL(loc, bus);
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/JAXRSBeanValidationInvoker.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/JAXRSBeanValidationInvoker.java
index 22fe956949b..f526c53490e 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/JAXRSBeanValidationInvoker.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/JAXRSBeanValidationInvoker.java
@@ -23,6 +23,7 @@
import javax.ws.rs.core.Response;
+import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.jaxrs.JAXRSInvoker;
import org.apache.cxf.jaxrs.utils.JAXRSUtils;
import org.apache.cxf.message.Exchange;
@@ -40,29 +41,34 @@ public Object invoke(Exchange exchange, final Object serviceObject, Method m, Li
Message message = JAXRSUtils.getCurrentMessage();
BeanValidationProvider theProvider = getProvider(message);
-
- if (isValidateServiceObject()) {
- theProvider.validateBean(serviceObject);
- }
-
- theProvider.validateParameters(serviceObject, m, params.toArray());
-
- Object response = super.invoke(exchange, serviceObject, m, params);
-
- if (response instanceof MessageContentsList) {
- MessageContentsList list = (MessageContentsList)response;
- if (list.size() == 1) {
- Object entity = ((MessageContentsList)list).get(0);
-
- if (entity instanceof Response) {
- theProvider.validateReturnValue(serviceObject, m, ((Response)entity).getEntity());
- } else {
- theProvider.validateReturnValue(serviceObject, m, entity);
+ try {
+ if (isValidateServiceObject()) {
+ theProvider.validateBean(serviceObject);
+ }
+
+ theProvider.validateParameters(serviceObject, m, params.toArray());
+
+ Object response = super.invoke(exchange, serviceObject, m, params);
+
+ if (response instanceof MessageContentsList) {
+ MessageContentsList list = (MessageContentsList)response;
+ if (list.size() == 1) {
+ Object entity = ((MessageContentsList)list).get(0);
+
+ if (entity instanceof Response) {
+ theProvider.validateReturnValue(serviceObject, m, ((Response)entity).getEntity());
+ } else {
+ theProvider.validateReturnValue(serviceObject, m, entity);
+ }
}
}
+ return response;
+ } catch (Fault ex) {
+ throw ex;
+ } catch (Throwable ex) {
+ throw new Fault(ex);
}
- return response;
}
protected BeanValidationProvider getProvider(Message message) {
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/ValidationExceptionMapper.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/ValidationExceptionMapper.java
index c1cbd32392f..b15ad0be817 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/ValidationExceptionMapper.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/ValidationExceptionMapper.java
@@ -29,6 +29,7 @@
import javax.ws.rs.ext.Provider;
import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
import org.apache.cxf.validation.ResponseConstraintViolationException;
@Provider
@@ -37,11 +38,11 @@
@Override
public Response toResponse(ValidationException exception) {
+ Response.Status errorStatus = Response.Status.INTERNAL_SERVER_ERROR;
if (exception instanceof ConstraintViolationException) {
final ConstraintViolationException constraint = (ConstraintViolationException) exception;
- final boolean isResponseException = constraint instanceof ResponseConstraintViolationException;
-
+
for (final ConstraintViolation< ? > violation: constraint.getConstraintViolations()) {
LOG.log(Level.WARNING,
violation.getRootBeanClass().getSimpleName()
@@ -49,15 +50,10 @@ public Response toResponse(ValidationException exception) {
+ ": " + violation.getMessage());
}
- if (isResponseException) {
- return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
+ if (!(constraint instanceof ResponseConstraintViolationException)) {
+ errorStatus = Response.Status.BAD_REQUEST;
}
-
- return Response.status(Response.Status.BAD_REQUEST).build();
- } else {
- return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
- }
-
-
+ }
+ return JAXRSUtils.toResponse(errorStatus);
}
}
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/ValidationUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/ValidationUtils.java
index 18fa7c59f39..5bc108f3b57 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/ValidationUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/ValidationUtils.java
@@ -35,6 +35,9 @@ public static Object getResourceInstance(Message message) {
if (ori == null) {
return null;
}
+ if (!ori.getClassResourceInfo().isRoot()) {
+ return message.getExchange().get("org.apache.cxf.service.object.last");
+ }
final ResourceProvider resourceProvider = ori.getClassResourceInfo().getResourceProvider();
if (!resourceProvider.isSingleton()) {
String error = "Service object is not a singleton, use a custom invoker to validate";
diff --git a/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd b/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd
index 74bc24f5147..749703a2817 100644
--- a/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd
+++ b/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd
@@ -29,7 +29,7 @@
<xsd:import namespace="http://www.osgi.org/xmlns/blueprint/v1.0.0" schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"/>
<xsd:import namespace="http://cxf.apache.org/configuration/beans" schemaLocation="http://cxf.apache.org/schemas/configuration/cxf-beans.xsd"/>
- <xsd:include schemaLocation="jaxrs-common.xsd"/>
+ <xsd:include schemaLocation="http://cxf.apache.org/schemas/blueprint/jaxrs-common.xsd"/>
<xsd:element name="server">
<xsd:complexType>
diff --git a/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs-common.xsd b/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs-common.xsd
index 8dbd6dfcf2d..b42570e880f 100644
--- a/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs-common.xsd
+++ b/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs-common.xsd
@@ -60,6 +60,7 @@
</xsd:attribute>
<xsd:attribute name="defaultValue" type="xsd:string"/>
<xsd:attribute name="encoded" type="xsd:boolean"/>
+ <xsd:attribute name="class" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
diff --git a/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd b/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
index 932dbe9e76e..ef408ad1c25 100644
--- a/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
+++ b/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
@@ -69,6 +69,7 @@
<xsd:attribute name="docLocation" type="xsd:string"/>
<xsd:attribute name="publishedEndpointUrl" type="xsd:string"/>
<xsd:attribute name="basePackages" type="xsd:string"/>
+ <xsd:attribute name="serviceAnnotation" type="xsd:string"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
index f64ae660b6a..8a16479f886 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
@@ -265,7 +265,7 @@ public UriInfo getUriInfo2() {
}
@Context
- public void setUriInfo(UriInfo ui) {
+ public void setTestUriInfo(UriInfo ui) {
uriInfo = ui;
}
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/DefaultMethodResource.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/DefaultMethodResource.java
new file mode 100644
index 00000000000..156c8e245fb
--- /dev/null
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/DefaultMethodResource.java
@@ -0,0 +1,44 @@
+/**
+ * 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.apache.cxf.jaxrs;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+
+import org.apache.cxf.jaxrs.ext.DefaultMethod;
+
+@Path("service")
+public class DefaultMethodResource {
+
+ @Path("all")
+ @DefaultMethod
+ public Response all() {
(This diff was longer than 20,000 lines, and has been truncated...)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services