tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r655411 [1/2] - in /incubator/tuscany/java/sca/modules/domain-manager/src: main/java/org/apache/tuscany/sca/domain/manager/impl/ main/java/org/apache/tuscany/sca/domain/manager/launcher/ main/resources/ test/java/org/apache/tuscany/sca/doma...
Date Mon, 12 May 2008 04:48:56 GMT
Author: jsdelfino
Date: Sun May 11 21:48:55 2008
New Revision: 655411

URL: http://svn.apache.org/viewvc?rev=655411&view=rev
Log:
Decomposed the domain manager in smaller/simpler components. Removed dependencies on ReallySmallRuntime. Performance improvements by having the components share a single extension point registry and use the proper contribution processor. Also some code cleanup, removed unused imports.

Added:
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationServiceImpl.java   (with props)
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeGeneratorServiceImpl.java   (with props)
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/ContributionServiceImpl.java   (with props)
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployableCompositeServiceImpl.java   (with props)
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerConfiguration.java   (contents, props changed)
      - copied, changed from r653300, incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/LauncherConfiguration.java
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerConfigurationImpl.java   (contents, props changed)
      - copied, changed from r653300, incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/LauncherConfigurationImpl.java
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/NodeConfigurationServiceImpl.java   (with props)
Removed:
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/LauncherConfiguration.java
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/LauncherConfigurationImpl.java
Modified:
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationCollectionImpl.java
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/ContributionCollectionImpl.java
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployableCompositeCollectionImpl.java
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployedCompositeCollectionImpl.java
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerUtil.java
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/FileCollectionImpl.java
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/FileServiceImpl.java
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/NodeProcessCollectionFacadeImpl.java
    incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/launcher/DomainManagerLauncherBootstrap.java
    incubator/tuscany/java/sca/modules/domain-manager/src/main/resources/DomainManager.composite
    incubator/tuscany/java/sca/modules/domain-manager/src/test/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerTestCase.java

Modified: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationCollectionImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationCollectionImpl.java?rev=655411&r1=655410&r2=655411&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationCollectionImpl.java (original)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationCollectionImpl.java Sun May 11 21:48:55 2008
@@ -23,17 +23,10 @@
 import static org.apache.tuscany.sca.domain.manager.impl.DomainManagerUtil.compositeTitle;
 import static org.apache.tuscany.sca.domain.manager.impl.DomainManagerUtil.contributionURI;
 
-import java.io.IOException;
-import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.logging.Logger;
 
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import javax.xml.namespace.QName;
 
 import org.apache.tuscany.sca.implementation.data.collection.Entry;
@@ -47,14 +40,13 @@
 import org.osoa.sca.annotations.Service;
 
 /**
- * Implementation of a composite configuration collection service. 
+ * Implementation of a component that returns composite configuration collections. 
  *
  * @version $Rev$ $Date$
  */
 @Scope("COMPOSITE")
-@Service(interfaces={ItemCollection.class, LocalItemCollection.class, Servlet.class})
-public class CompositeConfigurationCollectionImpl extends HttpServlet implements ItemCollection, LocalItemCollection, Servlet {
-    private static final long serialVersionUID = 1L;
+@Service(interfaces={ItemCollection.class, LocalItemCollection.class})
+public class CompositeConfigurationCollectionImpl implements ItemCollection, LocalItemCollection {
 
     private final static Logger logger = Logger.getLogger(CompositeConfigurationCollectionImpl.class.getName());    
 
@@ -132,40 +124,4 @@
         }
     }
 
-    @Override
-    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-        
-        // Get the request path
-        String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
-        String key = path.startsWith("/")? path.substring(1) : path;
-        logger.fine("get " + key);
-        
-        // The key contains a node name, redirect 
-        // to the corresponding composite config
-            
-        // Get the collection of cloud composites
-        Entry<String, Item>[] cloudEntries = cloudCollection.getAll();
-
-        // Find the specified node
-        for (Entry<String, Item> cloudEntry: cloudEntries) {
-            QName qname = compositeQName(cloudEntry.getKey());
-            if (qname.getLocalPart().equals(key)) {
-                
-                // Found the specified node
-                String related = cloudEntry.getData().getRelated();
-                int i = related.indexOf("composite:");
-                if (i != -1) {
-                    
-                    // Redirect to its composite config
-                    String compositeConfiguration = "/composite-config/?composite=" + related.substring(i);
-                    response.sendRedirect(compositeConfiguration);
-                    return;
-                }
-            }
-        }
-        
-        // Node not found
-        response.sendError(HttpServletResponse.SC_NOT_FOUND, key);
-        return;
-    }
 }

Added: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationServiceImpl.java?rev=655411&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationServiceImpl.java (added)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationServiceImpl.java Sun May 11 21:48:55 2008
@@ -0,0 +1,433 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.domain.manager.impl;
+
+import static org.apache.tuscany.sca.domain.manager.impl.DomainManagerUtil.compositeQName;
+import static org.apache.tuscany.sca.domain.manager.impl.DomainManagerUtil.contributionURI;
+import static org.apache.tuscany.sca.domain.manager.impl.DomainManagerUtil.locationURL;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl;
+import org.apache.tuscany.sca.assembly.builder.impl.CompositeIncludeBuilderImpl;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.implementation.data.collection.Entry;
+import org.apache.tuscany.sca.implementation.data.collection.Item;
+import org.apache.tuscany.sca.implementation.data.collection.LocalItemCollection;
+import org.apache.tuscany.sca.implementation.data.collection.NotFoundException;
+import org.apache.tuscany.sca.implementation.node.NodeImplementation;
+import org.apache.tuscany.sca.implementation.node.builder.impl.NodeCompositeBuilderImpl;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
+import org.apache.tuscany.sca.workspace.Workspace;
+import org.apache.tuscany.sca.workspace.WorkspaceFactory;
+import org.apache.tuscany.sca.workspace.builder.ContributionDependencyBuilder;
+import org.apache.tuscany.sca.workspace.builder.impl.ContributionDependencyBuilderImpl;
+import org.apache.tuscany.sca.workspace.processor.impl.ContributionContentProcessor;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Implementation of a service that returns a fully configured composite. 
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+@Service(Servlet.class)
+public class CompositeConfigurationServiceImpl extends HttpServlet implements Servlet {
+    private static final long serialVersionUID = -8809641932774129152L;
+    
+    private final static Logger logger = Logger.getLogger(CompositeConfigurationServiceImpl.class.getName());    
+
+    @Reference
+    public LocalItemCollection contributionCollection;
+    
+    @Reference 
+    public LocalItemCollection domainCompositeCollection;
+    
+    @Reference
+    public DomainManagerConfiguration domainManagerConfiguration;
+    
+    @Reference 
+    public LocalItemCollection cloudCollection;    
+
+    private ModelFactoryExtensionPoint modelFactories;
+    private ModelResolverExtensionPoint modelResolvers;
+    private AssemblyFactory assemblyFactory;
+    private WorkspaceFactory workspaceFactory;
+    private URLArtifactProcessor<Contribution> contributionProcessor;
+    private StAXArtifactProcessor<Composite> compositeProcessor;
+    private XMLOutputFactory outputFactory;
+    private ContributionDependencyBuilder contributionDependencyBuilder;
+    private CompositeBuilder compositeBuilder;
+    private CompositeBuilder compositeIncludeBuilder;
+    private CompositeBuilder nodeConfigurationBuilder;
+    private Monitor monitor;
+    
+    /**
+     * Initialize the component.
+     */
+    @Init
+    public void initialize() throws ParserConfigurationException {
+        
+        ExtensionPointRegistry extensionPoints = domainManagerConfiguration.getExtensionPoints();
+        
+        // Get model factories
+        modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
+        assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+        XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class);
+        outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
+        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true);
+        workspaceFactory = modelFactories.getFactory(WorkspaceFactory.class);
+        
+        // Get and initialize artifact processors
+        StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+        compositeProcessor = (StAXArtifactProcessor<Composite>)staxProcessors.getProcessor(Composite.class);
+        StAXArtifactProcessor<Object> staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+
+        URLArtifactProcessorExtensionPoint urlProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+        URLArtifactProcessor<Object> urlProcessor = new ExtensibleURLArtifactProcessor(urlProcessors);
+        
+        // Create contribution processor
+        modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class);
+        contributionProcessor = new ContributionContentProcessor(modelFactories, modelResolvers, urlProcessor, staxProcessor);
+
+        // Create a monitor
+        UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+        MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
+        monitor = monitorFactory.createMonitor();
+        
+        // Create contribution and composite builders
+        contributionDependencyBuilder = new ContributionDependencyBuilderImpl(monitor);
+        SCABindingFactory scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class);
+        IntentAttachPointTypeFactory intentAttachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class);
+        InterfaceContractMapper contractMapper = utilities.getUtility(InterfaceContractMapper.class);
+        compositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, intentAttachPointTypeFactory, contractMapper, monitor);
+        compositeIncludeBuilder = new CompositeIncludeBuilderImpl(monitor);
+        nodeConfigurationBuilder = new NodeCompositeBuilderImpl(assemblyFactory, scaBindingFactory, contractMapper, null, monitor);
+    }
+    
+    @Override
+    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        
+        // Get the request path
+        String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+        String key = path.startsWith("/")? path.substring(1) : path;
+        logger.fine("get " + key);
+        
+        // Expect a key in the form
+        // composite:contributionURI;namespace;localName
+        // and return the corresponding resolved composite
+        
+        // Extract the composite qname from the key
+        QName qname = compositeQName(key);
+        
+        // Somewhere to store the composite we expect to write out at the end
+        Composite compositeConfiguration = null;
+
+        // Create a domain composite model
+        Composite domainComposite = assemblyFactory.createComposite();
+        domainComposite.setName(new QName(Constants.SCA10_TUSCANY_NS, "domain"));
+            
+        // Get the domain composite items
+        Entry<String, Item>[] domainEntries = domainCompositeCollection.getAll();
+        
+        // Populate the domain composite
+        Workspace workspace = workspaceFactory.createWorkspace();
+        workspace.setModelResolver(new ExtensibleModelResolver(workspace, modelResolvers, modelFactories));
+        
+        Map<String, Contribution> contributionMap = new HashMap<String, Contribution>(); 
+        for (Entry<String, Item> domainEntry: domainEntries) {
+            
+            // Load the required contributions
+            String contributionURI = contributionURI(domainEntry.getKey());
+            Contribution contribution = contributionMap.get(contributionURI);
+            if (contribution == null) {
+                
+                // The contribution has not been loaded yet, load it with all its dependencies
+                Entry<String, Item>[] entries = contributionCollection.query("alldependencies=" + contributionURI);
+                for (Entry<String, Item> entry: entries) {
+                    Item dependencyItem = entry.getData();
+                    String dependencyURI = entry.getKey();
+                    
+                    if (!contributionMap.containsKey(dependencyURI)) {
+                        
+                        // Read the contribution
+                        Contribution dependency;
+                        try {
+                            String dependencyLocation = dependencyItem.getAlternate();
+                            dependency = contribution(workspace, dependencyURI, dependencyLocation);
+                        } catch (ContributionReadException e) {
+                            continue;
+                        }
+                        workspace.getContributions().add(dependency);
+                        contributionMap.put(dependencyURI, dependency);
+                        
+                        if (contributionURI.equals(entry.getKey())) {
+                            contribution = dependency;
+                        }
+                    }
+                }
+            }
+            
+            if (contribution == null) {
+                response.sendError(HttpServletResponse.SC_NOT_FOUND, contributionURI);
+                return;
+            }
+            
+            // Find the specified deployable composite in the contribution
+            Composite deployable = null;
+            QName qn = compositeQName(domainEntry.getKey());
+            for (Composite d: contribution.getDeployables()) {
+                if (qn.equals(d.getName())) {
+                    deployable = d;
+                    break;
+                }
+            }
+            if (deployable == null) {
+                response.sendError(HttpServletResponse.SC_NOT_FOUND, qn.toString());
+                return;
+            }
+            
+            // add the deployable composite to the domain composite
+            domainComposite.getIncludes().add(deployable);
+
+            // Fuse includes into the deployable composite
+            try {
+                compositeIncludeBuilder.build(deployable);
+            } catch (CompositeBuilderException e) {
+                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
+            }
+            
+            // store away the composite we are generating the deployable XML for. 
+            if (qname.equals(deployable.getName())){
+                compositeConfiguration = deployable;
+            }
+        }
+        
+        // Composite not found
+        if (compositeConfiguration == null) {
+            response.sendError(HttpServletResponse.SC_NOT_FOUND, key);
+            return;
+        }
+
+        // Get the clouds composite
+        Composite cloudsComposite;
+        try {
+            cloudsComposite = cloud();
+        } catch (NotFoundException e) {
+            response.sendError(HttpServletResponse.SC_NOT_FOUND, e.getMessage());
+            return;
+        }
+        
+        // configure the endpoints for each composite in the domain
+        List<Composite> domainIncludes = domainComposite.getIncludes(); 
+        for (int i = 0, n =domainIncludes.size(); i < n; i++) {
+            Composite composite = domainIncludes.get(i);
+            QName compositeName = composite.getName();
+            String contributionURI = contributionURI(domainEntries[i].getKey());
+            
+            // find the node that will run this composite and the default
+            // bindings that it configures
+            Component nodeComponent = null;
+            for (Composite cloudComposite : cloudsComposite.getIncludes()) {
+                for (Component nc : cloudComposite.getComponents()) {
+                    NodeImplementation nodeImplementation = (NodeImplementation)nc.getImplementation();
+                    if (nodeImplementation.getComposite().getName().equals(compositeName) &&
+                        nodeImplementation.getComposite().getURI().equals(contributionURI)) {
+                        nodeComponent = nc;
+                        nodeImplementation.setComposite(composite);
+                        break;
+                    }
+                }
+            }
+
+            if (nodeComponent != null) {
+                try {
+                    Composite nodeComposite = assemblyFactory.createComposite();
+                    nodeComposite.getComponents().add(nodeComponent);
+                    nodeConfigurationBuilder.build(nodeComposite);
+                } catch (CompositeBuilderException e) {
+                    throw new ServletException(e);
+                }
+            }
+        }
+        
+        // Build the domain composite
+        try {
+            compositeBuilder.build(domainComposite);
+        } catch (CompositeBuilderException e) {
+            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
+            return;
+        }        
+        
+        // Rebuild the requested composite from the domain composite
+        // we have to reverse the flattening that went on when the domain
+        // composite was built
+        List<Component> tempComponentList = new ArrayList<Component>();
+        tempComponentList.addAll(compositeConfiguration.getComponents());
+        compositeConfiguration.getComponents().clear();
+        for (Component inputComponent : tempComponentList){
+            for (Component deployComponent : domainComposite.getComponents()){
+                if (deployComponent.getName().equals(inputComponent.getName())){
+                    compositeConfiguration.getComponents().add(deployComponent);
+                }
+            }
+        }
+        
+        // Write the deployable composite
+        try {
+            response.setContentType("text/xml");
+            XMLStreamWriter writer = outputFactory.createXMLStreamWriter(response.getOutputStream());
+            compositeProcessor.write(compositeConfiguration, writer);
+        } catch (Exception e) {
+            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
+            return;
+        }
+    }
+
+    /**
+     * Returns the cloud composite.
+     * 
+     * @return the cloud composite
+     */
+    private Composite cloud() throws NotFoundException {
+
+        // Create a new composite for the clouds
+        Composite cloudComposite = assemblyFactory.createComposite();
+        cloudComposite.setName(new QName(Constants.SCA10_TUSCANY_NS, "cloud"));
+        
+        // Get the collection of cloud composites
+        Entry<String, Item>[] cloudEntries = cloudCollection.getAll();
+        
+        // Load the cloud contributions
+        Workspace workspace = workspaceFactory.createWorkspace();
+        Map<String, Contribution> contributionMap = new HashMap<String, Contribution>(); 
+        for (Entry<String, Item> cloudEntry: cloudEntries) {
+            String key = cloudEntry.getKey();
+            String contributionURI = contributionURI(key);
+
+            // Load the contribution
+            Contribution contribution = contributionMap.get(contributionURI);
+            if (contribution == null) {
+                Item contributionItem = contributionCollection.get(contributionURI);
+                
+                // Read the contribution
+                try {
+                    contribution = contribution(workspace, contributionURI, contributionItem.getAlternate());
+                } catch (ContributionReadException e) {
+                    continue;
+                }
+                workspace.getContributions().add(contribution);
+                contributionMap.put(contributionURI, contribution);
+                
+            }
+
+            // Include the cloud composite in the clouds composite
+            QName qname = compositeQName(key);
+            for (Artifact artifact : contribution.getArtifacts()) {
+                if (artifact.getModel() instanceof Composite) {
+                    Composite composite = (Composite)artifact.getModel();
+                    if (composite.getName().equals(qname)) {
+                        cloudComposite.getIncludes().add(composite);
+                    }
+                }
+            } 
+        }
+        
+        return cloudComposite;
+    }
+
+    /**
+     * Returns the contribution with the given URI.
+     * 
+     * @param workspace
+     * @param contributionURI
+     * @param contributionLocation
+     * @return
+     * @throws NotFoundException
+     */
+    private Contribution contribution(Workspace workspace, String contributionURI, String contributionLocation) throws ContributionReadException {
+        try {
+            URI uri = URI.create(contributionURI);
+            URL location = locationURL(contributionLocation);
+            Contribution contribution = (Contribution)contributionProcessor.read(null, uri, location);
+            
+            // Resolve the contribution dependencies
+            contributionDependencyBuilder.buildContributionDependencies(contribution, workspace);
+            
+            contributionProcessor.resolve(contribution, workspace.getModelResolver());
+            return contribution;
+
+        } catch (ContributionReadException e) {
+            throw e;
+        } catch (ContributionResolveException e) {
+            throw new ContributionReadException(e);
+        } catch (MalformedURLException e) {
+            throw new ContributionReadException(e);
+        }
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeConfigurationServiceImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeGeneratorServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeGeneratorServiceImpl.java?rev=655411&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeGeneratorServiceImpl.java (added)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeGeneratorServiceImpl.java Sun May 11 21:48:55 2008
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.domain.manager.impl;
+
+import static org.apache.tuscany.sca.domain.manager.impl.DomainManagerUtil.compositeQName;
+import static org.apache.tuscany.sca.domain.manager.impl.DomainManagerUtil.contributionURI;
+import static org.apache.tuscany.sca.domain.manager.impl.DomainManagerUtil.locationURL;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.util.logging.Logger;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.data.collection.Item;
+import org.apache.tuscany.sca.implementation.data.collection.LocalItemCollection;
+import org.apache.tuscany.sca.implementation.data.collection.NotFoundException;
+import org.apache.tuscany.sca.workspace.processor.impl.ContributionContentProcessor;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Implementation of a service that generates a composite from a composite model. 
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+@Service(interfaces={Servlet.class})
+public class CompositeGeneratorServiceImpl extends HttpServlet implements Servlet {
+    private static final long serialVersionUID = -6531448326726908269L;
+
+    private final static Logger logger = Logger.getLogger(CompositeGeneratorServiceImpl.class.getName());    
+
+    @Reference
+    public LocalItemCollection contributionCollection;
+    
+    @Reference
+    public DomainManagerConfiguration domainManagerConfiguration;
+    
+    private ModelFactoryExtensionPoint modelFactories;
+    private ModelResolverExtensionPoint modelResolvers;
+    private URLArtifactProcessor<Contribution> contributionProcessor;
+    private StAXArtifactProcessor<Composite> compositeProcessor;
+    private XMLOutputFactory outputFactory;
+    
+    /**
+     * Initialize the component.
+     */
+    @Init
+    public void initialize() throws ParserConfigurationException {
+        
+        ExtensionPointRegistry extensionPoints = domainManagerConfiguration.getExtensionPoints();
+        
+        // Get model factories
+        modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
+        XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class);
+        outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
+        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true);
+        
+        // Get and initialize artifact processors
+        StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+        compositeProcessor = (StAXArtifactProcessor<Composite>)staxProcessors.getProcessor(Composite.class);
+        StAXArtifactProcessor<Object> staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+
+        URLArtifactProcessorExtensionPoint urlProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+        URLArtifactProcessor<Object> urlProcessor = new ExtensibleURLArtifactProcessor(urlProcessors);
+        
+        // Create contribution processor
+        modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class);
+        contributionProcessor = new ContributionContentProcessor(modelFactories, modelResolvers, urlProcessor, staxProcessor);
+    }
+    
+    @Override
+    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+        // Expect a key in the form
+        // composite:contributionURI;namespace;localName
+        // and return the corresponding source file
+        
+        // Get the request path
+        String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+        String key = path.startsWith("/")? path.substring(1) : path;
+        logger.fine("get " + key);
+        
+        // Get the specified contribution info 
+        String contributionURI = contributionURI(key);
+        Item contributionItem;
+        try {
+            contributionItem = contributionCollection.get(contributionURI);
+        } catch (NotFoundException e) {
+            response.sendError(HttpServletResponse.SC_NOT_FOUND, key);
+            return;
+        }
+        
+        // Read the contribution
+        Contribution contribution;
+        try {
+            contribution = contribution(contributionURI, contributionItem.getAlternate());
+        } catch (ContributionReadException e) {
+            response.sendError(HttpServletResponse.SC_NOT_FOUND, key);
+            return;
+        }
+
+        // Find the specified deployable composite
+        QName qname = compositeQName(key);
+        Composite composite = null;
+        for (Composite deployable: contribution.getDeployables()) {
+            if (qname.equals(deployable.getName())) {
+                if (!deployable.isUnresolved()) {
+                    composite = deployable;
+                }
+                break;
+            }
+        }
+        if (composite == null) {
+            response.sendError(HttpServletResponse.SC_NOT_FOUND, key);
+            return;
+        }
+        
+        // Write the composite
+        response.setContentType("text/xml");
+        ServletOutputStream os = response.getOutputStream();
+        try {
+            compositeProcessor.write(composite, outputFactory.createXMLStreamWriter(os));
+        } catch (ContributionWriteException e) {
+            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
+            return;
+        } catch (XMLStreamException e) {
+            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
+            return;
+        }
+        os.flush();
+    }
+
+    /**
+     * Returns the contribution with the given URI.
+     * 
+     * @param contributionURI
+     * @param contributionLocation
+     * @return
+     * @throws NotFoundException
+     */
+    private Contribution contribution(String contributionURI, String contributionLocation) throws ContributionReadException {
+        try {
+            URI uri = URI.create(contributionURI);
+            URL location = locationURL(contributionLocation);
+            Contribution contribution = (Contribution)contributionProcessor.read(null, uri, location);
+            
+            contributionProcessor.resolve(contribution, new DefaultModelResolver());
+            return contribution;
+
+        } catch (ContributionReadException e) {
+            throw e;
+        } catch (MalformedURLException e) {
+            throw new ContributionReadException(e);
+        } catch (ContributionResolveException e) {
+            throw new ContributionReadException(e);
+        }
+    }
+    
+}

Propchange: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeGeneratorServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeGeneratorServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/CompositeGeneratorServiceImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/ContributionCollectionImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/ContributionCollectionImpl.java?rev=655411&r1=655410&r2=655411&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/ContributionCollectionImpl.java (original)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/ContributionCollectionImpl.java Sun May 11 21:48:55 2008
@@ -62,7 +62,6 @@
 import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
 import org.apache.tuscany.sca.contribution.service.ContributionReadException;
-import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.core.UtilityExtensionPoint;
 import org.apache.tuscany.sca.implementation.data.collection.Entry;
@@ -93,9 +92,8 @@
  * @version $Rev$ $Date$
  */
 @Scope("COMPOSITE")
-@Service(interfaces={ItemCollection.class, LocalItemCollection.class, Servlet.class})
-public class ContributionCollectionImpl extends HttpServlet implements ItemCollection, LocalItemCollection {
-    private static final long serialVersionUID = -4759297945439322773L;
+@Service(interfaces={ItemCollection.class, LocalItemCollection.class})
+public class ContributionCollectionImpl implements ItemCollection, LocalItemCollection {
 
     private final static Logger logger = Logger.getLogger(ContributionCollectionImpl.class.getName());    
 
@@ -106,9 +104,8 @@
     public String deploymentContributionDirectory;
     
     @Reference
-    public LauncherConfiguration launcherConfiguration;
+    public DomainManagerConfiguration domainManagerConfiguration;
     
-    private ExtensionPointRegistry extensionPoints;
     private Monitor monitor;
     private ContributionFactory contributionFactory;
     private WorkspaceFactory workspaceFactory;
@@ -124,7 +121,7 @@
     @Init
     public void initialize() throws ParserConfigurationException {
         
-        extensionPoints = new DefaultExtensionPointRegistry();
+        ExtensionPointRegistry extensionPoints = domainManagerConfiguration.getExtensionPoints();
         
         // Create a validation monitor
         UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
@@ -181,29 +178,6 @@
         throw new NotFoundException(key);
     }
     
-    @Override
-    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-
-        // Get the request path
-        String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
-
-        // The key is the contribution URI
-        String key = path.startsWith("/")? path.substring(1) : path;
-        logger.fine("get " + key);
-        
-        // Get the item describing the composite
-        Item item;
-        try {
-            item = get(key);
-        } catch (NotFoundException e) {
-            response.sendError(HttpServletResponse.SC_NOT_FOUND, key);
-            return;
-        }
-
-        // Redirect to the actual contribution location
-        response.sendRedirect("/files/" + item.getAlternate());
-    }
-
     public String post(String key, Item item) {
         logger.fine("post " + key);
         
@@ -420,7 +394,7 @@
      * @return
      */
     private Workspace readWorkspace() {
-        String rootDirectory = launcherConfiguration.getRootDirectory();
+        String rootDirectory = domainManagerConfiguration.getRootDirectory();
         
         Workspace workspace;
         File file = new File(rootDirectory + "/" + workspaceFile);
@@ -463,7 +437,7 @@
      */
     private void writeWorkspace(Workspace workspace) {
         try {
-            String rootDirectory = launcherConfiguration.getRootDirectory();
+            String rootDirectory = domainManagerConfiguration.getRootDirectory();
             
             // First write to a byte stream
             ByteArrayOutputStream bos = new ByteArrayOutputStream();

Added: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/ContributionServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/ContributionServiceImpl.java?rev=655411&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/ContributionServiceImpl.java (added)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/ContributionServiceImpl.java Sun May 11 21:48:55 2008
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.domain.manager.impl;
+
+import java.io.IOException;
+import java.net.URLDecoder;
+import java.util.logging.Logger;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tuscany.sca.implementation.data.collection.Item;
+import org.apache.tuscany.sca.implementation.data.collection.LocalItemCollection;
+import org.apache.tuscany.sca.implementation.data.collection.NotFoundException;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Implementation of a contribution collection service component. 
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+@Service(interfaces={Servlet.class})
+public class ContributionServiceImpl extends HttpServlet implements Servlet {
+    private static final long serialVersionUID = -4759297945439322773L;
+
+    private final static Logger logger = Logger.getLogger(ContributionServiceImpl.class.getName());    
+
+    @Reference
+    public LocalItemCollection contributionCollection;
+    
+    @Override
+    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+        // Get the request path
+        String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+
+        // The key is the contribution URI
+        String key = path.startsWith("/")? path.substring(1) : path;
+        logger.fine("get " + key);
+        
+        // Get the item describing the composite
+        Item item;
+        try {
+            item = contributionCollection.get(key);
+        } catch (NotFoundException e) {
+            response.sendError(HttpServletResponse.SC_NOT_FOUND, key);
+            return;
+        }
+
+        // Redirect to the actual contribution location
+        response.sendRedirect("/files/" + item.getAlternate());
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/ContributionServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/ContributionServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/ContributionServiceImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployableCompositeCollectionImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployableCompositeCollectionImpl.java?rev=655411&r1=655410&r2=655411&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployableCompositeCollectionImpl.java (original)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployableCompositeCollectionImpl.java Sun May 11 21:48:55 2008
@@ -26,44 +26,24 @@
 import static org.apache.tuscany.sca.domain.manager.impl.DomainManagerUtil.compositeTitle;
 import static org.apache.tuscany.sca.domain.manager.impl.DomainManagerUtil.contributionURI;
 import static org.apache.tuscany.sca.domain.manager.impl.DomainManagerUtil.locationURL;
-import static org.apache.tuscany.sca.domain.manager.impl.DomainManagerUtil.newRuntime;
 
-import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
-import java.net.URLDecoder;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.logging.Logger;
 
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import javax.xml.namespace.QName;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamWriter;
 
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
 import org.apache.tuscany.sca.assembly.Binding;
 import org.apache.tuscany.sca.assembly.Component;
 import org.apache.tuscany.sca.assembly.ComponentService;
 import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.SCABindingFactory;
-import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
-import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
-import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl;
-import org.apache.tuscany.sca.assembly.builder.impl.CompositeIncludeBuilderImpl;
-import org.apache.tuscany.sca.assembly.xml.Constants;
-import org.apache.tuscany.sca.contribution.Artifact;
 import org.apache.tuscany.sca.contribution.Contribution;
-import org.apache.tuscany.sca.contribution.ContributionFactory;
 import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
 import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor;
@@ -72,29 +52,19 @@
 import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint;
 import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
-import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
 import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
 import org.apache.tuscany.sca.contribution.service.ContributionReadException;
 import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
-import org.apache.tuscany.sca.contribution.xml.ContributionGeneratedMetadataDocumentProcessor;
-import org.apache.tuscany.sca.contribution.xml.ContributionMetadataDocumentProcessor;
-import org.apache.tuscany.sca.contribution.xml.ContributionMetadataProcessor;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-import org.apache.tuscany.sca.host.embedded.impl.ReallySmallRuntime;
 import org.apache.tuscany.sca.implementation.data.collection.Entry;
 import org.apache.tuscany.sca.implementation.data.collection.Item;
 import org.apache.tuscany.sca.implementation.data.collection.ItemCollection;
 import org.apache.tuscany.sca.implementation.data.collection.LocalItemCollection;
 import org.apache.tuscany.sca.implementation.data.collection.NotFoundException;
 import org.apache.tuscany.sca.implementation.node.NodeImplementation;
-import org.apache.tuscany.sca.implementation.node.builder.impl.NodeCompositeBuilderImpl;
-import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
 import org.apache.tuscany.sca.monitor.Monitor;
 import org.apache.tuscany.sca.monitor.MonitorFactory;
-import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
-import org.apache.tuscany.sca.workspace.Workspace;
-import org.apache.tuscany.sca.workspace.WorkspaceFactory;
 import org.apache.tuscany.sca.workspace.builder.ContributionDependencyBuilder;
 import org.apache.tuscany.sca.workspace.builder.impl.ContributionDependencyBuilderImpl;
 import org.apache.tuscany.sca.workspace.processor.impl.ContributionContentProcessor;
@@ -109,32 +79,22 @@
  * @version $Rev$ $Date$
  */
 @Scope("COMPOSITE")
-@Service(interfaces={ItemCollection.class, LocalItemCollection.class, Servlet.class})
-public class DeployableCompositeCollectionImpl extends HttpServlet implements ItemCollection, LocalItemCollection {
-    private static final long serialVersionUID = -8809641932774129151L;
-    
+@Service(interfaces={ItemCollection.class, LocalItemCollection.class})
+public class DeployableCompositeCollectionImpl implements ItemCollection, LocalItemCollection {
+
     private final static Logger logger = Logger.getLogger(DeployableCompositeCollectionImpl.class.getName());    
 
     @Reference
     public LocalItemCollection contributionCollection;
     
-    @Reference 
-    public LocalItemCollection domainCompositeCollection;
+    @Reference
+    public DomainManagerConfiguration domainManagerConfiguration;
     
-    @Reference 
-    public LocalItemCollection cloudCollection;    
-
     private ModelFactoryExtensionPoint modelFactories;
     private ModelResolverExtensionPoint modelResolvers;
-    private AssemblyFactory assemblyFactory;
-    private WorkspaceFactory workspaceFactory;
     private URLArtifactProcessor<Contribution> contributionProcessor;
-    private StAXArtifactProcessor<Composite> compositeProcessor;
     private XMLOutputFactory outputFactory;
     private ContributionDependencyBuilder contributionDependencyBuilder;
-    private CompositeBuilder compositeBuilder;
-    private CompositeBuilder compositeIncludeBuilder;
-    private CompositeBuilder nodeConfigurationBuilder;
     private Monitor monitor;
     
     /**
@@ -143,22 +103,16 @@
     @Init
     public void initialize() throws ParserConfigurationException {
         
-        // FIXME Remove this later
-        ReallySmallRuntime runtime = newRuntime();
-        
-        ExtensionPointRegistry extensionPoints = runtime.getExtensionPointRegistry();
+        ExtensionPointRegistry extensionPoints = domainManagerConfiguration.getExtensionPoints();
         
         // Get model factories
         modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
-        assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
         XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class);
         outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
         outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true);
-        workspaceFactory = modelFactories.getFactory(WorkspaceFactory.class);
         
         // Get and initialize artifact processors
         StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
-        compositeProcessor = (StAXArtifactProcessor<Composite>)staxProcessors.getProcessor(Composite.class);
         StAXArtifactProcessor<Object> staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
 
         URLArtifactProcessorExtensionPoint urlProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
@@ -175,12 +129,6 @@
         
         // Create contribution and composite builders
         contributionDependencyBuilder = new ContributionDependencyBuilderImpl(monitor);
-        SCABindingFactory scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class);
-        IntentAttachPointTypeFactory intentAttachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class);
-        InterfaceContractMapper contractMapper = utilities.getUtility(InterfaceContractMapper.class);
-        compositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory, intentAttachPointTypeFactory, contractMapper, monitor);
-        compositeIncludeBuilder = new CompositeIncludeBuilderImpl(monitor);
-        nodeConfigurationBuilder = new NodeCompositeBuilderImpl(assemblyFactory, scaBindingFactory, contractMapper, null, monitor);
     }
     
     public Entry<String, Item>[] getAll() {
@@ -241,7 +189,7 @@
 
         throw new NotFoundException(key);
     }
-
+    
     public String post(String key, Item item) {
         throw new UnsupportedOperationException();
     }
@@ -292,267 +240,6 @@
         }
     }
     
-    @Override
-    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-        
-        // Get the request path
-        String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
-        String key = path.startsWith("/")? path.substring(1) : path;
-        logger.fine("get " + key);
-        
-        // Expect a key in the form
-        // composite:contributionURI;namespace;localName
-        // and return the corresponding resolved composite
-        
-        // Extract the composite qname from the key
-        QName qname = compositeQName(key);
-        
-        // Somewhere to store the composite we expect to write out at the end
-        Composite compositeConfiguration = null;
-
-        // Create a domain composite model
-        Composite domainComposite = assemblyFactory.createComposite();
-        domainComposite.setName(new QName(Constants.SCA10_TUSCANY_NS, "domain"));
-            
-        // Get the domain composite items
-        Entry<String, Item>[] domainEntries = domainCompositeCollection.getAll();
-        
-        // Populate the domain composite
-        Workspace workspace = workspaceFactory.createWorkspace();
-        workspace.setModelResolver(new ExtensibleModelResolver(workspace, modelResolvers, modelFactories));
-        
-        Map<String, Contribution> contributionMap = new HashMap<String, Contribution>(); 
-        for (Entry<String, Item> domainEntry: domainEntries) {
-            
-            // Load the required contributions
-            String contributionURI = contributionURI(domainEntry.getKey());
-            Contribution contribution = contributionMap.get(contributionURI);
-            if (contribution == null) {
-                
-                // The contribution has not been loaded yet, load it with all its dependencies
-                Entry<String, Item>[] entries = contributionCollection.query("alldependencies=" + contributionURI);
-                for (Entry<String, Item> entry: entries) {
-                    Item dependencyItem = entry.getData();
-                    String dependencyURI = entry.getKey();
-                    
-                    if (!contributionMap.containsKey(dependencyURI)) {
-                        
-                        // Read the contribution
-                        Contribution dependency;
-                        try {
-                            String dependencyLocation = dependencyItem.getAlternate();
-                            dependency = contribution(workspace, dependencyURI, dependencyLocation);
-                        } catch (ContributionReadException e) {
-                            continue;
-                        }
-                        workspace.getContributions().add(dependency);
-                        contributionMap.put(dependencyURI, dependency);
-                        
-                        if (contributionURI.equals(entry.getKey())) {
-                            contribution = dependency;
-                        }
-                    }
-                }
-            }
-            
-            if (contribution == null) {
-                response.sendError(HttpServletResponse.SC_NOT_FOUND, contributionURI);
-                return;
-            }
-            
-            // Find the specified deployable composite in the contribution
-            Composite deployable = null;
-            QName qn = compositeQName(domainEntry.getKey());
-            for (Composite d: contribution.getDeployables()) {
-                if (qn.equals(d.getName())) {
-                    deployable = d;
-                    break;
-                }
-            }
-            if (deployable == null) {
-                response.sendError(HttpServletResponse.SC_NOT_FOUND, qn.toString());
-                return;
-            }
-            
-            // add the deployable composite to the domain composite
-            domainComposite.getIncludes().add(deployable);
-
-            // Fuse includes into the deployable composite
-            try {
-                compositeIncludeBuilder.build(deployable);
-            } catch (CompositeBuilderException e) {
-                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
-            }
-            
-            // store away the composite we are generating the deployable XML for. 
-            if (qname.equals(deployable.getName())){
-                compositeConfiguration = deployable;
-            }
-        }
-        
-        // Composite not found
-        if (compositeConfiguration == null) {
-            response.sendError(HttpServletResponse.SC_NOT_FOUND, key);
-            return;
-        }
-
-        // Get the clouds composite
-        Composite cloudsComposite;
-        try {
-            cloudsComposite = cloud();
-        } catch (NotFoundException e) {
-            response.sendError(HttpServletResponse.SC_NOT_FOUND, e.getMessage());
-            return;
-        }
-        
-        // configure the endpoints for each composite in the domain
-        List<Composite> domainIncludes = domainComposite.getIncludes(); 
-        for (int i = 0, n =domainIncludes.size(); i < n; i++) {
-            Composite composite = domainIncludes.get(i);
-            QName compositeName = composite.getName();
-            String contributionURI = contributionURI(domainEntries[i].getKey());
-            
-            // find the node that will run this composite and the default
-            // bindings that it configures
-            Component nodeComponent = null;
-            for (Composite cloudComposite : cloudsComposite.getIncludes()) {
-                for (Component nc : cloudComposite.getComponents()) {
-                    NodeImplementation nodeImplementation = (NodeImplementation)nc.getImplementation();
-                    if (nodeImplementation.getComposite().getName().equals(compositeName) &&
-                        nodeImplementation.getComposite().getURI().equals(contributionURI)) {
-                        nodeComponent = nc;
-                        nodeImplementation.setComposite(composite);
-                        break;
-                    }
-                }
-            }
-
-            if (nodeComponent != null) {
-                try {
-                    Composite nodeComposite = assemblyFactory.createComposite();
-                    nodeComposite.getComponents().add(nodeComponent);
-                    nodeConfigurationBuilder.build(nodeComposite);
-                } catch (CompositeBuilderException e) {
-                    throw new ServletException(e);
-                }
-            }
-        }
-        
-        // Build the domain composite
-        try {
-            compositeBuilder.build(domainComposite);
-        } catch (CompositeBuilderException e) {
-            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
-            return;
-        }        
-        
-        // Rebuild the requested composite from the domain composite
-        // we have to reverse the flattening that went on when the domain
-        // composite was built
-        List<Component> tempComponentList = new ArrayList<Component>();
-        tempComponentList.addAll(compositeConfiguration.getComponents());
-        compositeConfiguration.getComponents().clear();
-        for (Component inputComponent : tempComponentList){
-            for (Component deployComponent : domainComposite.getComponents()){
-                if (deployComponent.getName().equals(inputComponent.getName())){
-                    compositeConfiguration.getComponents().add(deployComponent);
-                }
-            }
-        }
-        
-        // Write the deployable composite
-        try {
-            response.setContentType("text/xml");
-            XMLStreamWriter writer = outputFactory.createXMLStreamWriter(response.getOutputStream());
-            compositeProcessor.write(compositeConfiguration, writer);
-        } catch (Exception e) {
-            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
-            return;
-        }
-    }
-
-    /**
-     * Returns the cloud composite.
-     * 
-     * @return the cloud composite
-     */
-    private Composite cloud() throws NotFoundException {
-
-        // Create a new composite for the clouds
-        Composite cloudComposite = assemblyFactory.createComposite();
-        cloudComposite.setName(new QName(Constants.SCA10_TUSCANY_NS, "cloud"));
-        
-        // Get the collection of cloud composites
-        Entry<String, Item>[] cloudEntries = cloudCollection.getAll();
-        
-        // Load the cloud contributions
-        Workspace workspace = workspaceFactory.createWorkspace();
-        Map<String, Contribution> contributionMap = new HashMap<String, Contribution>(); 
-        for (Entry<String, Item> cloudEntry: cloudEntries) {
-            String key = cloudEntry.getKey();
-            String contributionURI = contributionURI(key);
-
-            // Load the contribution
-            Contribution contribution = contributionMap.get(contributionURI);
-            if (contribution == null) {
-                Item contributionItem = contributionCollection.get(contributionURI);
-                
-                // Read the contribution
-                try {
-                    contribution = contribution(workspace, contributionURI, contributionItem.getAlternate());
-                } catch (ContributionReadException e) {
-                    continue;
-                }
-                workspace.getContributions().add(contribution);
-                contributionMap.put(contributionURI, contribution);
-                
-            }
-
-            // Include the cloud composite in the clouds composite
-            QName qname = compositeQName(key);
-            for (Artifact artifact : contribution.getArtifacts()) {
-                if (artifact.getModel() instanceof Composite) {
-                    Composite composite = (Composite)artifact.getModel();
-                    if (composite.getName().equals(qname)) {
-                        cloudComposite.getIncludes().add(composite);
-                    }
-                }
-            } 
-        }
-        
-        return cloudComposite;
-    }
-
-    /**
-     * Returns the contribution with the given URI.
-     * 
-     * @param workspace
-     * @param contributionURI
-     * @param contributionLocation
-     * @return
-     * @throws NotFoundException
-     */
-    private Contribution contribution(Workspace workspace, String contributionURI, String contributionLocation) throws ContributionReadException {
-        try {
-            URI uri = URI.create(contributionURI);
-            URL location = locationURL(contributionLocation);
-            Contribution contribution = (Contribution)contributionProcessor.read(null, uri, location);
-            
-            // Resolve the contribution dependencies
-            contributionDependencyBuilder.buildContributionDependencies(contribution, workspace);
-            
-            contributionProcessor.resolve(contribution, workspace.getModelResolver());
-            return contribution;
-
-        } catch (ContributionReadException e) {
-            throw e;
-        } catch (ContributionResolveException e) {
-            throw new ContributionReadException(e);
-        } catch (MalformedURLException e) {
-            throw new ContributionReadException(e);
-        }
-    }
-
     /**
      * Returns the contribution with the given URI.
      * 

Added: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployableCompositeServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployableCompositeServiceImpl.java?rev=655411&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployableCompositeServiceImpl.java (added)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployableCompositeServiceImpl.java Sun May 11 21:48:55 2008
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.domain.manager.impl;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLDecoder;
+import java.util.logging.Logger;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.data.collection.Item;
+import org.apache.tuscany.sca.implementation.data.collection.LocalItemCollection;
+import org.apache.tuscany.sca.implementation.data.collection.NotFoundException;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Implementation of a service that returns the source of a deployable composite. 
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+@Service(Servlet.class)
+public class DeployableCompositeServiceImpl extends HttpServlet implements Servlet {
+    private static final long serialVersionUID = -3477992129462720902L;
+
+    private final static Logger logger = Logger.getLogger(DeployableCompositeServiceImpl.class.getName());    
+
+    @Reference
+    public DomainManagerConfiguration domainManagerConfiguration;
+    
+    @Reference
+    public LocalItemCollection deployableCollection;
+    
+    /**
+     * Initialize the component.
+     */
+    @Init
+    public void initialize() throws ParserConfigurationException {
+        
+        ExtensionPointRegistry extensionPoints = domainManagerConfiguration.getExtensionPoints();
+    }
+    
+    @Override
+    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+        // Expect a key in the form
+        // composite:contributionURI;namespace;localName
+        // and return the corresponding source file
+        
+        // Get the request path
+        String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+        String key = path.startsWith("/")? path.substring(1) : path;
+        logger.fine("get " + key);
+        
+        // Get the item describing the composite
+        Item item;
+        try {
+            item = deployableCollection.get(key);
+        } catch (NotFoundException e) {
+            response.sendError(HttpServletResponse.SC_NOT_FOUND, key);
+            return;
+        }
+
+        // Redirect if there is no composite file
+        String uri = item.getAlternate();
+        if (uri == null) {
+            response.sendRedirect("/composite-generated/" + key);
+            return;
+        }
+        
+        // Read the composite file and write to response
+        InputStream is;
+        try {
+            URLConnection connection = new URL(uri).openConnection();
+            connection.setUseCaches(false);
+            connection.connect();
+            is = connection.getInputStream();
+        } catch (FileNotFoundException ex) {
+            response.sendError(HttpServletResponse.SC_NOT_FOUND, key);
+            return;
+        }
+
+        response.setContentType("text/xml");
+        ServletOutputStream os = response.getOutputStream();
+        byte[] buffer = new byte[4096];
+        for (;;) {
+            int n = is.read(buffer);
+            if (n < 0) {
+                break;
+            }
+            os.write(buffer, 0, n);
+        }
+        is.close();
+        os.flush();
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployableCompositeServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployableCompositeServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployableCompositeServiceImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployedCompositeCollectionImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployedCompositeCollectionImpl.java?rev=655411&r1=655410&r2=655411&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployedCompositeCollectionImpl.java (original)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DeployedCompositeCollectionImpl.java Sun May 11 21:48:55 2008
@@ -61,18 +61,15 @@
 import org.apache.tuscany.sca.assembly.AssemblyFactory;
 import org.apache.tuscany.sca.assembly.Composite;
 import org.apache.tuscany.sca.assembly.xml.Constants;
-import org.apache.tuscany.sca.contribution.ContributionFactory;
 import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
-import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.implementation.data.collection.Entry;
 import org.apache.tuscany.sca.implementation.data.collection.Item;
 import org.apache.tuscany.sca.implementation.data.collection.ItemCollection;
 import org.apache.tuscany.sca.implementation.data.collection.LocalItemCollection;
 import org.apache.tuscany.sca.implementation.data.collection.NotFoundException;
-import org.apache.tuscany.sca.policy.PolicyFactory;
 import org.apache.xml.serialize.OutputFormat;
 import org.apache.xml.serialize.XMLSerializer;
 import org.osoa.sca.ServiceRuntimeException;
@@ -108,9 +105,8 @@
     public LocalItemCollection processCollection;
 
     @Reference
-    public LauncherConfiguration launcherConfiguration;
+    public DomainManagerConfiguration domainManagerConfiguration;
     
-    private ExtensionPointRegistry extensionPoints;
     private ModelFactoryExtensionPoint modelFactories;
     private AssemblyFactory assemblyFactory;
     private StAXArtifactProcessor<Composite> compositeProcessor;
@@ -124,15 +120,13 @@
     public void initialize() throws ParserConfigurationException {
         
         // Create factories
-        extensionPoints = new DefaultExtensionPointRegistry();
+        ExtensionPointRegistry extensionPoints = domainManagerConfiguration.getExtensionPoints();
         modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
         assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
         outputFactory = modelFactories.getFactory(XMLOutputFactory.class);
         outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true);
         
         // Create composite processor
-        ContributionFactory contributionFactory = modelFactories.getFactory(ContributionFactory.class);
-        PolicyFactory policyFactory = modelFactories.getFactory(PolicyFactory.class);
         StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
         compositeProcessor = staxProcessors.getProcessor(Composite.class);
 
@@ -250,7 +244,7 @@
         // under the deployment composites directory, if that directory is
         // configured on this component
         if (deploymentContributionDirectory != null && item.getContents() != null) {
-            String rootDirectory = launcherConfiguration.getRootDirectory();
+            String rootDirectory = domainManagerConfiguration.getRootDirectory();
             
             File directory = new File(rootDirectory + "/" + deploymentContributionDirectory);
             if (!directory.exists()) {
@@ -329,7 +323,7 @@
 
         // Delete the file too if it is in the deployment contribution directory
         if (deploymentContributionDirectory != null && contributionURI.equals(DEPLOYMENT_CONTRIBUTION_URI)) {
-            String rootDirectory = launcherConfiguration.getRootDirectory();
+            String rootDirectory = domainManagerConfiguration.getRootDirectory();
             
             File file = new File(rootDirectory + "/" + deploymentContributionDirectory, qname.getLocalPart() + ".composite");
             if (file.exists()) {
@@ -353,7 +347,7 @@
      * @throws ServiceRuntimeException
      */
     private Composite readCompositeCollection() throws ServiceRuntimeException {
-        String rootDirectory = launcherConfiguration.getRootDirectory();
+        String rootDirectory = domainManagerConfiguration.getRootDirectory();
         
         Composite compositeCollection;
         File file = new File(rootDirectory + "/" + compositeFile);
@@ -387,7 +381,7 @@
      */
     private void writeCompositeCollection(Composite compositeCollection) {
         try {
-            String rootDirectory = launcherConfiguration.getRootDirectory();
+            String rootDirectory = domainManagerConfiguration.getRootDirectory();
             
             // First write to a byte stream
             ByteArrayOutputStream bos = new ByteArrayOutputStream();

Copied: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerConfiguration.java (from r653300, incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/LauncherConfiguration.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerConfiguration.java?p2=incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerConfiguration.java&p1=incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/LauncherConfiguration.java&r1=653300&r2=655411&rev=655411&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/LauncherConfiguration.java (original)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerConfiguration.java Sun May 11 21:48:55 2008
@@ -19,12 +19,14 @@
 
 package org.apache.tuscany.sca.domain.manager.impl;
 
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+
 /**
  * Domain manager configuration service interface.
  *
  * @version $Rev$ $Date$
  */
-public interface LauncherConfiguration {
+public interface DomainManagerConfiguration {
     
     /**
      * Sets the domain manager root directory.
@@ -39,5 +41,13 @@
      * @return the domain manager root directory
      */
     String getRootDirectory();
+    
+    /**
+     * Returns the extension point registry used in the
+     * domain manager.
+     * 
+     * @return
+     */
+    ExtensionPointRegistry getExtensionPoints();
 
 }

Propchange: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerConfiguration.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerConfiguration.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerConfigurationImpl.java (from r653300, incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/LauncherConfigurationImpl.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerConfigurationImpl.java?p2=incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerConfigurationImpl.java&p1=incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/LauncherConfigurationImpl.java&r1=653300&r2=655411&rev=655411&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/LauncherConfigurationImpl.java (original)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerConfigurationImpl.java Sun May 11 21:48:55 2008
@@ -19,6 +19,12 @@
 
 package org.apache.tuscany.sca.domain.manager.impl;
 
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ModuleActivator;
+import org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
 import org.osoa.sca.annotations.Scope;
 import org.osoa.sca.annotations.Service;
 
@@ -28,10 +34,42 @@
  * @version $Rev$ $Date$
  */
 @Scope("COMPOSITE")
-@Service(LauncherConfiguration.class)
-public class LauncherConfigurationImpl implements LauncherConfiguration {
+@Service(DomainManagerConfiguration.class)
+public class DomainManagerConfigurationImpl implements DomainManagerConfiguration {
 
     private String rootDirectory = ".";
+    private ExtensionPointRegistry extensionPoints;
+    
+    @Init
+    public void initialize() {
+        
+        // Create extension point registry
+        extensionPoints = new DefaultExtensionPointRegistry();
+
+        // Initialize module activators
+        ModuleActivatorExtensionPoint moduleActivators = extensionPoints.getExtensionPoint(ModuleActivatorExtensionPoint.class);
+        for (ModuleActivator activator: moduleActivators.getModuleActivators()) {
+            try {
+                activator.start(extensionPoints);
+            } catch (Exception e) {
+                //FIXME fix the module activators that have cross module dependencies
+                // and currently fail when the whole runtime is not present 
+            }
+        }
+    }
+    
+    @Destroy
+    public void destroy() {
+        ModuleActivatorExtensionPoint moduleActivators = extensionPoints.getExtensionPoint(ModuleActivatorExtensionPoint.class);
+        for (ModuleActivator activator: moduleActivators.getModuleActivators()) {
+            try {
+                activator.stop(extensionPoints);
+            } catch (Exception e) {
+                //FIXME fix the module activators that have cross module dependencies
+                // and currently fail when the whole runtime is not present 
+            }
+        }
+    }
     
     public String getRootDirectory() {
         return rootDirectory;
@@ -40,4 +78,8 @@
     public void setRootDirectory(String rootDirectory) {
         this.rootDirectory = rootDirectory;
     }
+    
+    public ExtensionPointRegistry getExtensionPoints() {
+        return extensionPoints;
+    }
 }

Propchange: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerConfigurationImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerConfigurationImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainManagerConfigurationImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message