summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientConfiguration.java10
-rw-r--r--eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientFactory.java8
2 files changed, 17 insertions, 1 deletions
diff --git a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientConfiguration.java b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientConfiguration.java
index 2fea1e85..40d22205 100644
--- a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientConfiguration.java
+++ b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientConfiguration.java
@@ -1,11 +1,13 @@
package at.gv.egiz.eaaf.core.impl.http;
import java.text.MessageFormat;
+import java.util.List;
import java.util.UUID;
import javax.annotation.Nonnull;
import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpRequestInterceptor;
import org.apache.http.client.ServiceUnavailableRetryStrategy;
import at.gv.egiz.eaaf.core.exceptions.EaafConfigurationException;
@@ -67,6 +69,12 @@ public class HttpClientConfiguration {
@Setter
private ServiceUnavailableRetryStrategy serviceUnavailStrategy = null;
+ /**
+ * List of {@link HttpRequestInterceptor} that are added first to HTTP client.
+ */
+ @Setter
+ private List<HttpRequestInterceptor> messageInterceptors;
+
/**
* Get a new HTTP-client configuration object.
@@ -198,6 +206,6 @@ public class HttpClientConfiguration {
return getMode();
}
-
}
+
}
diff --git a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientFactory.java b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientFactory.java
index 07522b56..784dbe0e 100644
--- a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientFactory.java
+++ b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpClientFactory.java
@@ -158,6 +158,14 @@ public class HttpClientFactory implements IHttpClientFactory {
HttpClientConnectionManager connectionManager
= injectConnectionManager(builder, sslConnectionFactory);
+ // set interceptor
+ if (config.getMessageInterceptors() != null) {
+ for (int i = config.getMessageInterceptors().size() - 1; i >= 0; i--) {
+ builder.addInterceptorFirst(config.getMessageInterceptors().get(i));
+
+ }
+ }
+
availableBuilders.put(config.getUuid(), Pair.newInstance(builder, connectionManager));
}