I have a Cache class, which is quite expensive to create, but after that it is installed as a single element and introduced into my service level.
@Override
protected void configure() {
bind(Cache.class).in(Singleton.class);
bind(Service.class).to(ServiceImpl.class).in(Singleton.class);
}
@Inject
public ServiceImpl(Cache cache){
this.cache = cache;
}
public Cache(){
}
My problem: it seems public () in the cache is only executed when trying to access one of its methods
Can I somehow create an object created when the server starts?
source
share