04-05-2021 02:01 AM
Hello guys i want to ask if someone knows to explain how DI works in SnapLogic.
For example i want to set one object in one component and after that to be able to inject and use it in other components i have tried with DependencyManager but i was not getting any success doing that way, maybe i am doing something wrong. Can you please describe to me how it works in SnapLogic?
Thanks a lot.
04-05-2021 09:19 AM
We use Google’s Guice library for DI. Sounds like you’re on the right path with DependencyManager interface. How/where are you implementing that interface? Are you implementing it in your snap class? What does your implementation look like? It should typically look something like this (you may or may not want to specify SINGLETON):
@Override
public Module getManagedModule() {
return new AbstractModule() {
@Override
protected void configure() {
bind(MyInterface.class).to(MyImpl.class).in(Scopes.SINGLETON);
}
};
}