JavaRebel and Jersey
By sandoz on Jan 04, 2008
reloads changes to Java classes on-the-fly without redeploy or restart including new methods and fields. It is a generic solution that works for standalone Java applications as well as application servers
I opened the HelloWorld example provided in the Jersey distribution and modified the run.jvmargs property in the nbproject/project.properties file to be:
ran the project and verified with curl the response to a GET request.
Then i modified the String returned by the HTTP GET method of the HelloWorldResource recompiled the project and verified the response to the GET request had changed. (I wish NetBeans had an automatic compile option.)
It is also possible to integrate with Glassfish (although i have not tried it). Add the following snippet of XML as a child of the <java-config> element in a domain.xml:
A very nice and easy integration. Clever stuff! I wonder how it is done...
Unfortunately it is not possible to modify the annotations, method signatures, add new methods, or add new resource classes. Jersey creates, for performance reasons, a runtime model of a resource so it does not have to analyze the annotations using Java reflection every time. Jersey has no way of knowing if a resource class has been created, modified or deleted. (I suppose it is the same for any framework that caches information about classes, for example JAXB.)
If there was a way to detect changes i think it would be easy to modify Jersey to update its runtime model accordingly (an API for listening to such changes seems useful independently of JavaRebel). And then it would make a rather nice rapid development platform for Jersey development.