Previously, we said that an action is a Java method that returns a play.mvc.Result value. Actually, Play manages internally actions as functions. An action provided by the Java API is an instance of play.mvc.Action. Play builds a root action for you that just calls the proper action method. This allows for more complicated action composition.

Note: Every request must be served by a distinct instance of your play.mvc.Action. If a singleton pattern is used, requests will be routed incorrectly during multiple request scenarios. For example, if you are using Spring as a DI container for Play, you need to make sure that your action beans are prototype scoped.

You can also put any action composition annotation directly on the Controller class. In this case it will be applied to all action methods defined by this controller.

@Security.Authenticated
public class Admin extends Controller {
...
}

Note: If you want the action composition annotation(s) put on a Controller class to be executed before the one(s) put on action methods set play.http.actionComposition.controllerAnnotationsFirst = true in application.conf. However, be aware that if you use a third party module in your project it may rely on a certain execution order of its annotations.

Note: As stated above, every request must be served by a distinct instance of your play.mvc.Action and that is why you add a java.util.function.Supplier<Action> instead of the instance itself. Of course, you can have a Supplier returning the same instance every time, but this is not encouraged.