[EMAIL PROTECTED] wrote:
> // untested code follows
> protected Class loadClass(String name, boolean resolve)
> throws ClassNotFoundException
> {
> Class cl = findLoadedClass(name);
> if (cl == null) {
> // cut off delegation to parent for certain classes
> // to ensure loading from the desired source
> if (!name.startsWith("org.apache.derby")) {
> cl = getParent().loadClass(name);
> }
> }
> if (cl == null) cl = findClass(name);
> if (cl == null) throw new ClassNotFoundException();
> if (resolve) resolveClass(cl);
> return cl;
> }
>
>
> You could subclass URLClassLoader and override this method.
>
Super neat! To summarize:
I can keep other Derby versions loaded from interfering with my app by
creating a DerbyURLClassLoader that overrides the loadClass method to
filter out any Derby classes in the parent class loader.
I can prevent my app from interfering with other Derby versions by
loading Derby in a separate DerbyURLClassLoader and creating a
DataSource from there that I use for all my connections as described in
my original mail.
I have a completely isolated environment with regard to Derby. Because
JDBC provides a single entry point at the DataSource, I don't have to
understand the overall ClassLoader hierarchy or otherwise be a
ClassLoader expert. Does anyone see any holes here?
Thanks
Kathey