users@hk2.java.net

Singleton Scope

From: Zack Manning <zack.manning_at_gmail.com>
Date: Wed, 28 May 2014 10:29:51 -0700

When binding a singleton scoped class within an AbstractBinder, I notice that I always have to chain .in(Singleton.class) to every binding, regardless of if my class has @Singleton at the class level. Does HK2 actually pay attention to the singleton binding on the class? Or is this a bug?

            ….

            bindAsContract(SingleUseTokenCache.class).in(Singleton.class); //i wish this didnt need the latter

            ….

            @Singleton
            public class SingleUseTokenCache {
            ….
        
Just some clarification would be much appreciated as it makes the configuration look muddier than it needs to be.

Zack