Reputation: 75
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?
Upvotes: 0
Views: 40