Sunday, August 9, 2009

Build or simply compile?

With Parancoe I already have a very productive environment for the development of my applications. I can have unit tests on most of the code, so I rarely need a full build and redeploy.

But sometimes it would be nice (and necessary) to just code and try the result in the browser. With JavaRebel you can do this simply compiling the new code, without the need of a full build and redeploy of your application.

For example, in my current parancoe-based project, I modified a method in the the HomeController, and some code (even adding a new method) in the UserProfileBo class.

Then I just recompiled the project, in 3 seconds:

NetBeans: Executing 'mvn -Dnetbeans.execution=true compiler:compile'
NetBeans: JAVA_HOME =/usr/lib/jvm/java-6-sun
Scanning for projects...
Searching repository for plugin with prefix: 'compiler'.
Building minimark Web Application
task-segment: [compiler:compile]
Compiling 2 source files to /home/lucio/MyWorks/minimark/minimark/target/classes
Total time: 3 seconds
Finished at: Sun Aug 09 08:14:56 CEST 2009
Final Memory: 18M/144M

When I refreshed the page in the browser, the log of my Tomcat showed:

JavaRebel: Reloading class 'com.benfante.minimark.controllers.HomeController'.
JavaRebel-Spring: Reconfiguring bean 'homeController' [com.benfante.minimark.controllers.HomeController]
JavaRebel: Reloading class 'com.benfante.minimark.blo.UserProfileBo'.
JavaRebel-Spring: Reconfiguring bean 'userProfileBo' [com.benfante.minimark.blo.UserProfileBo]

Notice the classes not only have been reloaded, but also the spring-managed annotation-configured beans have been reconfigured.

The configuration of JavaRebel (in this case) is very easy.

In my Maven pom.xml:




The Tomcat configuration is:

CATALINA_OPTS="-XX:PermSize=32m -XX:MaxPermSize=200m -Xmx256m -Dfile.encoding=UTF-8 -noverify -javaagent:/home/lucio/local/javarebel-2.0/javarebel.jar -Drebel.spring_plugin=true"