0

If I have a class bound in gin which is singleton as:

bind(SomeStore.class).in(Singleton.class);

While injecting this SomeStore class, it's instance always created new which is not supposed to be.

public class SomeStore {

    private HashMap<Integer, Serializable>  testMap;

    public SomeStore() {
    }

    public void addValue(Integer hashkey, Serializable serializable) {
        if (testMap == null)
            testMap = new HashMap<Integer, Serializable>();
        testMap.put(hashkey, serializable);
    }

    public Serializable getValue(Integer hashkey) {
        return testMap.get(hashkey);
    }
}

Does it remains singleton throughout the browser's different tabs, and even when the UI is reloaded. If not, what will be ideal solution to do so? What if I bound it in SessionScope?

  • `Does it remains singleton throughout the browser's different tabs, and even when the UI is reloaded. If not, what will be ideal solution to do so ?` no, different tabs don't share same memory. reload tab will clear current memory. single page app – PWC Mar 10 '17 at 05:58
  • What if I bound it in SessionScope? – komal_sonigra Mar 10 '17 at 06:07

0 Answers0