From 0d21b2fc90c97b97953c5681f0c90fec8ec83bb2 Mon Sep 17 00:00:00 2001 From: Ruslan Ibragimov Date: Sat, 13 Mar 2021 17:18:14 +0300 Subject: [PATCH] Spring-Scan --- README.md | 2 + common-deep/src/test/kotlin/TestRunner.kt | 2 +- .../build.gradle.kts | 12 + .../kotlin/io.heapy.sample.common2/Tree.kt | 819 ++++++++++++++++++ common-spring-annotations/build.gradle.kts | 12 + .../main/java/io/heapy/di/service/Service.kt | 5 + .../java/io/heapy/di/service/ServiceImpl.kt | 12 + .../java/io/heapy/di/service/SubService.kt | 5 + .../io/heapy/di/service/SubServiceImpl.kt | 10 + settings.gradle.kts | 3 + spring-scan-deep/build.gradle.kts | 18 + .../src/main/java/io/heapy/spring/Main.java | 15 + spring-scan/build.gradle.kts | 18 + .../src/main/java/io/heapy/spring/Main.java | 16 + 14 files changed, 948 insertions(+), 1 deletion(-) create mode 100644 common-spring-annotations-deep/build.gradle.kts create mode 100644 common-spring-annotations-deep/src/main/kotlin/io.heapy.sample.common2/Tree.kt create mode 100644 common-spring-annotations/build.gradle.kts create mode 100644 common-spring-annotations/src/main/java/io/heapy/di/service/Service.kt create mode 100644 common-spring-annotations/src/main/java/io/heapy/di/service/ServiceImpl.kt create mode 100644 common-spring-annotations/src/main/java/io/heapy/di/service/SubService.kt create mode 100644 common-spring-annotations/src/main/java/io/heapy/di/service/SubServiceImpl.kt create mode 100644 spring-scan-deep/build.gradle.kts create mode 100644 spring-scan-deep/src/main/java/io/heapy/spring/Main.java create mode 100644 spring-scan/build.gradle.kts create mode 100644 spring-scan/src/main/java/io/heapy/spring/Main.java diff --git a/README.md b/README.md index 6bd7a74..fa6dca9 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ OpenJDK 64-Bit Server VM Corretto-11.0.10.9.1 (build 11.0.10+9-LTS, mixed mode) |guice|5.42|331|33| |spring|5.60|356|23| |komodo|6.41|392|17| +|spring-scan|5.60|410|13| |owb|3.05|421|35| |spring-xml|5.60|430|19| |springboot|9.73|916|42| @@ -69,4 +70,5 @@ OpenJDK 64-Bit Server VM Corretto-11.0.10.9.1 (build 11.0.10+9-LTS, mixed mode) |komodo-deep|6.64|531|114| |spring-xml-deep|5.72|559|319| |owb-deep|3.18|584|532| +|spring-scan-deep|5.73|687|13| |springboot-deep|9.85|1054|439| diff --git a/common-deep/src/test/kotlin/TestRunner.kt b/common-deep/src/test/kotlin/TestRunner.kt index b1f0859..c91ee92 100644 --- a/common-deep/src/test/kotlin/TestRunner.kt +++ b/common-deep/src/test/kotlin/TestRunner.kt @@ -21,6 +21,7 @@ val projects = listOf( "kotlin-lazy", "owb", "spring", + "spring-scan", "spring-xml", "springboot", // TODO: @@ -29,7 +30,6 @@ val projects = listOf( // "quarkus", // "spring-fu", // "spring-index", -// "spring-scan", // "spring-scan-large", // "springboot-index", ) diff --git a/common-spring-annotations-deep/build.gradle.kts b/common-spring-annotations-deep/build.gradle.kts new file mode 100644 index 0000000..6bd2f5f --- /dev/null +++ b/common-spring-annotations-deep/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + kotlin("jvm").version("1.4.31") +} + +repositories { + mavenCentral() +} + +dependencies { + api(kotlin("stdlib-jdk8")) + implementation("org.springframework:spring-context:5.3.4") +} diff --git a/common-spring-annotations-deep/src/main/kotlin/io.heapy.sample.common2/Tree.kt b/common-spring-annotations-deep/src/main/kotlin/io.heapy.sample.common2/Tree.kt new file mode 100644 index 0000000..a5da3a7 --- /dev/null +++ b/common-spring-annotations-deep/src/main/kotlin/io.heapy.sample.common2/Tree.kt @@ -0,0 +1,819 @@ +package io.heapy.sample.common2 + +import org.springframework.stereotype.Component + +interface Service { + fun name(): String +} +@Component +class DefaultService(private val service: Service1) : Service { + override fun name() = service.name() +} + +interface Service1 { + fun name(): String +} +@Component +class DefaultService1(private val service: Service2) : Service1 { + override fun name() = service.name() +} + +interface Service2 { + fun name(): String +} +@Component +class DefaultService2(private val service: Service3) : Service2 { + override fun name() = service.name() +} + +interface Service3 { + fun name(): String +} +@Component +class DefaultService3(private val service: Service4) : Service3 { + override fun name() = service.name() +} + +interface Service4 { + fun name(): String +} +@Component +class DefaultService4(private val service: Service5) : Service4 { + override fun name() = service.name() +} + +interface Service5 { + fun name(): String +} +@Component +class DefaultService5(private val service: Service6) : Service5 { + override fun name() = service.name() +} + +interface Service6 { + fun name(): String +} +@Component +class DefaultService6(private val service: Service7) : Service6 { + override fun name() = service.name() +} + +interface Service7 { + fun name(): String +} +@Component +class DefaultService7(private val service: Service8) : Service7 { + override fun name() = service.name() +} + +interface Service8 { + fun name(): String +} +@Component +class DefaultService8(private val service: Service9) : Service8 { + override fun name() = service.name() +} + +interface Service9 { + fun name(): String +} +@Component +class DefaultService9(private val service: Service10) : Service9 { + override fun name() = service.name() +} + +interface Service10 { + fun name(): String +} +@Component +class DefaultService10(private val service: Service11) : Service10 { + override fun name() = service.name() +} + +interface Service11 { + fun name(): String +} +@Component +class DefaultService11(private val service: Service12) : Service11 { + override fun name() = service.name() +} + +interface Service12 { + fun name(): String +} +@Component +class DefaultService12(private val service: Service13) : Service12 { + override fun name() = service.name() +} + +interface Service13 { + fun name(): String +} +@Component +class DefaultService13(private val service: Service14) : Service13 { + override fun name() = service.name() +} + +interface Service14 { + fun name(): String +} +@Component +class DefaultService14(private val service: Service15) : Service14 { + override fun name() = service.name() +} + +interface Service15 { + fun name(): String +} +@Component +class DefaultService15(private val service: Service16) : Service15 { + override fun name() = service.name() +} + +interface Service16 { + fun name(): String +} +@Component +class DefaultService16(private val service: Service17) : Service16 { + override fun name() = service.name() +} + +interface Service17 { + fun name(): String +} +@Component +class DefaultService17(private val service: Service18) : Service17 { + override fun name() = service.name() +} + +interface Service18 { + fun name(): String +} +@Component +class DefaultService18(private val service: Service19) : Service18 { + override fun name() = service.name() +} + +interface Service19 { + fun name(): String +} +@Component +class DefaultService19(private val service: Service20) : Service19 { + override fun name() = service.name() +} + +interface Service20 { + fun name(): String +} +@Component +class DefaultService20(private val service: Service21) : Service20 { + override fun name() = service.name() +} + +interface Service21 { + fun name(): String +} +@Component +class DefaultService21(private val service: Service22) : Service21 { + override fun name() = service.name() +} + +interface Service22 { + fun name(): String +} +@Component +class DefaultService22(private val service: Service23) : Service22 { + override fun name() = service.name() +} + +interface Service23 { + fun name(): String +} +@Component +class DefaultService23(private val service: Service24) : Service23 { + override fun name() = service.name() +} + +interface Service24 { + fun name(): String +} +@Component +class DefaultService24(private val service: Service25) : Service24 { + override fun name() = service.name() +} + +interface Service25 { + fun name(): String +} +@Component +class DefaultService25(private val service: Service26) : Service25 { + override fun name() = service.name() +} + +interface Service26 { + fun name(): String +} +@Component +class DefaultService26(private val service: Service27) : Service26 { + override fun name() = service.name() +} + +interface Service27 { + fun name(): String +} +@Component +class DefaultService27(private val service: Service28) : Service27 { + override fun name() = service.name() +} + +interface Service28 { + fun name(): String +} +@Component +class DefaultService28(private val service: Service29) : Service28 { + override fun name() = service.name() +} + +interface Service29 { + fun name(): String +} +@Component +class DefaultService29(private val service: Service30) : Service29 { + override fun name() = service.name() +} + +interface Service30 { + fun name(): String +} +@Component +class DefaultService30(private val service: Service31) : Service30 { + override fun name() = service.name() +} + +interface Service31 { + fun name(): String +} +@Component +class DefaultService31(private val service: Service32) : Service31 { + override fun name() = service.name() +} + +interface Service32 { + fun name(): String +} +@Component +class DefaultService32(private val service: Service33) : Service32 { + override fun name() = service.name() +} + +interface Service33 { + fun name(): String +} +@Component +class DefaultService33(private val service: Service34) : Service33 { + override fun name() = service.name() +} + +interface Service34 { + fun name(): String +} +@Component +class DefaultService34(private val service: Service35) : Service34 { + override fun name() = service.name() +} + +interface Service35 { + fun name(): String +} +@Component +class DefaultService35(private val service: Service36) : Service35 { + override fun name() = service.name() +} + +interface Service36 { + fun name(): String +} +@Component +class DefaultService36(private val service: Service37) : Service36 { + override fun name() = service.name() +} + +interface Service37 { + fun name(): String +} +@Component +class DefaultService37(private val service: Service38) : Service37 { + override fun name() = service.name() +} + +interface Service38 { + fun name(): String +} +@Component +class DefaultService38(private val service: Service39) : Service38 { + override fun name() = service.name() +} + +interface Service39 { + fun name(): String +} +@Component +class DefaultService39(private val service: Service40) : Service39 { + override fun name() = service.name() +} + +interface Service40 { + fun name(): String +} +@Component +class DefaultService40(private val service: Service41) : Service40 { + override fun name() = service.name() +} + +interface Service41 { + fun name(): String +} +@Component +class DefaultService41(private val service: Service42) : Service41 { + override fun name() = service.name() +} + +interface Service42 { + fun name(): String +} +@Component +class DefaultService42(private val service: Service43) : Service42 { + override fun name() = service.name() +} + +interface Service43 { + fun name(): String +} +@Component +class DefaultService43(private val service: Service44) : Service43 { + override fun name() = service.name() +} + +interface Service44 { + fun name(): String +} +@Component +class DefaultService44(private val service: Service45) : Service44 { + override fun name() = service.name() +} + +interface Service45 { + fun name(): String +} +@Component +class DefaultService45(private val service: Service46) : Service45 { + override fun name() = service.name() +} + +interface Service46 { + fun name(): String +} +@Component +class DefaultService46(private val service: Service47) : Service46 { + override fun name() = service.name() +} + +interface Service47 { + fun name(): String +} +@Component +class DefaultService47(private val service: Service48) : Service47 { + override fun name() = service.name() +} + +interface Service48 { + fun name(): String +} +@Component +class DefaultService48(private val service: Service49) : Service48 { + override fun name() = service.name() +} + +interface Service49 { + fun name(): String +} +@Component +class DefaultService49(private val service: Service50) : Service49 { + override fun name() = service.name() +} + +interface Service50 { + fun name(): String +} +@Component +class DefaultService50(private val service: Service51) : Service50 { + override fun name() = service.name() +} + +interface Service51 { + fun name(): String +} +@Component +class DefaultService51(private val service: Service52) : Service51 { + override fun name() = service.name() +} + +interface Service52 { + fun name(): String +} +@Component +class DefaultService52(private val service: Service53) : Service52 { + override fun name() = service.name() +} + +interface Service53 { + fun name(): String +} +@Component +class DefaultService53(private val service: Service54) : Service53 { + override fun name() = service.name() +} + +interface Service54 { + fun name(): String +} +@Component +class DefaultService54(private val service: Service55) : Service54 { + override fun name() = service.name() +} + +interface Service55 { + fun name(): String +} +@Component +class DefaultService55(private val service: Service56) : Service55 { + override fun name() = service.name() +} + +interface Service56 { + fun name(): String +} +@Component +class DefaultService56(private val service: Service57) : Service56 { + override fun name() = service.name() +} + +interface Service57 { + fun name(): String +} +@Component +class DefaultService57(private val service: Service58) : Service57 { + override fun name() = service.name() +} + +interface Service58 { + fun name(): String +} +@Component +class DefaultService58(private val service: Service59) : Service58 { + override fun name() = service.name() +} + +interface Service59 { + fun name(): String +} +@Component +class DefaultService59(private val service: Service60) : Service59 { + override fun name() = service.name() +} + +interface Service60 { + fun name(): String +} +@Component +class DefaultService60(private val service: Service61) : Service60 { + override fun name() = service.name() +} + +interface Service61 { + fun name(): String +} +@Component +class DefaultService61(private val service: Service62) : Service61 { + override fun name() = service.name() +} + +interface Service62 { + fun name(): String +} +@Component +class DefaultService62(private val service: Service63) : Service62 { + override fun name() = service.name() +} + +interface Service63 { + fun name(): String +} +@Component +class DefaultService63(private val service: Service64) : Service63 { + override fun name() = service.name() +} + +interface Service64 { + fun name(): String +} +@Component +class DefaultService64(private val service: Service65) : Service64 { + override fun name() = service.name() +} + +interface Service65 { + fun name(): String +} +@Component +class DefaultService65(private val service: Service66) : Service65 { + override fun name() = service.name() +} + +interface Service66 { + fun name(): String +} +@Component +class DefaultService66(private val service: Service67) : Service66 { + override fun name() = service.name() +} + +interface Service67 { + fun name(): String +} +@Component +class DefaultService67(private val service: Service68) : Service67 { + override fun name() = service.name() +} + +interface Service68 { + fun name(): String +} +@Component +class DefaultService68(private val service: Service69) : Service68 { + override fun name() = service.name() +} + +interface Service69 { + fun name(): String +} +@Component +class DefaultService69(private val service: Service70) : Service69 { + override fun name() = service.name() +} + +interface Service70 { + fun name(): String +} +@Component +class DefaultService70(private val service: Service71) : Service70 { + override fun name() = service.name() +} + +interface Service71 { + fun name(): String +} +@Component +class DefaultService71(private val service: Service72) : Service71 { + override fun name() = service.name() +} + +interface Service72 { + fun name(): String +} +@Component +class DefaultService72(private val service: Service73) : Service72 { + override fun name() = service.name() +} + +interface Service73 { + fun name(): String +} +@Component +class DefaultService73(private val service: Service74) : Service73 { + override fun name() = service.name() +} + +interface Service74 { + fun name(): String +} +@Component +class DefaultService74(private val service: Service75) : Service74 { + override fun name() = service.name() +} + +interface Service75 { + fun name(): String +} +@Component +class DefaultService75(private val service: Service76) : Service75 { + override fun name() = service.name() +} + +interface Service76 { + fun name(): String +} +@Component +class DefaultService76(private val service: Service77) : Service76 { + override fun name() = service.name() +} + +interface Service77 { + fun name(): String +} +@Component +class DefaultService77(private val service: Service78) : Service77 { + override fun name() = service.name() +} + +interface Service78 { + fun name(): String +} +@Component +class DefaultService78(private val service: Service79) : Service78 { + override fun name() = service.name() +} + +interface Service79 { + fun name(): String +} +@Component +class DefaultService79(private val service: Service80) : Service79 { + override fun name() = service.name() +} + +interface Service80 { + fun name(): String +} +@Component +class DefaultService80(private val service: Service81) : Service80 { + override fun name() = service.name() +} + +interface Service81 { + fun name(): String +} +@Component +class DefaultService81(private val service: Service82) : Service81 { + override fun name() = service.name() +} + +interface Service82 { + fun name(): String +} +@Component +class DefaultService82(private val service: Service83) : Service82 { + override fun name() = service.name() +} + +interface Service83 { + fun name(): String +} +@Component +class DefaultService83(private val service: Service84) : Service83 { + override fun name() = service.name() +} + +interface Service84 { + fun name(): String +} +@Component +class DefaultService84(private val service: Service85) : Service84 { + override fun name() = service.name() +} + +interface Service85 { + fun name(): String +} +@Component +class DefaultService85(private val service: Service86) : Service85 { + override fun name() = service.name() +} + +interface Service86 { + fun name(): String +} +@Component +class DefaultService86(private val service: Service87) : Service86 { + override fun name() = service.name() +} + +interface Service87 { + fun name(): String +} +@Component +class DefaultService87(private val service: Service88) : Service87 { + override fun name() = service.name() +} + +interface Service88 { + fun name(): String +} +@Component +class DefaultService88(private val service: Service89) : Service88 { + override fun name() = service.name() +} + +interface Service89 { + fun name(): String +} +@Component +class DefaultService89(private val service: Service90) : Service89 { + override fun name() = service.name() +} + +interface Service90 { + fun name(): String +} +@Component +class DefaultService90(private val service: Service91) : Service90 { + override fun name() = service.name() +} + +interface Service91 { + fun name(): String +} +@Component +class DefaultService91(private val service: Service92) : Service91 { + override fun name() = service.name() +} + +interface Service92 { + fun name(): String +} +@Component +class DefaultService92(private val service: Service93) : Service92 { + override fun name() = service.name() +} + +interface Service93 { + fun name(): String +} +@Component +class DefaultService93(private val service: Service94) : Service93 { + override fun name() = service.name() +} + +interface Service94 { + fun name(): String +} +@Component +class DefaultService94(private val service: Service95) : Service94 { + override fun name() = service.name() +} + +interface Service95 { + fun name(): String +} +@Component +class DefaultService95(private val service: Service96) : Service95 { + override fun name() = service.name() +} + +interface Service96 { + fun name(): String +} +@Component +class DefaultService96(private val service: Service97) : Service96 { + override fun name() = service.name() +} + +interface Service97 { + fun name(): String +} +@Component +class DefaultService97(private val service: Service98) : Service97 { + override fun name() = service.name() +} + +interface Service98 { + fun name(): String +} +@Component +class DefaultService98(private val service: Service99) : Service98 { + override fun name() = service.name() +} + +interface Service99 { + fun name(): String +} +@Component +class DefaultService99(private val service: Service100) : Service99 { + override fun name() = service.name() +} + +interface Service100 { + fun name(): String +} +@Component +class DefaultService100(private val service: Service101) : Service100 { + override fun name() = service.name() +} + +interface Service101 { + fun name(): String +} +@Component +class DefaultService101() : Service101 { + override fun name() = "Hello, World!" +} diff --git a/common-spring-annotations/build.gradle.kts b/common-spring-annotations/build.gradle.kts new file mode 100644 index 0000000..6bd2f5f --- /dev/null +++ b/common-spring-annotations/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + kotlin("jvm").version("1.4.31") +} + +repositories { + mavenCentral() +} + +dependencies { + api(kotlin("stdlib-jdk8")) + implementation("org.springframework:spring-context:5.3.4") +} diff --git a/common-spring-annotations/src/main/java/io/heapy/di/service/Service.kt b/common-spring-annotations/src/main/java/io/heapy/di/service/Service.kt new file mode 100644 index 0000000..41813d6 --- /dev/null +++ b/common-spring-annotations/src/main/java/io/heapy/di/service/Service.kt @@ -0,0 +1,5 @@ +package io.heapy.di.service + +interface Service { + fun doIt(): String +} diff --git a/common-spring-annotations/src/main/java/io/heapy/di/service/ServiceImpl.kt b/common-spring-annotations/src/main/java/io/heapy/di/service/ServiceImpl.kt new file mode 100644 index 0000000..6b503a0 --- /dev/null +++ b/common-spring-annotations/src/main/java/io/heapy/di/service/ServiceImpl.kt @@ -0,0 +1,12 @@ +package io.heapy.di.service + +import org.springframework.stereotype.Component + +@Component +class ServiceImpl( + private val subService: SubService +) : Service { + override fun doIt(): String { + return "ServiceImpl_" + subService.doIt() + } +} diff --git a/common-spring-annotations/src/main/java/io/heapy/di/service/SubService.kt b/common-spring-annotations/src/main/java/io/heapy/di/service/SubService.kt new file mode 100644 index 0000000..251c234 --- /dev/null +++ b/common-spring-annotations/src/main/java/io/heapy/di/service/SubService.kt @@ -0,0 +1,5 @@ +package io.heapy.di.service + +interface SubService { + fun doIt(): String +} diff --git a/common-spring-annotations/src/main/java/io/heapy/di/service/SubServiceImpl.kt b/common-spring-annotations/src/main/java/io/heapy/di/service/SubServiceImpl.kt new file mode 100644 index 0000000..ae78b73 --- /dev/null +++ b/common-spring-annotations/src/main/java/io/heapy/di/service/SubServiceImpl.kt @@ -0,0 +1,10 @@ +package io.heapy.di.service + +import org.springframework.stereotype.Component + +@Component +class SubServiceImpl : SubService { + override fun doIt(): String { + return "SubServiceImpl" + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index d3ad328..48b7572 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,6 +1,9 @@ include("common") include("common-deep") +include("common-spring-annotations") +include("common-spring-annotations-deep") + include("jvm") include("baseline") diff --git a/spring-scan-deep/build.gradle.kts b/spring-scan-deep/build.gradle.kts new file mode 100644 index 0000000..cdad35d --- /dev/null +++ b/spring-scan-deep/build.gradle.kts @@ -0,0 +1,18 @@ +plugins { + java + application +} + +application { + mainClass.set("io.heapy.spring.Main") +} + +repositories { + mavenCentral() +} + +dependencies { + implementation(project(":common-spring-annotations-deep")) + + implementation("org.springframework:spring-context:5.3.4") +} diff --git a/spring-scan-deep/src/main/java/io/heapy/spring/Main.java b/spring-scan-deep/src/main/java/io/heapy/spring/Main.java new file mode 100644 index 0000000..29429cd --- /dev/null +++ b/spring-scan-deep/src/main/java/io/heapy/spring/Main.java @@ -0,0 +1,15 @@ +package io.heapy.spring; + +import io.heapy.sample.common2.*; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.stereotype.Component; + +@Component +@ComponentScan(basePackageClasses = Service.class) +public class Main { + public static void main(String[] args) { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Main.class); + System.out.println(context.getBean(Service.class).name()); + } +} diff --git a/spring-scan/build.gradle.kts b/spring-scan/build.gradle.kts new file mode 100644 index 0000000..ea254fc --- /dev/null +++ b/spring-scan/build.gradle.kts @@ -0,0 +1,18 @@ +plugins { + java + application +} + +application { + mainClass.set("io.heapy.spring.Main") +} + +repositories { + mavenCentral() +} + +dependencies { + implementation(project(":common-spring-annotations")) + + implementation("org.springframework:spring-context:5.3.4") +} diff --git a/spring-scan/src/main/java/io/heapy/spring/Main.java b/spring-scan/src/main/java/io/heapy/spring/Main.java new file mode 100644 index 0000000..85b7bc3 --- /dev/null +++ b/spring-scan/src/main/java/io/heapy/spring/Main.java @@ -0,0 +1,16 @@ +package io.heapy.spring; + +import io.heapy.di.service.Service; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.stereotype.Component; + +@Component +@ComponentScan(basePackageClasses = Service.class) +public class Main { + + public static void main(String[] args) { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Main.class); + System.out.println(context.getBean(Service.class).doIt()); + } +}