Guice Multibinding from Classpath

I am trying to configure a plugin system for cucumber-jvm bindings using Guice as a DI. The idea is to run the beforeRequest () method before each step When in a cucumber. Plugins are separate .jar found on the way to classes.

Since Cucumber requires an explicit Guice module expression in cucumber.properties, which will be used to create the Injector, I cannot use the standard Guice Multibindings and have a separate module for each plugin.

The idea of ​​what it should look like:

class CucumberClazz {

   Set<Plugin> plugins;

   public doRequest() {
     for(Plugin plugin: plugins) plugin.beforeRequest();
     /* Rest of the code */
   } 
}

Is there a fantastic option to detect all plugin implementations in the classpath using Guice?

+4

Source: https://habr.com/ru/post/1609328/


All Articles