What are Play 2.0 equivalents of @Before and @After from Play 1.2?

playframework-2.0

Solution

Unfortunately, you'll have to use action composition for the `@Before`, and there is no equivalent for the `@After`.

For the `@After`, I'd write my own `after` method at the end of end action; something like this:

public static Result index() {
    ....
    Result result = ...;
    return after(result);
}

protected static Result after(Result result) {
    ...
    Result afterResult = ...,
    return afterResult

}

Problem

When I was using Play 1.2, I was able to annotate some methods inside any controller with @Before or @After (and others...) in order to execute a method before or after each request inside this controller. How can I do this in Play 2.0? I read a little bit about the Global object, but it doesn't seem to be what I am looking for. Also, action composition seems way too complex for what I want to do. I hope to see something simpler. Any ideas?

Original source