Using JRebel for Speedy Alfresco Development

Showing results for 
Search instead for 
Did you mean: 

Using JRebel for Speedy Alfresco Development

0 0 1,227

Obsolete Pages{{Obsolete}}

The official documentation is at:

JRebel is a Java Agent that provides enhancements to the HotSwap capability provided with Java. HotSwap is quite limited in the sorts of updates it will support and will only work when you are running in debug mode. JRebel allows local and remote deployment of a much wider range of additions/changes including, changes to method signatures, adding new properties and methods and it knows quite a bit about common Java framworks such as the Spring Framework. As such, JRebel can handle some changes to existing beans and can even instantiate new beans without restarting your JVM.

There is an issue with some pointers on how to use JRebel while developing Java code for Alfresco on the Maven Alfresco Archetypes project site.

There is a discussion about how Zia Consulting incorporated JRebel into their rapid development framework on Tech Talk Live Episode 69.

Tips / Tricks

When developing content behaviors we typically define an initializing spring bean. In the init() method we usually use the policy component to bind one or more of our methods (the behaviors) to some sort of policy(ies) (such as properties being updated, nodes being created, aspects being applied, etc.) Any changes made to such a class while JRebel is hot deploying changes, will cause the init method to be called each time the class is updated. As a result the behavior(s) is bound to the policy(ies) repeatedly. When one of these policies fires, the behavior will be triggered multiple times. After discussing this with ZeroTurnaround, it is apparent that we have to utilize a workaround.

Our workaround is to define a private static boolean in our class that keeps track of if the init() method has been processed. Obviously this is initialized to false. The first lines in our init() method check the value of this variable, if it is false it is set to true, if it is true we return immediately without performing our binding logic.

WARNING: if you need to bind something new without a restart you would place your binding statement(s) above this guard condition, force the class to update one time and then move the binding statement(s) below this guard condition.


JRebel is proprietary, but the license cost is pretty reasonable.

Open Source project committers can apply for a free 1-year license.

In 2012 JRebel was considering a JRebel plugin for Alfresco, but it doesn't look like they got much interest. If you state your interest when purchasing a license, it might help them prioritize.

Development Environment