I'm still at the beginning in learning scala in addition to java and i didn't get it how is one supposed to do DI there? can or should i use an existing DI library, should it be done manually or is there another way?
+1
A:
I haven't done so myself, but most DI frameworks work at the bytecode level (AFAIK), so it should be possible to use them with any JVM language.
Marcelo Cantos
2010-04-01 21:55:20
One standard Java DI framework I've used with success in Scala over the past couple years is PicoContainer. (And you can use constructor injection instead of setter injection to maintain immutability.)
Seth Tisue
2010-04-01 22:47:02
+8
A:
Standard Java DI frameworks will usually work with Scala, but you can also use language constructs to achieve the same effect without external dependencies.
Dan Story
2010-04-01 21:59:49
the link gives me a really good overview with many examples. thank you very much.
Fabian
2010-04-01 22:09:28
fwiw, that article was one of the strongest inspirations I had when I first started learning Scala.
Daniel
2010-04-01 22:20:24
I'm curious how the cake pattern is implemented when a varying number of instances of a component might be needed by a service or registry. For example, what if WarmerComponentImpl in the linked example needed two different instances of an OnOffDeviceComponent to do its job?
Mitch Blevins
2010-04-01 22:57:40