The first time I encountered e.g. Ruby’s Sinatra framework or PHP’s Zend Framework, I wondered if there is something adequate in Java, it all seems so bloated here. Although there are myriads of frameworks around, I have found none so far that I deemed perfect for the kind of architecture I would like to implement.
I wanted to design a web application that would be heavy on the Javascript with most of the application logic implemented on the client, the Java back-end would more or less just serve as a data store or perform complex computations.
I did look through related questions here but I couldn’t find the perfect answer, each of the suggested solutions had a quirk that would not match the requirements.
So this is what I am looking for, a open source framework with the following features:
- Convention over Configuration
- No XML configuration except for web.xml
- Pure Java (no Scala, no Groovy, …)
- natural REST-style URLs such as /news/2011/july (no .do, no .jsp, …)
- REST-aware
- it shouldn’t force me to deploy on an application server (e.g. EJB should be optional)
- session support would be nice but not mandatory
- code generation as in Rails would be awesome but not mandatory
- minimum of dependencies, small in overall size
- MVC would be nice, but
- I’d like to be able to choose the M part, choose the persistence libraries on my own (no bundling).
- No automatically generated code for the view, neither HTML, Javascript, nor CSS
- An integrated template language would be nice, but it should be minimalistic (simple control flow, access to template variables)
- Layout support (i.e. you are able to specify a common template for similar views)
- Free choice of Javascript framework for the views
Basically this would mean an MVC framework that does the routing for me and offers template support for the views, but the rest is fully modular, no magic. Is there any minimalistic framework that would provide this (or at least is modular enough to be configured that way)?
How about Play Framework?
Play only has few configuration files. Most of its structure is by convention.
For example the basic structure goes like this:
Play has no XML configuration, including no web.xml. It has a Routing file instead. See the example below what it uses for routing.
It’s pure Java, but you can use Scala or Groovy through a plugin.
From the site:
Play is a real "Share nothing" system. Ready for REST, it is easily scaled by running multiple instances of the same application on several servers.In fact routing in a Rest like manner is quite easy:
It’s not hard to guess which goes where once you get used to Play a bit.
It doesn’t. In fact you deploy by saving your files. EJB are completely optional and so are
.war,.earand other forms of deployment.I don’t think it does much code generation but I’m not 100% on that. It does automatically create all required folders and instantiate a basic example page. I don’t know if Rails generates anything else…
See MVC in Play
.html,.css,.jsand other files to create dynamic pages.I has inbuilt template language based on Groovy template language e.g.
You have ${emails.unread ?: 'no'} ${emails.unread?.pluralize('email')} !Other pros:
Cons: