├── http4k-mongodb ├── gradle.properties ├── settings.gradle ├── src │ ├── test │ │ └── kotlin │ │ │ └── info │ │ │ └── novatec │ │ │ └── http4k │ │ │ └── FootballmanagerTests.kt │ └── main │ │ └── kotlin │ │ └── info │ │ └── novatec │ │ └── http4k │ │ ├── Footballer.kt │ │ ├── FootballerRepository.kt │ │ └── Main.kt ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── build.gradle ├── gradlew.bat └── gradlew ├── spark-kotlin-mongodb ├── src │ ├── test │ │ └── kotlin │ │ │ └── FootballManagerTests.kt │ └── main │ │ └── kotlin │ │ └── info │ │ └── novatec │ │ └── spark │ │ ├── Footballer.kt │ │ ├── Main.kt │ │ └── FootballerRepository.kt ├── gradle.properties ├── settings.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── build.gradle ├── gradlew.bat └── gradlew ├── javalin-kotlin-mongodb ├── gradle.properties ├── settings.gradle ├── src │ ├── test │ │ └── kotlin │ │ │ └── info.novatec.javalin │ │ │ └── FootballmanagerTest.kt │ └── main │ │ └── kotlin │ │ └── info │ │ └── novatec │ │ └── javalin │ │ ├── Footballer.kt │ │ ├── Main.kt │ │ └── FootballerRepository.kt ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── build.gradle ├── gradlew.bat └── gradlew ├── ktor-mongodb-advanced ├── settings.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── resources │ ├── application.conf │ └── logback.xml ├── src │ └── info │ │ └── novatec │ │ └── ktor │ │ ├── Footballer.kt │ │ ├── Application.kt │ │ ├── FootballerRepository.kt │ │ └── FootballerRouting.kt ├── test │ └── ApplicationTest.kt ├── build.gradle ├── gradlew.bat └── gradlew ├── ktor-mongodb-basic ├── settings.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── resources │ ├── application.conf │ └── logback.xml ├── src │ └── info │ │ └── novatec │ │ └── ktor │ │ ├── Footballer.kt │ │ ├── Application.kt │ │ └── FootballerRepository.kt ├── build.gradle ├── gradlew.bat └── gradlew ├── spring-kofu-webflux-mongodb ├── gradle.properties ├── settings.gradle ├── src │ ├── test │ │ └── kotlin │ │ │ └── info │ │ │ └── novatec │ │ │ └── spring │ │ │ └── fu │ │ │ └── FootballManagerTests.kt │ └── main │ │ └── kotlin │ │ └── info │ │ └── novatec │ │ └── spring │ │ └── fu │ │ ├── Footballer.kt │ │ ├── FootballerRepository.kt │ │ ├── Application.kt │ │ └── FootballerHandler.kt ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── build.gradle ├── gradlew.bat └── gradlew ├── micronaut-kotlin-mongodb ├── gradle.properties ├── micronaut-cli.yml ├── Dockerfile ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.yml │ │ │ └── logback.xml │ │ └── kotlin │ │ │ └── info │ │ │ └── novatec │ │ │ ├── Application.kt │ │ │ ├── Footballer.kt │ │ │ ├── FootballerRestController.kt │ │ │ └── FootballerRepository.kt │ └── test │ │ └── resources │ │ ├── commands.sh │ │ └── get-footballers.sh ├── build.gradle ├── gradlew.bat └── gradlew ├── microframeworks-kotlin-mongodb.png ├── .gitignore └── README.md /http4k-mongodb/gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official -------------------------------------------------------------------------------- /spark-kotlin-mongodb/src/test/kotlin/FootballManagerTests.kt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /javalin-kotlin-mongodb/gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official -------------------------------------------------------------------------------- /spark-kotlin-mongodb/gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official -------------------------------------------------------------------------------- /http4k-mongodb/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'footballmanager' 2 | -------------------------------------------------------------------------------- /ktor-mongodb-advanced/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "footballmanager" 2 | -------------------------------------------------------------------------------- /ktor-mongodb-basic/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "footballmanager" 2 | -------------------------------------------------------------------------------- /spring-kofu-webflux-mongodb/gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official 2 | -------------------------------------------------------------------------------- /spark-kotlin-mongodb/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'footballmanager' 2 | 3 | -------------------------------------------------------------------------------- /javalin-kotlin-mongodb/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'footballmanager' 2 | 3 | -------------------------------------------------------------------------------- /spring-kofu-webflux-mongodb/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'footballmanager' 2 | 3 | -------------------------------------------------------------------------------- /micronaut-kotlin-mongodb/gradle.properties: -------------------------------------------------------------------------------- 1 | kotlinVersion=1.3.72 2 | spekVersion=1.1.5 3 | junitVersion=5.6.2 4 | -------------------------------------------------------------------------------- /ktor-mongodb-basic/gradle.properties: -------------------------------------------------------------------------------- 1 | ktor_version=1.1.3 2 | kotlin.code.style=official 3 | kotlin_version=1.3.21 4 | logback_version=1.2.1 5 | -------------------------------------------------------------------------------- /http4k-mongodb/src/test/kotlin/info/novatec/http4k/FootballmanagerTests.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.http4k 2 | 3 | class FootballmanagerTests { 4 | } -------------------------------------------------------------------------------- /microframeworks-kotlin-mongodb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csh0711/jvm-microframeworks-kotlin-samples/HEAD/microframeworks-kotlin-mongodb.png -------------------------------------------------------------------------------- /micronaut-kotlin-mongodb/micronaut-cli.yml: -------------------------------------------------------------------------------- 1 | profile: service 2 | defaultPackage: info.novatec 3 | --- 4 | testFramework: spek 5 | sourceLanguage: kotlin -------------------------------------------------------------------------------- /javalin-kotlin-mongodb/src/test/kotlin/info.novatec.javalin/FootballmanagerTest.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.javalin 2 | 3 | class FootballmanagerTest { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /spring-kofu-webflux-mongodb/src/test/kotlin/info/novatec/spring/fu/FootballManagerTests.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.spring.fu 2 | 3 | class FootballManagerTests { 4 | } -------------------------------------------------------------------------------- /ktor-mongodb-advanced/gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official 2 | kotlin_version=1.3.61 3 | kmongo_version=3.12.0 4 | ktor_version=1.3.1 5 | logback_version=1.2.3 6 | -------------------------------------------------------------------------------- /http4k-mongodb/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csh0711/jvm-microframeworks-kotlin-samples/HEAD/http4k-mongodb/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /ktor-mongodb-basic/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csh0711/jvm-microframeworks-kotlin-samples/HEAD/ktor-mongodb-basic/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /ktor-mongodb-advanced/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csh0711/jvm-microframeworks-kotlin-samples/HEAD/ktor-mongodb-advanced/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /spark-kotlin-mongodb/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csh0711/jvm-microframeworks-kotlin-samples/HEAD/spark-kotlin-mongodb/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /javalin-kotlin-mongodb/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csh0711/jvm-microframeworks-kotlin-samples/HEAD/javalin-kotlin-mongodb/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /micronaut-kotlin-mongodb/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8u171-alpine3.7 2 | RUN apk --no-cache add curl 3 | COPY build/libs/*-all.jar footballmanager.jar 4 | CMD java ${JAVA_OPTS} -jar footballmanager.jar -------------------------------------------------------------------------------- /micronaut-kotlin-mongodb/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csh0711/jvm-microframeworks-kotlin-samples/HEAD/micronaut-kotlin-mongodb/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /spring-kofu-webflux-mongodb/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/csh0711/jvm-microframeworks-kotlin-samples/HEAD/spring-kofu-webflux-mongodb/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /ktor-mongodb-basic/resources/application.conf: -------------------------------------------------------------------------------- 1 | ktor { 2 | deployment { 3 | port = 8080 4 | port = ${?PORT} 5 | } 6 | application { 7 | modules = [ info.novatec.ktor.ApplicationKt.module ] 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Thumbs.db 2 | .DS_Store 3 | .gradle 4 | build/ 5 | target/ 6 | out/ 7 | .idea 8 | *.iml 9 | *.ipr 10 | *.iws 11 | .project 12 | .settings 13 | .classpath 14 | 15 | ### IntelliJ IDEA ### 16 | .idea 17 | *.iws 18 | *.iml 19 | *.ipr 20 | -------------------------------------------------------------------------------- /ktor-mongodb-advanced/resources/application.conf: -------------------------------------------------------------------------------- 1 | ktor { 2 | deployment { 3 | port = 8080 4 | port = ${?PORT} 5 | } 6 | application { 7 | modules = [ info.novatec.ktor.ApplicationKt.module ] 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ktor-mongodb-advanced/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /ktor-mongodb-basic/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /http4k-mongodb/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Mar 12 20:23:41 CET 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip 7 | -------------------------------------------------------------------------------- /ktor-mongodb-advanced/src/info/novatec/ktor/Footballer.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.ktor 2 | 3 | import org.bson.codecs.pojo.annotations.BsonId 4 | 5 | data class Footballer( 6 | @BsonId var id: String?, 7 | val firstName: String?, 8 | val lastName: String?, 9 | val position: String? 10 | ) -------------------------------------------------------------------------------- /javalin-kotlin-mongodb/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Mar 22 11:34:06 CET 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip 7 | -------------------------------------------------------------------------------- /spark-kotlin-mongodb/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Mar 29 13:31:07 CET 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip 7 | -------------------------------------------------------------------------------- /micronaut-kotlin-mongodb/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Feb 08 13:52:02 CET 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip 7 | -------------------------------------------------------------------------------- /spring-kofu-webflux-mongodb/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Mar 29 16:08:59 CET 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip 7 | -------------------------------------------------------------------------------- /micronaut-kotlin-mongodb/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | --- 2 | micronaut: 3 | application: 4 | name: footballmanager 5 | 6 | --- 7 | mongodb: 8 | uri: "mongodb://${MONGO_HOST:localhost}:${MONGO_PORT:27017}/footballmanager" 9 | cluster: 10 | maxWaitQueueSize: 5 11 | connectionPool: 12 | maxSize: 20 -------------------------------------------------------------------------------- /micronaut-kotlin-mongodb/src/main/kotlin/info/novatec/Application.kt: -------------------------------------------------------------------------------- 1 | package info.novatec 2 | 3 | import io.micronaut.runtime.Micronaut 4 | 5 | object Application { 6 | 7 | @JvmStatic 8 | fun main(args: Array) { 9 | Micronaut.build() 10 | .packages("info.novatec") 11 | .mainClass(Application.javaClass) 12 | .start() 13 | } 14 | } -------------------------------------------------------------------------------- /spring-kofu-webflux-mongodb/src/main/kotlin/info/novatec/spring/fu/Footballer.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.spring.fu 2 | 3 | import org.springframework.data.annotation.Id 4 | import org.springframework.data.mongodb.core.mapping.Document 5 | 6 | @Document 7 | data class Footballer ( 8 | @Id var _id: String?, 9 | val firstName: String?, 10 | val lastName: String?, 11 | val position: String? 12 | ) -------------------------------------------------------------------------------- /micronaut-kotlin-mongodb/src/test/resources/commands.sh: -------------------------------------------------------------------------------- 1 | ## Create Micronaut app 2 | mn create-app info.novatec.footballmanager --features=mongo-reactive --lang=kotlin 3 | 4 | ## CURLs 5 | curl http://localhost:8080/footballers/ | json_pp 6 | 7 | curl -X POST -H "Content-Type: application/json" -d '{"firstName" : "Leon","lastName" : "Goretzka","position" : "Midfield"}' http://localhost:8080/footballers/ 8 | 9 | curl -X DELETE http://localhost:8080/footballers/[id] 10 | -------------------------------------------------------------------------------- /micronaut-kotlin-mongodb/src/test/resources/get-footballers.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | for ((i=1;i<=1000;i++)); do 3 | curl http://localhost:8080/footballers/ | json_pp; 4 | sleep .25 5 | curl http://localhost:8080/footballers/5cc2d46f8735870692375404 | json_pp; 6 | sleep .1 7 | curl http://localhost:8080/footballers/5cc2d4a08735870692375405 | json_pp; 8 | sleep .1 9 | curl http://localhost:8080/footballers/5cc2d4c98735870692375406 | json_pp; 10 | done 11 | -------------------------------------------------------------------------------- /ktor-mongodb-basic/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /ktor-mongodb-advanced/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /micronaut-kotlin-mongodb/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /ktor-mongodb-advanced/src/info/novatec/ktor/Application.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.ktor 2 | 3 | import io.ktor.application.* 4 | import io.ktor.routing.* 5 | import com.fasterxml.jackson.databind.* 6 | import io.ktor.jackson.* 7 | import io.ktor.features.* 8 | 9 | fun main(args: Array): Unit = io.ktor.server.netty.EngineMain.main(args) 10 | 11 | fun Application.module() { 12 | 13 | install(ContentNegotiation) { 14 | jackson { 15 | enable(SerializationFeature.INDENT_OUTPUT) 16 | } 17 | } 18 | 19 | routing { 20 | footballerRoutes() 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ktor-mongodb-basic/src/info/novatec/ktor/Footballer.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.ktor 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore 4 | import org.bson.codecs.pojo.annotations.BsonCreator 5 | import org.bson.codecs.pojo.annotations.BsonId 6 | import org.bson.codecs.pojo.annotations.BsonProperty 7 | import org.bson.types.ObjectId 8 | 9 | data class Footballer @BsonCreator constructor( 10 | @JsonIgnore @BsonId var id: ObjectId?, 11 | @param:BsonProperty("firstName") val firstName: String?, 12 | @param:BsonProperty("lastName") val lastName: String?, 13 | @param:BsonProperty("position") val position: String? 14 | ) { 15 | val _id: String 16 | get() = id.toString() 17 | } -------------------------------------------------------------------------------- /http4k-mongodb/src/main/kotlin/info/novatec/http4k/Footballer.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.http4k 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore 4 | import org.bson.codecs.pojo.annotations.BsonCreator 5 | import org.bson.codecs.pojo.annotations.BsonId 6 | import org.bson.codecs.pojo.annotations.BsonProperty 7 | import org.bson.types.ObjectId 8 | 9 | data class Footballer @BsonCreator constructor( 10 | @JsonIgnore @BsonId var id: ObjectId?, 11 | @param:BsonProperty("firstName") val firstName: String?, 12 | @param:BsonProperty("lastName") val lastName: String?, 13 | @param:BsonProperty("position") val position: String? 14 | ) { 15 | val _id: String 16 | get() = id.toString() 17 | } -------------------------------------------------------------------------------- /spark-kotlin-mongodb/src/main/kotlin/info/novatec/spark/Footballer.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.spark 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore 4 | import org.bson.codecs.pojo.annotations.BsonCreator 5 | import org.bson.codecs.pojo.annotations.BsonId 6 | import org.bson.codecs.pojo.annotations.BsonProperty 7 | import org.bson.types.ObjectId 8 | 9 | data class Footballer @BsonCreator constructor( 10 | @JsonIgnore @BsonId var id: ObjectId?, 11 | @param:BsonProperty("firstName") val firstName: String?, 12 | @param:BsonProperty("lastName") val lastName: String?, 13 | @param:BsonProperty("position") val position: String? 14 | ) { 15 | val _id: String 16 | get() = id.toString() 17 | } -------------------------------------------------------------------------------- /javalin-kotlin-mongodb/src/main/kotlin/info/novatec/javalin/Footballer.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.javalin 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore 4 | import org.bson.codecs.pojo.annotations.BsonCreator 5 | import org.bson.codecs.pojo.annotations.BsonId 6 | import org.bson.codecs.pojo.annotations.BsonProperty 7 | import org.bson.types.ObjectId 8 | 9 | data class Footballer @BsonCreator constructor( 10 | @JsonIgnore @BsonId var id: ObjectId?, 11 | @param:BsonProperty("firstName") val firstName: String?, 12 | @param:BsonProperty("lastName") val lastName: String?, 13 | @param:BsonProperty("position") val position: String? 14 | ) { 15 | val _id: String 16 | get() = id.toString() 17 | } -------------------------------------------------------------------------------- /micronaut-kotlin-mongodb/src/main/kotlin/info/novatec/Footballer.kt: -------------------------------------------------------------------------------- 1 | package info.novatec 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore 4 | import org.bson.codecs.pojo.annotations.BsonCreator 5 | import org.bson.codecs.pojo.annotations.BsonId 6 | import org.bson.codecs.pojo.annotations.BsonProperty 7 | import org.bson.types.ObjectId 8 | 9 | data class Footballer @BsonCreator constructor( 10 | @JsonIgnore @BsonId var id: ObjectId?, 11 | @param:BsonProperty("firstName") val firstName: String?, 12 | @param:BsonProperty("lastName") val lastName: String?, 13 | @param:BsonProperty("position") val position: String? 14 | ) { 15 | val _id: String 16 | get() = id.toString() 17 | } 18 | -------------------------------------------------------------------------------- /ktor-mongodb-advanced/test/ApplicationTest.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.ktor 2 | 3 | import io.ktor.application.* 4 | import io.ktor.response.* 5 | import io.ktor.request.* 6 | import io.ktor.routing.* 7 | import io.ktor.http.* 8 | import io.ktor.locations.* 9 | import com.fasterxml.jackson.databind.* 10 | import io.ktor.jackson.* 11 | import io.ktor.features.* 12 | import kotlin.test.* 13 | import io.ktor.server.testing.* 14 | 15 | class ApplicationTest { 16 | // @Test 17 | // fun testRoot() { 18 | // withTestApplication({ module(testing = true) }) { 19 | // handleRequest(HttpMethod.Get, "/").apply { 20 | // assertEquals(HttpStatusCode.OK, response.status()) 21 | // assertEquals("HELLO WORLD!", response.content) 22 | // } 23 | // } 24 | // } 25 | } 26 | -------------------------------------------------------------------------------- /javalin-kotlin-mongodb/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.jetbrains.kotlin.jvm' version '1.3.61' 3 | } 4 | 5 | group 'info.novatec.javalin' 6 | version '1.0-SNAPSHOT' 7 | 8 | repositories { 9 | mavenCentral() 10 | } 11 | 12 | dependencies { 13 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 14 | compile "io.javalin:javalin:3.7.0" 15 | compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.10.1" 16 | compile "org.slf4j:slf4j-simple:1.7.30" 17 | compile "org.mongodb:mongo-java-driver:3.12.1" 18 | } 19 | 20 | jar { 21 | manifest { 22 | attributes "Main-Class": "info.novatec.javalin.MainKt" 23 | } 24 | 25 | from { 26 | configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } 27 | } 28 | } 29 | 30 | compileKotlin { 31 | kotlinOptions.jvmTarget = "1.8" 32 | } 33 | compileTestKotlin { 34 | kotlinOptions.jvmTarget = "1.8" 35 | } -------------------------------------------------------------------------------- /spark-kotlin-mongodb/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.jetbrains.kotlin.jvm' version '1.3.50' 3 | } 4 | 5 | group 'info.novatec.spark' 6 | version '1.0-SNAPSHOT' 7 | 8 | repositories { 9 | mavenCentral() 10 | } 11 | 12 | dependencies { 13 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 14 | compile "com.sparkjava:spark-core:2.9.1" 15 | compile "org.slf4j:slf4j-simple:1.7.28" 16 | compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.9.9" 17 | compile "org.mongodb:mongo-java-driver:3.11.0" 18 | } 19 | 20 | jar { 21 | manifest { 22 | attributes "Main-Class": "info.novatec.spark.MainKt" 23 | } 24 | 25 | from { 26 | configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } 27 | } 28 | } 29 | 30 | compileKotlin { 31 | kotlinOptions.jvmTarget = "1.8" 32 | } 33 | compileTestKotlin { 34 | kotlinOptions.jvmTarget = "1.8" 35 | } -------------------------------------------------------------------------------- /spring-kofu-webflux-mongodb/src/main/kotlin/info/novatec/spring/fu/FootballerRepository.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.spring.fu 2 | 3 | import org.springframework.data.mongodb.core.ReactiveMongoOperations 4 | import org.springframework.data.mongodb.core.findAll 5 | import org.springframework.data.mongodb.core.findById 6 | import org.springframework.data.mongodb.core.query.Criteria.where 7 | import org.springframework.data.mongodb.core.query.Query.query 8 | import org.springframework.data.mongodb.core.remove 9 | import reactor.core.publisher.Mono 10 | 11 | 12 | class FootballerRepository( 13 | private val mongo: ReactiveMongoOperations 14 | ) { 15 | 16 | fun find() = mongo.findAll() 17 | 18 | fun find(_id: String) = mongo.findById(_id) 19 | 20 | fun insert(footballer: Mono) = mongo.save(footballer) 21 | 22 | fun delete(_id: String) = 23 | mongo.remove(query(where("_id").`is`(_id))).subscribe() 24 | } 25 | -------------------------------------------------------------------------------- /ktor-mongodb-advanced/src/info/novatec/ktor/FootballerRepository.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.ktor 2 | 3 | import org.bson.types.ObjectId 4 | import org.litote.kmongo.coroutine.coroutine 5 | import org.litote.kmongo.eq 6 | import org.litote.kmongo.reactivestreams.KMongo 7 | 8 | 9 | class FootballerRepository { 10 | 11 | private val mongoClient = KMongo.createClient().coroutine 12 | private val database = mongoClient.getDatabase("footballmanager") 13 | private val collection = database.getCollection() 14 | 15 | suspend fun find(): List { 16 | return collection.find().toList() 17 | } 18 | 19 | suspend fun find(_id: String): Footballer? { 20 | return collection.findOne(Footballer::id eq _id) 21 | } 22 | 23 | suspend fun insert(footballer: Footballer): Footballer { 24 | footballer.id = ObjectId().toString() 25 | collection.insertOne(footballer) 26 | return footballer 27 | } 28 | 29 | suspend fun delete(_id: String) { 30 | collection.deleteOne(Footballer::id eq _id) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ktor-mongodb-advanced/src/info/novatec/ktor/FootballerRouting.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.ktor 2 | 3 | import io.ktor.application.call 4 | import io.ktor.http.HttpStatusCode 5 | import io.ktor.request.receive 6 | import io.ktor.response.respond 7 | import io.ktor.routing.* 8 | 9 | private val repository = FootballerRepository() 10 | 11 | fun Route.footballerRoutes() { 12 | route("/footballers") { 13 | get { 14 | call.respond(repository.find()) 15 | } 16 | get("/{_id}") { 17 | repository.find(call.parameters["_id"]!!)?.let { 18 | call.respond(it) 19 | } ?: call.respond(HttpStatusCode.NotFound) 20 | } 21 | post { 22 | val footballer = call.receive() 23 | repository.insert(footballer).let { 24 | call.respond(HttpStatusCode.Created, it) 25 | } 26 | } 27 | delete("/{_id}") { 28 | repository.delete(call.parameters["_id"]!!) 29 | call.respond(HttpStatusCode.NoContent) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /http4k-mongodb/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.jetbrains.kotlin.jvm' version '1.3.61' 3 | } 4 | 5 | group 'info.novatec.http4k' 6 | version '1.0-SNAPSHOT' 7 | 8 | repositories { 9 | mavenCentral() 10 | } 11 | 12 | dependencies { 13 | compile group: "org.http4k", name: "http4k-core", version: "3.224.0" 14 | compile group: "org.http4k", name: "http4k-server-jetty", version: "3.224.0" 15 | compile group: "org.http4k", name: "http4k-format-jackson", version: "3.224.0" 16 | compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.12.1' 17 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 18 | testCompile group: 'junit', name: 'junit', version: '4.12' 19 | } 20 | 21 | jar { 22 | manifest { 23 | attributes "Main-Class": "info.novatec.http4k.MainKt" 24 | } 25 | 26 | doFirst { 27 | from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } 28 | } 29 | exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA' 30 | } 31 | 32 | 33 | compileKotlin { 34 | kotlinOptions.jvmTarget = "1.8" 35 | } 36 | compileTestKotlin { 37 | kotlinOptions.jvmTarget = "1.8" 38 | } -------------------------------------------------------------------------------- /javalin-kotlin-mongodb/src/main/kotlin/info/novatec/javalin/Main.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.javalin 2 | 3 | import io.javalin.Javalin 4 | import io.javalin.apibuilder.ApiBuilder.* 5 | 6 | fun main() { 7 | val app = Javalin.create().start(8080) 8 | 9 | val repository = FootballerRepository() 10 | 11 | app.routes { 12 | path("/footballers") { 13 | 14 | get("/") { ctx -> 15 | ctx.json(repository.find()) 16 | } 17 | 18 | get("/:_id") { ctx -> 19 | val footballer = repository.find(ctx.pathParam("_id")) 20 | footballer?.let { 21 | ctx.json(it) 22 | } ?: ctx.status(404) 23 | } 24 | 25 | post("/") { ctx -> 26 | val footballer = ctx.body() 27 | val insertedFootballer = repository.insert(footballer) 28 | ctx.json(insertedFootballer) 29 | ctx.status(201) 30 | } 31 | 32 | delete("/:_id") { ctx -> 33 | repository.delete(ctx.pathParam("_id")) 34 | ctx.status(204) 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /micronaut-kotlin-mongodb/src/main/kotlin/info/novatec/FootballerRestController.kt: -------------------------------------------------------------------------------- 1 | package info.novatec 2 | 3 | import io.micronaut.http.HttpResponse 4 | import io.micronaut.http.annotation.* 5 | 6 | @Controller("/footballers") 7 | class FootballerRestController( 8 | private val repository: FootballerRepository 9 | ) { 10 | 11 | @Get("/") 12 | fun getAll(): HttpResponse> { 13 | return HttpResponse.ok(repository.find()) 14 | } 15 | 16 | @Get("/{_id}") 17 | fun getOne(_id: String): HttpResponse? { 18 | val footballer = repository.find(_id) 19 | footballer?.let { 20 | return HttpResponse.ok(repository.find(_id)) 21 | } ?: return HttpResponse.notFound() 22 | 23 | } 24 | 25 | @Post("/") 26 | fun postOne(@Body footballer: Footballer): HttpResponse { 27 | val insertedFootballer = repository.insert(footballer) 28 | return HttpResponse.created(insertedFootballer) 29 | } 30 | 31 | @Delete("/{_id}") 32 | fun deleteOne(_id: String): HttpResponse { 33 | repository.delete(_id) 34 | return HttpResponse.noContent() 35 | } 36 | } -------------------------------------------------------------------------------- /spring-kofu-webflux-mongodb/src/main/kotlin/info/novatec/spring/fu/Application.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.spring.fu 2 | 3 | import org.springframework.boot.WebApplicationType 4 | import org.springframework.fu.kofu.application 5 | import org.springframework.fu.kofu.mongo.reactiveMongodb 6 | import org.springframework.fu.kofu.webflux.webFlux 7 | 8 | val app = application(WebApplicationType.REACTIVE) { 9 | 10 | beans { 11 | bean() 12 | bean() 13 | } 14 | 15 | reactiveMongodb { 16 | uri = "mongodb://localhost:27017/footballmanager" 17 | } 18 | 19 | webFlux { 20 | port = 8080 21 | codecs { 22 | string() 23 | jackson() 24 | } 25 | 26 | router { 27 | val footballerHandler = ref() 28 | GET("/footballers", footballerHandler::findAll) 29 | GET("/footballers/{_id}", footballerHandler::findOne) 30 | POST("/footballers", footballerHandler::insert) 31 | DELETE("/footballers/{_id}", footballerHandler::delete) 32 | } 33 | } 34 | } 35 | 36 | fun main() { 37 | app.run() 38 | } 39 | -------------------------------------------------------------------------------- /spring-kofu-webflux-mongodb/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.jetbrains.kotlin.jvm' version '1.3.61' 3 | id "com.github.johnrengelman.shadow" version "4.0.2" 4 | } 5 | 6 | group 'info.novatec.spring-fu' 7 | version '1.0-SNAPSHOT' 8 | 9 | dependencies { 10 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 11 | compile "org.springframework.fu:spring-fu-kofu:0.2.2" 12 | compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.10.1" 13 | compile "org.springframework.boot:spring-boot-starter-webflux:2.2.4.RELEASE" 14 | compile "org.springframework.boot:spring-boot-starter-data-mongodb-reactive:2.2.4.RELEASE" 15 | } 16 | 17 | repositories { 18 | mavenLocal() 19 | mavenCentral() 20 | maven { url 'https://repo.spring.io/milestone' } 21 | maven { url "https://repo.spring.io/snapshot" } 22 | } 23 | 24 | jar { 25 | manifest { 26 | attributes "Main-Class": "info.novatec.spring.fu.ApplicationKt" 27 | } 28 | 29 | from { 30 | configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } 31 | } 32 | } 33 | 34 | compileKotlin { 35 | kotlinOptions.jvmTarget = "1.8" 36 | } 37 | compileTestKotlin { 38 | kotlinOptions.jvmTarget = "1.8" 39 | } -------------------------------------------------------------------------------- /ktor-mongodb-basic/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | 6 | dependencies { 7 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 8 | } 9 | } 10 | 11 | apply plugin: 'kotlin' 12 | apply plugin: 'application' 13 | 14 | group 'info.novatec.ktor' 15 | version '0.0.1' 16 | mainClassName = "io.ktor.server.jetty.EngineMain" 17 | //mainClassName = "io.ktor.server.netty.EngineMain" 18 | 19 | sourceSets { 20 | main.kotlin.srcDirs = main.java.srcDirs = ['src'] 21 | test.kotlin.srcDirs = test.java.srcDirs = ['test'] 22 | main.resources.srcDirs = ['resources'] 23 | test.resources.srcDirs = ['testresources'] 24 | } 25 | 26 | repositories { 27 | mavenLocal() 28 | jcenter() 29 | } 30 | 31 | dependencies { 32 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" 33 | // compile "io.ktor:ktor-server-netty:$ktor_version" 34 | compile "io.ktor:ktor-server-jetty:$ktor_version" 35 | compile "io.ktor:ktor-jackson:$ktor_version" 36 | compile "ch.qos.logback:logback-classic:$logback_version" 37 | compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.10.1' 38 | testCompile "io.ktor:ktor-server-tests:$ktor_version" 39 | } 40 | -------------------------------------------------------------------------------- /spark-kotlin-mongodb/src/main/kotlin/info/novatec/spark/Main.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.spark 2 | 3 | import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper 4 | import spark.Spark.* 5 | 6 | 7 | fun main() { 8 | 9 | val repository = FootballerRepository() 10 | 11 | path("/footballers") { 12 | port(8080) 13 | 14 | after("/*") {_, res -> res.type("application/json")} 15 | 16 | get("/") { _, res -> 17 | res.type("application/json") 18 | jacksonObjectMapper().writeValueAsString(repository.find()) 19 | } 20 | 21 | get("/:_id") { req, res -> 22 | val footballer = repository.find(req.params("_id")) 23 | footballer?.let { 24 | jacksonObjectMapper().writeValueAsString(footballer) 25 | } ?: res.status(404) 26 | } 27 | 28 | post("/") { req, res -> 29 | val footballer = jacksonObjectMapper().readValue(req.body(), Footballer::class.java) 30 | val insertedFootballer = repository.insert(footballer) 31 | jacksonObjectMapper().writeValueAsString(insertedFootballer).also { 32 | res.status(201) 33 | } 34 | } 35 | 36 | delete("/:_id") { req, res -> 37 | repository.delete(req.params("_id")) 38 | res.status(204) 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /ktor-mongodb-advanced/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | 6 | dependencies { 7 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 8 | } 9 | } 10 | 11 | apply plugin: 'kotlin' 12 | apply plugin: 'application' 13 | 14 | group 'info.novatec.ktor' 15 | version '0.0.1' 16 | mainClassName = "io.ktor.server.netty.EngineMain" 17 | 18 | sourceSets { 19 | main.kotlin.srcDirs = main.java.srcDirs = ['src'] 20 | test.kotlin.srcDirs = test.java.srcDirs = ['test'] 21 | main.resources.srcDirs = ['resources'] 22 | test.resources.srcDirs = ['testresources'] 23 | } 24 | 25 | repositories { 26 | mavenLocal() 27 | jcenter() 28 | maven { url 'https://kotlin.bintray.com/ktor' } 29 | } 30 | 31 | dependencies { 32 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" 33 | compile "io.ktor:ktor-server-netty:$ktor_version" 34 | compile "ch.qos.logback:logback-classic:$logback_version" 35 | compile "io.ktor:ktor-server-core:$ktor_version" 36 | compile "io.ktor:ktor-locations:$ktor_version" 37 | compile "io.ktor:ktor-jackson:$ktor_version" 38 | compile "org.litote.kmongo:kmongo-coroutine:$kmongo_version" 39 | // implementation 'org.kodein.di:kodein-di-generic-jvm:6.1.0' 40 | testCompile "io.ktor:ktor-server-tests:$ktor_version" 41 | } 42 | 43 | jar { 44 | manifest { 45 | attributes "Main-Class": "info.novatec.ktor.ApplicationKt" 46 | } 47 | 48 | from { 49 | configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /spring-kofu-webflux-mongodb/src/main/kotlin/info/novatec/spring/fu/FootballerHandler.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.spring.fu 2 | 3 | import org.springframework.http.MediaType 4 | import org.springframework.web.reactive.function.BodyExtractors 5 | import org.springframework.web.reactive.function.server.ServerRequest 6 | import org.springframework.web.reactive.function.server.ServerResponse 7 | import org.springframework.web.reactive.function.server.body 8 | import reactor.core.publisher.Mono 9 | 10 | @Suppress("UNUSED_PARAMETER") 11 | class FootballerHandler( 12 | private val repository: FootballerRepository 13 | ) { 14 | 15 | fun findAll(request: ServerRequest) = ServerResponse 16 | .ok() 17 | .contentType(MediaType.APPLICATION_JSON) 18 | .body(repository.find()) 19 | 20 | fun findOne(request: ServerRequest) = ServerResponse 21 | .ok() 22 | .contentType(MediaType.APPLICATION_JSON) 23 | .body(repository.find(request.pathVariables()["_id"]!!)) 24 | 25 | fun insert(request: ServerRequest): Mono { 26 | val insertedFootballer = repository.insert( 27 | request.body( 28 | BodyExtractors.toMono(Footballer::class.java) 29 | ) 30 | ) 31 | return ServerResponse 32 | .ok() 33 | .contentType(MediaType.APPLICATION_JSON) 34 | .body(insertedFootballer) 35 | } 36 | 37 | fun delete(request: ServerRequest): Mono { 38 | repository.delete(request.pathVariables()["_id"]!!) 39 | return ServerResponse.noContent().build() 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ktor-mongodb-basic/src/info/novatec/ktor/Application.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.ktor 2 | 3 | import io.ktor.application.call 4 | import io.ktor.application.install 5 | import io.ktor.features.ContentNegotiation 6 | import io.ktor.http.HttpStatusCode 7 | import io.ktor.jackson.jackson 8 | import io.ktor.request.receive 9 | import io.ktor.response.respond 10 | import io.ktor.routing.* 11 | import io.ktor.server.engine.embeddedServer 12 | import io.ktor.server.jetty.Jetty 13 | 14 | fun main() { 15 | 16 | val repository = FootballerRepository() 17 | 18 | val server = embeddedServer(Jetty, port = 8080) { 19 | routing { 20 | install(ContentNegotiation) { 21 | jackson { } 22 | } 23 | route("/footballers") { 24 | get { 25 | call.respond(repository.find()) 26 | } 27 | get("/{_id}") { 28 | repository.find(call.parameters["_id"]!!)?.let { 29 | call.respond(it) 30 | } ?: call.respond(HttpStatusCode.NotFound) 31 | } 32 | post { 33 | val footballer = call.receive() 34 | repository.insert(footballer).let { 35 | call.respond(HttpStatusCode.Created, it) 36 | } 37 | } 38 | delete("/{_id}") { 39 | repository.delete(call.parameters["_id"]!!) 40 | call.respond(HttpStatusCode.NoContent) 41 | } 42 | } 43 | } 44 | } 45 | server.start(wait = true) 46 | } 47 | -------------------------------------------------------------------------------- /ktor-mongodb-basic/src/info/novatec/ktor/FootballerRepository.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.ktor 2 | 3 | import com.mongodb.MongoClient 4 | import com.mongodb.MongoClientURI 5 | import com.mongodb.client.MongoCollection 6 | import com.mongodb.client.model.Filters 7 | import com.mongodb.client.model.Filters.eq 8 | import org.bson.codecs.configuration.CodecRegistries.fromProviders 9 | import org.bson.codecs.configuration.CodecRegistries.fromRegistries 10 | import org.bson.codecs.pojo.PojoCodecProvider 11 | import org.bson.types.ObjectId 12 | 13 | 14 | class FootballerRepository { 15 | 16 | private val mongoClient = MongoClient(MongoClientURI("mongodb://localhost:27017")) 17 | 18 | 19 | fun find(): List { 20 | return getCollection().find().toList() 21 | } 22 | 23 | fun find(_id: String): Footballer? { 24 | return getCollection().find(eq("_id", ObjectId(_id))).first() 25 | } 26 | 27 | fun insert(footballer: Footballer): Footballer { 28 | footballer.id = ObjectId() 29 | getCollection().insertOne(footballer) 30 | return footballer 31 | } 32 | 33 | fun delete(_id: String) { 34 | getCollection().deleteOne(Filters.eq("_id", ObjectId(_id))) 35 | } 36 | 37 | private fun getCollection(): MongoCollection { 38 | val codecRegistry = fromRegistries( 39 | MongoClient.getDefaultCodecRegistry(), 40 | fromProviders(PojoCodecProvider.builder().automatic(true).build()) 41 | ) 42 | return mongoClient 43 | .getDatabase("footballmanager") 44 | .withCodecRegistry(codecRegistry) 45 | .getCollection("footballer", Footballer::class.java) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /http4k-mongodb/src/main/kotlin/info/novatec/http4k/FootballerRepository.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.http4k 2 | 3 | import com.mongodb.MongoClient 4 | import com.mongodb.MongoClientURI 5 | import com.mongodb.client.MongoCollection 6 | import com.mongodb.client.model.Filters 7 | import com.mongodb.client.model.Filters.eq 8 | import org.bson.codecs.configuration.CodecRegistries.fromProviders 9 | import org.bson.codecs.configuration.CodecRegistries.fromRegistries 10 | import org.bson.codecs.pojo.PojoCodecProvider 11 | import org.bson.types.ObjectId 12 | 13 | 14 | class FootballerRepository { 15 | 16 | var mongoClient = MongoClient(MongoClientURI("mongodb://localhost:27017")) 17 | 18 | 19 | fun find(): List { 20 | return getCollection().find().toList() 21 | } 22 | 23 | fun find(_id: String): Footballer? { 24 | return getCollection().find(eq("_id", ObjectId(_id))).first() 25 | } 26 | 27 | fun insert(footballer: Footballer): Footballer { 28 | footballer.id = ObjectId() 29 | getCollection().insertOne(footballer) 30 | return footballer 31 | } 32 | 33 | fun delete(_id: String) { 34 | getCollection().deleteOne(Filters.eq("_id", ObjectId(_id))) 35 | } 36 | 37 | private fun getCollection(): MongoCollection { 38 | val codecRegistry = fromRegistries( 39 | MongoClient.getDefaultCodecRegistry(), 40 | fromProviders(PojoCodecProvider.builder().automatic(true).build()) 41 | ) 42 | return mongoClient 43 | .getDatabase("footballmanager") 44 | .withCodecRegistry(codecRegistry) 45 | .getCollection("footballer", Footballer::class.java) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /javalin-kotlin-mongodb/src/main/kotlin/info/novatec/javalin/FootballerRepository.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.javalin 2 | 3 | import com.mongodb.MongoClient 4 | import com.mongodb.MongoClientURI 5 | import com.mongodb.client.MongoCollection 6 | import com.mongodb.client.model.Filters 7 | import com.mongodb.client.model.Filters.eq 8 | import org.bson.codecs.configuration.CodecRegistries.fromProviders 9 | import org.bson.codecs.configuration.CodecRegistries.fromRegistries 10 | import org.bson.codecs.pojo.PojoCodecProvider 11 | import org.bson.types.ObjectId 12 | 13 | class FootballerRepository { 14 | 15 | private val mongoClient = MongoClient(MongoClientURI("mongodb://localhost:27017")) 16 | 17 | 18 | fun find(): List { 19 | return getCollection().find().toList() 20 | } 21 | 22 | fun find(_id: String): Footballer? { 23 | return getCollection().find(eq("_id", ObjectId(_id))).first() 24 | } 25 | 26 | fun insert(footballer: Footballer): Footballer { 27 | footballer.id = ObjectId() 28 | getCollection().insertOne(footballer) 29 | return footballer 30 | } 31 | 32 | fun delete(_id: String) { 33 | getCollection().deleteOne(Filters.eq("_id", ObjectId(_id))) 34 | } 35 | 36 | private fun getCollection(): MongoCollection { 37 | val codecRegistry = fromRegistries( 38 | MongoClient.getDefaultCodecRegistry(), 39 | fromProviders(PojoCodecProvider.builder().automatic(true).build()) 40 | ) 41 | return mongoClient 42 | .getDatabase("footballmanager") 43 | .withCodecRegistry(codecRegistry) 44 | .getCollection("footballer", Footballer::class.java) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /spark-kotlin-mongodb/src/main/kotlin/info/novatec/spark/FootballerRepository.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.spark 2 | 3 | import com.mongodb.MongoClient 4 | import com.mongodb.MongoClientURI 5 | import com.mongodb.client.MongoCollection 6 | import com.mongodb.client.model.Filters 7 | import com.mongodb.client.model.Filters.eq 8 | import org.bson.codecs.configuration.CodecRegistries.fromProviders 9 | import org.bson.codecs.configuration.CodecRegistries.fromRegistries 10 | import org.bson.codecs.pojo.PojoCodecProvider 11 | import org.bson.types.ObjectId 12 | 13 | 14 | class FootballerRepository { 15 | 16 | private val mongoClient = MongoClient(MongoClientURI("mongodb://localhost:27017")) 17 | 18 | 19 | fun find(): List { 20 | return getCollection().find().toList() 21 | } 22 | 23 | fun find(_id: String): Footballer? { 24 | return getCollection().find(eq("_id", ObjectId(_id))).first() 25 | } 26 | 27 | fun insert(footballer: Footballer): Footballer { 28 | footballer.id = ObjectId() 29 | getCollection().insertOne(footballer) 30 | return footballer 31 | } 32 | 33 | fun delete(_id: String) { 34 | getCollection().deleteOne(Filters.eq("_id", ObjectId(_id))) 35 | } 36 | 37 | private fun getCollection(): MongoCollection { 38 | val codecRegistry = fromRegistries( 39 | MongoClient.getDefaultCodecRegistry(), 40 | fromProviders(PojoCodecProvider.builder().automatic(true).build()) 41 | ) 42 | return mongoClient 43 | .getDatabase("footballmanager") 44 | .withCodecRegistry(codecRegistry) 45 | .getCollection("footballer", Footballer::class.java) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /micronaut-kotlin-mongodb/src/main/kotlin/info/novatec/FootballerRepository.kt: -------------------------------------------------------------------------------- 1 | package info.novatec 2 | 3 | import com.mongodb.MongoClientSettings 4 | import com.mongodb.client.MongoClient 5 | import com.mongodb.client.MongoCollection 6 | import com.mongodb.client.model.Filters.eq 7 | import org.bson.UuidRepresentation.JAVA_LEGACY 8 | import org.bson.codecs.UuidCodec 9 | import org.bson.codecs.configuration.CodecRegistries.* 10 | import org.bson.codecs.pojo.PojoCodecProvider 11 | import org.bson.types.ObjectId 12 | import java.util.* 13 | import javax.inject.Singleton 14 | 15 | @Singleton 16 | class FootballerRepository( 17 | private val mongoClient: MongoClient 18 | ) { 19 | 20 | fun find(): List { 21 | return getCollection().find().toList() 22 | } 23 | 24 | fun find(_id: String): Footballer? { 25 | return getCollection().find(eq("_id", ObjectId(_id))).first() 26 | } 27 | 28 | fun insert(footballer: Footballer): Footballer { 29 | footballer.id = ObjectId() 30 | getCollection().insertOne(footballer) 31 | return footballer 32 | } 33 | 34 | fun delete(_id: String) { 35 | getCollection().deleteOne(eq("_id", ObjectId(_id))) 36 | } 37 | 38 | private fun getCollection(): MongoCollection { 39 | val codecRegistry = fromRegistries( 40 | // fromCodecs(UuidCodec(JAVA_LEGACY)), // currently not needed as we use an ObjectId for _id and not an UUID 41 | MongoClientSettings.getDefaultCodecRegistry(), 42 | fromProviders(PojoCodecProvider.builder().automatic(true).build()) 43 | ) 44 | return mongoClient 45 | .getDatabase("footballmanager") 46 | .withCodecRegistry(codecRegistry) 47 | .getCollection("footballer", Footballer::class.java) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /http4k-mongodb/src/main/kotlin/info/novatec/http4k/Main.kt: -------------------------------------------------------------------------------- 1 | package info.novatec.http4k 2 | 3 | import org.http4k.core.Body 4 | import org.http4k.core.Method.DELETE 5 | import org.http4k.core.Method.GET 6 | import org.http4k.core.Method.POST 7 | import org.http4k.core.Request 8 | import org.http4k.core.Response 9 | import org.http4k.core.Status.Companion.CREATED 10 | import org.http4k.core.Status.Companion.NOT_FOUND 11 | import org.http4k.core.Status.Companion.NO_CONTENT 12 | import org.http4k.core.Status.Companion.OK 13 | import org.http4k.core.with 14 | import org.http4k.format.Jackson.auto 15 | import org.http4k.lens.Path 16 | import org.http4k.lens.string 17 | import org.http4k.routing.bind 18 | import org.http4k.routing.routes 19 | import org.http4k.server.Jetty 20 | import org.http4k.server.asServer 21 | 22 | fun main() { 23 | 24 | val repository = FootballerRepository() 25 | 26 | val idFromPath = Path.string().of("_id") 27 | val footballerLens = Body.auto().toLens() 28 | val footballerListLens = Body.auto>().toLens() 29 | 30 | routes( 31 | "footballers" bind GET to { 32 | Response(OK).with(footballerListLens.of(repository.find())) 33 | }, 34 | "footballers/{_id}" bind GET to { request: Request -> 35 | repository.find(idFromPath(request))?.let { 36 | Response(OK).with(footballerLens.of(it)) 37 | } ?: Response(NOT_FOUND) 38 | }, 39 | "footballers" bind POST to { request: Request -> 40 | repository.insert(footballerLens.extract(request)).let { 41 | Response(CREATED).with(footballerLens.of(it)) 42 | } 43 | }, 44 | "footballers/{_id}" bind DELETE to { request: Request -> 45 | repository.delete(idFromPath(request)) 46 | Response(NO_CONTENT) 47 | } 48 | ).asServer(Jetty(8080)).start() 49 | } 50 | -------------------------------------------------------------------------------- /micronaut-kotlin-mongodb/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "io.spring.dependency-management" version "1.0.9.RELEASE" 3 | id "com.github.johnrengelman.shadow" version "4.0.2" 4 | id "application" 5 | id "org.jetbrains.kotlin.jvm" version "1.3.72" 6 | id "org.jetbrains.kotlin.kapt" version "1.3.72" 7 | id "org.jetbrains.kotlin.plugin.allopen" version "1.3.72" 8 | } 9 | 10 | apply plugin:"application" 11 | 12 | version "0.1" 13 | group "info.novatec" 14 | 15 | repositories { 16 | mavenLocal() 17 | mavenCentral() 18 | maven { url "https://jcenter.bintray.com" } 19 | } 20 | 21 | dependencyManagement { 22 | imports { 23 | mavenBom 'io.micronaut:micronaut-bom:2.0.0' 24 | } 25 | } 26 | 27 | dependencies { 28 | compile "io.micronaut:micronaut-http-client" 29 | //compile "org.mongodb:mongo-java-driver:3.12.6" 30 | compile "io.micronaut:micronaut-http-server-netty" 31 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}" 32 | compile "org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}" 33 | compile "io.micronaut:micronaut-runtime" 34 | // implementation "io.micronaut.configuration:micronaut-mongo-reactive" 35 | implementation "io.micronaut.mongodb:micronaut-mongo-sync" 36 | kapt "io.micronaut:micronaut-inject-java" 37 | kapt "io.micronaut:micronaut-validation" 38 | kaptTest "io.micronaut:micronaut-inject-java" 39 | runtime "ch.qos.logback:logback-classic:1.2.3" 40 | runtime "com.fasterxml.jackson.module:jackson-module-kotlin:2.11.1" 41 | testCompile "de.flapdoodle.embed:de.flapdoodle.embed.mongo:2.2.0" 42 | testCompile "org.junit.jupiter:junit-jupiter-api:${junitVersion}" 43 | testCompile "org.jetbrains.spek:spek-api:${spekVersion}" 44 | testRuntime "org.junit.jupiter:junit-jupiter-engine:{junitVersion}" 45 | testRuntime "org.jetbrains.spek:spek-junit-platform-engine:${spekVersion}" 46 | } 47 | 48 | shadowJar { 49 | mergeServiceFiles() 50 | } 51 | 52 | run.jvmArgs('-noverify', '-XX:TieredStopAtLevel=1') 53 | 54 | mainClassName = "info.novatec.Application" 55 | 56 | test { 57 | useJUnitPlatform() 58 | } 59 | 60 | allOpen { 61 | annotation("io.micronaut.aop.Around") 62 | } 63 | 64 | compileKotlin { 65 | kotlinOptions { 66 | jvmTarget = '1.8' 67 | //Will retain parameter names for Java reflection 68 | javaParameters = true 69 | } 70 | } 71 | 72 | compileTestKotlin { 73 | kotlinOptions { 74 | jvmTarget = '1.8' 75 | javaParameters = true 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /http4k-mongodb/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /ktor-mongodb-basic/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /javalin-kotlin-mongodb/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /ktor-mongodb-advanced/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /micronaut-kotlin-mongodb/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /spark-kotlin-mongodb/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /spring-kofu-webflux-mongodb/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Samples of JVM-Microframeworks using MongoDB written in Kotlin 2 | This repo contains several examples of JVM-Microframeworks (e.g. [Micronaut](https://micronaut.io/), 3 | [Javalin](https://javalin.io/), [http4k](https://www.http4k.org/), [Ktor](https://ktor.io/), 4 | [Spring Fu](https://github.com/spring-projects/spring-fu), 5 | [Spark](http://sparkjava.com/), ...) written in [Kotlin](https://kotlinlang.org/) accessing a 6 | [MongoDB](https://www.mongodb.com/). 7 | 8 | ## Scenario 9 | All examples have this scenario in common: 10 | 11 | ![Scenario](microframeworks-kotlin-mongodb.png) 12 | 13 | This means they contain a _Footballmanager_ microservice which accesses a MongoDB and provides the data via REST/JSON. 14 | 15 | ## Setup 16 | The MongoDB should be running on `mongodb://localhost:27017`and have a database `footballmanager`. 17 | Within this database a collection `footballer` should provide documents of this kind: 18 | 19 | ``` 20 | { 21 | "_id" : ObjectId("5cc2d46f8735870692375404"), 22 | "firstName" : "Manuel", 23 | "lastName" : "Neuer", 24 | "position" : "Goalkeeper" 25 | } 26 | { 27 | "_id" : ObjectId("5cc2d4a08735870692375405"), 28 | "firstName" : "Antonio", 29 | "lastName" : "Rüdiger", 30 | "position" : "Defence" 31 | } 32 | { 33 | "_id" : ObjectId("5cc2d4c98735870692375406"), 34 | "firstName" : "Toni", 35 | "lastName" : "Kroos", 36 | "position" : "Midfield" 37 | } 38 | { 39 | "_id" : ObjectId("5cc2d5118735870692375407"), 40 | "firstName" : "Leroy", 41 | "lastName" : "Sane", 42 | "position" : "Striker" 43 | } 44 | ``` 45 | 46 | ## Projects 47 | 48 | #### Micronaut 49 | 50 | * See [micronaut-kotlin-mongodb](https://github.com/csh0711/jvm-microframeworks-kotlin-samples/tree/master/micronaut-kotlin-mongodb) 51 | 52 | #### Javalin 53 | 54 | * See [javalin-kotlin-mongodb](https://github.com/csh0711/jvm-microframeworks-kotlin-samples/tree/master/javalin-kotlin-mongodb) 55 | 56 | #### Spring Fu 57 | 58 | * See [spring-kofu-webflux-mongodb](https://github.com/csh0711/jvm-microframeworks-kotlin-samples/tree/master/spring-kofu-webflux-mongodb) 59 | 60 | #### Ktor (advanced example) 61 | 62 | * See [ktor-mongodb-advanced](https://github.com/csh0711/jvm-microframeworks-kotlin-samples/tree/master/ktor-mongodb-advanced) 63 | 64 | 65 | #### Ktor (basic example) 66 | 67 | * See [ktor-mongodb-basic](https://github.com/csh0711/jvm-microframeworks-kotlin-samples/tree/master/ktor-mongodb-basic) 68 | 69 | #### http4k 70 | 71 | * See [http4k-mongodb](https://github.com/csh0711/jvm-microframeworks-kotlin-samples/tree/master/http4k-mongodb) 72 | 73 | 74 | #### Spark 75 | 76 | * See [spark-kotlin-mongodb](https://github.com/csh0711/jvm-microframeworks-kotlin-samples/tree/master/spark-kotlin-mongodb) 77 | -------------------------------------------------------------------------------- /http4k-mongodb/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /ktor-mongodb-basic/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /spark-kotlin-mongodb/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /javalin-kotlin-mongodb/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /ktor-mongodb-advanced/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /micronaut-kotlin-mongodb/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /spring-kofu-webflux-mongodb/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | --------------------------------------------------------------------------------