I have a problem and I don't know which way to got about it
Say I have two Service Provider Interfaces (SPI)
public interface View{
display();
}
public interface Logger{
log(String s);
}
And a Service provider that provides both services i.e
public class LogView implements View, Logger{
...
}
The problem is that, when I try to get an instance of the log service via ServiceLoader.load(Logger.class)
it's different from the instance created with ServiceLoader.load(View.class)
. Is there a way to go about it such that I can get the same object instance from both calls?
The idea is that after loading the view as a GUI, I want to be able to log on that same instance of the GUI and not another. As it stand now I'm stuck with two separate instance so the log does show up.