During today's Tapestry Training at SkillsMatter, the question about live class reloading for Tapestry services came up.
Now, my normal response is to talk about class loaders, and mysterious class-cast exceptions it would cause, and the need to shut down and restart the container, etc.
But an idea went around ... what about just live reloading of implementation classes? That sparked some thoughts.
See, it seems to me that it should be possible to create a class loader that loads a single class (and, perhaps, inner classes of that single class), much as Tapestry uses a class loader to load pages and components.
In fact, it should be possible to have separate class loader for every implementation class that just performs the reload of that one class. A periodic check of the file modification date stamps could trigger the release of the class loader (and the current instance) and the instantiation of a new class loader, and the loading of the updated class.
You wouldn't be able to change service interfaces this way, or module classes (including contributions and the like) ... but changing a service implementation should be a snap. This would especially be useful for DAOs while creating and tuning database queries.
I think there would be some limitations here: services that are built via builder methods would not work; neither would services that export
this (typically, as a listener to events published by another service). However, the vast majority of services could, I think, be automatically reloaded.
This is worth spending some time on ... if I can pull it off, it would be an incredible coup!
The only downside is that some services may need to move from tapestry-core to tapestry-ioc and some of those may, in fact, be public already (but not widely used).