You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
Michael Ekstrand edited this page Sep 21, 2013
·
7 revisions
Grapht Dependency Injector
This is the documentation & project planning wiki for Grapht, the dependency injector developed by GroupLens Research.
Getting Started
To start using grapht, configure and build an Injector.
import org.grouplens.grapht.Injector;
import org.grouplens.grapht.InjectorBuilder;
...
InjectorBuilder builder = new InjectorBuilder();
builder.bind(MyInterface1.class).to(MyImpl1.class); // singleton
builder.bind(MyInterface2.class).unshared().to(MyImpl2.class); // new instance per getInstance
Injector injector = builder.build();
Then, you can use this injector to retrieve instances:
injector.getInstance(MyInterface1.class);
Make sure that your injectables (like MyImpl1 and MyImpl2) have a default constructor, or that the constructor is annotated with @Inject and depends on injectable types.