diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-25 10:58:30 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-25 10:58:30 +0000 |
commit | 01d244ef2681dc366e994ec5962456d07d75d148 (patch) | |
tree | 915a2cac6d5f5f76501f96b4a0c6dd7a3ae5cbb4 /sandbox/slaws | |
parent | 2f83f5e8e091074cbd4e3d0d7cc15af22411314c (diff) |
Fiddling about with making the composite artifact path do something
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1127474 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/slaws')
4 files changed, 103 insertions, 27 deletions
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 index de88ce9845..b4944dffb3 100644 --- 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 @@ -20,6 +20,7 @@ package org.apache.tuscany.sca.domain;
import javax.ws.rs.GET;
+import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
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 index 35fdf92f6f..44e8b5c937 100644 --- 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 @@ -25,6 +25,14 @@ import java.util.List; import javax.ws.rs.core.PathSegment;
import javax.ws.rs.core.UriInfo;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.xml.Utils;
+import org.apache.tuscany.sca.runtime.DomainRegistry;
+
/**
* Some hand crafted HTTP code to help me think about what info is missing
* from the domain registry
@@ -32,33 +40,86 @@ import javax.ws.rs.core.UriInfo; public class CompositeArtifactViewImpl implements CompositeArtifactView {
private String domainName;
+ private Composite composite;
+ private String artifacturi;
- public CompositeArtifactViewImpl(String domainName){
+ public CompositeArtifactViewImpl(String domainName, Composite composite, String artifacturi){
this.domainName = domainName;
+ this.composite = composite;
+ this.artifacturi = artifacturi;
}
public String get(UriInfo uriInfo){
- Iterator<PathSegment> pathSegmentsIter = uriInfo.getPathSegments().iterator();
+ if (composite == null){
+ return "<p/>composite not found";
+ }
+
+ String[] artifactNames = artifacturi.split("/");
+
+ Component component = null;
+ Service service = null;
+ Reference reference = null;
+ Binding binding = null;
+
+ // iterate down the artifact uri
+ for (int i=0; i < artifactNames.length; i++){
+ String name = artifactNames[i];
+
+ if (service != null) {
+ binding = service.getBinding(name);
+ break;
+ } else if (reference != null){
+ binding = reference.getBinding(name);
+ break;
+ }
+
+ if (component != null) {
+ service = component.getService(name);
+ reference = component.getReference(name);
+ }
+
+ component = composite.getComponent(name);
+ }
- // get past the sca/domain/domainname/composite/compositename segments
- pathSegmentsIter.next();
- pathSegmentsIter.next();
- pathSegmentsIter.next();
- pathSegmentsIter.next();
- pathSegmentsIter.next();
+ // not sure how to print out the artifacts
+ if (binding != null){
+ return "<p/><textarea rows=\"40\" cols=\"80\">" +
+ Utils.modelToXML(binding, true, DomainViewRunner.extensionPointRegistry) +
+ "</textarea>";
+ }
+
+ if (service != null){
+ /* need to register stax processors for this to work
+ return "<p/><textarea rows=\"40\" cols=\"80\">" +
+ Utils.modelToXML(service, false, DomainViewRunner.extensionPointRegistry) +
+ "</textarea>";
+ */
+ return "Service: " + service.toString();
+ }
+
+ if (reference != null){
+ /* need to register stax processors for this to work
+ return "<p/><textarea rows=\"40\" cols=\"80\">" +
+ Utils.modelToXML(reference, false, DomainViewRunner.extensionPointRegistry) +
+ "</textarea>";
+ */
+ return "Reference: " + reference.toString();
+ }
- // now expecting componentname/componentname/componentname/service or reference/binding
- while (pathSegmentsIter.hasNext()){
- pathSegmentsIter.next();
+ if (component != null){
+ /* need to register stax processors for this to work
+ return "<p/><textarea rows=\"40\" cols=\"80\">" +
+ Utils.modelToXML(component, false, DomainViewRunner.extensionPointRegistry) +
+ "</textarea>";
+ */
+ return "Component: " + component.toString();
}
- // get list of pairs of artifact type and name
- return "Yippeeeee! Show the composite artifact at " + uriInfo.getPath();
+ return "artifact " + artifacturi + " not found in composite " + composite.getURI();
}
- class Artifact {
- public String type;
- public String name;
+ public Component findComponent(Composite composite, String name){
+ return composite.getComponent(name);
}
}
\ 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 a60ec61bc3..636892f054 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 @@ -41,7 +41,11 @@ public interface CompositeView { @Path("{compositename}")
public String getComposite(@PathParam("compositename") String compositeName, @Context UriInfo uriInfo);
- @Path("{compositename}/{compositeartifact}")
- public CompositeArtifactView getCompositeArtifact();
+ // Hack to make it call this with any path added to the end of the composite name
+ // Want the user to be able to do something like
+ // http://localhost:80/sca/domain/mydomain/composite/mycomposite/component1/component2/service1
+ @Path("{compositename}/{artifacturi:.*}")
+ public CompositeArtifactView getCompositeArtifact(@PathParam("compositename") String compositeName,
+ @PathParam("artifacturi") String artifacturi);
}
\ 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 3f33d7335a..098446051b 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 @@ -51,21 +51,31 @@ public class CompositeViewImpl implements CompositeView { }
public String getComposite(String compositeName, UriInfo uriInfo) {
+ Composite composite = getComposite(compositeName);
+ if(composite != null){
+ return "<p/><textarea rows=\"40\" cols=\"80\">" +
+ Utils.modelToXML(composite, true, DomainViewRunner.extensionPointRegistry) +
+ "</textarea>";
+ } else {
+ return "<p/>composite not found";
+ }
+ }
+
+ public CompositeArtifactView getCompositeArtifact(String compositeName, String artifacturi){
+ return new CompositeArtifactViewImpl(domainName, getComposite(compositeName), artifacturi);
+ }
+
+ // utlilities
+
+ public Composite getComposite(String compositeName){
DomainRegistry domainRegistry = DomainViewRunner.domainRegistry;
Composite composite = domainRegistry.getDomainComposite();
for (Composite tmpComposite : composite.getIncludes()){
if (tmpComposite.getName().getLocalPart().equals(compositeName)){
- return "<p/><textarea rows=\"40\" cols=\"80\">" +
- Utils.modelToXML(tmpComposite, true, DomainViewRunner.extensionPointRegistry) +
- "</textarea>";
+ return tmpComposite;
}
}
- return "<p/>composite not found";
- }
-
- public CompositeArtifactView getCompositeArtifact(){
- return new CompositeArtifactViewImpl(domainName);
+ return null;
}
-
}
\ No newline at end of file |