db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oyvind.Bakk...@Sun.COM
Subject Re: [PATCH] (DERBY-205; 2nd patch) org.apache.derby.impl.drda.DB2jServerImpl to NetworkServerControlImpl
Date Thu, 26 May 2005 07:33:43 GMT
David Van Couvering wrote:
> Yes, this was my experience also.  You can't have multiple 
> configurations in a VM instance, because everything is dependent on 
> system properties (both Derby itself as well as the test harness 
> infrastructure).  I don't *think* using classloaders will help because 
> system properties, as I understand it, are VM-wide and span 
> classloaders.  But I haven't explicitly tested that.
> David

Yes, system properties are VM-wide, but they can be changed at any time. 
The problem is if the properties are read and used only once, when the 
driver is loaded, since it is impossible to instruct a class loader to 
"unload" anything.

It is possible to load the driver multiple times with different class 
loaders. However, this requires that the driver is not in the classpath 
for the VM, otherwise your class loaders will delegate to the system 
classloader, which finds the driver and caches it. Thus, each class 
loader will return the same class, which has been initialized only once.

If it is impossible to exclude the driver from the VM's classpath (due 
to the test harness), it is still possible to load the driver multiple 
times (with different system property settings) using a bit of a hack: 
Make your own ClassLoader which doesn't delegate to its parent 
classloader for certain class names (the driver's classes).

Øyvind Bakksjø
Sun Microsystems, Web Services, Database Technology Group
Haakon VII gt. 7b, N-7485 Trondheim, Norway
Tel: x43419 / +47 73842119, Fax: +47 73842101

View raw message