I was thinking about writing an article on what I recently learned about Java’s classloading capabilities. However, I was just surfing onjava.com and found the following article:
Internals of Java Class Loading by Binildas Christudas — When are two classes not the same? When they’re loaded by different class loaders. This is just one of many curious side effects of Java’s class-loading system. Binildas Christudas shows how different class loaders relate to one another and how (and why) to build your own custom class loader.
This covers exactly what I wanted to write about in nearly the same context. I was planning on writing about a Servlet based execution environment, where the system administrator could load patches while the application stays up. Basically, each session would be tied to a particular Classloader, so that each session maintains the same code version for the duration of the session. I handled all of this by defining a servlet that then mapped all URIs into the appropriate Class. I basically made a servlet into a Servlet container. Here is a web.xml entry for the loader:
So, the Loader servlet handles all URIs that start with /load/ and then uses a standard web.xml file for the class definitions. This makes it easy to put in place of an existing web.xml file and then use the old web.xml for the mapping. I may still write an article about it, but focus specifically on the mechanics of managing the patches. Not sure yet.
Post a Comment