public interface MyService {
void doSomething();
}
public class MyServiceImpl implements MyService {
@Override
public void doSomething() {
}
}
public class MyApp {
@Provides
public MyService provideMyService() {
return new MyServiceImpl();
}
@EventHandler
public void handleEvent(ExampleEvent event) {
}
public static void main(String[] args) {
MyApp app = new MyApp();
Injector injector = Injector.builder().addModule(app).build();
MyService myService = injector.getInstance(MyService.class);
myService.doSomething();
}
}