You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2006/04/26 23:32:31 UTC

svn commit: r397307 - in /geronimo/branches/1.1/modules: deployment/src/java/org/apache/geronimo/deployment/ deployment/src/test/org/apache/geronimo/deployment/ kernel/src/java/org/apache/geronimo/kernel/config/ system/src/java/org/apache/geronimo/syst...

Author: dain
Date: Wed Apr 26 14:32:30 2006
New Revision: 397307

URL: http://svn.apache.org/viewcvs?rev=397307&view=rev
Log:
Added inplace dir to configuration info. This lets a deployer to find an existing deployment using only a directory.
Added a simple SingleFileHotDeployer gbean which manages the hot deployment of a single unpacked directory.

Added:
    geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/SingleFileHotDeployer.java
    geronimo/branches/1.1/modules/deployment/src/test/org/apache/geronimo/deployment/SingleFileHotDeployerTest.java
Modified:
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationInfo.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java

Added: geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/SingleFileHotDeployer.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/SingleFileHotDeployer.java?rev=397307&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/SingleFileHotDeployer.java (added)
+++ geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/SingleFileHotDeployer.java Wed Apr 26 14:32:30 2006
@@ -0,0 +1,288 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.geronimo.deployment;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.jar.JarFile;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.util.DeploymentUtil;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.ConfigurationInfo;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationStore;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ArtifactResolver;
+import org.apache.geronimo.kernel.repository.Version;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SingleFileHotDeployer {
+    private static final Log log = LogFactory.getLog(SingleFileHotDeployer.class);
+    private final File dir;
+    private final String[] watchPaths;
+    private final Collection builders;
+    private final ConfigurationStore store;
+    private final ConfigurationManager configurationManager;
+    private final boolean forceDeploy;
+    private final Artifact configurationId;
+    private boolean wasDeployed;
+
+    public SingleFileHotDeployer(String path, ServerInfo serverInfo, String[] watchPaths, Collection builders, ConfigurationStore store, ConfigurationManager configurationManager, boolean forceDeploy) throws DeploymentException {
+        this(serverInfo.resolve(path), watchPaths, builders, store, configurationManager, forceDeploy);
+    }
+
+    public SingleFileHotDeployer(File dir, String[] watchPaths, Collection builders, ConfigurationStore store, ConfigurationManager configurationManager, boolean forceDeploy) throws DeploymentException {
+        this.dir = dir;
+        this.watchPaths = watchPaths;
+        this.builders = builders;
+        this.store = store;
+        this.configurationManager = configurationManager;
+        this.forceDeploy = forceDeploy;
+
+        configurationId = start(dir);
+    }
+
+    private Artifact start(File dir) throws DeploymentException {
+        if (!dir.exists()) {
+            throw new IllegalArgumentException("Directory does not exist " + dir.getAbsolutePath());
+        }
+        if (!dir.isDirectory()) {
+            throw new IllegalArgumentException("Directory is not a directory " + dir.getAbsolutePath());
+        }
+
+        // get the existing inplace configuration if there is one
+        ConfigurationInfo existingConfiguration = null;
+        List list = configurationManager.listConfigurations();
+        for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+            ConfigurationInfo configurationInfo = (ConfigurationInfo) iterator.next();
+            if (dir.equals(configurationInfo.getInPlaceLocation())) {
+                existingConfiguration = configurationInfo;
+            }
+        }
+        Artifact existingConfigurationId = (existingConfiguration == null) ? null : existingConfiguration.getConfigID();
+
+        if (!forceDeploy && existingConfiguration != null && !isModifedSince(existingConfiguration.getCreated())) {
+            return existingConfigurationId;
+        }
+
+        // if the current id and the new id only differ by version, we can reload, otherwise we need to load and start
+        if (existingConfigurationId != null && configurationManager.isLoaded(existingConfigurationId)) {
+            try {
+                configurationManager.unloadConfiguration(existingConfigurationId);
+            } catch (NoSuchConfigException e) {
+                throw new DeploymentException("Unable to unload existing configuration " + existingConfigurationId);
+            }
+        }
+
+        JarFile module = null;
+        try {
+            module = DeploymentUtil.createJarFile(dir);
+        } catch (IOException e) {
+            throw new DeploymentException("Cound not open module file: " + dir.getAbsolutePath(), e);
+        }
+
+        try {
+            // get the builder and plan
+            Object plan = null;
+            ConfigurationBuilder builder = null;
+            for (Iterator i = builders.iterator(); i.hasNext();) {
+                ConfigurationBuilder candidate = (ConfigurationBuilder) i.next();
+                plan = candidate.getDeploymentPlan(null, module);
+                if (plan != null) {
+                    builder = candidate;
+                    break;
+                }
+            }
+            if (builder == null) {
+                throw new DeploymentException("Cannot deploy the requested application module because no builder is able to handle it (dir=" + dir.getAbsolutePath() + ")");
+            }
+
+            // determine the new configuration id
+            Artifact configurationId = builder.getConfigurationID(plan, module);
+
+            // if the new configuration id isn't fully resolved, populate it with defaults
+            if (!configurationId.isResolved()) {
+                resolve(configurationId);
+            }
+
+            // if we are deploying over the exisitng version we need to uninstall first
+            if(configurationId.equals(existingConfigurationId)) {
+                configurationManager.uninstallConfiguration(existingConfigurationId);
+            }
+
+            // deploy it
+            deployConfiguration(builder, store, configurationId, plan, module, Arrays.asList(configurationManager.getStores()), configurationManager.getArtifactResolver());
+            wasDeployed = true;
+
+            configurationManager.loadConfiguration(configurationId);
+            configurationManager.startConfiguration(configurationId);
+
+            return configurationId;
+        } catch (Exception e) {
+            throw new DeploymentException("Unable to deploy " + dir, e);
+        } finally {
+            DeploymentUtil.close(module);
+        }
+    }
+
+    private boolean isModifedSince(long created) {
+        for (int i = 0; i < watchPaths.length; i++) {
+            String path = watchPaths[i];
+            File file = new File(dir, path);
+            if (!file.exists()) {
+                log.warn("Watched file does not exist " + file);
+            }
+            if (file.isFile() && file.lastModified() > created) {
+                log.info("Redeploying " + dir + " because file " + file + " was modified;");
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private void resolve(Artifact configID) throws DeploymentException {
+        String group = configID.getGroupId();
+        if (group == null) {
+            group = Artifact.DEFAULT_GROUP_ID;
+        }
+        String artifactId = configID.getArtifactId();
+        if (artifactId == null) {
+            throw new DeploymentException("Every configuration to deploy must have a ConfigID with an ArtifactID (not " + configID + ")");
+        }
+        Version version = configID.getVersion();
+        if (version == null) {
+            version = new Version(Long.toString(System.currentTimeMillis()));
+        }
+        String type = configID.getType();
+        if (type == null) {
+            type = "car";
+        }
+        configID = new Artifact(group, artifactId, version, type);
+    }
+
+    private List deployConfiguration(ConfigurationBuilder builder, ConfigurationStore store, Artifact configurationId, Object plan, JarFile module, Collection stores, ArtifactResolver artifactResolver) throws DeploymentException {
+        try {
+            // It's our responsibility to close this context, once we're done with it...
+            DeploymentContext context = builder.buildConfiguration(true, configurationId, plan, module, stores, artifactResolver, store);
+
+            List configurations = new ArrayList();
+            try {
+                configurations.add(context.getConfigurationData());
+                configurations.addAll(context.getAdditionalDeployment());
+
+                if (configurations.isEmpty()) {
+                    throw new DeploymentException("Deployer did not create any configurations");
+                }
+                List deployedURIs = new ArrayList();
+                for (Iterator iterator = configurations.iterator(); iterator.hasNext();) {
+                    ConfigurationData configurationData = (ConfigurationData) iterator.next();
+                    configurationData.setAutoStart(false);
+                    store.install(configurationData);
+                    deployedURIs.add(configurationData.getId().toString());
+                }
+                return deployedURIs;
+            } catch (IOException e) {
+                cleanupConfigurations(configurations);
+                throw e;
+            } catch (InvalidConfigException e) {
+                cleanupConfigurations(configurations);
+                // unlikely as we just built this
+                throw new DeploymentException(e);
+            } finally {
+                if (context != null) {
+                    context.close();
+                }
+            }
+        } catch (Throwable e) {
+            if (e instanceof Error) {
+                log.error("Deployment failed due to ", e);
+                throw (Error) e;
+            } else if (e instanceof DeploymentException) {
+                throw (DeploymentException) e;
+            } else if (e instanceof Exception) {
+                log.error("Deployment failed due to ", e);
+                throw new DeploymentException(e);
+            }
+            throw new Error(e);
+        } finally {
+            DeploymentUtil.close(module);
+        }
+    }
+
+    private void cleanupConfigurations(List configurations) {
+        for (Iterator iterator = configurations.iterator(); iterator.hasNext();) {
+            ConfigurationData configurationData = (ConfigurationData) iterator.next();
+            File dir = configurationData.getConfigurationDir();
+            if (!DeploymentUtil.recursiveDelete(dir)) {
+                log.warn("Unable delete directory " + dir);
+            }
+        }
+    }
+
+    public File getDir() {
+        return dir;
+    }
+
+    public Artifact getConfigurationId() {
+        return configurationId;
+    }
+
+    public boolean isForceDeploy() {
+        return forceDeploy;
+    }
+
+    public boolean wasDeployed() {
+        return wasDeployed;
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(SingleFileHotDeployer.class);
+
+        infoFactory.addAttribute("path", String.class, true);
+        infoFactory.addReference("ServerInfo", ServerInfo.class);
+        infoFactory.addAttribute("watchPaths", String[].class, true);
+        infoFactory.addReference("Builders", ConfigurationBuilder.class);
+        infoFactory.addReference("Store", ConfigurationStore.class);
+        infoFactory.addReference("ConfigurationManager", ConfigurationManager.class);
+        infoFactory.addAttribute("forceDeploy", boolean.class, true);
+
+        infoFactory.setConstructor(new String[]{"path", "ServerInfo", "watchPaths", "Builders", "Store", "ConfigurationManager", "forceDeploy"});
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Added: geronimo/branches/1.1/modules/deployment/src/test/org/apache/geronimo/deployment/SingleFileHotDeployerTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deployment/src/test/org/apache/geronimo/deployment/SingleFileHotDeployerTest.java?rev=397307&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/deployment/src/test/org/apache/geronimo/deployment/SingleFileHotDeployerTest.java (added)
+++ geronimo/branches/1.1/modules/deployment/src/test/org/apache/geronimo/deployment/SingleFileHotDeployerTest.java Wed Apr 26 14:32:30 2006
@@ -0,0 +1,454 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.geronimo.deployment;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.jar.JarFile;
+
+import junit.framework.TestCase;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.kernel.Jsr77Naming;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.config.ConfigurationAlreadyExistsException;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationModuleType;
+import org.apache.geronimo.kernel.config.ConfigurationResolver;
+import org.apache.geronimo.kernel.config.ConfigurationStore;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.LifecycleException;
+import org.apache.geronimo.kernel.config.LifecycleMonitor;
+import org.apache.geronimo.kernel.config.LifecycleResults;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.config.NoSuchStoreException;
+import org.apache.geronimo.kernel.config.SimpleConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationInfo;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ArtifactResolver;
+import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.Version;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SingleFileHotDeployerTest extends TestCase {
+    private static final long NOW = System.currentTimeMillis();
+    private static final long PAST = NOW - 1000;
+
+    private final Artifact NEW_ID = new Artifact("new", "new", "new", "new");
+    private final Artifact OLD_VERSION_ID = new Artifact("new", "new", "old", "new");
+    private final Artifact DIFFERENT_ID = new Artifact("different", "different", "different", "different");
+
+    private File dir;
+    private String[] watchPaths;
+    private MockConfigurationBuilder builder;
+    private MockConfigurationStore store;
+    private MockConfigurationManager configurationManager;
+
+    private ArtifactResolver artifactResolver = new DefaultArtifactResolver(null, null);
+    private ArrayList existingConfigurationInfos = new ArrayList();
+
+    private boolean shouldUninstall;
+    private boolean shouldUnload;
+    private boolean shouldLoad;
+    private boolean shouldStart;
+    private boolean isConfigurationAlreadyLoaded;
+
+    private File watchFile1;
+    private File watchFile2;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        dir = new File("target/deployTest");
+        dir.mkdirs();
+
+        String watch1 = "watch1";
+        String watch2 = "watch2";
+        watchPaths = new String[]{watch1, watch2};
+
+        watchFile1 = new File(dir, watch1);
+        watchFile2 = new File(dir, watch2);
+
+        builder = new MockConfigurationBuilder();
+        store = new MockConfigurationStore();
+        configurationManager = new MockConfigurationManager();
+    }
+
+    private void touch(File file, long lastModified) throws IOException {
+        file.createNewFile();
+        file.setLastModified(lastModified);
+    }
+
+    public void testDeploy() throws Exception {
+        shouldUninstall = false;
+        shouldUnload = false;
+        shouldLoad = true;
+        shouldStart = true;
+        isConfigurationAlreadyLoaded = true;
+
+        SingleFileHotDeployer singleFileHotDeployer = new SingleFileHotDeployer(dir,
+                watchPaths,
+                Collections.singleton(builder),
+                store,
+                configurationManager,
+                false);
+        assertEquals(NEW_ID, singleFileHotDeployer.getConfigurationId());
+        assertEquals(dir, singleFileHotDeployer.getDir());
+        assertTrue(singleFileHotDeployer.wasDeployed());
+        assertFalse(singleFileHotDeployer.isForceDeploy());
+    }
+
+    public void testRedeploySame() throws Exception {
+        shouldUninstall = true;
+        shouldUnload = true;
+        shouldLoad = true;
+        shouldStart = true;
+        isConfigurationAlreadyLoaded = true;
+
+        touch(watchFile1, NOW);
+        touch(watchFile2, NOW);
+
+        existingConfigurationInfos.add(new ConfigurationInfo(null, NEW_ID, ConfigurationModuleType.CAR, PAST, null, dir));
+
+        SingleFileHotDeployer singleFileHotDeployer = new SingleFileHotDeployer(dir,
+                watchPaths,
+                Collections.singleton(builder),
+                store,
+                configurationManager,
+                false);
+        assertEquals(NEW_ID, singleFileHotDeployer.getConfigurationId());
+        assertEquals(dir, singleFileHotDeployer.getDir());
+        assertTrue(singleFileHotDeployer.wasDeployed());
+        assertFalse(singleFileHotDeployer.isForceDeploy());
+    }
+
+    public void testRedeployCompletelyNew() throws Exception {
+        shouldUninstall = true;
+        shouldUnload = true;
+        shouldLoad = true;
+        shouldStart = true;
+        isConfigurationAlreadyLoaded = true;
+
+        touch(watchFile1, NOW);
+        touch(watchFile2, NOW);
+
+        existingConfigurationInfos.add(new ConfigurationInfo(null, DIFFERENT_ID, ConfigurationModuleType.CAR, PAST, null, dir));
+
+        SingleFileHotDeployer singleFileHotDeployer = new SingleFileHotDeployer(dir,
+                watchPaths,
+                Collections.singleton(builder),
+                store,
+                configurationManager,
+                false);
+        assertEquals(NEW_ID, singleFileHotDeployer.getConfigurationId());
+        assertEquals(dir, singleFileHotDeployer.getDir());
+        assertTrue(singleFileHotDeployer.wasDeployed());
+        assertFalse(singleFileHotDeployer.isForceDeploy());
+    }
+
+    public void testRedeployNewVersion() throws Exception {
+        shouldUninstall = true;
+        shouldUnload = true;
+        shouldLoad = true;
+        shouldStart = true;
+        isConfigurationAlreadyLoaded = true;
+
+        touch(watchFile1, NOW);
+        touch(watchFile2, NOW);
+
+        existingConfigurationInfos.add(new ConfigurationInfo(null, OLD_VERSION_ID, ConfigurationModuleType.CAR, PAST, null, dir));
+
+        SingleFileHotDeployer singleFileHotDeployer = new SingleFileHotDeployer(dir,
+                watchPaths,
+                Collections.singleton(builder),
+                store,
+                configurationManager,
+                false);
+        assertEquals(NEW_ID, singleFileHotDeployer.getConfigurationId());
+        assertEquals(dir, singleFileHotDeployer.getDir());
+        assertTrue(singleFileHotDeployer.wasDeployed());
+        assertFalse(singleFileHotDeployer.isForceDeploy());
+    }
+
+    public void testNoRedeploy() throws Exception {
+        shouldUninstall = false;
+        shouldUnload = false;
+        shouldLoad = false;
+        shouldStart = false;
+        isConfigurationAlreadyLoaded = true;
+
+        touch(watchFile1, PAST);
+        touch(watchFile2, PAST);
+
+        existingConfigurationInfos.add(new ConfigurationInfo(null, NEW_ID, ConfigurationModuleType.CAR, NOW, null, dir));
+
+        SingleFileHotDeployer singleFileHotDeployer = new SingleFileHotDeployer(dir,
+                watchPaths,
+                Collections.singleton(builder),
+                store,
+                configurationManager,
+                false);
+        assertEquals(NEW_ID, singleFileHotDeployer.getConfigurationId());
+        assertEquals(dir, singleFileHotDeployer.getDir());
+        assertFalse(singleFileHotDeployer.wasDeployed());
+        assertFalse(singleFileHotDeployer.isForceDeploy());
+    }
+
+    public void testForceRedeploy() throws Exception {
+        shouldUninstall = true;
+        shouldUnload = true;
+        shouldLoad = true;
+        shouldStart = true;
+        isConfigurationAlreadyLoaded = true;
+
+        touch(watchFile1, PAST);
+        touch(watchFile2, PAST);
+
+        existingConfigurationInfos.add(new ConfigurationInfo(null, OLD_VERSION_ID, ConfigurationModuleType.CAR, NOW, null, dir));
+
+        SingleFileHotDeployer singleFileHotDeployer = new SingleFileHotDeployer(dir,
+                watchPaths,
+                Collections.singleton(builder),
+                store,
+                configurationManager,
+                true);
+        assertEquals(NEW_ID, singleFileHotDeployer.getConfigurationId());
+        assertEquals(dir, singleFileHotDeployer.getDir());
+        assertTrue(singleFileHotDeployer.wasDeployed());
+        assertTrue(singleFileHotDeployer.isForceDeploy());
+    }
+
+    private class MockConfigurationBuilder implements ConfigurationBuilder {
+        public Object getDeploymentPlan(File planFile, JarFile module) throws DeploymentException {
+            return new Object();
+        }
+
+        public Artifact getConfigurationID(Object plan, JarFile module) throws IOException, DeploymentException {
+            return NEW_ID;
+        }
+
+        public DeploymentContext buildConfiguration(boolean inPlaceDeployment, Artifact configId, Object plan, JarFile module, Collection configurationStores, ArtifactResolver artifactResolver, ConfigurationStore targetConfigurationStore) throws IOException, DeploymentException {
+            return new DeploymentContext(dir,
+                    dir,
+                    new Environment(configId),
+                    ConfigurationModuleType.CAR,
+                    new Jsr77Naming(),
+                    new SimpleConfigurationManager(Collections.singletonList(store), artifactResolver, Collections.EMPTY_SET));
+        }
+    }
+
+    private class MockConfigurationStore implements ConfigurationStore {
+        public boolean isInPlaceConfiguration(Artifact configId) throws NoSuchConfigException, IOException {
+            throw new UnsupportedOperationException();
+        }
+
+        public void install(ConfigurationData configurationData) throws IOException, InvalidConfigException {
+        }
+
+        public void uninstall(Artifact configId) throws NoSuchConfigException, IOException {
+            throw new UnsupportedOperationException();
+        }
+
+        public ConfigurationData loadConfiguration(Artifact configId) throws NoSuchConfigException, IOException, InvalidConfigException {
+            throw new UnsupportedOperationException();
+        }
+
+        public boolean containsConfiguration(Artifact configId) {
+            throw new UnsupportedOperationException();
+        }
+
+        public String getObjectName() {
+            throw new UnsupportedOperationException();
+        }
+
+        public AbstractName getAbstractName() {
+            throw new UnsupportedOperationException();
+        }
+
+        public List listConfigurations() {
+            throw new UnsupportedOperationException();
+        }
+
+        public File createNewConfigurationDir(Artifact configId) throws ConfigurationAlreadyExistsException {
+            throw new UnsupportedOperationException();
+        }
+
+        public Set resolve(Artifact configId, String moduleName, String path) throws NoSuchConfigException, MalformedURLException {
+            throw new UnsupportedOperationException();
+        }
+
+        public void exportConfiguration(Artifact configId, OutputStream output) throws IOException, NoSuchConfigException {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    private class MockConfigurationManager implements ConfigurationManager {
+        private ConfigurationData loadedConfigurationData;
+
+        public boolean isInstalled(Artifact configurationId) {
+            throw new UnsupportedOperationException();
+        }
+
+        public boolean isLoaded(Artifact configurationId) {
+            return isConfigurationAlreadyLoaded;
+        }
+
+        public boolean isRunning(Artifact configurationId) {
+            throw new UnsupportedOperationException();
+        }
+
+        public Artifact[] getInstalled(Artifact query) {
+            throw new UnsupportedOperationException();
+        }
+
+        public Artifact[] getLoaded(Artifact query) {
+            throw new UnsupportedOperationException();
+        }
+
+        public Artifact[] getRunning(Artifact query) {
+            throw new UnsupportedOperationException();
+        }
+
+        public List listConfigurations() {
+            return existingConfigurationInfos;
+        }
+
+        public List listStores() {
+            throw new UnsupportedOperationException();
+        }
+
+        public ConfigurationStore[] getStores() {
+            return new ConfigurationStore[]{store};
+        }
+
+        public ConfigurationStore getStoreForConfiguration(Artifact configuration) {
+            throw new UnsupportedOperationException();
+        }
+
+        public List listConfigurations(AbstractName store) throws NoSuchStoreException {
+            throw new UnsupportedOperationException();
+        }
+
+        public boolean isConfiguration(Artifact artifact) {
+            throw new UnsupportedOperationException();
+        }
+
+        public Configuration getConfiguration(Artifact configurationId) {
+            try {
+                return new Configuration(Collections.EMPTY_SET, loadedConfigurationData, new ConfigurationResolver(configurationId, dir), null);
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        }
+
+        public LifecycleResults loadConfiguration(Artifact configurationId) throws NoSuchConfigException, LifecycleException {
+            assertTrue("Did not expect configuration to be loaded " + configurationId, shouldLoad);
+            return null;
+        }
+
+        public LifecycleResults loadConfiguration(ConfigurationData configurationData) throws NoSuchConfigException, LifecycleException {
+            loadedConfigurationData = configurationData;
+            return null;
+        }
+
+        public LifecycleResults loadConfiguration(Artifact configurationId, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
+            throw new UnsupportedOperationException();
+        }
+
+        public LifecycleResults loadConfiguration(ConfigurationData configurationData, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
+            throw new UnsupportedOperationException();
+        }
+
+        public LifecycleResults unloadConfiguration(Artifact configurationId) throws NoSuchConfigException {
+            assertTrue("Did not expect configuration to be unloaded " + configurationId, shouldUnload);
+            return null;
+        }
+
+        public LifecycleResults unloadConfiguration(Artifact configurationId, LifecycleMonitor monitor) throws NoSuchConfigException {
+            throw new UnsupportedOperationException();
+        }
+
+        public LifecycleResults startConfiguration(Artifact configurationId) throws NoSuchConfigException, LifecycleException {
+            assertTrue("Did not expect configuration to be started " + configurationId, shouldStart);
+            return null;
+        }
+
+        public LifecycleResults startConfiguration(Artifact configurationId, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
+            throw new UnsupportedOperationException();
+        }
+
+        public LifecycleResults stopConfiguration(Artifact configurationId) throws NoSuchConfigException {
+            throw new UnsupportedOperationException();
+        }
+
+        public LifecycleResults stopConfiguration(Artifact configurationId, LifecycleMonitor monitor) throws NoSuchConfigException {
+            throw new UnsupportedOperationException();
+        }
+
+        public LifecycleResults restartConfiguration(Artifact configurationId) throws NoSuchConfigException, LifecycleException {
+            throw new UnsupportedOperationException();
+        }
+
+        public LifecycleResults restartConfiguration(Artifact configurationId, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
+            throw new UnsupportedOperationException();
+        }
+
+        public LifecycleResults reloadConfiguration(Artifact configurationId) throws NoSuchConfigException, LifecycleException {
+            throw new UnsupportedOperationException();
+        }
+
+        public LifecycleResults reloadConfiguration(Artifact configurationId, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
+            throw new UnsupportedOperationException();
+        }
+
+        public LifecycleResults reloadConfiguration(Artifact configurationId, Version version) throws NoSuchConfigException, LifecycleException {
+            throw new UnsupportedOperationException();
+        }
+
+        public LifecycleResults reloadConfiguration(Artifact configurationId, Version version, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
+            throw new UnsupportedOperationException();
+        }
+
+        public LifecycleResults reloadConfiguration(ConfigurationData configurationData) throws NoSuchConfigException, LifecycleException {
+            throw new UnsupportedOperationException();
+        }
+
+        public LifecycleResults reloadConfiguration(ConfigurationData configurationData, LifecycleMonitor monitor) throws NoSuchConfigException, LifecycleException {
+            throw new UnsupportedOperationException();
+        }
+
+        public void uninstallConfiguration(Artifact configurationId) throws IOException, NoSuchConfigException {
+            assertTrue("Did not expect configuration to be uninstalled " + configurationId, shouldUninstall);
+        }
+
+        public ArtifactResolver getArtifactResolver() {
+            return artifactResolver;
+        }
+    }
+}

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java?rev=397307&r1=397306&r2=397307&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java Wed Apr 26 14:32:30 2006
@@ -85,6 +85,11 @@
     private File inPlaceConfigurationDir;
 
     /**
+     * Should this configuraiton be autoStarted
+     */
+    private boolean autoStart = true;
+
+    /**
      * The naming system
      */
     private transient Naming naming;
@@ -234,6 +239,14 @@
 
     public void setNaming(Naming naming) {
         this.naming = naming;
+    }
+
+    public boolean isAutoStart() {
+        return autoStart;
+    }
+
+    public void setAutoStart(boolean autoStart) {
+        this.autoStart = autoStart;
     }
 
     public ConfigurationStore getConfigurationStore() {

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationInfo.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationInfo.java?rev=397307&r1=397306&r2=397307&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationInfo.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationInfo.java Wed Apr 26 14:32:30 2006
@@ -17,6 +17,7 @@
 package org.apache.geronimo.kernel.config;
 
 import java.io.Serializable;
+import java.io.File;
 import java.util.LinkedHashSet;
 import java.util.Set;
 
@@ -35,15 +36,17 @@
     private final Artifact configID;
     private final ConfigurationModuleType type;
     private final long created;
+    private final File inPlaceLocation;
     private final Set ownedConfigurations = new LinkedHashSet();
     private final State state;
     private final Artifact parentID;
 
-    public ConfigurationInfo(AbstractName storeName, Artifact configID, ConfigurationModuleType type, long created, Set ownedConfigurations) {
+    public ConfigurationInfo(AbstractName storeName, Artifact configID, ConfigurationModuleType type, long created, Set ownedConfigurations, File inPlaceLocation) {
         this.storeName = storeName;
         this.configID = configID;
         this.type = type;
         this.created = created;
+        this.inPlaceLocation = inPlaceLocation;
         if (ownedConfigurations != null) {
             this.ownedConfigurations.addAll(ownedConfigurations);
         }
@@ -51,11 +54,12 @@
         parentID = null;
     }
 
-    public ConfigurationInfo(AbstractName storeName, Artifact configID, ConfigurationModuleType type, long created, Set ownedConfigurations, State state) {
+    public ConfigurationInfo(AbstractName storeName, Artifact configID, ConfigurationModuleType type, long created, Set ownedConfigurations, File inPlaceLocation, State state) {
         this.storeName = storeName;
         this.configID = configID;
         this.type = type;
         this.created = created;
+        this.inPlaceLocation = inPlaceLocation;
         if (ownedConfigurations != null) {
             this.ownedConfigurations.addAll(ownedConfigurations);
         }
@@ -63,11 +67,12 @@
         parentID = null;
     }
 
-    public ConfigurationInfo(AbstractName storeName, Artifact configID, ConfigurationModuleType type, long created, Set ownedConfigurations, State state, Artifact parentID) {
+    public ConfigurationInfo(AbstractName storeName, Artifact configID, ConfigurationModuleType type, long created, Set ownedConfigurations, File inPlaceLocation, State state, Artifact parentID) {
         this.storeName = storeName;
         this.configID = configID;
         this.type = type;
         this.created = created;
+        this.inPlaceLocation = inPlaceLocation;
         if (ownedConfigurations != null) {
             this.ownedConfigurations.addAll(ownedConfigurations);
         }
@@ -89,6 +94,10 @@
 
     public long getCreated() {
         return created;
+    }
+
+    public File getInPlaceLocation() {
+        return inPlaceLocation;
     }
 
     public Set getOwnedConfigurations() {

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java?rev=397307&r1=397306&r2=397307&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java Wed Apr 26 14:32:30 2006
@@ -20,6 +20,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PrintWriter;
+import java.io.File;
 import java.net.URL;
 import java.util.Collection;
 import java.util.HashSet;
@@ -178,7 +179,7 @@
         }
     }
 
-    public static ConfigurationInfo readConfigurationInfo(InputStream in, AbstractName storeName) throws IOException {
+    public static ConfigurationInfo readConfigurationInfo(InputStream in, AbstractName storeName, File inPlaceLocation) throws IOException {
         Properties properties = new Properties();
         properties.load(in);
 
@@ -209,7 +210,7 @@
                 ownedConfigurations.add(ownedConfiguration);
             }
         }
-        return new ConfigurationInfo(storeName, configId, moduleType, time, ownedConfigurations);
+        return new ConfigurationInfo(storeName, configId, moduleType, time, ownedConfigurations, inPlaceLocation);
     }
 
     /**

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java?rev=397307&r1=397306&r2=397307&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java Wed Apr 26 14:32:30 2006
@@ -101,7 +101,6 @@
                 addNewConfigurationToModel(configuration);
                 configurationModel.load(configurationId);
                 configurationModel.start(configurationId);
-                configurations.put(configurationId, configuration);
                 return new LifecycleResults();
             } catch (GBeanNotFoundException e) {
                 // configuration was unloaded, just continue as normal
@@ -167,7 +166,7 @@
     public void start(Configuration configuration) throws InvalidConfigException {
         ConfigurationUtil.startConfigurationGBeans(configuration.getAbstractName(), configuration, kernel);
 
-        if (configurationList != null) {
+        if (configurationList != null && configuration.getConfigurationData().isAutoStart()) {
             configurationList.addConfiguration(configuration.getId().toString());
         }
     }

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java?rev=397307&r1=397306&r2=397307&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java Wed Apr 26 14:32:30 2006
@@ -174,13 +174,16 @@
                         configurationInfo.getType(),
                         configurationInfo.getCreated(),
                         configurationInfo.getOwnedConfigurations(),
+                        configurationInfo.getInPlaceLocation(),
                         State.RUNNING);
             } else {
                 configurationInfo = new ConfigurationInfo(store.getAbstractName(),
                         configurationInfo.getConfigID(),
                         configurationInfo.getType(),
                         configurationInfo.getCreated(),
-                        configurationInfo.getOwnedConfigurations(), State.STOPPED);
+                        configurationInfo.getOwnedConfigurations(),
+                        configurationInfo.getInPlaceLocation(),
+                        State.STOPPED);
             }
             iterator.set(configurationInfo);
         }
@@ -322,7 +325,7 @@
             Configuration parent = null;
             if (loadedConfigurations.containsKey(resolvedArtifact)) {
                 parent = (Configuration) loadedConfigurations.get(resolvedArtifact);
-            } else if (isConfiguration(resolvedArtifact)) {
+            } else if (configurations.containsKey(resolvedArtifact)) {
                 parent = getConfiguration(resolvedArtifact);
             } else {
                 throw new InvalidConfigException("Cound not find parent configuration: " + resolvedArtifact);

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java?rev=397307&r1=397306&r2=397307&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java (original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java Wed Apr 26 14:32:30 2006
@@ -392,6 +392,8 @@
             throw new NoSuchConfigException(configId);
         }
 
+        File inPlaceLocation = inPlaceConfUtil.readInPlaceLocation(location);
+
         ConfigurationInfo configurationInfo;
         if (location.isDirectory()) {
             File infoFile = new File(location, "META-INF");
@@ -399,7 +401,7 @@
 
             InputStream in = new FileInputStream(infoFile);
             try {
-                configurationInfo = ConfigurationUtil.readConfigurationInfo(in, getAbstractName());
+                configurationInfo = ConfigurationUtil.readConfigurationInfo(in, getAbstractName(), inPlaceLocation);
             } finally {
                 IOUtil.close(in);
             }
@@ -409,7 +411,7 @@
             try {
                 ZipEntry entry = jarFile.getEntry("META-INF/config.info");
                 in = jarFile.getInputStream(entry);
-                configurationInfo = ConfigurationUtil.readConfigurationInfo(in, getAbstractName());
+                configurationInfo = ConfigurationUtil.readConfigurationInfo(in, getAbstractName(), inPlaceLocation);
             } finally {
                 IOUtil.close(in);
                 IOUtil.close(jarFile);