Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2014-06-10 14:27:50 -0400
committerRoberto E. Escobar2014-08-28 19:58:34 -0400
commit56ed1da4a2ae6d59e163e7b4ae1fd05df0ec5775 (patch)
tree3d3647cdbd778e3689d081a429a06691b77eea95
parent21a3c5b7427ef9991dc88c1e8b498bc8d59f84e7 (diff)
downloadorg.eclipse.osee-56ed1da4a2ae6d59e163e7b4ae1fd05df0ec5775.tar.gz
org.eclipse.osee-56ed1da4a2ae6d59e163e7b4ae1fd05df0ec5775.tar.xz
org.eclipse.osee-56ed1da4a2ae6d59e163e7b4ae1fd05df0ec5775.zip
bug[ats_ATS64246]: Fix JAX-RS Client server address config
Use OSGI style properties to configure JAX-RS clients Setup JAX-RS Client as a static factory library instead of OSGI service. Change-Id: Icd6798214da9264670a46f134638bd0b41963fb8
-rw-r--r--plugins/org.eclipse.osee.account.rest.client/OSGI-INF/account.rest.client.xml3
-rw-r--r--plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/AccountClientStandaloneSetup.java6
-rw-r--r--plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientImpl.java30
-rw-r--r--plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientModule.java33
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/OSGI-INF/web.client.provider.xml7
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/build.properties4
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsClientConstants.java40
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsClientFactory.java17
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsClientUtils.java65
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/OseeClientConfig.java46
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/OseeClientProperties.java29
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/OseeHttpProxyAddress.java27
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/OseeServerAddress.java27
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/JaxRsClientImpl.java97
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/StandadloneWebClientProvider.java41
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/StandaloneModule.java35
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/OSGI-INF/osee.client.xml3
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClientStandaloneSetup.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OrcsClientModule.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java49
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutorV1.java10
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/OSGI-INF/ote.master.rest.client.xml3
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/OTEMasterServerImpl.java16
-rw-r--r--plugins/org.eclipse.osee.ote.rest.client/OSGI-INF/ote.client.xml3
-rw-r--r--plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/OteClientImpl.java16
-rw-r--r--plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/IntegrationUtil.java13
27 files changed, 335 insertions, 303 deletions
diff --git a/plugins/org.eclipse.osee.account.rest.client/OSGI-INF/account.rest.client.xml b/plugins/org.eclipse.osee.account.rest.client/OSGI-INF/account.rest.client.xml
index 85b25f48752..b7f7404b4c2 100644
--- a/plugins/org.eclipse.osee.account.rest.client/OSGI-INF/account.rest.client.xml
+++ b/plugins/org.eclipse.osee.account.rest.client/OSGI-INF/account.rest.client.xml
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop">
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop" modified="update">
<implementation class="org.eclipse.osee.account.rest.client.internal.AccountClientImpl"/>
<service>
<provide interface="org.eclipse.osee.account.rest.client.AccountClient"/>
</service>
- <reference bind="setJaxRsClient" cardinality="1..1" interface="org.eclipse.osee.jaxrs.client.JaxRsClient" name="JaxRsClient" policy="static"/>
</scr:component>
diff --git a/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/AccountClientStandaloneSetup.java b/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/AccountClientStandaloneSetup.java
index f0afbf58795..6f92a29d103 100644
--- a/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/AccountClientStandaloneSetup.java
+++ b/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/AccountClientStandaloneSetup.java
@@ -10,9 +10,9 @@
*******************************************************************************/
package org.eclipse.osee.account.rest.client;
+import java.util.Map;
import org.eclipse.osee.account.rest.client.internal.AccountClientImpl;
import org.eclipse.osee.account.rest.client.internal.AccountClientModule;
-import org.eclipse.osee.jaxrs.client.OseeClientConfig;
import org.eclipse.osee.jaxrs.client.JaxRsClientFactory;
import com.google.inject.Module;
@@ -27,8 +27,8 @@ public final class AccountClientStandaloneSetup {
// Utility class
}
- public static AccountClient createClient(OseeClientConfig config) {
- Module module = new AccountClientModule();
+ public static AccountClient createClient(Map<String, Object> config) {
+ Module module = new AccountClientModule(config);
return JaxRsClientFactory.createClient(AccountClientImpl.class, config, module);
}
}
diff --git a/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientImpl.java b/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientImpl.java
index 04485d28b33..336cf5f6913 100644
--- a/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientImpl.java
+++ b/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientImpl.java
@@ -10,9 +10,11 @@
*******************************************************************************/
package org.eclipse.osee.account.rest.client.internal;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_SERVER_ADDRESS;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ws.rs.core.MediaType;
@@ -33,8 +35,8 @@ import org.eclipse.osee.account.rest.model.SubscriptionData;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.framework.jdk.core.type.ResultSets;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
-import org.eclipse.osee.jaxrs.client.OseeClientProperties;
-import com.google.inject.Inject;
+import org.eclipse.osee.jaxrs.client.JaxRsClientFactory;
+import org.eclipse.osee.jaxrs.client.JaxRsClientUtils;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.UniformInterfaceException;
import com.sun.jersey.api.client.WebResource;
@@ -44,25 +46,29 @@ import com.sun.jersey.api.client.WebResource;
*/
public class AccountClientImpl implements AccountClient {
+ private static final String OSEE_APPLICATION_SERVER = "osee.application.server";
private JaxRsClient client;
- private URI serverUri;
- @Inject
- public void setJaxRsClient(JaxRsClient client) {
- this.client = client;
+ public void start(Map<String, Object> properties) {
+ update(properties);
}
- public void start() {
- String appServer = OseeClientProperties.getApplicationServerAddress();
- serverUri = URI.create(appServer);
+ public void stop() {
+ client = null;
}
- public void stop() {
- //
+ public void update(Map<String, Object> properties) {
+ Map<String, Object> propsToUse = properties;
+ String newServerAddress = JaxRsClientUtils.get(propsToUse, JAXRS_CLIENT_SERVER_ADDRESS, null);
+ if (newServerAddress == null) {
+ propsToUse = new HashMap<String, Object>(properties);
+ propsToUse.put(JAXRS_CLIENT_SERVER_ADDRESS, System.getProperty(OSEE_APPLICATION_SERVER, ""));
+ }
+ client = JaxRsClientFactory.createClient(propsToUse);
}
private UriBuilder newBuilder() {
- return UriBuilder.fromUri(serverUri).path(AccountContexts.ACCOUNTS);
+ return UriBuilder.fromPath(AccountContexts.ACCOUNTS);
}
private <T> T get(URI uri, Class<T> clazz) {
diff --git a/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientModule.java b/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientModule.java
index aa70fb9f854..195035fda66 100644
--- a/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientModule.java
+++ b/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientModule.java
@@ -10,11 +10,11 @@
*******************************************************************************/
package org.eclipse.osee.account.rest.client.internal;
+import java.util.Map;
import org.eclipse.osee.account.rest.client.AccountClient;
+import org.eclipse.osee.jaxrs.client.JaxRsClientUtils;
import com.google.inject.AbstractModule;
import com.google.inject.TypeLiteral;
-import com.google.inject.matcher.AbstractMatcher;
-import com.google.inject.matcher.Matcher;
import com.google.inject.spi.InjectionListener;
import com.google.inject.spi.TypeEncounter;
import com.google.inject.spi.TypeListener;
@@ -24,6 +24,13 @@ import com.google.inject.spi.TypeListener;
*/
public class AccountClientModule extends AbstractModule {
+ private final Map<String, Object> config;
+
+ public AccountClientModule(Map<String, Object> config) {
+ super();
+ this.config = config;
+ }
+
@Override
protected void configure() {
bind(AccountClient.class).to(AccountClientImpl.class);
@@ -36,30 +43,12 @@ public class AccountClientModule extends AbstractModule {
@Override
public void afterInjection(I injectee) {
AccountClientImpl client = (AccountClientImpl) injectee;
- client.start();
+ client.start(config);
}
});
}
};
- bindListener(subtypeOf(AccountClientImpl.class), listener);
- }
-
- private static Matcher<? super TypeLiteral<?>> subtypeOf(Class<?> superclass) {
- return new SubTypeOfMatcher(TypeLiteral.get(AccountClientImpl.class));
- }
-
- private static final class SubTypeOfMatcher extends AbstractMatcher<TypeLiteral<?>> {
- private final TypeLiteral<AccountClientImpl> superType;
-
- public SubTypeOfMatcher(TypeLiteral<AccountClientImpl> superType) {
- super();
- this.superType = superType;
- }
-
- @Override
- public boolean matches(TypeLiteral<?> subType) {
- return subType.equals(superType) || superType.getRawType().isAssignableFrom(subType.getRawType());
- }
+ bindListener(JaxRsClientUtils.subtypeOf(AccountClient.class), listener);
}
}
diff --git a/plugins/org.eclipse.osee.jaxrs.client/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.jaxrs.client/META-INF/MANIFEST.MF
index 7e38b4d572a..d101cf05a5c 100644
--- a/plugins/org.eclipse.osee.jaxrs.client/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.jaxrs.client/META-INF/MANIFEST.MF
@@ -6,7 +6,6 @@ Bundle-Version: 0.18.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: Eclipse Open System Engineering Environment
Bundle-ActivationPolicy: lazy
-Service-Component: OSGI-INF/*.xml
Import-Package: com.google.inject,
com.google.inject.binder,
com.google.inject.matcher,
@@ -16,7 +15,6 @@ Import-Package: com.google.inject,
javax.inject,
javax.ws.rs,
javax.ws.rs.core,
- org.eclipse.core.net.proxy,
org.eclipse.osee.framework.jdk.core.type,
org.eclipse.osee.framework.jdk.core.util,
org.eclipse.osee.jaxrs
diff --git a/plugins/org.eclipse.osee.jaxrs.client/OSGI-INF/web.client.provider.xml b/plugins/org.eclipse.osee.jaxrs.client/OSGI-INF/web.client.provider.xml
deleted file mode 100644
index cdd564872f8..00000000000
--- a/plugins/org.eclipse.osee.jaxrs.client/OSGI-INF/web.client.provider.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" >
- <implementation class="org.eclipse.osee.jaxrs.client.internal.JaxRsClientImpl"/>
- <service>
- <provide interface="org.eclipse.osee.jaxrs.client.JaxRsClient"/>
- </service>
-</scr:component>
diff --git a/plugins/org.eclipse.osee.jaxrs.client/build.properties b/plugins/org.eclipse.osee.jaxrs.client/build.properties
index 6d4f3aa975c..34d2e4d2dad 100644
--- a/plugins/org.eclipse.osee.jaxrs.client/build.properties
+++ b/plugins/org.eclipse.osee.jaxrs.client/build.properties
@@ -1,6 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
- .,\
- OSGI-INF/
-additional.bundles = com.sun.jersey
+ .
diff --git a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsClientConstants.java b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsClientConstants.java
new file mode 100644
index 00000000000..d6a5bf519fc
--- /dev/null
+++ b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsClientConstants.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.jaxrs.client;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class JaxRsClientConstants {
+
+ private JaxRsClientConstants() {
+ // Utility class
+ }
+
+ public static final String NAMESPACE = "jaxrs.client";
+
+ private static String qualify(String value) {
+ return String.format("%s.%s", NAMESPACE, value);
+ }
+
+ public static final boolean DEFAULT_JAXRS_CLIENT_FOLLOW_REDIRECTS = true;
+ public static final int DEFAULT_JAXRS_CLIENT_THREADPOOL_SIZE = -1; // cached thread pool - no limit
+ public static final int DEFAULT_JAXRS_CLIENT_CONNECT_TIMEOUT = 30 * 1000; // 30 seconds
+ public static final int DEFAULT_JAXRS_CLIENT_READ_TIMEOUT = -1; // infinity
+
+ public static final String JAXRS_CLIENT_SERVER_ADDRESS = qualify("server.address");
+ public static final String JAXRS_CLIENT_PROXY_SERVER_ADDRESS = qualify("proxy.server.address");
+ public static final String JAXRS_CLIENT_FOLLOW_REDIRECTS = qualify("follow.redirects");
+ public static final String JAXRS_CLIENT_CONNECT_TIMEOUT = qualify("connect.timeout");
+ public static final String JAXRS_CLIENT_READ_TIMEOUT = qualify("read.timeout");
+ public static final String JAXRS_CLIENT_THREADPOOL_SIZE = qualify("threadpool.size");
+
+}
diff --git a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsClientFactory.java b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsClientFactory.java
index 0691f0fd175..181b223b9dd 100644
--- a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsClientFactory.java
+++ b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsClientFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Boeing.
+ * Copyright (c) 2014 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,14 +12,13 @@ package org.eclipse.osee.jaxrs.client;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import org.eclipse.osee.jaxrs.client.internal.StandaloneModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
/**
- * Class to use when using the API in a non-OSGI environment
- *
* @author Roberto E. Escobar
*/
public final class JaxRsClientFactory {
@@ -28,14 +27,18 @@ public final class JaxRsClientFactory {
// Utility class
}
- public static <T> T createClient(Class<T> api, OseeClientConfig config, Module... modules) {
- Injector injector = createInjector(config, modules);
+ public static JaxRsClient createClient(Map<String, Object> props) {
+ return createClient(JaxRsClient.class, props);
+ }
+
+ public static <T> T createClient(Class<T> api, Map<String, Object> props, Module... modules) {
+ Injector injector = createInjector(props, modules);
return injector.getInstance(api);
}
- private static Injector createInjector(OseeClientConfig config, Module... modules) {
+ private static Injector createInjector(Map<String, Object> props, Module... modules) {
List<Module> moduleList = new ArrayList<Module>();
- moduleList.add(new StandaloneModule(config));
+ moduleList.add(new StandaloneModule(props));
for (Module module : modules) {
moduleList.add(module);
}
diff --git a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsClientUtils.java b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsClientUtils.java
new file mode 100644
index 00000000000..063464cb248
--- /dev/null
+++ b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsClientUtils.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.jaxrs.client;
+
+import java.util.Map;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import com.google.inject.TypeLiteral;
+import com.google.inject.matcher.AbstractMatcher;
+import com.google.inject.matcher.Matcher;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class JaxRsClientUtils {
+
+ private JaxRsClientUtils() {
+ // Utility class
+ }
+
+ public static Integer getInt(Map<String, Object> props, String key, int defaultValue) {
+ String toReturn = get(props, key, String.valueOf(defaultValue));
+ return Strings.isNumeric(toReturn) ? Integer.parseInt(toReturn) : -1;
+ }
+
+ public static boolean getBoolean(Map<String, Object> props, String key, boolean defaultValue) {
+ String toReturn = get(props, key, String.valueOf(defaultValue));
+ return Boolean.parseBoolean(toReturn);
+ }
+
+ public static String get(Map<String, Object> props, String key, String defaultValue) {
+ String toReturn = defaultValue;
+ Object object = props != null ? props.get(key) : null;
+ if (object != null) {
+ toReturn = String.valueOf(object);
+ }
+ return toReturn;
+ }
+
+ public static Matcher<? super TypeLiteral<?>> subtypeOf(Class<?> superclass) {
+ return new SubTypeOfMatcher(TypeLiteral.get(superclass));
+ }
+
+ private static final class SubTypeOfMatcher extends AbstractMatcher<TypeLiteral<?>> {
+ private final TypeLiteral<?> superType;
+
+ public SubTypeOfMatcher(TypeLiteral<?> superType) {
+ super();
+ this.superType = superType;
+ }
+
+ @Override
+ public boolean matches(TypeLiteral<?> subType) {
+ return subType.equals(superType) || superType.getRawType().isAssignableFrom(subType.getRawType());
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/OseeClientConfig.java b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/OseeClientConfig.java
deleted file mode 100644
index a4975f6d80d..00000000000
--- a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/OseeClientConfig.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.jaxrs.client;
-
-/**
- * @author Roberto E. Escobar
- */
-public class OseeClientConfig {
-
- private String serverAddress = "";
- private String proxyAddress = "";
-
- public OseeClientConfig(String serverAddress) {
- this.serverAddress = serverAddress;
- }
-
- public String getServerAddress() {
- return serverAddress;
- }
-
- public void setServerAddress(String serverAddress) {
- this.serverAddress = serverAddress;
- }
-
- public String getProxyAddress() {
- return proxyAddress;
- }
-
- public void setProxyAddress(String proxyAddress) {
- this.proxyAddress = proxyAddress;
- }
-
- @Override
- public String toString() {
- return "OseeClientConfig [serverAddress=" + serverAddress + ", proxyAddress=" + proxyAddress + "]";
- }
-
-}
diff --git a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/OseeClientProperties.java b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/OseeClientProperties.java
deleted file mode 100644
index b974319af35..00000000000
--- a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/OseeClientProperties.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.jaxrs.client;
-
-/**
- * @author Roberto E. Escobar
- */
-public final class OseeClientProperties {
-
- private OseeClientProperties() {
- // Utility class
- }
-
- private static final String OSEE_APPLICATION_SERVER = "osee.application.server";
-
- public static String getApplicationServerAddress() {
- String appServer = System.getProperty(OSEE_APPLICATION_SERVER, "");
- return appServer;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/OseeHttpProxyAddress.java b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/OseeHttpProxyAddress.java
deleted file mode 100644
index 9ee0ca6b30d..00000000000
--- a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/OseeHttpProxyAddress.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.jaxrs.client;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import com.google.inject.BindingAnnotation;
-
-/**
- * @author Roberto E. Escobar
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.FIELD, ElementType.PARAMETER})
-@BindingAnnotation
-public @interface OseeHttpProxyAddress {
- //
-}
diff --git a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/OseeServerAddress.java b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/OseeServerAddress.java
deleted file mode 100644
index 3085a768a43..00000000000
--- a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/OseeServerAddress.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.jaxrs.client;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import com.google.inject.BindingAnnotation;
-
-/**
- * @author Roberto E. Escobar
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.FIELD, ElementType.PARAMETER})
-@BindingAnnotation
-public @interface OseeServerAddress {
- //
-}
diff --git a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/JaxRsClientImpl.java b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/JaxRsClientImpl.java
index 30b9bfcbc2c..843b80a89e4 100644
--- a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/JaxRsClientImpl.java
+++ b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/JaxRsClientImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Boeing.
+ * Copyright (c) 2014 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,17 +10,34 @@
*******************************************************************************/
package org.eclipse.osee.jaxrs.client.internal;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_CONNECT_TIMEOUT;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_FOLLOW_REDIRECTS;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_READ_TIMEOUT;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_THREADPOOL_SIZE;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_CONNECT_TIMEOUT;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_FOLLOW_REDIRECTS;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_PROXY_SERVER_ADDRESS;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_READ_TIMEOUT;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_SERVER_ADDRESS;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_THREADPOOL_SIZE;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientUtils.get;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientUtils.getBoolean;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientUtils.getInt;
import java.net.URI;
import java.util.Map;
+import javax.ws.rs.core.UriBuilder;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.jaxrs.ErrorResponse;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
+import org.eclipse.osee.jaxrs.client.JaxRsClientUtils;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.UniformInterfaceException;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.client.apache.ApacheHttpClient;
+import com.sun.jersey.client.apache.config.ApacheHttpClientConfig;
import com.sun.jersey.client.apache.config.DefaultApacheHttpClientConfig;
/**
@@ -28,12 +45,19 @@ import com.sun.jersey.client.apache.config.DefaultApacheHttpClientConfig;
*/
public class JaxRsClientImpl implements JaxRsClient {
- private Client client;
+ public interface JaxRsClientHolder {
+ WebResource target(URI uri);
+ }
+
+ private volatile JaxRsClientHolder client;
@Override
public WebResource createResource(URI uri) {
- Client client = createClient(uri);
- return client.resource(uri);
+ return client.target(uri);
+ }
+
+ public void configure(Map<String, Object> properties) {
+ client = newJaxRsClient(properties);
}
@Override
@@ -49,19 +73,62 @@ public class JaxRsClientImpl implements JaxRsClient {
return new OseeCoreException(ex, message);
}
- protected void configure(URI uri, Map<String, Object> properties) {
- properties.put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, true);
- }
+ private JaxRsClientHolder newJaxRsClient(Map<String, Object> props) {
+ DefaultApacheHttpClientConfig clientConfig = new DefaultApacheHttpClientConfig();
+ Map<String, Object> properties = clientConfig.getProperties();
+
+ String proxyAddress = get(props, JAXRS_CLIENT_PROXY_SERVER_ADDRESS, "");
+ if (Strings.isValid(proxyAddress)) {
+ properties.put(ApacheHttpClientConfig.PROPERTY_PROXY_URI, proxyAddress);
+ }
+
+ //@formatter:off
+ properties.put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, getBoolean(props, JAXRS_CLIENT_FOLLOW_REDIRECTS, DEFAULT_JAXRS_CLIENT_FOLLOW_REDIRECTS));
+ properties.put(ClientConfig.PROPERTY_THREADPOOL_SIZE, getInt(props, JAXRS_CLIENT_THREADPOOL_SIZE, DEFAULT_JAXRS_CLIENT_THREADPOOL_SIZE));
+ properties.put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, minZero(getInt(props, JAXRS_CLIENT_CONNECT_TIMEOUT, DEFAULT_JAXRS_CLIENT_CONNECT_TIMEOUT)));
+ properties.put(ClientConfig.PROPERTY_READ_TIMEOUT, minZero(getInt(props, JAXRS_CLIENT_READ_TIMEOUT, DEFAULT_JAXRS_CLIENT_READ_TIMEOUT)));
+ //@formatter:on
- private Client createClient(URI uri) {
- if (client == null) {
- DefaultApacheHttpClientConfig clientConfig = new DefaultApacheHttpClientConfig();
- Map<String, Object> properties = clientConfig.getProperties();
- properties.put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, true);
- configure(uri, properties);
- client = ApacheHttpClient.create(clientConfig);
+ Client delegate = ApacheHttpClient.create(clientConfig);
+ JaxRsClientHolder toReturn;
+ String serverAddress = JaxRsClientUtils.get(props, JAXRS_CLIENT_SERVER_ADDRESS, "");
+ if (Strings.isValid(serverAddress)) {
+ toReturn = newClient(delegate, serverAddress);
+ } else {
+ toReturn = newClient(delegate);
}
- return client;
+ return toReturn;
}
+ private static int minZero(int value) {
+ return value < 0 ? 0 : value;
+ }
+
+ private JaxRsClientHolder newClient(final Client delegate) {
+ return new JaxRsClientHolder() {
+
+ @Override
+ public WebResource target(URI uri) {
+ return delegate.resource(uri);
+ }
+ };
+ }
+
+ private JaxRsClientHolder newClient(final Client delegate, final String serverAddress) {
+ return new JaxRsClientHolder() {
+
+ private boolean isPartialAddress(URI uri) {
+ return uri != null && !uri.isAbsolute();
+ }
+
+ @Override
+ public WebResource target(URI uri) {
+ URI uriToContact = uri;
+ if (isPartialAddress(uriToContact)) {
+ uriToContact = UriBuilder.fromUri(serverAddress).path(uri.toASCIIString()).build();
+ }
+ return delegate.resource(uriToContact);
+ }
+ };
+ }
}
diff --git a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/StandadloneWebClientProvider.java b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/StandadloneWebClientProvider.java
deleted file mode 100644
index 009f75631af..00000000000
--- a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/StandadloneWebClientProvider.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.jaxrs.client.internal;
-
-import java.net.URI;
-import java.util.Map;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.jaxrs.client.OseeHttpProxyAddress;
-import com.google.inject.Inject;
-import com.sun.jersey.api.client.config.ClientConfig;
-import com.sun.jersey.client.apache.config.ApacheHttpClientConfig;
-
-/**
- * @author Roberto E. Escobar
- */
-public class StandadloneWebClientProvider extends JaxRsClientImpl {
-
- private final String proxyAddress;
-
- @Inject
- public StandadloneWebClientProvider(@OseeHttpProxyAddress String proxyAddress) {
- this.proxyAddress = proxyAddress;
- }
-
- @Override
- protected void configure(URI uri, Map<String, Object> properties) {
- properties.put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, true);
- if (Strings.isValid(proxyAddress)) {
- properties.put(ApacheHttpClientConfig.PROPERTY_PROXY_URI, proxyAddress);
- }
- }
-
-}
diff --git a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/StandaloneModule.java b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/StandaloneModule.java
index a3c08826cb2..3a62d6247ed 100644
--- a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/StandaloneModule.java
+++ b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/StandaloneModule.java
@@ -10,28 +10,45 @@
*******************************************************************************/
package org.eclipse.osee.jaxrs.client.internal;
-import org.eclipse.osee.jaxrs.client.OseeClientConfig;
-import org.eclipse.osee.jaxrs.client.OseeHttpProxyAddress;
-import org.eclipse.osee.jaxrs.client.OseeServerAddress;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientUtils.subtypeOf;
+import java.util.Map;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
import com.google.inject.AbstractModule;
+import com.google.inject.TypeLiteral;
+import com.google.inject.spi.InjectionListener;
+import com.google.inject.spi.TypeEncounter;
+import com.google.inject.spi.TypeListener;
/**
* @author Roberto E. Escobar
*/
public class StandaloneModule extends AbstractModule {
- private final OseeClientConfig config;
+ private final Map<String, Object> props;
- public StandaloneModule(OseeClientConfig config) {
- this.config = config;
+ public StandaloneModule(Map<String, Object> props) {
+ this.props = props;
}
@Override
protected void configure() {
- bindConstant().annotatedWith(OseeServerAddress.class).to(config.getServerAddress());
- bindConstant().annotatedWith(OseeHttpProxyAddress.class).to(config.getProxyAddress());
+ bind(JaxRsClient.class).to(JaxRsClientImpl.class);
- bind(JaxRsClient.class).to(StandadloneWebClientProvider.class);
+ TypeListener listener = new TypeListener() {
+
+ @Override
+ public <I> void hear(TypeLiteral<I> type, TypeEncounter<I> encounter) {
+ encounter.register(new InjectionListener<I>() {
+
+ @Override
+ public void afterInjection(I injectee) {
+ JaxRsClientImpl client = (JaxRsClientImpl) injectee;
+ client.configure(props);
+ }
+ });
+ }
+ };
+ bindListener(subtypeOf(JaxRsClient.class), listener);
}
+
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/OSGI-INF/osee.client.xml b/plugins/org.eclipse.osee.orcs.rest.client/OSGI-INF/osee.client.xml
index d8217c57541..19a1595ffcc 100644
--- a/plugins/org.eclipse.osee.orcs.rest.client/OSGI-INF/osee.client.xml
+++ b/plugins/org.eclipse.osee.orcs.rest.client/OSGI-INF/osee.client.xml
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop">
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop" modified="update">
<implementation class="org.eclipse.osee.orcs.rest.client.internal.OseeClientImpl"/>
<service>
<provide interface="org.eclipse.osee.orcs.rest.client.OseeClient"/>
</service>
- <reference bind="setJaxRsClient" cardinality="1..1" interface="org.eclipse.osee.jaxrs.client.JaxRsClient" name="JaxRsClient" policy="static"/>
</scr:component>
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClientStandaloneSetup.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClientStandaloneSetup.java
index 6da5b7e2f4a..42f8a772516 100644
--- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClientStandaloneSetup.java
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClientStandaloneSetup.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.orcs.rest.client;
-import org.eclipse.osee.jaxrs.client.OseeClientConfig;
+import java.util.Map;
import org.eclipse.osee.jaxrs.client.JaxRsClientFactory;
import org.eclipse.osee.orcs.rest.client.internal.OrcsClientModule;
import org.eclipse.osee.orcs.rest.client.internal.OseeClientImpl;
@@ -27,8 +27,8 @@ public final class OseeClientStandaloneSetup {
// Utility class
}
- public static OseeClient createClient(OseeClientConfig config) {
- Module module = new OrcsClientModule();
+ public static OseeClient createClient(Map<String, Object> config) {
+ Module module = new OrcsClientModule(config);
return JaxRsClientFactory.createClient(OseeClientImpl.class, config, module);
}
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OrcsClientModule.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OrcsClientModule.java
index 245802ce930..654ec465bac 100644
--- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OrcsClientModule.java
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OrcsClientModule.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.orcs.rest.client.internal;
+import java.util.Map;
import org.eclipse.osee.orcs.rest.client.OseeClient;
import com.google.inject.AbstractModule;
import com.google.inject.TypeLiteral;
@@ -24,6 +25,13 @@ import com.google.inject.spi.TypeListener;
*/
public class OrcsClientModule extends AbstractModule {
+ private final Map<String, Object> config;
+
+ public OrcsClientModule(Map<String, Object> config) {
+ super();
+ this.config = config;
+ }
+
@Override
protected void configure() {
bind(OseeClient.class).to(OseeClientImpl.class);
@@ -36,7 +44,7 @@ public class OrcsClientModule extends AbstractModule {
@Override
public void afterInjection(I injectee) {
OseeClientImpl client = (OseeClientImpl) injectee;
- client.start();
+ client.start(config);
}
});
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java
index da8aef52280..66b6a7abc75 100644
--- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java
@@ -10,15 +10,19 @@
*******************************************************************************/
package org.eclipse.osee.orcs.rest.client.internal;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_SERVER_ADDRESS;
import java.net.URI;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.data.OseeCodeVersion;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
-import org.eclipse.osee.jaxrs.client.OseeClientProperties;
+import org.eclipse.osee.jaxrs.client.JaxRsClientFactory;
+import org.eclipse.osee.jaxrs.client.JaxRsClientUtils;
import org.eclipse.osee.orcs.rest.client.OseeClient;
import org.eclipse.osee.orcs.rest.client.QueryBuilder;
import org.eclipse.osee.orcs.rest.client.internal.search.PredicateFactory;
@@ -29,7 +33,6 @@ import org.eclipse.osee.orcs.rest.client.internal.search.QueryExecutorV1.BaseUri
import org.eclipse.osee.orcs.rest.client.internal.search.QueryOptions;
import org.eclipse.osee.orcs.rest.model.Client;
import org.eclipse.osee.orcs.rest.model.search.artifact.Predicate;
-import com.google.inject.Inject;
import com.sun.jersey.api.client.UniformInterfaceException;
import com.sun.jersey.api.client.WebResource;
@@ -39,24 +42,38 @@ import com.sun.jersey.api.client.WebResource;
*/
public class OseeClientImpl implements OseeClient, BaseUriBuilder {
- private PredicateFactory predicateFactory;
- private QueryExecutorV1 executor;
+ private static final String OSEE_APPLICATION_SERVER = "osee.application.server";
- private JaxRsClient client;
+ private volatile PredicateFactory predicateFactory;
+ private volatile QueryExecutorV1 executor;
+ private volatile JaxRsClient client;
- @Inject
- public void setJaxRsClient(JaxRsClient client) {
- this.client = client;
- }
-
- public void start() {
+ public void start(Map<String, Object> properties) {
predicateFactory = new PredicateFactoryImpl();
- executor = new QueryExecutorV1(client, this);
+
+ update(properties);
}
public void stop() {
- predicateFactory = null;
executor = null;
+ client = null;
+ predicateFactory = null;
+ }
+
+ public void update(Map<String, Object> properties) {
+ Map<String, Object> propsToUse = properties;
+ String newServerAddress = JaxRsClientUtils.get(propsToUse, JAXRS_CLIENT_SERVER_ADDRESS, null);
+ if (newServerAddress == null) {
+ propsToUse = new HashMap<String, Object>(properties);
+ propsToUse.put(JAXRS_CLIENT_SERVER_ADDRESS, System.getProperty(OSEE_APPLICATION_SERVER, ""));
+ }
+ client = JaxRsClientFactory.createClient(propsToUse);
+ executor = new QueryExecutorV1(client, this);
+ }
+
+ @Override
+ public UriBuilder newBuilder() {
+ return UriBuilder.fromPath("orcs");
}
@Override
@@ -67,12 +84,6 @@ public class OseeClientImpl implements OseeClient, BaseUriBuilder {
}
@Override
- public UriBuilder newBuilder() {
- String serverUri = OseeClientProperties.getApplicationServerAddress();
- return UriBuilder.fromUri(serverUri).path("orcs");
- }
-
- @Override
public boolean isClientVersionSupportedByApplicationServer() {
boolean result = false;
URI uri = newBuilder().path("client").build();
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutorV1.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutorV1.java
index 38bc14bedf4..54793ebf061 100644
--- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutorV1.java
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutorV1.java
@@ -35,12 +35,12 @@ public class QueryExecutorV1 implements QueryExecutor {
UriBuilder newBuilder();
}
- private final JaxRsClient clientProvider;
+ private final JaxRsClient client;
private final BaseUriBuilder baseUriBuilder;
- public QueryExecutorV1(JaxRsClient clientProvider, BaseUriBuilder baseUriBuilder) {
+ public QueryExecutorV1(JaxRsClient client, BaseUriBuilder baseUriBuilder) {
super();
- this.clientProvider = clientProvider;
+ this.client = client;
this.baseUriBuilder = baseUriBuilder;
}
@@ -77,14 +77,14 @@ public class QueryExecutorV1 implements QueryExecutor {
requestType.name().toLowerCase(), fromTx, includeDeleted);
URI uri = getQueryUri(branch.getUuid());
- WebResource resource = clientProvider.createResource(uri);
+ WebResource resource = client.createResource(uri);
SearchResponse searchResult = null;
try {
searchResult =
resource.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON_TYPE).post(
SearchResponse.class, params);
} catch (UniformInterfaceException ex) {
- throw clientProvider.handleException(ex);
+ throw client.handleException(ex);
}
return searchResult;
}
diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/OSGI-INF/ote.master.rest.client.xml b/plugins/org.eclipse.osee.ote.master.rest.client/OSGI-INF/ote.master.rest.client.xml
index a2fd3832043..6c2a6e593a3 100644
--- a/plugins/org.eclipse.osee.ote.master.rest.client/OSGI-INF/ote.master.rest.client.xml
+++ b/plugins/org.eclipse.osee.ote.master.rest.client/OSGI-INF/ote.master.rest.client.xml
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop">
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop" modified="update">
<implementation class="org.eclipse.osee.ote.master.rest.client.internal.OTEMasterServerImpl"/>
<service>
<provide interface="org.eclipse.osee.ote.master.rest.client.OTEMasterServer"/>
</service>
- <reference bind="setJaxRsClient" cardinality="1..1" interface="org.eclipse.osee.jaxrs.client.JaxRsClient" name="JaxRsClient" policy="static"/>
</scr:component>
diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/OTEMasterServerImpl.java b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/OTEMasterServerImpl.java
index a395da7fe2d..3456be01f3f 100644
--- a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/OTEMasterServerImpl.java
+++ b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/OTEMasterServerImpl.java
@@ -1,11 +1,13 @@
package org.eclipse.osee.ote.master.rest.client.internal;
import java.net.URI;
+import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
+import org.eclipse.osee.jaxrs.client.JaxRsClientFactory;
import org.eclipse.osee.ote.master.rest.client.OTEMasterServer;
import org.eclipse.osee.ote.master.rest.client.OTEMasterServerAvailableNodes;
import org.eclipse.osee.ote.master.rest.client.OTEMasterServerResult;
@@ -16,14 +18,10 @@ public class OTEMasterServerImpl implements OTEMasterServer {
static final String CONTEXT_NAME = "otemaster";
static final String CONTEXT_SERVERS = "servers";
- private JaxRsClient client;
+ private volatile JaxRsClient client;
private ExecutorService executor;
- public void setJaxRsClient(JaxRsClient client) {
- this.client = client;
- }
-
- public void start() {
+ public void start(Map<String, Object> props) {
executor = Executors.newCachedThreadPool(new ThreadFactory() {
@Override
public Thread newThread(Runnable arg0) {
@@ -33,12 +31,18 @@ public class OTEMasterServerImpl implements OTEMasterServer {
return th;
}
});
+ update(props);
}
public void stop() {
if (executor != null) {
executor.shutdown();
}
+ client = null;
+ }
+
+ public void update(Map<String, Object> props) {
+ client = JaxRsClientFactory.createClient(props);
}
@Override
diff --git a/plugins/org.eclipse.osee.ote.rest.client/OSGI-INF/ote.client.xml b/plugins/org.eclipse.osee.ote.rest.client/OSGI-INF/ote.client.xml
index 8d857e8f933..239d14858d2 100644
--- a/plugins/org.eclipse.osee.ote.rest.client/OSGI-INF/ote.client.xml
+++ b/plugins/org.eclipse.osee.ote.rest.client/OSGI-INF/ote.client.xml
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop">
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop" modified="update">
<implementation class="org.eclipse.osee.ote.rest.client.internal.OteClientImpl"/>
<service>
<provide interface="org.eclipse.osee.ote.rest.client.OteClient"/>
</service>
- <reference bind="setJaxRsClient" cardinality="1..1" interface="org.eclipse.osee.jaxrs.client.JaxRsClient" name="JaxRsClient" policy="static"/>
</scr:component>
diff --git a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/OteClientImpl.java b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/OteClientImpl.java
index 78b9cd4e6c0..b717364f334 100644
--- a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/OteClientImpl.java
+++ b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/OteClientImpl.java
@@ -13,11 +13,13 @@ package org.eclipse.osee.ote.rest.client.internal;
import java.io.File;
import java.net.URI;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
+import org.eclipse.osee.jaxrs.client.JaxRsClientFactory;
import org.eclipse.osee.ote.rest.client.OTECacheItem;
import org.eclipse.osee.ote.rest.client.OteClient;
import org.eclipse.osee.ote.rest.client.Progress;
@@ -31,13 +33,9 @@ import org.eclipse.osee.ote.rest.model.OTETestRun;
public class OteClientImpl implements OteClient {
private ExecutorService executor;
- private JaxRsClient client;
+ private volatile JaxRsClient client;
- public void setJaxRsClient(JaxRsClient client) {
- this.client = client;
- }
-
- public void start() {
+ public void start(Map<String, Object> props) {
executor = Executors.newCachedThreadPool(new ThreadFactory() {
@Override
public Thread newThread(Runnable arg0) {
@@ -47,12 +45,18 @@ public class OteClientImpl implements OteClient {
return th;
}
});
+ update(props);
}
public void stop() {
if (executor != null) {
executor.shutdown();
}
+ client = null;
+ }
+
+ public void update(Map<String, Object> props) {
+ client = JaxRsClientFactory.createClient(props);
}
@Override
diff --git a/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/IntegrationUtil.java b/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/IntegrationUtil.java
index 41f2b0102ce..13ee1d854e7 100644
--- a/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/IntegrationUtil.java
+++ b/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/IntegrationUtil.java
@@ -10,13 +10,15 @@
*******************************************************************************/
package org.eclipse.osee.x.server.integration.tests.performance;
+import java.util.HashMap;
+import java.util.Map;
import org.databene.contiperf.junit.ContiPerfRule;
import org.databene.contiperf.report.CSVLatencyReportModule;
import org.databene.contiperf.report.CSVSummaryReportModule;
import org.databene.contiperf.report.HtmlReportModule;
import org.eclipse.osee.account.rest.client.AccountClient;
import org.eclipse.osee.account.rest.client.AccountClientStandaloneSetup;
-import org.eclipse.osee.jaxrs.client.OseeClientConfig;
+import org.eclipse.osee.jaxrs.client.JaxRsClientConstants;
import org.eclipse.osee.orcs.rest.client.OseeClient;
import org.eclipse.osee.orcs.rest.client.OseeClientStandaloneSetup;
import org.junit.rules.MethodRule;
@@ -35,18 +37,19 @@ public final class IntegrationUtil {
}
public static OseeClient createClient() {
- OseeClientConfig config = createClientConfig();
+ Map<String, Object> config = createClientConfig();
return OseeClientStandaloneSetup.createClient(config);
}
- private static OseeClientConfig createClientConfig() {
+ private static Map<String, Object> createClientConfig() {
+ Map<String, Object> config = new HashMap<String, Object>();
String serverAddress = System.getProperty(OSEE_APPLICATION_SERVER, DEFAULT_OSEE_APPLICATION_SERVER);
- OseeClientConfig config = new OseeClientConfig(serverAddress);
+ config.put(JaxRsClientConstants.JAXRS_CLIENT_SERVER_ADDRESS, serverAddress);
return config;
}
public static AccountClient createAccountClient() {
- OseeClientConfig config = createClientConfig();
+ Map<String, Object> config = createClientConfig();
return AccountClientStandaloneSetup.createClient(config);
}

Back to the top