cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r407768 - /cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/
Date Fri, 19 May 2006 10:50:32 GMT
Author: cziegeler
Date: Fri May 19 03:50:32 2006
New Revision: 407768

URL: http://svn.apache.org/viewvc?rev=407768&view=rev
Log:
Cleanup interface

Modified:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/AbstractClassLoaderFactory.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/DefaultClassLoader.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/DefaultClassLoaderFactory.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/ReloadingClassLoader.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/ReloadingClassLoaderFactory.java

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/AbstractClassLoaderFactory.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/AbstractClassLoaderFactory.java?rev=407768&r1=407767&r2=407768&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/AbstractClassLoaderFactory.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/AbstractClassLoaderFactory.java
Fri May 19 03:50:32 2006
@@ -28,7 +28,6 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.cocoon.util.WildcardHelper;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.excalibur.source.TraversableSource;
@@ -150,26 +149,11 @@
         }
 
         URL[] urls = (URL[])urlList.toArray(new URL[urlList.size()]);
-        int[][] includes = compilePatterns(config.getIncludes());
-        int[][] excludes = compilePatterns(config.getExcludes());
         
-        return this.createClassLoader(urls, includes, excludes, parent);
+        return this.createClassLoader(urls, config.getIncludes(), config.getExcludes(), parent);
     }
 
-    protected abstract ClassLoader createClassLoader(URL[] urls, int[][] includes, int[][]
excludes, ClassLoader parent);
-
-    private int[][] compilePatterns(List patternConfigs) throws ConfigurationException {
-        if (patternConfigs.size() == 0) {
-            return null;
-        }
-        final int[][] patterns = new int[patternConfigs.size()][];
-
-        for (int i = 0; i < patternConfigs.size(); i++) {
-            patterns[i] = WildcardHelper.compilePattern((String)patternConfigs.get(i));
-        }
-
-        return patterns;
-    }
+    protected abstract ClassLoader createClassLoader(URL[] urls, List includePatterns, List
excludePatterns, ClassLoader parent);
 
     /**
      * @see org.apache.avalon.framework.activity.Disposable#dispose()

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/DefaultClassLoader.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/DefaultClassLoader.java?rev=407768&r1=407767&r2=407768&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/DefaultClassLoader.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/DefaultClassLoader.java
Fri May 19 03:50:32 2006
@@ -21,10 +21,14 @@
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.net.URLStreamHandlerFactory;
+import java.util.List;
 
 import org.apache.cocoon.util.WildcardHelper;
 
 /**
+ * This class loader reverses the search order for classes.  It checks this classloader
+ * before it checks its parent. In addition it can be configured with includes and excludes.
+ *
  * @version $Id$
  */
 public class DefaultClassLoader extends URLClassLoader {
@@ -36,18 +40,31 @@
      * Alternate constructor to define a parent and initial <code>URL</code>
      * s.
      */
-    public DefaultClassLoader(URL[] urls, int[][] includes, int[][] excludes, final ClassLoader
parent) {
-        this(urls, includes, excludes, parent, null);
+    public DefaultClassLoader(URL[] urls, List includePatterns, List excludePatterns, final
ClassLoader parent) {
+        this(urls, includePatterns, excludePatterns, parent, null);
     }
 
     /**
      * Alternate constructor to define a parent, initial <code>URL</code>s,
      * and a default <code>URLStreamHandlerFactory</code>.
      */
-    public DefaultClassLoader(final URL[] urls, int[][] includes, int[][] excludes, ClassLoader
parent, URLStreamHandlerFactory factory) {
+    public DefaultClassLoader(final URL[] urls, List includePatterns, List excludePatterns,
ClassLoader parent, URLStreamHandlerFactory factory) {
         super(urls, parent, factory);
-        this.includes = includes;
-        this.excludes = excludes;
+        this.includes = compilePatterns(includePatterns);
+        this.excludes = compilePatterns(excludePatterns);
+    }
+
+    private int[][] compilePatterns(List patternConfigs) {
+        if (patternConfigs.size() == 0) {
+            return null;
+        }
+        final int[][] patterns = new int[patternConfigs.size()][];
+
+        for (int i = 0; i < patternConfigs.size(); i++) {
+            patterns[i] = WildcardHelper.compilePattern((String)patternConfigs.get(i));
+        }
+
+        return patterns;
     }
 
     protected boolean tryClassHere(String name) {

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/DefaultClassLoaderFactory.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/DefaultClassLoaderFactory.java?rev=407768&r1=407767&r2=407768&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/DefaultClassLoaderFactory.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/DefaultClassLoaderFactory.java
Fri May 19 03:50:32 2006
@@ -17,6 +17,7 @@
 package org.apache.cocoon.components.classloader;
 
 import java.net.URL;
+import java.util.List;
 
 /**
  * @see AbstractClassLoaderFactory
@@ -25,7 +26,7 @@
 public class DefaultClassLoaderFactory
     extends AbstractClassLoaderFactory {
 
-    protected ClassLoader createClassLoader(URL[] urls, int[][] includes, int[][] excludes,
ClassLoader parent) {
-        return new DefaultClassLoader(urls, includes, excludes, parent);
+    protected ClassLoader createClassLoader(URL[] urls, List includePatterns, List excludePatterns,
ClassLoader parent) {
+        return new DefaultClassLoader(urls, includePatterns, excludePatterns, parent);
     }
 }

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/ReloadingClassLoader.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/ReloadingClassLoader.java?rev=407768&r1=407767&r2=407768&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/ReloadingClassLoader.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/ReloadingClassLoader.java
Fri May 19 03:50:32 2006
@@ -18,6 +18,7 @@
 
 import java.net.URL;
 import java.net.URLStreamHandlerFactory;
+import java.util.List;
 
 import org.apache.commons.jci.stores.ResourceStore;
 
@@ -32,16 +33,16 @@
      * Alternate constructor to define a parent and initial <code>URL</code>
      * s.
      */
-    public ReloadingClassLoader(URL[] urls, int[][] includes, int[][] excludes, final ClassLoader
parent) {
-        this(urls, includes, excludes, parent, null);
+    public ReloadingClassLoader(URL[] urls, List includePatterns, List excludePatterns, final
ClassLoader parent) {
+        this(urls, includePatterns, excludePatterns, parent, null);
     }
 
     /**
      * Alternate constructor to define a parent, initial <code>URL</code>s,
      * and a default <code>URLStreamHandlerFactory</code>.
      */
-    public ReloadingClassLoader(final URL[] urls, int[][] includes, int[][] excludes, ClassLoader
parent, URLStreamHandlerFactory factory) {
-        super(urls, includes, excludes, parent, factory);
+    public ReloadingClassLoader(final URL[] urls, List includePatterns, List excludePatterns,
ClassLoader parent, URLStreamHandlerFactory factory) {
+        super(urls, includePatterns, excludePatterns, parent, factory);
     }
 
     public void addResourceStore(final ResourceStore pStore) {

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/ReloadingClassLoaderFactory.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/ReloadingClassLoaderFactory.java?rev=407768&r1=407767&r2=407768&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/ReloadingClassLoaderFactory.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader/ReloadingClassLoaderFactory.java
Fri May 19 03:50:32 2006
@@ -17,6 +17,7 @@
 package org.apache.cocoon.components.classloader;
 
 import java.net.URL;
+import java.util.List;
 
 /**
  * @see AbstractClassLoaderFactory
@@ -24,7 +25,7 @@
  */
 public class ReloadingClassLoaderFactory extends AbstractClassLoaderFactory {
 
-    protected ClassLoader createClassLoader(URL[] urls, int[][] includes, int[][] excludes,
ClassLoader parent) {
-        return new ReloadingClassLoader(urls, includes, excludes, parent);
+    protected ClassLoader createClassLoader(URL[] urls, List includePatterns, List excludePatterns,
ClassLoader parent) {
+        return new ReloadingClassLoader(urls, includePatterns, excludePatterns, parent);
     }
 }



Mime
View raw message