User: user57
Date: 02/02/21 18:11:20
Modified: src/main/org/jboss/system UnifiedClassLoader.java
Log:
o javadoc
o removed getResourceAsStream() it was an exact dup of
ClassLoader.getResourceAsStream()
except it would catch Exception and not IOException, which could cause problems.
Revision Changes Path
1.9 +74 -78 jboss/src/main/org/jboss/system/UnifiedClassLoader.java
Index: UnifiedClassLoader.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/system/UnifiedClassLoader.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- UnifiedClassLoader.java 21 Feb 2002 23:17:00 -0000 1.8
+++ UnifiedClassLoader.java 22 Feb 2002 02:11:19 -0000 1.9
@@ -11,8 +11,8 @@
import java.io.InputStream;
/**
- * The URLClassLoader is associated with a given URL.
- * It can load jar and sar (or jsr).
+ * A ClassLoader which loades classes from a single URL
+ * in conjunction with the {@link ServiceLibraries}.
*
* <p>The ServiceLibraries keeps track of the UCL and asks everyone for
* resources and classes.
@@ -20,7 +20,7 @@
* @author <a href="[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="[EMAIL PROTECTED]">Christoph G. Jung</a>
* @author <a href="[EMAIL PROTECTED]">Scott Stark/a>
- * @version $Revision: 1.8 $
+ * @version <tt>$Revision: 1.9 $</tt>
*
* <p><b>20010830 marc fleury:</b>
* <ul>
@@ -36,70 +36,64 @@
extends java.net.URLClassLoader
implements UnifiedClassLoaderMBean
{
- /** One URL per classLoader in our case */
- private URL url;
-
- /** An SCL can also be loading on behalf of an MBean */
- //private ObjectName mbean = null; not used
+ /** The bootstrap interface to the log4j system */
+ private static BootstrapLogger log =
BootstrapLogger.getLogger(UnifiedClassLoader.class);
/** All SCL are just in orbit around a basic ServiceLibraries */
private static ServiceLibraries libraries;
-
- /** The bootstrap interface to the log4j system */
- private static BootstrapLogger log =
BootstrapLogger.getLogger(UnifiedClassLoader.class);
+
+ /** One URL per ClassLoader in our case */
+ private URL url;
/**
- * One url per SCL
+ * Construct a <tt>UnifiedClassLoader<tt>.
+ *
+ * <p>A UCL only loads classes from a single URL;
*
- * @param String application
- * @param ClassLoader parent
+ * @param url The single URL to load classes from.
*/
- public UnifiedClassLoader(URL url)
+ public UnifiedClassLoader(final URL url)
{
super(new URL[] {url}, UnifiedClassLoader.class.getClassLoader());
- if (log.isDebugEnabled()) log.debug("New UCL with url "+url);
-
+ if (log.isDebugEnabled()) log.debug("New UCL with url " + url);
this.url = url;
- try
- {
-
- if (libraries == null)
- {
- libraries = ServiceLibraries.getLibraries();
- }
-
- // A URL enabled SCL must register itself with the libraries to
- // be queried
- libraries.addClassLoader(this);
- }
- catch(Exception e)
+
+ // Initialize our reference to SL
+ if (libraries == null)
{
- //
- // FIXME: Should not mask exceptionsd like this, if it is an error, then
- // propagate it to caller tyo handle
- //
- log.warn("URL "+url+" could not be opened", e);
+ libraries = ServiceLibraries.getLibraries();
}
+
+ // Must register itself with the libraries to be queried
+ libraries.addClassLoader(this);
}
/**
* We intercept the load class to know exactly the dependencies
- * of the underlying jar
+ * of the underlying jar.
+ *
+ * <p>Forwards request to {@link ServiceLibraries}.
*/
public Class loadClass(String name, boolean resolve)
throws ClassNotFoundException
{
return libraries.loadClass(name, resolve, this);
}
-
-
- public Class loadClassLocally (String name, boolean resolve)
+
+ /**
+ * Provides the same functionality as {@link URLClassLoader#loadClass}.
+ */
+ public Class loadClassLocally(String name, boolean resolve)
throws ClassNotFoundException
{
return super.loadClass(name, resolve);
}
-
+
+ /**
+ * Attempts to load the resource from its URL and if not found
+ * forwards to the request to {@link ServiceLibraries}.
+ */
public URL getResource(String name)
{
URL resource = super.getResource(name);
@@ -109,56 +103,54 @@
resource = libraries.getResource(name, this);
}
- /*
- if (resource == null)
- {
- if( log.isTraceEnabled() )
- log.trace("Did not find the UCL resource "+name);
- }
- */
+ // if (resource == null)
+ // {
+ // if (log.isTraceEnabled())
+ // log.trace("Did not find the UCL resource: " + name);
+ // }
+
return resource;
}
-
+
+ /**
+ * Provides the same functionality as {@link URLClassLoader#getResource}.
+ */
public URL getResourceLocally(String name)
{
return super.getResource(name);
}
-
- public InputStream getResourceAsStream(String name)
- {
- try
- {
- URL resourceUrl = getResource(name);
-
- if (resourceUrl != null)
- {
- return resourceUrl.openStream();
- }
- }
- catch (Exception ignore)
- {
- }
-
- return null;
+
+ /**
+ * Returns the single URL for this UCL.
+ */
+ public URL getURL() {
+ return url;
}
-
- public URL getURL() {return url;}
-
+
+ /**
+ * Uses the hash code from it's URL.
+ */
public int hashCode()
{
return url.hashCode();
}
- /** Return an empty URL array to force the RMI marshalling subsystem to
- *use the java.server.codebase property as the annotated codebase. Do not
- *remove this method without discussing it on the dev list.
+ /**
+ * Return an empty URL array to force the RMI marshalling subsystem to
+ * use the <tt>java.server.codebase</tt> property as the annotated codebase.
+ *
+ * <p>Do not remove this method without discussing it on the dev list.
+ *
+ * @return Empty URL[]
*/
- private static final URL[] empty = {};
public URL[] getURLs()
{
- return empty;
+ return EMPTY_URL_ARRAY;
}
+ /** The value returned by {@link getURLs}. */
+ private static final URL[] EMPTY_URL_ARRAY = {};
+
/**
* This method simply invokes the super.getURLs() method to access the
* list of URLs that make up the UnifiedClassLoader classpath.
@@ -168,6 +160,9 @@
return super.getURLs();
}
+ /**
+ * This UCL is equal to another UCL when the two URLs are equal.
+ */
public boolean equals(Object other)
{
if (other instanceof UnifiedClassLoader)
@@ -176,12 +171,13 @@
}
return false;
}
-
+
+ /**
+ * Retruns a string representaion of this UCL.
+ */
public String toString()
{
- StringBuffer tmp = new StringBuffer("JBoss UnifiedClassloader: keyURL : ");
- tmp.append(getURL());
- tmp.append(']');
- return tmp.toString();
+ return super.toString() + "{ url=" + getURL() + " }";
}
}
+
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development