summaryrefslogtreecommitdiffstats
path: root/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeArtifactViewImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeArtifactViewImpl.java')
-rw-r--r--sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/CompositeArtifactViewImpl.java93
1 files changed, 77 insertions, 16 deletions
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