tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r1101031 - in /tuscany/sca-java-2.x/trunk/modules: core-spi/src/main/java/org/apache/tuscany/sca/runtime/ core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/ domain-...
Date Mon, 09 May 2011 14:01:00 GMT
Author: antelder
Date: Mon May  9 14:00:59 2011
New Revision: 1101031

URL: http://svn.apache.org/viewvc?rev=1101031&view=rev
Log:
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.

Modified:
    tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
    tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
    tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
    tuscany/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
    tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java

Modified: tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java?rev=1101031&r1=1101030&r2=1101031&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java
Mon May  9 14:00:59 2011
@@ -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();
 }

Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java?rev=1101031&r1=1101030&r2=1101031&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
Mon May  9 14:00:59 2011
@@ -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 extend
     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 extend
         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());
+    }
+
 }

Modified: tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java?rev=1101031&r1=1101030&r2=1101031&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
Mon May  9 14:00:59 2011
@@ -836,5 +836,19 @@ public class DeployerImpl implements Dep
 
         public void stop() {
         }
+
+        @Override
+        public void addRunningComposite(Composite composite) {
+        }
+
+        @Override
+        public void removeRunningComposite(QName name) {
+        }
+
+        @Override
+        public List<Composite> getRunningComposites() {
+            return null;
+        }
+
     }
 }

Modified: tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java?rev=1101031&r1=1101030&r2=1101031&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java
Mon May  9 14:00:59 2011
@@ -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.ConcurrentHa
 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 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 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 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());
+    }
 }

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java?rev=1101031&r1=1101030&r2=1101031&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java
Mon May  9 14:00:59 2011
@@ -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);
     }

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java?rev=1101031&r1=1101030&r2=1101031&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
Mon May  9 14:00:59 2011
@@ -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.contributi
 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;

Modified: tuscany/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java?rev=1101031&r1=1101030&r2=1101031&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
Mon May  9 14:00:59 2011
@@ -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.
 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 
         }
     }
 
+    @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;
+    }
+
 }

Modified: tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java?rev=1101031&r1=1101030&r2=1101031&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
Mon May  9 14:00:59 2011
@@ -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 {



Mime
View raw message