In common-project I have this:
trait DBProvider trait DBTableNamesProvider trait DefaultDBProvider extends DBProvider trait DefaultTableNames extends DBTableNamesProvider trait MyService extends DBProvider with DBTableNamesProvider object MyService { def apply() = new MyService with DefaultDBProvider with DefaultTableNames {} } In projectA which has a reference to common-project as a jar I wish to construct MyService
projectA (has dependency on common-project):
object MyOtherApp { trait MyOtherTableName extends DBTableNamesProvider val MyCustomService = MyService() with MyOtherTableName // will not compile how to reuse the module's MyService() with another implementation of one of the traits? } The above will not compile I cannot just call MyService() construction and override some of the dependencies.
The above is what I wish to do, I wish to override from a different project the factory construction of MyService() apply with my own implementation of MyProjectATableNames is that possible in scala? if not what is the recommended way without code repetition?