You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2008/04/25 18:12:55 UTC

svn commit: r651636 [2/2] - in /incubator/tuscany/java/sca: distribution/bundle/ distribution/manifest/ itest/osgi-tuscany/tuscany-runtime/ modules/ modules/domain-manager/ modules/domain-manager/src/ modules/domain-manager/src/main/java/org/apache/tus...

Added: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainAdminUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainAdminUtil.java?rev=651636&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainAdminUtil.java (added)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/DomainAdminUtil.java Fri Apr 25 09:12:51 2008
@@ -0,0 +1,246 @@
+/*
+ * 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.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.core.assembly.ActivationException;
+import org.apache.tuscany.sca.core.assembly.CompositeActivator;
+import org.apache.tuscany.sca.core.context.ServiceReferenceImpl;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.host.embedded.impl.ReallySmallRuntime;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.ServiceRuntimeException;
+
+/**
+ * Common functions and constants used by the admin components.
+ *
+ * @version $Rev$ $Date$
+ */
+public final class DomainAdminUtil {
+
+    static final String DEPLOYMENT_CONTRIBUTION_URI = "http://tuscany.apache.org/cloud";
+
+    /**
+     * Extracts a qname from a key expressed as contributionURI;namespace;localpart.
+     * @param key
+     * @return
+     */
+    static QName compositeQName(String key) {
+        int i = key.indexOf(';');
+        key = key.substring(i + 1);
+        i = key.indexOf(';');
+        return new QName(key.substring(0, i), key.substring(i + 1));
+    }
+
+    /**
+     * Returns a composite title expressed as contributionURI - namespace;localpart.
+     * @param qname
+     * @return
+     */
+    static String compositeTitle(String uri, QName qname) {
+        if (uri.equals(DEPLOYMENT_CONTRIBUTION_URI)) {
+            return qname.getLocalPart();
+        } else {
+            return uri + " - " + qname.getNamespaceURI() + ";" + qname.getLocalPart();
+        }
+    }
+
+    /**
+     * Extracts a contribution uri from a key expressed as contributionURI;namespace;localpart.
+     * @param key
+     * @return
+     */
+    static String contributionURI(String key) {
+        int i = key.indexOf(';');
+        return key.substring("composite:".length(), i);
+    }
+
+    /**
+     * Returns a composite key expressed as contributionURI;namespace;localpart.
+     * @param qname
+     * @return
+     */
+    static String compositeKey(String uri, QName qname) {
+        return "composite:" + uri + ';' + qname.getNamespaceURI() + ';' + qname.getLocalPart();
+    }
+
+    /**
+     * Returns a link to the source of a composite
+     * @param contributionURI
+     * @param qname
+     * @return
+     */
+    static String compositeSourceLink(String contributionURI, QName qname) {
+        return "/composite-source/" + compositeKey(contributionURI, qname);
+    }
+
+    /**
+     * Returns a composite title expressed as contributionURI - namespace;localpart.
+     * @param qname
+     * @return
+     */
+    static String compositeSimpleTitle(String uri, QName qname) {
+        if (uri.equals(DomainAdminUtil.DEPLOYMENT_CONTRIBUTION_URI)) {
+            return qname.getLocalPart();
+        } else {
+            return qname.getNamespaceURI() + ";" + qname.getLocalPart();
+        }
+    }
+
+    /**
+     * Returns a URL from a location string.
+     * @param location
+     * @return
+     * @throws MalformedURLException
+     */
+    static URL locationURL(String location) throws MalformedURLException {
+        URI uri = URI.create(location);
+        String scheme = uri.getScheme();
+        if (scheme == null) {
+            File file = new File(location);
+            return file.toURI().toURL();
+        } else if (scheme.equals("file")) {
+            File file = new File(location.substring(5));
+            return file.toURI().toURL();
+        } else {
+            return uri.toURL();
+        }
+    }
+
+    /**
+     * Returns a link to a deployable composite.
+     * 
+     * If the containing contribution is a local directory, return the URI of  the local composite file
+     * inside the contribution.
+     * 
+     * If the containing contribution is a local or remote file, return a URI of the form:
+     * jar: contribution URI !/ composite URI.
+     *  
+     * @param contributionLocation
+     * @param deployableURI
+     * @return
+     */
+    static String compositeAlternateLink(String contributionLocation, String deployableURI) {
+        URI uri = URI.create(contributionLocation);
+        if ("file".equals(uri.getScheme())) {
+            String path = uri.toString().substring(5);
+            File file = new File(path);
+            if (file.isDirectory()) {
+                if (contributionLocation.endsWith("/")) {
+                    return contributionLocation + deployableURI;
+                } else {
+                    return contributionLocation + "/" + deployableURI;
+                }
+            } else {
+                return contributionLocation + "!/" + deployableURI; 
+            }
+        } else {
+            return contributionLocation + "!/" + deployableURI;
+        }
+    }
+
+    /**
+     * Extract a node URI from an ATOM entry content.
+     * 
+     * @param content
+     * @return
+     */
+    static String nodeURI(String content) {
+        if (content != null) {
+            int bs = content.indexOf("<span id=\"nodeURI\">");
+            if (bs != -1) {
+                content = content.substring(bs + 19);
+                int es = content.indexOf("</span>");
+                if (es != -1) {
+                    return content.substring(0, es);
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Create a new service reference dynamically.
+     * 
+     * @param <B>
+     * @param businessInterface
+     * @param binding
+     * @param assemblyFactory
+     * @param compositeActivator
+     * @return
+     */
+    static <B> ServiceReference<B> dynamicReference(Class<B> businessInterface, Binding binding, AssemblyFactory assemblyFactory, CompositeActivator compositeActivator) {
+        try {
+    
+            Composite composite = assemblyFactory.createComposite();
+            composite.setName(new QName("http://tempuri.org", "default"));
+            RuntimeComponent component = (RuntimeComponent)assemblyFactory.createComponent();
+            component.setName("default");
+            component.setURI("default");
+            compositeActivator.configureComponentContext(component);
+            composite.getComponents().add(component);
+            RuntimeComponentReference reference = (RuntimeComponentReference)assemblyFactory.createComponentReference();
+            reference.setName("default");
+            JavaInterfaceFactory javaInterfaceFactory = compositeActivator.getJavaInterfaceFactory();
+            InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+            interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(businessInterface));
+            reference.setInterfaceContract(interfaceContract);
+            component.getReferences().add(reference);
+            reference.setComponent(component);
+            reference.getBindings().add(binding);
+    
+            ProxyFactory proxyFactory = compositeActivator.getProxyFactory();
+            return new ServiceReferenceImpl<B>(businessInterface, component, reference, binding, proxyFactory, compositeActivator);
+            
+        } catch (Exception e) {
+            throw new ServiceRuntimeException(e);
+        }
+    }
+
+    /**
+     * Temporary instantiation of a dummy Tuscany runtime.
+     * FIXME We need a better way to bootstrap without having to create
+     * a runtime instance at all.
+     * 
+     * @return
+     */
+    static ReallySmallRuntime newRuntime() {
+        try {
+            ReallySmallRuntime runtime = new ReallySmallRuntime(Thread.currentThread().getContextClassLoader());
+            runtime.start();
+            return runtime;
+        } catch (ActivationException e) {
+            throw new ServiceRuntimeException(e);
+        }
+    }
+}

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

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

Added: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/FileCollectionImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/FileCollectionImpl.java?rev=651636&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/FileCollectionImpl.java (added)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/FileCollectionImpl.java Fri Apr 25 09:12:51 2008
@@ -0,0 +1,129 @@
+/*
+ * 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.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Logger;
+
+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.NotFoundException;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Implementation of a file collection service component. 
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+@Service(ItemCollection.class)
+public class FileCollectionImpl implements ItemCollection {
+    
+    private final static Logger logger = Logger.getLogger(FileCollectionImpl.class.getName());    
+
+    @Property
+    public String directoryName;
+
+    /**
+     * Initialize the component.
+     */
+    @Init
+    public void initialize() throws IOException {
+    }
+    
+    public Entry<String, Item>[] getAll() {
+        logger.info("getAll");
+        
+        // Return all the files
+        List<Entry<String, Item>> entries = new ArrayList<Entry<String, Item>>();
+        File directory = new File(directoryName);
+        if (directory.exists()) {
+            for (File file: directory.listFiles()) {
+                if (file.getName().startsWith(".")) {
+                    continue;
+                }
+                entries.add(entry(file.getName()));
+            }
+        }
+        return entries.toArray(new Entry[entries.size()]);
+    }
+
+    public Item get(String key) throws NotFoundException {
+        logger.info("get " + key);
+        return item(key);
+    }
+
+    public String post(String key, Item item) {
+        throw new UnsupportedOperationException();
+    }
+
+    public void put(String key, Item item) throws NotFoundException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void delete(String key) throws NotFoundException {
+        logger.info("delete " + key);
+
+        File directory = new File(directoryName);
+        File file = new File(directory, key);
+        if (file.exists()) {
+            file.delete();
+        } else {
+            throw new NotFoundException(key);
+        }
+    }
+
+    public Entry<String, Item>[] query(String queryString) {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Returns an entry representing a file.
+     * 
+     * @param fileName
+     * @return
+     */
+    private static Entry<String, Item> entry(String fileName) {
+        Entry<String, Item> entry = new Entry<String, Item>();
+        entry.setKey(fileName);
+        entry.setData(item(fileName));
+        return entry;
+    }
+
+    /**
+     * Returns an item representing a file.
+     * 
+     * @param fileName
+     * @return
+     */
+    private static Item item(String fileName) {
+        Item item = new Item();
+        item.setTitle(fileName);
+        item.setLink("/files/" + fileName);
+        return item;
+    }
+}

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

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

Added: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/FileServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/FileServiceImpl.java?rev=651636&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/FileServiceImpl.java (added)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/FileServiceImpl.java Fri Apr 25 09:12:51 2008
@@ -0,0 +1,147 @@
+/*
+ * 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.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URLConnection;
+import java.net.URLDecoder;
+import java.util.List;
+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 org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Implementation of a servlet component supporting file upload/download.
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+@Service(Servlet.class)
+public class FileServiceImpl extends HttpServlet {
+    private static final long serialVersionUID = -4560385595481971616L;
+    
+    private final static Logger logger = Logger.getLogger(FileServiceImpl.class.getName());    
+
+    @Property
+    public String directoryName;
+    
+    private ServletFileUpload upload;
+    
+    /**
+     * Initialize the component.
+     */
+    @Init
+    public void initialize() throws IOException {
+        upload = new ServletFileUpload(new DiskFileItemFactory());
+    }
+    
+    @Override
+    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+        // Upload files
+        try {
+            for (FileItem item: (List<FileItem>)upload.parseRequest(request)) {
+                if (!item.isFormField()) {
+                    File directory = new File(directoryName);
+                    if (!directory.exists()) {
+                        directory.mkdirs();
+                    }
+                    logger.info("post " + item.getName());
+                    item.write(new File(directory, item.getName()));
+                }
+            }
+            
+            // Redirect to the admin page
+            response.sendRedirect("/ui/files");
+        }
+        catch (Exception e) {
+            throw new IOException(e.toString());
+        }
+    }
+    
+    @Override
+    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        
+        // Download a file
+        String requestURI = URLDecoder.decode(request.getRequestURI(), "UTF-8");
+        String path = requestURI.substring(request.getServletPath().length());
+        if (path.startsWith("/")) {
+            path = path.substring(1);
+        }
+        logger.info("get " + path);
+        
+        try {
+            
+            // Analyze the given path
+            URI uri = URI.create(path);
+            String scheme = uri.getScheme();
+            if (scheme == null) {
+
+                // If no scheme is specified then the path identifies file
+                // inside our directory
+                uri = new File(directoryName, path).toURI();
+                
+            } else if (!scheme.equals("file")) {
+                
+                // If the scheme does not identify a local file, just redirect to the server
+                // hosting the file
+                response.sendRedirect(path);
+            }
+            
+            // Read the file and write to response 
+            URLConnection connection = uri.toURL().openConnection();
+            connection.setUseCaches(false);
+            connection.connect();
+            InputStream is = connection.getInputStream();
+            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();
+            
+      } catch (FileNotFoundException e) {
+          response.sendError(HttpServletResponse.SC_NOT_FOUND);
+      }
+    }
+    
+}

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

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

Added: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/NodeProcessCollectionFacadeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/NodeProcessCollectionFacadeImpl.java?rev=651636&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/NodeProcessCollectionFacadeImpl.java (added)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/NodeProcessCollectionFacadeImpl.java Fri Apr 25 09:12:51 2008
@@ -0,0 +1,249 @@
+/*
+ * 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.DomainAdminUtil.compositeQName;
+import static org.apache.tuscany.sca.domain.manager.impl.DomainAdminUtil.dynamicReference;
+import static org.apache.tuscany.sca.domain.manager.impl.DomainAdminUtil.newRuntime;
+import static org.apache.tuscany.sca.domain.manager.impl.DomainAdminUtil.nodeURI;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.binding.atom.AtomBinding;
+import org.apache.tuscany.sca.binding.atom.AtomBindingFactory;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.assembly.CompositeActivator;
+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.osoa.sca.ServiceReference;
+import org.osoa.sca.ServiceRuntimeException;
+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 node process collection service. 
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+@Service(interfaces={ItemCollection.class, LocalItemCollection.class})
+public class NodeProcessCollectionFacadeImpl implements ItemCollection, LocalItemCollection {
+
+    private final static Logger logger = Logger.getLogger(NodeProcessCollectionFacadeImpl.class.getName());    
+
+    @Reference
+    public LocalItemCollection cloudCollection;
+    
+    private AssemblyFactory assemblyFactory;
+    private AtomBindingFactory atomBindingFactory;
+    private CompositeActivator compositeActivator;
+
+    /**
+     * Initialize the component.
+     */
+    @Init
+    public void initialize() {
+
+        // Get a runtime
+        ReallySmallRuntime runtime = newRuntime();
+        
+        // Get its composite activator
+        compositeActivator = runtime.getCompositeActivator();
+
+        // Get the model factories
+        ExtensionPointRegistry extensionPoints = runtime.getExtensionPointRegistry();
+        ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
+        assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+        atomBindingFactory = modelFactories.getFactory(AtomBindingFactory.class);
+    }
+    
+    public Entry<String, Item>[] getAll() {
+        logger.info("getAll");
+        
+        // Get the collection of nodes
+        Entry<String, Item>[] nodeEntries = cloudCollection.getAll();
+
+        // Dispatch to the hosts hosting these nodes
+        List<Entry<String, Item>> entries = new ArrayList<Entry<String,Item>>();
+        for (String host: hosts(nodeEntries)) {
+            ItemCollection processCollection = processCollection(host);
+            for (Entry<String, Item> remoteEntry: processCollection.getAll()) {
+                entries.add(remoteEntry);
+            }
+            break;
+        }
+        
+        return entries.toArray(new Entry[entries.size()]);
+    }
+
+    public Item get(String key) throws NotFoundException {
+        logger.info("get " + key);
+        
+        // Get the host hosting the given node
+        String host = host(key);
+        
+        // Dispatch the request to that host
+        ItemCollection processCollection = processCollection(host);
+        return processCollection.get(key);
+    }
+
+    public String post(String key, Item item) {
+        logger.info("post " + key);
+
+        // Get the host hosting the given node
+        String host;
+        try {
+            host = host(key);
+        } catch (NotFoundException e) {
+            throw new ServiceRuntimeException(e);
+        }
+        
+        // Dispatch the request to that host
+        ItemCollection processCollection = processCollection(host);
+        return processCollection.post(key, item);
+    }
+
+    public void put(String key, Item item) throws NotFoundException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void delete(String key) throws NotFoundException {
+        logger.info("delete " + key);
+        
+        // Get the host hosting the given node
+        String host = host(key);
+        
+        // Dispatch the request to that host
+        ItemCollection processCollection = processCollection(host);
+        processCollection.delete(key);
+    }
+    
+    public Entry<String, Item>[] query(String queryString) {
+        logger.info("query " + queryString);
+        
+        if (queryString.startsWith("node=")) {
+            String key = queryString.substring(queryString.indexOf('=') + 1);
+            
+            // Get the host hosting the given node
+            String host;
+            try {
+                host = host(key);
+            } catch (NotFoundException e) {
+                return new Entry[0];
+            }
+            
+            // Dispatch the request to that host
+            ItemCollection processCollection = processCollection(host);
+            return processCollection.query(queryString);
+            
+        } else {
+            throw new UnsupportedOperationException();
+        }
+    }
+    
+    private String host(String nodeName) throws NotFoundException {
+
+        // Get the entry representing the given node
+        Entry<String, Item> nodeEntry = nodeEntry(cloudCollection.getAll(), nodeName);
+        if (nodeEntry == null) {
+            throw new NotFoundException(nodeName);
+        }
+        
+        // Get the host hosting it
+        return host(nodeEntry.getData());
+    }
+
+    /**
+     * Returns the entry representing the given node.
+     *  
+     * @param entries
+     * @param name
+     * @return
+     */
+    private static Entry<String, Item> nodeEntry(Entry<String, Item>[] entries, String name) {
+        for (Entry<String, Item> entry: entries) {
+            QName qname = compositeQName(entry.getKey());
+            if (qname.getLocalPart().equals(name)) {
+                return entry;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Returns the lists of hosts hosting the nodes in the given entries.
+     *  
+     * @param entries
+     * @return
+     */
+    private static List<String> hosts(Entry<String, Item>[] entries) {
+        List<String> hosts = new ArrayList<String>();
+        for (Entry<String, Item> entry: entries) {
+            String host = host(entry.getData());
+            if (!hosts.contains(host)) {
+                hosts.add(host);
+            }
+        }
+        return hosts;
+    }
+
+    /**
+     * Returns the host of the node represented by the given item.
+     * 
+     * @param item
+     * @return
+     */
+    private static String host(Item item) {
+        String uri = nodeURI(item.getContents());
+        if (uri != null) {
+            return URI.create(uri).getHost();
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Returns a proxy to the process collection service on the specified
+     * host.
+     * 
+     * @param host
+     * @return
+     */
+    private ItemCollection processCollection(String host) {
+        AtomBinding binding = atomBindingFactory.createAtomBinding();
+        binding.setURI("http://" + host + ":9990/node/processes");
+        ServiceReference<ItemCollection> reference = dynamicReference(ItemCollection.class, binding, assemblyFactory, compositeActivator);
+        return reference.getService();
+    }
+        
+}

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

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

Added: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/QuickStartServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/QuickStartServiceImpl.java?rev=651636&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/QuickStartServiceImpl.java (added)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/impl/QuickStartServiceImpl.java Fri Apr 25 09:12:51 2008
@@ -0,0 +1,236 @@
+/*
+ * 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.DomainAdminUtil.compositeKey;
+import static org.apache.tuscany.sca.domain.manager.impl.DomainAdminUtil.compositeQName;
+import static org.apache.tuscany.sca.domain.manager.impl.DomainAdminUtil.contributionURI;
+import static org.apache.tuscany.sca.domain.manager.impl.DomainAdminUtil.nodeURI;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URLDecoder;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.logging.Level;
+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 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.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 component that provides a quick start path for a
+ * composite in a contribution. 
+ *
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+@Service(interfaces={Servlet.class})
+public class QuickStartServiceImpl extends HttpServlet {
+    private static final long serialVersionUID = -3477992129462720901L;
+
+    private final static Logger logger = Logger.getLogger(QuickStartServiceImpl.class.getName());    
+
+    @Reference
+    public LocalItemCollection contributionCollection;
+    
+    @Reference
+    public LocalItemCollection deployableCollection;
+
+    @Reference 
+    public LocalItemCollection domainCompositeCollection;
+    
+    @Reference
+    public LocalItemCollection cloudCollection;
+    
+    @Reference
+    public LocalItemCollection processCollection;
+    
+    /**
+     * Initialize the component.
+     */
+    @Init
+    public void initialize() throws ParserConfigurationException {
+    }
+
+    @Override
+    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        try {
+            
+            // Get the request path
+            String path = URLDecoder.decode(request.getRequestURI().substring(request.getServletPath().length()), "UTF-8");
+            if (path.startsWith("/")) {
+                path = path.substring(1);
+            }
+            
+            // Get the request parameters
+            String contributionURI = request.getParameter("contribution");
+            String contributionLocation = request.getParameter("location");
+            String compositeURI = request.getParameter("composite");
+            String start = request.getParameter("start");
+    
+            logger.info("Composite Quick Start.");
+            logger.info("Contribution URI: " + contributionURI);
+            logger.info("Contribution location: " + contributionLocation);
+            logger.info("Composite URI: " + compositeURI);
+            
+            // Look for the contribution in the workspace
+            Entry<String, Item>[] contributionEntries = contributionCollection.getAll();
+            Entry<String, Item> contributionEntry = null;
+            for (Entry<String, Item> entry: contributionEntries) {
+                if (contributionURI.equals(entry.getKey())) {
+                    contributionEntry = entry;
+                    break;
+                }
+            }
+            
+            // Add the contribution if necessary
+            if (contributionEntry == null) {
+                Item item = new Item();
+                item.setLink(contributionLocation);
+                contributionCollection.post(contributionURI, item);
+            }
+            
+            // Look for the specified deployable composite in the contribution
+            String compositeKey = null;
+            Entry<String, Item>[] deployableEntries = deployableCollection.query("contribution=" + contributionURI);
+            for (Entry<String, Item> entry: deployableEntries) {
+                Item item = entry.getData();
+                if (contributionURI.equals(contributionURI(entry.getKey())) && item.getAlternate().endsWith(compositeURI)) {
+                    compositeKey = entry.getKey();
+                    break;
+                }
+            }
+            
+            if (compositeKey == null) {
+                response.sendError(HttpServletResponse.SC_NOT_FOUND, compositeURI);
+                return;
+            }
+            
+            // Look for the deployable composite in the domain composite
+            try {
+                domainCompositeCollection.get(compositeKey);
+            } catch (NotFoundException e) {
+    
+                // Add the deployable composite to the domain composite
+                Item item = new Item();
+                domainCompositeCollection.post(compositeKey, item);
+            }
+    
+            // Check if the deployable composite is already assigned a node
+            Entry<String, Item>[] nodeEntries = cloudCollection.getAll();
+            String nodeName = null;
+            for (Entry<String, Item> entry: nodeEntries) {
+                Item item = entry.getData();
+                String related = item.getRelated();
+                if (related != null) {
+                    int c = related.indexOf("composite:");
+                    related = related.substring(c);
+                    if (compositeKey.equals(related)) {
+                        nodeName = compositeQName(entry.getKey()).getLocalPart();
+                    }
+                }
+            }
+            
+            // Create a new node for the composite if necessary
+            if (nodeName == null) {
+                
+                // Construct node name and key
+                QName compositeName = compositeQName(compositeKey); 
+                nodeName = compositeName.getLocalPart() + "Node"; 
+                String nodeKey = compositeKey("http://tuscany.apache.org/cloud", new QName("http://tuscany.apache.org/cloud", nodeName));
+                
+                // Find a free node port
+                Set<Integer> nodePorts = new HashSet<Integer>(); 
+                for (Entry<String, Item> entry: nodeEntries) {
+                    Item item = entry.getData();
+                    String uri = nodeURI(item.getContents());
+                    if (uri != null) {
+                        URI u = URI.create(uri);
+                        int port = u.getPort();
+                        if (port != -1) {
+                            nodePorts.add(port);
+                        }
+                    }
+                }
+                String nodeURI = null;
+                for (int port = 8100; port<8200; port++) {
+                    if (!nodePorts.contains(port)) {
+                        nodeURI = "http://localhost:" + port;
+                        break;
+                    }
+                }
+                if (nodeURI == null) {
+                    throw new RuntimeException("Couldn't find a free port for new node: " + nodeName);
+                }
+                
+                // Build the entry describing the node
+                Item item = new Item();
+                String content = 
+                                "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\"\n" +
+                                "       xmlns:t=\"http://tuscany.apache.org/xmlns/sca/1.0\"\n" +
+                                "       targetNamespace=\"http://tuscany.apache.org/cloud\"\n" +
+                                "       xmlns:c=\"" + compositeName.getNamespaceURI() + "\"\n" +
+                                "       name=\"" + nodeName + "\">\n" +
+                                "\n" +
+                                "       <component name=\"" + nodeName + "\">\n" +
+                                "               <t:implementation.node uri=\"" + contributionURI + "\" composite=\"c:" + compositeName.getLocalPart() + "\"/>\n" +
+                                "               <service name=\"Node\">\n" +
+                                "                       <binding.ws uri=\"" + nodeURI + "\"/>\n" +
+                                "                       <t:binding.http uri=\"" + nodeURI + "\"/>\n" +
+                                "                       <t:binding.jsonrpc uri=\"" + nodeURI + "\"/>\n" +
+                                "                       <t:binding.atom uri=\"" + nodeURI + "\"/>\n" +
+                                "               </service>\n" +
+                                "       </component>\n" + 
+                                "</composite>";
+                item.setContents(content);
+    
+                // Create the new node
+                cloudCollection.post(nodeKey, item);
+            }
+            
+            // Finally, start the node
+            if ("true".equals(start)) {
+                processCollection.post(nodeName, new Item());
+            }
+            
+            response.getWriter().print("<html><body>Node <span id=\"node\">" + nodeName + "</span> OK.</body></html>");
+
+        } catch (Exception e) {
+            logger.log(Level.SEVERE, "Could not start composite", e);
+            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
+        }
+    }
+    
+}

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

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

Added: incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/launcher/DomainManagerLauncherBootstrap.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/launcher/DomainManagerLauncherBootstrap.java?rev=651636&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/launcher/DomainManagerLauncherBootstrap.java (added)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/java/org/apache/tuscany/sca/domain/manager/launcher/DomainManagerLauncherBootstrap.java Fri Apr 25 09:12:51 2008
@@ -0,0 +1,84 @@
+/*
+ * 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.launcher;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.node.SCANode2;
+
+/**
+ * Bootstrap class for the SCA domain manager.
+ *  
+ * @version $Rev$ $Date$
+ */
+public class DomainManagerLauncherBootstrap {
+    private SCANode2 node;
+
+    /**
+     * A node wrappering an instance of a domain manager.
+     */
+    public static class NodeFacade implements SCANode2 {
+        private ClassLoader threadContextClassLoader;
+        private ClassLoader runtimeClassLoader;
+        private SCADomain domainManager;
+        
+        private NodeFacade() {
+            runtimeClassLoader = Thread.currentThread().getContextClassLoader();
+        }
+        
+        public void start() {
+            threadContextClassLoader = Thread.currentThread().getContextClassLoader();
+            boolean started = false;
+            try {
+                Thread.currentThread().setContextClassLoader(runtimeClassLoader);
+                domainManager = SCADomain.newInstance("DomainManager.composite");
+                started = true;
+            } finally {
+                if (!started) {
+                    Thread.currentThread().setContextClassLoader(threadContextClassLoader);
+                }
+            }
+        }
+        
+        public void stop() {
+            try {
+                Thread.currentThread().setContextClassLoader(runtimeClassLoader);
+                domainManager.close();
+            } finally {
+                Thread.currentThread().setContextClassLoader(threadContextClassLoader);
+            }
+        }
+    }
+    
+    /**
+     * Constructs a new domain manager bootstrap.
+     */
+    public DomainManagerLauncherBootstrap() throws Exception {
+        node = new NodeFacade();
+    }
+
+    /**
+     * Returns the node representing the domain manager.
+     * @return
+     */
+    public SCANode2 getNode() {
+        return node;
+    }
+
+}

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

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

Modified: incubator/tuscany/java/sca/modules/domain-manager/src/main/resources/DomainManager.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/main/resources/DomainManager.composite?rev=651636&r1=651633&r2=651636&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/main/resources/DomainManager.composite (original)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/main/resources/DomainManager.composite Fri Apr 25 09:12:51 2008
@@ -79,7 +79,7 @@
     </component>
     
     <component name="ContributionCollectionComponent">
-        <implementation.java class="org.apache.tuscany.sca.workspace.admin.impl.ContributionCollectionImpl"/>             
+        <implementation.java class="org.apache.tuscany.sca.domain.manager.impl.ContributionCollectionImpl"/>             
         <property name="workspaceFile">workspace.xml</property>             
         <property name="deploymentContributionDirectory">cloud</property>             
    		<service name="ItemCollection">
@@ -91,7 +91,7 @@
     </component>
 
     <component name="FileCollectionComponent">
-        <implementation.java class="org.apache.tuscany.sca.workspace.admin.impl.FileCollectionImpl"/>             
+        <implementation.java class="org.apache.tuscany.sca.domain.manager.impl.FileCollectionImpl"/>             
         <property name="directoryName">files</property>             
    		<service name="ItemCollection">
    	 		<t:binding.atom uri="http://localhost:9990/feed/files" title="Files"/>
@@ -99,7 +99,7 @@
     </component>
 
     <component name="FileServiceComponent">
-        <implementation.java class="org.apache.tuscany.sca.workspace.admin.impl.FileServiceImpl"/>
+        <implementation.java class="org.apache.tuscany.sca.domain.manager.impl.FileServiceImpl"/>
         <property name="directoryName">files</property>             
    		<service name="Servlet">
    	 		<t:binding.http uri="http://localhost:9990/files"/>
@@ -107,7 +107,7 @@
     </component>
 
     <component name="DomainCompositeCollectionComponent">
-        <implementation.java class="org.apache.tuscany.sca.workspace.admin.impl.DeployedCompositeCollectionImpl"/>
+        <implementation.java class="org.apache.tuscany.sca.domain.manager.impl.DeployedCompositeCollectionImpl"/>
         <property name="compositeFile">domain.composite</property>
    		<service name="ItemCollection">
    	 		<t:binding.atom uri="http://localhost:9990/composite" title="Domain Composites"/>
@@ -119,7 +119,7 @@
     </component>
 
     <component name="DeployableCompositeCollectionComponent">
-        <implementation.java class="org.apache.tuscany.sca.workspace.admin.impl.DeployableCompositeCollectionImpl"/>
+        <implementation.java class="org.apache.tuscany.sca.domain.manager.impl.DeployableCompositeCollectionImpl"/>
    		<service name="ItemCollection">
    	 		<t:binding.atom uri="http://localhost:9990/deployable" title="Deployable Composites"/>
    		</service>
@@ -132,7 +132,7 @@
     </component>
 
     <component name="CloudCollectionComponent">
-        <implementation.java class="org.apache.tuscany.sca.workspace.admin.impl.DeployedCompositeCollectionImpl"/>
+        <implementation.java class="org.apache.tuscany.sca.domain.manager.impl.DeployedCompositeCollectionImpl"/>
         <property name="compositeFile">cloud.composite</property>
         <property name="deploymentContributionDirectory">cloud</property>             
    		<service name="ItemCollection">
@@ -146,7 +146,7 @@
     </component>
 
     <component name="CompositeImageCollectionComponent">
-        <implementation.java class="org.apache.tuscany.sca.workspace.admin.impl.CompositeImageCollectionImpl"/>
+        <implementation.java class="org.apache.tuscany.sca.domain.manager.impl.CompositeImageCollectionImpl"/>
    		<service name="ItemCollection">
    	 		<t:binding.atom uri="http://localhost:9990/composite-image" title="Install Image"/>
    		</service>
@@ -158,7 +158,7 @@
     </component>
 
     <component name="QuickStartServiceComponent">
-        <implementation.java class="org.apache.tuscany.sca.workspace.admin.impl.QuickStartServiceImpl"/>
+        <implementation.java class="org.apache.tuscany.sca.domain.manager.impl.QuickStartServiceImpl"/>
    		<service name="Servlet">
    	 		<t:binding.http uri="http://localhost:9990/quickstart"/>
    		</service>
@@ -170,7 +170,7 @@
     </component>
 
     <component name="NodeProcessCollectionFacadeComponent">
-        <implementation.java class="org.apache.tuscany.sca.workspace.admin.impl.NodeProcessCollectionFacadeImpl"/>
+        <implementation.java class="org.apache.tuscany.sca.domain.manager.impl.NodeProcessCollectionFacadeImpl"/>
    		<service name="ItemCollection">
    	 		<t:binding.atom uri="http://localhost:9990/processes" title="Log"/>
    		</service>

Added: incubator/tuscany/java/sca/modules/domain-manager/src/test/java/org/apache/tuscany/sca/workspace/manager/impl/AdminTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/domain-manager/src/test/java/org/apache/tuscany/sca/workspace/manager/impl/AdminTestCase.java?rev=651636&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/domain-manager/src/test/java/org/apache/tuscany/sca/workspace/manager/impl/AdminTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/domain-manager/src/test/java/org/apache/tuscany/sca/workspace/manager/impl/AdminTestCase.java Fri Apr 25 09:12:51 2008
@@ -0,0 +1,109 @@
+/*
+ * 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.workspace.manager.impl;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.domain.manager.impl.ContributionCollectionImpl;
+import org.apache.tuscany.sca.domain.manager.impl.DeployableCompositeCollectionImpl;
+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.NotFoundException;
+
+/**
+ * Test case for the workspace admin services.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AdminTestCase extends TestCase {
+    
+    private ContributionCollectionImpl contributionCollection;
+    private DeployableCompositeCollectionImpl deployableCollection;
+    
+    private final static String WORKSPACE_XML =
+        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+        "<workspace xmlns=\"http://tuscany.apache.org/xmlns/sca/1.0\" " +
+        "xmlns:ns1=\"http://tuscany.apache.org/xmlns/sca/1.0\">\n" +
+        "</workspace>";
+    
+    @Override
+    protected void setUp() throws Exception {
+        ClassLoader cl = getClass().getClassLoader();
+
+        // Make sure we start with a clean workspace.xml file
+        URL url = cl.getResource("workspace.xml");
+        FileOutputStream os = new FileOutputStream(new File(url.toURI()));
+        Writer writer = new OutputStreamWriter(os);
+        writer.write(WORKSPACE_XML);
+        writer.flush();
+        writer.close();
+        
+        // Create a workspace collection component
+        contributionCollection = new ContributionCollectionImpl();
+        contributionCollection.workspaceFile = url.getFile();
+        contributionCollection.deploymentContributionDirectory = "cloud";
+        deployableCollection = new DeployableCompositeCollectionImpl();
+        deployableCollection.contributionCollection = contributionCollection;
+        contributionCollection.initialize();
+        deployableCollection.initialize();
+        
+        // Populate the workspace with test data
+        Item item = new Item();
+        item.setLink(cl.getResource("contributions/store").toString());
+        contributionCollection.post("store", item);
+        item.setLink(cl.getResource("contributions/assets").toString());
+        contributionCollection.post("assets", item);
+    }
+    
+    public void testGetAll() {
+        Entry<String, Item>[] entries = contributionCollection.getAll();
+        assertEquals(2, entries.length);
+        assertEquals(entries[0].getKey(), "store");
+    }
+
+    public void testGet() throws NotFoundException {
+        Item item = contributionCollection.get("assets");
+        assertTrue(item.getAlternate().endsWith("contributions/assets/"));
+    }
+    
+    public void testDependencies1() {
+        Entry<String, Item>[] entries = contributionCollection.query("alldependencies=store");
+        assertEquals(2, entries.length);
+    }
+    
+    public void testDependencies2() {
+        Entry<String, Item>[] entries = contributionCollection.query("alldependencies=assets");
+        assertEquals(1, entries.length);
+        assertEquals("assets", entries[0].getKey());
+    }
+    
+    public void testDeployables() throws NotFoundException {
+        Entry<String, Item>[] entries = deployableCollection.getAll();
+        assertEquals(1, entries.length);
+        assertEquals("composite:store;http://store;store", entries[0].getKey());
+    }
+    
+}

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

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

Modified: incubator/tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java?rev=651636&r1=651635&r2=651636&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java (original)
+++ incubator/tuscany/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java Fri Apr 25 09:12:51 2008
@@ -375,7 +375,7 @@
     
             // Use Java reflection to create the node daemon as only the runtime class
             // loader knows the runtime classes required by the node
-            String className = "org.apache.tuscany.sca.workspace.admin.launcher.DomainManagerLauncherBootstrap";
+            String className = "org.apache.tuscany.sca.domain.manager.launcher.DomainManagerLauncherBootstrap";
             Class<?> bootstrapClass;
             if (runtimeClassLoader != null) {
                 bootstrapClass = Class.forName(className, true, runtimeClassLoader);

Modified: incubator/tuscany/java/sca/modules/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/pom.xml?rev=651636&r1=651635&r2=651636&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/pom.xml Fri Apr 25 09:12:51 2008
@@ -90,6 +90,7 @@
                 <module>domain</module>
                 <module>domain-api</module>
                 <module>domain-impl</module>
+                <module>domain-manager</module>
                 <module>extensibility</module>
                 <module>extension-helper</module>
                 <module>host-embedded</module>
@@ -147,7 +148,6 @@
                 <module>runtime-war</module>
                 <module>sca-api</module>
                 <module>workspace</module>
-                <module>workspace-admin</module>
                 <module>workspace-impl</module>
                 <module>workspace-xml</module>
                 <module>definitions</module>

Modified: incubator/tuscany/java/sca/samples/calculator-distributed/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/calculator-distributed/pom.xml?rev=651636&r1=651635&r2=651636&view=diff
==============================================================================
--- incubator/tuscany/java/sca/samples/calculator-distributed/pom.xml (original)
+++ incubator/tuscany/java/sca/samples/calculator-distributed/pom.xml Fri Apr 25 09:12:51 2008
@@ -51,7 +51,7 @@
         
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-workspace-admin</artifactId>
+            <artifactId>tuscany-domain-manager</artifactId>
             <version>2.0-incubating-SNAPSHOT</version>
         </dependency> 
         

Modified: incubator/tuscany/java/sca/tutorial/domain/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tutorial/domain/pom.xml?rev=651636&r1=651635&r2=651636&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tutorial/domain/pom.xml (original)
+++ incubator/tuscany/java/sca/tutorial/domain/pom.xml Fri Apr 25 09:12:51 2008
@@ -44,7 +44,7 @@
 
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-workspace-admin</artifactId>
+            <artifactId>tuscany-domain-manager</artifactId>
             <version>2.0-incubating-SNAPSHOT</version>
             <scope>runtime</scope>
         </dependency>