You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2006/05/19 12:39:35 UTC
svn commit: r407766 - in
/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/classloader:
AbstractClassLoaderFactory.java DefaultClassLoader.java
Author: cziegeler
Date: Fri May 19 03:39:34 2006
New Revision: 407766
URL: http://svn.apache.org/viewvc?rev=407766&view=rev
Log:
Merge in methods from ParanoidClassLoader
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
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=407766&r1=407765&r2=407766&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:39:34 2006
@@ -24,7 +24,6 @@
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
@@ -53,7 +52,6 @@
* </pre>
*/
public abstract class AbstractClassLoaderFactory
- extends AbstractLogEnabled
implements ClassLoaderFactory,
Serviceable,
ThreadSafe,
@@ -70,11 +68,11 @@
this.resolver = (SourceResolver)manager.lookup(SourceResolver.ROLE);
}
- private void ensureIsDirectory(Source src, String location) throws ConfigurationException {
+ private void ensureIsDirectory(Source src) throws Exception {
if (!src.exists()) {
- throw new ConfigurationException(src.getURI() + " doesn't exist, at " + location);
+ throw new Exception(src.getURI() + " doesn't exist");
} else if (!(src instanceof TraversableSource) || !((TraversableSource)src).isCollection()) {
- throw new ConfigurationException(src.getURI() + " is not a directory, at " + location);
+ throw new Exception(src.getURI() + " is not a directory");
}
}
@@ -121,7 +119,7 @@
Source src = null;
try {
src = resolver.resolveURI(directory);
- ensureIsDirectory(src, null);
+ ensureIsDirectory(src);
urlList.add(new URL(src.getURI()));
} finally {
this.resolver.release(src);
@@ -136,7 +134,7 @@
Source src = null;
try {
src = resolver.resolveURI(directory);
- ensureIsDirectory(src, null);
+ ensureIsDirectory(src);
Iterator iter = ((TraversableSource)src).getChildren().iterator();
while (iter.hasNext()) {
Source childSrc = (Source)iter.next();
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=407766&r1=407765&r2=407766&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:39:34 2006
@@ -16,6 +16,8 @@
*/
package org.apache.cocoon.components.classloader;
+import java.io.File;
+import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLStreamHandlerFactory;
@@ -102,7 +104,7 @@
if (clazz == null) {
- ClassLoader parent = getParent();
+ final ClassLoader parent = getParent();
if (tryClassHere(name)) {
try {
@@ -149,6 +151,25 @@
}
return resource;
+ }
+
+ /**
+ * Adds a new directory of class files.
+ *
+ * @param file
+ * for jar or directory
+ * @throws IOException
+ */
+ public final void addDirectory(File file) throws IOException {
+ this.addURL(file.getCanonicalFile().toURL());
+ }
+
+ /**
+ * Adds a new URL
+ */
+
+ public void addURL(URL url) {
+ super.addURL(url);
}
}