Ola Berg wrote:
> I have this problem with using my own (URLClassLoader) class loader
> in a servlet of mine.
>
> The thing is that I am writing a web front end to domain name
> services (automatic registration of .org, .com. .biz, .info etc
> domains).
>
> Depending on the top level domain, I need to use different versions
> (jars) of the same API, since the protocol differs. So I need to
> dynamically load my classes at runtime. Just putting the jars in lib
> won't work since there are different implementations of the same
> classes in them. I have to decide in runtime.
>
> Using the URLClassLoader in a standalone app works perfectly, when
> using it in a servlet it just hangs. I suspect the problem lies
> within the different lookup order used in servlets (as dscribed in
> the classloader-HOWTO).
>
> I can't figure out how to do it.
>
> Has anyone experience in the field?
>
I have an analogous case, in which I have a single API for database
access, with choice of database (Oracle, MySQL,...) made at run-time.
The problem was simply solved using the 'Abstract Factory' pattern. This
means that I have two packages (....db.MySql, & ....db.Oracle), which
both include an implementation of a DBFactory. I then use ClassForName()
to load the appropriate implementation, and then call factory methods to
instantiate the appropriate classes.
Hence, you don't need to bother with custom classloaders, and your
design is much 'cleaner' as a result.
HTH,
Martin
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
- Denny access to dir webapps RAFA
- [classloading] How to use URLClassLoader within a ser... Ola Berg
- Re: [classloading] How to use URLClassLoader with... Martin Jacobson
- Re: [classloading] How to use URLClassLoader ... Ola Berg
- Re: [classloading] How to use URLClassLoa... Kris Schneider
- Re: [classloading] How to use URLCla... Ola Berg
- Re: [classloading] How to use UR... Kris Schneider
- Re: [classloading] How to us... Ola Berg
