db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kathey Marsden <kmarsdende...@sbcglobal.net>
Subject Re: Question about using URLClassLoader and Derby
Date Mon, 14 Nov 2005 14:20:58 GMT
I am moving this to derby-dev as  I think my new questions are more
appropriate for this list.
Oyvind's suggestion to make a DerbyURLClassLoader to filter out the
derby classes from the parent class loader all seems to be working ok
(with some very minimal testing). 


David W. Van Couvering wrote (for Binod):

>Make sure that there is only one URL classloader instance that has
>access to the derby jar files. And make sure that whenever a code
>accesses the datasource, it always go thru newDataSource method, then
>yes, it should work.
>
>  
>

I just want to verify that this just means that my app should use the
same loader if it needed to get another datasource for say shutting down
the database.  Other applications should be able to use their own
DerbyURLClassLoaders to access Derby as long as they are accessing
different databases, right?

>- Binod.
>
>p.s: This is all assuming that derby code doent do any other interesting
>classloader mechanism inside :-). For example, it can use Thread's
>context classLoader to load some other part of derby that might break.
>
>  
>
Is there anything like Binod describes  in Derby that might cause
problems (e.g. code for loading generated byte code, loading databases
from jars or aggregates) ?   

One other issue I have encountered is  that I am not sure how to handle
the derby error log (derby.log).    The configuration for this is only
provided with System properties or entries in the derby.properties file
which would affect other apps.  How do I create my own isolated error
log with out clobbering the error logs of other apps or having them
clobber mine?

Thanks

Kathey


Below is the DerbyURLClassLoader loadClass method for reference.

/* Override the parent class loader to filter out any derby
     * jars in the classpath.  Any classes that start with
     * "org.apache.derby" will load  from the URLClassLoader
     *
     * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean)
     */
    protected Class loadClass(String name, boolean resolve)
    throws ClassNotFoundException
    {
        // This code and a approach were suggeted by Knut Anders Hatlen and
        // Oyvind Bakksjo on the derby-user list.
        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;
    }
    





Mime
View raw message