Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2011-09-20 15:53:31 -0400
committerRyan D. Brooks2011-09-20 15:53:31 -0400
commite24b1c4179aef4cfced9ecc58dae3977c0b8a54b (patch)
tree31e3537950a6d085dfdac7b7b8e7259b321bdd6f /plugins/org.eclipse.osee.cluster.rest
parent7035596c9237da7042db9bee5ca00d2774759665 (diff)
downloadorg.eclipse.osee-e24b1c4179aef4cfced9ecc58dae3977c0b8a54b.tar.gz
org.eclipse.osee-e24b1c4179aef4cfced9ecc58dae3977c0b8a54b.tar.xz
org.eclipse.osee-e24b1c4179aef4cfced9ecc58dae3977c0b8a54b.zip
feature[ats_Q9NLC]: Rename cluster bundles
Diffstat (limited to 'plugins/org.eclipse.osee.cluster.rest')
-rw-r--r--plugins/org.eclipse.osee.cluster.rest/.classpath7
-rw-r--r--plugins/org.eclipse.osee.cluster.rest/.project33
-rw-r--r--plugins/org.eclipse.osee.cluster.rest/META-INF/MANIFEST.MF11
-rw-r--r--plugins/org.eclipse.osee.cluster.rest/OSGI-INF/cluster.rest.application.xml9
-rw-r--r--plugins/org.eclipse.osee.cluster.rest/build.properties7
-rw-r--r--plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/ClusterRestApplication.java48
-rw-r--r--plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/ClusterUtil.java32
-rw-r--r--plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/JobsResource.java28
-rw-r--r--plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/MemberResource.java69
-rw-r--r--plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/MembersResource.java68
-rw-r--r--plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/XmlMember.java57
11 files changed, 369 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.cluster.rest/.classpath b/plugins/org.eclipse.osee.cluster.rest/.classpath
new file mode 100644
index 0000000000..ad32c83a78
--- /dev/null
+++ b/plugins/org.eclipse.osee.cluster.rest/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.osee.cluster.rest/.project b/plugins/org.eclipse.osee.cluster.rest/.project
new file mode 100644
index 0000000000..f5184787b8
--- /dev/null
+++ b/plugins/org.eclipse.osee.cluster.rest/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.cluster.rest</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.osee.cluster.rest/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.cluster.rest/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..846cbb735a
--- /dev/null
+++ b/plugins/org.eclipse.osee.cluster.rest/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSEE Cluster Rest
+Bundle-SymbolicName: org.eclipse.osee.cluster.rest
+Bundle-Version: 0.9.9.qualifier
+Bundle-Vendor: Eclipse Open System Engineering Environment
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Service-Component: OSGI-INF/*.xml
+Import-Package: javax.ws.rs,
+ javax.ws.rs.core,
+ org.eclipse.osee.cluster
diff --git a/plugins/org.eclipse.osee.cluster.rest/OSGI-INF/cluster.rest.application.xml b/plugins/org.eclipse.osee.cluster.rest/OSGI-INF/cluster.rest.application.xml
new file mode 100644
index 0000000000..589c2bdd3e
--- /dev/null
+++ b/plugins/org.eclipse.osee.cluster.rest/OSGI-INF/cluster.rest.application.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.osee.cluster.rest.internal.ClusterRestApplication">
+ <implementation class="org.eclipse.osee.cluster.rest.internal.ClusterRestApplication"/>
+ <service>
+ <provide interface="javax.ws.rs.core.Application"/>
+ </service>
+ <property name="context.name" type="String" value="cluster"/>
+ <reference bind="setClusterService" cardinality="1..1" interface="org.eclipse.osee.cluster.ClusterService" name="ClusterService" policy="static"/>
+</scr:component> \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.cluster.rest/build.properties b/plugins/org.eclipse.osee.cluster.rest/build.properties
new file mode 100644
index 0000000000..80e0032caa
--- /dev/null
+++ b/plugins/org.eclipse.osee.cluster.rest/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/
+additional.bundles = org.eclipse.osee.cluster,\
+ javax.ws.rs
diff --git a/plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/ClusterRestApplication.java b/plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/ClusterRestApplication.java
new file mode 100644
index 0000000000..5c3f2baf04
--- /dev/null
+++ b/plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/ClusterRestApplication.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.cluster.rest.internal;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.ws.rs.core.Application;
+import org.eclipse.osee.cluster.ClusterService;
+import org.eclipse.osee.cluster.Member;
+
+/**
+ * A service for clients to obtain information about the cluster.
+ *
+ * @author Roberto E. Escobar
+ */
+public class ClusterRestApplication extends Application {
+
+ private static ClusterService clusterService;
+
+ public void setClusterService(ClusterService clusterService) {
+ ClusterRestApplication.clusterService = clusterService;
+ }
+
+ public static ClusterService getClusterService() {
+ return clusterService;
+ }
+
+ public static Set<Member> getMembers() {
+ ClusterService service = ClusterRestApplication.getClusterService();
+ return service.getCluster().getMembers();
+ }
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ Set<Class<?>> resources = new HashSet<Class<?>>();
+ resources.add(MembersResource.class);
+ resources.add(JobsResource.class);
+ return resources;
+ }
+}
diff --git a/plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/ClusterUtil.java b/plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/ClusterUtil.java
new file mode 100644
index 0000000000..cd8ae1bf28
--- /dev/null
+++ b/plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/ClusterUtil.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.cluster.rest.internal;
+
+import java.net.InetSocketAddress;
+import org.eclipse.osee.cluster.Member;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class ClusterUtil {
+
+ private ClusterUtil() {
+ // Utility class
+ }
+
+ public static String asId(InetSocketAddress address) {
+ return address.toString();
+ }
+
+ public static XmlMember fromMember(Member member) {
+ return new XmlMember(member.getInetSocketAddress().toString(), member.hasData(), member.isLocal());
+ }
+}
diff --git a/plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/JobsResource.java b/plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/JobsResource.java
new file mode 100644
index 0000000000..e53a463ee2
--- /dev/null
+++ b/plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/JobsResource.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.cluster.rest.internal;
+
+import javax.ws.rs.Path;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@Path("jobs")
+public class JobsResource {
+ //
+ // GET /jobs/ gets list of jobs
+ //
+ // One user methods:
+ //
+ // GET /jobs/[jobId] gets job details
+ // DELETE /jobs/[jobId] deletes a job - stops/cancels ?
+ //
+}
diff --git a/plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/MemberResource.java b/plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/MemberResource.java
new file mode 100644
index 0000000000..37eed14033
--- /dev/null
+++ b/plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/MemberResource.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.cluster.rest.internal;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.UriInfo;
+import org.eclipse.osee.cluster.Member;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class MemberResource {
+
+ @Context
+ UriInfo uriInfo;
+ @Context
+ Request request;
+ String id;
+
+ public MemberResource(UriInfo uriInfo, Request request, String id) {
+ this.uriInfo = uriInfo;
+ this.request = request;
+ this.id = id;
+ }
+
+ @GET
+ @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+ public XmlMember getMember() {
+ XmlMember toReturn = toXmlMember(id);
+ if (toReturn == null) {
+ throw new RuntimeException("Get: Member with " + id + " not found");
+ }
+ return toReturn;
+ }
+
+ @GET
+ @Produces(MediaType.TEXT_XML)
+ public XmlMember getMemberHTML() {
+ XmlMember toReturn = toXmlMember(id);
+ if (toReturn == null) {
+ throw new RuntimeException("Get: Member with " + id + " not found");
+ }
+ return toReturn;
+ }
+
+ private XmlMember toXmlMember(String id) {
+ XmlMember toReturn = null;
+ for (Member member : ClusterRestApplication.getMembers()) {
+ String memberId = ClusterUtil.asId(member.getInetSocketAddress());
+ if (memberId.equals(id)) {
+ toReturn = ClusterUtil.fromMember(member);
+ break;
+ }
+ }
+ return toReturn;
+ }
+}
diff --git a/plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/MembersResource.java b/plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/MembersResource.java
new file mode 100644
index 0000000000..5af2415eed
--- /dev/null
+++ b/plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/MembersResource.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.cluster.rest.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.UriInfo;
+import org.eclipse.osee.cluster.Member;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@Path("members")
+public class MembersResource {
+
+ @Context
+ UriInfo uriInfo;
+ @Context
+ Request request;
+
+ @GET
+ @Produces(MediaType.TEXT_XML)
+ public List<XmlMember> getMemberBrowser() {
+ List<XmlMember> todos = new ArrayList<XmlMember>();
+ for (Member member : ClusterRestApplication.getMembers()) {
+ todos.add(ClusterUtil.fromMember(member));
+ }
+ return todos;
+ }
+
+ @GET
+ @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+ public List<XmlMember> getMembers() {
+ List<XmlMember> todos = new ArrayList<XmlMember>();
+ for (Member member : ClusterRestApplication.getMembers()) {
+ todos.add(ClusterUtil.fromMember(member));
+ }
+ return todos;
+ }
+
+ @GET
+ @Path("count")
+ @Produces(MediaType.TEXT_PLAIN)
+ public String getCount() {
+ int count = ClusterRestApplication.getMembers().size();
+ return String.valueOf(count);
+ }
+
+ @Path("{member}")
+ public MemberResource getTodo(@PathParam("member") String id) {
+ return new MemberResource(uriInfo, request, id);
+ }
+}
diff --git a/plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/XmlMember.java b/plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/XmlMember.java
new file mode 100644
index 0000000000..ad0e678b22
--- /dev/null
+++ b/plugins/org.eclipse.osee.cluster.rest/src/org/eclipse/osee/cluster/rest/internal/XmlMember.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.cluster.rest.internal;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "member", namespace = "members")
+public class XmlMember {
+
+ private String socketAddress;
+ private boolean hasData;
+ private boolean localMember;
+
+ public XmlMember() {
+ super();
+ }
+
+ public XmlMember(String socketAddress, boolean hasData, boolean localMember) {
+ super();
+ this.socketAddress = socketAddress;
+ this.hasData = hasData;
+ this.localMember = localMember;
+ }
+
+ public boolean isLocal() {
+ return localMember;
+ }
+
+ public String getSocketAddress() {
+ return socketAddress;
+ }
+
+ public boolean hasData() {
+ return hasData;
+ }
+
+ public void setSocketAddress(String socketAddress) {
+ this.socketAddress = socketAddress;
+ }
+
+ public void setHasData(boolean hasData) {
+ this.hasData = hasData;
+ }
+
+ public void setLocal(boolean local) {
+ this.localMember = local;
+ }
+
+}

Back to the top