• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic classloading switch  RSS feed

 
Dennis Meyer
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JAR that needs to be deployed into a webapp, but will also be used for stand-alone apps as a persitence layer. Since we have two identical systems on two different db servers (only the DB server specific enhancement differs), we need to decide which one to deploy (oracle.jar and mysql.jar). What would be great is to have a single JAR (database.jar) containing both codes, but only one gets loaded. This will not change at ruintime - it must be decided uplon load time.

I've been thinking of a kind of kickstart.jar which dynamically loads one of the jars (mysql.jar or oracle.jar) depending on a property setting. To avoid to load it in before of the other jars I could zip the two JARS into the kickstart.jar and retrieve again as resource and the load it using a custom).

The troubles I force is that I would have to write a customClassLoader which loads the classes into his scope. But: the other apps rely on the classes in oracle.jar (or mysql.jar) but wouldn't get known to it until they would have the same parentclassloader!

Is there a way to write a customClassloader that loads the classes into the parent (or tells the parent where it'll find a specific class)?

Thanks a lot!

PS: Note that the solution would have best design if I could add the database.jar in any lib fiolöder like any other jar and it would decide what to load on it's own. Without any dependencies on classloading orders (like Tomcat endored lib and WEB/INF/lib classloading order)

Thanks a lot for any suggestion!
 
Angel Taveras
Ranch Hand
Posts: 84
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could check the classworlds project. I believe you could me a good use with what you want.

regards,
 
Dennis Meyer
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The project really looks very promising. I'll have a deeper look into it. Not exacly what I was asking (thinking in the wrong direction?) but maybe even more useful for some other stuff we have
Thanks very much!

Other hints still welcome for discussion...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!