Before Playframework 2.4 I used create object for singleton class, and now I see than Singletons can be achieved using the @Singleton annotation.
But, what is the difference?
Is only for using a dependency injection with @Inject() ?
I am afraid that Playframework 2.4 with dependency Injection enter in an unnecessarily complicated way.
@Singletonis part of the JSR 330 standard and is indeed for dependency injection only. It tells your DI framework to create only one instance of the given class and use that single instance across your application. From the docs:You can think of it as a directive to your DI framework to create only one instance. Nothing holds you back from creating multiple
@Singletonannotated classes by hand usingnew.Singleton objects in scala in contrast are true singletons and cannot be instantiated by hand.