geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r390003 - in /geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel: config/Configuration.java repository/DefaultArtifactResolver.java
Date Thu, 30 Mar 2006 06:17:33 GMT
Author: dain
Date: Wed Mar 29 22:17:30 2006
New Revision: 390003

URL: http://svn.apache.org/viewcvs?rev=390003&view=rev
Log:
Configuration class loader now created with inverse class loader, hidden clases and non-overrideable
classes specified.

Modified:
    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/repository/DefaultArtifactResolver.java

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=390003&r1=390002&r2=390003&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
Wed Mar 29 22:17:30 2006
@@ -258,39 +258,14 @@
         }
 
         //
-        // Propagate non-overridable classes from class parents
-        //
-        for (Iterator iterator = classParents.iterator(); iterator.hasNext();) {
-            Configuration parent = (Configuration) iterator.next();
-
-            Environment parentEnvironment = parent.getEnvironment();
-            Set nonOverridableClasses = parentEnvironment.getNonOverrideableClasses();
-            environment.addNonOverrideableClasses(nonOverridableClasses);
-        }
-
-        //
         // Build the configuration class loader
         //
-        URL[] urls = buildClassPath(classPath);
-        log.debug("ClassPath for " + id + " resolved to " + Arrays.asList(urls));
-        if (parents.size() == 0 && classParents.size() == 0) {
-            // no explicit parent set, so use the class loader of this class as
-            // the parent... this class should be in the root geronimo classloader,
-            // which is normally the system class loader but not always, so be safe
-            configurationClassLoader = new MultiParentClassLoader(environment.getConfigId(),
urls, getClass().getClassLoader());
-        } else {
-            ClassLoader[] parentClassLoaders = new ClassLoader[classParents.size()];
-            for (ListIterator iterator = classParents.listIterator(); iterator.hasNext();)
{
-                Configuration configuration = (Configuration) iterator.next();
-                parentClassLoaders[iterator.previousIndex()] = configuration.getConfigurationClassLoader();
-            }
-            configurationClassLoader = new MultiParentClassLoader(environment.getConfigId(),
urls, parentClassLoaders);
-        }
+        configurationClassLoader = createConfigurationClasssLoader(parents, environment,
classPath);
 
         //
         // Get all service parents in depth first order
         //
-        getDepthFirstServiceParents(this, allServiceParents);
+        addDepthFirstServiceParents(this, allServiceParents);
 
         //
         // Deserialize the GBeans
@@ -321,11 +296,54 @@
         }
     }
 
-    private void getDepthFirstServiceParents(Configuration configuration, List ancestors)
{
+    private MultiParentClassLoader createConfigurationClasssLoader(Collection parents, Environment
environment, List classPath) throws MalformedURLException, MissingDependencyException, NoSuchConfigException
{
+        // create the URL list
+        URL[] urls = buildClassPath(classPath);
+
+        // parents
+        ClassLoader[] parentClassLoaders;
+        if (parents.size() == 0 && classParents.size() == 0) {
+            // no explicit parent set, so use the class loader of this class as
+            // the parent... this class should be in the root geronimo classloader,
+            // which is normally the system class loader but not always, so be safe
+            parentClassLoaders = new ClassLoader[] {getClass().getClassLoader()};
+        } else {
+            parentClassLoaders = new ClassLoader[classParents.size()];
+            for (ListIterator iterator = classParents.listIterator(); iterator.hasNext();)
{
+                Configuration configuration = (Configuration) iterator.next();
+                parentClassLoaders[iterator.previousIndex()] = configuration.getConfigurationClassLoader();
+            }
+        }
+
+        // hidden classes
+        Set hiddenClassesSet = environment.getHiddenClasses();
+        String[] hiddenClasses = (String[]) hiddenClassesSet.toArray(new String[hiddenClassesSet.size()]);
+
+        // we need to propagate the non-overrideable classes from parents
+        LinkedHashSet nonOverridableSet = new LinkedHashSet();
+        for (Iterator iterator = classParents.iterator(); iterator.hasNext();) {
+            Configuration parent = (Configuration) iterator.next();
+
+            Environment parentEnvironment = parent.getEnvironment();
+            nonOverridableSet.addAll(parentEnvironment.getNonOverrideableClasses());
+        }
+        String[] nonOverridableClasses = (String[]) nonOverridableSet.toArray(new String[nonOverridableSet.size()]);
+
+        log.debug("ClassPath for " + id + " resolved to " + Arrays.asList(urls));
+
+        return new MultiParentClassLoader(environment.getConfigId(),
+                urls,
+                parentClassLoaders,
+                environment.isInverseClassLoading(),
+                hiddenClasses,
+                nonOverridableClasses);
+    }
+
+    private void addDepthFirstServiceParents(Configuration configuration, List ancestors)
{
         ancestors.add(configuration);
         for (Iterator parents = configuration.getServiceParents().iterator(); parents.hasNext();)
{
             Configuration parent = (Configuration) parents.next();
-            getDepthFirstServiceParents(parent, ancestors);
+            addDepthFirstServiceParents(parent, ancestors);
         }
     }
 

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java?rev=390003&r1=390002&r2=390003&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java
Wed Mar 29 22:17:30 2006
@@ -132,6 +132,11 @@
         for (Iterator iterator = parentConfigurations.iterator(); iterator.hasNext();) {
             Configuration configuration = (Configuration) iterator.next();
 
+            // check if this parent matches the groupId, artifactId, and type
+            if (matches(configuration.getId(), groupId, artifactId, type)) {
+                return configuration.getId().getVersion();
+            }
+
             Environment environment = configuration.getEnvironment();
             if (environment.isInverseClassLoading()) {
                 // Search dependencies of the configuration before searching the parents
@@ -166,13 +171,17 @@
     private Version getArtifactVersion(Collection artifacts, String groupId, String artifactId,
String type) {
         for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
             Artifact artifact = (Artifact) iterator.next();
-            if (groupId.equals(artifact.getGroupId()) &&
-                    artifactId.equals(artifact.getArtifactId()) &&
-                    type.equals(artifact.getType())) {
+            if (matches(artifact, groupId, artifactId, type)) {
                 return artifact.getVersion();
             }
         }
         return null;
+    }
+
+    private boolean matches(Artifact artifact, String groupId, String artifactId, String
type) {
+        return groupId.equals(artifact.getGroupId()) &&
+                artifactId.equals(artifact.getArtifactId()) &&
+                type.equals(artifact.getType());
     }
 
     public static final GBeanInfo GBEAN_INFO;



Mime
View raw message