Why is MyDslFactory.eINSTANCE the common way to get a factory? [message #1832962] |
Wed, 30 September 2020 03:00  |
Eclipse User |
|
|
|
Hello Community,
I was wondering if there is a reason why in the tutorials and books I have seen so far the factory for creating EObjects of the model is always instantiated by using
static val factory = MyDslFactory.eINSTANCE
But this prohibits future extension of the factory that I use in my code.
Is there any reason why I should not implement a binding (possible annotated with @SingletonBinding) in the RuntimeModule that instantiates the desired factory?
I mean something like this:
class PslpRuntimeModule extends AbstractPslpRuntimeModule {
def MyDslFactory bindMyDslFactory() {
val factory = MyDslFactory.eINSTANCE
return new MyDslDecoratingFactory(factory)
}
}
Now at the desired places I could just use the factory by injecting it via @Inject MyDslFactory factory
Or is there a more elegant (or canonical) way of having the same flexibility?
Regards
Jan Hermes
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04179 seconds