Skip to content

Commit

Permalink
Add kodein
Browse files Browse the repository at this point in the history
  • Loading branch information
IRus committed Jan 11, 2021
1 parent 569f94a commit d685b9a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,7 @@ time (for i in {1..10}; do ./owb/build/install/owb/bin/owb; done)
time (for i in {1..10}; do ./spring/build/install/spring/bin/spring; done)
time (for i in {1..10}; do ./springboot/build/install/springboot/bin/springboot; done)
time (for i in {1..10}; do ./koin/build/install/koin/bin/koin; done)
time (for i in {1..10}; do ./koin/build/install/koin/bin/koin; done)
time (for i in {1..10}; do ./springboot/build/install/springboot/bin/springboot; done)
time (for i in {1..10}; do ./spring/build/install/spring/bin/spring; done)
time (for i in {1..10}; do ./owb/build/install/owb/bin/owb; done)
time (for i in {1..10}; do ./komodo/build/install/komodo/bin/komodo; done)
time (for i in {1..10}; do ./guice/build/install/guice/bin/guice; done)
time (for i in {1..10}; do ./dagger/build/install/dagger/bin/dagger; done)
time (for i in {1..10}; do ./cayennedi/build/install/cayennedi/bin/cayennedi; done)
time (for i in {1..10}; do ./bootique2/build/install/bootique2/bin/bootique2; done)
time (for i in {1..10}; do ./baseline/build/install/baseline/bin/baseline; done)
time (for i in {1..10}; do ./kodein/build/install/kodein/bin/kodein; done)
```

```
Expand All @@ -66,6 +57,7 @@ cloc ./koin/src
|Dagger|1.7|1.41|37|
|Cayenne DI|1.8|2.05|37|
|Koin|1.8|2.56|16|
|Kodein|2.4|2.93|17|
|Bootique 2|4.2|4.31|52|
|Guice|5.4|6.22|33|
|Komodo|6.4|7.56|17|
Expand Down
23 changes: 23 additions & 0 deletions kodein/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
kotlin("jvm").version("1.4.30-M1")
application
}

application {
mainClass.set("org.objectstyle.kodein.MainKt")
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "11"
}

repositories {
jcenter()
}

dependencies {
implementation(project(":common"))

implementation(kotlin("stdlib-jdk8"))
implementation("org.kodein.di:kodein-di-jvm:7.2.0")
}
20 changes: 20 additions & 0 deletions kodein/src/main/kotlin/org/objectstyle/kodein/Main.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.objectstyle.kodein

import org.kodein.di.DI
import org.kodein.di.bind
import org.kodein.di.direct
import org.kodein.di.instance
import org.kodein.di.singleton
import org.objectstyle.di.service.Service
import org.objectstyle.di.service.ServiceImpl
import org.objectstyle.di.service.SubService
import org.objectstyle.di.service.SubServiceImpl

fun main() {
val s = DI {
bind<Service>() with singleton { ServiceImpl(instance()) }
bind<SubService>() with singleton { SubServiceImpl() }
}.direct.instance<Service>()

println(s.doIt())
}
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include("common")
include("baseline")
include("kodein")
include("koin")
include("komodo")
include("bootique2")
Expand Down

0 comments on commit d685b9a

Please sign in to comment.