As I understand from the documentation Lift
provides Injector
trait (and its implementations) to inject dependencies as follows:
object MyInjector extends Injector {...}
val myThing: Box[Thing] = MyInjector.inject
Unfortunately, it looks too intrusive for me. I don't want my business classes to depend on the Injector
trait (and its implementation). I would like to keep my business classes clean and free of any framework dependencies.
Spring
开发者_C百科, for example, is not intrusive in this sense. That is, I do not have to add Spring
imports to my business classes in order to implement dependency injection.
Am I missing something?
If you don't like the Injector trait (neither do I), you do not have to use it. http://scala.sygneca.com/patterns/component-mixins. You can just stick to the cake pattern. Does Spring offer you anything that you can't implement with the cake pattern?
精彩评论