Category Archives: Play! Framework

Executing Play! from outside of Play! code

As I’ve said earlier, I think that the Play! framework is lovely. It makes it easy to develop and write code quickly. One of the ways that it enables this is through performing runtime byte code enhancement of the code. This makes execution of your code somewhat non-trivial when coming from a non-Play! context. Play! aims to meet all your needs, but use cases exist where it is important non-Play! code with Play! code, and have your non-Play! code call into Play!

Having said that this is non-trivial, it is reassuring to know that the process to do this is very straight forward.

  1. Create a subclass of play.Invoker.Invocation.
  2. Override the public void execute() method.
  3. Call the run() method of the invocation.

Invoker.Invocation invocation = new Invoker.Invocation() {
public void execute() {
//do stuff with play here

With this simple snippet of code, it is possible to have non-Play! code easily and cleanly call your Play! application code.

Eleven reasons to use the Play! Framework for Java Web Development

The Play! Framework is a great tool for rapidly building Java web applications. Play! takes many of the ideas from the dynamic languages world (Rails and Django), and provides them to Java web development. Reasons to conside Play! for Java Development are:

  1. Rapid development via a local development server that automatically compiles your java code for you. It’s amazing how good it is to develop like this, and what a difference the rapid feedback loop makes.
  2. A good clean MVC famework.
  3. Nice testing support baked in.
  4. A useful routing table to make clean urls easy to work with.
  5. A focus around REST, but no slavish observence of it.
  6. built-in simple JSON support.
  7. A good module framework with useful modules including a “CRUD” module, and a Scala module currently under development
  8. An interesting mix of Java class enhancement that makes it easy to work with code, and then have the enhancer provide some of the hard work for ensuring that multiple threads are handled well.
  9. Deployment to a range of platforms, including JEE Servlets (Play! 1.0.2 has been tested on containers such as tomcat, jetty, JBoss and IBM WebSphere Portal 6.1), and the GAE.
  10. Enhancements to the JPA which make it really easy to work with.
  11. An active and supportive community. There is the right balance between having strong opinions about the “Play!” way of doing things, and helping people to get things done.

Play! makes Java web development fun and productive. The feedback loop is really quick, and much of the boilerplate code is removed. It’s well worth considering for any application you want to write in Java.

Take a look at the video, and work through the tutorial to get a feel for what development with Play! is like.