cancel
Showing results for 
Search instead for 
Did you mean: 

Dependency Injection

imilan
New Contributor

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.

1 REPLY 1

ptaylor
Employee
Employee

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);
        }
    };
}