matth 2004/02/18 11:40:44
Modified: discovery STATUS.html maven.xml project.xml
discovery/src/java/org/apache/commons/discovery/jdk
JDK12Hooks.java
discovery/src/test/org/apache/commons/discovery/test
TestAll.java
Log:
PR: Bugzilla Bug 26875
- Added a try/catch for RuntimeExceptions in JDK12Hooks to avoid
NullPointerExceptions
from JBoss' UnifiedClassLoader. Reloading the Axis webapp after a redepoy of service
classes then allows things to work normally.
- Added a pregoal to test:test in maven.xml to make the unit tests pass. There were
some problems with the classpath configuration.
- Added self as committer.
Revision Changes Path
1.5 +3 -2 jakarta-commons/discovery/STATUS.html
Index: STATUS.html
===================================================================
RCS file: /home/cvs/jakarta-commons/discovery/STATUS.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- STATUS.html 14 Apr 2003 17:56:09 -0000 1.4
+++ STATUS.html 18 Feb 2004 19:40:44 -0000 1.5
@@ -41,7 +41,7 @@
<li>Functional within a J2EE environment.</li>
</ul>
</p>
-
+
<p>
Non-goals:
<ul>
@@ -54,7 +54,7 @@
NOT use commons-discovery.</li>
</ul>
</p>
-
+
<a name="Dependencies"></a>
<h3>2. DEPENDENCIES</h3>
@@ -88,6 +88,7 @@
<li>Richard A. Sitze</li>
<li>Costin Manoloche</li>
<li>Craig R. McClanahan</li>
+ <li>Matthew Hawthorne</li>
</ul>
1.4 +27 -3 jakarta-commons/discovery/maven.xml
Index: maven.xml
===================================================================
RCS file: /home/cvs/jakarta-commons/discovery/maven.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- maven.xml 8 Jan 2003 04:36:17 -0000 1.3
+++ maven.xml 18 Feb 2004 19:40:44 -0000 1.4
@@ -1,4 +1,28 @@
-<project default="java:jar"
- xmlns:j="jelly:core">
+<?xml version="1.0"?>
+
+<project default="java:jar" xmlns:j="jelly:core" xmlns:ant="jelly:ant"
+ xmlns:maven="jelly:maven">
+
+
+ <preGoal name="test:test">
+ <ant:property name="test.dest"
+
value="${pom.getPluginContext('maven-test-plugin').getVariable('maven.test.dest')}"/>
+
+ <ant:path id="test.extra.classpath">
+ <pathelement location="${test.dest}/test"/>
+ <pathelement location="${test.dest}/testAlt1"/>
+ <pathelement location="${test.dest}/testAlt2"/>
+ </ant:path>
+
+ <maven:addPath id="maven.dependency.classpath"
+ refid="test.extra.classpath"/>
+
+ <ant:pathconvert property="classpath"
+ refid="maven.dependency.classpath" targetOS="unix"/>
+
+ <ant:echo message="classpath: ${classpath}"/>
+ </preGoal>
+
+
+</project>
- </project>
1.17 +13 -4 jakarta-commons/discovery/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-commons/discovery/project.xml,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- project.xml 10 Feb 2004 19:15:04 -0000 1.16
+++ project.xml 18 Feb 2004 19:40:44 -0000 1.17
@@ -20,7 +20,7 @@
<description>
Commons Discovery
</description>
-
+
<developers>
<developer>
<name>Richard Sitze</name>
@@ -46,8 +46,13 @@
<email>[EMAIL PROTECTED]</email>
<organization>SpiritSoft, Inc.</organization>
</developer>
+ <developer>
+ <name>Matthew Hawthorne</name>
+ <id>matth</id>
+ <email>[EMAIL PROTECTED]</email>
+ </developer>
</developers>
-
+
<dependencies>
<dependency>
@@ -63,10 +68,12 @@
</dependencies>
<build>
+
<unitTest>
<includes>
<include>**/TestAll.java</include>
</includes>
+
<resources>
<resource>
<directory>${basedir}/src</directory>
@@ -74,6 +81,7 @@
<include>**/testResource</include>
</includes>
</resource>
+
<resource>
<directory>${basedir}/src/test</directory>
<includes>
@@ -81,8 +89,9 @@
<include>META-INF/**</include>
</includes>
</resource>
- </resources>
- </unitTest>
+ </resources>
+ </unitTest>
+
</build>
1.5 +46 -2
jakarta-commons/discovery/src/java/org/apache/commons/discovery/jdk/JDK12Hooks.java
Index: JDK12Hooks.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/discovery/src/java/org/apache/commons/discovery/jdk/JDK12Hooks.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JDK12Hooks.java 9 Oct 2003 19:38:19 -0000 1.4
+++ JDK12Hooks.java 18 Feb 2004 19:40:44 -0000 1.5
@@ -63,17 +63,35 @@
import java.io.IOException;
import java.net.URL;
+import java.util.Collections;
import java.util.Enumeration;
+import org.apache.commons.discovery.log.DiscoveryLogFactory;
+import org.apache.commons.logging.Log;
+
/**
* @author Richard A. Sitze
*/
class JDK12Hooks extends JDKHooks {
+
+ /**
+ * Logger
+ */
+ private static Log log = DiscoveryLogFactory.newLog(JDK12Hooks.class);
+
+
private static final ClassLoader systemClassLoader
= findSystemClassLoader();
/**
+ * Must be implemented to use DiscoveryLogFactory
+ */
+ public static void setLog(Log _log) {
+ log = _log;
+ }
+
+ /**
* The thread context class loader is available for JDK 1.2
* or later, if certain security conditions are met.
*
@@ -146,9 +164,35 @@
* and eliminate the redundent element.
*/
- final URL first = (URL)loader.getResource(resourceName);
- final Enumeration rest = loader.getResources(resourceName);
+ final URL first = loader.getResource(resourceName);
+
+ // XXX: Trying to avoid JBoss UnifiedClassLoader problem
+
+ Enumeration resources;
+
+ if(first == null) {
+ log.debug("Could not find resource: " + resourceName);
+ resources = Collections.enumeration(Collections.EMPTY_LIST);
+
+ } else {
+ try {
+
+ resources = loader.getResources(resourceName);
+
+ } catch (RuntimeException ex) {
+ log.error("Exception occured during attept to get " + resourceName
+ + " from " + first, ex);
+ resources = Collections.enumeration(Collections.EMPTY_LIST);
+ }
+
+ resources = getResourcesFromUrl(first, resources);
+ }
+
+ return resources;
+ }
+
+ private static Enumeration getResourcesFromUrl(final URL first, final
Enumeration rest) {
return new Enumeration() {
private boolean firstDone = (first == null);
private URL next = getNext();
1.8 +2 -1
jakarta-commons/discovery/src/test/org/apache/commons/discovery/test/TestAll.java
Index: TestAll.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/discovery/src/test/org/apache/commons/discovery/test/TestAll.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TestAll.java 9 Oct 2003 19:36:01 -0000 1.7
+++ TestAll.java 18 Feb 2004 19:40:44 -0000 1.8
@@ -316,6 +316,7 @@
DiscoverResources discovery = new DiscoverResources(loaders);
ResourceIterator iter = discovery.findResources(name);
int count = 0;
+
while (iter.hasNext()) {
Resource resource = iter.nextResource();
URL url = resource.getResource();
@@ -323,7 +324,7 @@
System.out.println("URL = " + url.toString());
if (url.getFile().indexOf(partialPaths[count]) == -1) {
- fail("expected to locate URL containing " +
partialPaths[count]);
+ fail(url + " does not contain " + partialPaths[count]);
}
count++;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]