I'm using guice to dynamically inject classes in my constructors. For example:
@Inject
public PublisherFrame(EventBus eventBus, MyPublisherService publishService)
And in my guice module:
bind(EventBus.class).in(Singleton.class);
bind(MyPublisherService.class).in(Singleton.class);
Works without problems.
The problem starts when i create a object which has a parameter which is constructed in java code:
public LoginController(EventBus eventBus, MyPublisherService publisherService, LoginDialog dlg)
Here LoginDialog is a java class which java codes create. To solve this i use @assist and:
install(new FactoryModuleBuilder().implement(ILoginController.class, LoginController.class).build(GuiceLoginControllerFactory.class));
Works also nicely. But now i have to create 2 extra java files:
- a new interface for LoginController: ILoginController, which doesn't do anything except help guice.
- another interface for guice: GuiceLoginControllerFactory
Is there an easier way to inject a variable which has a custom parameter in the constructor? (without creating 2 extra "guice" helper files)