Skip to content

Conversation

@galarragas
Copy link

I'm using subcut in some of my projects and I wanted to simplify the use case in which an object needs to retrieve some of the properties from configuration files.

I added some feature to implement injection similarly to the @value annotation in spring. For example:

class ToInject(implicit val bindingModule: BindingModule) extends Injectable {
    val stringProperty = injectProperty[String]("property1")
    val intProperty = injectProperty[Int]("property2")
    val longProperty = injectProperty[Long]("property3")
    val floatProperty = injectProperty[Float]("property4")
}

Allowing to inject in this way:

{
  implicit val bindingModule = newBindingModuleWithConfig(PropertiesConfigPropertySource.fromPath("src/test/resources/test.properties"))

   val configReaderInstance = new ToInject
}

It supports injection of basic types and allows generic types injection if a custom conversion function is provided.

I think it can help in simplify the code a lot. At least is doing it in my current work.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the "import .....config.Undefined" really needed ? (as you imported the entire package before)

@lucamilanesio
Copy link

That's cool stuff, like it 👍

galarragas and others added 9 commits February 6, 2014 10:58
…e approved. Fixed problems of lack of config support when mofidying the module with modifyBindings
SBT Plugins dependencies and repositories were obsolete and needed to be
updated to get the project building again.
Fix SBT Plugins dependencies
Scala 2.9.x is largely obsolete and subcut wasn't compiling on it anyway.
Conflicts:
	build.sbt
	pom.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants