commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Essl Christian <ju...@esslchristian.de>
Subject Re: [HiveMind] Having problem with tomcat.
Date Thu, 11 Sep 2003 12:28:47 GMT
On Wed, 10 Sep 2003 20:01:36 -0400, Howard M. Lewis Ship 
<hlship@comcast.net> wrote:


> Why do you think the committed solution is faster?

Because it just uses one map lookup.

However I was thinking about the multiple (unneeded) ClassLoaders. I have 
my problems with that. A minor problem is that a ClassLoader is quite a big 
class (Maps, Sets etc). My actual problem is that it of course integrates 
tightly with the VM (native-methods) and I don't know how different VMs 
behave when there are many class loaders (Do you have an idea?). Therefore 
I thought its better to prevent it when it is not realy needed.

I also saw that a javassist class-pool is constructed for each module 
(which is I think as well not needed).

Because you don't like the IdentityHashMap with ClassLoaders as keys (Why?) 
. I took a compromise and used as a key in the (normal) _moduleData Map 
just the ClassResolver of the module instead of the id (I think they 
shouldn't be equal if they use different ClassLoaders). This way there is 
only one ClassFactoryClassLoader and one ClassPool per ClassResolver.

The code change is minimal. The hivemind tests work and also the tomcat- 
stuff works.

Here is the diff:

Index: 
src/java/org/apache/commons/hivemind/service/impl/ClassFactoryImpl.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons- 
sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/ClassFactoryImpl.java,v
retrieving revision 1.9
diff -u -r1.9 ClassFactoryImpl.java
--- 
src/java/org/apache/commons/hivemind/service/impl/ClassFactoryImpl.java	10 
Sep 2003 20:38:03 -0000	1.9
+++ 
src/java/org/apache/commons/hivemind/service/impl/ClassFactoryImpl.java	11 
Sep 2003 12:20:33 -0000
@@ -67,6 +67,7 @@
 import javassist.NotFoundException;
 import org.apache.commons.hivemind.ApplicationRuntimeException;
+import org.apache.commons.hivemind.ClassResolver;
 import org.apache.commons.hivemind.HiveMind;
 import org.apache.commons.hivemind.Module;
 import org.apache.commons.hivemind.service.ClassFab;
@@ -142,15 +143,15 @@
 private synchronized ModuleData findModuleData(Module module)
     {
-        String id = module.getModuleId();
+        ClassResolver resolver = module.getClassResolver();
 -        ModuleData result = (ModuleData) _moduleDataMap.get(id);
+        ModuleData result = (ModuleData) _moduleDataMap.get(resolver);
 if (result == null)
         {
             ClassPool pool = new ClassPool(null);
 -            ClassLoader moduleLoader = module.getClassResolver() 
.getClassLoader();
+            ClassLoader moduleLoader = resolver.getClassLoader();
             ClassPath path = new LoaderClassPath(moduleLoader);
 pool.appendClassPath(path);
@@ -162,7 +163,7 @@
             result._pool = pool;
             result._loader = loader;
 -            _moduleDataMap.put(id, result);
+            _moduleDataMap.put(resolver, result);
         }
 return result;
 

Mime
View raw message