You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/03/22 10:54:09 UTC
[camel] branch main updated: CAMEL-19179: camel-jetty - Remove JettyHttpBinding which is not in use
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new d0b980ea942 CAMEL-19179: camel-jetty - Remove JettyHttpBinding which is not in use
d0b980ea942 is described below
commit d0b980ea9425eb9933dc21c873aefb6111a8d7a1
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Mar 22 11:53:53 2023 +0100
CAMEL-19179: camel-jetty - Remove JettyHttpBinding which is not in use
---
.../org/apache/camel/catalog/components/jetty.json | 1 -
.../component/jetty/JettyContentExchange.java | 72 -----
.../camel/component/jetty/JettyHttpBinding.java | 122 --------
.../camel/component/jetty/JettyHttpComponent.java | 15 -
.../camel/component/jetty/JettyHttpEndpoint.java | 2 -
.../jetty11/JettyHttpComponent11Configurer.java | 6 -
.../org/apache/camel/component/jetty11/jetty.json | 1 -
.../component/jetty11/JettyContentExchange11.java | 330 ---------------------
.../component/jetty11/JettyHttpEndpoint11.java | 5 -
.../dsl/JettyComponentBuilderFactory.java | 19 --
10 files changed, 573 deletions(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jetty.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jetty.json
index d074d07894d..1ddd3761f0d 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jetty.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jetty.json
@@ -42,7 +42,6 @@
"errorHandler": { "kind": "property", "displayName": "Error Handler", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.eclipse.jetty.server.handler.ErrorHandler", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "This option is used to set the ErrorHandler that Jetty server uses." },
"httpBinding": { "kind": "property", "displayName": "Http Binding", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.http.common.HttpBinding", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Not to be used - use JettyHttpBinding instead." },
"httpConfiguration": { "kind": "property", "displayName": "Http Configuration", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.http.common.HttpConfiguration", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Jetty component does not use HttpConfiguration." },
- "jettyHttpBinding": { "kind": "property", "displayName": "Jetty Http Binding", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.jetty.JettyHttpBinding", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "To use a custom org.apache.camel.component.jetty.JettyHttpBinding, which are used to customize how a response should be written for the producer." },
"mbContainer": { "kind": "property", "displayName": "Mb Container", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.eclipse.jetty.jmx.MBeanContainer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "To use a existing configured org.eclipse.jetty.jmx.MBeanContainer if JMX is enabled that Jetty uses for registering mbeans." },
"headerFilterStrategy": { "kind": "property", "displayName": "Header Filter Strategy", "group": "filter", "label": "filter", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel message." },
"proxyHost": { "kind": "property", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "To use a http proxy to configure the hostname." },
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
deleted file mode 100644
index 5aeb4f6065e..00000000000
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java
+++ /dev/null
@@ -1,72 +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 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, 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 setRequestContent(InputStream ins, int contentLength);
-
- 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();
-
- Map<String, Collection<String>> getRequestHeaders();
-}
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
deleted file mode 100644
index 171e01a64a0..00000000000
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpBinding.java
+++ /dev/null
@@ -1,122 +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 org.apache.camel.component.jetty;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.spi.HeaderFilterStrategy;
-
-/**
- * Jetty specific binding to parse the request/response from Jetty and Camel.
- */
-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.http.common.HttpHeaderFilterStrategy}
- *
- * @param headerFilterStrategy the custom strategy
- */
- void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy);
-
- /**
- * Whether to throw {@link org.apache.camel.http.base.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.http.base.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
- * <p/>
- * This is by default turned off. If you enable this then be aware that Java will deserialize the incoming data from
- * the request to Java and that can be a potential security risk.
- *
- * @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
- * <p/>
- * This is by default turned off. If you enable this then be aware that Java will deserialize the incoming data from
- * the request to Java and that can be a potential security risk.
- *
- * @return <tt>true</tt> to transfer exception
- */
- boolean isTransferException();
-
- /**
- * Whether to allow java serialization when a request uses context-type=application/x-java-serialized-object
- * <p/>
- * This is by default turned off. If you enable this then be aware that Java will deserialize the incoming data from
- * the request to Java and that can be a potential security risk.
- *
- * @param allowJavaSerializedObject <tt>true</tt> to allow serializing java objects
- */
- void setAllowJavaSerializedObject(boolean allowJavaSerializedObject);
-
- /**
- * Whether to allow java serialization when a request uses context-type=application/x-java-serialized-object
- * <p/>
- * This is by default turned off. If you enable this then be aware that Java will deserialize the incoming data from
- * the request to Java and that can be a potential security risk.
- */
- boolean isAllowJavaSerializedObject();
-
- /**
- * The status codes which are considered a success response. The values are inclusive. Multiple ranges can be
- * defined, separated by comma, e.g. <tt>200-204,209,301-304</tt>. Each range must be a single number or from-to
- * with the dash included.
- * <p/>
- * The default range is <tt>200-299</tt>
- */
- String getOkStatusCodeRange();
-
- /**
- * The status codes which are considered a success response. The values are inclusive. Multiple ranges can be
- * defined, separated by comma, e.g. <tt>200-204,209,301-304</tt>. Each range must be a single number or from-to
- * with the dash included.
- * <p/>
- * The default range is <tt>200-299</tt>
- */
- void setOkStatusCodeRange(String okStatusCodeRange);
-
-}
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
index 55f7ef42b40..28adb274298 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
@@ -119,7 +119,6 @@ public abstract class JettyHttpComponent extends HttpCommonComponent
protected ThreadPool threadPool;
protected MBeanContainer mbContainer;
protected boolean enableJmx;
- protected JettyHttpBinding jettyHttpBinding;
protected Long continuationTimeout;
protected boolean useContinuation = true;
protected SSLContextParameters sslContextParameters;
@@ -779,20 +778,6 @@ public abstract class JettyHttpComponent extends HttpCommonComponent
this.enableJmx = enableJmx;
}
- public JettyHttpBinding getJettyHttpBinding() {
- return jettyHttpBinding;
- }
-
- /**
- * To use a custom org.apache.camel.component.jetty.JettyHttpBinding, which are used to customize how a response
- * should be written for the producer.
- */
- @Metadata(description = "To use a custom org.apache.camel.component.jetty.JettyHttpBinding, which are used to customize how a response should be written for the producer.",
- label = "advanced")
- public void setJettyHttpBinding(JettyHttpBinding jettyHttpBinding) {
- this.jettyHttpBinding = jettyHttpBinding;
- }
-
/**
* Not to be used - use JettyHttpBinding instead.
*/
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java
index 16fc9ccf223..78682f23fbb 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java
@@ -259,6 +259,4 @@ public abstract class JettyHttpEndpoint extends HttpCommonEndpoint {
this.enableCORS = enableCORS;
}
- public abstract JettyContentExchange createContentExchange();
-
}
diff --git a/components/camel-jetty/src/generated/java/org/apache/camel/component/jetty11/JettyHttpComponent11Configurer.java b/components/camel-jetty/src/generated/java/org/apache/camel/component/jetty11/JettyHttpComponent11Configurer.java
index cf2f084c338..0dff8a66e99 100644
--- a/components/camel-jetty/src/generated/java/org/apache/camel/component/jetty11/JettyHttpComponent11Configurer.java
+++ b/components/camel-jetty/src/generated/java/org/apache/camel/component/jetty11/JettyHttpComponent11Configurer.java
@@ -39,8 +39,6 @@ public class JettyHttpComponent11Configurer extends PropertyConfigurerSupport im
case "httpBinding": target.setHttpBinding(property(camelContext, org.apache.camel.http.common.HttpBinding.class, value)); return true;
case "httpconfiguration":
case "httpConfiguration": target.setHttpConfiguration(property(camelContext, org.apache.camel.http.common.HttpConfiguration.class, value)); return true;
- case "jettyhttpbinding":
- case "jettyHttpBinding": target.setJettyHttpBinding(property(camelContext, org.apache.camel.component.jetty.JettyHttpBinding.class, value)); return true;
case "keystore": target.setKeystore(property(camelContext, java.lang.String.class, value)); return true;
case "maxthreads":
case "maxThreads": target.setMaxThreads(property(camelContext, java.lang.Integer.class, value)); return true;
@@ -111,8 +109,6 @@ public class JettyHttpComponent11Configurer extends PropertyConfigurerSupport im
case "httpBinding": return org.apache.camel.http.common.HttpBinding.class;
case "httpconfiguration":
case "httpConfiguration": return org.apache.camel.http.common.HttpConfiguration.class;
- case "jettyhttpbinding":
- case "jettyHttpBinding": return org.apache.camel.component.jetty.JettyHttpBinding.class;
case "keystore": return java.lang.String.class;
case "maxthreads":
case "maxThreads": return java.lang.Integer.class;
@@ -184,8 +180,6 @@ public class JettyHttpComponent11Configurer extends PropertyConfigurerSupport im
case "httpBinding": return target.getHttpBinding();
case "httpconfiguration":
case "httpConfiguration": return target.getHttpConfiguration();
- case "jettyhttpbinding":
- case "jettyHttpBinding": return target.getJettyHttpBinding();
case "keystore": return target.getKeystore();
case "maxthreads":
case "maxThreads": return target.getMaxThreads();
diff --git a/components/camel-jetty/src/generated/resources/org/apache/camel/component/jetty11/jetty.json b/components/camel-jetty/src/generated/resources/org/apache/camel/component/jetty11/jetty.json
index d074d07894d..1ddd3761f0d 100644
--- a/components/camel-jetty/src/generated/resources/org/apache/camel/component/jetty11/jetty.json
+++ b/components/camel-jetty/src/generated/resources/org/apache/camel/component/jetty11/jetty.json
@@ -42,7 +42,6 @@
"errorHandler": { "kind": "property", "displayName": "Error Handler", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.eclipse.jetty.server.handler.ErrorHandler", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "This option is used to set the ErrorHandler that Jetty server uses." },
"httpBinding": { "kind": "property", "displayName": "Http Binding", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.http.common.HttpBinding", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Not to be used - use JettyHttpBinding instead." },
"httpConfiguration": { "kind": "property", "displayName": "Http Configuration", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.http.common.HttpConfiguration", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Jetty component does not use HttpConfiguration." },
- "jettyHttpBinding": { "kind": "property", "displayName": "Jetty Http Binding", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.jetty.JettyHttpBinding", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "To use a custom org.apache.camel.component.jetty.JettyHttpBinding, which are used to customize how a response should be written for the producer." },
"mbContainer": { "kind": "property", "displayName": "Mb Container", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.eclipse.jetty.jmx.MBeanContainer", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "To use a existing configured org.eclipse.jetty.jmx.MBeanContainer if JMX is enabled that Jetty uses for registering mbeans." },
"headerFilterStrategy": { "kind": "property", "displayName": "Header Filter Strategy", "group": "filter", "label": "filter", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel message." },
"proxyHost": { "kind": "property", "displayName": "Proxy Host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "To use a http proxy to configure the hostname." },
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty11/JettyContentExchange11.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty11/JettyContentExchange11.java
deleted file mode 100644
index f03b5724e34..00000000000
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty11/JettyContentExchange11.java
+++ /dev/null
@@ -1,330 +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 org.apache.camel.component.jetty11;
-
-import java.io.ByteArrayOutputStream;
-import java.io.Closeable;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.nio.ByteBuffer;
-import java.util.Collection;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.apache.camel.AsyncCallback;
-import org.apache.camel.CamelExchangeException;
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangeTimedOutException;
-import org.apache.camel.StreamCache;
-import org.apache.camel.component.jetty.JettyContentExchange;
-import org.apache.camel.component.jetty.JettyHttpBinding;
-import org.apache.camel.support.builder.OutputStreamBuilder;
-import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.client.api.Response;
-import org.eclipse.jetty.client.api.Result;
-import org.eclipse.jetty.client.util.BytesContentProvider;
-import org.eclipse.jetty.client.util.InputStreamContentProvider;
-import org.eclipse.jetty.client.util.InputStreamResponseListener;
-import org.eclipse.jetty.client.util.StringContentProvider;
-import org.eclipse.jetty.http.HttpFields;
-import org.eclipse.jetty.util.Callback;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Jetty specific exchange which keeps track of the request and response.
- */
-public class JettyContentExchange11 implements JettyContentExchange {
-
- private static final Logger LOG = LoggerFactory.getLogger(JettyContentExchange11.class);
-
- private volatile Exchange exchange;
- private volatile AsyncCallback callback;
- private volatile JettyHttpBinding jettyBinding;
- private volatile HttpClient client;
- private final CountDownLatch done = new CountDownLatch(1);
- private Request request;
- private Response response;
- private byte[] responseContent;
-
- private String requestContentType;
-
- private boolean supportRedirect;
-
- @Override
- public void init(Exchange exchange, JettyHttpBinding jettyBinding, final HttpClient client, AsyncCallback callback) {
- this.exchange = exchange;
- this.jettyBinding = jettyBinding;
- this.client = client;
- this.callback = callback;
- }
-
- protected void onRequestComplete() {
- LOG.trace("onRequestComplete");
- closeRequestContentSource();
- }
-
- protected void onResponseComplete(Result result, byte[] content) {
- LOG.trace("onResponseComplete");
- done.countDown();
- this.response = result.getResponse();
- this.responseContent = content;
- if (callback == null) {
- // this is only for the async callback
- return;
- }
- try {
- jettyBinding.populateResponse(exchange, this);
- } catch (Exception e) {
- exchange.setException(e);
- } finally {
- callback.done(false);
- }
- }
-
- protected void onExpire() {
- LOG.trace("onExpire");
-
- // need to close the request input stream
- closeRequestContentSource();
- doTaskCompleted(new ExchangeTimedOutException(exchange, client.getConnectTimeout()));
- }
-
- protected void onException(Throwable ex) {
- LOG.trace("onException {}", ex.getMessage(), ex);
-
- // need to close the request input stream
- closeRequestContentSource();
- doTaskCompleted(ex);
- }
-
- protected void onConnectionFailed(Throwable ex) {
- LOG.trace("onConnectionFailed {}", ex.getMessage(), ex);
-
- // need to close the request input stream
- closeRequestContentSource();
- doTaskCompleted(ex);
- }
-
- @Override
- public byte[] getBody() {
- // must return the content as raw bytes
- return getResponseContentBytes();
- }
-
- @Override
- public String getUrl() {
- try {
- return this.request.getURI().toURL().toExternalForm();
- } catch (MalformedURLException e) {
- throw new IllegalStateException(e.getMessage(), e);
- }
- }
-
- protected void closeRequestContentSource() {
- tryClose(this.request.getContent());
- }
-
- private void tryClose(Object obj) {
- if (obj instanceof Closeable) {
- try {
- ((Closeable) obj).close();
- } catch (IOException e) {
- // Ignore
- }
- }
- }
-
- protected void doTaskCompleted(Throwable ex) {
- if (ex instanceof TimeoutException) {
- exchange.setException(new ExchangeTimedOutException(exchange, request.getTimeout()));
- } else {
- exchange.setException(new CamelExchangeException("JettyClient failed cause by: " + ex.getMessage(), exchange, ex));
- }
- done.countDown();
-
- if (callback != null) {
- // now invoke callback to indicate we are done async
- callback.done(false);
- }
- }
-
- @Override
- public void setRequestContentType(String contentType) {
- this.requestContentType = contentType;
- }
-
- @Override
- public int getResponseStatus() {
- return this.response.getStatus();
- }
-
- @Override
- public void setMethod(String method) {
- this.request.method(method);
- }
-
- @Override
- public void setTimeout(long timeout) {
- this.request.timeout(timeout, TimeUnit.MILLISECONDS);
- }
-
- @Override
- public void setURL(String url) {
- this.request = client.newRequest(url);
- }
-
- @Override
- public void setRequestContent(byte[] byteArray) {
- this.request.content(new BytesContentProvider(byteArray), this.requestContentType);
- }
-
- @Override
- public void setRequestContent(String data, String charset) throws UnsupportedEncodingException {
- StringContentProvider cp = charset != null ? new StringContentProvider(data, charset) : new StringContentProvider(data);
- this.request.content(cp, this.requestContentType);
- }
-
- @Override
- public void setRequestContent(InputStream ins) {
- this.request.content(new InputStreamContentProvider(ins), this.requestContentType);
- }
-
- @Override
- public void setRequestContent(InputStream ins, int contentLength) {
- this.request.content(new CamelInputStreamContentProvider(ins, contentLength), this.requestContentType);
- }
-
- @Override
- public void addRequestHeader(String key, String s) {
- this.request.header(key, s);
- }
-
- @Override
- public void send(HttpClient client) throws IOException {
- org.eclipse.jetty.client.api.Request.Listener listener = new Request.Listener.Adapter() {
-
- @Override
- public void onSuccess(Request request) {
- onRequestComplete();
- }
-
- @Override
- public void onFailure(Request request, Throwable failure) {
- onConnectionFailed(failure);
- }
-
- };
-
- InputStreamResponseListener responseListener = new InputStreamResponseListener() {
- OutputStreamBuilder osb = OutputStreamBuilder.withExchange(exchange);
-
- @Override
- public void onContent(Response response, ByteBuffer content, Callback callback) {
- byte[] buffer = new byte[content.limit()];
- content.get(buffer);
- try {
- osb.write(buffer);
- callback.succeeded();
- } catch (IOException e) {
- callback.failed(e);
- }
- }
-
- @Override
- public void onComplete(Result result) {
- if (result.isFailed()) {
- doTaskCompleted(result.getFailure());
- } else {
- try {
- Object content = osb.build();
- if (content instanceof byte[]) {
- onResponseComplete(result, (byte[]) content);
- } else {
- StreamCache cos = (StreamCache) content;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- cos.writeTo(baos);
- onResponseComplete(result, baos.toByteArray());
- }
- } catch (IOException e) {
- doTaskCompleted(e);
- }
- }
- }
- };
- request.followRedirects(supportRedirect).listener(listener).send(responseListener);
- }
-
- protected void setResponse(Response response) {
- this.response = response;
- }
-
- @Override
- public byte[] getResponseContentBytes() {
- return responseContent;
- }
-
- private Map<String, Collection<String>> getFieldsAsMap(HttpFields fields) {
- final Map<String, Collection<String>> result = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
- for (String name : getFieldNamesCollection(fields)) {
- result.put(name, fields.getValuesList(name));
- }
- return result;
- }
-
- @SuppressWarnings("unchecked")
- private Collection<String> getFieldNamesCollection(HttpFields fields) {
- try {
- return fields.getFieldNamesCollection();
- } catch (NoSuchMethodError e) {
- try {
- // In newer versions of Jetty the return type has been changed
- // to Set.
- // This causes problems at byte-code level. Try recovering.
- Method reflGetFieldNamesCollection = HttpFields.class.getMethod("getFieldNamesCollection");
- Object result = reflGetFieldNamesCollection.invoke(fields);
- return (Collection<String>) result;
- } catch (Exception reflectionException) {
- // Suppress, throwing the original exception
- throw e;
- }
- }
- }
-
- @Override
- public Map<String, Collection<String>> getRequestHeaders() {
- return getFieldsAsMap(request.getHeaders());
- }
-
- @Override
- public Map<String, Collection<String>> getResponseHeaders() {
- return getFieldsAsMap(response.getHeaders());
- }
-
- @Override
- public void setSupportRedirect(boolean supportRedirect) {
- this.supportRedirect = supportRedirect;
- }
-
-}
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty11/JettyHttpEndpoint11.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty11/JettyHttpEndpoint11.java
index f7de2a08099..be6480dff0b 100644
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty11/JettyHttpEndpoint11.java
+++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty11/JettyHttpEndpoint11.java
@@ -21,7 +21,6 @@ import java.net.URISyntaxException;
import org.apache.camel.AsyncEndpoint;
import org.apache.camel.Category;
-import org.apache.camel.component.jetty.JettyContentExchange;
import org.apache.camel.component.jetty.JettyHttpComponent;
import org.apache.camel.component.jetty.JettyHttpConstants;
import org.apache.camel.component.jetty.JettyHttpEndpoint;
@@ -70,8 +69,4 @@ public class JettyHttpEndpoint11 extends JettyHttpEndpoint implements AsyncEndpo
this.binding = binding;
}
- @Override
- public JettyContentExchange createContentExchange() {
- return new JettyContentExchange11();
- }
}
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/JettyComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/JettyComponentBuilderFactory.java
index 1f605fb8c56..53c46b2750a 100644
--- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/JettyComponentBuilderFactory.java
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/JettyComponentBuilderFactory.java
@@ -377,24 +377,6 @@ public interface JettyComponentBuilderFactory {
doSetProperty("httpConfiguration", httpConfiguration);
return this;
}
- /**
- * To use a custom org.apache.camel.component.jetty.JettyHttpBinding,
- * which are used to customize how a response should be written for the
- * producer.
- *
- * The option is a:
- * <code>org.apache.camel.component.jetty.JettyHttpBinding</code> type.
- *
- * Group: advanced
- *
- * @param jettyHttpBinding the value to set
- * @return the dsl builder
- */
- default JettyComponentBuilder jettyHttpBinding(
- org.apache.camel.component.jetty.JettyHttpBinding jettyHttpBinding) {
- doSetProperty("jettyHttpBinding", jettyHttpBinding);
- return this;
- }
/**
* To use a existing configured org.eclipse.jetty.jmx.MBeanContainer if
* JMX is enabled that Jetty uses for registering mbeans.
@@ -640,7 +622,6 @@ public interface JettyComponentBuilderFactory {
case "errorHandler": ((JettyHttpComponent11) component).setErrorHandler((org.eclipse.jetty.server.handler.ErrorHandler) value); return true;
case "httpBinding": ((JettyHttpComponent11) component).setHttpBinding((org.apache.camel.http.common.HttpBinding) value); return true;
case "httpConfiguration": ((JettyHttpComponent11) component).setHttpConfiguration((org.apache.camel.http.common.HttpConfiguration) value); return true;
- case "jettyHttpBinding": ((JettyHttpComponent11) component).setJettyHttpBinding((org.apache.camel.component.jetty.JettyHttpBinding) value); return true;
case "mbContainer": ((JettyHttpComponent11) component).setMbContainer((org.eclipse.jetty.jmx.MBeanContainer) value); return true;
case "headerFilterStrategy": ((JettyHttpComponent11) component).setHeaderFilterStrategy((org.apache.camel.spi.HeaderFilterStrategy) value); return true;
case "proxyHost": ((JettyHttpComponent11) component).setProxyHost((java.lang.String) value); return true;