bloritsch 01/05/23 09:29:14
Modified: src/org/apache/cocoon/servlet ParanoidClassLoader.java
Log:
Add ability to add new files (like RepositoryClassLoader)
Revision Changes Path
1.2 +24 -1
xml-cocoon2/src/org/apache/cocoon/servlet/ParanoidClassLoader.java
Index: ParanoidClassLoader.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/servlet/ParanoidClassLoader.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ParanoidClassLoader.java 2001/05/23 14:05:01 1.1
+++ ParanoidClassLoader.java 2001/05/23 16:29:08 1.2
@@ -7,6 +7,10 @@
*****************************************************************************/
package org.apache.cocoon.servlet;
+import java.io.IOException;
+import java.io.File;
+
+import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLStreamHandlerFactory;
@@ -16,7 +20,7 @@
* classes. It checks this classloader before it checks its parent.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.1 $ $Date: 2001/05/23 14:05:01 $
+ * @version CVS $Revision: 1.2 $ $Date: 2001/05/23 16:29:08 $
*/
public class ParanoidClassLoader extends URLClassLoader {
@@ -86,6 +90,9 @@
* note that this is the exact opposite of the
* <code>ClassLoader</code> spec. We use it to work around
* inconsistent class loaders from third party vendors.
+ *
+ * @param name of class
+ * @throws ClassNotFoundException
*/
public final Class loadClass(final String name) throws
ClassNotFoundException {
Class resource = null;
@@ -104,11 +111,27 @@
}
/**
+ * Adds a new directory of class files.
+ *
+ * @param file for jar or directory
+ * @throws IOException
+ */
+ public final void addDirectory(File file) throws IOException {
+ try {
+ this.addURL(file.getCanonicalFile().toURL());
+ } catch (MalformedURLException mue) {
+ throw new IOException("Could not add repository");
+ }
+ }
+
+ /**
* Gets a resource from this <code>ClassLoader</class>. If the
* resource does not exist in this one, we check the parent.
* Please note that this is the exact opposite of the
* <code>ClassLoader</code> spec. We use it to work around
* inconsistent class loaders from third party vendors.
+ *
+ * @param name of resource
*/
public final URL getResource(final String name) {
URL resource = super.getResource(name);
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]