开发者

Question about Injector in Lift

开发者 https://www.devze.com 2023-03-03 19:10 出处:网络
As I understand from the documentation Lift provides Injector trait (and its implementations) to inject dependencies as follows:

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消