summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-05-09 14:00:59 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-05-09 14:00:59 +0000
commit65145ace6c12a703bb3a8f9063d338d2703d86f0 (patch)
treef957508b62db2737a073d555a12f00bd3288e622 /sca-java-2.x/trunk
parent3947e373c50dc536f99547d3d03a224bee34a769 (diff)
Start looking at support for a Shell command to show the domain level composite, this includes adding info about the running composites to the domain registry and a the new shell command to access it.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1101031 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk')
-rw-r--r--sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java7
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java21
-rw-r--r--sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java14
-rw-r--r--sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java26
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java3
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java33
-rw-r--r--sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java21
-rw-r--r--sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java25
8 files changed, 138 insertions, 12 deletions
diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java
index ed2d6894c0..a2ceeda5a7 100644
--- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java
+++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java
@@ -22,6 +22,9 @@ package org.apache.tuscany.sca.runtime;
import java.util.Collection;
import java.util.List;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.EndpointReference;
@@ -76,4 +79,8 @@ public interface EndpointRegistry {
void removeListener(EndpointListener listener);
String getDomainURI();
+
+ void addRunningComposite(Composite composite);
+ void removeRunningComposite(QName name);
+ List<Composite> getRunningComposites();
}
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
index 7555b95140..1f03395040 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
@@ -20,13 +20,18 @@
package org.apache.tuscany.sca.core.assembly.impl;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.xml.namespace.QName;
+
import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.LifeCycleListener;
@@ -43,6 +48,7 @@ public class EndpointRegistryImpl extends BaseEndpointRegistry implements Endpoi
private final Logger logger = Logger.getLogger(EndpointRegistryImpl.class.getName());
private List<Endpoint> endpoints = new ArrayList<Endpoint>();
+ private Map<QName, Composite> runningComposites = new HashMap<QName, Composite>();
protected boolean quietLogging;
@@ -155,4 +161,19 @@ public class EndpointRegistryImpl extends BaseEndpointRegistry implements Endpoi
listeners.clear();
}
+ @Override
+ public void addRunningComposite(Composite composite) {
+ runningComposites.put(composite.getName(), composite);
+ }
+
+ @Override
+ public void removeRunningComposite(QName name) {
+ runningComposites.remove(name);
+ }
+
+ @Override
+ public List<Composite> getRunningComposites() {
+ return new ArrayList<Composite>(runningComposites.values());
+ }
+
}
diff --git a/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java b/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
index 8f3af59235..1781e75d45 100644
--- a/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
+++ b/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
@@ -836,5 +836,19 @@ public class DeployerImpl implements Deployer {
public void stop() {
}
+
+ @Override
+ public void addRunningComposite(Composite composite) {
+ }
+
+ @Override
+ public void removeRunningComposite(QName name) {
+ }
+
+ @Override
+ public List<Composite> getRunningComposites() {
+ return null;
+ }
+
}
}
diff --git a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
index 93230afbc5..cefbcd73d1 100644
--- a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
+++ b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
@@ -23,6 +23,7 @@ import java.io.FileNotFoundException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -30,7 +31,10 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.xml.namespace.QName;
+
import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
@@ -69,10 +73,13 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E
protected Map<Object, Object> endpointMap;
protected Map<String, Endpoint> localEndpoints = new ConcurrentHashMap<String, Endpoint>();
protected MultiMap<String, String> endpointOwners;
+ protected Map<QName, Composite> runningComposites;
+
protected AssemblyFactory assemblyFactory;
protected Object shutdownMutex = new Object();
protected Properties properties;
+
public HazelcastEndpointRegistry(ExtensionPointRegistry registry, Properties properties, String endpointRegistryURI, String domainURI) {
super(registry, null, endpointRegistryURI, domainURI);
this.assemblyFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(AssemblyFactory.class);
@@ -106,6 +113,10 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E
endpointOwners = hazelcastInstance.getMultiMap(domainURI + "/EndpointOwners");
+ // TODO: get going in-JVM first then fix this which needs to serialize/deserialize the composite
+ // runningComposites = hazelcastInstance.getMap(domainURI + "/composites");
+ runningComposites = new HashMap<QName, Composite>();
+
hazelcastInstance.getCluster().addMembershipListener(this);
// }
}
@@ -395,4 +406,19 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E
}
return null;
}
+
+ @Override
+ public void addRunningComposite(Composite composite) {
+ runningComposites.put(composite.getName(), composite);
+ }
+
+ @Override
+ public void removeRunningComposite(QName name) {
+ runningComposites.remove(name);
+ }
+
+ @Override
+ public List<Composite> getRunningComposites() {
+ return new ArrayList<Composite>(runningComposites.values());
+ }
}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java
index 923a12c9b1..1b3b244d08 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java
@@ -85,6 +85,7 @@ public class DeployedComposite {
Monitor monitor = deployer.createMonitor();
builtComposite = deployer.build(contribution, dependedOnContributions, new HashMap<QName, List<String>>(), monitor);
+ builtComposite.setName(composite.getName());
monitor.analyzeProblems();
compositeContext = new CompositeContext(extensionPointRegistry,
@@ -100,9 +101,11 @@ public class DeployedComposite {
public void start() throws ActivationException {
compositeActivator.activate(compositeContext, builtComposite);
compositeActivator.start(compositeContext, builtComposite);
+ endpointRegistry.addRunningComposite(builtComposite);
}
public void stop() throws ActivationException {
+ endpointRegistry.removeRunningComposite(builtComposite.getName());
compositeActivator.stop(compositeContext, builtComposite);
compositeActivator.deactivate(builtComposite);
}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
index b1d1c97e61..38d06b6f59 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.impl;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.Reader;
import java.util.ArrayList;
@@ -29,11 +30,13 @@ import java.util.Map;
import java.util.Set;
import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import org.apache.tuscany.sca.Node;
import org.apache.tuscany.sca.TuscanyRuntime;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Base;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.ComponentService;
@@ -48,6 +51,9 @@ import org.apache.tuscany.sca.contribution.Artifact;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.contribution.ContributionMetadata;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+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.core.invocation.ExtensibleProxyFactory;
@@ -209,15 +215,32 @@ public class NodeImpl implements Node {
}
public Composite getDomainLevelComposite() {
- // TODO Auto-generated method stub
- return null;
+ FactoryExtensionPoint factories = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class);
+ AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ Composite domainComposite = assemblyFactory.createComposite();
+ domainComposite.setName(new QName(Base.SCA11_TUSCANY_NS, "domainCompoiste"));
+ List<Composite> domainIncludes = domainComposite.getIncludes();
+ for (Composite composite : endpointRegistry.getRunningComposites()) {
+ domainIncludes.add(composite);
+ }
+ return domainComposite;
}
public String getDomainLevelCompositeAsString() {
- // TODO Auto-generated method stub
- return null;
- }
+ StAXArtifactProcessorExtensionPoint xmlProcessors = extensionPointRegistry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ StAXArtifactProcessor<Composite> compositeProcessor = xmlProcessors.getProcessor(Composite.class);
+ XMLOutputFactory outputFactory = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(XMLOutputFactory.class);
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ try {
+ compositeProcessor.write(getDomainLevelComposite(), outputFactory.createXMLStreamWriter(bos), new ProcessorContext(extensionPointRegistry));
+ } catch(Exception e) {
+ throw new RuntimeException(e);
+ }
+ String result = bos.toString();
+ return result;
+ }
public Object getQNameDefinition(String contributionURI, QName definition, QName symbolSpace) {
// TODO Auto-generated method stub
return null;
diff --git a/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java b/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
index 5dc627d88d..035418545f 100644
--- a/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
+++ b/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
@@ -34,6 +34,8 @@ import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.xml.namespace.QName;
+
import org.apache.catalina.tribes.Channel;
import org.apache.catalina.tribes.ChannelException;
import org.apache.catalina.tribes.ChannelReceiver;
@@ -43,6 +45,7 @@ import org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor
import org.apache.catalina.tribes.membership.McastService;
import org.apache.catalina.tribes.membership.StaticMember;
import org.apache.catalina.tribes.transport.ReceiverBase;
+import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.LifeCycleListener;
@@ -417,4 +420,22 @@ public class ReplicatedEndpointRegistry extends BaseEndpointRegistry implements
}
}
+ @Override
+ public void addRunningComposite(Composite composite) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void removeRunningComposite(QName name) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public List<Composite> getRunningComposites() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
diff --git a/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java b/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
index 642c7a0051..e9d8068b8a 100644
--- a/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
+++ b/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
@@ -67,7 +67,7 @@ public class Shell {
private Map<String, Node> standaloneNodes = new HashMap<String, Node>();
private Map<String, Node> nodes = new HashMap<String, Node>();
- public static final String[] COMMANDS = new String[] {"bye", "domain", "domains", "help", "install", "installed", "invoke",
+ public static final String[] COMMANDS = new String[] {"bye", "domain", "domains", "domainComposite", "help", "install", "installed", "invoke",
"load", "remove", "run", "save", "services", "start", "started", "stop"};
public static void main(final String[] args) throws Exception {
@@ -135,6 +135,11 @@ public class Shell {
return true;
}
+ boolean domainComposite() {
+ System.out.println(getNode().getDomainLevelCompositeAsString());
+ return true;
+ }
+
boolean install(final List<String> toks) throws ContributionReadException, ActivationException, ValidationException {
if (getNode() == null) {
out.println("not in domain, use domain command first");
@@ -531,12 +536,18 @@ public class Shell {
return domain(toks.size() > 1 ? toks.get(1) : "");
}
};
- if (op.equalsIgnoreCase("domains"))
- return new Callable<Boolean>() {
- public Boolean call() throws Exception {
- return domains();
- }
- };
+ if (op.equalsIgnoreCase("domains"))
+ return new Callable<Boolean>() {
+ public Boolean call() throws Exception {
+ return domains();
+ }
+ };
+ if (op.equalsIgnoreCase("domainComposite"))
+ return new Callable<Boolean>() {
+ public Boolean call() throws Exception {
+ return domainComposite();
+ }
+ };
if (op.equalsIgnoreCase("install"))
return new Callable<Boolean>() {
public Boolean call() throws Exception {