On Github vadger / devclub-presentation
MVC action based framework
Stateless
Runtime class reloading
Convention over configuration
Built-in HTTP server
No Servlet API
Inspired by Rails
Situation we had
Considered frameworks
We had only 2 weeks to make quite functional prototype
We had no constraints in technology selection
We wanted something lightweight and new
We wanted to be efficient
Well known (already boring) frameworks:
Something new and fun:
Small learning curve to start fast
No redeploy needed to code fast
JPA 2 out of the box for fast models creation/modification
H2 in-memory database for speed and simplicity
Play! has no DI out of the box
Play! approach: controller + model that also acts as DAO
Does not work good if you have several backends
Play! has Guice integration via modules (Spring too)
Due to slow backend caching was a must
Hopefully, Play! has cache support out of the box
EhCache for single instance applications we used initially
Memcached for multiple instances we were forced to switch after
With Guice method interceptors we made caching more elegant
@Singleton public class ABCDCoreService implements CoreService { @Cached(name = "customer", expires="5mn") @Override public Customer customer(long id) { .... } }
Play! has out of the box jobs support
On application start/stop jobs
Scheduled jobs: simple @Every("5mn") or more complex cron like @On("0 0 12 * * ?")
Or even run job from controller
By default jobs run in transaction
Also you can manage transactions manually
Tracking database schema changes is essential
Play! has built in support for managing DB evolutions
# -- 1.sql # --- !Ups ALTER TABLE User ADD age INT; # --- !Downs ALTER TABLE User DROP age;
In dev mode changes are detected on request
In prod mode: play evolutions:apply
In v.1.2.4 evolutions didn't work out of the box with Oracle :)
No Ant/Maven
No WAR (however, Play! has WAR support)
Just hardcore custom .sh build script
Separate script for fast test env update
Jenkins for Continuous Integration
Unit and UI tests run separately due to conflicts
Play! has 3 level of testing:
But Play! standard solution didn't suit us
Our approach: