From 7608b05fc67449fca1fbefaddc202598b8b4639c Mon Sep 17 00:00:00 2001 From: slaws Date: Tue, 24 May 2011 08:32:01 +0000 Subject: Add a and atom view of composites and look at retrieving the composite artifact hierarchy git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1126924 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/domain/CompositeArtifactView.java | 37 +++ .../sca/domain/CompositeArtifactViewImpl.java | 64 ++++++ .../tuscany/sca/domain/CompositeAtomView.java | 38 ++++ .../tuscany/sca/domain/CompositeAtomViewImpl.java | 72 ++++++ .../apache/tuscany/sca/domain/CompositeView.java | 15 +- .../tuscany/sca/domain/CompositeViewImpl.java | 66 +++--- .../org/apache/tuscany/sca/domain/DomainView.java | 10 +- .../apache/tuscany/sca/domain/DomainViewImpl.java | 14 +- .../src/main/resources/domain.composite | 14 +- .../domain1/helloworld-client-contribution.jar | Bin 0 -> 9625 bytes .../repo/domain1/helloworld-iface-contribution.jar | Bin 0 -> 8212 bytes .../domain1/helloworld-service-contribution.jar | Bin 0 -> 9432 bytes .../resources/repo/domain1/nodeClient/node.xml | 38 ++++ .../resources/repo/domain1/nodeService/node.xml | 38 ++++ .../domain-view/src/main/resources/repo/index.html | 250 +++++++++++++++++++++ 15 files changed, 598 insertions(+), 58 deletions(-) create mode 100644 sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeArtifactView.java create mode 100644 sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeArtifactViewImpl.java create mode 100644 sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeAtomView.java create mode 100644 sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeAtomViewImpl.java create mode 100644 sandbox/slaws/domain-view/src/main/resources/repo/domain1/helloworld-client-contribution.jar create mode 100644 sandbox/slaws/domain-view/src/main/resources/repo/domain1/helloworld-iface-contribution.jar create mode 100644 sandbox/slaws/domain-view/src/main/resources/repo/domain1/helloworld-service-contribution.jar create mode 100644 sandbox/slaws/domain-view/src/main/resources/repo/domain1/nodeClient/node.xml create mode 100644 sandbox/slaws/domain-view/src/main/resources/repo/domain1/nodeService/node.xml create mode 100644 sandbox/slaws/domain-view/src/main/resources/repo/index.html diff --git a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeArtifactView.java b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeArtifactView.java new file mode 100644 index 0000000000..de88ce9845 --- /dev/null +++ b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeArtifactView.java @@ -0,0 +1,37 @@ +/* + * 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; + +import javax.ws.rs.GET; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface CompositeArtifactView { + + @GET + @Produces( {MediaType.TEXT_HTML}) + public String get(@Context UriInfo uriInfo); + +} \ No newline at end of file diff --git a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeArtifactViewImpl.java b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeArtifactViewImpl.java new file mode 100644 index 0000000000..35fdf92f6f --- /dev/null +++ b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeArtifactViewImpl.java @@ -0,0 +1,64 @@ +/* + * 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; + +import java.util.Iterator; +import java.util.List; + +import javax.ws.rs.core.PathSegment; +import javax.ws.rs.core.UriInfo; + +/** + * Some hand crafted HTTP code to help me think about what info is missing + * from the domain registry + */ +public class CompositeArtifactViewImpl implements CompositeArtifactView { + + private String domainName; + + public CompositeArtifactViewImpl(String domainName){ + this.domainName = domainName; + } + + public String get(UriInfo uriInfo){ + Iterator pathSegmentsIter = uriInfo.getPathSegments().iterator(); + + // get past the sca/domain/domainname/composite/compositename segments + pathSegmentsIter.next(); + pathSegmentsIter.next(); + pathSegmentsIter.next(); + pathSegmentsIter.next(); + pathSegmentsIter.next(); + + // now expecting componentname/componentname/componentname/service or reference/binding + while (pathSegmentsIter.hasNext()){ + pathSegmentsIter.next(); + } + + // get list of pairs of artifact type and name + return "Yippeeeee! Show the composite artifact at " + uriInfo.getPath(); + } + + class Artifact { + public String type; + public String name; + } + +} \ No newline at end of file diff --git a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeAtomView.java b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeAtomView.java new file mode 100644 index 0000000000..8d9cada6bd --- /dev/null +++ b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeAtomView.java @@ -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.domain; + +import javax.ws.rs.GET; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; + +import org.apache.wink.common.model.atom.AtomFeed; +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface CompositeAtomView { + + @GET + @Produces( {MediaType.APPLICATION_ATOM_XML} ) + public AtomFeed getFeed(@Context UriInfo uriInfo); + +} \ No newline at end of file diff --git a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeAtomViewImpl.java b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeAtomViewImpl.java new file mode 100644 index 0000000000..d858f82013 --- /dev/null +++ b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeAtomViewImpl.java @@ -0,0 +1,72 @@ +/* + * 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; + +import java.util.Date; + +import javax.ws.rs.core.UriInfo; + +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.xml.Utils; +import org.apache.tuscany.sca.runtime.DomainRegistry; +import org.apache.wink.common.model.atom.AtomEntry; +import org.apache.wink.common.model.atom.AtomFeed; +import org.apache.wink.common.model.atom.AtomLink; +import org.apache.wink.common.model.atom.AtomText; + +/** + * Some hand crafted HTTP code to help me think about what info is missing + * from the domain registry + */ +public class CompositeAtomViewImpl implements CompositeAtomView { + + private String domainName; + + public CompositeAtomViewImpl(String domainName){ + this.domainName = domainName; + } + + public AtomFeed getFeed(UriInfo uriInfo) { + AtomFeed feed = new AtomFeed(); + feed.setId(domainName + " composites"); + feed.setTitle(new AtomText("Composites installed in domain: " + domainName)); + feed.setUpdated(new Date()); + AtomLink feedLink = new AtomLink(); + feedLink.setHref(uriInfo.getPath()); + feed.getLinks().add(feedLink); + + DomainRegistry domainRegistry = DomainViewRunner.domainRegistry; + Composite composite = domainRegistry.getDomainComposite(); + for (Composite tmpComposite : composite.getIncludes()){ + + AtomEntry entry = new AtomEntry(); + entry.setId(tmpComposite.getName().toString()); + entry.setTitle(new AtomText(tmpComposite.getName().toString())); + entry.setUpdated(new Date()); + entry.setPublished(new Date()); + entry.setSummary(new AtomText(Utils.modelToXML(tmpComposite, true, DomainViewRunner.extensionPointRegistry))); + + feed.getEntries().add(entry); + } + + return feed; + } + +} \ No newline at end of file diff --git a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeView.java b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeView.java index 4ff1101cfa..a60ec61bc3 100644 --- a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeView.java +++ b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeView.java @@ -23,7 +23,9 @@ import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; import org.oasisopen.sca.annotation.Remotable; @@ -32,15 +34,14 @@ public interface CompositeView { @GET @Produces( {MediaType.TEXT_HTML}) - public String get(); - + public String getComposites(); @GET - @Produces( {MediaType.APPLICATION_ATOM_XML, - MediaType.APPLICATION_JSON, - MediaType.APPLICATION_XML, - MediaType.TEXT_HTML}) + @Produces( {MediaType.TEXT_HTML}) @Path("{compositename}") - public String getComposite(@PathParam("compositename") String domainName); + public String getComposite(@PathParam("compositename") String compositeName, @Context UriInfo uriInfo); + + @Path("{compositename}/{compositeartifact}") + public CompositeArtifactView getCompositeArtifact(); } \ No newline at end of file diff --git a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeViewImpl.java b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeViewImpl.java index 8220672a8b..3f33d7335a 100644 --- a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeViewImpl.java +++ b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeViewImpl.java @@ -19,55 +19,53 @@ package org.apache.tuscany.sca.domain; -import java.util.List; -import java.util.Map; +import java.util.Date; -import javax.xml.namespace.QName; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.UriInfo; -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.assembly.Base; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.xml.Utils; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; +import org.apache.tuscany.sca.runtime.DomainRegistry; +import org.apache.wink.common.model.atom.AtomEntry; +import org.apache.wink.common.model.atom.AtomFeed; +import org.apache.wink.common.model.atom.AtomLink; +import org.apache.wink.common.model.atom.AtomText; /** * Some hand crafted HTTP code to help me think about what info is missing * from the domain registry - * */ public class CompositeViewImpl implements CompositeView { - public String get() { - String outputHTML = "

get"; - return outputHTML; - -// Utils.modelToXML(getDomainComposite(domainName), true, DomainViewRunner.extensionPointRegistry); - } + private String domainName; - - public String getComposite(String domainName) { - String outputHTML = "

get composite"; - return outputHTML; - } + public CompositeViewImpl(String domainName){ + this.domainName = domainName; + } - // utilities + public String getComposites() { + DomainRegistry domainRegistry = DomainViewRunner.domainRegistry; + Composite composite = domainRegistry.getDomainComposite(); + return composite.getIncludes().toString(); + } - // copied from domain node - public Composite getDomainComposite(String domainName) { - FactoryExtensionPoint factories = DomainViewRunner.extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class); - AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class); - Composite domainComposite = assemblyFactory.createComposite(); - domainComposite.setName(new QName(Base.SCA11_TUSCANY_NS, domainName)); - domainComposite.setAutowire(false); - domainComposite.setLocal(false); - List domainIncludes = domainComposite.getIncludes(); - Map> runningCompositeURIs = DomainViewRunner.domainRegistry.getRunningCompositeURIs(); - for (String curi : runningCompositeURIs.keySet()) { - for (String compositeURI : runningCompositeURIs.get(curi)) { - domainIncludes.add(DomainViewRunner.domainRegistry.getRunningComposite(curi, compositeURI)); + public String getComposite(String compositeName, UriInfo uriInfo) { + DomainRegistry domainRegistry = DomainViewRunner.domainRegistry; + Composite composite = domainRegistry.getDomainComposite(); + for (Composite tmpComposite : composite.getIncludes()){ + if (tmpComposite.getName().getLocalPart().equals(compositeName)){ + return "

"; } } - return domainComposite; - } + + return "

composite not found"; + } + public CompositeArtifactView getCompositeArtifact(){ + return new CompositeArtifactViewImpl(domainName); + } + } \ No newline at end of file diff --git a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/DomainView.java b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/DomainView.java index d7514f1bf3..7f4981e574 100644 --- a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/DomainView.java +++ b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/DomainView.java @@ -23,7 +23,9 @@ import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; import org.oasisopen.sca.annotation.Remotable; @@ -32,7 +34,7 @@ public interface DomainView { @GET @Produces( {MediaType.TEXT_HTML}) - public String get(); + public String get(@Context UriInfo uriInfo); @Path("{domainname}") @GET @@ -51,7 +53,11 @@ public interface DomainView { public String getContributions(@PathParam("domainname") String domainName); @Path("{domainname}/composite") - public CompositeView getComposites(@PathParam("domainname") String domainName); + public CompositeView getComposites(@PathParam("domainname") String domainName); + + @Path("{domainname}/composite.atom") + public CompositeAtomView getCompositesAtom(@PathParam("domainname") String domainName); + @Path("{domainname}/component") @GET diff --git a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/DomainViewImpl.java b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/DomainViewImpl.java index 1cfa4da94e..f297b00b77 100644 --- a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/DomainViewImpl.java +++ b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/DomainViewImpl.java @@ -22,6 +22,9 @@ package org.apache.tuscany.sca.domain; import java.util.List; import java.util.Map; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.UriInfo; import javax.xml.namespace.QName; import org.apache.tuscany.sca.assembly.AssemblyFactory; @@ -39,7 +42,10 @@ import org.apache.tuscany.sca.runtime.DomainRegistry; */ public class DomainViewImpl implements DomainView { - public String get() { + @Context + HttpHeaders requestHeaders; + + public String get(UriInfo uriInfo) { String outputHTML = "

enter URL in the form http://host:port/sca/domain/yourdomainnamehere"; return outputHTML; } @@ -60,9 +66,13 @@ public class DomainViewImpl implements DomainView { } public CompositeView getComposites(String domainName){ - return new CompositeViewImpl(); + return new CompositeViewImpl(domainName); } + public CompositeAtomView getCompositesAtom(String domainName){ + return new CompositeAtomViewImpl(domainName); + } + public String getComponents(String domainName) { return null; } diff --git a/sandbox/slaws/domain-view/src/main/resources/domain.composite b/sandbox/slaws/domain-view/src/main/resources/domain.composite index a3cdcbc3f8..be9aaa4a0c 100644 --- a/sandbox/slaws/domain-view/src/main/resources/domain.composite +++ b/sandbox/slaws/domain-view/src/main/resources/domain.composite @@ -28,7 +28,7 @@ - + @@ -39,16 +39,4 @@ - - diff --git a/sandbox/slaws/domain-view/src/main/resources/repo/domain1/helloworld-client-contribution.jar b/sandbox/slaws/domain-view/src/main/resources/repo/domain1/helloworld-client-contribution.jar new file mode 100644 index 0000000000..c98214fc83 Binary files /dev/null and b/sandbox/slaws/domain-view/src/main/resources/repo/domain1/helloworld-client-contribution.jar differ diff --git a/sandbox/slaws/domain-view/src/main/resources/repo/domain1/helloworld-iface-contribution.jar b/sandbox/slaws/domain-view/src/main/resources/repo/domain1/helloworld-iface-contribution.jar new file mode 100644 index 0000000000..455de9c58a Binary files /dev/null and b/sandbox/slaws/domain-view/src/main/resources/repo/domain1/helloworld-iface-contribution.jar differ diff --git a/sandbox/slaws/domain-view/src/main/resources/repo/domain1/helloworld-service-contribution.jar b/sandbox/slaws/domain-view/src/main/resources/repo/domain1/helloworld-service-contribution.jar new file mode 100644 index 0000000000..28e3e680e9 Binary files /dev/null and b/sandbox/slaws/domain-view/src/main/resources/repo/domain1/helloworld-service-contribution.jar differ diff --git a/sandbox/slaws/domain-view/src/main/resources/repo/domain1/nodeClient/node.xml b/sandbox/slaws/domain-view/src/main/resources/repo/domain1/nodeClient/node.xml new file mode 100644 index 0000000000..f6756ad187 --- /dev/null +++ b/sandbox/slaws/domain-view/src/main/resources/repo/domain1/nodeClient/node.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/slaws/domain-view/src/main/resources/repo/domain1/nodeService/node.xml b/sandbox/slaws/domain-view/src/main/resources/repo/domain1/nodeService/node.xml new file mode 100644 index 0000000000..38274a1a62 --- /dev/null +++ b/sandbox/slaws/domain-view/src/main/resources/repo/domain1/nodeService/node.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/slaws/domain-view/src/main/resources/repo/index.html b/sandbox/slaws/domain-view/src/main/resources/repo/index.html new file mode 100644 index 0000000000..7862cd5f82 --- /dev/null +++ b/sandbox/slaws/domain-view/src/main/resources/repo/index.html @@ -0,0 +1,250 @@ + + + + +Tuscany SCA Domain Components + + + + + + + + +

+ +
+ + +
+ + + + + + + + + +
prevnext
+
+ +
+
+ +
+ + + + + + + + -- cgit v1.2.3