summaryrefslogtreecommitdiffstats
path: root/sandbox
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java98
-rw-r--r--sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/DomainView.java56
-rw-r--r--sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Tuscany.java27
-rw-r--r--sandbox/slaws/domain-view/src/main/resources/META-INF/sca-contribution.xml2
-rw-r--r--sandbox/slaws/domain-view/src/main/resources/domain.composite2
-rw-r--r--sandbox/slaws/domain-view/src/test/resources/domain1/nodeClient/node.xml5
-rw-r--r--sandbox/slaws/domain-view/src/test/resources/domain1/nodeService/node.xml5
7 files changed, 123 insertions, 72 deletions
diff --git a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java
index a8625e91a2..754966b9a3 100644
--- a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java
+++ b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java
@@ -26,6 +26,7 @@ import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
+import java.util.List;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
@@ -35,8 +36,8 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
+import org.apache.tuscany.sca.impl.NodeImpl;
import org.oasisopen.sca.annotation.Service;
-import org.apache.tuscany.sca.node.impl.NodeImpl;
/**
* Some hand crafted HTTP code to help me think about what info is missing
@@ -45,16 +46,38 @@ import org.apache.tuscany.sca.node.impl.NodeImpl;
*/
@Service(Domain.class)
public class Domain implements Servlet {
+
public String getDomainComposite(){
- NodeImpl node = (NodeImpl)Tuscany.node;
- String domainComposite = node.dumpDomainComposite();
- return domainComposite;
+ NodeImpl node = (NodeImpl)DomainView.domainAccessPointNode;
+ return node.getDomainLevelCompositeAsString();
}
+ public String getContributions(){
+ NodeImpl node = (NodeImpl)DomainView.domainAccessPointNode;
+ List<String> contributions = node.getInstalledContributionURIs();
+ return contributions.toString();
+ }
+
+ public String getEndpoints(){
+ NodeImpl node = (NodeImpl)DomainView.domainAccessPointNode;
+ return node.getEndpointRegistry().getEndpoints().toString();
+ }
+
+ public String getNodes(String domainName){
+ // use the domain on the file system in lieu of info in the registry
+ File domainDir = new File("target/test-classes/" + domainName);
+ String nodes = "";
+
+ for (File subDir : domainDir.listFiles()){
+ if (subDir.isDirectory()){
+ nodes += subDir.getName() + "\n";
+ }
+ }
+ return nodes;
+ }
+
public String getComponent(){
- NodeImpl node = (NodeImpl)Tuscany.node;
- String domainComposite = node.dumpDomainComposite();
- return domainComposite;
+ return null;
}
public void init(ServletConfig config) throws ServletException {
@@ -75,48 +98,35 @@ public class Domain implements Servlet {
String[] pathElements = pathInfo.split("/");
String domainName = pathElements[0];
- String action = "none";
- if (pathElements.length == 2){
- action = pathElements[1];
- }
// Just some hand crafted code to help me visualize resources
os.print("<html><body>");
- if ( action.equals("composite")){
- String domainComposite = getDomainComposite();
- domainComposite = domainComposite.replaceAll("<", "&lt;");
- domainComposite = domainComposite.replaceAll(">", "&gt;");
- os.print("<html><body><p>" + domainComposite + "</body></html>");
- return;
- } else {
- try {
- File domainDir = new File("target/test-classes/" + domainName);
-
- URI domainDirURI = domainDir.toURI();
- URI domainResourceURI = domainDirURI.resolve(pathInfo);
-
- os.print("<p/>contributions");
-
- for (File subDir : domainDir.listFiles()){
- if (!subDir.isDirectory()){
- os.print("<p/><a href=\"" + subDir.toURI().toString() + "\">" + subDir.getName());
- }
- }
-
- os.print("<p/>nodes");
- os.print("<p/><a href=\"" + domainName + "/composite\">domainComposite</a>");
-
- os.print("</body></html>");
-
- return;
- } catch (Exception ex){
- ex.printStackTrace();
+ if (pathElements.length > 1){
+ String action = "none";
+ action = pathElements[1];
+
+ if ( action.equals("composite")){
+ os.print(prettyPrintXMLString(getDomainComposite()));
+ } else if ( action.equals("contribution")){
+ os.print(prettyPrintXMLString(getContributions()));
+ } else if ( action.equals("endpoint")){
+ os.print(prettyPrintXMLString(getEndpoints()));
+ } else if ( action.equals("node")){
+ os.print(prettyPrintXMLString(getNodes(domainName)));
+ } else {
+ os.print("URL path component " + action + "is invalid");
}
+
+ } else {
+ os.print("<p/><a href=\"" + domainName + "/contribution\">contributions</a>");
+ os.print("<p/><a href=\"" + domainName + "/composite\">domainComposite</a>");
+ os.print("<p/><a href=\"" + domainName + "/endpoint\">endpoints</a>");
+ os.print("<p/><a href=\"" + domainName + "/node\">nodes</a>");
}
- os.print("<html><body><p>no processing</body></html>");
+ os.print("</body></html>");
}
@@ -141,5 +151,11 @@ public class Domain implements Servlet {
os.write(aChar);
}
}
+
+ public String prettyPrintXMLString(String inXML){
+ return inXML.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
+
+ // etc. need to read and write a structured version
+ }
} \ No newline at end of file
diff --git a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/DomainView.java b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/DomainView.java
new file mode 100644
index 0000000000..882f10756e
--- /dev/null
+++ b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/DomainView.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.domain.interop;
+
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
+
+/**
+ * Main class for Tuscany. Just looking at what it means to read config from a directory structure.
+ *
+ */
+public class DomainView {
+
+ public static Node domainAccessPointNode = null;
+ private static Node domainViewNode = null;
+
+ public static void main(String[] args) throws Exception {
+ String domainName = args[0];
+
+ TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
+
+ // a node to access the specified domain
+ domainAccessPointNode = tuscanyRuntime.createNode("uri:" + domainName);
+
+ // a node to run the domain view app. Just starts in the local domain "domainview"
+ domainViewNode = tuscanyRuntime.createNode("domainview");
+ domainViewNode.installContribution("target/classes");
+
+ System.out.print("Press a key to stop");
+ try{
+ System.in.read();
+ } catch(Exception ex){
+ // do nothing
+ }
+
+ domainViewNode.stop();
+ }
+
+} \ No newline at end of file
diff --git a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Tuscany.java b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Tuscany.java
index bafd818355..aac7ce7aaa 100644
--- a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Tuscany.java
+++ b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Tuscany.java
@@ -26,9 +26,8 @@ import java.net.ServerSocket;
import java.net.Socket;
import java.net.URL;
-import org.apache.tuscany.sca.node.Contribution;
-import org.apache.tuscany.sca.node.Node;
-import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
/**
* Main class for Tuscany. Just looking at what it means to read config from a directory structure.
@@ -37,7 +36,6 @@ import org.apache.tuscany.sca.node.NodeFactory;
public class Tuscany {
public static Node node = null;
- private static Node domain = null;
public static void main(String[] args) throws Exception {
String domainName = args[0];
@@ -57,29 +55,13 @@ public class Tuscany {
File nodeDirectory = findDirectory(currentDirectory, nodeName);
System.out.println("Node: " + nodeDirectory.getPath());
- // start a node with the node configuration
-/* don't know how to start the node using the following
TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
- Node node = tuscanyRuntime.createNodeFromXML(nodeDirectory.getPath() +
- File.separator +
- "node.xml");
-*/
- NodeFactory nodeFactory = NodeFactory.newInstance();
-
- // temporarily use the Tuscany runtime to expose domain services
- // for looking at the domain in a RESTful way. Replace with more
- // integrated code!
- domain = nodeFactory.createNode(new Contribution("domain", "target/classes"));
- domain.start();
URL nodeConfigURL = nodeDirectory.toURI().resolve("node.xml").toURL();
- node = nodeFactory.createNode(nodeConfigURL);
-
+ node = tuscanyRuntime.createNodeFromXML(nodeConfigURL.toString());
try {
- node.start();
-
- // Use ? to provide web access to the domain details.
+ //node.start();
// for testing we're going to set up a deamon that listens for
// a shutdown message on a specified port (well it actually just
@@ -111,7 +93,6 @@ public class Tuscany {
} finally {
node.stop();
- domain.stop();
}
}
diff --git a/sandbox/slaws/domain-view/src/main/resources/META-INF/sca-contribution.xml b/sandbox/slaws/domain-view/src/main/resources/META-INF/sca-contribution.xml
index 370fe9903c..276a1cadcc 100644
--- a/sandbox/slaws/domain-view/src/main/resources/META-INF/sca-contribution.xml
+++ b/sandbox/slaws/domain-view/src/main/resources/META-INF/sca-contribution.xml
@@ -20,6 +20,6 @@
<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
xmlns:sample="http://sample">
- <deployable composite="sample:domain-composite" />
+ <deployable composite="sample:domainview" />
</contribution>
diff --git a/sandbox/slaws/domain-view/src/main/resources/domain.composite b/sandbox/slaws/domain-view/src/main/resources/domain.composite
index 316c1693ec..de236611f6 100644
--- a/sandbox/slaws/domain-view/src/main/resources/domain.composite
+++ b/sandbox/slaws/domain-view/src/main/resources/domain.composite
@@ -20,7 +20,7 @@
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
targetNamespace="http://sample"
- name="domain-composite">
+ name="domainview">
<component name="Domain">
<implementation.java class="org.apache.tuscany.sca.domain.interop.Domain"/>
diff --git a/sandbox/slaws/domain-view/src/test/resources/domain1/nodeClient/node.xml b/sandbox/slaws/domain-view/src/test/resources/domain1/nodeClient/node.xml
index 81f82a9590..f6756ad187 100644
--- a/sandbox/slaws/domain-view/src/test/resources/domain1/nodeClient/node.xml
+++ b/sandbox/slaws/domain-view/src/test/resources/domain1/nodeClient/node.xml
@@ -20,9 +20,8 @@
<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
xmlns="http://tuscany.apache.org/xmlns/sca/1.1"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
- uri="http://sample/nodes/node1"
- domain="default"
- domainRegistry="tuscany:default">
+ uri="http://sample/domain1/nodeClient"
+ domain="uri:domain1">
<!-- Configure the base URIs for a given binding -->
<!-- Each base URI is for a protocol supported by the binding -->
diff --git a/sandbox/slaws/domain-view/src/test/resources/domain1/nodeService/node.xml b/sandbox/slaws/domain-view/src/test/resources/domain1/nodeService/node.xml
index 2bb0bc7558..38274a1a62 100644
--- a/sandbox/slaws/domain-view/src/test/resources/domain1/nodeService/node.xml
+++ b/sandbox/slaws/domain-view/src/test/resources/domain1/nodeService/node.xml
@@ -20,9 +20,8 @@
<node xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
xmlns="http://tuscany.apache.org/xmlns/sca/1.1"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
- uri="http://sample/nodes/TestNode3"
- domain="default"
- domainRegistry="tuscany:default?listen=127.0.0.1:14820">
+ uri="http://sample/domain1/nodeService"
+ domain="uri:domain1">
<!-- Configure the base URIs for a given binding -->
<!-- Each base URI is for a protocol supported by the binding -->