My Component and and application file are getting very large and the same
code base serves multiple brands. We want to conditionally inject modules
depending on certain config. Is there any way to do this.
Our current code base looks something like this.
public class SupportPortalApplication extends
Application<SupportPortalConfiguration> { ... private void
initializeComponent() { if (component == null) { component =
DaggerSupportPortalComponent.builder() .moduleOne(new ModuleOne())
.moduleTwo(new ModuleTwo()) .moduleThree(new ModuleThree()) .build(); } }
private void registerEndpoints(Environment environment) {
environment.jersey().register(component.getResourceModule1());
environment.jersey().register(component.getResourceModule2());
environment.jersey().register(component.getResourceModule3()); } ... }
@Singleton @Component(modules = {ModuleOne.class, ModuleTwo.class,
ModuleThree.class}) public interface SupportPortalComponent { ModuleOne
getModuleOne(); ModuleTwo getModuleTwo(); ModuleThree getModuleThree(); }
I want to be able to conditionally load module three, along with its
routes. It is easy to just remove the .moduleThree(new ModuleThree()) from
the initializeComponent function conditionally but I would need a way to
remove it as a module in the SupportPortalComponent. Is there any way to do
this?
DropwizardVersion: "1.3.5"
DaggerVersion:"2.29.1"
Github Question:
https://github.com/dropwizard/dropwizard/issues/3982
--
You received this message because you are subscribed to the Google Groups
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/dropwizard-user/42237a9c-b0c1-457c-bfc2-dae17f46332cn%40googlegroups.com.