Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2014-06-10 14:47:10 -0400
committerRoberto E. Escobar2014-08-28 19:58:30 -0400
commit2cba21dbf75f6e7bed63a267036ddd7192eb4b77 (patch)
tree65fb5b5ebd623c6a769f22b8ba8ead02d59720c8 /plugins/org.eclipse.osee.ote.master.rest.client
parentfc1724d32fd8d2e3e5c8c1e004c7a2b249a99c24 (diff)
downloadorg.eclipse.osee-2cba21dbf75f6e7bed63a267036ddd7192eb4b77.tar.gz
org.eclipse.osee-2cba21dbf75f6e7bed63a267036ddd7192eb4b77.tar.xz
org.eclipse.osee-2cba21dbf75f6e7bed63a267036ddd7192eb4b77.zip
refactor[ats_ATS64244]: Update OTE to use JAX-RS Client
Diffstat (limited to 'plugins/org.eclipse.osee.ote.master.rest.client')
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/OSGI-INF/ote.master.rest.client.webclientprovider.xml7
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/OSGI-INF/ote.master.rest.client.xml4
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/AddServer.java18
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/GetAvailableServers.java16
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/MasterServerCallable.java9
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/OTEMasterServerImpl.java36
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/RemoveServer.java19
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/WebClientProvider.java24
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/WebClientProviderImpl.java58
10 files changed, 45 insertions, 148 deletions
diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ote.master.rest.client/META-INF/MANIFEST.MF
index 320dc4ad54..eb830fe1d7 100644
--- a/plugins/org.eclipse.osee.ote.master.rest.client/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.ote.master.rest.client/META-INF/MANIFEST.MF
@@ -11,6 +11,8 @@ Import-Package: com.sun.jersey.api.client,
com.sun.jersey.client.apache,
com.sun.jersey.client.apache.config,
javax.ws.rs.core,
+ org.eclipse.osee.framework.jdk.core.type,
+ org.eclipse.osee.jaxrs.client,
org.eclipse.osee.ote.master.rest.model
Export-Package: org.eclipse.osee.ote.master.rest.client
Service-Component: OSGI-INF/*.xml
diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/OSGI-INF/ote.master.rest.client.webclientprovider.xml b/plugins/org.eclipse.osee.ote.master.rest.client/OSGI-INF/ote.master.rest.client.webclientprovider.xml
deleted file mode 100644
index 63e9df3ff6..0000000000
--- a/plugins/org.eclipse.osee.ote.master.rest.client/OSGI-INF/ote.master.rest.client.webclientprovider.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" name="org.eclipse.osee.ote.master.rest.client..webclientprovider">
- <implementation class="org.eclipse.osee.ote.master.rest.client.internal.WebClientProviderImpl"/>
- <service>
- <provide interface="org.eclipse.osee.ote.master.rest.client.internal.WebClientProvider"/>
- </service>
-</scr:component>
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 0bfaa47b1d..10ff996630 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,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop" name="org.eclipse.osee.ote.master.rest.client">
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop">
<implementation class="org.eclipse.osee.ote.master.rest.client.internal.OTEMasterServerImpl"/>
- <reference bind="bindWebClientProvider" cardinality="1..1" interface="org.eclipse.osee.ote.master.rest.client.internal.WebClientProvider" name="WebClientProvider" policy="static" unbind="unbindWebClientProvider"/>
<service>
<provide interface="org.eclipse.osee.ote.master.rest.client.OTEMasterServer"/>
</service>
+ <reference bind="setWebClientProvider" cardinality="1..1" interface="org.eclipse.osee.jaxrs.client.WebClientProvider" name="WebClientProvider" policy="static"/>
</scr:component>
diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/AddServer.java b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/AddServer.java
index 6450e61837..9aab0fbb8f 100644
--- a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/AddServer.java
+++ b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/AddServer.java
@@ -2,19 +2,17 @@ package org.eclipse.osee.ote.master.rest.client.internal;
import java.net.URI;
import java.util.concurrent.Callable;
-
import javax.ws.rs.core.MediaType;
-
+import org.eclipse.osee.jaxrs.client.WebClientProvider;
import org.eclipse.osee.ote.master.rest.client.OTEMasterServerResult;
import org.eclipse.osee.ote.master.rest.model.OTEServer;
-
import com.sun.jersey.api.client.WebResource;
public class AddServer implements Callable<OTEMasterServerResult> {
- private WebClientProvider webClientProvider;
- private OTEServer server;
- private URI uri;
+ private final WebClientProvider webClientProvider;
+ private final OTEServer server;
+ private final URI uri;
public AddServer(WebClientProvider webClientProvider, URI uri, OTEServer server) {
this.webClientProvider = webClientProvider;
@@ -25,10 +23,12 @@ public class AddServer implements Callable<OTEMasterServerResult> {
@Override
public OTEMasterServerResult call() throws Exception {
OTEMasterServerResult result = new OTEMasterServerResult();
- try{
+ try {
WebResource resource = webClientProvider.createResource(uri);
- resource.path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).accept(MediaType.APPLICATION_XML).post(server);
- } catch (Throwable th){
+ resource.path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).accept(
+ MediaType.APPLICATION_XML).post(server);
+
+ } catch (Throwable th) {
result.setSuccess(false);
result.setThrowable(th);
}
diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/GetAvailableServers.java b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/GetAvailableServers.java
index 0ef39942ca..7449c0f795 100644
--- a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/GetAvailableServers.java
+++ b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/GetAvailableServers.java
@@ -2,18 +2,16 @@ package org.eclipse.osee.ote.master.rest.client.internal;
import java.net.URI;
import java.util.concurrent.Callable;
-
import javax.ws.rs.core.MediaType;
-
+import org.eclipse.osee.jaxrs.client.WebClientProvider;
import org.eclipse.osee.ote.master.rest.client.OTEMasterServerAvailableNodes;
import org.eclipse.osee.ote.master.rest.model.OTEServer;
-
import com.sun.jersey.api.client.WebResource;
public class GetAvailableServers implements Callable<OTEMasterServerAvailableNodes> {
- private WebClientProvider webClientProvider;
- private URI uri;
+ private final WebClientProvider webClientProvider;
+ private final URI uri;
public GetAvailableServers(WebClientProvider webClientProvider, URI uri) {
this.webClientProvider = webClientProvider;
@@ -23,12 +21,14 @@ public class GetAvailableServers implements Callable<OTEMasterServerAvailableNod
@Override
public OTEMasterServerAvailableNodes call() throws Exception {
OTEMasterServerAvailableNodes result = new OTEMasterServerAvailableNodes();
- try{
+ try {
WebResource resource = webClientProvider.createResource(uri);
- OTEServer[] servers = resource.path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).accept(MediaType.APPLICATION_XML).get(OTEServer[].class);
+ OTEServer[] servers =
+ resource.path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).accept(
+ MediaType.APPLICATION_XML).get(OTEServer[].class);
result.setServers(servers);
result.setSuccess(true);
- } catch (Throwable th){
+ } catch (Throwable th) {
result.setSuccess(false);
result.setThrowable(th);
}
diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/MasterServerCallable.java b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/MasterServerCallable.java
deleted file mode 100644
index 49a65bb364..0000000000
--- a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/MasterServerCallable.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.eclipse.osee.ote.master.rest.client.internal;
-
-import java.util.concurrent.Callable;
-
-public abstract class MasterServerCallable<V> implements Callable<V> {
-
-
-
-}
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 533201e202..c7993e93ed 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
@@ -5,7 +5,7 @@ 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.WebClientProvider;
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;
@@ -15,12 +15,16 @@ public class OTEMasterServerImpl implements OTEMasterServer {
static final String CONTEXT_NAME = "otemaster";
static final String CONTEXT_SERVERS = "servers";
-
+
private WebClientProvider webClientProvider;
private ExecutorService executor;
-
- public OTEMasterServerImpl(){
- executor = Executors.newCachedThreadPool(new ThreadFactory(){
+
+ public void setWebClientProvider(WebClientProvider webClientProvider) {
+ this.webClientProvider = webClientProvider;
+ }
+
+ public void start() {
+ executor = Executors.newCachedThreadPool(new ThreadFactory() {
@Override
public Thread newThread(Runnable arg0) {
Thread th = new Thread(arg0);
@@ -30,23 +34,13 @@ public class OTEMasterServerImpl implements OTEMasterServer {
}
});
}
-
- public void start(){
-
- }
-
- public void stop(){
-
- }
-
- public void bindWebClientProvider(WebClientProvider webClientProvider){
- this.webClientProvider = webClientProvider;
- }
-
- public void unbindWebClientProvider(WebClientProvider webClientProvider){
- this.webClientProvider = null;
+
+ public void stop() {
+ if (executor != null) {
+ executor.shutdown();
+ }
}
-
+
@Override
public Future<OTEMasterServerAvailableNodes> getAvailableServers(URI uri) {
return executor.submit(new GetAvailableServers(webClientProvider, uri));
diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/RemoveServer.java b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/RemoveServer.java
index f087640a59..6f8b2d2fcf 100644
--- a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/RemoveServer.java
+++ b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/RemoveServer.java
@@ -2,19 +2,17 @@ package org.eclipse.osee.ote.master.rest.client.internal;
import java.net.URI;
import java.util.concurrent.Callable;
-
import javax.ws.rs.core.MediaType;
-
+import org.eclipse.osee.jaxrs.client.WebClientProvider;
import org.eclipse.osee.ote.master.rest.client.OTEMasterServerResult;
import org.eclipse.osee.ote.master.rest.model.OTEServer;
-
import com.sun.jersey.api.client.WebResource;
public class RemoveServer implements Callable<OTEMasterServerResult> {
- private WebClientProvider webClientProvider;
- private OTEServer server;
- private URI uri;
+ private final WebClientProvider webClientProvider;
+ private final OTEServer server;
+ private final URI uri;
public RemoveServer(WebClientProvider webClientProvider, URI uri, OTEServer server) {
this.webClientProvider = webClientProvider;
@@ -25,14 +23,15 @@ public class RemoveServer implements Callable<OTEMasterServerResult> {
@Override
public OTEMasterServerResult call() throws Exception {
OTEMasterServerResult result = new OTEMasterServerResult();
- try{
+ try {
WebResource resource = webClientProvider.createResource(uri);
- resource.path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).accept(MediaType.APPLICATION_XML).delete(server);
- } catch (Throwable th){
+ resource.path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).accept(
+ MediaType.APPLICATION_XML).delete(server);
+ } catch (Throwable th) {
result.setSuccess(false);
result.setThrowable(th);
}
return result;
}
-
+
}
diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/WebClientProvider.java b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/WebClientProvider.java
deleted file mode 100644
index 65c40e8475..0000000000
--- a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/WebClientProvider.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.ote.master.rest.client.internal;
-
-import java.net.URI;
-
-import com.sun.jersey.api.client.AsyncWebResource;
-import com.sun.jersey.api.client.WebResource;
-
-public interface WebClientProvider {
-
- WebResource createResource(URI uri) throws Exception;
-
- AsyncWebResource createAsyncResource(URI uri) throws Exception;
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/WebClientProviderImpl.java b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/WebClientProviderImpl.java
deleted file mode 100644
index 8f7fbf77c9..0000000000
--- a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/WebClientProviderImpl.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.ote.master.rest.client.internal;
-
-import java.net.URI;
-import java.util.Map;
-
-import com.sun.jersey.api.client.AsyncWebResource;
-import com.sun.jersey.api.client.Client;
-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.DefaultApacheHttpClientConfig;
-
-public class WebClientProviderImpl implements WebClientProvider {
-
- private Client client;
-
- public void start() {
-
- }
-
- public void stop() {
- }
-
- @Override
- public WebResource createResource(URI uri) {
- Client client = createClient(uri);
- return client.resource(uri);
- }
-
- @Override
- public AsyncWebResource createAsyncResource(URI uri) {
- Client client = createClient(uri);
- return client.asyncResource(uri);
- }
-
- 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);
-
- client = ApacheHttpClient.create(clientConfig);
- }
- return client;
- }
-
-} \ No newline at end of file

Back to the top