Thursday, May 2, 2013

Convert ColdFusion application to Java

A little while back I was given the task of converting and old legacy ColdFusion application to a shiny, new Java one. I was also given very little time to do this. This application has now been at least 1 year live and only run into one issue that was due to the conversion. I thought I would just jot down a few points about the conversion process.

The first issue that came up was about what technology / frameworks to use in the new application. At the time GWT was a favoured web framework by one team and being pushed as the right choice. I ended up using Struts2, JSP and jQuery which ended up working really well because it was a request driven solution. A component driven framework, like GWT, would have required me to rewrite huge parts of the ColdFusion request driven logic. This would have no doubt introduced lots of bugs and extra time into the project. This was also something I wanted to avoid as well because there was little documentation or knowledge about the logic of the original ColdFusion application. In the end I believe it was absolutely the right choice given the time constraints and wishes just to "convert it to Java".

In addition I used Spring and Hibernate because I had used them lots before and having them running on Tomcat was nothing new.

Converting the ColdFusion code was pretty straightforward.
  • I would take a .cfm file and convert that to a .jsp.
  • Any of the scripting I would move out into a Struts2 action which would set attributes in the request that could be used by the JSP.
  • The logic from the action I would further remove and put into beans that were controlled by Spring.
  • I replaced any CFQUERY calls with a DAO layer using Hibernate that was configured using JPA annotations.
  • Most of the Spring beans had JUnit tests run against them to ensure they worked as expected.
In the end it was not really that difficult because I stayed within the bounds of request driven logic. The hardest part was finding out why things where done in a certain way with none of the original developers around and very little documentation.

1 comment:

  1. Since you could integrate with Java/J2EE , Struts and with Apache Axis Web Services and also having ColdSpring. Wondering what would be objective and context for such a migration from ColdFusion to Java/J2EE??.

    Let us all know through your reply.

    Thanks & Best Regards

    Harish

    ReplyDelete