IoC container supporting constructor injection with arguments named Scala named / default?

I would prefer to use the constructor installation over the JavaBean property nesting if I could use the named and default arguments function of Scala 2.8 arguments. Are there any IoC containers that support this or can be easily distributed for this? (The necessary information is present at runtime in the annotation of the scala.reflect.ScalaSignature class.)

I also have some basic (?) Expectations from the IoC container:

  • Auto-posting (by target class / feature or annotation, one-to-one, and one-to-many)
  • Explicit injection (explicit wiring) without much hassle (for example, Guice is weak there). For example, user is entered this way in new ConnectionPool(user="test") .
  • Lifecycle callback for shutdown cleanup (in the correct order)

Spring can do this, obviosuly, but does not support named parameters. I considered using FactoryBean -s for the Scala and Spring bridge, but that would mean too much hassle (creating a template or code) as far as I can see.

+4
source share
4 answers

PART A

I have a work reflection library that parses the Scala signature and can currently resolve named parameters: https://github.com/scalaj/scalaj-reflect

Unfortunately, I have not yet bound it to a Java reflection in order to be able to refer to methods, and I have not added logic to determine the default values ​​(although this should be trivial). Both features are very high on my to-do list :)

This is not an IoC per se container, but it is a prerequisite for my other project: https://github.com/scalaj/scalaj-spring . Work on scalaj-spring stopped when it became dazzlingly clear that I could not make any worthwhile further progress until I had signature-based reflection.

PART B

All these things are for people with large enterprises. Those who have no choice but to integrate their shiny new Scala code into some kind of awkward legacy system ... If this is not your use case, then you can just make Scala DI directly inside Scala.

It supports DI support under the Lift banner: http://www.assembla.com/wiki/show/liftweb/Dependency_Injection

You should also look for links to the cake template.

+3
source

Another dependency injection infrastructure in Scala subcut

+2
source

I considered using FactoryBean-s for Scala and Spring bridge, but that would mean too much trouble

I'm not sure I understand the complexity. It is actually quite simple to implement Spring FactoryBeans in Scala. Check out this small review http://olegzk.blogspot.com/2011/07/implementing-springs-factorybean-in.html

+1
source

I just released Sindi, an IoC container for the Scala programming language.

http://aloiscochard.github.com/sindi/

+1
source

Source: https://habr.com/ru/post/1343310/


All Articles