Enterprise Architect in HCL Technologies a $7Billion IT services organization. My role is to work as a Technology Partner for large enterprise customers providing them low cost opensource solutions around Java, Spring and vFabric stack. I am also working on various projects involving, Cloud base solution, Mobile application and Business Analytics around Spring and vFabric space. Over 23 yrs, I have build repository of technologies and tools I liked and used extensively in my day to day work. In this blog, I am putting all these best practices and tools so that it will help the people who visit my website. Krishna is a DZone MVB and is not an employee of DZone and has posted 64 posts at DZone. You can read more from them at their website. View Full User Profile

Java Web Development Frameworks: Play 2.0 and Spring MVC

10.31.2012
| 9138 views |
  • submit to reddit

Recently, while exploring alternative Java Web Development frameworks, I stumbled upon Play 2.0, I wanted to compare this with Spring MVC, which has strong enterprise development capabilities. Though I'm biased towards Spring MVC, I still liked Play 2.0 as a potential candidate. Also note, there are some major differences between Play 2.0 and Play 1.0.

Taking advantage of existing knowledge

Play 2.0 support MVC design pattern similar to Spring MVC. Java is the primary language in Play 2.0, it also support for ScalaLift is another popular framework that support Scala. There is a good comparison of Play 2.0 and Lift here. Java developers can be productive immediately, I was up and running a web application in 15mins.

There is a good article in Stackoverflow comparing Play 2.0 with other non java frameworks like, Grails and Django on What is pro and contra of using Play Framework?

SBT: Ease of build

Play 2.0 uses SBT (Simple build tool) for build process and Maven for repository management.Maven and Gradle are popular among Java and Spring MVC world for build and repository management.

SBT Support for continuous Integration

As mentioned earlier, Play 2.0 is built on top of SBTSBT has plugins for Hudson for continuous integration

Netty based Ease of deploy

Play 2.0 is built on top and bundled with Netty web server which is an asynchronous event-driven network application framework. Netty is similar to Node.js, which is popular among people who are looking for high performance web application development. It also supportswinsocket protocol.  Ideally for deployment, you can use commands like

play dist
play publish

The above commands will zip the whole Play 2.0 application into a zip file and publish the application to Maven repository. In the Production environment, based on the version, you can download and unzip and run the Play 2.0 environment. There are few good articles around this in Stackoverflow, Play Framework Deployment.

The other and not so preferred way is to bundle the play application in a war file and deploy it in a Servlet container like vFabric tc Server. When you do this, you will not exploit the full potential of Play framework like Netty. Play development team will support Servlet containers like vFabric tc Server in their future version, till than there is a article in Stackoverflow which shows how to deploy in Tomcat.

Ease of Unit test

There is a good article on how to do JUnit test in Play 2.0. This will demonstrate testing of all the layers of Play 2.0 like Routes, Controllers and Views. Play 2.0 definitely encourages Test first developmentSonar is a good software quality measuring tool, there are also some configuration for integrating SBT with Sonar.

Support for ORM: Ebean and JPA

Play 2.0 primarily supports EBean and JPA. There are hacks to support iBatis and other lightweight ORMs but it is not officially supported.


Published at DZone with permission of Krishna Prasad, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)