Showing posts with label Time Management. Show all posts
Showing posts with label Time Management. Show all posts

Sunday, November 18, 2012

Save Time - Integrating JRebel Development with Alfresco Customization


For the past two months or so, my team has been using JRebel 5.0.1 with our custom Alfresco development to minimize application redeploys during development.    It has been a LIFESAVER TIMESAVER!  I am hooked and won't ever go back to doing Java development without it!  Personally for the past 30 days, JRebel has prevented at least 314 redeploys/restarts saving me about 12.7 hours. (Which it tells you each time you start your application server locally).

I'm working on an Alfresco 4.0.2 customization project built with Alfresco web scripts where we store content in the Alfresco repository, Spring configuration to inject our custom Java-backed web scripts, and Spring's JDBC template to store and retrieve metadata about the content.  In conjunction with debug options turned on and attaching to the remote java app, multiple JUnit integration tests for each of the 18 custom web scripts we are writing, and the key - JRebel development integration - this has started being one of the most awesome development experiences I've only just had the opportunity to enjoy!

Here's a small blurb from the JRebel page on what it does:
"Save. Refresh. Enjoy. And stop redeploying in Java!
JRebel is a JVM-plugin that makes it possible for Java developers to instantly see any code change made to an app without redeploying. JRebel lets you see code changes instantly, versioning classes and resources individually and updating one at a time instead of as a lump application redeploy. When developers make a change to any class or resource in their IDE, the change is immediately reflected in the deployed application, skipping the build and redeploy phases and preventing an average of 5.25 work weeks per year in redeploys!"
For a detailed list, please refer here.

JRebel has detailed instructions on how to install with your IDE of choice, here's what I had to do:
  • View the instructions to install the plugin for your IDE (eclipse in our case) - http://zeroturnaround.com/software/jrebel/download/installing-jrebel-plugin-for-eclipse/
  • Install with Eclipse update manager
  • Restart Eclipse, window should pop up to Activate JRebel license.  Can also Open JRebel perspective and go to ‘Activation’ tab
  • Point to JRebel license, or use the link from the JRebel server, download client.lic and point to that file
  • Open JRebel perspective, navigate to ‘Overview’ tab, choose the project to have JRebel recognize
  • Right click on project root, JRebel, ensure that ‘Automatically generate jrebel.xml’ is enabled.  This creates the jrebel.xml file (tells what classes to auto deploy) in /src/main/resources
  • Ensure Project -> Build Automatically is enabled
  • Configure tomcat server where Alfresco is deployed.  In JRebel perspective, navigate to ‘Overview’ tab.  If you use 'External Server', click there to get the JVM options you will need to add to your tomcat JVM.  I have an alfresco.bat file that starts up my local tomcat server.  Add the JRebel JVM options to your JAVA_OPTS.
rem set debug options
set DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=n

rem set jrebel options
set JREBEL_OPTS=-javaagent:"C:\Apps\springsource\sts-2.9.2.RELEASE\plugins\org.zeroturnaround.eclipse.embedder_5.0.1.RELEASE-201207191833\jrebel\jrebel.jar" -Drebel.workspace.path="C:\workspaces\opm-team" -Drebel.log.file="C:\Users\jhsu\.jrebel\jrebel.log" -Drebel.properties="C:\Users\jhsu\.jrebel\jrebel.properties"

rem Set any default JVM options
set JAVA_OPTS=%DEBUG_OPTS% -Xms512m -Xmx512m -Xss512k -XX:MaxPermSize=256m -XX:NewSize=256m -server -Dalfresco.home=%ALF_HOME% -Dcom.sun.management.jmxremote %JREBEL_OPTS%
  • Deploy once more from scratch so the jrebel.xml will be on the target
  • NOTE:  Refreshes anything that goes in target/classes or target/test-classes (as defined in rebel.xml)
  • NOTE: Won’t refresh the web script descriptor files yet, have to do that manually
NOTE: There is a bug that I noticed with version 5.0.1 last week when I changed code inside the constructor.  Since both adding / removing constructors and changes to method bodies are claimed to be supported by JRebel, I was surprised at this.  *Edit:  We are using spring's default scope of singleton for this particular spring bean definition.*
  • We're not using Spring constructor injection so it's not this: http://zeroturnaround.com/forums/topic/does-jrebel-see-constructor-implementation-change-for-spring-component/
  • This article says re-invoking the constructor will break the existing bean’s state so this is very unlikely that this will ever be implemented, then why does JRebel state say adding / removing constructors is supported? http://zeroturnaround.com/forums/topic/jrebel-5-0-x-does-it-invoke-constructor-on-spring-bean-on-reloading-of-it/

Monday, September 17, 2012

The Key to Accomplishing More - EVERYDAY!

Drivers in the Washington DC area are one of two cities that spend the most time in traffic - an average of 70 hours being stuck in traffic PER YEAR. For me personally, I used to spend up to two hours a day in traffic commuting to and from work, I'm sure a lot of you have the same story!

My solution is crazy simple - Wake up early and get to work! It doesn't matter if you are not a morning person - YOU WILL BE. I slashed my commute time in half just doing this, and got other time benefits from doing this:

  • going to the grocery store at 3pm is a whole lot faster than 6 pm (when everyone else is trying to go)
  • going to the pool to catch the 3:45 adult-only swim lets me get in and out for lap training
  • basically, time savings get COMPOUNDED for everything else that you do
How did I come to this conclusion?
I live up I-270, and from where I live, you MUST leave before 6:30 am to not get stuck in 45+ minutes of traffic to get down 270. For example, three years ago I worked in Herndon, my first day, it took me two hours to get to work! I thought, "oh no", this is how long it's going to take me to get to work everyday? What have I done to myself?!

Well, I started leaving for work at 5:45am, this means getting up at 4:45am for me, I would get to work by 6:15. Most people didn't get in work that early, so I had another solution - go to the gym every morning (I was lucky enough to have a both a gym and shower in my work location - if you do I recommend this)! During that year in Herndon, waking up early, working out everyday, I was in THE BEST SHAPE OF MY LIFE!

My schedule is a little bit different now, but I still adhere to the leave early policy. I work in Vienna, leave by 6:15, get home by 3:00, and exercise in the afternoon to enjoy the great weather outside.