CAMEL-8239 Split jetty8 and jetty9 support into separate modules
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0d96e56d Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0d96e56d Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0d96e56d Branch: refs/heads/temp-jetty9-2 Commit: 0d96e56d223ec29946bbde06790c27f8e1f24716 Parents: 76c6a27 Author: Christian Schneider <ch...@die-schneider.net> Authored: Thu Jan 15 10:52:43 2015 +0100 Committer: Christian Schneider <ch...@die-schneider.net> Committed: Thu Jan 15 10:52:43 2015 +0100 ---------------------------------------------------------------------- apache-camel/pom.xml | 10 +- components/camel-ahc/pom.xml | 2 +- components/camel-cxf-transport/pom.xml | 2 +- components/camel-cxf/pom.xml | 2 +- components/camel-jetty-common/pom.xml | 130 ++ .../jetty/CamelContinuationServlet.java | 212 +++ .../component/jetty/CamelFilterWrapper.java | 71 ++ .../camel/component/jetty/CamelHttpClient.java | 78 ++ .../component/jetty/CamelMultipartFilter.java | 31 + .../jetty/DefaultJettyHttpBinding.java | 194 +++ .../component/jetty/JettyContentExchange.java | 70 + .../camel/component/jetty/JettyConverter.java | 53 + .../camel/component/jetty/JettyHttpBinding.java | 86 ++ .../component/jetty/JettyHttpComponent.java | 1203 ++++++++++++++++++ .../component/jetty/JettyHttpEndpoint.java | 283 ++++ .../component/jetty/JettyHttpProducer.java | 305 +++++ .../component/jetty/JettyRestHttpBinding.java | 75 ++ ...JettyRestServletResolveConsumerStrategy.java | 163 +++ .../apache/camel/component/jetty/package.html | 25 + components/camel-jetty/pom.xml | 198 --- .../jetty/CamelContinuationServlet.java | 212 --- .../component/jetty/CamelFilterWrapper.java | 71 -- .../camel/component/jetty/CamelHttpClient.java | 78 -- .../component/jetty/CamelMultipartFilter.java | 31 - .../jetty/DefaultJettyHttpBinding.java | 194 --- .../component/jetty/JettyContentExchange.java | 70 - .../camel/component/jetty/JettyConverter.java | 53 - .../camel/component/jetty/JettyHttpBinding.java | 86 -- .../component/jetty/JettyHttpComponent.java | 1203 ------------------ .../component/jetty/JettyHttpEndpoint.java | 283 ---- .../component/jetty/JettyHttpProducer.java | 305 ----- .../component/jetty/JettyRestHttpBinding.java | 75 -- ...JettyRestServletResolveConsumerStrategy.java | 163 --- .../apache/camel/component/jetty/package.html | 25 - .../component/jetty8/CamelHttpClient8.java | 68 - .../component/jetty8/CamelRedirectListener.java | 52 - .../component/jetty8/JettyContentExchange8.java | 287 ----- .../component/jetty8/JettyHttpComponent8.java | 132 -- .../component/jetty8/JettyHttpEndpoint8.java | 36 - .../component/jetty9/AttachmentHttpBinding.java | 75 -- .../component/jetty9/CamelHttpClient9.java | 52 - .../component/jetty9/JettyContentExchange9.java | 295 ----- .../component/jetty9/JettyHttpComponent9.java | 140 -- .../component/jetty9/JettyHttpEndpoint9.java | 36 - .../src/main/resources/META-INF/LICENSE.txt | 203 --- .../src/main/resources/META-INF/NOTICE.txt | 11 - .../services/org/apache/camel/TypeConverter | 18 - .../services/org/apache/camel/component/jetty | 17 - components/camel-jetty/src/test/data/logo.jpeg | Bin 10249 -> 0 bytes components/camel-jetty/src/test/data/plain.txt | 18 - .../camel/component/jetty/BaseJettyTest.java | 119 -- .../jetty/ConvertPayloadToInputStreamTest.java | 64 - .../component/jetty/CustomFiltersTest.java | 109 -- .../camel/component/jetty/EnableCORSTest.java | 71 -- .../component/jetty/ExplicitHttpsRouteTest.java | 69 - ...licitHttpsSslContextParametersRouteTest.java | 85 -- .../component/jetty/ExplicitJettyRouteTest.java | 65 - .../camel/component/jetty/HandlerTest.java | 106 -- .../jetty/HttpAuthMethodPriorityTest.java | 125 -- .../HttpBasicAuthComponentConfiguredTest.java | 109 -- .../component/jetty/HttpBasicAuthTest.java | 106 -- ...ndingPreservePostFormUrlEncodedBodyTest.java | 66 - .../component/jetty/HttpBindingRefTest.java | 93 -- .../jetty/HttpBridgeEncodedPathTest.java | 65 - .../jetty/HttpBridgeMultipartRouteTest.java | 99 -- .../component/jetty/HttpBridgeRouteTest.java | 72 -- .../jetty/HttpCharacterEncodingTest.java | 64 - .../jetty/HttpClientRouteEnableChunkedTest.java | 84 -- .../component/jetty/HttpClientRouteTest.java | 147 --- .../component/jetty/HttpConverterTest.java | 131 -- .../component/jetty/HttpEndpointURLTest.java | 30 - .../jetty/HttpEndpointUriEncodingIssueTest.java | 68 - .../jetty/HttpFilterCamelHeadersTest.java | 79 -- .../component/jetty/HttpGZipEncodingTest.java | 100 -- .../component/jetty/HttpHeaderCaseTest.java | 73 -- .../camel/component/jetty/HttpHeaderTest.java | 95 -- .../component/jetty/HttpMethodRestrictTest.java | 74 -- .../HttpOperationsFailedExceptionUriTest.java | 57 - .../jetty/HttpPollingConsumerTest.java | 63 - .../component/jetty/HttpPollingGetTest.java | 76 -- .../component/jetty/HttpProducerByteTest.java | 44 - .../jetty/HttpProducerConcurrentTest.java | 92 -- .../jetty/HttpProducerJMXBeansIssueTest.java | 80 -- .../jetty/HttpProducerQueryParamTest.java | 78 -- .../jetty/HttpProducerSOTimeoutTest.java | 72 -- .../jetty/HttpProducerSendEmptyHeaderTest.java | 54 - ...ttpProducerTwoParametersWithSameKeyTest.java | 103 -- .../jetty/HttpProxyRouteContentTypeTest.java | 52 - .../component/jetty/HttpProxyRouteTest.java | 99 -- .../jetty/HttpRedirectNoLocationTest.java | 59 - .../camel/component/jetty/HttpRedirectTest.java | 89 -- .../jetty/HttpRequestResponseTest.java | 81 -- ...ReturnDataNotInputStreamConvertableTest.java | 56 - .../component/jetty/HttpReturnFaultTest.java | 61 - .../jetty/HttpRoundtripHeaderTest.java | 126 -- .../camel/component/jetty/HttpRouteTest.java | 269 ---- .../camel/component/jetty/HttpSendFileTest.java | 70 - .../jetty/HttpStreamCacheFileIssueTest.java | 90 -- .../jetty/HttpStreamCacheFileResponseTest.java | 72 -- .../jetty/HttpStreamCacheFileStopIssueTest.java | 92 -- .../jetty/HttpStreamCacheFileTest.java | 101 -- .../camel/component/jetty/HttpToFileTest.java | 81 -- .../component/jetty/HttpTwoEndpointTest.java | 67 - .../component/jetty/HttpTwoServerPortsTest.java | 75 -- .../component/jetty/HttpUrlRewriteTest.java | 63 - ...HttpsRouteAddSslConnectorPropertiesTest.java | 55 - .../component/jetty/HttpsRouteAliasTest.java | 67 - .../HttpsRouteSetupWithSystemPropsTest.java | 63 - ...outeSslContextParametersInComponentTest.java | 63 - ...HttpsRouteSslContextParametersInUriTest.java | 71 -- .../camel/component/jetty/HttpsRouteTest.java | 210 --- ...ttpsRouteWithSslConnectorPropertiesTest.java | 56 - .../camel/component/jetty/InterfacesTest.java | 135 -- .../jetty/JettyCallHttpThenExceptionTest.java | 71 -- .../jetty/JettyCamelHttpUrlCBRTest.java | 55 - .../JettyComponentSpringConfiguredTest.java | 48 - .../jetty/JettyContentBasedRouteTest.java | 66 - .../component/jetty/JettyContentTypeTest.java | 110 -- .../jetty/JettyContinuationDisabledTest.java | 59 - .../component/jetty/JettyEnableJmxTest.java | 157 --- .../JettyEndpointContinuationDisabledTest.java | 55 - .../jetty/JettyEndpointSetHttpTraceTest.java | 61 - .../component/jetty/JettyHandle404Test.java | 107 -- .../jetty/JettyHttpBindingRefTest.java | 101 -- .../jetty/JettyHttpBridgeEncodedPathTest.java | 66 - .../jetty/JettyHttpClientOptionsTest.java | 77 -- ...ponentConfigurationAndDocumentationTest.java | 58 - .../jetty/JettyHttpContentTypeTest.java | 80 -- .../jetty/JettyHttpEndpointDisconnectTest.java | 42 - ...ttyHttpGetWithParamAsExchangeHeaderTest.java | 128 -- .../jetty/JettyHttpGetWithParamTest.java | 93 -- .../component/jetty/JettyHttpHeadersTest.java | 54 - .../component/jetty/JettyImageFileTest.java | 71 -- .../jetty/JettyOnExceptionHandledTest.java | 59 - .../jetty/JettyResponseBodyWhenErrorTest.java | 64 - .../jetty/JettyResponseBufferSizeTest.java | 40 - .../camel/component/jetty/JettyRouteTest.java | 80 -- .../JettyRouteWithSocketPropertiesTest.java | 79 -- ...ttyRouteWithUnknownSocketPropertiesTest.java | 63 - ...RouteWithUnknownSslSocketPropertiesTest.java | 63 - .../jetty/JettySessionSupportTest.java | 70 - .../jetty/JettySimplifiedHandle404Test.java | 78 -- .../jetty/JettySimulateInOnlyTest.java | 120 -- .../component/jetty/JettySteveIssueTest.java | 51 - .../jetty/JettyStreamCacheIssueTest.java | 66 - .../component/jetty/JettySuspendResumeTest.java | 71 -- .../camel/component/jetty/JettySuspendTest.java | 64 - .../jetty/JettySuspendWhileInProgressTest.java | 85 -- .../jetty/JettyWithXPathChoiceTest.java | 82 -- .../component/jetty/MultiPartFormTest.java | 115 -- .../MultiPartFormWithCustomFilterTest.java | 152 --- .../jetty/MultiThreadedHttpGetTest.java | 120 -- .../camel/component/jetty/MyErrorHandler.java | 42 - .../camel/component/jetty/MyUrlRewrite.java | 31 - .../jetty/SimpleJettyChunkedFalseTest.java | 40 - .../camel/component/jetty/SimpleJettyTest.java | 40 - .../component/jetty/SpringHttpsRouteTest.java | 135 -- .../SpringJettyNoConnectionRedeliveryTest.java | 64 - .../jetty/SpringJettyNoConnectionTest.java | 55 - .../TwoCamelContextWithJettyRouteTest.java | 93 -- .../jetty/async/JettyAsyncCBRTest.java | 55 - .../JettyAsyncContinuationDisabledTest.java | 51 - .../JettyAsyncContinuationTimeoutOkTest.java | 51 - .../JettyAsyncContinuationTimeoutTest.java | 67 - ...ettyAsyncDefaultContinuationTimeoutTest.java | 71 -- .../jetty/async/JettyAsyncFilterTest.java | 54 - .../component/jetty/async/JettyAsyncTest.java | 51 - .../jetty/async/JettyAsyncThrottleTest.java | 76 -- .../jetty/async/JettyAsyncTransformTest.java | 55 - .../async/JettyAsyncTryCatchFinallyTest.java | 64 - .../component/jetty/async/MyAsyncComponent.java | 48 - .../component/jetty/async/MyAsyncEndpoint.java | 74 -- .../component/jetty/async/MyAsyncProducer.java | 75 -- .../jetty/file/JettyFileConsumerTest.java | 106 -- .../jetty/javabody/HttpJavaBodyTest.java | 126 -- .../component/jetty/javabody/MyCoolBean.java | 42 - ...oducerRecipientListCustomThreadPoolTest.java | 70 - .../HttpJettyProducerRecipientListTest.java | 70 - .../HttpJettyProducerTwoEndpointTest.java | 76 -- ...ttyProducerTwoParametersWithSameKeyTest.java | 119 -- .../jettyproducer/HttpJettyUrlRewriteTest.java | 65 - .../JettyHttpProderReturnFaultTest.java | 70 - .../JettyHttpProducerAsyncTimeoutTest.java | 64 - .../JettyHttpProducerAsynchronousTest.java | 97 -- ...tpProducerBridgePathWithSpacesAtEndTest.java | 65 - ...ttyHttpProducerBridgePathWithSpacesTest.java | 61 - .../JettyHttpProducerBridgeTest.java | 61 - .../JettyHttpProducerConcurrentTest.java | 110 -- .../JettyHttpProducerConnectionFailureTest.java | 66 - .../JettyHttpProducerContentBasedRouteTest.java | 81 -- ...pProducerContentTypeEncodingInQuoteTest.java | 99 -- ...roducerGetWithParamAsExchangeHeaderTest.java | 98 -- .../JettyHttpProducerGetWithParamTest.java | 95 -- ...JettyHttpProducerGoogleAsynchronousTest.java | 59 - .../JettyHttpProducerGoogleTest.java | 52 - ...JettyHttpProducerInvalidDestinationTest.java | 36 - .../JettyHttpProducerJavaBodyTest.java | 126 -- .../JettyHttpProducerPutContentTest.java | 81 -- .../JettyHttpProducerQueryParamTest.java | 95 -- .../JettyHttpProducerRedirectTest.java | 62 - .../JettyHttpProducerSendEmptyHeaderTest.java | 53 - .../JettyHttpProducerSendFileTest.java | 79 -- .../JettyHttpProducerSimulate404ErrorTest.java | 71 -- .../JettyHttpProducerSlowResponseTest.java | 84 -- .../JettyHttpProducerSuspendResumeTest.java | 77 -- .../JettyHttpProducerSuspendTest.java | 70 - ...yHttpProducerSuspendWhileInProgressTest.java | 93 -- .../JettyHttpProducerSynchronousFalseTest.java | 78 -- .../JettyHttpProducerSynchronousTest.java | 78 -- .../JettyHttpProducerTimeoutTest.java | 68 - .../JettyHttpProducerTransferExceptionTest.java | 50 - ...psProducerRouteSetupWithSystemPropsTest.java | 69 - .../JettyHttpsProducerSslContextInUriTest.java | 87 -- .../JettyProducerHandle404Test.java | 32 - .../JettyProducerHttpsRouteTest.java | 49 - .../jetty/jettyproducer/MyCoolBean.java | 42 - .../jetty/jettyproducer/MyInputStream.java | 35 - .../component/jetty/manual/JettyManual.java | 62 - .../jetty/proxy/HttpClientProxyTest.java | 87 -- .../HttpClientProxyTransferExceptionTest.java | 80 -- .../jetty/proxy/JettyChuckedFalseTest.java | 70 - .../component/jetty/proxy/MyAppException.java | 35 - .../component/jetty/proxy/MyCoolService.java | 25 - .../jetty/proxy/MyCoolServiceBean.java | 31 - .../camel/component/jetty/rest/CountryPojo.java | 40 - .../jetty/rest/JettyRestRedirectTest.java | 57 - .../RestJettyBindingModeAutoWithJsonTest.java | 59 - .../RestJettyBindingModeAutoWithXmlTest.java | 59 - .../rest/RestJettyBindingModeJsonTest.java | 75 -- .../jetty/rest/RestJettyBindingModeXmlTest.java | 75 -- .../component/jetty/rest/RestJettyGetTest.java | 66 - .../jetty/rest/RestJettyPojoInOutTest.java | 68 - .../rest/RestJettyPostJsonJaxbPojoTest.java | 61 - .../rest/RestJettyPostJsonPojoListTest.java | 67 - .../jetty/rest/RestJettyPostJsonPojoTest.java | 61 - .../rest/RestJettyPostXmlJaxbPojoTest.java | 79 -- .../jetty/rest/RestPathMatchingTest.java | 85 -- .../component/jetty/rest/UserJaxbPojo.java | 48 - .../camel/component/jetty/rest/UserPojo.java | 40 - .../camel/component/jetty/rest/UserService.java | 33 - .../camel-jetty/src/test/resources/java.jpg | Bin 1262 -> 0 bytes .../src/test/resources/jsse/localhost-alias.ks | Bin 2507 -> 0 bytes .../src/test/resources/jsse/localhost.ks | Bin 1265 -> 0 bytes .../src/test/resources/log4j.properties | 47 - .../src/test/resources/myRealm.properties | 18 - .../JettyComponentSpringConfiguredTest.xml | 42 - .../camel/component/jetty/jetty-https.xml | 55 - .../jetty/jetty-noconnection-redelivery.xml | 62 - .../component/jetty/jetty-noconnection.xml | 56 - components/camel-jetty8/pom.xml | 149 +++ .../component/jetty8/CamelHttpClient8.java | 68 + .../component/jetty8/CamelRedirectListener.java | 52 + .../component/jetty8/JettyContentExchange8.java | 287 +++++ .../component/jetty8/JettyHttpComponent8.java | 132 ++ .../component/jetty8/JettyHttpEndpoint8.java | 36 + .../src/main/resources/META-INF/LICENSE.txt | 203 +++ .../src/main/resources/META-INF/NOTICE.txt | 11 + .../services/org/apache/camel/TypeConverter | 18 + .../services/org/apache/camel/component/jetty | 17 + components/camel-jetty8/src/test/data/logo.jpeg | Bin 0 -> 10249 bytes components/camel-jetty8/src/test/data/plain.txt | 18 + .../camel-jetty8/src/test/resources/java.jpg | Bin 0 -> 1262 bytes .../src/test/resources/jsse/localhost-alias.ks | Bin 0 -> 2507 bytes .../src/test/resources/jsse/localhost.ks | Bin 0 -> 1265 bytes .../src/test/resources/log4j.properties | 47 + .../src/test/resources/myRealm.properties | 18 + .../JettyComponentSpringConfiguredTest.xml | 42 + .../camel/component/jetty/jetty-https.xml | 55 + .../jetty/jetty-noconnection-redelivery.xml | 62 + .../component/jetty/jetty-noconnection.xml | 56 + components/camel-jetty9/pom.xml | 149 +++ .../component/jetty9/AttachmentHttpBinding.java | 75 ++ .../component/jetty9/CamelHttpClient9.java | 52 + .../component/jetty9/JettyContentExchange9.java | 295 +++++ .../component/jetty9/JettyHttpComponent9.java | 140 ++ .../component/jetty9/JettyHttpEndpoint9.java | 36 + .../src/main/resources/META-INF/LICENSE.txt | 203 +++ .../src/main/resources/META-INF/NOTICE.txt | 11 + .../services/org/apache/camel/TypeConverter | 18 + .../services/org/apache/camel/component/jetty | 17 + components/camel-jetty9/src/test/data/logo.jpeg | Bin 0 -> 10249 bytes components/camel-jetty9/src/test/data/plain.txt | 18 + .../camel/component/jetty/BaseJettyTest.java | 119 ++ .../jetty/ConvertPayloadToInputStreamTest.java | 64 + .../component/jetty/CustomFiltersTest.java | 109 ++ .../camel/component/jetty/EnableCORSTest.java | 71 ++ .../component/jetty/ExplicitHttpsRouteTest.java | 69 + ...licitHttpsSslContextParametersRouteTest.java | 85 ++ .../component/jetty/ExplicitJettyRouteTest.java | 65 + .../camel/component/jetty/HandlerTest.java | 106 ++ .../jetty/HttpAuthMethodPriorityTest.java | 125 ++ .../HttpBasicAuthComponentConfiguredTest.java | 109 ++ .../component/jetty/HttpBasicAuthTest.java | 106 ++ ...ndingPreservePostFormUrlEncodedBodyTest.java | 66 + .../component/jetty/HttpBindingRefTest.java | 93 ++ .../jetty/HttpBridgeEncodedPathTest.java | 65 + .../jetty/HttpBridgeMultipartRouteTest.java | 99 ++ .../component/jetty/HttpBridgeRouteTest.java | 72 ++ .../jetty/HttpCharacterEncodingTest.java | 64 + .../jetty/HttpClientRouteEnableChunkedTest.java | 84 ++ .../component/jetty/HttpClientRouteTest.java | 147 +++ .../component/jetty/HttpConverterTest.java | 131 ++ .../component/jetty/HttpEndpointURLTest.java | 30 + .../jetty/HttpEndpointUriEncodingIssueTest.java | 68 + .../jetty/HttpFilterCamelHeadersTest.java | 79 ++ .../component/jetty/HttpGZipEncodingTest.java | 100 ++ .../component/jetty/HttpHeaderCaseTest.java | 73 ++ .../camel/component/jetty/HttpHeaderTest.java | 95 ++ .../component/jetty/HttpMethodRestrictTest.java | 74 ++ .../HttpOperationsFailedExceptionUriTest.java | 57 + .../jetty/HttpPollingConsumerTest.java | 63 + .../component/jetty/HttpPollingGetTest.java | 76 ++ .../component/jetty/HttpProducerByteTest.java | 44 + .../jetty/HttpProducerConcurrentTest.java | 92 ++ .../jetty/HttpProducerJMXBeansIssueTest.java | 80 ++ .../jetty/HttpProducerQueryParamTest.java | 78 ++ .../jetty/HttpProducerSOTimeoutTest.java | 72 ++ .../jetty/HttpProducerSendEmptyHeaderTest.java | 54 + ...ttpProducerTwoParametersWithSameKeyTest.java | 103 ++ .../jetty/HttpProxyRouteContentTypeTest.java | 52 + .../component/jetty/HttpProxyRouteTest.java | 99 ++ .../jetty/HttpRedirectNoLocationTest.java | 59 + .../camel/component/jetty/HttpRedirectTest.java | 89 ++ .../jetty/HttpRequestResponseTest.java | 81 ++ ...ReturnDataNotInputStreamConvertableTest.java | 56 + .../component/jetty/HttpReturnFaultTest.java | 61 + .../jetty/HttpRoundtripHeaderTest.java | 126 ++ .../camel/component/jetty/HttpRouteTest.java | 269 ++++ .../camel/component/jetty/HttpSendFileTest.java | 70 + .../jetty/HttpStreamCacheFileIssueTest.java | 90 ++ .../jetty/HttpStreamCacheFileResponseTest.java | 72 ++ .../jetty/HttpStreamCacheFileStopIssueTest.java | 92 ++ .../jetty/HttpStreamCacheFileTest.java | 101 ++ .../camel/component/jetty/HttpToFileTest.java | 81 ++ .../component/jetty/HttpTwoEndpointTest.java | 67 + .../component/jetty/HttpTwoServerPortsTest.java | 75 ++ .../component/jetty/HttpUrlRewriteTest.java | 63 + ...HttpsRouteAddSslConnectorPropertiesTest.java | 55 + .../component/jetty/HttpsRouteAliasTest.java | 67 + .../HttpsRouteSetupWithSystemPropsTest.java | 63 + ...outeSslContextParametersInComponentTest.java | 63 + ...HttpsRouteSslContextParametersInUriTest.java | 71 ++ .../camel/component/jetty/HttpsRouteTest.java | 210 +++ ...ttpsRouteWithSslConnectorPropertiesTest.java | 56 + .../camel/component/jetty/InterfacesTest.java | 135 ++ .../jetty/JettyCallHttpThenExceptionTest.java | 71 ++ .../jetty/JettyCamelHttpUrlCBRTest.java | 55 + .../JettyComponentSpringConfiguredTest.java | 48 + .../jetty/JettyContentBasedRouteTest.java | 66 + .../component/jetty/JettyContentTypeTest.java | 110 ++ .../jetty/JettyContinuationDisabledTest.java | 59 + .../component/jetty/JettyEnableJmxTest.java | 157 +++ .../JettyEndpointContinuationDisabledTest.java | 55 + .../jetty/JettyEndpointSetHttpTraceTest.java | 61 + .../component/jetty/JettyHandle404Test.java | 107 ++ .../jetty/JettyHttpBindingRefTest.java | 101 ++ .../jetty/JettyHttpBridgeEncodedPathTest.java | 66 + .../jetty/JettyHttpClientOptionsTest.java | 77 ++ ...ponentConfigurationAndDocumentationTest.java | 58 + .../jetty/JettyHttpContentTypeTest.java | 80 ++ .../jetty/JettyHttpEndpointDisconnectTest.java | 42 + ...ttyHttpGetWithParamAsExchangeHeaderTest.java | 128 ++ .../jetty/JettyHttpGetWithParamTest.java | 93 ++ .../component/jetty/JettyHttpHeadersTest.java | 54 + .../component/jetty/JettyImageFileTest.java | 71 ++ .../jetty/JettyOnExceptionHandledTest.java | 59 + .../jetty/JettyResponseBodyWhenErrorTest.java | 64 + .../jetty/JettyResponseBufferSizeTest.java | 40 + .../camel/component/jetty/JettyRouteTest.java | 80 ++ .../JettyRouteWithSocketPropertiesTest.java | 79 ++ ...ttyRouteWithUnknownSocketPropertiesTest.java | 63 + ...RouteWithUnknownSslSocketPropertiesTest.java | 63 + .../jetty/JettySessionSupportTest.java | 70 + .../jetty/JettySimplifiedHandle404Test.java | 78 ++ .../jetty/JettySimulateInOnlyTest.java | 120 ++ .../component/jetty/JettySteveIssueTest.java | 51 + .../jetty/JettyStreamCacheIssueTest.java | 66 + .../component/jetty/JettySuspendResumeTest.java | 71 ++ .../camel/component/jetty/JettySuspendTest.java | 64 + .../jetty/JettySuspendWhileInProgressTest.java | 85 ++ .../jetty/JettyWithXPathChoiceTest.java | 82 ++ .../component/jetty/MultiPartFormTest.java | 115 ++ .../MultiPartFormWithCustomFilterTest.java | 152 +++ .../jetty/MultiThreadedHttpGetTest.java | 120 ++ .../camel/component/jetty/MyErrorHandler.java | 42 + .../camel/component/jetty/MyUrlRewrite.java | 31 + .../jetty/SimpleJettyChunkedFalseTest.java | 40 + .../camel/component/jetty/SimpleJettyTest.java | 40 + .../component/jetty/SpringHttpsRouteTest.java | 135 ++ .../SpringJettyNoConnectionRedeliveryTest.java | 64 + .../jetty/SpringJettyNoConnectionTest.java | 55 + .../TwoCamelContextWithJettyRouteTest.java | 93 ++ .../jetty/async/JettyAsyncCBRTest.java | 55 + .../JettyAsyncContinuationDisabledTest.java | 51 + .../JettyAsyncContinuationTimeoutOkTest.java | 51 + .../JettyAsyncContinuationTimeoutTest.java | 67 + ...ettyAsyncDefaultContinuationTimeoutTest.java | 71 ++ .../jetty/async/JettyAsyncFilterTest.java | 54 + .../component/jetty/async/JettyAsyncTest.java | 51 + .../jetty/async/JettyAsyncThrottleTest.java | 76 ++ .../jetty/async/JettyAsyncTransformTest.java | 55 + .../async/JettyAsyncTryCatchFinallyTest.java | 64 + .../component/jetty/async/MyAsyncComponent.java | 48 + .../component/jetty/async/MyAsyncEndpoint.java | 74 ++ .../component/jetty/async/MyAsyncProducer.java | 75 ++ .../jetty/file/JettyFileConsumerTest.java | 108 ++ .../jetty/javabody/HttpJavaBodyTest.java | 126 ++ .../component/jetty/javabody/MyCoolBean.java | 42 + ...oducerRecipientListCustomThreadPoolTest.java | 70 + .../HttpJettyProducerRecipientListTest.java | 70 + .../HttpJettyProducerTwoEndpointTest.java | 76 ++ ...ttyProducerTwoParametersWithSameKeyTest.java | 119 ++ .../jettyproducer/HttpJettyUrlRewriteTest.java | 65 + .../JettyHttpProderReturnFaultTest.java | 70 + .../JettyHttpProducerAsyncTimeoutTest.java | 64 + .../JettyHttpProducerAsynchronousTest.java | 97 ++ ...tpProducerBridgePathWithSpacesAtEndTest.java | 65 + ...ttyHttpProducerBridgePathWithSpacesTest.java | 61 + .../JettyHttpProducerBridgeTest.java | 61 + .../JettyHttpProducerConcurrentTest.java | 110 ++ .../JettyHttpProducerConnectionFailureTest.java | 66 + .../JettyHttpProducerContentBasedRouteTest.java | 81 ++ ...pProducerContentTypeEncodingInQuoteTest.java | 99 ++ ...roducerGetWithParamAsExchangeHeaderTest.java | 98 ++ .../JettyHttpProducerGetWithParamTest.java | 95 ++ ...JettyHttpProducerGoogleAsynchronousTest.java | 59 + .../JettyHttpProducerGoogleTest.java | 52 + ...JettyHttpProducerInvalidDestinationTest.java | 36 + .../JettyHttpProducerJavaBodyTest.java | 126 ++ .../JettyHttpProducerPutContentTest.java | 81 ++ .../JettyHttpProducerQueryParamTest.java | 95 ++ .../JettyHttpProducerRedirectTest.java | 62 + .../JettyHttpProducerSendEmptyHeaderTest.java | 53 + .../JettyHttpProducerSendFileTest.java | 79 ++ .../JettyHttpProducerSimulate404ErrorTest.java | 71 ++ .../JettyHttpProducerSlowResponseTest.java | 84 ++ .../JettyHttpProducerSuspendResumeTest.java | 77 ++ .../JettyHttpProducerSuspendTest.java | 70 + ...yHttpProducerSuspendWhileInProgressTest.java | 93 ++ .../JettyHttpProducerSynchronousFalseTest.java | 78 ++ .../JettyHttpProducerSynchronousTest.java | 78 ++ .../JettyHttpProducerTimeoutTest.java | 68 + .../JettyHttpProducerTransferExceptionTest.java | 50 + ...psProducerRouteSetupWithSystemPropsTest.java | 69 + .../JettyHttpsProducerSslContextInUriTest.java | 87 ++ .../JettyProducerHandle404Test.java | 32 + .../JettyProducerHttpsRouteTest.java | 49 + .../jetty/jettyproducer/MyCoolBean.java | 42 + .../jetty/jettyproducer/MyInputStream.java | 35 + .../component/jetty/manual/JettyManual.java | 62 + .../jetty/proxy/HttpClientProxyTest.java | 87 ++ .../HttpClientProxyTransferExceptionTest.java | 80 ++ .../jetty/proxy/JettyChuckedFalseTest.java | 70 + .../component/jetty/proxy/MyAppException.java | 35 + .../component/jetty/proxy/MyCoolService.java | 25 + .../jetty/proxy/MyCoolServiceBean.java | 31 + .../camel/component/jetty/rest/CountryPojo.java | 40 + .../jetty/rest/JettyRestRedirectTest.java | 57 + .../RestJettyBindingModeAutoWithJsonTest.java | 59 + .../RestJettyBindingModeAutoWithXmlTest.java | 59 + .../rest/RestJettyBindingModeJsonTest.java | 75 ++ .../jetty/rest/RestJettyBindingModeXmlTest.java | 75 ++ .../component/jetty/rest/RestJettyGetTest.java | 66 + .../jetty/rest/RestJettyPojoInOutTest.java | 68 + .../rest/RestJettyPostJsonJaxbPojoTest.java | 61 + .../rest/RestJettyPostJsonPojoListTest.java | 67 + .../jetty/rest/RestJettyPostJsonPojoTest.java | 61 + .../rest/RestJettyPostXmlJaxbPojoTest.java | 79 ++ .../jetty/rest/RestPathMatchingTest.java | 85 ++ .../component/jetty/rest/UserJaxbPojo.java | 48 + .../camel/component/jetty/rest/UserPojo.java | 40 + .../camel/component/jetty/rest/UserService.java | 33 + .../camel-jetty9/src/test/resources/java.jpg | Bin 0 -> 1262 bytes .../src/test/resources/jsse/localhost-alias.ks | Bin 0 -> 2507 bytes .../src/test/resources/jsse/localhost.ks | Bin 0 -> 1265 bytes .../src/test/resources/log4j.properties | 47 + .../src/test/resources/myRealm.properties | 18 + .../JettyComponentSpringConfiguredTest.xml | 42 + .../camel/component/jetty/jetty-https.xml | 55 + .../jetty/jetty-noconnection-redelivery.xml | 62 + .../component/jetty/jetty-noconnection.xml | 56 + components/camel-quickfix/pom.xml | 2 +- components/camel-restlet/pom.xml | 2 +- components/camel-swagger/pom.xml | 2 +- components/camel-urlrewrite/pom.xml | 2 +- components/camel-xmlrpc/pom.xml | 2 +- components/pom.xml | 4 +- examples/camel-example-cxf/pom.xml | 2 +- parent/pom.xml | 12 +- tests/camel-itest/pom.xml | 2 +- 490 files changed, 19992 insertions(+), 19193 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/0d96e56d/apache-camel/pom.xml ---------------------------------------------------------------------- diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml index bf1b666..ce72c53 100644 --- a/apache-camel/pom.xml +++ b/apache-camel/pom.xml @@ -353,7 +353,15 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-jetty</artifactId> + <artifactId>camel-jetty-common</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-jetty8</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-jetty9</artifactId> </dependency> <dependency> <groupId>org.apache.camel</groupId> http://git-wip-us.apache.org/repos/asf/camel/blob/0d96e56d/components/camel-ahc/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-ahc/pom.xml b/components/camel-ahc/pom.xml index bd546dd..3c6f71c 100644 --- a/components/camel-ahc/pom.xml +++ b/components/camel-ahc/pom.xml @@ -65,7 +65,7 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-jetty</artifactId> + <artifactId>camel-jetty8</artifactId> <scope>test</scope> </dependency> <dependency> http://git-wip-us.apache.org/repos/asf/camel/blob/0d96e56d/components/camel-cxf-transport/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-cxf-transport/pom.xml b/components/camel-cxf-transport/pom.xml index fe08105..d683cf1 100644 --- a/components/camel-cxf-transport/pom.xml +++ b/components/camel-cxf-transport/pom.xml @@ -105,7 +105,7 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-jetty</artifactId> + <artifactId>camel-jetty8</artifactId> <scope>test</scope> </dependency> <dependency> http://git-wip-us.apache.org/repos/asf/camel/blob/0d96e56d/components/camel-cxf/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-cxf/pom.xml b/components/camel-cxf/pom.xml index 97d9e0c..a51a5a0 100644 --- a/components/camel-cxf/pom.xml +++ b/components/camel-cxf/pom.xml @@ -211,7 +211,7 @@ <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-jetty</artifactId> + <artifactId>camel-jetty8</artifactId> <scope>test</scope> </dependency> http://git-wip-us.apache.org/repos/asf/camel/blob/0d96e56d/components/camel-jetty-common/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-jetty-common/pom.xml b/components/camel-jetty-common/pom.xml new file mode 100644 index 0000000..a331bd3 --- /dev/null +++ b/components/camel-jetty-common/pom.xml @@ -0,0 +1,130 @@ +<?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. +--> +<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> + + <parent> + <groupId>org.apache.camel</groupId> + <artifactId>components</artifactId> + <version>2.15-SNAPSHOT</version> + </parent> + + <artifactId>camel-jetty-common</artifactId> + <packaging>bundle</packaging> + <name>Camel :: Jetty :: common</name> + <description>Camel Jetty support</description> + + <properties> + <camel.osgi.import.before.defaults> + javax.servlet.*;version="${servlet-version-range}" + </camel.osgi.import.before.defaults> + <camel.osgi.export.pkg>org.apache.camel.component.jetty.*</camel.osgi.export.pkg> + <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=jetty</camel.osgi.export.service> + </properties> + + <dependencies> + + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-http</artifactId> + </dependency> + <dependency> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>geronimo-servlet_3.0_spec</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-server</artifactId> + <exclusions> + <exclusion> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + </exclusion> + <exclusion> + <groupId>org.eclipse.jetty.orbit</groupId> + <artifactId>javax.servlet</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-servlet</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-security</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-servlets</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-client</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-jmx</artifactId> + </dependency> + + <!-- test dependencies --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-test-spring</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-spring</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-test</artifactId> + <optional>true</optional> + <scope>test</scope> + </dependency> + <!-- for testing rest-dsl --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-jackson</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-jaxb</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + +</project> http://git-wip-us.apache.org/repos/asf/camel/blob/0d96e56d/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java new file mode 100644 index 0000000..3ab15f2 --- /dev/null +++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java @@ -0,0 +1,212 @@ +/** + * 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.camel.component.jetty; + +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.camel.AsyncCallback; +import org.apache.camel.Exchange; +import org.apache.camel.ExchangePattern; +import org.apache.camel.component.http.CamelServlet; +import org.apache.camel.component.http.HttpConsumer; +import org.apache.camel.component.http.HttpMessage; +import org.apache.camel.component.http.helper.HttpHelper; +import org.apache.camel.impl.DefaultExchange; +import org.eclipse.jetty.continuation.Continuation; +import org.eclipse.jetty.continuation.ContinuationSupport; + +/** + * Servlet which leverage <a href="http://wiki.eclipse.org/Jetty/Feature/Continuations">Jetty Continuations</a>. + * + * @version + */ +public class CamelContinuationServlet extends CamelServlet { + + static final String EXCHANGE_ATTRIBUTE_NAME = "CamelExchange"; + static final String EXCHANGE_ATTRIBUTE_ID = "CamelExchangeId"; + + private static final long serialVersionUID = 1L; + // jetty will by default use 30000 millis as default timeout + private Long continuationTimeout; + // we must remember expired exchanges as Jetty will initiate a new continuation when we send + // back the error when timeout occurred, and thus in the async callback we cannot check the + // continuation if it was previously expired. So that's why we have our own map for that + private final Map<String, String> expiredExchanges = new ConcurrentHashMap<String, String>(); + + @Override + protected void service(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { + log.trace("Service: {}", request); + + // is there a consumer registered for the request. + HttpConsumer consumer = getServletResolveConsumerStrategy().resolve(request, getConsumers()); + if (consumer == null) { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + return; + } + + if (consumer.getEndpoint().getHttpMethodRestrict() != null + && !consumer.getEndpoint().getHttpMethodRestrict().equals(request.getMethod())) { + response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); + return; + } + + if ("TRACE".equals(request.getMethod()) && !consumer.isTraceEnabled()) { + response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); + return; + } + + final Exchange result = (Exchange) request.getAttribute(EXCHANGE_ATTRIBUTE_NAME); + if (result == null) { + // no asynchronous result so leverage continuation + final Continuation continuation = ContinuationSupport.getContinuation(request); + if (continuation.isInitial() && continuationTimeout != null) { + // set timeout on initial + continuation.setTimeout(continuationTimeout); + } + + // are we suspended and a request is dispatched initially? + if (consumer.isSuspended() && continuation.isInitial()) { + response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE); + return; + } + + if (continuation.isExpired()) { + String id = (String) continuation.getAttribute(EXCHANGE_ATTRIBUTE_ID); + // remember this id as expired + expiredExchanges.put(id, id); + log.warn("Continuation expired of exchangeId: {}", id); + response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE); + return; + } + + // a new request so create an exchange + final Exchange exchange = new DefaultExchange(consumer.getEndpoint(), ExchangePattern.InOut); + + if (consumer.getEndpoint().isBridgeEndpoint()) { + exchange.setProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.TRUE); + exchange.setProperty(Exchange.SKIP_WWW_FORM_URLENCODED, Boolean.TRUE); + } + if (consumer.getEndpoint().isDisableStreamCache()) { + exchange.setProperty(Exchange.DISABLE_HTTP_STREAM_CACHE, Boolean.TRUE); + } + + HttpHelper.setCharsetFromContentType(request.getContentType(), exchange); + + exchange.setIn(new HttpMessage(exchange, request, response)); + // set context path as header + String contextPath = consumer.getEndpoint().getPath(); + exchange.getIn().setHeader("CamelServletContextPath", contextPath); + + String httpPath = (String)exchange.getIn().getHeader(Exchange.HTTP_PATH); + // here we just remove the CamelServletContextPath part from the HTTP_PATH + if (contextPath != null + && httpPath.startsWith(contextPath)) { + exchange.getIn().setHeader(Exchange.HTTP_PATH, + httpPath.substring(contextPath.length())); + } + + if (log.isTraceEnabled()) { + log.trace("Suspending continuation of exchangeId: {}", exchange.getExchangeId()); + } + continuation.setAttribute(EXCHANGE_ATTRIBUTE_ID, exchange.getExchangeId()); + + // we want to handle the UoW + try { + consumer.createUoW(exchange); + } catch (Exception e) { + log.error("Error processing request", e); + throw new ServletException(e); + } + + // must suspend before we process the exchange + continuation.suspend(); + + ClassLoader oldTccl = overrideTccl(exchange); + + if (log.isTraceEnabled()) { + log.trace("Processing request for exchangeId: {}", exchange.getExchangeId()); + } + // use the asynchronous API to process the exchange + + consumer.getAsyncProcessor().process(exchange, new AsyncCallback() { + public void done(boolean doneSync) { + // check if the exchange id is already expired + boolean expired = expiredExchanges.remove(exchange.getExchangeId()) != null; + if (!expired) { + if (log.isTraceEnabled()) { + log.trace("Resuming continuation of exchangeId: {}", exchange.getExchangeId()); + } + // resume processing after both, sync and async callbacks + continuation.setAttribute(EXCHANGE_ATTRIBUTE_NAME, exchange); + continuation.resume(); + } else { + log.warn("Cannot resume expired continuation of exchangeId: {}", exchange.getExchangeId()); + } + } + }); + + if (oldTccl != null) { + restoreTccl(exchange, oldTccl); + } + + // return to let Jetty continuation to work as it will resubmit and invoke the service + // method again when its resumed + return; + } + + try { + // now lets output to the response + if (log.isTraceEnabled()) { + log.trace("Resumed continuation and writing response for exchangeId: {}", result.getExchangeId()); + } + Integer bs = consumer.getEndpoint().getResponseBufferSize(); + if (bs != null) { + log.trace("Using response buffer size: {}", bs); + response.setBufferSize(bs); + } + consumer.getBinding().writeResponse(result, response); + } catch (IOException e) { + log.error("Error processing request", e); + throw e; + } catch (Exception e) { + log.error("Error processing request", e); + throw new ServletException(e); + } finally { + consumer.doneUoW(result); + } + } + + public Long getContinuationTimeout() { + return continuationTimeout; + } + + public void setContinuationTimeout(Long continuationTimeout) { + this.continuationTimeout = continuationTimeout; + } + + @Override + public void destroy() { + expiredExchanges.clear(); + super.destroy(); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/0d96e56d/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelFilterWrapper.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelFilterWrapper.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelFilterWrapper.java new file mode 100644 index 0000000..f247e5f --- /dev/null +++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelFilterWrapper.java @@ -0,0 +1,71 @@ +/** + * 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.camel.component.jetty; + +import java.io.File; +import java.io.IOException; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +/** + * The camel filter wrapper that processes only initially dispatched requests. + * Re-dispatched requests are ignored. + */ +public class CamelFilterWrapper implements Filter { + + private Filter wrapped; + + public CamelFilterWrapper(Filter wrapped) { + this.wrapped = wrapped; + } + + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + if (request.getAttribute(CamelContinuationServlet.EXCHANGE_ATTRIBUTE_NAME) == null) { + wrapped.doFilter(request, response, chain); + } else { + chain.doFilter(request, response); + } + } + + public void destroy() { + wrapped.destroy(); + } + + public void init(FilterConfig config) throws ServletException { + Object o = config.getServletContext().getAttribute("javax.servlet.context.tempdir"); + if (o == null) { + //when run in embedded mode, Jetty 8 will forget to set this property, + //but the MultiPartFilter requires it (will NPE if not set) so we'll + //go ahead and set it to the default tmp dir on the system. + try { + File file = File.createTempFile("camel", ""); + file.delete(); + config.getServletContext().setAttribute("javax.servlet.context.tempdir", + file.getParentFile()); + } catch (IOException e) { + //ignore + } + } + wrapped.init(config); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/0d96e56d/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelHttpClient.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelHttpClient.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelHttpClient.java new file mode 100644 index 0000000..1f4504c --- /dev/null +++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelHttpClient.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.camel.component.jetty; + +import java.util.concurrent.Executor; + +import javax.net.ssl.SSLContext; + +import org.apache.camel.util.ObjectHelper; +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.util.ssl.SslContextFactory; +import org.eclipse.jetty.util.thread.QueuedThreadPool; + +public abstract class CamelHttpClient extends HttpClient { + + private boolean supportRedirect; + + public CamelHttpClient(SslContextFactory sslContextFactory) { + super(sslContextFactory); + } + + @Deprecated + /** + * It does nothing here, please setup SslContextFactory directly, it will be removed in Camel 2.16.0 + * @param context + */ + public void setSSLContext(SSLContext context) { + // do nothing here, please setup SslContextFactory directly. + } + + @Override + protected void doStart() throws Exception { + if (!hasThreadPool()) { + // if there is no thread pool then create a default thread pool using daemon threads + QueuedThreadPool qtp = new QueuedThreadPool(); + // 16 max threads is the default in the http client + qtp.setMaxThreads(16); + qtp.setDaemon(true); + // let the thread names indicate they are from the client + qtp.setName("CamelJettyClient(" + ObjectHelper.getIdentityHashCode(this) + ")"); + setThreadPoolOrExecutor(qtp); + } + super.doStart(); + } + + protected abstract boolean hasThreadPool(); + + protected abstract void setThreadPoolOrExecutor(Executor pool); + + public abstract void setProxy(String host, int port); + + public boolean isSupportRedirect() { + return supportRedirect; + } + + public void setSupportRedirect(boolean supportRedirect) { + this.supportRedirect = supportRedirect; + } + + public abstract String getProxyHost(); + + public abstract int getProxyPort(); + +} http://git-wip-us.apache.org/repos/asf/camel/blob/0d96e56d/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelMultipartFilter.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelMultipartFilter.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelMultipartFilter.java new file mode 100644 index 0000000..9a0c6ea --- /dev/null +++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelMultipartFilter.java @@ -0,0 +1,31 @@ +/** + * 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.camel.component.jetty; + +import javax.servlet.Filter; + +/** + * Please use the CamelFilterWrapper instead of using this classs + */ +@Deprecated +class CamelMultipartFilter extends CamelFilterWrapper { + + public CamelMultipartFilter(Filter wrapped) { + super(wrapped); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/0d96e56d/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java new file mode 100644 index 0000000..7b73a8a --- /dev/null +++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/DefaultJettyHttpBinding.java @@ -0,0 +1,194 @@ +/** + * 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.camel.component.jetty; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.RuntimeCamelException; +import org.apache.camel.component.http.HttpConstants; +import org.apache.camel.component.http.HttpHeaderFilterStrategy; +import org.apache.camel.component.http.HttpOperationFailedException; +import org.apache.camel.component.http.helper.HttpHelper; +import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.util.IOHelper; +import org.apache.camel.util.MessageHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @version + */ +public class DefaultJettyHttpBinding implements JettyHttpBinding { + + private static final Logger LOG = LoggerFactory.getLogger(DefaultJettyHttpBinding.class); + private HeaderFilterStrategy headerFilterStrategy = new HttpHeaderFilterStrategy(); + private boolean throwExceptionOnFailure; + private boolean transferException; + public DefaultJettyHttpBinding() { + + } + + public void populateResponse(Exchange exchange, JettyContentExchange httpExchange) throws Exception { + int responseCode = httpExchange.getResponseStatus(); + + LOG.debug("HTTP responseCode: {}", responseCode); + + Message in = exchange.getIn(); + if (!isThrowExceptionOnFailure()) { + // if we do not use failed exception then populate response for all response codes + populateResponse(exchange, httpExchange, in, getHeaderFilterStrategy(), responseCode); + } else { + if (responseCode >= 100 && responseCode < 300) { + // only populate response for OK response + populateResponse(exchange, httpExchange, in, getHeaderFilterStrategy(), responseCode); + } else { + // operation failed so populate exception to throw + Exception ex = populateHttpOperationFailedException(exchange, httpExchange, responseCode); + if (ex != null) { + throw ex; + } else { + populateResponse(exchange, httpExchange, in, getHeaderFilterStrategy(), responseCode); + } + } + } + } + + public HeaderFilterStrategy getHeaderFilterStrategy() { + return headerFilterStrategy; + } + + public void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy) { + this.headerFilterStrategy = headerFilterStrategy; + } + + public boolean isThrowExceptionOnFailure() { + return throwExceptionOnFailure; + } + + public void setThrowExceptionOnFailure(boolean throwExceptionOnFailure) { + this.throwExceptionOnFailure = throwExceptionOnFailure; + } + + public boolean isTransferException() { + return transferException; + } + + public void setTransferException(boolean transferException) { + this.transferException = transferException; + } + + protected void populateResponse(Exchange exchange, JettyContentExchange httpExchange, + Message in, HeaderFilterStrategy strategy, int responseCode) throws IOException { + Message answer = exchange.getOut(); + + answer.setHeader(Exchange.HTTP_RESPONSE_CODE, responseCode); + + // must use response fields to get the http headers as + // httpExchange.getHeaders() does not work well with multi valued headers + Map<String, Collection<String>> headers = httpExchange.getResponseHeaders(); + for (Map.Entry<String, Collection<String>> ent : headers.entrySet()) { + String name = ent.getKey(); + Collection<String> values = ent.getValue(); + for (String value : values) { + if (name.toLowerCase().equals("content-type")) { + name = Exchange.CONTENT_TYPE; + exchange.setProperty(Exchange.CHARSET_NAME, IOHelper.getCharsetNameFromContentType(value)); + } + if (strategy != null && !strategy.applyFilterToExternalHeaders(name, value, exchange)) { + HttpHelper.appendHeader(answer.getHeaders(), name, value); + } + } + } + + // preserve headers from in by copying any non existing headers + // to avoid overriding existing headers with old values + MessageHelper.copyHeaders(exchange.getIn(), answer, false); + + // extract body after headers has been set as we want to ensure content-type from Jetty HttpExchange + // has been populated first + answer.setBody(extractResponseBody(exchange, httpExchange)); + } + + protected Exception populateHttpOperationFailedException(Exchange exchange, JettyContentExchange httpExchange, + int responseCode) throws IOException { + HttpOperationFailedException answer; + String uri = httpExchange.getUrl(); + Map<String, String> headers = getSimpleMap(httpExchange.getResponseHeaders()); + Object responseBody = extractResponseBody(exchange, httpExchange); + + if (transferException && responseBody != null && responseBody instanceof Exception) { + // if the response was a serialized exception then use that + return (Exception) responseBody; + } + + // make a defensive copy of the response body in the exception so its detached from the cache + String copy = null; + if (responseBody != null) { + copy = exchange.getContext().getTypeConverter().convertTo(String.class, exchange, responseBody); + } + + if (responseCode >= 300 && responseCode < 400) { + Collection<String> loc = httpExchange.getResponseHeaders().get("location"); + if (loc != null && !loc.isEmpty()) { + String locationHeader = loc.iterator().next(); + answer = new HttpOperationFailedException(uri, responseCode, null, locationHeader, headers, copy); + } else { + // no redirect location + answer = new HttpOperationFailedException(uri, responseCode, null, null, headers, copy); + } + } else { + // internal server error (error code 500) + answer = new HttpOperationFailedException(uri, responseCode, null, null, headers, copy); + } + + return answer; + } + + protected Object extractResponseBody(Exchange exchange, JettyContentExchange httpExchange) throws IOException { + Map<String, String> headers = getSimpleMap(httpExchange.getResponseHeaders()); + String contentType = headers.get(Exchange.CONTENT_TYPE); + + // if content type is serialized java object, then de-serialize it to a Java object + if (contentType != null && HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT.equals(contentType)) { + try { + InputStream is = exchange.getContext().getTypeConverter().mandatoryConvertTo(InputStream.class, httpExchange.getResponseContentBytes()); + return HttpHelper.deserializeJavaObjectFromStream(is); + } catch (Exception e) { + throw new RuntimeCamelException("Cannot deserialize body to Java object", e); + } + } else { + // just grab the raw content body + return httpExchange.getBody(); + } + } + + Map<String, String> getSimpleMap(Map<String, Collection<String>> headers) { + Map<String, String> result = new HashMap<String , String>(); + for (String key : headers.keySet()) { + Collection<String> valueCol = headers.get(key); + String value = (valueCol == null) ? null : valueCol.iterator().next(); + result.put(key, value); + } + return result; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0d96e56d/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java new file mode 100644 index 0000000..94d272a --- /dev/null +++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java @@ -0,0 +1,70 @@ +/** + * 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.camel.component.jetty; + +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.util.Collection; +import java.util.Map; + +import org.apache.camel.AsyncCallback; +import org.apache.camel.Exchange; +import org.eclipse.jetty.client.HttpClient; + +public interface JettyContentExchange { + void init(Exchange exchange, JettyHttpBinding jettyBinding, + final HttpClient client, AsyncCallback callback); + + // Methods to prepare the request + void setRequestContentType(String contentType); + + void setMethod(String method); + + void setTimeout(long timeout); + + void setURL(String url); + + void setRequestContent(byte[] byteArray); + + void setRequestContent(String data, String charset) throws UnsupportedEncodingException; + + void setRequestContent(InputStream ins); + + void addRequestHeader(String key, String s); + + void setSupportRedirect(boolean supportRedirect); + + /* + * Send using jetty HttpClient and return. The callback will be called when the response + * arrives + */ + void send(HttpClient client) throws IOException; + + // Methods to retrieve the response + + byte[] getBody(); + + String getUrl(); + + int getResponseStatus(); + + byte[] getResponseContentBytes(); + + Map<String, Collection<String>> getResponseHeaders(); + +} http://git-wip-us.apache.org/repos/asf/camel/blob/0d96e56d/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyConverter.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyConverter.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyConverter.java new file mode 100644 index 0000000..6ed174f --- /dev/null +++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyConverter.java @@ -0,0 +1,53 @@ +/** + * 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.camel.component.jetty; + +import org.apache.camel.Converter; +import org.apache.camel.Exchange; +import org.apache.camel.FallbackConverter; +import org.apache.camel.spi.TypeConverterRegistry; +import org.eclipse.jetty.server.Request; +import org.eclipse.jetty.server.Response; + +/** + * @version + */ +@Converter +public final class JettyConverter { + private JettyConverter() { + //Helper class + } + + @Converter + public static String toString(Response response) { + return response.toString(); + } + + @FallbackConverter + @SuppressWarnings("unchecked") + public static <T> T convertTo(Class<T> type, Exchange exchange, Object value, TypeConverterRegistry registry) { + if (value != null) { + // should not try to convert Request as its not possible + if (Request.class.isAssignableFrom(value.getClass())) { + return (T) Void.TYPE; + } + } + + return null; + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/0d96e56d/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpBinding.java ---------------------------------------------------------------------- diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpBinding.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpBinding.java new file mode 100644 index 0000000..75e9863 --- /dev/null +++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpBinding.java @@ -0,0 +1,86 @@ +/** + * 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.camel.component.jetty; + +import org.apache.camel.Exchange; +import org.apache.camel.spi.HeaderFilterStrategy; + +/** + * Jetty specific binding to parse the response when using {@link org.apache.camel.component.jetty.JettyHttpProducer} + * + * @version + */ +public interface JettyHttpBinding { + + /** + * Parses the response from the Jetty client. + * + * @param exchange the Exchange which to populate with the response + * @param httpExchange the response from the Jetty client + * @throws Exception is thrown if error parsing response + */ + void populateResponse(Exchange exchange, JettyContentExchange httpExchange) throws Exception; + + /** + * Gets the header filter strategy + * + * @return the strategy + */ + HeaderFilterStrategy getHeaderFilterStrategy(); + + /** + * Sets the header filter strategy to use. + * <p/> + * Will default use {@link org.apache.camel.component.http.HttpHeaderFilterStrategy} + * + * @param headerFilterStrategy the custom strategy + */ + void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy); + + /** + * Whether to throw {@link org.apache.camel.component.http.HttpOperationFailedException} + * in case of response code != 200. + * + * @param throwExceptionOnFailure <tt>true</tt> to throw exception + */ + void setThrowExceptionOnFailure(boolean throwExceptionOnFailure); + + /** + * Whether to throw {@link org.apache.camel.component.http.HttpOperationFailedException} + * in case of response code != 200. + * + * @return <tt>true</tt> to throw exception + */ + boolean isThrowExceptionOnFailure(); + + /** + * Whether to transfer exception back as a serialized java object + * if processing failed due to an exception + * + * @param transferException <tt>true</tt> to transfer exception + */ + void setTransferException(boolean transferException); + + /** + * Whether to transfer exception back as a serialized java object + * if processing failed due to an exception + * + * @return <tt>true</tt> to transfer exception + */ + boolean isTransferException(); + +}