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/03/16 07:49:41 UTC

svn commit: r386276 [3/4] - in /geronimo/branches/1.1: applications/console-core/src/java/org/apache/geronimo/console/util/ applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/ configs/client-system/src/plan/ configs/...

Copied: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java (from r385892, geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java)
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java?p2=geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java&p1=geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java&r1=385892&r2=386276&rev=386276&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java Wed Mar 15 22:49:33 2006
@@ -17,25 +17,16 @@
 
 package org.apache.geronimo.kernel.config;
 
-import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
 import java.util.Set;
+import java.util.Map;
 import java.util.HashSet;
+import java.io.IOException;
 import java.net.URL;
 import java.net.URI;
 import javax.management.ObjectName;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
@@ -55,10 +46,6 @@
 import org.apache.geronimo.kernel.repository.ArtifactManager;
 import org.apache.geronimo.kernel.repository.ArtifactResolver;
 import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
-import org.apache.geronimo.kernel.repository.Dependency;
-import org.apache.geronimo.kernel.repository.Environment;
-import org.apache.geronimo.kernel.repository.ImportType;
-import org.apache.geronimo.kernel.repository.MissingDependencyException;
 import org.apache.geronimo.kernel.repository.Repository;
 
 /**
@@ -69,21 +56,16 @@
  * @version $Rev: 384999 $ $Date$
  * @see EditableConfigurationManager
  */
-public class ConfigurationManagerImpl implements ConfigurationManager, GBeanLifecycle {
-    protected static final Log log = LogFactory.getLog(ConfigurationManagerImpl.class);
+public class KernelConfigurationManager extends SimpleConfigurationManager implements GBeanLifecycle {
 
     protected final Kernel kernel;
-    private final Collection stores;
     protected final ManageableAttributeStore attributeStore;
     protected final PersistentConfigurationList configurationList;
-    private final ShutdownHook shutdownHook;
     private final ArtifactManager artifactManager;
-    private final ArtifactResolver artifactResolver;
-    private final ClassLoader classLoader;
-    private final Map configurations = new LinkedHashMap();
-    private final Collection repositories;
+    protected final ClassLoader classLoader;
+    private final ShutdownHook shutdownHook;
 
-    public ConfigurationManagerImpl(Kernel kernel,
+    public KernelConfigurationManager(Kernel kernel,
             Collection stores,
             ManageableAttributeStore attributeStore,
             PersistentConfigurationList configurationList,
@@ -92,72 +74,32 @@
             Collection repositories,
             ClassLoader classLoader) {
 
-        if (kernel == null) throw new NullPointerException("kernel is null");
-        if (stores == null) stores = Collections.EMPTY_SET;
-        if (classLoader == null) throw new NullPointerException("classLoader is null");
-        if (artifactResolver == null) artifactResolver = new DefaultArtifactResolver(artifactManager, repositories);
-        if (repositories == null) repositories = Collections.EMPTY_SET;
+        super(stores,
+                createArtifactResolver(artifactResolver, artifactManager, repositories),
+                kernel.getNaming(),
+                repositories);
 
+        if (kernel == null) throw new NullPointerException("kernel is null");
         this.kernel = kernel;
-        this.stores = stores;
         this.attributeStore = attributeStore;
         this.configurationList = configurationList;
         this.artifactManager = artifactManager;
-        this.artifactResolver = artifactResolver;
-        this.repositories = repositories;
         this.classLoader = classLoader;
-        shutdownHook = new ShutdownHook(kernel);
-    }
-
-    public List listStores() {
-        List storeSnapshot = getStores();
-        List result = new ArrayList(storeSnapshot.size());
-        for (int i = 0; i < storeSnapshot.size(); i++) {
-            ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
-            result.add(JMXUtil.getObjectName(store.getObjectName()));
-        }
-        return result;
-    }
 
-    public List listConfigurations(ObjectName storeName) throws NoSuchStoreException {
-        List storeSnapshot = getStores();
-        for (int i = 0; i < storeSnapshot.size(); i++) {
-            ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
-            if (storeName.equals(JMXUtil.getObjectName(store.getObjectName()))) {
-                return store.listConfigurations();
-            }
-        }
-        throw new NoSuchStoreException("No such store: " + storeName);
+        shutdownHook = new ShutdownHook(kernel);
     }
 
-    public boolean isConfiguration(Artifact artifact) {
-        List storeSnapshot = getStores();
-        for (int i = 0; i < storeSnapshot.size(); i++) {
-            ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
-            if (store.containsConfiguration(artifact)) {
-                return true;
-            }
+    private static ArtifactResolver createArtifactResolver(ArtifactResolver artifactResolver, ArtifactManager artifactManager, Collection repositories) {
+        if (artifactResolver != null) {
+            return artifactResolver;
         }
-        return false;
+        return new DefaultArtifactResolver(artifactManager, repositories);
     }
 
-    public Configuration getConfiguration(Artifact configurationId) {
+    public synchronized Configuration loadConfiguration(Artifact configurationId) throws NoSuchConfigException, IOException, InvalidConfigException {
+        // todo hack for bootstrap deploy
         ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(configurationId);
-        return configurationStatus.getConfiguration();
-    }
-
-    public boolean isLoaded(Artifact configId) {
-        return configurations.containsKey(configId);
-    }
-
-    public Configuration loadConfiguration(Artifact configurationId) throws NoSuchConfigException, IOException, InvalidConfigException {
-        ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(configurationId);
-        if (configurationStatus != null) {
-            // already loaded, so just update the load count
-            configurationStatus.load();
-            return configurationStatus.getConfiguration();
-        } else if (kernel.isLoaded(Configuration.getConfigurationObjectName(configurationId))) {
-            // todo hack for bootstrap deploy
+        if (configurationStatus == null && kernel.isLoaded(Configuration.getConfigurationObjectName(configurationId))) {
             Configuration configuration = (Configuration) kernel.getProxyManager().createProxy(Configuration.getConfigurationObjectName(configurationId), Configuration.class);
             configurationStatus = createConfigurationStatus(configuration);
             configurationStatus.load();
@@ -165,246 +107,50 @@
             return configurationStatus.getConfiguration();
         }
 
-        // load the GBeanData for the new configuration
-        GBeanData gbeanData = loadConfigurationGBeanData(configurationId);
-
-        // load the configuration
-        return loadConfiguration(gbeanData);
+        return super.loadConfiguration(configurationId);
     }
 
-    public Configuration loadConfiguration(ConfigurationData configurationData) throws NoSuchConfigException, IOException, InvalidConfigException {
-        return loadConfiguration(configurationData, null);
-    }
+    protected Configuration load(GBeanData configurationData, Map loadedConfigurations) throws InvalidConfigException {
+        Artifact configurationId = getConfigurationId(configurationData);
+        AbstractName configurationName = Configuration.getConfigurationAbstractName(configurationId);
 
-    public Configuration loadConfiguration(ConfigurationData configurationData, ConfigurationStore configurationStore) throws NoSuchConfigException, IOException, InvalidConfigException {
-        GBeanData gbeanData = ConfigurationUtil.toConfigurationGBeanData(configurationData, configurationStore, repositories, artifactResolver);
-        return loadConfiguration(gbeanData);
-    }
-
-    private Configuration loadConfiguration(GBeanData gbeanData) throws NoSuchConfigException, IOException, InvalidConfigException {
-        Artifact id = getConfigurationId(gbeanData);
-        if (configurations.containsKey(id)) {
-            // already loaded, so just update the load count
-            ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(id);
-            configurationStatus.load();
-            return configurationStatus.getConfiguration();
-        }
-
-        // load configurations from the new child to the parents
-        LinkedHashMap unloadedConfigurations = new LinkedHashMap();
-        loadDepthFirst(gbeanData, unloadedConfigurations);
-
-        // load and start the unloaded configurations depth first
-        Map loadedConfigurations = new LinkedHashMap(unloadedConfigurations.size());
+        // load the configuation
         try {
-            for (Iterator iterator = unloadedConfigurations.entrySet().iterator(); iterator.hasNext();) {
-                Map.Entry entry = (Map.Entry) iterator.next();
-                Artifact configurationId = (Artifact) entry.getKey();
-                GBeanData configurationData = (GBeanData) entry.getValue();
-                AbstractName configurationName = Configuration.getConfigurationAbstractName(configurationId);
-
-                // load the configuation
-                try {
-                    kernel.loadGBean(configurationData, classLoader);
-                } catch (GBeanAlreadyExistsException e) {
-                    throw new InvalidConfigException("Unable to load configuration gbean " + configurationId, e);
-                }
-
-                // start the configuration and assure it started
-                Configuration configuration;
-                try {
-                    kernel.startGBean(configurationName);
-                    if (State.RUNNING_INDEX != kernel.getGBeanState(configurationName)) {
-                        throw new InvalidConfigurationException("Configuration gbean failed to start " + configurationId);
-                    }
-
-                    // create a proxy to the configuration
-                    configuration = (Configuration) kernel.getProxyManager().createProxy(configurationName, Configuration.class);
-                    loadedConfigurations.put(configurationId, configuration);
-
-                    // declare the dependencies as loaded
-                    if (artifactManager != null) {
-                        artifactManager.loadArtifacts(configurationId, configuration.getDependencies());
-                    }
-
-                    log.debug("Loaded Configuration " + configurationName);
-                } catch (InvalidConfigurationException e) {
-                    throw e;
-                } catch (Exception e) {
-                    safeConfigurationUnload(configurationId);
-                    if (e instanceof InvalidConfigException) {
-                        throw (InvalidConfigException) e;
-                    }
-                    throw new InvalidConfigException("Error starting configuration gbean " + configurationId, e);
-                }
-
-//                // todo move this to startConfiguration when deployment code has been update to not search kernel
-//                registerGBeans(configuration);
-            }
-        } catch (Exception e) {
-            for (Iterator iterator = loadedConfigurations.keySet().iterator(); iterator.hasNext();) {
-                Artifact configurationId = (Artifact) iterator.next();
-                safeConfigurationUnload(configurationId);
-            }
-            if (e instanceof InvalidConfigException) {
-                throw (InvalidConfigException) e;
-            }
-            throw new InvalidConfigException("Unable to start configuration gbean " + id, e);
+            kernel.loadGBean(configurationData, classLoader);
+        } catch (GBeanAlreadyExistsException e) {
+            throw new InvalidConfigException("Unable to load configuration gbean " + configurationId, e);
         }
 
-        // update the status of the loaded configurations
-        for (Iterator iterator = loadedConfigurations.values().iterator(); iterator.hasNext();) {
-            Configuration configuration = (Configuration) iterator.next();
-            ConfigurationStatus configurationStatus = createConfigurationStatus(configuration);
-            configurations.put(getConfigurationId(configuration), configurationStatus);
-        }
-
-        ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(id);
-        configurationStatus.load();
-        return configurationStatus.getConfiguration();
-    }
-
-    private ConfigurationStatus createConfigurationStatus(Configuration configuration) {
-        // start parents are just the service parents of the configuration... we want the services to be running so we can use them
-        List startParents = getParentStatuses(configuration.getServiceParents());
-
-        // load parents are both the class parents and the service parents
-        LinkedHashSet loadParents = new LinkedHashSet(startParents);
-        loadParents.addAll(getParentStatuses(configuration.getClassParents()));
-
-        ConfigurationStatus configurationStatus = new ConfigurationStatus(configuration, new ArrayList(loadParents), startParents);
-        return configurationStatus;
-    }
-
-    private List getParentStatuses(List parents) {
-        List parentStatuses = new ArrayList(parents.size());
-        for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
-            Configuration parent = (Configuration) iterator.next();
-            Artifact parentId = getConfigurationId(parent);
-            ConfigurationStatus parentStatus = (ConfigurationStatus) configurations.get(parentId);
-            if (parentStatus == null) {
-                throw new IllegalStateException("Parent status not found " + parentId);
-            }
-
-            parentStatuses.add(parentStatus);
-        }
-        return parentStatuses;
-    }
-
-    private Artifact getConfigurationId(GBeanData gbeanData) {
-        Environment environment = (Environment) gbeanData.getAttribute("environment");
-        return environment.getConfigId();
-    }
-
-    private void loadDepthFirst(GBeanData gbeanData, LinkedHashMap unloadedConfigurations) throws NoSuchConfigException, IOException, InvalidConfigException {
+        // start the configuration and assure it started
+        Configuration configuration;
         try {
-            // if this parent hasn't already been processed, iterate into the parent
-            Artifact configurationId = getConfigurationId(gbeanData);
-            if (!unloadedConfigurations.containsKey(configurationId)) {
-                preprocessConfiguration(gbeanData);
-
-                Environment environment = (Environment) gbeanData.getAttribute("environment");
-                for (Iterator iterator = environment.getDependencies().iterator(); iterator.hasNext();) {
-                    Dependency dependency = (Dependency) iterator.next();
-                    Artifact parentId = dependency.getArtifact();
-                    if (!configurations.containsKey(parentId) && isConfiguration(parentId)) {
-                        GBeanData parentGBeanData = loadConfigurationGBeanData(parentId);
-                        loadDepthFirst(parentGBeanData, unloadedConfigurations);
-                    }
-                }
+            kernel.startGBean(configurationName);
+            if (State.RUNNING_INDEX != kernel.getGBeanState(configurationName)) {
+                throw new InvalidConfigurationException("Configuration gbean failed to start " + configurationId);
             }
 
-            // depth first - all unloaded parents have been added, now add this configuration
-            unloadedConfigurations.put(configurationId, gbeanData);
-        } catch (NoSuchConfigException e) {
-            throw e;
-        } catch (IOException e) {
-            throw e;
-        } catch (InvalidConfigException e) {
-            throw e;
-        } catch (Exception e) {
-            throw new InvalidConfigException(e);
-        }
-    }
+            // create a proxy to the configuration
+            configuration = (Configuration) kernel.getProxyManager().createProxy(configurationName, Configuration.class);
 
-    private GBeanData loadConfigurationGBeanData(Artifact configId) throws NoSuchConfigException, IOException, InvalidConfigException {
-        List storeSnapshot = getStores();
-
-        for (int i = 0; i < storeSnapshot.size(); i++) {
-            ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
-            if (store.containsConfiguration(configId)) {
-                GBeanData configurationGBean = store.loadConfiguration(configId);
-                AbstractName configurationName = Configuration.getConfigurationAbstractName(configId);
-                configurationGBean.setAbstractName(configurationName);
-
-                Environment environment = (Environment) configurationGBean.getAttribute("environment");
-                ConfigurationResolver configurationResolver = new ConfigurationResolver(environment.getConfigId(), store, repositories, artifactResolver);
-                configurationGBean.setAttribute("configurationResolver", configurationResolver);
-
-                return configurationGBean;
+            // declare the dependencies as loaded
+            if (artifactManager != null) {
+                artifactManager.loadArtifacts(configurationId, configuration.getDependencies());
             }
-        }
-        throw new NoSuchConfigException("No configuration with id: " + configId);
-    }
-
-    private void preprocessConfiguration(GBeanData gbeanData) throws MissingDependencyException, InvalidConfigException {
-        Environment environment = (Environment) gbeanData.getAttribute("environment");
-
-        LinkedHashSet parentNames = new LinkedHashSet();
-        List dependencies = new ArrayList(environment.getDependencies());
-        for (ListIterator iterator = dependencies.listIterator(); iterator.hasNext();) {
-            Dependency dependency = (Dependency) iterator.next();
-            Artifact resolvedArtifact = artifactResolver.resolve(dependency.getArtifact());
-            if (isConfiguration(resolvedArtifact)) {
-                AbstractName parentName = Configuration.getConfigurationAbstractName(resolvedArtifact);
-                parentNames.add(parentName);
 
-                // update the dependency list to contain the resolved artifact
-                dependency = new Dependency(resolvedArtifact, dependency.getImportType());
-                iterator.set(dependency);
-            } else if (dependency.getImportType() == ImportType.SERVICES) {
-                // Service depdendencies require that the depdencency be a configuration
-                throw new InvalidConfigException("Dependency does not have services: " + resolvedArtifact);
+            log.debug("Loaded Configuration " + configurationName);
+        } catch (Exception e) {
+            unload(configurationId);
+            if (e instanceof InvalidConfigException) {
+                throw (InvalidConfigException) e;
             }
+            throw new InvalidConfigException("Error starting configuration gbean " + configurationId, e);
         }
-        environment.setDependencies(dependencies);
-
-
-        // add parents to the parents reference collection
-        gbeanData.addDependencies(parentNames);
-        gbeanData.setReferencePatterns("Parents", parentNames);
-    }
-
-    private void safeConfigurationUnload(Artifact configurationId) {
-        AbstractName configurationName;
-        try {
-            configurationName = Configuration.getConfigurationAbstractName(configurationId);
-        } catch (InvalidConfigException e) {
-            throw new AssertionError(e);
-        }
-
-        // unload this configuration
-        try {
-            kernel.stopGBean(configurationName);
-        } catch (GBeanNotFoundException ignored) {
-            // Good
-        } catch (Exception stopException) {
-            log.warn("Unable to stop failed configuration: " + configurationId, stopException);
-        }
-
-        try {
-            kernel.unloadGBean(configurationName);
-        } catch (GBeanNotFoundException ignored) {
-            // Good
-        } catch (Exception unloadException) {
-            log.warn("Unable to unload failed configuration: " + configurationId, unloadException);
-        }
+        return configuration;
     }
 
-    private void registerGBeans(Configuration configuration) throws InvalidConfigException {
+    public void start(Configuration configuration) throws InvalidConfigException {
         // load the attribute overrides from the attribute store
-        Map gbeanMap = configuration.getGBeans();
-        Collection gbeans = gbeanMap.values();
+        Collection gbeans = configuration.getGBeans().values();
         if (attributeStore != null) {
             gbeans = attributeStore.applyOverrides(getConfigurationId(configuration), gbeans, configuration.getConfigurationClassLoader());
         }
@@ -426,6 +172,33 @@
                 throw new InvalidConfigException(e);
             }
         }
+
+        try {
+            // start the gbeans
+            for (Iterator iterator = gbeans.iterator(); iterator.hasNext();) {
+                GBeanData gbeanData = (GBeanData) iterator.next();
+                AbstractName gbeanName = gbeanData.getAbstractName();
+                if (kernel.isGBeanEnabled(gbeanName)) {
+                    kernel.startRecursiveGBean(gbeanName);
+                }
+            }
+
+            // assure all of the gbeans are started
+            for (Iterator iterator = gbeans.iterator(); iterator.hasNext();) {
+                GBeanData gbeanData = (GBeanData) iterator.next();
+                AbstractName gbeanName = gbeanData.getAbstractName();
+                if (State.RUNNING_INDEX != kernel.getGBeanState(gbeanName)) {
+                    throw new InvalidConfigurationException("Configuration " + getConfigurationId(configuration) + " failed to start because gbean " + gbeanName + " did not start");
+                }
+            }
+        } catch (GBeanNotFoundException e) {
+            throw new InvalidConfigException(e);
+        }
+        // todo clean up after failure
+
+        if (configurationList != null) {
+            configurationList.addConfiguration(getConfigurationId(configuration).toString());
+        }
     }
 
     protected static void preprocessGBeanData(Configuration configuration, GBeanData gbeanData) throws InvalidConfigException {
@@ -477,75 +250,7 @@
         gbeanData.addDependency(configuration.getAbstractName());
     }
 
-    public void startConfiguration(Configuration configuration) throws InvalidConfigException {
-        startConfiguration(getConfigurationId(configuration));
-    }
-
-    public void startConfiguration(Artifact id) throws InvalidConfigException {
-        ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(id);
-        if (configurationStatus == null) {
-            throw new InvalidConfigurationException("Configuration is not loaded " + id);
-        }
-
-        // todo recursion disabled
-        List startList = configurationStatus.start();
-        for (Iterator iterator = startList.iterator(); iterator.hasNext();) {
-            Configuration configuration = (Configuration) iterator.next();
-            start(configuration);
-        }
-        // todo clean up after failure
-    }
-
-    public void start(Configuration configuration) throws InvalidConfigException {
-        // todo move this from loadConfiguration when deployment code has been update to not search kernel
-         registerGBeans(configuration);
-
-        try {
-            // start the gbeans
-            Map gbeans = configuration.getGBeans();
-            for (Iterator iterator = gbeans.values().iterator(); iterator.hasNext();) {
-                GBeanData gbeanData = (GBeanData) iterator.next();
-                AbstractName gbeanName = gbeanData.getAbstractName();
-                if (kernel.isGBeanEnabled(gbeanName)) {
-                    kernel.startRecursiveGBean(gbeanName);
-                }
-            }
-
-            // assure all of the gbeans are started
-            for (Iterator iterator = gbeans.keySet().iterator(); iterator.hasNext();) {
-                AbstractName gbeanName = (AbstractName) iterator.next();
-                if (State.RUNNING_INDEX != kernel.getGBeanState(gbeanName)) {
-                    throw new InvalidConfigurationException("Configuration " + getConfigurationId(configuration) + " failed to start because gbean " + gbeanName + " did not start");
-                }
-            }
-        } catch (GBeanNotFoundException e) {
-            throw new InvalidConfigException(e);
-        }
-        // todo clean up after failure
-
-        if (configurationList != null) {
-            configurationList.addConfiguration(getConfigurationId(configuration).toString());
-        }
-    }
-
-    public void stopConfiguration(Configuration configuration) throws InvalidConfigException {
-        stopConfiguration(getConfigurationId(configuration));
-    }
-
-    public void stopConfiguration(Artifact id) throws InvalidConfigException {
-        ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(id);
-        if (configurationStatus == null) {
-            throw new InvalidConfigurationException("Configuration is not loaded " + id);
-        }
-
-        List stopList = configurationStatus.stop();
-        for (Iterator iterator = stopList.iterator(); iterator.hasNext();) {
-            Configuration configuration = (Configuration) iterator.next();
-            stop(configuration);
-        }
-    }
-
-    private void stop(Configuration configuration) throws InvalidConfigException {
+    protected void stop(Configuration configuration) throws InvalidConfigException {
         try {
             Collection gbeans = configuration.getGBeans().values();
 
@@ -569,72 +274,41 @@
         }
     }
 
-    public void unloadConfiguration(Configuration configuration) throws NoSuchConfigException {
-        unloadConfiguration(getConfigurationId(configuration));
-    }
-
-    private Artifact getConfigurationId(Configuration configuration) {
-        return configuration.getEnvironment().getConfigId();
-    }
-
-    public void unloadConfiguration(Artifact id) throws NoSuchConfigException {
-        ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(id);
-        List unloadList = configurationStatus.unload();
-        for (Iterator iterator = unloadList.iterator(); iterator.hasNext();) {
-            Configuration configuration = (Configuration) iterator.next();
-            Artifact configurationId = getConfigurationId(configuration);
-            unload(configurationId);
-            configurations.remove(configurationId);
-        }
+    protected void unload(Configuration configuration) {
+        Artifact configurationId = getConfigurationId(configuration);
+        unload(configurationId);
     }
 
-    private void unload(Artifact configurationId) throws NoSuchConfigException {
-        AbstractName configName;
+    private void unload(Artifact configurationId) {
+        AbstractName configurationName;
         try {
-            configName = Configuration.getConfigurationAbstractName(configurationId);
+            configurationName = Configuration.getConfigurationAbstractName(configurationId);
         } catch (InvalidConfigException e) {
-            throw new NoSuchConfigException("Could not construct configuration object name", e);
+            throw new AssertionError(e);
         }
-        try {
-            if (State.RUNNING_INDEX == kernel.getGBeanState(configName)) {
-//                try {
-//                    Map gbeans = (Map) kernel.getAttribute(configName, "GBeans");
-//
-//                    // unload the gbeans
-//                    // todo move this to stopConfiguration
-//                    for (Iterator iterator = gbeans.values().iterator(); iterator.hasNext();) {
-//                        GBeanData gbeanData = (GBeanData) iterator.next();
-//                        AbstractName gbeanName = gbeanData.getAbstractName();
-//                        kernel.unloadGBean(gbeanName);
-//                    }
-//                } catch (Exception e) {
-//                    throw new InvalidConfigException("Could not stop gbeans in configuration", e);
-//                }
-                kernel.stopGBean(configName);
-            }
-            kernel.unloadGBean(configName);
 
-            // declare all artifacts as unloaded
-            if (artifactManager != null) {
-                artifactManager.unloadAllArtifacts(configurationId);
-            }
-        } catch (GBeanNotFoundException e) {
-            throw new NoSuchConfigException("No config registered: " + configName, e);
-        } catch (Exception e) {
-            throw new NoSuchConfigException("Problem unloading config: " + configName, e);
+        // unload this configuration
+        try {
+            kernel.stopGBean(configurationName);
+        } catch (GBeanNotFoundException ignored) {
+            // Good
+        } catch (Exception stopException) {
+            log.warn("Unable to stop failed configuration: " + configurationId, stopException);
         }
-    }
 
-    private List getStores() {
-        return new ArrayList(stores);
+        try {
+            kernel.unloadGBean(configurationName);
+        } catch (GBeanNotFoundException ignored) {
+            // Good
+        } catch (Exception unloadException) {
+            log.warn("Unable to unload failed configuration: " + configurationId, unloadException);
+        }
     }
 
     public void doStart() {
         kernel.registerShutdownHook(shutdownHook);
     }
 
-    private static final ObjectName CONFIG_QUERY = JMXUtil.getObjectName("geronimo.config:*");
-
     public void doStop() {
         kernel.unregisterShutdownHook(shutdownHook);
     }
@@ -643,28 +317,8 @@
         log.error("Cofiguration manager failed");
     }
 
-    public static final GBeanInfo GBEAN_INFO;
-
-    static {
-        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(ConfigurationManagerImpl.class, "ConfigurationManager");
-        infoFactory.addAttribute("kernel", Kernel.class, false);
-        infoFactory.addReference("Stores", ConfigurationStore.class, "ConfigurationStore");
-        infoFactory.addReference("AttributeStore", ManageableAttributeStore.class, ManageableAttributeStore.ATTRIBUTE_STORE);
-        infoFactory.addReference("PersistentConfigurationList", PersistentConfigurationList.class, PersistentConfigurationList.PERSISTENT_CONFIGURATION_LIST);
-        infoFactory.addReference("ArtifactManager", ArtifactManager.class, "ArtifactManager");
-        infoFactory.addReference("ArtifactResolver", ArtifactResolver.class, "ArtifactResolver");
-        infoFactory.addReference("Repositories", Repository.class, "Repository");
-        infoFactory.addAttribute("classLoader", ClassLoader.class, false);
-        infoFactory.addInterface(ConfigurationManager.class);
-        infoFactory.setConstructor(new String[]{"kernel", "Stores", "AttributeStore", "PersistentConfigurationList", "ArtifactManager", "ArtifactResolver", "Repositories", "classLoader"});
-        GBEAN_INFO = infoFactory.getBeanInfo();
-    }
-
-    public static GBeanInfo getGBeanInfo() {
-        return GBEAN_INFO;
-    }
-
     private static class ShutdownHook implements Runnable {
+        private static final ObjectName CONFIG_QUERY = JMXUtil.getObjectName("geronimo.config:*");
         private final Kernel kernel;
 
         public ShutdownHook(Kernel kernel) {
@@ -698,83 +352,24 @@
         }
     }
 
-    private static class ConfigurationStatus {
-        private final Configuration configuration;
-        private final List loadParents;
-        private final List startParents;
-        private int loadCount = 0;
-        private int startCount = 0;
-
-        public ConfigurationStatus(Configuration configuration, List loadParents, List startParents) {
-            if (!loadParents.containsAll(startParents)) throw new IllegalArgumentException("loadParents must contain all startParents");
-            this.configuration = configuration;
-            this.loadParents = loadParents;
-            this.startParents = startParents;
-        }
-
-        public Configuration getConfiguration() {
-            return configuration;
-        }
-
-        public int getLoadCount() {
-            return loadCount;
-        }
-
-        public void load() {
-            for (Iterator iterator = loadParents.iterator(); iterator.hasNext();) {
-                ConfigurationStatus parent = (ConfigurationStatus) iterator.next();
-                parent.load();
-            }
-            loadCount++;
-        }
-
-        public List unload() {
-            if (loadCount == 1 && startCount > 0) {
-                // todo this will most likely need to be removed
-                throw new IllegalStateException(configuration.getId() + " is RUNNING: startCount=" + startCount);
-            }
-
-            LinkedList unloadList = new LinkedList();
-            for (Iterator iterator = loadParents.iterator(); iterator.hasNext();) {
-                ConfigurationStatus parent = (ConfigurationStatus) iterator.next();
-                unloadList.addAll(parent.unload());
-            }
-            loadCount--;
-            if (loadCount == 0) {
-                assert(startCount == 0);
-                unloadList.addFirst(configuration);
-            }
-            return unloadList;
-        }
-
-        public int getStartCount() {
-            return startCount;
-        }
+    public static final GBeanInfo GBEAN_INFO;
 
-        public List start() {
-            List startList = new LinkedList();
-            for (Iterator iterator = startParents.iterator(); iterator.hasNext();) {
-                ConfigurationStatus parent = (ConfigurationStatus) iterator.next();
-                startList.addAll(parent.start());
-            }
-            startCount++;
-            if (startCount == 1) {
-                startList.add(configuration);
-            }
-            return startList;
-        }
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(KernelConfigurationManager.class, "ConfigurationManager");
+        infoFactory.addAttribute("kernel", Kernel.class, false);
+        infoFactory.addReference("Stores", ConfigurationStore.class, "ConfigurationStore");
+        infoFactory.addReference("AttributeStore", ManageableAttributeStore.class, ManageableAttributeStore.ATTRIBUTE_STORE);
+        infoFactory.addReference("PersistentConfigurationList", PersistentConfigurationList.class, PersistentConfigurationList.PERSISTENT_CONFIGURATION_LIST);
+        infoFactory.addReference("ArtifactManager", ArtifactManager.class, "ArtifactManager");
+        infoFactory.addReference("ArtifactResolver", ArtifactResolver.class, "ArtifactResolver");
+        infoFactory.addReference("Repositories", Repository.class, "Repository");
+        infoFactory.addAttribute("classLoader", ClassLoader.class, false);
+        infoFactory.addInterface(ConfigurationManager.class);
+        infoFactory.setConstructor(new String[]{"kernel", "Stores", "AttributeStore", "PersistentConfigurationList", "ArtifactManager", "ArtifactResolver", "Repositories", "classLoader"});
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
 
-        public List stop() {
-            LinkedList stopList = new LinkedList();
-            for (Iterator iterator = startParents.iterator(); iterator.hasNext();) {
-                ConfigurationStatus parent = (ConfigurationStatus) iterator.next();
-                stopList.addAll(parent.stop());
-            }
-            startCount--;
-            if (startCount == 0) {
-                stopList.addFirst(configuration);
-            }
-            return stopList;
-        }
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
     }
 }

Propchange: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=386276&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java (added)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java Wed Mar 15 22:49:33 2006
@@ -0,0 +1,502 @@
+/**
+ *
+ * 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.kernel.config;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import javax.management.ObjectName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.InvalidConfigurationException;
+import org.apache.geronimo.kernel.jmx.JMXUtil;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ArtifactResolver;
+import org.apache.geronimo.kernel.repository.Dependency;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.ImportType;
+import org.apache.geronimo.kernel.repository.MissingDependencyException;
+import org.apache.geronimo.kernel.Naming;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SimpleConfigurationManager implements ConfigurationManager {
+    protected static final Log log = LogFactory.getLog(SimpleConfigurationManager.class);
+    protected final Collection stores;
+    protected final ArtifactResolver artifactResolver;
+    protected final Map configurations = new LinkedHashMap();
+    protected final Collection repositories;
+    private final Naming naming;
+
+    public SimpleConfigurationManager(Collection stores, ArtifactResolver artifactResolver, Naming naming, Collection repositories) {
+        if (naming == null) throw new NullPointerException("naming is null");
+        if (stores == null) stores = Collections.EMPTY_SET;
+        if (repositories == null) repositories = Collections.EMPTY_SET;
+
+        this.stores = stores;
+        this.artifactResolver = artifactResolver;
+        this.naming = naming;
+        this.repositories = repositories;
+    }
+
+    public List listStores() {
+        List storeSnapshot = getStores();
+        List result = new ArrayList(storeSnapshot.size());
+        for (int i = 0; i < storeSnapshot.size(); i++) {
+            ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
+            result.add(JMXUtil.getObjectName(store.getObjectName()));
+        }
+        return result;
+    }
+
+    public List listConfigurations(ObjectName storeName) throws NoSuchStoreException {
+        List storeSnapshot = getStores();
+        for (int i = 0; i < storeSnapshot.size(); i++) {
+            ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
+            if (storeName.equals(JMXUtil.getObjectName(store.getObjectName()))) {
+                return store.listConfigurations();
+            }
+        }
+        throw new NoSuchStoreException("No such store: " + storeName);
+    }
+
+    public boolean isConfiguration(Artifact artifact) {
+        List storeSnapshot = getStores();
+        for (int i = 0; i < storeSnapshot.size(); i++) {
+            ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
+            if (store.containsConfiguration(artifact)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public synchronized Configuration getConfiguration(Artifact configurationId) {
+        ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(configurationId);
+        return configurationStatus.getConfiguration();
+    }
+
+    protected Artifact getConfigurationId(Configuration configuration) {
+        return configuration.getEnvironment().getConfigId();
+    }
+
+    public synchronized boolean isLoaded(Artifact configId) {
+        return configurations.containsKey(configId);
+    }
+
+    public synchronized Configuration loadConfiguration(Artifact configurationId) throws NoSuchConfigException, IOException, InvalidConfigException {
+        ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(configurationId);
+        if (configurationStatus != null) {
+            // already loaded, so just update the load count
+            configurationStatus.load();
+            return configurationStatus.getConfiguration();
+        }
+
+        // load the GBeanData for the new configuration
+        GBeanData gbeanData = loadConfigurationGBeanData(configurationId);
+
+        // load the configuration
+        return loadConfiguration(gbeanData);
+    }
+
+    public Configuration loadConfiguration(ConfigurationData configurationData) throws NoSuchConfigException, IOException, InvalidConfigException {
+        return loadConfiguration(configurationData, null);
+    }
+
+    public Configuration loadConfiguration(ConfigurationData configurationData, ConfigurationStore configurationStore) throws NoSuchConfigException, IOException, InvalidConfigException {
+        GBeanData gbeanData = ConfigurationUtil.toConfigurationGBeanData(configurationData, configurationStore, repositories, artifactResolver);
+        return loadConfiguration(gbeanData);
+    }
+
+    private synchronized Configuration loadConfiguration(GBeanData gbeanData) throws NoSuchConfigException, IOException, InvalidConfigException {
+        Artifact id = getConfigurationId(gbeanData);
+        if (configurations.containsKey(id)) {
+            // already loaded, so just update the load count
+            ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(id);
+            configurationStatus.load();
+            return configurationStatus.getConfiguration();
+        }
+
+        // load configurations from the new child to the parents
+        LinkedHashMap unloadedConfigurations = new LinkedHashMap();
+        loadDepthFirst(gbeanData, unloadedConfigurations);
+
+        // load and start the unloaded configurations depth first
+        Map loadedConfigurations = new LinkedHashMap(unloadedConfigurations.size());
+        try {
+            for (Iterator iterator = unloadedConfigurations.entrySet().iterator(); iterator.hasNext();) {
+                Map.Entry entry = (Map.Entry) iterator.next();
+                Artifact configurationId = (Artifact) entry.getKey();
+                GBeanData configurationData = (GBeanData) entry.getValue();
+                Configuration configuration = load(configurationData, loadedConfigurations);
+                loadedConfigurations.put(configurationId, configuration);
+            }
+        } catch (Exception e) {
+            for (Iterator iterator = loadedConfigurations.values().iterator(); iterator.hasNext();) {
+                Configuration configuration = (Configuration) iterator.next();
+                unload(configuration);
+            }
+            if (e instanceof InvalidConfigException) {
+                throw (InvalidConfigException) e;
+            }
+            throw new InvalidConfigException("Unable to start configuration gbean " + id, e);
+        }
+
+        // update the status of the loaded configurations
+        for (Iterator iterator = loadedConfigurations.values().iterator(); iterator.hasNext();) {
+            Configuration configuration = (Configuration) iterator.next();
+            ConfigurationStatus configurationStatus = createConfigurationStatus(configuration);
+            configurations.put(getConfigurationId(configuration), configurationStatus);
+        }
+
+        ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(id);
+        configurationStatus.load();
+        return configurationStatus.getConfiguration();
+    }
+
+    protected Configuration load(GBeanData configurationData, Map loadedConfigurations) throws InvalidConfigException {
+        Artifact configurationId = getConfigurationId(configurationData);
+        try {
+            Environment environment = (Environment) configurationData.getAttribute("environment");
+
+            LinkedHashMap parents = new LinkedHashMap();
+            List dependencies = new ArrayList(environment.getDependencies());
+            for (ListIterator iterator = dependencies.listIterator(); iterator.hasNext();) {
+                Dependency dependency = (Dependency) iterator.next();
+                Artifact resolvedArtifact = artifactResolver.resolve(dependency.getArtifact());
+
+                Configuration parent = null;
+                if (loadedConfigurations.containsKey(resolvedArtifact)) {
+                    parent = (Configuration) loadedConfigurations.get(resolvedArtifact);
+                } else if (isConfiguration(resolvedArtifact)) {
+                    parent = getConfiguration(resolvedArtifact);
+                } else if (dependency.getImportType() == ImportType.SERVICES) {
+                    // Service depdendencies require that the depdencency be a configuration
+                    throw new InvalidConfigException("Dependency does not have services: " + resolvedArtifact);
+                }
+
+                if (parent != null) {
+                    parents.put(resolvedArtifact, parent);
+
+                    // update the dependency list to contain the resolved artifact
+                    dependency = new Dependency(resolvedArtifact, dependency.getImportType());
+                    iterator.set(dependency);
+                }
+            }
+            environment.setDependencies(dependencies);
+
+            ConfigurationModuleType moduleType = (ConfigurationModuleType) configurationData.getAttribute("moduleType");
+            List classPath = (List) configurationData.getAttribute("classPath");
+            byte[] gbeanState = (byte[]) configurationData.getAttribute("gBeanState");
+            ConfigurationResolver configurationResolver = (ConfigurationResolver) configurationData.getAttribute("configurationResolver");
+
+            Configuration configuration = new Configuration(parents.values(), moduleType, environment, classPath, gbeanState, configurationResolver, naming);
+            configuration.doStart();
+            return configuration;
+        } catch (Exception e) {
+            throw new InvalidConfigException("Error starting configuration gbean " + configurationId, e);
+        }
+    }
+
+
+    protected synchronized ConfigurationStatus createConfigurationStatus(Configuration configuration) {
+        // start parents are just the service parents of the configuration... we want the services to be running so we can use them
+        List startParents = getParentStatuses(configuration.getServiceParents());
+
+        // load parents are both the class parents and the service parents
+        LinkedHashSet loadParents = new LinkedHashSet(startParents);
+        loadParents.addAll(getParentStatuses(configuration.getClassParents()));
+
+        ConfigurationStatus configurationStatus = new ConfigurationStatus(configuration, new ArrayList(loadParents), startParents);
+        return configurationStatus;
+    }
+
+    private synchronized List getParentStatuses(List parents) {
+        List parentStatuses = new ArrayList(parents.size());
+        for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
+            Configuration parent = (Configuration) iterator.next();
+            Artifact parentId = getConfigurationId(parent);
+            ConfigurationStatus parentStatus = (ConfigurationStatus) configurations.get(parentId);
+            if (parentStatus == null) {
+                throw new IllegalStateException("Parent status not found " + parentId);
+            }
+
+            parentStatuses.add(parentStatus);
+        }
+        return parentStatuses;
+    }
+
+    protected static Artifact getConfigurationId(GBeanData gbeanData) {
+        Environment environment = (Environment) gbeanData.getAttribute("environment");
+        return environment.getConfigId();
+    }
+
+    private synchronized void loadDepthFirst(GBeanData gbeanData, LinkedHashMap unloadedConfigurations) throws NoSuchConfigException, IOException, InvalidConfigException {
+        try {
+            // if this parent hasn't already been processed, iterate into the parent
+            Artifact configurationId = getConfigurationId(gbeanData);
+            if (!unloadedConfigurations.containsKey(configurationId)) {
+                preprocessConfiguration(gbeanData);
+
+                Environment environment = (Environment) gbeanData.getAttribute("environment");
+                for (Iterator iterator = environment.getDependencies().iterator(); iterator.hasNext();) {
+                    Dependency dependency = (Dependency) iterator.next();
+                    Artifact parentId = dependency.getArtifact();
+                    if (!configurations.containsKey(parentId) && isConfiguration(parentId)) {
+                        GBeanData parentGBeanData = loadConfigurationGBeanData(parentId);
+                        loadDepthFirst(parentGBeanData, unloadedConfigurations);
+                    }
+                }
+            }
+
+            // depth first - all unloaded parents have been added, now add this configuration
+            unloadedConfigurations.put(configurationId, gbeanData);
+        } catch (NoSuchConfigException e) {
+            throw e;
+        } catch (IOException e) {
+            throw e;
+        } catch (InvalidConfigException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new InvalidConfigException(e);
+        }
+    }
+
+    private GBeanData loadConfigurationGBeanData(Artifact configId) throws NoSuchConfigException, IOException, InvalidConfigException {
+        List storeSnapshot = getStores();
+
+        for (int i = 0; i < storeSnapshot.size(); i++) {
+            ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
+            if (store.containsConfiguration(configId)) {
+                GBeanData configurationGBean = store.loadConfiguration(configId);
+                AbstractName configurationName = Configuration.getConfigurationAbstractName(configId);
+                configurationGBean.setAbstractName(configurationName);
+
+                Environment environment = (Environment) configurationGBean.getAttribute("environment");
+                ConfigurationResolver configurationResolver = new ConfigurationResolver(environment.getConfigId(), store, repositories, artifactResolver);
+                configurationGBean.setAttribute("configurationResolver", configurationResolver);
+
+                return configurationGBean;
+            }
+        }
+        throw new NoSuchConfigException("No configuration with id: " + configId);
+    }
+
+    private void preprocessConfiguration(GBeanData gbeanData) throws MissingDependencyException, InvalidConfigException {
+        Environment environment = (Environment) gbeanData.getAttribute("environment");
+
+        LinkedHashSet parentNames = new LinkedHashSet();
+        List dependencies = new ArrayList(environment.getDependencies());
+        for (ListIterator iterator = dependencies.listIterator(); iterator.hasNext();) {
+            Dependency dependency = (Dependency) iterator.next();
+            Artifact resolvedArtifact = artifactResolver.resolve(dependency.getArtifact());
+            if (isConfiguration(resolvedArtifact)) {
+                AbstractName parentName = Configuration.getConfigurationAbstractName(resolvedArtifact);
+                parentNames.add(parentName);
+
+                // update the dependency list to contain the resolved artifact
+                dependency = new Dependency(resolvedArtifact, dependency.getImportType());
+                iterator.set(dependency);
+            } else if (dependency.getImportType() == ImportType.SERVICES) {
+                // Service depdendencies require that the depdencency be a configuration
+                throw new InvalidConfigException("Dependency does not have services: " + resolvedArtifact);
+            }
+        }
+        environment.setDependencies(dependencies);
+
+
+        // add parents to the parents reference collection
+        gbeanData.addDependencies(parentNames);
+        gbeanData.setReferencePatterns("Parents", parentNames);
+
+        gbeanData.setAttribute("naming", naming);
+    }
+
+    public void startConfiguration(Configuration configuration) throws InvalidConfigException {
+        startConfiguration(getConfigurationId(configuration));
+    }
+
+    public synchronized void startConfiguration(Artifact id) throws InvalidConfigException {
+        ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(id);
+        if (configurationStatus == null) {
+            throw new InvalidConfigurationException("Configuration is not loaded " + id);
+        }
+
+        List unstartedConfigurations = configurationStatus.start();
+        List startedConfigurations = new ArrayList(unstartedConfigurations.size());
+        try {
+            for (Iterator iterator = unstartedConfigurations.iterator(); iterator.hasNext();) {
+                Configuration configuration = (Configuration) iterator.next();
+                start(configuration);
+                startedConfigurations.add(configuration);
+            }
+        } catch (Exception e) {
+            for (Iterator iterator = startedConfigurations.iterator(); iterator.hasNext();) {
+                Configuration configuration = (Configuration) iterator.next();
+                stop(configuration);
+            }
+            if (e instanceof InvalidConfigException) {
+                throw (InvalidConfigException) e;
+            }
+            throw new InvalidConfigException("Unable to start configuration gbean " + id, e);
+        }
+    }
+
+    protected void start(Configuration configuration) throws InvalidConfigException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void stopConfiguration(Configuration configuration) throws InvalidConfigException {
+        stopConfiguration(getConfigurationId(configuration));
+    }
+
+    public synchronized void stopConfiguration(Artifact id) throws InvalidConfigException {
+        ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(id);
+        if (configurationStatus == null) {
+            throw new InvalidConfigurationException("Configuration is not loaded " + id);
+        }
+
+        List stopList = configurationStatus.stop();
+        for (Iterator iterator = stopList.iterator(); iterator.hasNext();) {
+            Configuration configuration = (Configuration) iterator.next();
+            stop(configuration);
+        }
+    }
+
+    protected void stop(Configuration configuration) throws InvalidConfigException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void unloadConfiguration(Configuration configuration) throws NoSuchConfigException {
+        unloadConfiguration(getConfigurationId(configuration));
+    }
+
+    public synchronized void unloadConfiguration(Artifact id) throws NoSuchConfigException {
+        ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(id);
+        List unloadList = configurationStatus.unload();
+        for (Iterator iterator = unloadList.iterator(); iterator.hasNext();) {
+            Configuration configuration = (Configuration) iterator.next();
+            Artifact configurationId = getConfigurationId(configuration);
+            unload(configuration);
+            configurations.remove(configurationId);
+        }
+    }
+
+    protected void unload(Configuration configuration) {
+        try {
+            configuration.doStop();
+        } catch (Exception e) {
+            log.debug("Problem unloading config: " + getConfigurationId(configuration), e);
+        }
+    }
+
+    private List getStores() {
+        return new ArrayList(stores);
+    }
+
+    protected static class ConfigurationStatus {
+        private final Configuration configuration;
+        private final List loadParents;
+        private final List startParents;
+        private int loadCount = 0;
+        private int startCount = 0;
+
+        public ConfigurationStatus(Configuration configuration, List loadParents, List startParents) {
+            if (!loadParents.containsAll(startParents)) throw new IllegalArgumentException("loadParents must contain all startParents");
+            this.configuration = configuration;
+            this.loadParents = loadParents;
+            this.startParents = startParents;
+        }
+
+        public Configuration getConfiguration() {
+            return configuration;
+        }
+
+        public int getLoadCount() {
+            return loadCount;
+        }
+
+        public void load() {
+            for (Iterator iterator = loadParents.iterator(); iterator.hasNext();) {
+                KernelConfigurationManager.ConfigurationStatus parent = (KernelConfigurationManager.ConfigurationStatus) iterator.next();
+                parent.load();
+            }
+            loadCount++;
+        }
+
+        public List unload() {
+            if (loadCount == 1 && startCount > 0) {
+                // todo this will most likely need to be removed
+                throw new IllegalStateException(configuration.getId() + " is RUNNING: startCount=" + startCount);
+            }
+
+            LinkedList unloadList = new LinkedList();
+            for (Iterator iterator = loadParents.iterator(); iterator.hasNext();) {
+                KernelConfigurationManager.ConfigurationStatus parent = (KernelConfigurationManager.ConfigurationStatus) iterator.next();
+                unloadList.addAll(parent.unload());
+            }
+            loadCount--;
+            if (loadCount == 0) {
+                assert(startCount == 0);
+                unloadList.addFirst(configuration);
+            }
+            return unloadList;
+        }
+
+        public int getStartCount() {
+            return startCount;
+        }
+
+        public List start() {
+            List startList = new LinkedList();
+            for (Iterator iterator = startParents.iterator(); iterator.hasNext();) {
+                KernelConfigurationManager.ConfigurationStatus parent = (KernelConfigurationManager.ConfigurationStatus) iterator.next();
+                startList.addAll(parent.start());
+            }
+            startCount++;
+            if (startCount == 1) {
+                startList.add(configuration);
+            }
+            return startList;
+        }
+
+        public List stop() {
+            LinkedList stopList = new LinkedList();
+            for (Iterator iterator = startParents.iterator(); iterator.hasNext();) {
+                KernelConfigurationManager.ConfigurationStatus parent = (KernelConfigurationManager.ConfigurationStatus) iterator.next();
+                stopList.addAll(parent.stop());
+            }
+            startCount--;
+            if (startCount == 0) {
+                stopList.addFirst(configuration);
+            }
+            return stopList;
+        }
+    }
+}

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/KernelDelegate.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/KernelDelegate.java?rev=386276&r1=386275&r2=386276&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/KernelDelegate.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/KernelDelegate.java Wed Mar 15 22:49:33 2006
@@ -37,11 +37,12 @@
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.NoSuchAttributeException;
 import org.apache.geronimo.kernel.NoSuchOperationException;
+import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor;
 import org.apache.geronimo.kernel.proxy.ProxyManager;
 
 /**
- * @version $Rev$ $Date$
+ * @version $Rev: 385487 $ $Date$
  */
 public class KernelDelegate implements Kernel {
     private final MBeanServerConnection mbeanServer;
@@ -58,6 +59,10 @@
 
     public String getKernelName() {
         return (String) getKernelAttribute("kernelName");
+    }
+
+    public Naming getNaming() {
+        throw new UnsupportedOperationException();
     }
 
     public void loadGBean(GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException {

Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java?rev=386276&r1=386275&r2=386276&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java Wed Mar 15 22:49:33 2006
@@ -23,7 +23,6 @@
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelFactory;
 import org.apache.geronimo.kernel.MockGBean;
-import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.repository.Artifact;
 
 /**
@@ -95,11 +94,12 @@
         // start a kernel
         Kernel kernel = KernelFactory.newInstance().createKernel("speed");
         kernel.boot();
-        GBeanData mockGBean = buildGBeanData();
+        AbstractName abstractName = kernel.getNaming().createRootName(new Artifact("test", "foo", "1", "car"), "test", "test");
+        GBeanData mockGBean = new GBeanData(abstractName, MockGBean.getGBeanInfo());
         mockGBean.setAttribute("Name", "bar");
         mockGBean.setAttribute("FinalInt", new Integer(57));
         kernel.loadGBean(mockGBean, Speed.class.getClassLoader());
-        kernel.startGBean(mockGBean.getAbstractName());
+        kernel.startGBean(abstractName);
 
         // reflect proxy
 //        ProxyFactory vmProxyFactory = new VMProxyFactory(MyInterface.class);
@@ -172,13 +172,6 @@
 //        printResults("CGLibProxy", end, start, iterations);
     }
 
-    private static GBeanData buildGBeanData() {
-        AbstractName abstractName = Naming.createRootName(new Artifact("test", "foo", "1", "car"), "test", "test");
-        GBeanData mockGBean = new GBeanData(abstractName, MockGBean.getGBeanInfo());
-        return mockGBean;
-    }
-
-
     public static void echoTimings() throws Exception {
         Method myMethod = MockGBean.class.getMethod("echo", new Class[]{String.class});
 
@@ -230,7 +223,8 @@
         // start a kernel
         Kernel kernel = KernelFactory.newInstance().createKernel("speed");
         kernel.boot();
-        GBeanData mockGBean = buildGBeanData();
+        AbstractName abstractName = kernel.getNaming().createRootName(new Artifact("test", "foo", "1", "car"), "test", "test");
+        GBeanData mockGBean = new GBeanData(abstractName, MockGBean.getGBeanInfo());
         mockGBean.setAttribute("Name", "bar");
         mockGBean.setAttribute("FinalInt", new Integer(57));
         kernel.loadGBean(mockGBean, Speed.class.getClassLoader());

Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java?rev=386276&r1=386275&r2=386276&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java Wed Mar 15 22:49:33 2006
@@ -24,7 +24,6 @@
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelFactory;
 import org.apache.geronimo.kernel.MockGBean;
-import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.repository.Artifact;
 
 /**
@@ -331,7 +330,7 @@
         kernel = KernelFactory.newInstance().createKernel("test");
         kernel.boot();
 
-        AbstractName name = Naming.createRootName(new Artifact("test", "foo", "1", "car"), "test", "test");
+        AbstractName name = kernel.getNaming().createRootName(new Artifact("test", "foo", "1", "car"), "test", "test");
         gbeanInstance = new GBeanInstance(new GBeanData(name, MockGBean.getGBeanInfo()),
                 kernel,
                 kernel.getDependencyManager(),

Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanDependencyTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanDependencyTest.java?rev=386276&r1=386275&r2=386276&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanDependencyTest.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanDependencyTest.java Wed Mar 15 22:49:33 2006
@@ -23,7 +23,6 @@
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelFactory;
 import org.apache.geronimo.kernel.MockGBean;
-import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.management.State;
 import org.apache.geronimo.kernel.repository.Artifact;
 
@@ -34,9 +33,9 @@
     private Kernel kernel;
 
     public void testGBeanDependency() throws Exception {
-        AbstractName parentName = Naming.createRootName(new Artifact("test", "foo", "1", "car"), "parent", "parent");
+        AbstractName parentName = kernel.getNaming().createRootName(new Artifact("test", "foo", "1", "car"), "parent", "parent");
         GBeanData gbeanDataParent = new GBeanData(parentName, MockGBean.getGBeanInfo());
-        GBeanData gbeanDataChild = new GBeanData(Naming.createChildName(parentName, "child", "child"), MockGBean.getGBeanInfo());
+        GBeanData gbeanDataChild = new GBeanData(kernel.getNaming().createChildName(parentName, "child", "child"), MockGBean.getGBeanInfo());
         gbeanDataChild.addDependency(new ReferencePatterns(parentName));
         kernel.loadGBean(gbeanDataChild, MockGBean.class.getClassLoader());
         kernel.startGBean(gbeanDataChild.getName());

Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java?rev=386276&r1=386275&r2=386276&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java Wed Mar 15 22:49:33 2006
@@ -25,7 +25,7 @@
 import org.apache.geronimo.kernel.config.ConfigurationData;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
 import org.apache.geronimo.kernel.config.EditableConfigurationManager;
-import org.apache.geronimo.kernel.config.EditableConfigurationManagerImpl;
+import org.apache.geronimo.kernel.config.EditableKernelConfigurationManager;
 import org.apache.geronimo.kernel.management.State;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
@@ -151,7 +151,7 @@
         Configuration configuration = configurationManager.loadConfiguration(configurationData);
         assertNotNull(configuration.getConfigurationClassLoader());
 
-        GBeanData mockBean3 = new GBeanData(configuration.getId(), "MyMockGMBean3", MockGBean.getGBeanInfo());
+        GBeanData mockBean3 = new GBeanData(MockGBean.getGBeanInfo());
         try {
             kernel.getGBeanState(mockBean3.getAbstractName());
             fail("Gbean should not be found yet");
@@ -160,7 +160,7 @@
         mockBean3.setAttribute("value", "1234");
         mockBean3.setAttribute("name", "child");
         mockBean3.setAttribute("finalInt", new Integer(1));
-        configurationManager.addGBeanToConfiguration(configuration.getId(), mockBean3, true);
+        configurationManager.addGBeanToConfiguration(configuration.getId(), "MyMockGMBean3", mockBean3, true);
 
         assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(mockBean3.getAbstractName()));
         assertEquals(new Integer(1), kernel.getAttribute(mockBean3.getAbstractName(), "finalInt"));
@@ -173,42 +173,37 @@
         kernel = KernelFactory.newInstance().createKernel("test");
         kernel.boot();
 
-        ConfigurationData bootstrap = new ConfigurationData(new Artifact("test", "test", "", "car"));
+        ConfigurationData bootstrap = new ConfigurationData(new Artifact("bootstrap", "bootstrap", "", "car"), kernel.getNaming());
 
-        GBeanData artifactManagerData = new GBeanData(bootstrap.getId(), "ArtifactManager", DefaultArtifactManager.GBEAN_INFO);
-        bootstrap.addGBean(artifactManagerData);
+        GBeanData artifactManagerData = bootstrap.addGBean("ArtifactManager", DefaultArtifactManager.GBEAN_INFO);
 
-        GBeanData artifactResolverData = new GBeanData(bootstrap.getId(), "ArtifactResolver", DefaultArtifactResolver.GBEAN_INFO);
+        GBeanData artifactResolverData = bootstrap.addGBean("ArtifactResolver", DefaultArtifactResolver.GBEAN_INFO);
         artifactResolverData.setReferencePattern("ArtifactManager", artifactManagerData.getAbstractName());
-        bootstrap.addGBean(artifactResolverData);
 
-        GBeanData configurationManagerData = new GBeanData(bootstrap.getId(), "ConfigurationManager", EditableConfigurationManagerImpl.GBEAN_INFO);
+        GBeanData configurationManagerData = bootstrap.addGBean("ConfigurationManager", EditableKernelConfigurationManager.GBEAN_INFO);
         configurationManagerData.setReferencePattern("ArtifactManager", artifactManagerData.getAbstractName());
         configurationManagerData.setReferencePattern("ArtifactResolver", artifactResolverData.getAbstractName());
-        bootstrap.addGBean(configurationManagerData);
 
         ConfigurationUtil.loadBootstrapConfiguration(kernel, bootstrap, getClass().getClassLoader());
 
         configurationManager = ConfigurationUtil.getEditableConfigurationManager(kernel);
 
 
-        configurationData = new ConfigurationData(new Artifact("geronimo", "test", "1", "car"));
+        configurationData = new ConfigurationData(new Artifact("test", "test", "", "car"), kernel.getNaming());
 
-        GBeanData mockBean1 = new GBeanData(configurationData.getId(),"MyMockGMBean1", MockGBean.getGBeanInfo());
+        GBeanData mockBean1 = configurationData.addGBean("MyMockGMBean1", MockGBean.getGBeanInfo());
         gbeanName1 = mockBean1.getAbstractName();
         mockBean1.setAttribute("value", "1234");
         mockBean1.setAttribute("name", "child");
         mockBean1.setAttribute("finalInt", new Integer(1));
-        configurationData.addGBean(mockBean1);
 
-        GBeanData mockBean2 = new GBeanData(configurationData.getId(), "MyMockGMBean2", MockGBean.getGBeanInfo());
+        GBeanData mockBean2 = configurationData.addGBean("MyMockGMBean2", MockGBean.getGBeanInfo());
         gbeanName2 = mockBean2.getAbstractName();
         mockBean2.setAttribute("value", "5678");
         mockBean2.setAttribute("name", "Parent");
         mockBean2.setAttribute("finalInt", new Integer(3));
         mockBean2.setReferencePattern("MockEndpoint", gbeanName1);
         mockBean2.setReferencePattern("EndpointCollection", new AbstractNameQuery(gbeanName1));
-        configurationData.addGBean(mockBean2);
     }
 
     protected void tearDown() throws Exception {

Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/GBeanTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/GBeanTest.java?rev=386276&r1=386275&r2=386276&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/GBeanTest.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/GBeanTest.java Wed Mar 15 22:49:33 2006
@@ -215,7 +215,7 @@
     }
 
     private GBeanData buildGBeanData(String name, String type, GBeanInfo info) {
-        AbstractName abstractName = Naming.createRootName(new Artifact("test", "foo", "1", "car"), name, type);
+        AbstractName abstractName = kernel.getNaming().createRootName(new Artifact("test", "foo", "1", "car"), name, type);
         return new GBeanData(abstractName, info);
     }
 }

Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java?rev=386276&r1=386275&r2=386276&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java Wed Mar 15 22:49:33 2006
@@ -36,7 +36,6 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelFactory;
-import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.management.State;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.ArtifactManager;
@@ -94,33 +93,33 @@
 
         Environment e1 = new Environment();
         e1.setConfigId(artifact1);
-        ConfigurationData configurationData1 = new ConfigurationData(ConfigurationModuleType.CAR, null, null, null, e1, new File("."));
+        ConfigurationData configurationData1 = new ConfigurationData(ConfigurationModuleType.CAR, null, null, null, e1, new File("."), kernel.getNaming());
         GBeanData gbeanData1 = ConfigurationUtil.toConfigurationGBeanData(configurationData1, configStore, Collections.singleton(testRepository), artifactResolver);
         configurations.put(artifact1, gbeanData1);
 
         Environment e2 = new Environment();
         e2.setConfigId(artifact2);
         e2.addDependency(new Artifact("test", "1", (Version) null, "bar"), ImportType.ALL);
-        ConfigurationData configurationData2 = new ConfigurationData(ConfigurationModuleType.CAR, null, null, null, e2, new File("."));
+        ConfigurationData configurationData2 = new ConfigurationData(ConfigurationModuleType.CAR, null, null, null, e2, new File("."), kernel.getNaming());
         GBeanData gbeanData2 = ConfigurationUtil.toConfigurationGBeanData(configurationData2, configStore, Collections.singleton(testRepository), artifactResolver);
         configurations.put(artifact2, gbeanData2);
 
         Environment e3 = new Environment();
         e3.setConfigId(artifact3);
         e3.addDependency(new Artifact("test", "2", (Version) null, "bar"), ImportType.ALL);
-        ConfigurationData configurationData3 = new ConfigurationData(ConfigurationModuleType.CAR, null, null, null, e3, new File("."));
+        ConfigurationData configurationData3 = new ConfigurationData(ConfigurationModuleType.CAR, null, null, null, e3, new File("."), kernel.getNaming());
         GBeanData gbeanData3 = ConfigurationUtil.toConfigurationGBeanData(configurationData3, configStore, Collections.singleton(testRepository), artifactResolver);
         configurations.put(artifact3, gbeanData3);
 
 
-        configurationManager = new ConfigurationManagerImpl(kernel,
+        configurationManager = new KernelConfigurationManager(kernel,
                 Collections.singleton(configStore),
                 null,
                 null,
                 artifactManager,
                 artifactResolver,
                 Collections.singleton(testRepository),
-                ConfigurationManagerImpl.class.getClassLoader());
+                KernelConfigurationManager.class.getClassLoader());
     }
 
     private class TestConfigStore implements ConfigurationStore {
@@ -158,7 +157,7 @@
     }
 
     private GBeanData buildGBeanData(String key, String value, GBeanInfo info) {
-        AbstractName abstractName = Naming.createRootName(new Artifact("test", "foo", "1", "car"), value, key);
+        AbstractName abstractName = kernel.getNaming().createRootName(new Artifact("test", "foo", "1", "car"), value, key);
         return new GBeanData(abstractName, info);
     }
 

Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java?rev=386276&r1=386275&r2=386276&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java Wed Mar 15 22:49:33 2006
@@ -24,6 +24,7 @@
 import org.apache.geronimo.kernel.config.NoSuchConfigException;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
 import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.Jsr77Naming;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
@@ -115,7 +116,8 @@
                 environment,
                 null,
                 null,
-                configurationResolver);
+                configurationResolver,
+                new Jsr77Naming());
 
         LinkedHashSet parents = new LinkedHashSet();
         parents.add(parent);

Modified: geronimo/branches/1.1/modules/naming-builder/src/test/org/apache/geronimo/naming/deployment/MessageDestinationTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/naming-builder/src/test/org/apache/geronimo/naming/deployment/MessageDestinationTest.java?rev=386276&r1=386275&r2=386276&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/naming-builder/src/test/org/apache/geronimo/naming/deployment/MessageDestinationTest.java (original)
+++ geronimo/branches/1.1/modules/naming-builder/src/test/org/apache/geronimo/naming/deployment/MessageDestinationTest.java Wed Mar 15 22:49:33 2006
@@ -28,12 +28,13 @@
 import org.apache.geronimo.j2ee.deployment.ResourceReferenceBuilder;
 import org.apache.geronimo.j2ee.deployment.ServiceReferenceBuilder;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 import org.apache.geronimo.kernel.config.ConfigurationResolver;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.Naming;
+import org.apache.geronimo.kernel.Jsr77Naming;
 import org.apache.geronimo.naming.java.ComponentContextBuilder;
 import org.apache.geronimo.xbeans.geronimo.naming.GerMessageDestinationType;
 import org.apache.geronimo.xbeans.j2ee.MessageDestinationRefType;
@@ -47,7 +48,7 @@
 import java.util.Map;
 
 /**
- * @version $Rev$ $Date$
+ * @version $Rev: 385372 $ $Date$
  */
 public class MessageDestinationTest extends TestCase {
     private RefContext refContext = new RefContext(new EJBReferenceBuilder() {
@@ -100,20 +101,23 @@
     }
 
     );
+    private static final Naming naming = new Jsr77Naming();
     Configuration configuration;
     AbstractName baseName;
 
     ComponentContextBuilder builder = new ComponentContextBuilder();
 
     protected void setUp() throws Exception {
+        super.setUp();
         Artifact id = new Artifact("test", "test", "", "car");
         configuration = new Configuration(Collections.EMPTY_LIST,
                 ConfigurationModuleType.RAR,
                 new Environment(id),
                 Collections.EMPTY_LIST,
-                new byte[] {},
-                new ConfigurationResolver(id, null));
-        baseName = Naming.createRootName(configuration.getId(), "testRoot", NameFactory.RESOURCE_ADAPTER_MODULE);
+                new byte[]{},
+                new ConfigurationResolver(id, null),
+                naming);
+        baseName = naming.createRootName(configuration.getId(), "testRoot", NameFactory.RESOURCE_ADAPTER_MODULE);
     }
 
     public void testMessageDestinations() throws Exception {
@@ -121,8 +125,8 @@
         GerMessageDestinationType[] gerdests = new GerMessageDestinationType[]{makeGerMD("d1", "l1"), makeGerMD("d2", "l2")};
         MessageDestinationRefType[] destRefs = new MessageDestinationRefType[]{makeMDR("n1", "d1"), makeMDR("n2", "d2")};
         ENCConfigBuilder.registerMessageDestinations(refContext, "module1", specdests, gerdests);
-        AbstractName n1 = Naming.createChildName(baseName, NameFactory.JCA_ADMIN_OBJECT, "l1");
-        AbstractName n2 = Naming.createChildName(baseName, NameFactory.JCA_ADMIN_OBJECT, "l2");
+        AbstractName n1 = naming.createChildName(baseName, "l1", NameFactory.JCA_ADMIN_OBJECT);
+        AbstractName n2 = naming.createChildName(baseName, "l2", NameFactory.JCA_ADMIN_OBJECT);
         configuration.addGBean(new GBeanData(n1, null));
         configuration.addGBean(new GBeanData(n2, null));
         ENCConfigBuilder.addMessageDestinationRefs(configuration, refContext, destRefs, this.getClass().getClassLoader(), builder);
@@ -135,8 +139,8 @@
         GerMessageDestinationType[] gerdests = new GerMessageDestinationType[]{makeGerMD("d1", "module1", "l1"), makeGerMD("d2", "module1", "l2")};
         MessageDestinationRefType[] destRefs = new MessageDestinationRefType[]{makeMDR("n1", "d1"), makeMDR("n2", "d2")};
         ENCConfigBuilder.registerMessageDestinations(refContext, "module1", specdests, gerdests);
-        AbstractName n1 = Naming.createChildName(baseName, NameFactory.JCA_ADMIN_OBJECT, "l1");
-        AbstractName n2 = Naming.createChildName(baseName, NameFactory.JCA_ADMIN_OBJECT, "l2");
+        AbstractName n1 = naming.createChildName(baseName, "l1", NameFactory.JCA_ADMIN_OBJECT);
+        AbstractName n2 = naming.createChildName(baseName, "l2", NameFactory.JCA_ADMIN_OBJECT);
         configuration.addGBean(new GBeanData(n1, null));
         configuration.addGBean(new GBeanData(n2, null));
         ENCConfigBuilder.addMessageDestinationRefs(configuration, refContext, destRefs, this.getClass().getClassLoader(), builder);