Catch up with Ant's changes

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1124703 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
slaws 2011-05-19 12:10:28 +00:00
parent a9bd5854f9
commit a5707c170d
4 changed files with 45 additions and 24 deletions

View file

@ -30,7 +30,7 @@ import org.oasisopen.sca.annotation.Remotable;
@Remotable
public interface Composite {
@GET
// @GET
@Produces( {MediaType.TEXT_HTML})
@Path("{domainname}/composite")
public String get();

View file

@ -66,7 +66,7 @@ public interface Domain {
MediaType.TEXT_HTML})
public String getComponents(@PathParam("domainname") String domainName);
@Path("{domainname}/endpoints")
@Path("{domainname}/endpoint")
@GET
@Produces( {MediaType.APPLICATION_ATOM_XML,
MediaType.APPLICATION_JSON,

View file

@ -21,8 +21,17 @@ package org.apache.tuscany.sca.domain;
import java.io.File;
import java.util.List;
import java.util.Map;
import javax.xml.namespace.QName;
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.impl.NodeImpl;
import org.apache.tuscany.sca.runtime.DomainRegistry;
/**
@ -46,14 +55,13 @@ public class DomainImpl implements Domain {
}
public String getContributions(String domainName) {
NodeImpl node = (NodeImpl)DomainView.domainAccessPointNode;
List<String> contributions = node.getInstalledContributionURIs();
DomainRegistry domainRegistry = DomainView.domainRegistry;
List<String> contributions = domainRegistry.getInstalledContributionURIs();
return contributions.toString();
}
public String getComposites(String domainName){
NodeImpl node = (NodeImpl)DomainView.domainAccessPointNode;
return node.getDomainLevelCompositeAsString();
return Utils.modelToXML(getDomainComposite(domainName), true, DomainView.extensionPointRegistry);
}
public String getComponents(String domainName) {
@ -62,29 +70,33 @@ public class DomainImpl implements Domain {
}
public String getEndpoints(String domainName) {
NodeImpl node = (NodeImpl)DomainView.domainAccessPointNode;
return node.getEndpointRegistry().getEndpoints().toString();
DomainRegistry domainRegistry = DomainView.domainRegistry;
return domainRegistry.getEndpoints().toString();
}
public String getNodes(String domainName){
// use the domain on the file system in lieu of info in the registry
File domainDir = new File("target/test-classes/" + domainName);
String nodes = "";
for (File subDir : domainDir.listFiles()){
if (subDir.isDirectory()){
nodes += subDir.getName() + "\n";
}
}
return nodes;
DomainRegistry domainRegistry = DomainView.domainRegistry;
return domainRegistry.getMembers().toString();
}
// utilities
public String prettyPrintXMLString(String inXML){
return inXML.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
// etc. need to read and write a structured version
// copied from domain node
public Composite getDomainComposite(String domainName) {
FactoryExtensionPoint factories = DomainView.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<Composite> domainIncludes = domainComposite.getIncludes();
Map<String, List<String>> runningCompositeURIs = DomainView.domainRegistry.getRunningCompositeURIs();
for (String curi : runningCompositeURIs.keySet()) {
for (String compositeURI : runningCompositeURIs.get(curi)) {
domainIncludes.add(DomainView.domainRegistry.getRunningComposite(curi, compositeURI));
}
}
return domainComposite;
}
}

View file

@ -21,6 +21,9 @@ package org.apache.tuscany.sca.domain;
import org.apache.tuscany.sca.Node;
import org.apache.tuscany.sca.TuscanyRuntime;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.impl.NodeImpl;
import org.apache.tuscany.sca.runtime.DomainRegistry;
/**
* Main class for Tuscany. Just looking at what it means to read config from a directory structure.
@ -28,20 +31,26 @@ import org.apache.tuscany.sca.TuscanyRuntime;
*/
public class DomainView {
public static Node domainAccessPointNode = null;
public static DomainRegistry domainRegistry = null;
public static ExtensionPointRegistry extensionPointRegistry = null;
private static Node domainAccessPointNode = null;
private static Node domainViewNode = null;
public static void main(String[] args) throws Exception {
String domainName = args[0];
TuscanyRuntime tuscanyRuntime = TuscanyRuntime.newInstance();
extensionPointRegistry = tuscanyRuntime.getExtensionPointRegistry();
// a node to access the specified domain
domainAccessPointNode = tuscanyRuntime.createNode("uri:" + domainName);
domainRegistry = ((NodeImpl)domainAccessPointNode).getEndpointRegistry();
// a node to run the domain view app. Just starts in the local domain "domainview"
domainViewNode = tuscanyRuntime.createNode("domainview");
domainViewNode.installContribution("target/classes");
domainViewNode.installContribution("domainViewContrib", "target/classes", null, null);
domainViewNode.startComposite("domainViewContrib", "domain.composite");
System.out.print("Press a key to stop");
try{