Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. @Singleton
  2. class Person1 @Inject() (personApiService: PersonApiService, personDBApiService: PersonDBApiService) extends Person {
  3.  
  4. override def gerPersonInfo(person: Person): Future[PersonInfo] = {
  5. ...
  6. }
  7.  
  8. }
  9.  
  10. trait PeopleManager {
  11.  
  12. def application: Application
  13.  
  14. def peopleList = List(
  15. classOf[Person1],
  16. classOf[Person2],
  17. ...
  18. )
  19.  
  20. lazy val peopleInstances: List[Person] = peopleList.map(personClass => application.injector.instanceOf(personClass))
  21. }
  22.  
  23. class PersonService @Inject() (val application: Application) extends PeopleManager {
  24. // now I can use here peopleInstances.
  25. }
  26.  
  27. class MyController @Inject() (cc: ControllerComponents, peopleService: Provider[PersonServcie]) extends AbstractController(cc) {
  28. ...
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement