Annotation Type EagerSingleton


  • @Target(TYPE)
    @Retention(RUNTIME)
    @Documented
    @Inherited
    public @interface EagerSingleton
    Annotated beans will be injected in guice module as singleton. (equivalent of bind(type).asEagerSingleton()). Ideal for any kind of initializers (e.g. with @PostConstruct)

    If annotated extension is manually bound in guice then extension will simply check that bean is bound as eager singleton and fail otherwise (because it is not possible to modify existing binding).

    NOTE: use sparingly, because such initialization logic contradicts with guice ideology (such initializer may be suitable for quick prototype or some rare exceptional cases).

    Since:
    01.09.2014