java - Dynamically loading jars from remote location -


Is there a framework for this scenario or some solution?

I have a webpage that is running when I say Tommet Server, when my application starts, I would like to download some jars which are completely different. Like all external Nexus servers or some things, all those commercial jargons in Jars are required for injection with spring.

Why do I need something like this? My application is installed at very different locations. To easily install the latest version of the code on all installations I would like to update only 1 location and all applications are updated once it is restarted.

To do this, use your custom class load loader Will be required.

The good news is that you do not have to write your own: You can use Java's built-in java.net.URLClassLoader . The bad news is that you have to wire it in a tomcat, for which some code may be required.

This is a recommended suggestion:

  1. A classloader that extends the WebappClassLoader of Tomcat
  2. Add a URLClassLoader and start it in your constructor (or LifecycleListener Start () ) events like < / Li>
  3. Override all methods to call the superclass method of the same signature and call the same method as the URLclassloader you are using. In order to consult you either super.whatever or urlClassLoader.whatever , read सर्वोलेट स्पैक to determine how you want to work in
  4. META-INF / context.xml file in your web application & lt; Loader & gt; Define your custom classload loader by defining .

If you need help with any of the above, then proceed.

EDIT 2014-11-04

Note I think using a URLClassLoader to do this is fragile, Error prone, and maybe a bad idea, instead, fix your deployment process so it's easy to update your web application across a cluster. You can use Tomcat's "Fire Web Depler" for this kind of work or you can use some other solution. But loading classes on the network can make your life difficult and results in some strange non-reproducible behaviors in some cases.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -