From 62d55709374e7c299f720aa9066f8b3dcb315ac0 Mon Sep 17 00:00:00 2001 From: antelder Date: Mon, 18 Jul 2011 10:21:06 +0000 Subject: Create a branch for beta3 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1147804 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/node/manager/DomainCompositeResource.java | 35 +++ .../manager/impl/DomainCompositeResourceImpl.java | 100 +++++++++ ...he.tuscany.sca.node.extensibility.NodeActivator | 18 ++ .../manager/DomainCompositeResourceTestCase.java | 80 +++++++ .../src/test/resources/node-manager-test.composite | 40 ++++ .../src/test/resources/ui/component.gif | Bin 0 -> 547 bytes .../src/test/resources/ui/composite.gif | Bin 0 -> 536 bytes .../node-manager/src/test/resources/ui/index.html | 250 +++++++++++++++++++++ .../src/test/resources/ui/interface.gif | Bin 0 -> 734 bytes .../src/test/resources/ui/property.gif | Bin 0 -> 333 bytes .../src/test/resources/ui/reference.gif | Bin 0 -> 524 bytes .../node-manager/src/test/resources/ui/service.gif | Bin 0 -> 513 bytes 12 files changed, 523 insertions(+) create mode 100644 sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java create mode 100644 sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainCompositeResourceImpl.java create mode 100644 sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.extensibility.NodeActivator create mode 100644 sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/java/org/apache/tuscany/sca/node/manager/DomainCompositeResourceTestCase.java create mode 100644 sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/node-manager-test.composite create mode 100644 sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/component.gif create mode 100644 sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/composite.gif create mode 100644 sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/index.html create mode 100644 sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/interface.gif create mode 100644 sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/property.gif create mode 100644 sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/reference.gif create mode 100644 sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/service.gif (limited to 'sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src') diff --git a/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java new file mode 100644 index 0000000000..d9abd288ea --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java @@ -0,0 +1,35 @@ +/* + * 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 org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface DomainCompositeResource { + + @GET + @Path("{domainURI}") + String getDomainComposite(@PathParam("domainURI") @DefaultValue("default") String domainURI); +} diff --git a/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainCompositeResourceImpl.java b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainCompositeResourceImpl.java new file mode 100644 index 0000000000..9cb91e2917 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainCompositeResourceImpl.java @@ -0,0 +1,100 @@ +/* + * 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 nodeMap = new ConcurrentHashMap(); + + 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) { + 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 compositeProcessor = + xmlProcessors.getProcessor(Composite.class); + + return writeComposite(composite, registry, compositeProcessor); + } + + + private String writeComposite(Composite composite, ExtensionPointRegistry registry, StAXArtifactProcessor 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\n" + + writeComposite((Composite)component.getImplementation(), registry, + compositeProcessor); + } + } + return result; + } +} diff --git a/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.extensibility.NodeActivator b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.extensibility.NodeActivator new file mode 100644 index 0000000000..76ecb610ff --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.extensibility.NodeActivator @@ -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 diff --git a/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/java/org/apache/tuscany/sca/node/manager/DomainCompositeResourceTestCase.java b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/java/org/apache/tuscany/sca/node/manager/DomainCompositeResourceTestCase.java new file mode 100644 index 0000000000..da50dca604 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/java/org/apache/tuscany/sca/node/manager/DomainCompositeResourceTestCase.java @@ -0,0 +1,80 @@ +/* + * 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.Ignore; +import org.junit.Test; + +import com.meterware.httpunit.GetMethodWebRequest; +import com.meterware.httpunit.WebConversation; +import com.meterware.httpunit.WebRequest; +import com.meterware.httpunit.WebResponse; + +@Ignore +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()); + } + +} diff --git a/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/node-manager-test.composite b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/node-manager-test.composite new file mode 100644 index 0000000000..6f107a392d --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/node-manager-test.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/component.gif b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/component.gif new file mode 100644 index 0000000000..46b8963f4c Binary files /dev/null and b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/component.gif differ diff --git a/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/composite.gif b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/composite.gif new file mode 100644 index 0000000000..6749240e15 Binary files /dev/null and b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/composite.gif differ diff --git a/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/index.html b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/index.html new file mode 100644 index 0000000000..1d0e69bca3 --- /dev/null +++ b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/index.html @@ -0,0 +1,250 @@ + + + + +Tuscany SCA Domain Components + + + + + + + + + + +
+ + +
+ + + + + + + + + +
prevnext
+
+ +
+
+ +
+ + + + + + + + diff --git a/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/interface.gif b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/interface.gif new file mode 100644 index 0000000000..1d11c37913 Binary files /dev/null and b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/interface.gif differ diff --git a/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/property.gif b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/property.gif new file mode 100644 index 0000000000..354ad64645 Binary files /dev/null and b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/property.gif differ diff --git a/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/reference.gif b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/reference.gif new file mode 100644 index 0000000000..b3e2c80188 Binary files /dev/null and b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/reference.gif differ diff --git a/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/service.gif b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/service.gif new file mode 100644 index 0000000000..9b986e3788 Binary files /dev/null and b/sca-java-2.x/branches/2.0-Beta3/modules/node-manager/src/test/resources/ui/service.gif differ -- cgit v1.2.3