I have classes as below. I want statements in constructor of DataService to be called itself after the application or DataService class has has been initialized and before DataHandler is intitalized. But dataLoader object is null in the constructor. I am new to guice and want to know how can i achieve this using GUICE
@Singleton
@Managed
class DataService{
@Inject private DataLoader dataLoader;
DataService(){
dataLoader.load(); // I am trying to udnerstand why dataLoader is null?
}
}
@Singleton
@Managed
class DataHandler{
@EventHandler
public void handle(StaticData data){
//some logic om data
}
}
Class StaticDataModule extends AbstractModule{
@Override
protected void configure(){
bind(DataService.class).asEagerSingletin();
bind(DataHandler.class).asEarSingleton();
}
}