From: Leo U. <leo...@ya...> - 2005-11-11 18:00:53
|
Im thinking some more about this and think maybe the best way to attack it is to do it via a module. Something along the lines of "register_classloader.py". What register_classloader.py will do is allow the developer to register classloaders in the system to allow subclassing of classloaded classes easily. import register_classloader register_classloader.registerClassLoader( classloader_instance ) behind the scenes this deals with all the internal manipulation of the runtime. I think though that this will require a modification to the way the system compiles classes. I believe the compile sequence is: 1. Check if System state has a classloader, try getting the class from that if there. 2. Use the System classloader to get the class if there isn't a #1. Im thinking that to enable this a 3rd step should be included: 3. If #2 fails check a list a of classloaders that have been registered with the SystemState and see if the class can be found. The ClassLoaders in step 3 are acquired by the register_classloader module. I like this approach better than: import org.python.core.Py as Py system_state = Py.getSystemState() system_state.setClassLoader( ..... ) .... because it allows you to have your ClassLoader work without monkeying around with the Jython internals directly. It also makes it easy to deal with a running system that uses more than 1 custom classloader, like mine! :) A flaw I can see is that it may be possible that more than one registered classloader may have the same class loaded. This may be a bad problem, it certainly is bad if there are multiple versions of the Class in the system. Im not sure if there is a way around this, unless their is a marker to compile this class with this specific classloader. Hmmm.... maybe there is a much way of dealing with this than what Ive just outlined??? leouser __________________________________ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com |