Playback 2.2.1 Entering classes other than the controller

I followed this great example https://github.com/huntc/play-spring-data-jpa to include JPA and DI in the Java Play app. It works fine, but in more complex applications, it is more difficult to implement several things.

The main problem is using DI with:

  • (for example, Deadbolt, where in the Deadbolt handler you need to access the database to retrieve the user and roles).
  • (you must authenticate the user in the authentication method)

My question is: how to inject repositories (or something else) into classes other than the controller? I tried to access the repository using Play.current (). Global (). GetControllerInstance (PersonRepository.class); but I find it hacks. Any ideas how to solve it OR should I choose a different approach?

+4
source share

All Articles