db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Binod...@Sun.COM
Subject Re: Question about using URLClassLoader and Derby
Date Mon, 14 Nov 2005 14:43:12 GMT


----- Original Message -----
From: Kathey Marsden <kmarsdenderby@sbcglobal.net>
Date: Monday, November 14, 2005 7:51 pm
Subject: Re: Question about using URLClassLoader and Derby
To: Derby Discussion <derby-user@db.apache.org>
Cc: Binod P G <Binod.Pg@Sun.COM>

> 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 
> downthe database.  Other applications should be able to use their own
> DerbyURLClassLoaders to access Derby as long as they are accessing
> different databases, right?

Yes. It is also possible that two parts of same application want to create two
datasource instances.

BTW, where would your application run? I am assuming it is outside of
any managed environment like application server.

- Binod.

> 
> >- 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 
> handlethe derby error log (derby.log).    The configuration for 
> this is only
> provided with System properties or entries in the derby.properties 
> filewhich would affect other apps.  How do I create my own isolated 
> errorlog with out clobbering the error logs of other apps or having 
> themclobber 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