Reloading web applications

Recently there was an article on TheServerSide: JavaRebel Brings Class Reloading to Java. Unfortunatly we (Apache Cocoon) haven’t talked much about it but this feature has already been available for Cocoon for quite some time. Thanks to Jakarta Commons JCI the hard work of class reloading is already done. JCI provides a reloading classloader which detects all changes in classes that it monitors and automatically reloads them. Unlike HotSwap this also works on adding new classes, changing interfaces, removing methods etc.

For all Cocoon 2.2 users this feature comes for free with zero configuration (if you use the archetype which already configures the plugin for you). Use the Cocoon Maven Plugin to run your Cocoon block (a Cocoon block is the modularization unit of Cocoon applications and mostly specifying a standard directory structure) and all changes to your Java classes will take effect immediatly. The Maven plugin also takes care that the Spring application context gets reloaded if necessary (don’t know if the JavaRebel library can do this …) because for singletons it isn’t enough to change the class definition provided by the classloader. Spring wouldn’t  change the object that it is using.

If you want to find out more about this really cool stuff, follow the “Your first Cocoon application” tutorial, then start Eclipse and load the created project and change the Spring bean.