Author: slaws Date: Wed May 11 15:50:08 2011 New Revision: 1101928 URL: http://svn.apache.org/viewvc?rev=1101928&view=rev Log: Changes to exercise some of the new functions Ant is adding to the registry Added: tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/DomainView.java Modified: tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Tuscany.java tuscany/sandbox/slaws/domain-view/src/main/resources/META-INF/sca-contribution.xml tuscany/sandbox/slaws/domain-view/src/main/resources/domain.composite tuscany/sandbox/slaws/domain-view/src/test/resources/domain1/nodeClient/node.xml tuscany/sandbox/slaws/domain-view/src/test/resources/domain1/nodeService/node.xml Modified: tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java URL: http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java?rev=1101928&r1=1101927&r2=1101928&view=diff ============================================================================== --- tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java (original) +++ tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java Wed May 11 15:50:08 2011 @@ -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. */ @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 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(""); - if ( action.equals("composite")){ - String domainComposite = getDomainComposite(); - domainComposite = domainComposite.replaceAll("<", "<"); - domainComposite = domainComposite.replaceAll(">", ">"); - os.print("

" + domainComposite + ""); - return; - } else { - try { - File domainDir = new File("target/test-classes/" + domainName); - - URI domainDirURI = domainDir.toURI(); - URI domainResourceURI = domainDirURI.resolve(pathInfo); - - os.print("

contributions"); - - for (File subDir : domainDir.listFiles()){ - if (!subDir.isDirectory()){ - os.print("

" + subDir.getName()); - } - } - - os.print("

nodes"); - os.print("

domainComposite"); - - os.print(""); - - 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("

contributions"); + os.print("

domainComposite"); + os.print("

endpoints"); + os.print("

nodes"); } - os.print("

no processing"); + os.print(""); } @@ -141,5 +151,11 @@ public class Domain implements Servlet { os.write(aChar); } } + + public String prettyPrintXMLString(String inXML){ + return inXML.replaceAll("<", "<").replaceAll(">", ">"); + + // etc. need to read and write a structured version + } } \ No newline at end of file Added: tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/DomainView.java URL: http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/DomainView.java?rev=1101928&view=auto ============================================================================== --- tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/DomainView.java (added) +++ tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/DomainView.java Wed May 11 15:50:08 2011 @@ -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 Modified: tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Tuscany.java URL: http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Tuscany.java?rev=1101928&r1=1101927&r2=1101928&view=diff ============================================================================== --- tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Tuscany.java (original) +++ tuscany/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Tuscany.java Wed May 11 15:50:08 2011 @@ -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.NodeF 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(); } } Modified: tuscany/sandbox/slaws/domain-view/src/main/resources/META-INF/sca-contribution.xml URL: http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/resources/META-INF/sca-contribution.xml?rev=1101928&r1=1101927&r2=1101928&view=diff ============================================================================== --- tuscany/sandbox/slaws/domain-view/src/main/resources/META-INF/sca-contribution.xml (original) +++ tuscany/sandbox/slaws/domain-view/src/main/resources/META-INF/sca-contribution.xml Wed May 11 15:50:08 2011 @@ -20,6 +20,6 @@ - + Modified: tuscany/sandbox/slaws/domain-view/src/main/resources/domain.composite URL: http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/main/resources/domain.composite?rev=1101928&r1=1101927&r2=1101928&view=diff ============================================================================== --- tuscany/sandbox/slaws/domain-view/src/main/resources/domain.composite (original) +++ tuscany/sandbox/slaws/domain-view/src/main/resources/domain.composite Wed May 11 15:50:08 2011 @@ -20,7 +20,7 @@ + name="domainview"> Modified: tuscany/sandbox/slaws/domain-view/src/test/resources/domain1/nodeClient/node.xml URL: http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/test/resources/domain1/nodeClient/node.xml?rev=1101928&r1=1101927&r2=1101928&view=diff ============================================================================== --- tuscany/sandbox/slaws/domain-view/src/test/resources/domain1/nodeClient/node.xml (original) +++ tuscany/sandbox/slaws/domain-view/src/test/resources/domain1/nodeClient/node.xml Wed May 11 15:50:08 2011 @@ -20,9 +20,8 @@ + uri="http://sample/domain1/nodeClient" + domain="uri:domain1"> Modified: tuscany/sandbox/slaws/domain-view/src/test/resources/domain1/nodeService/node.xml URL: http://svn.apache.org/viewvc/tuscany/sandbox/slaws/domain-view/src/test/resources/domain1/nodeService/node.xml?rev=1101928&r1=1101927&r2=1101928&view=diff ============================================================================== --- tuscany/sandbox/slaws/domain-view/src/test/resources/domain1/nodeService/node.xml (original) +++ tuscany/sandbox/slaws/domain-view/src/test/resources/domain1/nodeService/node.xml Wed May 11 15:50:08 2011 @@ -20,9 +20,8 @@ + uri="http://sample/domain1/nodeService" + domain="uri:domain1">