You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rs...@apache.org on 2002/07/09 23:12:01 UTC
cvs commit: jakarta-commons/discovery/src/java/org/apache/commons/discovery ServiceFinder.java ClassFinder.java
rsitze 2002/07/09 14:12:01
Modified: discovery/src/java/org/apache/commons/discovery
ServiceFinder.java ClassFinder.java
Log:
Corrected caching behavior. Wasn't looking at all classloaders when going through cache.
Revision Changes Path
1.3 +7 -10 jakarta-commons/discovery/src/java/org/apache/commons/discovery/ServiceFinder.java
Index: ServiceFinder.java
===================================================================
RCS file: /home/cvs/jakarta-commons/discovery/src/java/org/apache/commons/discovery/ServiceFinder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ServiceFinder.java 9 Jul 2002 20:45:20 -0000 1.2
+++ ServiceFinder.java 9 Jul 2002 21:12:01 -0000 1.3
@@ -162,16 +162,13 @@
{
/**
* Return previously registered service object (not class)
- * for this spi. Try contextClassLoader first, and if that
- * fails then try the spi's class loader.
+ * for this spi. Try each class loader in succession.
*/
- Object service = (spiContext.getThreadContextClassLoader() == null)
- ? null
- : get(spiContext.getSPI().getName(), spiContext.getThreadContextClassLoader());
-
- if (service == null) {
- service = get(spiContext.getSPI().getName(),
- spiContext.getSPI().getClassLoader());
+ Object service = null;
+ ClassLoader[] allLoaders = classFinder.getAllLoaders();
+
+ for (int idx = 0; service == null && idx < allLoaders.length; idx++) {
+ service = get(spiContext.getSPI().getName(), allLoaders[idx]);
}
if (service != null) {
@@ -504,7 +501,7 @@
*/
private static Object get(String spi, ClassLoader classLoader)
{
- ServiceCache cache = (spi == null)
+ ServiceCache cache = (spi == null || classLoader == null)
? null
: (ServiceCache)service_caches.get(spi);
1.2 +2 -0 jakarta-commons/discovery/src/java/org/apache/commons/discovery/ClassFinder.java
Index: ClassFinder.java
===================================================================
RCS file: /home/cvs/jakarta-commons/discovery/src/java/org/apache/commons/discovery/ClassFinder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ClassFinder.java 9 Jul 2002 18:03:23 -0000 1.1
+++ ClassFinder.java 9 Jul 2002 21:12:01 -0000 1.2
@@ -94,6 +94,8 @@
private final ClassLoader[] localLoaders;
private final ClassLoader[] allLoaders;
+
+ ClassLoader[] getAllLoaders() { return allLoaders; }
public ClassFinder(SPIContext spiContext, Class rootFinderClass) {
this.spiContext = spiContext;
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>