geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r384999 - in /geronimo/branches/1.1/modules/kernel/src: java/org/apache/geronimo/kernel/ java/org/apache/geronimo/kernel/config/ test/org/apache/geronimo/kernel/
Date Sat, 11 Mar 2006 03:42:12 GMT
Author: dain
Date: Fri Mar 10 19:42:09 2006
New Revision: 384999

URL: http://svn.apache.org/viewcvs?rev=384999&view=rev
Log:
Moved GBeanData preprocessing from ConfigurationManager to Configuration
Added findGBean(query) methods to Configuation which recursively searches the serviceParents
tree

Modified:
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/GBeanNotFoundException.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java
    geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/GBeanNotFoundException.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/GBeanNotFoundException.java?rev=384999&r1=384998&r2=384999&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/GBeanNotFoundException.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/GBeanNotFoundException.java
Fri Mar 10 19:42:09 2006
@@ -16,7 +16,10 @@
  */
 package org.apache.geronimo.kernel;
 
+import java.util.Set;
+
 import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
 
 import javax.management.ObjectName;
 
@@ -39,6 +42,10 @@
 
     public GBeanNotFoundException(AbstractName abstractName) {
         super(abstractName + " not found");
+    }
+
+    public GBeanNotFoundException(String message, Set patterns) {
+        super(message + ": " + patterns);
     }
 
     public ObjectName getGBeanName() {

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java?rev=384999&r1=384998&r2=384999&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
Fri Mar 10 19:42:09 2006
@@ -38,6 +38,7 @@
 import java.util.ListIterator;
 import java.util.Map;
 import java.util.Set;
+import java.util.HashSet;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
@@ -48,6 +49,10 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.ReferencePatterns;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GReferenceInfo;
+import org.apache.geronimo.gbean.GAttributeInfo;
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.ObjectInputStreamExt;
@@ -160,6 +165,11 @@
     private final List serviceParents = new ArrayList();
 
     /**
+     * All service parents depth first
+     */
+    private final List allServiceParents = new ArrayList();
+
+    /**
      * Artifacts added to the class loader (non-configuation artifacts).
      */
     private final LinkedHashSet dependencies;
@@ -300,6 +310,11 @@
         }
 
         //
+        // Get all service parents in depth first order
+        //
+        getDepthFirstServiceParents(this, allServiceParents);
+
+        //
         // Deserialize the GBeans
         //
         if (gbeanState != null && gbeanState.length > 0) {
@@ -326,6 +341,14 @@
                 Thread.currentThread().setContextClassLoader(oldCl);
             }
         }
+
+        //
+        // Preprocess all of the GBeans resolving the singleton-references, dependencies,
and setting a few configuration specific attributes
+        //
+        for (Iterator iterator = gbeans.values().iterator(); iterator.hasNext();) {
+            GBeanData gbeanData = (GBeanData) iterator.next();
+            preprocessGBeanData(gbeanData);
+        }
     }
 
     private List resolveDependencies(ArtifactResolver artifactResolver, Collection parents,
List dependencies) throws MissingDependencyException {
@@ -357,6 +380,14 @@
         return dependencies;
     }
 
+    private void getDepthFirstServiceParents(Configuration configuration, List ancestors)
{
+        ancestors.add(configuration);
+        for (Iterator parents = configuration.getServiceParents().iterator(); parents.hasNext();)
{
+            Configuration parent = (Configuration) parents.next();
+            getDepthFirstServiceParents(parent, ancestors);
+        }
+    }
+
     private URL[] buildClassPath(List classPath) throws MalformedURLException, MissingDependencyException,
NoSuchConfigException {
         List urls = new ArrayList();
         for (Iterator i = dependencies.iterator(); i.hasNext();) {
@@ -478,9 +509,10 @@
     }
 
     public synchronized void addGBean(GBeanData gbean) throws InvalidConfigException, GBeanAlreadyExistsException
{
-        if (gbeans.containsKey(gbean.getName())) {
+        if (gbeans.containsKey(gbean.getAbstractName())) {
             throw new GBeanAlreadyExistsException(gbean.getName().getCanonicalName());
         }
+        preprocessGBeanData(gbean);
         gbeans.put(gbean.getAbstractName(), gbean);
     }
 
@@ -489,6 +521,122 @@
             throw new GBeanNotFoundException(name);
         }
         gbeans.remove(name);
+    }
+
+    private void preprocessGBeanData(GBeanData gbeanData) throws InvalidConfigException {
+        for (Iterator references = gbeanData.getReferencesNames().iterator(); references.hasNext();)
{
+            String referenceName = (String) references.next();
+            GReferenceInfo referenceInfo = gbeanData.getGBeanInfo().getReference(referenceName);
+            if (referenceInfo == null) {
+                throw new InvalidConfigException("No reference named " + referenceName +
" in gbean " + gbeanData.getAbstractName());
+            }
+            boolean isSingleValued = !referenceInfo.getProxyType().equals(Collection.class.getName());
+            if (isSingleValued) {
+                ReferencePatterns referencePatterns = gbeanData.getReferencePatterns(referenceName);
+                AbstractName abstractName = null;
+                try {
+                    abstractName = findGBean(referencePatterns);
+                } catch (GBeanNotFoundException e) {
+                    throw new InvalidConfigException("Unable to resolve reference named "
+ referenceName + " in gbean " + gbeanData.getAbstractName(), e);
+                }
+                gbeanData.setReferencePatterns(referenceName, new ReferencePatterns(abstractName));
+            }
+        }
+
+        Set newDependencies = new HashSet();
+        for (Iterator dependencyIterator = gbeanData.getDependencies().iterator(); dependencyIterator.hasNext();)
{
+            ReferencePatterns referencePatterns = (ReferencePatterns) dependencyIterator.next();
+            AbstractName abstractName = null;
+            try {
+                abstractName = findGBean(referencePatterns);
+            } catch (GBeanNotFoundException e) {
+                throw new InvalidConfigException("Unable to resolve dependency in gbean "
+ gbeanData.getAbstractName(), e);
+            }
+            newDependencies.add(new ReferencePatterns(abstractName));
+        }
+        gbeanData.setDependencies(newDependencies);
+
+        // If the GBean has a configurationBaseUrl attribute, set it
+        // todo remove this when web app cl are config. cl.
+        GAttributeInfo attribute = gbeanData.getGBeanInfo().getAttribute("configurationBaseUrl");
+        if (attribute != null && attribute.getType().equals("java.net.URL")) {
+            try {
+                URL baseURL = configurationStore.resolve(id, URI.create(""));
+                gbeanData.setAttribute("configurationBaseUrl", baseURL);
+            } catch (Exception e) {
+                throw new InvalidConfigException("Unable to set attribute named " + "configurationBaseUrl"
+ " in gbean " + gbeanData.getAbstractName(), e);
+            }
+        }
+
+        // add a dependency from the gbean to the configuration
+        gbeanData.addDependency(abstractName);
+    }
+
+    public AbstractName findGBean(AbstractNameQuery pattern) throws GBeanNotFoundException
{
+        return findGBean(Collections.singleton(pattern));
+    }
+
+    public AbstractName findGBean(ReferencePatterns referencePatterns) throws GBeanNotFoundException
{
+        if (referencePatterns.getAbstractName() != null) {
+            // this pattern is already resolved
+            return referencePatterns.getAbstractName();
+        }
+
+        // check the local config
+        Set patterns = referencePatterns.getPatterns();
+        return findGBean(patterns);
+    }
+
+    public AbstractName findGBean(Set patterns) throws GBeanNotFoundException {
+        AbstractName result = resolve(this, patterns);
+        if (result != null) {
+            return result;
+        }
+
+        // search all parents
+        for (Iterator iterator = allServiceParents.iterator(); iterator.hasNext();) {
+            Configuration configuration = (Configuration) iterator.next();
+            AbstractName match = resolve(configuration, patterns);
+
+            // if we already found a match we have an ambiguous query
+            if (result != null) {
+                throw new GBeanNotFoundException("More than one match for referencePatterns",
patterns);
+            }
+            result = match;
+        }
+
+        if (result == null) {
+            throw new GBeanNotFoundException("No matches for referencePatterns", patterns);
+        }
+
+        return result;
+    }
+
+    private AbstractName resolve(Configuration configuration, Set patterns) throws GBeanNotFoundException
{
+        AbstractName result = null;
+
+        Set gbeanNames = configuration.getGBeans().keySet();
+        for (Iterator abstractNameQueries = patterns.iterator(); abstractNameQueries.hasNext();)
{
+            AbstractNameQuery abstractNameQuery =  (AbstractNameQuery) abstractNameQueries.next();
+            Artifact queryArtifact = abstractNameQuery.getArtifact();
+
+            // Does this query apply to this configuration
+            if (queryArtifact == null || queryArtifact.matches(configuration.getId())) {
+
+                // Search the GBeans
+                for (Iterator iterator = gbeanNames.iterator(); iterator.hasNext();) {
+                    AbstractName abstractName = (AbstractName) iterator.next();
+                    if (abstractNameQuery.matches(abstractName)) {
+                        // if we already found a match we have an ambiguous query
+                        if (result != null ) {
+                            throw new GBeanNotFoundException("More than one match to referencePatterns",
patterns);
+                        }
+                        result = abstractName;
+                    }
+                }
+            }
+        }
+        return result;
     }
 
     public void doStart() throws Exception {

Modified: 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/ConfigurationManagerImpl.java?rev=384999&r1=384998&r2=384999&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/ConfigurationManagerImpl.java
Fri Mar 10 19:42:09 2006
@@ -17,18 +17,29 @@
 
 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 javax.management.MalformedObjectNameException;
+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.GAttributeInfo;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.InvalidConfigurationException;
-import org.apache.geronimo.gbean.GReferenceInfo;
-import org.apache.geronimo.gbean.ReferencePatterns;
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.InternalKernelException;
@@ -40,29 +51,10 @@
 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.ImportType;
 import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.ImportType;
 import org.apache.geronimo.kernel.repository.MissingDependencyException;
 
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-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.ListIterator;
-import java.util.Map;
-import java.util.List;
-import java.util.Set;
-import java.util.HashSet;
-
 /**
  * The standard non-editable ConfigurationManager implementation.  That is,
  * you can save a lost configurations and stuff, but not change the set of
@@ -298,7 +290,7 @@
             // if this parent hasn't already been processed, iterate into the parent
             Artifact configurationId = getConfigurationId(gbeanData);
             if (!unloadedConfigurations.containsKey(configurationId)) {
-                preprocess(gbeanData);
+                preprocessConfiguration(gbeanData);
 
                 Environment environment = (Environment) gbeanData.getAttribute("environment");
                 for (Iterator iterator = environment.getDependencies().iterator(); iterator.hasNext();)
{
@@ -342,7 +334,7 @@
         throw new NoSuchConfigException("No configuration with id: " + configId);
     }
 
-    private void preprocess(GBeanData gbeanData) throws MissingDependencyException, InvalidConfigException
{
+    private void preprocessConfiguration(GBeanData gbeanData) throws MissingDependencyException,
InvalidConfigException {
         if (artifactManager != null) {
             gbeanData.setAttribute("artifactManager", artifactManager);
         }
@@ -401,7 +393,7 @@
         }
     }
 
-    private void registerGBeans(Configuration configuration) throws InvalidConfigException,
NoSuchConfigException, MalformedURLException {
+    private void registerGBeans(Configuration configuration) throws InvalidConfigException
{
         // load the attribute overrides from the attribute store
         Map gbeanMap = configuration.getGBeans();
         Collection gbeans = gbeanMap.values();
@@ -409,50 +401,50 @@
             gbeans = attributeStore.applyOverrides(getConfigurationId(configuration), gbeans,
configuration.getConfigurationClassLoader());
         }
 
-        List ancestors = new ArrayList();
-        resolveAncestors(configuration, ancestors);
+//        List ancestors = new ArrayList();
+//        resolveAncestors(configuration, ancestors);
 
         // register all the GBeans
-        AbstractName configurationName = Configuration.getConfigurationAbstractName(configuration.getId());
-        ConfigurationStore configurationStore = configuration.getConfigurationStore();
+//        AbstractName configurationName = Configuration.getConfigurationAbstractName(configuration.getId());
+//        ConfigurationStore configurationStore = configuration.getConfigurationStore();
         for (Iterator iterator = gbeans.iterator(); iterator.hasNext();) {
             GBeanData gbeanData = (GBeanData) iterator.next();
 
-            // copy the gbeanData object as not to mutate the original
-            gbeanData = new GBeanData(gbeanData);
-
-            for (Iterator references = gbeanData.getReferencesNames().iterator(); references.hasNext();)
{
-                String referenceName = (String) references.next();
-                GReferenceInfo referenceInfo = gbeanData.getGBeanInfo().getReference(referenceName);
-                if (referenceInfo == null) {
-                    throw new InvalidConfigException("No reference named " + referenceName
+ " in gbean " + gbeanData.getAbstractName());
-                }
-                boolean isSingleValued = !referenceInfo.getProxyType().equals(Collection.class.getName());
-                if (isSingleValued) {
-                    ReferencePatterns referencePatterns = gbeanData.getReferencePatterns(referenceName);
-                    ReferencePatterns resolvedPatterns = resolveReferencePatterns(referencePatterns,
ancestors);
-                    gbeanData.setReferencePatterns(referenceName, resolvedPatterns);
-                }
-            }
-
-            Set newDependencies = new HashSet();
-            for (Iterator dependencies = gbeanData.getDependencies().iterator(); dependencies.hasNext();)
{
-                ReferencePatterns referencePatterns = (ReferencePatterns) dependencies.next();
-                ReferencePatterns resolvedPatterns = resolveReferencePatterns(referencePatterns,
ancestors);
-                newDependencies.add(resolvedPatterns);
-            }
-            gbeanData.setDependencies(newDependencies);
-
-            // If the GBean has a configurationBaseUrl attribute, set it
-            // todo remove this when web app cl are config. cl.
-            GAttributeInfo attribute = gbeanData.getGBeanInfo().getAttribute("configurationBaseUrl");
-            if (attribute != null && attribute.getType().equals("java.net.URL"))
{
-                URL baseURL = configurationStore.resolve(getConfigurationId(configuration),
URI.create(""));
-                gbeanData.setAttribute("configurationBaseUrl", baseURL);
-            }
-
-            // add a dependency from the gbean to the configuration
-            gbeanData.addDependency(configurationName);
+//            // copy the gbeanData object as not to mutate the original
+//            gbeanData = new GBeanData(gbeanData);
+//
+//            for (Iterator references = gbeanData.getReferencesNames().iterator(); references.hasNext();)
{
+//                String referenceName = (String) references.next();
+//                GReferenceInfo referenceInfo = gbeanData.getGBeanInfo().getReference(referenceName);
+//                if (referenceInfo == null) {
+//                    throw new InvalidConfigException("No reference named " + referenceName
+ " in gbean " + gbeanData.getAbstractName());
+//                }
+//                boolean isSingleValued = !referenceInfo.getProxyType().equals(Collection.class.getName());
+//                if (isSingleValued) {
+//                    ReferencePatterns referencePatterns = gbeanData.getReferencePatterns(referenceName);
+//                    ReferencePatterns resolvedPatterns = resolveReferencePatterns(referencePatterns,
ancestors);
+//                    gbeanData.setReferencePatterns(referenceName, resolvedPatterns);
+//                }
+//            }
+//
+//            Set newDependencies = new HashSet();
+//            for (Iterator dependencies = gbeanData.getDependencies().iterator(); dependencies.hasNext();)
{
+//                ReferencePatterns referencePatterns = (ReferencePatterns) dependencies.next();
+//                ReferencePatterns resolvedPatterns = resolveReferencePatterns(referencePatterns,
ancestors);
+//                newDependencies.add(resolvedPatterns);
+//            }
+//            gbeanData.setDependencies(newDependencies);
+//
+//            // If the GBean has a configurationBaseUrl attribute, set it
+//            // todo remove this when web app cl are config. cl.
+//            GAttributeInfo attribute = gbeanData.getGBeanInfo().getAttribute("configurationBaseUrl");
+//            if (attribute != null && attribute.getType().equals("java.net.URL"))
{
+//                URL baseURL = configurationStore.resolve(getConfigurationId(configuration),
URI.create(""));
+//                gbeanData.setAttribute("configurationBaseUrl", baseURL);
+//            }
+//
+//            // add a dependency from the gbean to the configuration
+//            gbeanData.addDependency(configurationName);
 
             log.trace("Registering GBean " + gbeanData.getName());
 
@@ -464,60 +456,60 @@
         }
     }
 
-    private ReferencePatterns resolveReferencePatterns(ReferencePatterns referencePatterns,
List ancestors) throws InvalidConfigException {
-        ReferencePatterns result = null;
-        boolean first = true;
-        for (Iterator iterator = ancestors.iterator(); iterator.hasNext();) {
-            Configuration configuration = (Configuration) iterator.next();
-            ReferencePatterns match = resolve(referencePatterns, configuration);
-            if (first && match != null) {
-                return match;
-            }
-            first = false;
-            if (result != null) {
-                throw new InvalidConfigException("More than one match for referencePatterns
" + referencePatterns);
-            }
-            result = match;
-        }
-        if (result == null) {
-            throw new InvalidConfigException("No matches for referencePatterns: " + referencePatterns);
-        }
-        return result;
-    }
-
-    private ReferencePatterns resolve(ReferencePatterns referencePatterns, Configuration
configuration) throws InvalidConfigException {
-        if (referencePatterns.getAbstractName() != null) {
-            //this should not occur, but it means no further resolution is needed
-            return referencePatterns;
-        }
-        ReferencePatterns result = null;
-        Set gbeanNames = configuration.getGBeans().keySet();
-        for (Iterator abstractNameQueries = referencePatterns.getPatterns().iterator(); abstractNameQueries.hasNext();)
{
-            AbstractNameQuery abstractNameQuery =  (AbstractNameQuery) abstractNameQueries.next();
-            Artifact queryArtifact = abstractNameQuery.getArtifact();
-            //skip this configuration if we know it can't match.
-            if (queryArtifact == null || queryArtifact.matches(configuration.getId())) {
-                for (Iterator iterator = gbeanNames.iterator(); iterator.hasNext();) {
-                    AbstractName abstractName = (AbstractName) iterator.next();
-                    if (abstractNameQuery.matches(abstractName)) {
-                        if (result != null ) {
-                            throw new InvalidConfigException("More than one match to referencePatterns
" + referencePatterns + " in configuration " + configuration.getId());
-                        }
-                        result = new ReferencePatterns(abstractName);
-                    }
-                }
-            }
-        }
-        return result;
-    }
-
-    private void resolveAncestors(Configuration configuration, List ancestors) {
-        ancestors.add(configuration);
-        for (Iterator parents = configuration.getServiceParents().iterator(); parents.hasNext();)
{
-            Configuration parent = (Configuration) parents.next();
-            resolveAncestors(parent, ancestors);
-        }
-    }
+//    private ReferencePatterns resolveReferencePatterns(ReferencePatterns referencePatterns,
List ancestors) throws InvalidConfigException {
+//        ReferencePatterns result = null;
+//        boolean first = true;
+//        for (Iterator iterator = ancestors.iterator(); iterator.hasNext();) {
+//            Configuration configuration = (Configuration) iterator.next();
+//            ReferencePatterns match = resolve(referencePatterns, configuration);
+//            if (first && match != null) {
+//                return match;
+//            }
+//            first = false;
+//            if (result != null) {
+//                throw new InvalidConfigException("More than one match for referencePatterns
" + referencePatterns);
+//            }
+//            result = match;
+//        }
+//        if (result == null) {
+//            throw new InvalidConfigException("No matches for referencePatterns: " + referencePatterns);
+//        }
+//        return result;
+//    }
+//
+//    private ReferencePatterns resolve(ReferencePatterns referencePatterns, Configuration
configuration) throws InvalidConfigException {
+//        if (referencePatterns.getAbstractName() != null) {
+//            //this should not occur, but it means no further resolution is needed
+//            return referencePatterns;
+//        }
+//        ReferencePatterns result = null;
+//        Set gbeanNames = configuration.getGBeans().keySet();
+//        for (Iterator abstractNameQueries = referencePatterns.getPatterns().iterator();
abstractNameQueries.hasNext();) {
+//            AbstractNameQuery abstractNameQuery =  (AbstractNameQuery) abstractNameQueries.next();
+//            Artifact queryArtifact = abstractNameQuery.getArtifact();
+//            //skip this configuration if we know it can't match.
+//            if (queryArtifact == null || queryArtifact.matches(configuration.getId()))
{
+//                for (Iterator iterator = gbeanNames.iterator(); iterator.hasNext();) {
+//                    AbstractName abstractName = (AbstractName) iterator.next();
+//                    if (abstractNameQuery.matches(abstractName)) {
+//                        if (result != null ) {
+//                            throw new InvalidConfigException("More than one match to referencePatterns
" + referencePatterns + " in configuration " + configuration.getId());
+//                        }
+//                        result = new ReferencePatterns(abstractName);
+//                    }
+//                }
+//            }
+//        }
+//        return result;
+//    }
+//
+//    private void resolveAncestors(Configuration configuration, List ancestors) {
+//        ancestors.add(configuration);
+//        for (Iterator parents = configuration.getServiceParents().iterator(); parents.hasNext();)
{
+//            Configuration parent = (Configuration) parents.next();
+//            resolveAncestors(parent, ancestors);
+//        }
+//    }
 
     public void startConfiguration(Configuration configuration) throws InvalidConfigException
{
         startConfiguration(getConfigurationId(configuration));
@@ -759,6 +751,11 @@
         }
 
         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();

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=384999&r1=384998&r2=384999&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
Fri Mar 10 19:42:09 2006
@@ -166,6 +166,7 @@
         assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanName2));
 
         // unload -- configuration and gbeans should be unloaded
+        configurationManager.stopConfiguration(configuration);
         configurationManager.unloadConfiguration(configuration);
 
         assertFalse(kernel.isLoaded(configurationName));



Mime
View raw message