You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by lr...@apache.org on 2011/03/29 20:26:08 UTC

svn commit: r1086674 [1/3] - in /tuscany/sca-java-2.x/trunk/modules: ./ node-manager/ node-manager/src/ node-manager/src/main/ node-manager/src/main/java/ node-manager/src/main/java/org/ node-manager/src/main/java/org/apache/ node-manager/src/main/java...

Author: lresende
Date: Tue Mar 29 18:26:07 2011
New Revision: 1086674

URL: http://svn.apache.org/viewvc?rev=1086674&view=rev
Log:
Simple strawman to provide some management rest services for nodes.

Added:
    tuscany/sca-java-2.x/trunk/modules/node-manager/
    tuscany/sca-java-2.x/trunk/modules/node-manager/pom.xml   (with props)
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java   (with props)
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainCompositeResourceImpl.java   (with props)
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/resources/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/resources/META-INF/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/resources/META-INF/services/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.extensibility.NodeActivator
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/org/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/org/apache/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/org/apache/tuscany/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/org/apache/tuscany/sca/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/org/apache/tuscany/sca/node/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/org/apache/tuscany/sca/node/manager/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/org/apache/tuscany/sca/node/manager/DomainCompositeResourceTestCase.java   (with props)
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/node-manager-test.composite   (with props)
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/atomutil.js   (with props)
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/component.js   (with props)
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/elemutil.js   (with props)
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/graph.js   (with props)
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/index.html   (with props)
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/jsonutil.js   (with props)
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/scdl.js   (with props)
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/ui.css   (with props)
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/ui.js   (with props)
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/uiblue.css   (with props)
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/uicyan.css   (with props)
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/util.js   (with props)
    tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/xmlutil.js   (with props)
Modified:
    tuscany/sca-java-2.x/trunk/modules/pom.xml

Added: tuscany/sca-java-2.x/trunk/modules/node-manager/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/pom.xml?rev=1086674&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/pom.xml (added)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/pom.xml Tue Mar 29 18:26:07 2011
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<project>
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-modules</artifactId>
+        <version>2.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>tuscany-node-manager</artifactId>
+    <name>Apache Tuscany SCA Node Manager</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-assembly</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+
+         <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-contribution</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-node-api</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-core</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-assembly-xml</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-deployment</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-builder</artifactId>
+            <version>2.0-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-binding-sca-runtime</artifactId>
+            <version>2.0-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-core-databinding</artifactId>
+            <version>2.0-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-assembly-xsd</artifactId>
+            <version>2.0-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+       <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-common-http</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-http</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+
+       <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-java-runtime</artifactId>
+            <version>2.0-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+       <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-widget-runtime-dojo</artifactId>
+            <version>2.0-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+       <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-binding-rest-runtime</artifactId>
+            <version>2.0-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+
+        <dependency>
+	        <groupId>httpunit</groupId>
+	        <artifactId>httpunit</artifactId>
+	        <version>1.7</version>
+	        <scope>test</scope>
+	        <exclusions>
+	        	<exclusion>
+		            <groupId>javax.servlet</groupId>
+		            <artifactId>servlet-api</artifactId>
+	        	</exclusion>
+	        </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.8.1</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java?rev=1086674&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java (added)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java Tue Mar 29 18:26:07 2011
@@ -0,0 +1,38 @@
+/*
+ * 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.node.manager;
+
+import javax.ws.rs.DefaultValue;
+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.MediaType;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface DomainCompositeResource {
+
+    @GET
+    @Path("{domainURI}")
+    //@Produces(MediaType.TEXT_PLAIN)
+    String getDomainComposite(@PathParam("domainURI") @DefaultValue("default") String domainURI);
+}

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainCompositeResourceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainCompositeResourceImpl.java?rev=1086674&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainCompositeResourceImpl.java (added)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainCompositeResourceImpl.java Tue Mar 29 18:26:07 2011
@@ -0,0 +1,109 @@
+/*
+ * 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.node.manager.impl;
+
+import java.io.ByteArrayOutputStream;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.ws.rs.WebApplicationException;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.extensibility.NodeActivator;
+import org.apache.tuscany.sca.node.extensibility.NodeExtension;
+import org.apache.tuscany.sca.node.manager.DomainCompositeResource;
+
+public class DomainCompositeResourceImpl implements NodeActivator, DomainCompositeResource {
+    private static Map<String, NodeExtension> nodeMap = new ConcurrentHashMap<String,NodeExtension>();
+
+    public void nodeStarted(Node node) {
+        NodeExtension nodeExtension = (NodeExtension) node;
+        nodeMap.put(nodeExtension.getDomainURI(), nodeExtension);
+    }
+
+    public void nodeStopped(Node node) {
+        NodeExtension nodeExtension = (NodeExtension) node;
+        nodeMap.remove(nodeExtension.getDomainURI());
+    }
+
+    public String getDomainComposite(String domainURI) {
+        System.out.println(">>> getDomainComposite");
+
+        if( ! nodeMap.containsKey(domainURI)) {
+            throw new WebApplicationException(404);
+        }
+
+        NodeExtension node = nodeMap.get(domainURI);
+        Composite composite = node.getDomainComposite();
+
+        //set name, as it's empty by default
+        composite.setName(new QName("", "Domain"));
+
+        ExtensionPointRegistry registry = node.getExtensionPointRegistry();
+        StAXArtifactProcessorExtensionPoint xmlProcessors =
+            registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+        StAXArtifactProcessor<Composite>  compositeProcessor =
+            xmlProcessors.getProcessor(Composite.class);
+
+        return writeComposite(composite, registry, compositeProcessor);
+
+        //String compositeAsString = writeComposite(composite, registry, compositeProcessor);
+        //return "something";
+
+        //return Response.ok(compositeText, MediaType.APPLICATION_XML).build();
+
+        //return Response.ok().type(MediaType.APPLICATION_XML).entity(compositeAsString).build();
+    }
+
+
+    private String writeComposite(Composite composite, ExtensionPointRegistry registry, StAXArtifactProcessor<Composite> compositeProcessor){
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        XMLOutputFactory outputFactory =
+            registry.getExtensionPoint(FactoryExtensionPoint.class)
+                .getFactory(XMLOutputFactory.class);
+
+        try {
+            compositeProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), new ProcessorContext(registry));
+        } catch(Exception ex) {
+            return ex.toString();
+        }
+
+        String result = bos.toString();
+
+        // write out and nested composites
+        for (Component component : composite.getComponents()) {
+            if (component.getImplementation() instanceof Composite) {
+                result += "\n<!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -->\n" +
+                           writeComposite((Composite)component.getImplementation(), registry,
+                                          compositeProcessor);
+            }
+        }
+        return result;
+    }
+}

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainCompositeResourceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainCompositeResourceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.extensibility.NodeActivator
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.extensibility.NodeActivator?rev=1086674&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.extensibility.NodeActivator (added)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.extensibility.NodeActivator Tue Mar 29 18:26:07 2011
@@ -0,0 +1,18 @@
+# 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.
+# Implementation class for the ModuleActivator
+org.apache.tuscany.sca.node.manager.impl.DomainCompositeResourceImpl;ranking=100

Added: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/org/apache/tuscany/sca/node/manager/DomainCompositeResourceTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/org/apache/tuscany/sca/node/manager/DomainCompositeResourceTestCase.java?rev=1086674&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/org/apache/tuscany/sca/node/manager/DomainCompositeResourceTestCase.java (added)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/org/apache/tuscany/sca/node/manager/DomainCompositeResourceTestCase.java Tue Mar 29 18:26:07 2011
@@ -0,0 +1,78 @@
+/*
+ * 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.node.manager;
+
+import java.net.Socket;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+public class DomainCompositeResourceTestCase {
+    private static final String SERVICE_URL = "http://localhost:8080/domain";
+
+    private static Node node;
+
+    @BeforeClass
+    public static void init() throws Exception {
+        try {
+            String contribution = ContributionLocationHelper.getContributionLocation(DomainCompositeResourceTestCase.class);
+            node = NodeFactory.newInstance().createNode("node-manager-test.composite", new Contribution("node-manager", contribution));
+            node.start();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    @AfterClass
+    public static void destroy() throws Exception {
+        if (node != null) {
+            node.stop();
+        }
+    }
+
+    @Test
+    public void testPing() throws Exception {
+        new Socket("127.0.0.1", 8080);
+        System.in.read();
+    }
+
+    @Test
+    public void testDefaultDomainCompositeResource() throws Exception {
+        String url = SERVICE_URL + "/default";
+        WebConversation wc = new WebConversation();
+        WebRequest request = new GetMethodWebRequest(url);
+        WebResponse response = wc.getResource(request);
+
+        Assert.assertEquals(200, response.getResponseCode());
+        System.out.println(">>>" + response.getText());
+    }
+
+}

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/org/apache/tuscany/sca/node/manager/DomainCompositeResourceTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/java/org/apache/tuscany/sca/node/manager/DomainCompositeResourceTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/node-manager-test.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/node-manager-test.composite?rev=1086674&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/node-manager-test.composite (added)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/node-manager-test.composite Tue Mar 29 18:26:07 2011
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite	xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+		xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+		targetNamespace="http://node-manager"
+		name="NodeManager">
+
+	<component name="NodeManagerUI">
+		<tuscany:implementation.widget location="ui/index.html" />
+		<service name="Widget">
+			<tuscany:binding.rest uri="/manager/ui" />
+		</service>
+	</component>
+
+	<component name="NodeManagerComponent">
+		<implementation.java class="org.apache.tuscany.sca.node.manager.impl.DomainCompositeResourceImpl"/>
+		<service name="DomainCompositeResource">
+			<tuscany:binding.rest uri="/domain">
+			    <tuscany:operationSelector.jaxrs />
+    		</tuscany:binding.rest>
+   		</service>
+	</component>
+</composite>

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/node-manager-test.composite
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/node-manager-test.composite
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/node-manager-test.composite
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/atomutil.js
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/atomutil.js?rev=1086674&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/atomutil.js (added)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/atomutil.js Tue Mar 29 18:26:07 2011
@@ -0,0 +1,165 @@
+/*
+ * 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.    
+ */
+
+/**
+ * ATOM data conversion functions.
+ */
+var atom = {};
+
+/**
+ * Convert a list of elements to a list of values representing an ATOM entry.
+ */
+atom.entryElementValues = function(e) {
+    var lt = filter(selector(mklist(element, "'title")), e);
+    var t = isNil(lt)? '' : elementValue(car(lt));
+    var li = filter(selector(mklist(element, "'id")), e);
+    var i = isNil(li)? '' : elementValue(car(li));
+    var lc = filter(selector(mklist(element, "'content")), e);
+    return append(mklist(element, "'entry", mklist(element, "'title", t), mklist(element, "'id", i)),
+            isNil(lc)? mklist() : mklist(mklist(element, "'content", elementValue(car(lc)))))
+};
+
+/**
+ * Convert a list of elements to a list of values representing ATOM entries.
+ */
+atom.entriesElementValues = function(e) {
+    if (isNil(e))
+        return e;
+    return cons(atom.entryElementValues(car(e)), atom.entriesElementValues(cdr(e)));
+};
+
+/**
+ * Return true if a list of strings represents an ATOM entry.
+ */
+atom.isATOMEntry = function(l) {
+    if (!isXML(l))
+        return false;
+    return car(l).match('<entry') != null && car(l).match('<feed') == null && car(l).match('="http://www.w3.org/2005/Atom"') != null;
+};
+
+/**
+ * Convert a DOM Document to a list of values representing an ATOM entry.
+ */
+atom.readATOMEntryDocument = function(doc) {
+    var e = readXMLDocument(doc);
+    if (isNil(e))
+        return mklist();
+    return mklist(atom.entryElementValues(car(e)));
+};
+
+/**
+ * Convert a list of strings to a list of values representing an ATOM entry.
+ */
+atom.readATOMEntry = function(l) {
+    return atom.readATOMEntryDocument(parseXML(l));
+};
+
+/**
+ * Return true if a list of strings represents an ATOM feed.
+ */
+atom.isATOMFeed = function(l) {
+    if (!isXML(l))
+        return false;
+    return car(l).match('<feed') != null && car(l).match('="http://www.w3.org/2005/Atom"') != null;
+};
+
+/**
+ * Convert a DOM document to a list of values representing an ATOM feed.
+ */
+atom.readATOMFeedDocument = function(doc) {
+    var f = readXMLDocument(doc);
+    if (isNil(f))
+        return mklist();
+    var t = filter(selector(mklist(element, "'title")), car(f));
+    var i = filter(selector(mklist(element, "'id")), car(f));
+    var e = filter(selector(mklist(element, "'entry")), car(f));
+    return mklist(append(
+                mklist(element, "'feed", mklist(element, "'title", elementValue(car(t))), mklist(element, "'id", elementValue(car(i)))),
+                atom.entriesElementValues(e)));
+};
+
+/**
+ * Convert a list of strings to a list of values representing an ATOM feed.
+ */
+atom.readATOMFeed = function(l) {
+    return atom.readATOMFeedDocument(parseXML(l));
+};
+
+/**
+ * Convert a list of values representy an ATOM entry to a list of elements.
+ */
+atom.entryElement = function(l) {
+    var title = elementValue(namedElementChild("'title", l));
+    var id = elementValue(namedElementChild("'id", l));
+    var content = namedElementChild("'content", l);
+    var text = isNil(content)? false : elementHasValue(content);
+    return append(append(
+            mklist(element, "'entry", mklist(attribute, "'xmlns", "http://www.w3.org/2005/Atom"),
+            mklist(element, "'title", mklist(attribute, "'type", "text"), title), mklist(element, "'id", id)),
+            isNil(content)? mklist() :
+                append(mklist(element, "'content", mklist(attribute, "'type", text? "text" : "application/xml")), text? mklist(elementValue(content)) : elementChildren(content))),
+            mklist(element, "'link", mklist(attribute, "'href", id)));
+};
+
+/**
+ * Convert a list of values representing ATOM entries to a list of elements.
+ */
+atom.entriesElements = function(l) {
+    if (isNil(l))
+        return l;
+    return cons(atom.entryElement(car(l)), atom.entriesElements(cdr(l)));
+};
+
+/**
+ * Convert a list of values representing an ATOM entry to an ATOM entry.
+ */
+atom.writeATOMEntry = function(ll) {
+    var l = isNil(ll)? ll : car(ll);
+    return writeXML(mklist(atom.entryElement(l)), true);
+};
+
+/**
+ * Convert a list of values representing an ATOM feed to an ATOM feed.
+ */
+atom.writeATOMFeed = function(ll) {
+    var l = isNil(ll)? ll : car(ll);
+    var lt = filter(selector(mklist(element, "'title")), l);
+    var t = isNil(lt)? '' : elementValue(car(lt));
+    var li = filter(selector(mklist(element, "'id")), l);
+    var i = isNil(li)? '' : elementValue(car(li));
+    var f = mklist(element, "'feed", mklist(attribute, "'xmlns", "http://www.w3.org/2005/Atom"),
+            mklist(element, "'title", mklist(attribute, "'type", "text"), car(l)),
+            mklist(element, "'id", cadr(l)));
+
+    // Write ATOM entries
+    var le = filter(selector(mklist(element, "'entry")), l);
+    if (isNil(le))
+        return writeXML(mklist(f), true);
+
+    // Write a single ATOM entry element with a list of values
+    if (!isNil(le) && !isNil(car(le)) && isList(car(caddr(car(le))))) {
+        var fe = append(f, atom.entriesElements(caddr(car(le))));
+        return writeXML(mklist(fe), true);
+    }
+
+    // Write separate ATOM entry elements
+    var fe = append(f, atom.entriesElements(le));
+    return writeXML(mklist(fe), true);
+};
+

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/atomutil.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/component.js
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/component.js?rev=1086674&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/component.js (added)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/component.js Tue Mar 29 18:26:07 2011
@@ -0,0 +1,443 @@
+/*
+ * 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.    
+ *
+ * The JSON-RPC client code is based on Jan-Klaas' JavaScript
+ * o lait library (jsolait).
+ *
+ * $Id: jsonrpc.js,v 1.36.2.3 2006/03/08 15:09:37 mclark Exp $
+ *
+ * Copyright (c) 2003-2004 Jan-Klaas Kollhof
+ * Copyright (c) 2005 Michael Clark, Metaparadigm Pte Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ */
+
+/**
+ * Client component wiring API, supporting JSON and ATOM bindings.
+ */
+
+var JSONClient = {};
+
+/**
+ * Escape a character.
+ */
+JSONClient.escapeJSONChar = function(c) {
+    if(c == "\"" || c == "\\") return "\\" + c;
+    if (c == "\b") return "\\b";
+    if (c == "\f") return "\\f";
+    if (c == "\n") return "\\n";
+    if (c == "\r") return "\\r";
+    if (c == "\t") return "\\t";
+    var hex = c.charCodeAt(0).toString(16);
+    if(hex.length == 1) return "\\u000" + hex;
+    if(hex.length == 2) return "\\u00" + hex;
+    if(hex.length == 3) return "\\u0" + hex;
+    return "\\u" + hex;
+};
+
+/**
+ * Encode a string into JSON format.
+ */
+JSONClient.escapeJSONString = function(s) {
+    // The following should suffice but Safari's regex is broken (doesn't support callback substitutions)
+    // return "\"" + s.replace(/([^\u0020-\u007f]|[\\\"])/g, JSONClient.escapeJSONChar) + "\"";
+
+    // Rather inefficient way to do it
+    var parts = s.split("");
+    for(var i = 0; i < parts.length; i++) {
+        var c = parts[i];
+        if(c == '"' || c == '\\' || c.charCodeAt(0) < 32 || c.charCodeAt(0) >= 128)
+            parts[i] = JSONClient.escapeJSONChar(parts[i]);
+    }
+    return "\"" + parts.join("") + "\"";
+};
+
+/**
+ * Marshall objects to JSON format.
+ */
+JSONClient.toJSON = function(o) {
+    if(o == null)
+        return "null";
+    if(o.constructor == String)
+        return JSONClient.escapeJSONString(o);
+    if(o.constructor == Number)
+        return o.toString();
+    if(o.constructor == Boolean)
+        return o.toString();
+    if(o.constructor == Date)
+        return '{javaClass: "java.util.Date", time: ' + o.valueOf() +'}';
+    if(o.constructor == Array) {
+        var v = [];
+        for(var i = 0; i < o.length; i++)
+            v.push(JSONClient.toJSON(o[i]));
+        return "[" + v.join(", ") + "]";
+    }
+    var v = [];
+    for(attr in o) {
+        if(o[attr] == null)
+            v.push("\"" + attr + "\": null");
+        else if(typeof o[attr] == "function")
+            ; // Skip
+        else
+            v.push(JSONClient.escapeJSONString(attr) + ": " + JSONClient.toJSON(o[attr]));
+    }
+    return "{" + v.join(", ") + "}";
+};
+
+/**
+ * Construct an HTTPBindingClient.
+ */
+function HTTPBindingClient(name, uri) {
+    this.name = name;
+    this.uri = uri;
+    this.apply = this.createApplyMethod();
+}
+
+/**
+ * JSON-RPC request counter.
+ */
+HTTPBindingClient.jsonrpcID = 1;
+
+/**
+ * HTTPBindingClient implementation
+ */
+
+/**
+ * Generate client proxy apply method.
+ */
+HTTPBindingClient.prototype.createApplyMethod = function() {
+    var fn = function() {
+        var methodName = arguments[0];
+        var args = [];
+        for(var i = 1; i < arguments.length; i++)
+            args.push(arguments[i]);
+
+        var cb = null;
+        if (typeof args[args.length - 1] == "function")
+            cb = args.pop();
+
+        var req = HTTPBindingClient.makeJSONRequest(methodName, args, cb);
+        return fn.client.jsonApply(req);
+    };
+    fn.client = this;
+    return fn;
+};
+
+/**
+ * Make a JSON-RPC request.
+ */
+HTTPBindingClient.makeJSONRequest = function(methodName, args, cb) {
+    var req = {};
+    req.id = HTTPBindingClient.jsonrpcID++;
+    if (cb)
+        req.cb = cb;
+    var obj = {};
+    obj.id = req.id;
+    obj.method = methodName;
+    obj.params = args;
+    req.data = JSONClient.toJSON(obj);
+    return req;
+};
+
+/**
+ * Return the JSON result from an XMLHttpRequest.
+ */
+HTTPBindingClient.jsonResult = function(http) {
+    // Get the charset
+    function httpCharset(http) {
+        try {
+            var contentType = http.getResponseHeader("Content-type");
+            var parts = contentType.split(/\s*;\s*/);
+            for (var i = 0; i < parts.length; i++) {
+                if (parts[i].substring(0, 8) == "charset=")
+                    return parts[i].substring(8, parts[i].length);
+            }
+        } catch (e) {}
+        return "UTF-8";
+    }
+    if(!HTTPBindingClient.charset)
+        HTTPBindingClient.charset = httpCharset(http);
+
+    // Unmarshall the JSON response
+    var obj;
+    eval("obj = " + http.responseText);
+    if(obj.error)
+        throw new HTTPBindingClient.Exception(obj.error.code, obj.error.msg);
+    var res = obj.result;
+    return res;
+};
+
+/**
+ * Apply a function remotely using JSON-RPC.
+ */
+HTTPBindingClient.prototype.jsonApply = function(req) {
+    // Connect to the service
+    var http = HTTPBindingClient.getHTTPRequest();
+    var hascb = req.cb? true : false;
+    http.open("POST", this.uri, hascb);
+    http.setRequestHeader("Content-type", "application/json-rpc");
+
+    // Construct call back if we have one
+    if(hascb) {
+        http.onreadystatechange = function() {
+            if(http.readyState == 4) {
+                // Pass the result or exception
+                if(http.status == 200) {
+                    var res = null;
+                    try {
+                        res = HTTPBindingClient.jsonResult(http);
+                    } catch(e) {
+                        req.cb(null, e);
+                    }
+                    req.cb(res);
+                } else
+                    req.cb(null, HTTPBindingClient.Exception(http.status, http.statusText));
+            }
+        };
+
+        // Send the request
+        http.send(req.data);
+        return req.id;
+    }
+
+    // Send the request and return the result or exception
+    http.send(req.data);
+    if (http.status == 200)
+        return HTTPBindingClient.jsonResult(http);
+    throw new HTTPBindingClient.Exception(http.status, http.statusText);
+};
+
+/**
+ * REST ATOMPub GET method.
+ */
+HTTPBindingClient.prototype.get = function(id, cb) {
+    // Connect to the service
+    var http = HTTPBindingClient.getHTTPRequest();
+    var hascb = cb? true : false;
+    http.open("GET", this.uri + '/' + id, hascb);
+
+    // Construct call back if we have one
+    if (hascb) {
+        http.onreadystatechange = function() {
+            if (http.readyState == 4) {
+                // Pass the result or exception
+                if (http.status == 200)
+                    cb(http.responseText);
+                else
+                    cb(null, new HTTPBindingClient.Exception(http.status, http.statusText));
+            }
+        };
+
+        // Send the request
+        http.send(null);
+        return true;
+    }
+
+    // Send the request and return the result or exception
+    http.send(null);
+    if (http.status == 200)
+        return http.responseText;
+    throw new HTTPBindingClient.Exception(http.status, http.statusText);
+};
+
+/**
+ * REST ATOMPub POST method.
+ */
+HTTPBindingClient.prototype.post = function (entry, cb) {
+    // Connect to the service
+    var http = HTTPBindingClient.getHTTPRequest();
+    var hascb = cb? true : false;
+    http.open("POST", this.uri, hascb);
+    http.setRequestHeader("Content-Type", "application/atom+xml");
+
+    // Construct call back if we have one
+    if (hascb) {
+        http.onreadystatechange = function() {
+            // Pass the result or exception
+            if (http.readyState == 4) {
+                if (http.status == 201)
+                    cb(http.responseText);
+                else
+                    cb(null, new HTTPBindingClient.Exception(http.status, http.statusText));
+            }
+        };
+        // Send the request
+        http.send(entry);
+        return true;
+    }
+
+    // Send the request and return the result or exception
+    http.send(entry);
+    if (http.status == 201)
+        return http.responseText;
+    throw new HTTPBindingClient.Exception(http.status, http.statusText);
+};
+
+/**
+ * REST ATOMPub PUT method.
+ */
+HTTPBindingClient.prototype.put = function (id, entry, cb) {
+    // Connect to the service
+    var http = HTTPBindingClient.getHTTPRequest();
+    var hascb = cb? true : false;
+    http.open("PUT", this.uri + '/' + id, hascb);
+    http.setRequestHeader("Content-Type", "application/atom+xml");
+
+    // Construct call back if we have one
+    if (hascb) {
+        http.onreadystatechange = function() {
+            if (http.readyState == 4) {
+                // Pass any exception
+                if (http.status == 200)
+                    cb();
+                else
+                    cb(new HTTPBindingClient.Exception(http.status, http.statusText));
+            }
+        };
+        // Send the request
+        http.send(entry);
+        return true;
+    }
+
+    // Send the request and return any exception
+    http.send(entry);
+    if (http.status == 200)
+        return true;
+    throw new HTTPBindingClient.Exception(http.status, http.statusText);
+};
+
+/**
+ * REST ATOMPub DELETE method.
+ */
+HTTPBindingClient.prototype.del = function (id, cb) {       
+    // Connect to the service
+    var http = HTTPBindingClient.getHTTPRequest();
+    var hascb = cb? true : false;
+    http.open("DELETE", this.uri + '/' + id, hascb);        
+
+    // Construct call back if we have one
+    if (cb) {
+        http.onreadystatechange = function() {
+            if (http.readyState == 4) {
+                // Pass any exception
+                if (http.status == 200)
+                    cb();
+                else
+                    cb(new HTTPBindingClient.Exception(http.status, http.statusText));
+            }
+        };
+        // Send the request
+        http.send(null);
+        return true;
+    }
+
+    // Send the request and return any exception
+    http.send(null);
+    if (http.status == 200)
+        return true;
+    throw new HTTPBindingClient.Exception(http.status, http.statusText);
+};
+
+/**
+ * HTTPBindingClient exceptions.
+ */
+HTTPBindingClient.Exception = function(code, message) {
+    this.name = "HTTPBindingClientException";
+    this.code = code;
+    this.message = message;
+};
+
+HTTPBindingClient.Exception.prototype = new Error();
+
+HTTPBindingClient.Exception.prototype.toString = function() {
+    return this.name + ": " + this.message;
+};
+
+/**
+ * XMLHttpRequest wrapper.
+ */
+HTTPBindingClient.msxmlNames = [ "MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP" ];
+
+HTTPBindingClient.getHTTPRequest = function() {
+    if (HTTPBindingClient.httpFactory)
+        return HTTPBindingClient.httpFactory();
+
+    // Mozilla XMLHttpRequest
+    try {
+        HTTPBindingClient.httpFactory = function() {
+            return new XMLHttpRequest();
+        };
+        return HTTPBindingClient.httpFactory();
+    } catch(e) {}
+
+    // Microsoft MSXML ActiveX
+    for (var i = 0; i < HTTPBindingClient.msxmlNames.length; i++) {
+        try {
+            HTTPBindingClient.httpFactory = function() {
+                return new ActiveXObject(HTTPBindingClient.msxmlNames[i]);
+            };
+            return HTTPBindingClient.httpFactory();
+        } catch (e) {}
+    }
+
+    // Can't create XMLHttpRequest
+    HTTPBindingClient.httpFactory = null;
+    throw new HTTPBindingClient.Exception(0, "Can't create XMLHttpRequest object");
+};
+
+/**
+ * Public API.
+ */
+
+var sca = {};
+
+/**
+ * Return a component proxy.
+ */
+sca.component = function(name) {
+    return new HTTPBindingClient(name, '/components/' + name);
+};
+
+/**
+ * Return a reference proxy.
+ */
+sca.reference = function(comp, rname) {
+    return new HTTPBindingClient(comp.name + '/' + rname, "/references/" + comp.name + "/" + rname);
+};
+
+/**
+ * Add proxy functions to a reference proxy.
+ */
+sca.defun = function(ref) {
+    function defapply(name) {
+        return function() {
+            var args = new Array();
+            args[0] = name;
+            for (i = 0, n = arguments.length; i < n; i++)
+                args[i + 1] = arguments[i];
+            return this.apply.apply(this, args);
+        };
+    }
+
+    for (f = 1; f < arguments.length; f++) {
+        var fn = arguments[f];
+        ref[fn]= defapply(fn);
+    }
+    return ref;
+};
+

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/component.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/elemutil.js
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/elemutil.js?rev=1086674&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/elemutil.js (added)
+++ tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/elemutil.js Tue Mar 29 18:26:07 2011
@@ -0,0 +1,257 @@
+/*
+ * 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.    
+ */
+
+/**
+ * Functions to help represent data as lists of elements and attributes.
+ */
+
+var element = "'element"
+var attribute = "'attribute"
+var atsign = "'@"
+
+/**
+ * Return true if a value is an element.
+ */
+function isElement(v) {
+    if (!isList(v) || isNil(v) || car(v) != element)
+        return false;
+    return true;
+}
+
+/**
+ * Return true if a value is an attribute.
+ */
+function isAttribute(v) {
+    if (!isList(v) || isNil(v) || car(v) != attribute)
+        return false;
+    return true;
+}
+
+/**
+ * Return the name of an attribute.
+ */
+function attributeName(l) {
+    return cadr(l);
+}
+
+/**
+ * Return the value of an attribute.
+ */
+function attributeValue(l) {
+    return caddr(l);
+}
+
+/**
+ * Return the name of an element.
+ */
+function elementName(l) {
+    return cadr(l);
+}
+
+/**
+ * Return true if an element has children.
+ */
+function elementHasChildren(l) {
+    return !isNil(cddr(l));
+}
+
+/**
+ * Return the children of an element.
+ */
+function elementChildren(l) {
+    return cddr(l);
+}
+
+
+/**
+ * Return true if an element has a value.
+ */
+function elementHasValue(l) {
+    r = reverse(l);
+    if (isSymbol(car(r)))
+        return false;
+    if (isList(car(r)) && !isNil(car(r)) && isSymbol(car(car(r))))
+        return false;
+    return true;
+}
+
+/**
+ * Return the value of an element.
+ */
+function elementValue(l) {
+    return car(reverse(l));
+}
+
+/**
+ * Convert an element to a value.
+ */
+function elementToValueIsList(v) {
+    if (!isList(v))
+        return false;
+    return isNil(v) || !isSymbol(car(v));
+}
+
+function elementToValue(t) {
+    if (isTaggedList(t, attribute))
+        return mklist(atsign + attributeName(t).substring(1), attributeValue(t));
+    if (isTaggedList(t, element)) {
+        if (elementHasValue(t)) {
+            if (!elementToValueIsList(elementValue(t)))
+                return mklist(elementName(t), elementValue(t));
+            return cons(elementName(t), mklist(elementsToValues(elementValue(t))));
+        }
+        return cons(elementName(t), elementsToValues(elementChildren(t)));
+    }
+    if (!isList(t))
+        return t;
+    return elementsToValues(t);
+}
+
+/**
+ * Convert a list of elements to a list of values.
+ */
+function elementToValueIsSymbol(v) {
+    if (!isList(v))
+        return false;
+    if (isNil(v))
+        return false;
+    if (!isSymbol(car(v)))
+        return false;
+    return true;
+}
+
+function elementToValueGroupValues(v, l) {
+    if (isNil(l) || !elementToValueIsSymbol(v) || !elementToValueIsSymbol(car(l)))
+        return cons(v, l);
+    if (car(car(l)) != car(v))
+        return cons(v, l);
+    if (!elementToValueIsList(cadr(car(l)))) {
+        var g = mklist(car(v), mklist(cdr(v), cdr(car(l))));
+        return elementToValueGroupValues(g, cdr(l));
+    }
+    var g = mklist(car(v), cons(cdr(v), cadr(car(l))));
+    return elementToValueGroupValues(g, cdr(l));
+}
+
+function elementsToValues(e) {
+    if (isNil(e))
+        return e;
+    return elementToValueGroupValues(elementToValue(car(e)), elementsToValues(cdr(e)));
+}
+
+/**
+ * Convert a value to an element.
+ */
+function valueToElement(t) {
+    if (isList(t) && !isNil(t) && isSymbol(car(t))) {
+        var n = car(t);
+        var v = isNil(cdr(t))? mklist() : cadr(t);
+        if (!isList(v)) {
+            if (n.substring(0, 2) == atsign)
+                return mklist(attribute, "'" + n.substring(2), v);
+            return mklist(element, n, v);
+        }
+        if (isNil(v) || !isSymbol(car(v)))
+            return cons(element, cons(n, mklist(valuesToElements(v))));
+        return cons(element, cons(n, valuesToElements(cdr(t))));
+    }
+    if (!isList(t))
+        return t;
+    return valuesToElements(t);
+}
+
+/**
+ * Convert a list of values to a list of elements.
+ */
+function valuesToElements(l) {
+    if (isNil(l))
+        return l;
+    return cons(valueToElement(car(l)), valuesToElements(cdr(l)));
+}
+
+/**
+ * Return a selector lambda function which can be used to filter elements.
+ */
+function selector(s) {
+    function evalSelect(s, v) {
+        if (isNil(s))
+            return true;
+        if (isNil(v))
+            return false;
+        if (car(s) != car(v))
+            return false;
+        return evalSelect(cdr(s), cdr(v));
+    }
+
+    return function(v) { return evalSelect(s, v); };
+}
+
+/**
+ * Return the attribute with the given name.
+ */
+function namedAttribute(name, l) {
+    return memo(l, name, function() {
+        var f = filter(function(v) { return isAttribute(v) && attributeName(v) == name; }, l);
+        if (isNil(f))
+            return null;
+        return car(f);
+    });
+}
+
+/**
+ * Return the value of the attribute with the given name.
+ */
+function namedAttributeValue(name, l) {
+    var a = namedAttribute(name, l);
+    if (a == null)
+        return null
+    return attributeValue(a);
+}
+
+/**
+ * Return child elements with the given name.
+ */
+function namedElementChildren(name, l) {
+    return memo(l, name, function() {
+        return filter(function(v) { return isElement(v) && elementName(v) == name; }, l);
+    });
+}
+
+/**
+ * Return the child element with the given name.
+ */
+function namedElementChild(name, l) {
+    var f = namedElementChildren(name, l);
+    if (isNil(f))
+        return null;
+    return car(f);
+}
+
+/**
+ * Side effect functions. Use with moderation.
+ */
+
+/**
+ * Set the contents of an element.
+ */
+function setElement(l, e) {
+    setlist(l, e);
+    l.memo = {};
+}
+

Propchange: tuscany/sca-java-2.x/trunk/modules/node-manager/src/test/resources/ui/elemutil.js
------------------------------------------------------------------------------
    svn:eol-style = native