Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Reckord2019-05-30 14:02:59 -0400
committerCarsten Reckord2019-05-30 14:10:10 -0400
commit157a38e5ba18fa19ab85c07629f4beb824141366 (patch)
tree9c33673c1b01ec9eeda83f204e79a6c8e9203a0d
parent80963b1c3390b01df210d6ccdfe532ed2931b963 (diff)
downloadorg.eclipse.ecf-157a38e5ba18fa19ab85c07629f4beb824141366.tar.gz
org.eclipse.ecf-157a38e5ba18fa19ab85c07629f4beb824141366.tar.xz
org.eclipse.ecf-157a38e5ba18fa19ab85c07629f4beb824141366.zip
Bug 544447 - [provider] Implement filetransfer provider using HttpClient 4.5 API
Introduced property to control shared HttpClient instance vs new one for every transfer. Change-Id: I734c921a6a35ea201ad904121143c7284c5bb648 Signed-off-by: Carsten Reckord <reckord@yatta.de>
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient45/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient45/Activator.java52
1 files changed, 36 insertions, 16 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient45/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient45/Activator.java b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient45/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient45/Activator.java
index abcd8aaf2..11c300023 100644
--- a/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient45/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient45/Activator.java
+++ b/providers/bundles/org.eclipse.ecf.provider.filetransfer.httpclient45/src/org/eclipse/ecf/internal/provider/filetransfer/httpclient45/Activator.java
@@ -73,9 +73,8 @@ public class Activator implements BundleActivator {
return false;
}
String[] scopes = ((String) scopeProperty).split("\\s*,\\s*"); //$NON-NLS-1$
- boolean hasScope = false;
for (String scope : scopes) {
- if (neededScope.equals(scope) || (scope.endsWith("*") && neededScope.startsWith(scope.substring(0, scope.length() - 1)))) {
+ if (neededScope.equals(scope) || (scope.endsWith("*") && neededScope.startsWith(scope.substring(0, scope.length() - 1)))) { //$NON-NLS-1$
return true;
}
}
@@ -98,6 +97,10 @@ public class Activator implements BundleActivator {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.ecf.provider.filetransfer.httpclient45"; //$NON-NLS-1$
+ public static final String USE_SHARED_CLIENT = PLUGIN_ID + ".sharedClient"; //$NON-NLS-1$
+
+ private static final String USE_SHARED_CLIENT_DEFAULT = "false"; //$NON-NLS-1$
+
// The shared instance
private static Activator plugin;
private BundleContext context = null;
@@ -114,6 +117,8 @@ public class Activator implements BundleActivator {
private ServiceTracker<HttpClient, CloseableHttpClient> retrieveClientTracker;
+ private boolean useSharedClient;
+
/**
* The constructor
*/
@@ -129,6 +134,7 @@ public class Activator implements BundleActivator {
public void start(BundleContext ctxt) throws Exception {
plugin = this;
this.context = ctxt;
+ useSharedClient = Boolean.parseBoolean(System.getProperty(USE_SHARED_CLIENT, USE_SHARED_CLIENT_DEFAULT));
applyDebugOptions(ctxt);
}
@@ -196,6 +202,10 @@ public class Activator implements BundleActivator {
return logServiceTracker.getService();
}
+ public boolean isUseSharedClient() {
+ return useSharedClient;
+ }
+
public void log(IStatus status) {
LogService logService = getLogService();
if (logService != null) {
@@ -240,25 +250,35 @@ public class Activator implements BundleActivator {
}
public synchronized CloseableHttpClient getBrowseHttpClient() {
- if (browseClientTracker == null) {
- browseClientTracker = new ServiceTracker<HttpClient, CloseableHttpClient>(context, HttpClient.class, new ScopedHttpClientCustomizer(context, IRemoteFileSystemBrowser.class.getName()));
- browseClientTracker.open();
- }
- CloseableHttpClient service = browseClientTracker.getService();
- if (service == null) {
- service = registerHttpClient();
+ CloseableHttpClient service;
+ if (isUseSharedClient()) {
+ if (browseClientTracker == null) {
+ browseClientTracker = new ServiceTracker<HttpClient, CloseableHttpClient>(context, HttpClient.class, new ScopedHttpClientCustomizer(context, IRemoteFileSystemBrowser.class.getName()));
+ browseClientTracker.open();
+ }
+ service = browseClientTracker.getService();
+ if (service == null) {
+ service = registerHttpClient();
+ }
+ } else {
+ service = getHttpClientFactory().newClient().build();
}
return service;
}
public synchronized CloseableHttpClient getRetrieveHttpClient() {
- if (retrieveClientTracker == null) {
- retrieveClientTracker = new ServiceTracker<HttpClient, CloseableHttpClient>(context, HttpClient.class, new ScopedHttpClientCustomizer(context, IRetrieveFileTransfer.class.getName()));
- retrieveClientTracker.open();
- }
- CloseableHttpClient service = retrieveClientTracker.getService();
- if (service == null) {
- service = registerHttpClient();
+ CloseableHttpClient service;
+ if (isUseSharedClient()) {
+ if (retrieveClientTracker == null) {
+ retrieveClientTracker = new ServiceTracker<HttpClient, CloseableHttpClient>(context, HttpClient.class, new ScopedHttpClientCustomizer(context, IRetrieveFileTransfer.class.getName()));
+ retrieveClientTracker.open();
+ }
+ service = retrieveClientTracker.getService();
+ if (service == null) {
+ service = registerHttpClient();
+ }
+ } else {
+ service = getHttpClientFactory().newClient().build();
}
return service;
}

Back to the top