Hello Everybody,
I am trying to load a list of scaldi.Module classes from a jar (exposed as a service), and want to use those Modules to override existing ones in my application at runtime. Is there a way to initialize with an arbitrary list of Modules files loaded at run time. [Context: Moving an existing scala application from Guice, where we used to use the override functionality in Guice to do the same]
Ex:
val overrideModules: ServiceLoader[Module] = ServiceLoader.load(classOf[Module]) //This is fine it gets List of overrides for the Module
val listOfOverrideModules: List[Module] = convertToList(overrideModules)
implicit val appModule: MutableInjectorAggregation = listOfOverrideModules ++
new SpecificModule ++
new AnotherSpecificModule
....
That of course doesn't work currently, but was trying to figure out what would the right translation of this requirement. Another option I have is to create a providerFunction during the binding that can do a looking for Overridden services exposed in jars to be used at runtime.
Any precedence , ideas ?
Jayadev