Sunday, 28 October 2012

Java Web Development Frameworks: Play 2.0 and Spring MVC


Recently I was exploring alternative Java Web Development frameworks, I stumbled uponPlay 2.0, I wanted to compare this against Spring MVC which supports enterprise development well enough. In this blog I will discuss few of those points, There are some major differences between Play 2.0 and Play 1.0 for awareness.
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 Scala. Lift 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.

A good article in Stackoverflow comparing Play 2.0 with other non java frameworks like, Grailsand Django on What is pro and contra of using Play Framework?
SBT: Ease of build

For build and deployment Play 2.0 uses SBT (Simple build tool) and Maven, both are popular among Java and Spring MVC world. Play 2.0 uses, Maven for repository management.
SBT Support for continuous Integration

As mentioned earlier, Play 2.0 is built on top of SBT. SBT 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. This is similar to Node.js, which are popular among people who are looking for high performance web application development. It works on the principle of winsocket. Ideally for deployment, you can use commands like



1 play dist


2


3 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. 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 development. 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.

No comments:

Post a Comment