├── .gitignore ├── KotlinInJavaProject ├── gradle-multi-module │ ├── .gitignore │ ├── README.md │ ├── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── sample-admin │ │ ├── build.gradle │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── sungjun │ │ │ │ │ └── admin │ │ │ │ │ ├── SampleAdminApplication.java │ │ │ │ │ └── member │ │ │ │ │ └── MemberController.java │ │ │ └── resources │ │ │ │ └── application.yml │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── sungjun │ │ │ └── admin │ │ │ └── SampleAdminApplicationTest.java │ ├── sample-api │ │ ├── build.gradle │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── sungjun │ │ │ │ │ └── api │ │ │ │ │ └── SampleApiApplication.java │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── sungjun │ │ │ │ │ └── api │ │ │ │ │ └── service │ │ │ │ │ └── MemberServiceCustom.kt │ │ │ └── resources │ │ │ │ └── application.yml │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── sungjun │ │ │ └── api │ │ │ └── service │ │ │ └── MemberServiceCustomTest.java │ ├── sample-common │ │ ├── build.gradle │ │ └── src │ │ │ ├── main │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── sungjun │ │ │ │ └── common │ │ │ │ ├── member │ │ │ │ └── Member.java │ │ │ │ └── repository │ │ │ │ └── MemberRepository.java │ │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── sungjun │ │ │ └── common │ │ │ ├── ModuleCommonApplicationTests.java │ │ │ └── member │ │ │ └── MemberRepositoryTest.java │ └── settings.gradle └── maven-modular │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── module1 │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── jitpack │ │ │ │ └── App.java │ │ └── kotlin │ │ │ └── io │ │ │ └── jitpack │ │ │ └── KotlinRulezService.kt │ │ └── test │ │ └── java │ │ └── io │ │ └── jitpack │ │ └── AppTest.java │ ├── module2 │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── jitpack │ │ │ └── App.java │ │ └── test │ │ └── java │ │ └── io │ │ └── jitpack │ │ └── AppTest.java │ └── pom.xml ├── QuarkusVsSpringBoot ├── .gitignore ├── QuarkusSimpleAPI │ ├── .gitignore │ ├── build.gradle.kts │ ├── build.sh │ ├── build_native.sh │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── run.sh │ ├── run_native.sh │ ├── settings.gradle.kts │ └── src │ │ ├── main │ │ ├── docker │ │ │ ├── Dockerfile.multistage │ │ │ └── Dockerfile.native.multistage │ │ ├── kotlin │ │ │ └── pl │ │ │ │ └── codeaddict │ │ │ │ └── quarkussimpleapi │ │ │ │ ├── ApiResource.kt │ │ │ │ ├── ApiResourceService.kt │ │ │ │ └── DataObject.kt │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── kotlin │ │ └── ApiResourceTest.kt ├── README.md ├── SpringSimpleAPI │ ├── .gitignore │ ├── build.gradle.kts │ ├── build.sh │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── run.sh │ ├── settings.gradle.kts │ └── src │ │ ├── main │ │ ├── docker │ │ │ └── Dockerfile.multistage │ │ ├── kotlin │ │ │ └── pl │ │ │ │ └── codeaddict │ │ │ │ └── springsimpleapi │ │ │ │ ├── ApiResource.kt │ │ │ │ ├── ApiResourceService.kt │ │ │ │ ├── DataObject.kt │ │ │ │ └── KotlinSimpleApiApplication.kt │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── kotlin │ │ └── pl │ │ └── codeaddict │ │ └── springsimpleapi │ │ └── KotlinSimpleApiApplicationTests.kt ├── docker-compose.yml ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── jupyterData │ ├── .ipynb_checkpoints │ │ └── quarkus_vs_spring-checkpoint.ipynb │ ├── appMemUsage.csv │ ├── appPackageSizes.csv │ ├── appRamPlot.png │ ├── appSizesPlot.png │ ├── appStartTimes.csv │ ├── quarkus_vs_spring.ipynb │ ├── reportQuarkusJVMGet.csv │ ├── reportQuarkusJVMPost.csv │ ├── reportQuarkusNativeGet.csv │ ├── reportQuarkusNativePost.csv │ ├── reportSpringGet.csv │ ├── reportSpringGetLong.csv │ ├── reportSpringPost.csv │ ├── reportSpringPostLong.csv │ ├── startTimesPlot.png │ ├── summaryLatencyPlot.png │ └── summaryRequestsPlot.png └── test-scripts │ ├── Dockerfile │ ├── perfBuildDocker.sh │ ├── perfGetObjQuarkusJVM.sh │ ├── perfGetObjQuarkusNative.sh │ ├── perfGetObjSpring.sh │ ├── perfGetObjSpringLong.sh │ ├── perfPostObjQuarkusJVM.sh │ ├── perfPostObjQuarkusNative.sh │ ├── perfPostObjSpring.sh │ ├── perfPostObjSpringLong.sh │ ├── report.csv │ └── utils │ ├── getObject.sh │ ├── perfGetObject.sh │ ├── perfGetObjectLong.sh │ ├── perfPostObject.sh │ ├── perfPostObjectLong.sh │ ├── postObject.sh │ ├── wrk-get.lua │ └── wrk-post.lua ├── active-directory ├── .gitignore ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── activedirectory │ │ │ ├── ActiveDirectoryApplication.java │ │ │ ├── DummyUserDetailsService.java │ │ │ ├── HomeController.java │ │ │ └── WebSecurityConfiguration.java │ └── resources │ │ ├── application.properties │ │ └── templates │ │ └── home.html │ └── test │ └── java │ └── com │ └── example │ └── activedirectory │ └── ActiveDirectoryApplicationTests.java ├── camel-example ├── .gitignore ├── README.md ├── build.gradle ├── db-schema │ ├── README.md │ ├── build.gradle │ ├── settings.gradle │ └── src │ │ └── main │ │ └── db │ │ ├── 05-09-19-create-test-data.sql │ │ └── changelogs.xml ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── java │ │ └── pl │ │ │ └── codeaddict │ │ │ └── camelexample │ │ │ ├── CamelExampleApplication.java │ │ │ ├── EventQueue.java │ │ │ └── QueueSelectRoute.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── pl │ └── codeaddict │ └── camelexample │ └── CamelExampleApplicationTests.java ├── flutter-spring-kotlin-web ├── README.md ├── curl-scripts │ ├── get_non_secured_api.sh │ ├── get_secured_api.sh │ ├── get_user_refresh_token.sh │ ├── get_user_token.sh │ └── get_user_token_using_refresh_token.sh ├── docker-compose.yml ├── flutter-gui │ ├── .devcontainer │ │ └── devcontainer.json │ ├── .gitignore │ ├── .metadata │ ├── .vscode │ │ └── launch.json │ ├── Dockerfile │ ├── Dockerfile_dev │ ├── README.md │ ├── android │ │ ├── .gitignore │ │ ├── app │ │ │ ├── build.gradle │ │ │ └── src │ │ │ │ ├── debug │ │ │ │ └── AndroidManifest.xml │ │ │ │ ├── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── kotlin │ │ │ │ │ └── com │ │ │ │ │ │ └── example │ │ │ │ │ │ └── gui │ │ │ │ │ │ └── MainActivity.kt │ │ │ │ └── res │ │ │ │ │ ├── drawable-v21 │ │ │ │ │ └── launch_background.xml │ │ │ │ │ ├── drawable │ │ │ │ │ └── launch_background.xml │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── values-night │ │ │ │ │ └── styles.xml │ │ │ │ │ └── values │ │ │ │ │ └── styles.xml │ │ │ │ └── profile │ │ │ │ └── AndroidManifest.xml │ │ ├── build.gradle │ │ ├── gradle.properties │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ └── gradle-wrapper.properties │ │ └── settings.gradle │ ├── ios │ │ ├── .gitignore │ │ ├── Flutter │ │ │ ├── AppFrameworkInfo.plist │ │ │ ├── Debug.xcconfig │ │ │ └── Release.xcconfig │ │ ├── Runner.xcodeproj │ │ │ ├── project.pbxproj │ │ │ ├── project.xcworkspace │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ └── xcshareddata │ │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ │ └── WorkspaceSettings.xcsettings │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ └── Runner.xcscheme │ │ ├── Runner.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── Runner │ │ │ ├── AppDelegate.swift │ │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ │ └── LaunchImage.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ └── README.md │ │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ │ ├── Info.plist │ │ │ └── Runner-Bridging-Header.h │ ├── lib │ │ ├── constants │ │ │ └── api_path.dart │ │ ├── flutter_api_demo_app.dart │ │ ├── login_page.dart │ │ ├── main.dart │ │ ├── models │ │ │ ├── api_response.dart │ │ │ ├── server_message.dart │ │ │ └── token_model.dart │ │ └── services │ │ │ ├── auth_service.dart │ │ │ ├── rest_api_service.dart │ │ │ └── session_storage_service.dart │ ├── nginx │ │ └── nginx.conf │ ├── pubspec.lock │ ├── pubspec.yaml │ ├── test │ │ └── widget_test.dart │ └── web │ │ ├── favicon.png │ │ ├── icons │ │ ├── Icon-192.png │ │ └── Icon-512.png │ │ ├── index.html │ │ └── manifest.json ├── keycloak-docker │ └── realm-export.json └── kotlin-api │ ├── .gitignore │ ├── README.md │ ├── build.gradle.kts │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle.kts │ └── src │ ├── main │ ├── kotlin │ │ └── pl │ │ │ └── codeaddict │ │ │ └── flutterapi │ │ │ ├── ApiController.kt │ │ │ ├── ApiResponse.kt │ │ │ ├── FlutterApiApplication.kt │ │ │ └── config │ │ │ ├── nonreactive │ │ │ ├── KeycloakJwtAuthenticationConverter.kt │ │ │ ├── KeycloakRealmRoleConverter.kt │ │ │ └── NonReactiveSecurityConfig.kt │ │ │ └── reactive │ │ │ ├── CorsConfiguration.kt │ │ │ ├── KeycloakRealmRoleConverter.kt │ │ │ └── ReactiveSecurityConfig.kt │ └── resources │ │ └── application.yml │ └── test │ └── kotlin │ └── pl │ └── codeaddict │ └── flutterapi │ └── FlutterApiApplicationTests.kt ├── hazelcast-demo ├── .gitignore ├── README.md ├── build.gradle ├── demo-hazelcast-cache │ ├── .gitignore │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── kotlin │ │ │ └── pl │ │ │ │ └── codeaddict │ │ │ │ └── demohazelcast │ │ │ │ └── cache │ │ │ │ ├── DemoHazelcastApplicationCache.kt │ │ │ │ ├── HazelcastConfiguration.kt │ │ │ │ └── ScheduledTasks.kt │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── kotlin │ │ └── pl │ │ └── codeaddict │ │ └── demohazelcast │ │ └── cache │ │ └── DemoHazelcastApplicationCacheTests.kt ├── demo-hazelcast-client │ ├── .gitignore │ ├── build.gradle │ └── src │ │ └── main │ │ ├── kotlin │ │ └── pl │ │ │ └── codeaddict │ │ │ └── demohazelcast │ │ │ └── client │ │ │ ├── DemoHazelcastApplicationClient.kt │ │ │ ├── HazelcastClientController.kt │ │ │ └── HazelcastConfiguration.kt │ │ └── resources │ │ └── application.properties ├── docker │ ├── docker-compose.yml │ └── run.sh ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ├── kafka-demo ├── .gitignore ├── README.md ├── build.gradle ├── docker │ ├── .travis.yml │ ├── broker-list.sh │ └── docker-compose.yml ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ ├── main │ ├── kotlin │ │ └── pl │ │ │ └── codeaddict │ │ │ └── kafkademo │ │ │ ├── KafkaDemoApplication.kt │ │ │ ├── config │ │ │ ├── KafkaConsumerConfig.kt │ │ │ ├── KafkaProducerConfig.kt │ │ │ ├── MongoConfig.kt │ │ │ └── Topics.kt │ │ │ ├── consumers │ │ │ └── KafkaStreamConsumer.kt │ │ │ ├── controllers │ │ │ └── KafkaDemoController.kt │ │ │ ├── domain │ │ │ ├── DhcpData.kt │ │ │ ├── FraudData.kt │ │ │ └── ProxyData.kt │ │ │ ├── producers │ │ │ └── KafkaMessageProducer.kt │ │ │ └── repositories │ │ │ └── FraudDataRepository.kt │ └── resources │ │ └── application.properties │ └── test │ └── kotlin │ └── pl │ └── codeaddict │ └── kafkademo │ └── KafkaDemoApplicationTests.kt ├── minecraft-camera-drawing ├── README.md └── minecraft-drawing.py ├── permission-evaluator-boot2 ├── .gitignore ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── permissionevaluatorboot2 │ │ │ ├── ConfidentialDocument.java │ │ │ ├── ConfidentialDocumentsController.java │ │ │ ├── ConfidentialDocumentsRepository.java │ │ │ ├── CustomPermissionEvaluator.java │ │ │ ├── DummyConfidentialDocumentsRepository.java │ │ │ ├── MethodSecurityConfig.java │ │ │ ├── PermissionEvaluatorBoot2Application.java │ │ │ └── WebSecurityConfig.java │ └── resources │ │ ├── application.properties │ │ └── templates │ │ ├── document.html │ │ └── documents.html │ └── test │ └── java │ └── com │ └── example │ └── permissionevaluatorboot2 │ ├── ConfidentialDocumentsControllerTest.java │ └── PermissionEvaluatorBoot2ApplicationTests.java ├── reporting-services ├── .gitignore ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── reportingservices │ │ │ ├── ReportingServicesApplication.java │ │ │ ├── ReportingServicesClient.java │ │ │ └── ReportingServicesHTTPClientConfiguration.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── example │ └── reportingservices │ ├── ReportingServicesApplicationTests.java │ └── ReportingServicesClientTest.java ├── siddhi-demo ├── .gitignore ├── HELP.md ├── README.md ├── build.gradle.kts ├── docker │ ├── docker-compose.yml │ ├── run.sh │ └── siddhi │ │ └── jobs │ │ └── SIMPLE_ALERT_FILTER.siddhi ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle.kts └── src │ ├── main │ ├── kotlin │ │ └── pl │ │ │ └── codeaddict │ │ │ └── siddhidemoclient │ │ │ ├── MessageQueueController.kt │ │ │ ├── RabbitMQAlarmReceiver.kt │ │ │ ├── RabbitMQConfig.kt │ │ │ ├── RabbitMQSenderService.kt │ │ │ └── SiddhidemoclientApplication.kt │ └── resources │ │ ├── application.yml │ │ └── static │ │ └── message.html │ └── test │ └── kotlin │ └── pl │ └── codeaddict │ └── siddhidemoclient │ └── SiddhidemoclientApplicationTests.kt └── spockapidocks ├── .gitignore ├── README.md ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src ├── docs └── asciidoc │ └── api.adoc ├── main ├── java │ └── pl │ │ └── codeaddict │ │ └── spockapidocs │ │ ├── AddPostRequest.java │ │ ├── AddPostResponse.java │ │ ├── BlogApiController.java │ │ ├── GetPostDetailsResponse.java │ │ ├── LoginRequest.java │ │ ├── ModifyPostRequest.java │ │ └── SpockApidDocsApplication.java └── resources │ └── application.properties └── test └── groovy └── pl └── codeaddict └── spockapidocs └── BlogApiDocumentationSpec.groovy /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/java,intellij+iml 3 | 4 | ### Intellij+iml ### 5 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 6 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 7 | 8 | # User-specific stuff: 9 | .idea/**/workspace.xml 10 | .idea/**/tasks.xml 11 | .idea/dictionaries 12 | 13 | # Sensitive or high-churn files: 14 | .idea/**/dataSources/ 15 | .idea/**/dataSources.ids 16 | .idea/**/dataSources.xml 17 | .idea/**/dataSources.local.xml 18 | .idea/**/sqlDataSources.xml 19 | .idea/**/dynamic.xml 20 | .idea/**/uiDesigner.xml 21 | 22 | # Gradle: 23 | .idea/**/gradle.xml 24 | .idea/**/libraries 25 | 26 | # CMake 27 | cmake-build-debug/ 28 | 29 | # Mongo Explorer plugin: 30 | .idea/**/mongoSettings.xml 31 | 32 | ## File-based project format: 33 | *.iws 34 | 35 | ## Plugin-specific files: 36 | 37 | # IntelliJ 38 | /out/ 39 | 40 | # mpeltonen/sbt-idea plugin 41 | .idea_modules/ 42 | 43 | # JIRA plugin 44 | atlassian-ide-plugin.xml 45 | 46 | # Cursive Clojure plugin 47 | .idea/replstate.xml 48 | 49 | # Ruby plugin and RubyMine 50 | /.rakeTasks 51 | 52 | # Crashlytics plugin (for Android Studio and IntelliJ) 53 | com_crashlytics_export_strings.xml 54 | crashlytics.properties 55 | crashlytics-build.properties 56 | fabric.properties 57 | 58 | ### Intellij+iml Patch ### 59 | # Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 60 | 61 | *.iml 62 | modules.xml 63 | .idea/misc.xml 64 | *.ipr 65 | 66 | ### Java ### 67 | # Compiled class file 68 | *.class 69 | 70 | # Log file 71 | *.log 72 | 73 | # BlueJ files 74 | *.ctxt 75 | 76 | # Mobile Tools for Java (J2ME) 77 | .mtj.tmp/ 78 | 79 | # Package Files # 80 | *.jar 81 | *.war 82 | *.ear 83 | *.zip 84 | *.tar.gz 85 | *.rar 86 | 87 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 88 | hs_err_pid* 89 | 90 | 91 | # End of https://www.gitignore.io/api/java,intellij+iml 92 | .mvn 93 | -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/README.md: -------------------------------------------------------------------------------- 1 | - Links : [Gradle 멀티 프로젝트(모듈) 관리 ](https://okky.kr/article/375833) -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '2.1.3.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | classpath "io.spring.gradle:dependency-management-plugin:1.0.6.RELEASE" 11 | } 12 | } 13 | 14 | plugins { 15 | id "org.jetbrains.kotlin.jvm" version "1.3.72" 16 | } 17 | 18 | allprojects { 19 | group 'com.sungjun' 20 | version '1.0-SNAPSHOT' 21 | } 22 | 23 | subprojects { 24 | apply plugin: 'java' 25 | apply plugin: 'org.springframework.boot' 26 | apply plugin: 'io.spring.dependency-management' 27 | apply plugin: 'kotlin' 28 | 29 | sourceCompatibility = 1.8 30 | 31 | repositories { 32 | mavenCentral() 33 | } 34 | 35 | dependencies { 36 | testCompile group: 'junit', name: 'junit', version: '4.12' 37 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 38 | } 39 | } 40 | 41 | project(':sample-api') { 42 | dependencies { 43 | compile project(':sample-common') 44 | } 45 | } 46 | 47 | project(':sample-admin') { 48 | dependencies { 49 | compile project(':sample-common') 50 | } 51 | } -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/KotlinInJavaProject/gradle-multi-module/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Apr 02 16:19:39 KST 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 | -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/sample-admin/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | compile('org.springframework.boot:spring-boot-starter-web') 3 | testCompile('org.springframework.boot:spring-boot-starter-test') 4 | } -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/sample-admin/src/main/java/com/sungjun/admin/SampleAdminApplication.java: -------------------------------------------------------------------------------- 1 | package com.sungjun.admin; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication(scanBasePackages = "com.sungjun") 7 | public class SampleAdminApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SampleAdminApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/sample-admin/src/main/java/com/sungjun/admin/member/MemberController.java: -------------------------------------------------------------------------------- 1 | package com.sungjun.admin.member; 2 | 3 | import com.sungjun.common.member.Member; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | public class MemberController { 9 | 10 | @GetMapping("/") 11 | public Member get() { 12 | return new Member("sungjun", "sungjun@gmail.com"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/sample-admin/src/main/resources/application.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/KotlinInJavaProject/gradle-multi-module/sample-admin/src/main/resources/application.yml -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/sample-admin/src/test/java/com/sungjun/admin/SampleAdminApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.sungjun.admin; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | import static org.junit.Assert.assertEquals; 9 | 10 | @RunWith(SpringRunner.class) 11 | @SpringBootTest 12 | public class SampleAdminApplicationTest { 13 | 14 | @Test 15 | public void contextLoads() { 16 | assertEquals("1", "1"); 17 | } 18 | } -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/sample-api/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | compile('org.springframework.boot:spring-boot-starter-web') 3 | testCompile('org.springframework.boot:spring-boot-starter-test') 4 | } -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/sample-api/src/main/java/com/sungjun/api/SampleApiApplication.java: -------------------------------------------------------------------------------- 1 | package com.sungjun.api; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.domain.EntityScan; 6 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 7 | 8 | @SpringBootApplication 9 | @EntityScan("com.sungjun.*") 10 | @EnableJpaRepositories("com.sungjun.*") 11 | public class SampleApiApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(SampleApiApplication.class, args); 15 | } 16 | } -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/sample-api/src/main/kotlin/com/sungjun/api/service/MemberServiceCustom.kt: -------------------------------------------------------------------------------- 1 | package com.sungjun.api.service 2 | 3 | import com.sungjun.common.member.Member 4 | import com.sungjun.common.repository.MemberRepository 5 | import org.springframework.stereotype.Service 6 | 7 | @Service 8 | class MemberServiceCustom(private val memberRepository: MemberRepository) { 9 | fun singup(member: Member) = memberRepository.save(member).id 10 | } 11 | -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/sample-api/src/main/resources/application.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/KotlinInJavaProject/gradle-multi-module/sample-api/src/main/resources/application.yml -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/sample-api/src/test/java/com/sungjun/api/service/MemberServiceCustomTest.java: -------------------------------------------------------------------------------- 1 | package com.sungjun.api.service; 2 | 3 | import com.sungjun.common.member.Member; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | 10 | import static org.hamcrest.MatcherAssert.assertThat; 11 | import static org.hamcrest.CoreMatchers.is; 12 | 13 | @RunWith(SpringRunner.class) 14 | @SpringBootTest 15 | public class MemberServiceCustomTest { 16 | 17 | @Autowired 18 | private MemberServiceCustom memberServiceCustom; 19 | 20 | @Test 21 | public void save() { 22 | Member member = new Member("sungjun", "sungjun@gmail.com"); 23 | Long id = memberServiceCustom.singup(member); 24 | assertThat(id, is(1l)); 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/sample-common/build.gradle: -------------------------------------------------------------------------------- 1 | bootJar { 2 | enabled = false 3 | } 4 | jar { 5 | enabled = true 6 | } 7 | dependencies { 8 | compile('org.springframework.boot:spring-boot-starter-data-jpa') 9 | runtime('com.h2database:h2') 10 | testCompile('org.springframework.boot:spring-boot-starter-test') 11 | } -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/sample-common/src/main/java/com/sungjun/common/member/Member.java: -------------------------------------------------------------------------------- 1 | package com.sungjun.common.member; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.Id; 7 | 8 | @Entity 9 | public class Member { 10 | 11 | @Id 12 | @GeneratedValue 13 | private Long id; 14 | 15 | @Column 16 | private String name; 17 | 18 | @Column 19 | private String email; 20 | 21 | public Member(){} 22 | 23 | public Member(String name, String email) { 24 | this.name = name; 25 | this.email = email; 26 | } 27 | 28 | public Long getId() { 29 | return id; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public String getEmail() { 37 | return email; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/sample-common/src/main/java/com/sungjun/common/repository/MemberRepository.java: -------------------------------------------------------------------------------- 1 | package com.sungjun.common.repository; 2 | 3 | import com.sungjun.common.member.Member; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface MemberRepository extends JpaRepository { 7 | } 8 | -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/sample-common/src/test/java/com/sungjun/common/ModuleCommonApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.sungjun.common; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | 5 | @SpringBootApplication 6 | public class ModuleCommonApplicationTests { 7 | public void contextLoads(){} 8 | } 9 | -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/sample-common/src/test/java/com/sungjun/common/member/MemberRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package com.sungjun.common.member; 2 | 3 | import com.sungjun.common.repository.MemberRepository; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; 8 | import org.springframework.test.context.junit4.SpringRunner; 9 | 10 | import static org.hamcrest.MatcherAssert.assertThat; 11 | import static org.hamcrest.Matchers.is; 12 | 13 | @RunWith(SpringRunner.class) 14 | @DataJpaTest 15 | public class MemberRepositoryTest { 16 | 17 | @Autowired 18 | private MemberRepository memberRepository; 19 | 20 | @Test 21 | public void add() { 22 | memberRepository.save(new Member("sungjun", "sungjun@gmail.com")); 23 | Member saved = memberRepository.findById(1l).get(); 24 | assertThat(saved.getName(), is("sungjun")); 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /KotlinInJavaProject/gradle-multi-module/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'sample-multi-module' 2 | include 'sample-api' 3 | include 'sample-admin' 4 | include 'sample-common' -------------------------------------------------------------------------------- /KotlinInJavaProject/maven-modular/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 jitpack 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /KotlinInJavaProject/maven-modular/README.md: -------------------------------------------------------------------------------- 1 | Example Maven multi-module project 2 | === 3 | The project has been copied to show you how to add Kotlin to a multi-modular Java project with maven. 4 | Blog post [http://code-addict.pl/kotlin-in-java-project/](http://code-addict.pl/kotlin-in-java-project/) 5 | The original project is here: [https://github.com/jitpack/maven-modular] (https://github.com/jitpack/maven-modular) 6 | 7 | This project has two maven modules: 8 | - module1 9 | - module2 10 | 11 | With multi-module projects the groupId becomes: com.github.User.Repo 12 | And artifactId remains the same as in the module's pom file. 13 | 14 | Module 1: 15 | ```xml 16 | 17 | com.github.jitpack.maven-modular 18 | module1 19 | 1.1 20 | 21 | ``` 22 | 23 | Module 2: 24 | ```xml 25 | 26 | com.github.jitpack.maven-modular 27 | module2 28 | 1.1 29 | 30 | ``` 31 | 32 | To get both of them together use the usual repository syntax: 33 | 34 | ```xml 35 | 36 | com.github.jitpack 37 | maven-modular 38 | 1.1 39 | 40 | ``` 41 | 42 | -------------------------------------------------------------------------------- /KotlinInJavaProject/maven-modular/module1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | io.jitpack 7 | example-root 8 | 2.0-SNAPSHOT 9 | 10 | io.jitpack 11 | module1 12 | 2.0-SNAPSHOT 13 | module1 14 | http://maven.apache.org 15 | 16 | UTF-8 17 | 18 | 19 | 20 | junit 21 | junit 22 | 3.8.1 23 | test 24 | 25 | 26 | com.google.guava 27 | guava 28 | 18.0 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /KotlinInJavaProject/maven-modular/module1/src/main/java/io/jitpack/App.java: -------------------------------------------------------------------------------- 1 | package io.jitpack; 2 | 3 | /** 4 | * Hello world! 5 | * 6 | */ 7 | public class App 8 | { 9 | public static final String GREETING = "Hello World!"; 10 | 11 | public static void main( String[] args ) 12 | { 13 | KotlinRulezService service = new KotlinRulezService(); 14 | service.talkToMe(GREETING); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /KotlinInJavaProject/maven-modular/module1/src/main/kotlin/io/jitpack/KotlinRulezService.kt: -------------------------------------------------------------------------------- 1 | package io.jitpack 2 | 3 | class KotlinRulezService { 4 | 5 | fun talkToMe(greetingWord: String) { 6 | println("Kotlin Rulez $greetingWord") 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /KotlinInJavaProject/maven-modular/module1/src/test/java/io/jitpack/AppTest.java: -------------------------------------------------------------------------------- 1 | package io.jitpack; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestCase; 5 | import junit.framework.TestSuite; 6 | 7 | /** 8 | * Unit test for simple App. 9 | */ 10 | public class AppTest 11 | extends TestCase 12 | { 13 | /** 14 | * Create the test case 15 | * 16 | * @param testName name of the test case 17 | */ 18 | public AppTest( String testName ) 19 | { 20 | super( testName ); 21 | } 22 | 23 | /** 24 | * @return the suite of tests being tested 25 | */ 26 | public static Test suite() 27 | { 28 | return new TestSuite( AppTest.class ); 29 | } 30 | 31 | /** 32 | * Rigourous Test :-) 33 | */ 34 | public void testApp() 35 | { 36 | assertTrue( true ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /KotlinInJavaProject/maven-modular/module2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | io.jitpack 7 | example-root 8 | 2.0-SNAPSHOT 9 | 10 | 11 | io.jitpack 12 | module2 13 | 2.0-SNAPSHOT 14 | module2 15 | http://maven.apache.org 16 | 17 | 18 | UTF-8 19 | 2.9.6 20 | 21 | 22 | 23 | 24 | io.jitpack 25 | module1 26 | 2.0-SNAPSHOT 27 | 28 | 29 | junit 30 | junit 31 | 3.8.1 32 | test 33 | 34 | 35 | com.fasterxml.jackson.module 36 | jackson-module-kotlin 37 | 2.9.6 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /KotlinInJavaProject/maven-modular/module2/src/main/java/io/jitpack/App.java: -------------------------------------------------------------------------------- 1 | package io.jitpack; 2 | 3 | /** 4 | * Hello world! 5 | * 6 | */ 7 | public class App 8 | { 9 | public static String GREETING = "Hello World!"; 10 | 11 | public static void main( String[] args ) 12 | { 13 | System.out.println( GREETING ); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /KotlinInJavaProject/maven-modular/module2/src/test/java/io/jitpack/AppTest.java: -------------------------------------------------------------------------------- 1 | package io.jitpack; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestCase; 5 | import junit.framework.TestSuite; 6 | 7 | /** 8 | * Unit test for simple App. 9 | */ 10 | public class AppTest 11 | extends TestCase 12 | { 13 | /** 14 | * Create the test case 15 | * 16 | * @param testName name of the test case 17 | */ 18 | public AppTest( String testName ) 19 | { 20 | super( testName ); 21 | } 22 | 23 | /** 24 | * @return the suite of tests being tested 25 | */ 26 | public static Test suite() 27 | { 28 | return new TestSuite( AppTest.class ); 29 | } 30 | 31 | /** 32 | * Rigourous Test :-) 33 | */ 34 | public void testApp() 35 | { 36 | assertTrue( true ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/** 6 | !**/src/test/** 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | out/ 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | 31 | ### VS Code ### 32 | .vscode/ 33 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/QuarkusSimpleAPI/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/** 6 | !**/src/test/** 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | out/ 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | 31 | ### VS Code ### 32 | .vscode/ 33 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/QuarkusSimpleAPI/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import io.quarkus.gradle.tasks.QuarkusNative 2 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 3 | 4 | group = "pl.codeaddict" 5 | version = "1.0.0-SNAPSHOT" 6 | 7 | plugins { 8 | java 9 | id("io.quarkus") version "1.3.1.Final" 10 | kotlin("jvm") version "1.3.71" 11 | kotlin("plugin.allopen") version "1.3.71" 12 | } 13 | 14 | repositories { 15 | mavenCentral() 16 | } 17 | 18 | dependencies { 19 | implementation(kotlin("stdlib-jdk8")) 20 | 21 | implementation(enforcedPlatform("io.quarkus:quarkus-bom:1.3.1.Final")) 22 | implementation("io.quarkus:quarkus-kotlin") 23 | implementation("io.quarkus:quarkus-resteasy") 24 | implementation("io.quarkus:quarkus-resteasy-jackson") 25 | implementation("io.quarkus:quarkus-agroal") 26 | implementation("io.quarkus:quarkus-jdbc-h2") 27 | 28 | testImplementation("io.quarkus:quarkus-junit5") 29 | testImplementation("io.rest-assured:rest-assured") 30 | } 31 | 32 | tasks { 33 | named("buildNative") { 34 | isEnableHttpUrlHandler = true 35 | } 36 | } 37 | 38 | allOpen { 39 | annotation("javax.ws.rs.Path") 40 | annotation("javax.enterprise.context.ApplicationScoped") 41 | annotation("io.quarkus.test.junit.QuarkusTest") 42 | } 43 | 44 | java { 45 | sourceCompatibility = JavaVersion.VERSION_11 46 | targetCompatibility = JavaVersion.VERSION_11 47 | } 48 | 49 | val compileKotlin: KotlinCompile by tasks 50 | compileKotlin.kotlinOptions { 51 | jvmTarget = "11" 52 | } 53 | 54 | val compileTestKotlin: KotlinCompile by tasks 55 | compileTestKotlin.kotlinOptions { 56 | jvmTarget = "11" 57 | } -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/QuarkusSimpleAPI/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker build -f src/main/docker/Dockerfile.multistage -t app-quarkus-jvm . 4 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/QuarkusSimpleAPI/build_native.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker build -f src/main/docker/Dockerfile.native.multistage -t app-quarkus-native . 4 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/QuarkusSimpleAPI/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/QuarkusVsSpringBoot/QuarkusSimpleAPI/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/QuarkusSimpleAPI/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/QuarkusSimpleAPI/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | docker run -i --rm -p 8080:8080 app-quarkus-jvm 3 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/QuarkusSimpleAPI/run_native.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | docker run -i --rm -p 8080:8080 app-quarkus-native 3 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/QuarkusSimpleAPI/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "QuarkusSimpleAPI" 2 | 3 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/QuarkusSimpleAPI/src/main/docker/Dockerfile.multistage: -------------------------------------------------------------------------------- 1 | ## Stage 1 : build with maven builder image (using same imag as for quarkus because it has everything) 2 | FROM quay.io/quarkus/centos-quarkus-maven:19.3.1-java11 AS build 3 | COPY src /usr/src/app/src 4 | COPY gradle /usr/src/app/gradle 5 | COPY gradlew /usr/src/app 6 | COPY build.gradle.kts /usr/src/app 7 | COPY settings.gradle.kts /usr/src/app 8 | #COPY gradle.properties /usr/src/app 9 | USER root 10 | RUN chown -R quarkus /usr/src/app 11 | USER quarkus 12 | WORKDIR /usr/src/app/ 13 | RUN ./gradlew clean build -x test -Dquarkus.package.uber-jar=true 14 | 15 | ## Stage 2 : create the docker final image 16 | FROM openjdk:11.0.6-jre 17 | WORKDIR /work/ 18 | COPY --from=build /usr/src/app/build/*-runner.jar /work/app.jar 19 | RUN chmod 775 /work 20 | EXPOSE 8080 21 | ENTRYPOINT ["java","-jar","app.jar"] -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/QuarkusSimpleAPI/src/main/docker/Dockerfile.native.multistage: -------------------------------------------------------------------------------- 1 | ## Stage 1 : build with maven builder image with native capabilities 2 | FROM quay.io/quarkus/centos-quarkus-maven:19.3.1-java11 AS build 3 | COPY src /usr/src/app/src 4 | COPY gradle /usr/src/app/gradle 5 | COPY gradlew /usr/src/app 6 | COPY build.gradle.kts /usr/src/app 7 | COPY settings.gradle.kts /usr/src/app 8 | #COPY gradle.properties /usr/src/app 9 | USER root 10 | RUN chown -R quarkus /usr/src/app 11 | USER quarkus 12 | WORKDIR /usr/src/app/ 13 | RUN ./gradlew clean build -x test -Dquarkus.package.type=native 14 | 15 | ## Stage 2 : create the docker final image 16 | FROM registry.access.redhat.com/ubi8/ubi-minimal 17 | WORKDIR /work/ 18 | COPY --from=build /usr/src/app/build/*-runner /work/application 19 | RUN chmod 775 /work 20 | EXPOSE 8080 21 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/QuarkusSimpleAPI/src/main/kotlin/pl/codeaddict/quarkussimpleapi/ApiResource.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.quarkussimpleapi 2 | 3 | import javax.ws.rs.* 4 | import javax.ws.rs.core.MediaType 5 | 6 | @Path("/api") 7 | @Produces(MediaType.APPLICATION_JSON) 8 | @Consumes(MediaType.APPLICATION_JSON) 9 | class ApiResource(private val service: ApiResourceService) { 10 | 11 | @GET 12 | @Path("/{data}") 13 | fun apiGet(@PathParam("data") data: String): DataObject { 14 | return service.readDataObject(data) 15 | .orElseThrow { RuntimeException("No data object with data: $data") } 16 | } 17 | 18 | @POST 19 | fun apiPost(dataObject: DataObject): Int { 20 | return service.storeDataObject(dataObject) 21 | } 22 | } -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/QuarkusSimpleAPI/src/main/kotlin/pl/codeaddict/quarkussimpleapi/ApiResourceService.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.quarkussimpleapi 2 | 3 | import io.agroal.api.AgroalDataSource 4 | import java.sql.Connection 5 | import java.sql.ResultSet 6 | import java.util.* 7 | import javax.inject.Singleton 8 | 9 | 10 | @Singleton 11 | open class ApiResourceService(private val dataSource: AgroalDataSource) { 12 | 13 | fun readDataObject(data: String): Optional { 14 | synchronized(this) { 15 | val sql = "SELECT * FROM DATA_OBJECTS WHERE DATA = '$data'" 16 | val connection = getConnection() 17 | val statement = connection.createStatement() 18 | val results: ResultSet = statement.executeQuery(sql) 19 | var dataResult: DataObject? = null 20 | while (results.next()) { 21 | val resultData: String = results.getString("DATA") 22 | dataResult = DataObject(resultData) 23 | break 24 | } 25 | statement.close() 26 | connection.close() 27 | return Optional.ofNullable(dataResult) 28 | } 29 | } 30 | 31 | fun storeDataObject(data: DataObject): Int { 32 | synchronized(this) { 33 | val connection = getConnection() 34 | val statement = connection.createStatement() 35 | statement.execute("DROP TABLE DATA_OBJECTS IF EXISTS") 36 | statement.execute("CREATE TABLE DATA_OBJECTS(" + 37 | "ID INT, DATA VARCHAR(100))") 38 | 39 | val result: Int = 40 | statement.executeUpdate("INSERT INTO DATA_OBJECTS(DATA) VALUES ('${data.data}')") 41 | statement.close() 42 | connection.close() 43 | return result 44 | } 45 | } 46 | 47 | private fun getConnection(): Connection { 48 | println("JDBC Metrics:" + dataSource.metrics) 49 | return dataSource.connection 50 | } 51 | } -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/QuarkusSimpleAPI/src/main/kotlin/pl/codeaddict/quarkussimpleapi/DataObject.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.quarkussimpleapi 2 | 3 | data class DataObject (val data: String = "") -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/QuarkusSimpleAPI/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | quarkus.datasource.db-kind=h2 2 | quarkus.datasource.username=sa 3 | 4 | quarkus.datasource.jdbc.url=jdbc:h2:tcp://localhost:1521/test 5 | quarkus.datasource.jdbc.initial-size=10 6 | quarkus.datasource.jdbc.min-size=10 7 | quarkus.datasource.jdbc.max-size=100 8 | quarkus.datasource.jdbc.enable-metrics=true 9 | quarkus.datasource.metrics.enabled=true -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/QuarkusSimpleAPI/src/test/kotlin/ApiResourceTest.kt: -------------------------------------------------------------------------------- 1 | import io.quarkus.test.junit.QuarkusTest 2 | import io.restassured.RestAssured.given 3 | import io.restassured.http.ContentType 4 | import org.hamcrest.CoreMatchers.equalTo 5 | import org.junit.jupiter.api.Test 6 | 7 | @QuarkusTest 8 | class ApiResourceTest { 9 | private val payload = """{ 10 | "data": "SomeData" 11 | }""" 12 | 13 | @Test 14 | fun testApiEndpoint() { 15 | given() 16 | .`when`() 17 | .contentType(ContentType.JSON) 18 | .body(payload) 19 | .post("/api") 20 | .then() 21 | .statusCode(200) 22 | .body( equalTo("1")) 23 | 24 | given() 25 | .`when`().get("/api/SomeData") 26 | .then() 27 | .statusCode(200) 28 | .body("data", equalTo("SomeData")) 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/SpringSimpleAPI/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/** 6 | !**/src/test/** 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | out/ 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | 31 | ### VS Code ### 32 | .vscode/ 33 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/SpringSimpleAPI/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 2 | 3 | plugins { 4 | id("org.springframework.boot") version "2.2.6.RELEASE" 5 | id("io.spring.dependency-management") version "1.0.9.RELEASE" 6 | kotlin("jvm") version "1.3.71" 7 | kotlin("plugin.spring") version "1.3.71" 8 | } 9 | 10 | group = "pl.codeaddict" 11 | version = "1.0.0-SNAPSHOT" 12 | 13 | repositories { 14 | mavenCentral() 15 | } 16 | 17 | dependencies { 18 | implementation("org.springframework.boot:spring-boot-starter") 19 | implementation("org.springframework.boot:spring-boot-starter-web") 20 | implementation("org.springframework.boot:spring-boot-starter-data-jdbc") 21 | runtimeOnly("com.h2database:h2:1.4.200") 22 | 23 | implementation("org.jetbrains.kotlin:kotlin-reflect") 24 | implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") 25 | 26 | testImplementation("org.springframework.boot:spring-boot-starter-test") { 27 | exclude(group = "org.junit.vintage", module = "junit-vintage-engine") 28 | } 29 | testImplementation("io.rest-assured:rest-assured") 30 | 31 | } 32 | 33 | tasks.withType { 34 | useJUnitPlatform() 35 | } 36 | 37 | java { 38 | sourceCompatibility = JavaVersion.VERSION_11 39 | targetCompatibility = JavaVersion.VERSION_11 40 | } 41 | 42 | val compileKotlin: KotlinCompile by tasks 43 | compileKotlin.kotlinOptions { 44 | jvmTarget = "11" 45 | freeCompilerArgs = listOf("-Xjsr305=strict") 46 | } 47 | 48 | val compileTestKotlin: KotlinCompile by tasks 49 | compileTestKotlin.kotlinOptions { 50 | jvmTarget = "11" 51 | } -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/SpringSimpleAPI/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker build -f src/main/docker/Dockerfile.multistage -t spring_simple_api . -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/SpringSimpleAPI/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/QuarkusVsSpringBoot/SpringSimpleAPI/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/SpringSimpleAPI/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/SpringSimpleAPI/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | docker run -i --rm -p 8080:8080 spring_simple_api 3 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/SpringSimpleAPI/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "SpringSimpleApi" 2 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/SpringSimpleAPI/src/main/docker/Dockerfile.multistage: -------------------------------------------------------------------------------- 1 | ## Stage 1 : build with maven builder image (using same imag as for quarkus because it has everything) 2 | FROM quay.io/quarkus/centos-quarkus-maven:19.3.1-java11 AS build 3 | COPY src /usr/src/app/src 4 | COPY gradle /usr/src/app/gradle 5 | COPY gradlew /usr/src/app 6 | COPY build.gradle.kts /usr/src/app 7 | COPY settings.gradle.kts /usr/src/app 8 | #COPY gradle.properties /usr/src/app 9 | USER root 10 | RUN chown -R quarkus /usr/src/app 11 | USER quarkus 12 | WORKDIR /usr/src/app/ 13 | RUN ./gradlew clean build -x test 14 | 15 | ## Stage 2 : create the docker final image 16 | FROM openjdk:11.0.6-jre 17 | WORKDIR /work/ 18 | COPY --from=build /usr/src/app/build/libs/*.jar /work/app.jar 19 | RUN chmod 775 /work 20 | EXPOSE 8080 21 | ENTRYPOINT ["java","-jar","app.jar"] -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/SpringSimpleAPI/src/main/kotlin/pl/codeaddict/springsimpleapi/ApiResource.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.springsimpleapi 2 | 3 | import org.springframework.http.MediaType 4 | import org.springframework.web.bind.annotation.* 5 | 6 | @RestController 7 | class ApiResource(private val service: ApiResourceService) { 8 | 9 | @GetMapping(path = ["/api/{name}"], produces = [MediaType.APPLICATION_JSON_VALUE]) 10 | fun apiGet(@PathVariable name: String): DataObject { 11 | return service.readDataObject(name) 12 | .orElseThrow { RuntimeException("No data object with name: $name") } 13 | } 14 | 15 | @PostMapping(path = ["/api"], consumes = [MediaType.APPLICATION_JSON_VALUE], produces = [MediaType.APPLICATION_JSON_VALUE]) 16 | fun apiPost(@RequestBody dataObject: DataObject): Int { 17 | return service.storeDataObject(dataObject) 18 | } 19 | } -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/SpringSimpleAPI/src/main/kotlin/pl/codeaddict/springsimpleapi/ApiResourceService.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.springsimpleapi 2 | 3 | import org.springframework.jdbc.core.JdbcTemplate 4 | import org.springframework.stereotype.Service 5 | import java.sql.ResultSet 6 | import java.util.* 7 | 8 | 9 | @Service 10 | open class ApiResourceService(private val jdbcTemplate: JdbcTemplate) { 11 | 12 | fun readDataObject(data: String): Optional { 13 | synchronized(this) { 14 | val sql = "SELECT * FROM DATA_OBJECTS WHERE DATA = ?" 15 | 16 | return Optional.ofNullable(jdbcTemplate.queryForObject(sql, arrayOf(data)) { rs: ResultSet, _: Int -> 17 | DataObject(rs.getString("DATA")) 18 | }) 19 | } 20 | } 21 | 22 | fun storeDataObject(dataObject: DataObject): Int { 23 | synchronized(this) { 24 | jdbcTemplate.execute("DROP TABLE DATA_OBJECTS IF EXISTS") 25 | jdbcTemplate.execute("CREATE TABLE DATA_OBJECTS(" + 26 | "ID INT, DATA VARCHAR(100))") 27 | return jdbcTemplate.update("INSERT INTO DATA_OBJECTS(DATA) VALUES (?)", dataObject.data) 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/SpringSimpleAPI/src/main/kotlin/pl/codeaddict/springsimpleapi/DataObject.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.springsimpleapi 2 | 3 | data class DataObject(val data: String = "") -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/SpringSimpleAPI/src/main/kotlin/pl/codeaddict/springsimpleapi/KotlinSimpleApiApplication.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.springsimpleapi 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication 4 | import org.springframework.boot.runApplication 5 | 6 | @SpringBootApplication 7 | class KotlinSimpleApiApplication 8 | 9 | fun main(args: Array) { 10 | runApplication(*args) 11 | } 12 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/SpringSimpleAPI/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:h2:tcp://localhost:1521/test 2 | spring.datasource.username=sa 3 | spring.datasource.password= 4 | spring.datasource.hikari.minimumIdle=10 5 | spring.datasource.hikari.maximumPoolSize=100 6 | logging.level.com.zaxxer.hikari=TRACE 7 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/SpringSimpleAPI/src/test/kotlin/pl/codeaddict/springsimpleapi/KotlinSimpleApiApplicationTests.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.springsimpleapi 2 | 3 | import io.restassured.RestAssured.given 4 | import io.restassured.http.ContentType 5 | import org.hamcrest.CoreMatchers.equalTo 6 | import org.junit.jupiter.api.Test 7 | import org.springframework.boot.test.context.SpringBootTest 8 | 9 | @SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.DEFINED_PORT) 10 | class KotlinSimpleApiApplicationTests { 11 | private val payload = """{ 12 | "data": "SomeData" 13 | }""" 14 | 15 | @Test 16 | fun testApiEndpoint() { 17 | given() 18 | .`when`() 19 | .contentType(ContentType.JSON) 20 | .body(payload) 21 | .post("/api") 22 | .then() 23 | .statusCode(200) 24 | .body( equalTo("1")) 25 | 26 | given() 27 | .`when`().get("/api/SomeData") 28 | .then() 29 | .statusCode(200) 30 | .body("data", equalTo("SomeData")) 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | h2: 4 | container_name: quarkus-vs-spring-h2 5 | image: oscarfonts/h2 6 | ports: 7 | - "1521:1521" 8 | - "81:81" 9 | environment: 10 | H2_OPTIONS: '-ifNotExists' 11 | networks: 12 | - quarkus-vs-spring-net 13 | app-quarkus-jvm: 14 | container_name: quarkus-vs-spring-app-quarkus-jvm 15 | ports: 16 | - "8081:8080" 17 | environment: 18 | QUARKUS_DATASOURCE_JDBC_URL: 'jdbc:h2:tcp://quarkus-vs-spring-h2:1521/test' 19 | build: 20 | context: ./QuarkusSimpleAPI/ 21 | dockerfile: ./src/main/docker/Dockerfile.multistage 22 | image: quarkus_vs_spring_app_quarkus_jvm 23 | networks: 24 | - quarkus-vs-spring-net 25 | app-quarkus-native: 26 | container_name: quarkus-vs-spring-app-quarkus-native 27 | ports: 28 | - "8082:8080" 29 | environment: 30 | QUARKUS_DATASOURCE_JDBC_URL: 'jdbc:h2:tcp://quarkus-vs-spring-h2:1521/test' 31 | build: 32 | context: ./QuarkusSimpleAPI/ 33 | dockerfile: ./src/main/docker/Dockerfile.native.multistage 34 | image: quarkus_vs_spring_app_quarkus_native 35 | networks: 36 | - quarkus-vs-spring-net 37 | app-spring-boot: 38 | container_name: quarkus-vs-spring-app-spring-jvm 39 | ports: 40 | - "8090:8080" 41 | environment: 42 | SPRING_DATASOURCE_URL: 'jdbc:h2:tcp://quarkus-vs-spring-h2:1521/test' 43 | build: 44 | context: ./SpringSimpleAPI/ 45 | dockerfile: ./src/main/docker/Dockerfile.multistage 46 | image: quarkus_vs_spring_app_spring_jvm 47 | networks: 48 | - quarkus-vs-spring-net 49 | jupyter: 50 | container_name: quarkus-vs-spring-jupyter 51 | image: jupyter/scipy-notebook:latest 52 | volumes: 53 | - ./jupyterData:/home/jovyan/work 54 | ports: 55 | - "8888:8888" 56 | networks: 57 | quarkus-vs-spring-net: 58 | external: true 59 | 60 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/QuarkusVsSpringBoot/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/jupyterData/.ipynb_checkpoints/quarkus_vs_spring-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [], 3 | "metadata": {}, 4 | "nbformat": 4, 5 | "nbformat_minor": 4 6 | } 7 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/jupyterData/appMemUsage.csv: -------------------------------------------------------------------------------- 1 | Framework,Mem_usage_at_rest_mb, Max_mem_usage_max_mb 2 | app-quarkus-jvm,97.34,418.2 3 | app-spring-boot,287.3,601.5 4 | app-quarkus-native,6.488,282.5 5 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/jupyterData/appPackageSizes.csv: -------------------------------------------------------------------------------- 1 | Framework, size_mb 2 | app-quarkus-jvm,23.388866 3 | app-spring-boot,26.882397 4 | app-quarkus-native,47.413896 5 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/jupyterData/appRamPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/QuarkusVsSpringBoot/jupyterData/appRamPlot.png -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/jupyterData/appSizesPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/QuarkusVsSpringBoot/jupyterData/appSizesPlot.png -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/jupyterData/appStartTimes.csv: -------------------------------------------------------------------------------- 1 | Framework,1,2,3,4,5,6,7,8,9,10,11 2 | app-quarkus-jvm,3.665,1.737,1.716,1.715,1.667,1.877,1.811,1.676,1.895,1.793,1.921 3 | app-spring-boot,3.807,2.724,2.856,2.891,2.819,2.760,2.732,2.744,2.758,2.818,2.908 4 | app-quarkus-native,0.892,0.013,0.016,0.014,0.014,0.012,0.012,0.014,0.014,0.012,0.013 5 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/jupyterData/reportQuarkusJVMGet.csv: -------------------------------------------------------------------------------- 1 | latency_min,latency_max,latency_mean,latency_stdev,latency_p50,latency_p90,latency_p95,latency_p99,rps,duration,requests,bytes,errors_connect,errors_read,errors_write,errors_status,errors_imeout 2 | 0.414,343.493,15.571699428939,33215.053476691,8.973,26.61,36.952,223.367,1020.0929054181,10017715,10219,929929,0,0,0,0,0 3 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/jupyterData/reportQuarkusJVMPost.csv: -------------------------------------------------------------------------------- 1 | latency_min,latency_max,latency_mean,latency_stdev,latency_p50,latency_p90,latency_p95,latency_p99,rps,duration,requests,bytes,errors_connect,errors_read,errors_write,errors_status,errors_imeout 2 | 0.947,387.82,22.44548959042,40837.364092471,14.823,34.855,51.807,275.456,643.53207317708,10011933,6443,457453,0,0,0,0,0 3 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/jupyterData/reportQuarkusNativeGet.csv: -------------------------------------------------------------------------------- 1 | latency_min,latency_max,latency_mean,latency_stdev,latency_p50,latency_p90,latency_p95,latency_p99,rps,duration,requests,bytes,errors_connect,errors_read,errors_write,errors_status,errors_imeout 2 | 0.427,26.13,4.639572282439,2154.9421258536,4.063,7.454,8.427,10.876,2177.6350283692,10001676,21780,1981980,0,0,0,0,0 3 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/jupyterData/reportQuarkusNativePost.csv: -------------------------------------------------------------------------------- 1 | latency_min,latency_max,latency_mean,latency_stdev,latency_p50,latency_p90,latency_p95,latency_p99,rps,duration,requests,bytes,errors_connect,errors_read,errors_write,errors_status,errors_imeout 2 | 0.824,45.995,9.0166374955532,2988.0607910739,8.609,12.307,13.668,17.18,1114.7375597136,10011325,11160,792360,0,0,0,0,0 3 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/jupyterData/reportSpringGet.csv: -------------------------------------------------------------------------------- 1 | latency_min,latency_max,latency_mean,latency_stdev,latency_p50,latency_p90,latency_p95,latency_p99,rps,duration,requests,bytes,errors_connect,errors_read,errors_write,errors_status,errors_imeout 2 | 0.303,441.14,11.405436122474,45567.164830198,2.837,10.651,20.349,307.525,3239.6820918867,10003142,32407,4705076,0,0,0,0,0 3 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/jupyterData/reportSpringGetLong.csv: -------------------------------------------------------------------------------- 1 | latency_min,latency_max,latency_mean,latency_stdev,latency_p50,latency_p90,latency_p95,latency_p99,rps,duration,requests,bytes,errors_connect,errors_read,errors_write,errors_status,errors_imeout 2 | 0.199,402.72,1.5487901649731,4859.3839417263,1.396,2.381,2.687,4.725,7136.7032944118,900025647,6423216,932586932,0,0,0,0,0 3 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/jupyterData/reportSpringPost.csv: -------------------------------------------------------------------------------- 1 | latency_min,latency_max,latency_mean,latency_stdev,latency_p50,latency_p90,latency_p95,latency_p99,rps,duration,requests,bytes,errors_connect,errors_read,errors_write,errors_status,errors_imeout 2 | 0.449,429.639,14.413367346939,46060.319729047,5.715,16.142,27.158,310.95,1623.4003159233,10003694,16240,2033223,0,0,0,0,0 3 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/jupyterData/reportSpringPostLong.csv: -------------------------------------------------------------------------------- 1 | latency_min,latency_max,latency_mean,latency_stdev,latency_p50,latency_p90,latency_p95,latency_p99,rps,duration,requests,bytes,errors_connect,errors_read,errors_write,errors_status,errors_imeout 2 | 0.367,438.586,3.7650161458428,5831.5805645743,3.617,6.2,6.868,9.048,2778.5710291017,900086042,2500953,313094340,0,0,0,0,0 3 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/jupyterData/startTimesPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/QuarkusVsSpringBoot/jupyterData/startTimesPlot.png -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/jupyterData/summaryLatencyPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/QuarkusVsSpringBoot/jupyterData/summaryLatencyPlot.png -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/jupyterData/summaryRequestsPlot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/QuarkusVsSpringBoot/jupyterData/summaryRequestsPlot.png -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM williamyeh/wrk 2 | 3 | #COPY utils/* /scripts/ 4 | 5 | 6 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/perfBuildDocker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | docker network create quarkus-vs-spring-net 3 | docker build -t quarkus-vs-spring-wrk . 4 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/perfGetObjQuarkusJVM.sh: -------------------------------------------------------------------------------- 1 | ./utils/perfGetObject.sh quarkus-vs-spring-app-quarkus-jvm:8080 2 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/perfGetObjQuarkusNative.sh: -------------------------------------------------------------------------------- 1 | ./utils/perfGetObject.sh quarkus-vs-spring-app-quarkus-native:8080 2 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/perfGetObjSpring.sh: -------------------------------------------------------------------------------- 1 | ./utils/perfGetObject.sh quarkus-vs-spring-app-spring-jvm:8080 2 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/perfGetObjSpringLong.sh: -------------------------------------------------------------------------------- 1 | ./utils/perfGetObjectLong.sh quarkus-vs-spring-app-spring-jvm:8080 2 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/perfPostObjQuarkusJVM.sh: -------------------------------------------------------------------------------- 1 | ./utils/perfPostObject.sh quarkus-vs-spring-app-quarkus-jvm:8080 2 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/perfPostObjQuarkusNative.sh: -------------------------------------------------------------------------------- 1 | ./utils/perfPostObject.sh quarkus-vs-spring-app-quarkus-native:8080 2 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/perfPostObjSpring.sh: -------------------------------------------------------------------------------- 1 | ./utils/perfPostObject.sh quarkus-vs-spring-app-spring-jvm:8080 2 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/perfPostObjSpringLong.sh: -------------------------------------------------------------------------------- 1 | ./utils/perfPostObjectLong.sh quarkus-vs-spring-app-spring-jvm:8080 2 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/report.csv: -------------------------------------------------------------------------------- 1 | latency_min,latency_max,latency_mean,latency_stdev,latency_p50,latency_p90,latency_p95,latency_p99,rps,duration,requests,bytes,errors_connect,errors_read,errors_write,errors_status,errors_imeout 2 | 0.199,402.72,1.5487901649731,4859.3839417263,1.396,2.381,2.687,4.725,7136.7032944118,900025647,6423216,932586932,0,0,0,0,0 3 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/utils/getObject.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | URL="http://localhost:$1/api/SlimShady" 3 | 4 | if [ $# -eq 0 ] 5 | then 6 | echo "No arguments supplied. Provide PORT number!" 7 | exit 8 | fi 9 | 10 | echo "Using URL: $URL" 11 | 12 | 13 | curl $URL 14 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/utils/perfGetObject.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | URL="http://$1/api/SlimShady" 3 | 4 | if [ $# -eq 0 ] 5 | then 6 | echo "No arguments supplied. Provide URL (container name) with PORT number!" 7 | exit 8 | fi 9 | 10 | echo "Running wrk with 2 threads and 11 connections over period of 10 seconds. Using URL: $URL" 11 | echo "If you can't connect remember to use docker containers internal port numbers for example quarkus-vs-spring-app-quarkus-native:8080" 12 | 13 | docker run --rm -v `pwd`:/scripts -w /scripts --net quarkus-vs-spring-net quarkus-vs-spring-wrk:latest -t2 -c10 -d10s -s ./utils/wrk-get.lua $URL 14 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/utils/perfGetObjectLong.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | URL="http://$1/api/SlimShady" 3 | 4 | if [ $# -eq 0 ] 5 | then 6 | echo "No arguments supplied. Provide URL (container name) with PORT number!" 7 | exit 8 | fi 9 | 10 | echo "Running wrk with 2 threads and 11 connections over period of 10 seconds. Using URL: $URL" 11 | echo "If you can't connect remember to use docker containers internal port numbers for example quarkus-vs-spring-app-quarkus-native:8080" 12 | 13 | docker run --rm -v `pwd`:/scripts -w /scripts --net quarkus-vs-spring-net quarkus-vs-spring-wrk:latest -t2 -c10 -d15m -s ./utils/wrk-get.lua $URL 14 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/utils/perfPostObject.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | URL="http://$1/api/" 3 | 4 | if [ $# -eq 0 ] 5 | then 6 | echo "No arguments supplied. Provide URL (container name) with PORT number!" 7 | exit 8 | fi 9 | 10 | echo "Running wrk with 2 threads and 11 connections over period of 10 seconds. Using URL: $URL" 11 | echo "If you can't connect remember to use docker containers internal port numbers for example quarkus-vs-spring-app-quarkus-native:8080" 12 | 13 | docker run --rm -v `pwd`:/scripts -w /scripts --net quarkus-vs-spring-net quarkus-vs-spring-wrk:latest -t2 -c10 -d10s -s ./utils/wrk-post.lua $URL 14 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/utils/perfPostObjectLong.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | URL="http://$1/api/" 3 | 4 | if [ $# -eq 0 ] 5 | then 6 | echo "No arguments supplied. Provide URL (container name) with PORT number!" 7 | exit 8 | fi 9 | 10 | echo "Running wrk with 2 threads and 11 connections over period of 10 seconds. Using URL: $URL" 11 | echo "If you can't connect remember to use docker containers internal port numbers for example quarkus-vs-spring-app-quarkus-native:8080" 12 | 13 | docker run --rm -v `pwd`:/scripts -w /scripts --net quarkus-vs-spring-net quarkus-vs-spring-wrk:latest -t2 -c10 -d15m -s ./utils/wrk-post.lua $URL 14 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/utils/postObject.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | URL="http://localhost:$1/api" 4 | 5 | if [ $# -eq 0 ] 6 | then 7 | echo "No arguments supplied. Provide PORT number!" 8 | exit 9 | fi 10 | 11 | echo "Using URL: $URL" 12 | curl --header "Content-Type: application/json" \ 13 | --request POST \ 14 | --data '{"data":"SlimShady"}' \ 15 | $URL 16 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/utils/wrk-get.lua: -------------------------------------------------------------------------------- 1 | -- wrk report to output CSV 2 | 3 | local report = os.getenv('WRK_REPORT') or 'report.csv' 4 | local output = assert(io.open(report, 'w+')) 5 | 6 | local labels = { 7 | 'latency_min', 'latency_max','latency_mean', 'latency_stdev', 8 | 'latency_p50', 'latency_p90', 'latency_p95', 'latency_p99', 9 | 'rps', 'duration', 'requests', 'bytes', 10 | 'errors_connect', 11 | 'errors_read', 12 | 'errors_write', 13 | 'errors_status', 14 | 'errors_imeout' 15 | } 16 | 17 | done = function(summary, latency) 18 | local errors = summary.errors 19 | output:write(table.concat(labels, ',')) 20 | output:write('\n') 21 | output:write(table.concat({ 22 | latency.min/1000, latency.max/1000, latency.mean/1000, latency.stdev, 23 | latency:percentile(50)/1000, latency:percentile(90)/1000, latency:percentile(95)/1000, latency:percentile(99)/1000, 24 | summary.requests/summary.duration*1000*1000, summary.duration, summary.requests, summary.bytes, 25 | errors.connect, errors.read, errors.write, errors.status, errors.timeout, 26 | },',')) 27 | output:write('\n') 28 | end 29 | -------------------------------------------------------------------------------- /QuarkusVsSpringBoot/test-scripts/utils/wrk-post.lua: -------------------------------------------------------------------------------- 1 | wrk.method = "POST" 2 | wrk.body = '{"data":"SlimShady"}' 3 | wrk.headers["Content-Type"] = "application/json" 4 | 5 | -- wrk report to output CSV 6 | 7 | local report = os.getenv('WRK_REPORT') or 'report.csv' 8 | local output = assert(io.open(report, 'w+')) 9 | 10 | local labels = { 11 | 'latency_min', 'latency_max','latency_mean', 'latency_stdev', 12 | 'latency_p50', 'latency_p90', 'latency_p95', 'latency_p99', 13 | 'rps', 'duration', 'requests', 'bytes', 14 | 'errors_connect', 15 | 'errors_read', 16 | 'errors_write', 17 | 'errors_status', 18 | 'errors_imeout' 19 | } 20 | 21 | done = function(summary, latency) 22 | local errors = summary.errors 23 | output:write(table.concat(labels, ',')) 24 | output:write('\n') 25 | output:write(table.concat({ 26 | latency.min/1000, latency.max/1000, latency.mean/1000, latency.stdev, 27 | latency:percentile(50)/1000, latency:percentile(90)/1000, latency:percentile(95)/1000, latency:percentile(99)/1000, 28 | summary.requests/summary.duration*1000*1000, summary.duration, summary.requests, summary.bytes, 29 | errors.connect, errors.read, errors.write, errors.status, errors.timeout, 30 | },',')) 31 | output:write('\n') 32 | end 33 | 34 | -------------------------------------------------------------------------------- /active-directory/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /active-directory/README.md: -------------------------------------------------------------------------------- 1 | # Spring Boot 2 - Kerberos Authentication Configuration Demo 2 | 3 | Aim of the project is to show how to create Kerberos authentication in Spring Boot project. Whole idea is described in my blog post [Code-Addict](http://code-addict.pl/spring-security-kerberos/) 4 | 5 | ## Functionalities: 6 | 7 | - Authenticate to simple web page using kerberos. 8 | 9 | ## Dependencies 10 | Project is very simple and uses following dependencies: 11 | - Spring Boot 2 12 | - Thymeleaf 3 13 | - Spring Security + Spring Security Kerberos 14 | - Lombok 1.16.20 15 | 16 | ## Running 17 | 18 | You can run application using maven `mvn spring-boot:run`. Please see blog post for details 19 | 20 | ## Testing 21 | Test it manually according to description provided in blog post. 22 | 23 | ## Licence 24 | 25 | Project uses a MIT licence . 26 | 27 | MIT License 28 | 29 | Copyright (c) 2018 Michal Kostewicz 30 | 31 | Permission is hereby granted, free of charge, to any person obtaining a copy 32 | of this software and associated documentation files (the "Software"), to deal 33 | in the Software without restriction, including without limitation the rights 34 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 35 | copies of the Software, and to permit persons to whom the Software is 36 | furnished to do so, subject to the following conditions: 37 | 38 | The above copyright notice and this permission notice shall be included in all 39 | copies or substantial portions of the Software. 40 | 41 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 42 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 43 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 44 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 45 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 46 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 47 | SOFTWARE. 48 | -------------------------------------------------------------------------------- /active-directory/src/main/java/com/example/activedirectory/ActiveDirectoryApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.activedirectory; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ActiveDirectoryApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ActiveDirectoryApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /active-directory/src/main/java/com/example/activedirectory/DummyUserDetailsService.java: -------------------------------------------------------------------------------- 1 | package com.example.activedirectory; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.security.core.authority.AuthorityUtils; 5 | import org.springframework.security.core.userdetails.User; 6 | import org.springframework.security.core.userdetails.UserDetails; 7 | import org.springframework.security.core.userdetails.UserDetailsService; 8 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 9 | 10 | @Slf4j //Lombok annotation for logging 11 | public class DummyUserDetailsService implements UserDetailsService { 12 | 13 | @Override 14 | public UserDetails loadUserByUsername(String username) 15 | throws UsernameNotFoundException { 16 | log.info(username); 17 | return new User(username, "notUsed", true, true, true, true, 18 | AuthorityUtils.createAuthorityList("ROLE_USER", "ROLE_ADMIN")); 19 | } 20 | } -------------------------------------------------------------------------------- /active-directory/src/main/java/com/example/activedirectory/HomeController.java: -------------------------------------------------------------------------------- 1 | package com.example.activedirectory; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.servlet.ModelAndView; 7 | 8 | @Controller 9 | @RequestMapping("/") 10 | public class HomeController { 11 | 12 | @GetMapping 13 | public ModelAndView home(ModelAndView modelAndView) { 14 | modelAndView.setViewName("home"); 15 | return modelAndView; 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /active-directory/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | security.basic.enabled=false 2 | security.keytab.file=/opt/tomcat.keytab 3 | security.service.principal=HTTP/applicationhost@YOURDOMAIN.COM 4 | server.port = 8080 5 | -------------------------------------------------------------------------------- /active-directory/src/main/resources/templates/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | Content 12 |
13 | 14 |
This is footer
15 | 16 | -------------------------------------------------------------------------------- /active-directory/src/test/java/com/example/activedirectory/ActiveDirectoryApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.activedirectory; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ActiveDirectoryApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /camel-example/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/** 6 | !**/src/test/** 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | out/ 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | 31 | ### VS Code ### 32 | .vscode/ 33 | -------------------------------------------------------------------------------- /camel-example/README.md: -------------------------------------------------------------------------------- 1 | # Apache Camel with Spring Boot 2.1 Demo app 2 | 3 | Aim of the project is to show how to use Apache Camel with SQL component in Spring Boot 2 application. Whole idea is described in my blog 4 | post [Code-Addict](http://code-addict.pl/spring-boot-2-camel/) 5 | 6 | ## Functionalities: 7 | The application launches the camel route which in a given time interval downloads data from the database. 8 | 9 | ## Dependencies 10 | Project is very simple and uses following dependencies: 11 | - Spring Boot 2.1.1 12 | - Apache Camel 2.24.1 13 | - Apache Camel SQL Component 14 | - Spring Boot JDBC 15 | - MS SQL 16 | 17 | ## Running 18 | You can first run ms sql docker container and liquibase scripts, please check README.md in db-schema folder. 19 | 20 | To run application use gradle: 21 | ``` 22 | ./gradlew bootRun 23 | ``` 24 | 25 | ## Licence 26 | 27 | Project uses a MIT licence . 28 | 29 | MIT License 30 | 31 | Copyright (c) 2019 Michal Kostewicz 32 | 33 | Permission is hereby granted, free of charge, to any person obtaining a copy 34 | of this software and associated documentation files (the "Software"), to deal 35 | in the Software without restriction, including without limitation the rights 36 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 37 | copies of the Software, and to permit persons to whom the Software is 38 | furnished to do so, subject to the following conditions: 39 | 40 | The above copyright notice and this permission notice shall be included in all 41 | copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 44 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 45 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 46 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 47 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 48 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 49 | SOFTWARE. 50 | -------------------------------------------------------------------------------- /camel-example/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.1.7.RELEASE' 3 | id 'io.spring.dependency-management' version '1.0.8.RELEASE' 4 | id 'java' 5 | } 6 | 7 | group = 'pl.codeaddict' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '1.8' 10 | 11 | repositories { 12 | mavenCentral() 13 | } 14 | 15 | dependencies { 16 | implementation 'org.springframework.boot:spring-boot-starter-jdbc' 17 | implementation 'org.apache.camel:camel-spring-boot-starter:2.24.0' 18 | runtimeOnly 'com.microsoft.sqlserver:mssql-jdbc' 19 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 20 | implementation 'org.apache.camel:camel-jdbc-starter:2.24.0' 21 | implementation 'org.apache.camel:camel-sql-starter:2.24.0' 22 | compileOnly 'org.projectlombok:lombok:1.18.8' 23 | annotationProcessor 'org.projectlombok:lombok:1.18.8' 24 | } 25 | -------------------------------------------------------------------------------- /camel-example/db-schema/README.md: -------------------------------------------------------------------------------- 1 | #Docker with MS SQL DB 2 | Launching docker container with ms sql database: 3 | ``` 4 | docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=QWE45rty' --name camel_example_db -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-CU8-ubuntu 5 | 6 | ``` 7 | #Running Liquibase scripts 8 | ``` 9 | ./gradlew -p db-schema update 10 | ``` 11 | We need to run this from the main catalog of the project . -------------------------------------------------------------------------------- /camel-example/db-schema/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | dependencies { 6 | classpath "org.liquibase:liquibase-gradle-plugin:1.1.1" 7 | classpath "com.microsoft.sqlserver:mssql-jdbc:6.2.1.jre8" 8 | } 9 | } 10 | apply plugin: 'java' 11 | apply plugin: 'org.liquibase.gradle' 12 | 13 | 14 | sourceCompatibility = 1.8 15 | targetCompatibility = 1.8 16 | version = '1.0' 17 | 18 | repositories { 19 | mavenCentral() 20 | } 21 | 22 | dependencies { 23 | testCompile group: 'junit', name: 'junit', version: '4.11' 24 | } 25 | 26 | liquibase { 27 | activities { 28 | main { 29 | changeLogFile 'db-schema/src/main/db/changelogs.xml' 30 | url 'jdbc:sqlserver://localhost:1433;databaseName=master' 31 | username 'sa' 32 | password 'QWE45rty' 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /camel-example/db-schema/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'liquibase-mssql' 2 | 3 | -------------------------------------------------------------------------------- /camel-example/db-schema/src/main/db/05-09-19-create-test-data.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE master.dbo.event_queue ( 2 | id bigint IDENTITY(1,1) NOT NULL, 3 | data varchar(50) NOT NULL, 4 | CONSTRAINT PK__event_queue PRIMARY KEY (id) 5 | ) 6 | 7 | INSERT INTO master.dbo.event_queue 8 | (data) 9 | VALUES('123456'); 10 | INSERT INTO master.dbo.event_queue 11 | (data) 12 | VALUES('654321'); 13 | INSERT INTO master.dbo.event_queue 14 | (data) 15 | VALUES('789065'); 16 | INSERT INTO master.dbo.event_queue 17 | (data) 18 | VALUES('098761'); 19 | -------------------------------------------------------------------------------- /camel-example/db-schema/src/main/db/changelogs.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /camel-example/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/camel-example/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /camel-example/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Aug 30 12:21:44 CEST 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-5.6-all.zip 7 | -------------------------------------------------------------------------------- /camel-example/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'camel-example' 2 | -------------------------------------------------------------------------------- /camel-example/src/main/java/pl/codeaddict/camelexample/CamelExampleApplication.java: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.camelexample; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | 8 | 9 | @SpringBootApplication 10 | public class CamelExampleApplication { 11 | private static final Logger log = LoggerFactory.getLogger(CamelExampleApplication.class); 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(CamelExampleApplication.class, args); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /camel-example/src/main/java/pl/codeaddict/camelexample/EventQueue.java: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.camelexample; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Created by Michal Kostewicz on 30.08.19. 7 | */ 8 | @Data 9 | public class EventQueue { 10 | private Long id; 11 | private String data; 12 | 13 | @Override 14 | public String toString() { 15 | return String.format( 16 | "EventQueue[id=%d, data=%d]", 17 | id, data); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /camel-example/src/main/java/pl/codeaddict/camelexample/QueueSelectRoute.java: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.camelexample; 2 | 3 | import org.apache.camel.LoggingLevel; 4 | import org.apache.camel.builder.RouteBuilder; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | import java.util.stream.Collectors; 10 | 11 | /** 12 | * Created by Michal Kostewicz on 30.08.19. 13 | */ 14 | 15 | @Component 16 | public class QueueSelectRoute extends RouteBuilder { 17 | 18 | @Override 19 | public void configure() throws Exception { 20 | from("timer://dbQueryTimer?period=10s") 21 | .routeId("DATABASE_QUERY_TIMER_ROUTE") 22 | .to("sql:SELECT * FROM event_queue?dataSource=#dataSource") 23 | .process(xchg -> { 24 | List> row = xchg.getIn().getBody(List.class); 25 | row.stream() 26 | .map((x) -> { 27 | EventQueue eventQueue = new EventQueue(); 28 | eventQueue.setId((Long) x.get("id")); 29 | eventQueue.setData((String) x.get("data")); 30 | return eventQueue; 31 | }).collect(Collectors.toList()); 32 | }) 33 | .log(LoggingLevel.INFO, "******Database query executed - body:${body}******"); 34 | } 35 | } -------------------------------------------------------------------------------- /camel-example/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:sqlserver://localhost;databaseName=master 2 | spring.datasource.username=sa 3 | spring.datasource.password=QWE45rty 4 | spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver 5 | spring.jpa.show-sql=true 6 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect 7 | logging.level.root=DEBUG 8 | camel.springboot.main-run-controller=true 9 | -------------------------------------------------------------------------------- /camel-example/src/test/java/pl/codeaddict/camelexample/CamelExampleApplicationTests.java: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.camelexample; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class CamelExampleApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/curl-scripts/get_non_secured_api.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | curl -X GET http://localhost:8080/not-secured 4 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/curl-scripts/get_secured_api.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source ./get_user_token.sh 3 | 4 | echo "Using acccess token: $ACCESS_TOKEN" 5 | 6 | curl -H "Authorization: Bearer $ACCESS_TOKEN" http://localhost:8080/secured 7 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/curl-scripts/get_user_refresh_token.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TOKEN_RESPONSE=$(curl -d "client_id=login-app&username=user&password=password&grant_type=password" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:8081/auth/realms/kotlin-flutter-demo-realm/protocol/openid-connect/token) 4 | 5 | echo $TOKEN_RESPONSE 6 | 7 | REFRESH_TOKEN=$(echo $TOKEN_RESPONSE | jq -j '.refresh_token') 8 | 9 | echo "In order to use REFRESH_TOKEN in rest of the script please run this script using '. ./get_user_refresh_token.sh'" 10 | 11 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/curl-scripts/get_user_token.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TOKEN_RESPONSE=$(curl -d "client_id=login-app&username=user&password=password&grant_type=password" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:8081/auth/realms/kotlin-flutter-demo-realm/protocol/openid-connect/token) 4 | 5 | echo $TOKEN_RESPONSE 6 | 7 | ACCESS_TOKEN=$(echo $TOKEN_RESPONSE | jq -j '.access_token') 8 | 9 | echo "In order to use ACCESS_TOKEN in rest of the script please run this script using '. ./get_user_token.sh'" 10 | 11 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/curl-scripts/get_user_token_using_refresh_token.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source ./get_user_refresh_token.sh 3 | 4 | echo "Getting ACCESS_TOKEN using refresh token: $REFRESH_TOKEN" 5 | 6 | curl -d "client_id=login-app&refresh_token=$REFRESH_TOKEN&grant_type=refresh_token" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:8081/auth/realms/kotlin-flutter-demo-realm/protocol/openid-connect/token 7 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.7" 2 | services: 3 | flutter-kotlin-api: 4 | container_name: flutter-kotlin-api 5 | image: flutter-kotlin-api 6 | environment: 7 | - SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI=http://flutter-kotlin-keycloak:8080/auth/realms/kotlin-flutter-demo-realm/protocol/openid-connect/certs 8 | ports: 9 | - "8080:8080" 10 | flutter-kotlin-gui: 11 | container_name: flutter-kotlin-gui 12 | image: flutter-kotlin-gui 13 | ports: 14 | - "80:80" 15 | flutter-kotlin-keycloak: 16 | container_name: flutter-kotlin-keycloak 17 | image: jboss/keycloak:12.0.3 18 | environment: 19 | - KEYCLOAK_USER=admin 20 | - KEYCLOAK_PASSWORD=admin 21 | - KEYCLOAK_IMPORT=/tmp/realm-export.json 22 | ports: 23 | - "8081:8080" 24 | volumes: 25 | - ./keycloak-docker/realm-export.json:/tmp/realm-export.json 26 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Flutter", 3 | "dockerFile": "../Dockerfile_dev", 4 | "extensions": [ 5 | "dart-code.dart-code", 6 | "dart-code.flutter", 7 | "k--kato.intellij-idea-keybindings" 8 | ], 9 | "runArgs": [], 10 | "postCreateCommand": "flutter pub get" 11 | } -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | lib/generated_plugin_registrant.dart 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 9b2d32b605630f28625709ebd9d78ab3016b2bf6 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "flutter-dart DEBUG", 9 | "request": "launch", 10 | "type": "dart", 11 | "program": "lib/main.dart", 12 | "args": [ 13 | "-d", 14 | "web-server", 15 | "--web-port", 16 | "$FLUTTER_WEB_PORT", 17 | "--web-enable-expression-evaluation" 18 | ] 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/Dockerfile: -------------------------------------------------------------------------------- 1 | # Stage 1 : build production code 2 | FROM ubuntu:20.04 AS build 3 | ARG DEBIAN_FRONTEND=noninteractive 4 | ## Prerequisites 5 | RUN apt-get update && apt-get install -y unzip xz-utils git openssh-client curl && apt-get upgrade -y 6 | 7 | ## Install flutter beta 8 | RUN curl -L https://storage.googleapis.com/flutter_infra/releases/stable/linux/flutter_linux_2.0.1-stable.tar.xz | tar -C /opt -xJ 9 | ENV PATH="$PATH":"/opt/flutter/.pub-cache/bin:/opt/flutter/bin" 10 | 11 | COPY . /app 12 | WORKDIR /app/ 13 | 14 | RUN flutter build web 15 | 16 | ## Stage 2 : create the docker final image 17 | FROM nginx:alpine 18 | WORKDIR /usr/share/nginx/html 19 | COPY --from=build /app/build/web ./ 20 | COPY nginx/nginx.conf /etc/nginx/nginx.conf 21 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/Dockerfile_dev: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | ARG DEBIAN_FRONTEND=noninteractive 3 | 4 | ENV FLUTTER_WEB_PORT="8090" 5 | ENV FLUTTER_DEBUG_PORT="42000" 6 | 7 | # Prerequisites 8 | RUN apt-get update && apt-get install -y unzip xz-utils git openssh-client curl && apt-get upgrade -y 9 | 10 | # Install flutter beta 11 | RUN curl -L https://storage.googleapis.com/flutter_infra/releases/stable/linux/flutter_linux_2.0.1-stable.tar.xz | tar -C /opt -xJ 12 | 13 | ENV PATH="$PATH":"/opt/flutter/.pub-cache/bin:/opt/flutter/bin" 14 | 15 | RUN flutter update-packages 16 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 29 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | lintOptions { 36 | disable 'InvalidPackage' 37 | } 38 | 39 | defaultConfig { 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 41 | applicationId "com.example.gui" 42 | minSdkVersion 18 43 | targetSdkVersion 29 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | } 47 | 48 | buildTypes { 49 | release { 50 | // TODO: Add your own signing config for the release build. 51 | // Signing with the debug keys for now, so `flutter run --release` works. 52 | signingConfig signingConfigs.debug 53 | } 54 | } 55 | } 56 | 57 | flutter { 58 | source '../..' 59 | } 60 | 61 | dependencies { 62 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 63 | } 64 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/android/app/src/main/kotlin/com/example/gui/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.gui 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.50' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.5.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 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-5.6.2-all.zip 7 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/app.flx 22 | Flutter/app.zip 23 | Flutter/flutter_assets/ 24 | Flutter/flutter_export_environment.sh 25 | ServiceDefinitions.json 26 | Runner/GeneratedPluginRegistrant.* 27 | 28 | # Exceptions to above rules. 29 | !default.mode1v3 30 | !default.mode2v3 31 | !default.pbxuser 32 | !default.perspectivev3 33 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | gui 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/lib/constants/api_path.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_flavor/flutter_flavor.dart'; 2 | 3 | class ApiPath { 4 | static final baseKeycloakUrl = 5 | FlavorConfig.instance.variables["baseKeycloakUrl"]; 6 | static final baseApiUrl = FlavorConfig.instance.variables["baseApiUrl"]; 7 | 8 | static final Uri KEYCLOAK_AUTH = Uri.parse( 9 | '$baseKeycloakUrl/auth/realms/kotlin-flutter-demo-realm/protocol/openid-connect/token'); 10 | static final Uri API_SECURED = Uri.parse('$baseApiUrl/secured'); 11 | static final Uri API_NOT_SECURED = Uri.parse('$baseApiUrl/not-secured'); 12 | } 13 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_flavor/flutter_flavor.dart'; 3 | import 'flutter_api_demo_app.dart'; 4 | 5 | 6 | void main() { 7 | FlavorConfig( 8 | name: "DEV", 9 | color: Colors.red, 10 | location: BannerLocation.bottomStart, 11 | variables: { 12 | "baseApiUrl": "http://localhost:8080", 13 | "baseKeycloakUrl": "http://localhost:8081", 14 | }, 15 | ); 16 | 17 | runApp(FlutterApiDemoApp()); 18 | } -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/lib/models/api_response.dart: -------------------------------------------------------------------------------- 1 | class ApiResponse { 2 | final T body; 3 | final int code; 4 | 5 | ApiResponse({this.body, this.code}); 6 | } 7 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/lib/models/server_message.dart: -------------------------------------------------------------------------------- 1 | class ServerMessage { 2 | final String message; 3 | 4 | ServerMessage({this.message}); 5 | 6 | factory ServerMessage.fromJson(Map json) { 7 | return ServerMessage(message: json['message']); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/lib/models/token_model.dart: -------------------------------------------------------------------------------- 1 | class TokenModel { 2 | final String accessToken; 3 | final String tokenType; 4 | final String scope; 5 | final String sessionState; 6 | final int notBeforePolicy; 7 | 8 | TokenModel( 9 | {this.accessToken, 10 | this.tokenType, 11 | this.scope, 12 | this.sessionState, 13 | this.notBeforePolicy}); 14 | 15 | factory TokenModel.fromJson(Map json) { 16 | return TokenModel( 17 | accessToken: json['access_token'], 18 | tokenType: json['token_type'], 19 | scope: json['scope'], 20 | sessionState: json['session_state'], 21 | notBeforePolicy: json['not-before-policy'], 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/lib/services/auth_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:gui/constants/api_path.dart'; 3 | import 'package:gui/services/session_storage_service.dart'; 4 | import 'package:http/http.dart' as http; 5 | 6 | class AuthService { 7 | static AuthService service; 8 | 9 | static Future getInstance() async { 10 | if (service == null) { 11 | service = AuthService(); 12 | } 13 | return service; 14 | } 15 | 16 | Future authenticateUser(String username, String password) async { 17 | var res = await http.post(ApiPath.KEYCLOAK_AUTH, headers: { 18 | "Content-Type": "application/x-www-form-urlencoded" 19 | }, body: { 20 | "username": username, 21 | "password": password, 22 | "client_id": "login-app", 23 | "grant_type": "password" 24 | }); 25 | 26 | if (res.statusCode == 200) { 27 | var sessionStorageService = await SessionStorageService.getInstance(); 28 | sessionStorageService.saveAccessToken(res.body); 29 | return res.statusCode; 30 | } else { 31 | debugPrint( 32 | "An Error Occurred during loggin in. Status code: ${res.statusCode} , body: ${res.body.toString()}"); 33 | return res.statusCode; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/lib/services/session_storage_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:shared_preferences/shared_preferences.dart'; 2 | import 'dart:convert'; 3 | import 'package:gui/models/token_model.dart'; 4 | 5 | class SessionStorageService { 6 | static SessionStorageService manager; 7 | static SharedPreferences _prefs; 8 | static const String ACCESS_TOKEN_KEY = "ACCESS_TOKEN"; 9 | 10 | static Future getInstance() async { 11 | if (manager == null || _prefs == null) { 12 | manager = SessionStorageService(); 13 | _prefs = await SharedPreferences.getInstance(); 14 | } 15 | return manager; 16 | } 17 | 18 | void saveAccessToken(String accessToken) { 19 | _prefs.setString(ACCESS_TOKEN_KEY, accessToken); 20 | } 21 | 22 | String retriveAccessToken() { 23 | var tokenJson = _prefs.getString(ACCESS_TOKEN_KEY); 24 | if (tokenJson == null) { 25 | return null; 26 | } 27 | return TokenModel.fromJson(jsonDecode(tokenJson)).accessToken; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | worker_processes 1; 2 | 3 | events { 4 | worker_connections 1024; 5 | } 6 | 7 | http { 8 | sendfile on; 9 | 10 | server { 11 | listen 80; 12 | 13 | root /usr/share/nginx/html; 14 | index index.html index.html; 15 | include /etc/nginx/mime.types; 16 | 17 | gzip on; 18 | gzip_min_length 1000; 19 | gzip_proxied expired no-cache no-store private auth; 20 | gzip_types text/css application/javascript; 21 | 22 | location / { 23 | alias /usr/share/nginx/html/; 24 | try_files $uri /index.html =404; 25 | 26 | add_header Last-Modified $date_gmt; 27 | add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; 28 | if_modified_since off; 29 | expires off; 30 | etag off; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:gui/flutter_api_demo_app.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(FlutterApiDemoApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/web/favicon.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/web/icons/Icon-192.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/flutter-gui/web/icons/Icon-512.png -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | gui 30 | 31 | 32 | 33 | 36 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/flutter-gui/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gui", 3 | "short_name": "gui", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/kotlin-api/.gitignore: -------------------------------------------------------------------------------- 1 | # IDEA 2 | 3 | .idea/* 4 | 5 | # IntelliJ 6 | out/ 7 | 8 | 9 | # Crashlytics plugin (for Android Studio and IntelliJ) 10 | com_crashlytics_export_strings.xml 11 | crashlytics.properties 12 | crashlytics-build.properties 13 | fabric.properties 14 | 15 | ### Intellij+iml Patch ### 16 | # Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 17 | 18 | *.iml 19 | modules.xml 20 | .idea/misc.xml 21 | *.ipr 22 | 23 | ### Gradle ### 24 | .gradle 25 | build/ 26 | 27 | # Ignore Gradle GUI config 28 | gradle-app.setting 29 | 30 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 31 | !gradle-wrapper.jar 32 | 33 | # Cache of project 34 | .gradletasknamecache 35 | 36 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 37 | # gradle/wrapper/gradle-wrapper.properties 38 | 39 | ### Gradle Patch ### 40 | **/build/ 41 | 42 | # End of https://www.toptal.com/developers/gitignore/api/intellij+iml,gradle 43 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/kotlin-api/README.md: -------------------------------------------------------------------------------- 1 | # API 2 | 3 | An example of a very simple api written in Kotlin using Spring Boot 2 and Spring Web Flux. The application has one secured endpoint and one unsecured. The Spring Boot Oauth 2 resource server is used for security. 4 | 5 | You can find more details in my blog post [Code-Addict](http://code-addict.pl/flutter-spring-kotlin-web/) 6 | 7 | ## Running project 8 | This project use Spring Boot 2, so in order to run it you can simply use `./gradlew bootRun` command. 9 | 10 | ## Building Docker image with application 11 | You can build application docker image using `jib` gradle plugin. Just use following command in root of this project: 12 | ``` 13 | ./gradlew jibDocerBuild 14 | ``` 15 | 16 | You can run container using following command: 17 | ``` 18 | docker run -p 80:80 flutter-kotlin-api 19 | ``` 20 | 21 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/kotlin-api/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 2 | 3 | plugins { 4 | id("org.springframework.boot") version "2.4.2" 5 | id("io.spring.dependency-management") version "1.0.11.RELEASE" 6 | id("com.google.cloud.tools.jib") version "2.7.1" 7 | 8 | kotlin("jvm") version "1.4.21" 9 | kotlin("plugin.spring") version "1.4.21" 10 | } 11 | 12 | group = "pl.codeaddict" 13 | version = "0.0.1-SNAPSHOT" 14 | java.sourceCompatibility = JavaVersion.VERSION_11 15 | 16 | repositories { 17 | mavenCentral() 18 | } 19 | 20 | dependencies { 21 | implementation("org.springframework.boot:spring-boot-starter-webflux") 22 | implementation("com.fasterxml.jackson.module:jackson-module-kotlin") 23 | implementation("io.projectreactor.kotlin:reactor-kotlin-extensions") 24 | implementation("org.jetbrains.kotlin:kotlin-reflect") 25 | implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") 26 | implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor") 27 | implementation("org.springframework.boot:spring-boot-starter-oauth2-resource-server") 28 | 29 | testImplementation("org.springframework.boot:spring-boot-starter-test") 30 | testImplementation("io.projectreactor:reactor-test") 31 | } 32 | 33 | tasks.withType { 34 | kotlinOptions { 35 | freeCompilerArgs = listOf("-Xjsr305=strict") 36 | jvmTarget = "11" 37 | } 38 | } 39 | 40 | tasks.withType { 41 | useJUnitPlatform() 42 | } 43 | 44 | jib { 45 | from { 46 | image = "gcr.io/distroless/java-debian10:11" 47 | } 48 | to { 49 | image = "flutter-kotlin-api" 50 | } 51 | container { 52 | jvmFlags = listOf("-Duser.timezone=UTC") 53 | ports = listOf("8080") 54 | creationTime = "USE_CURRENT_TIMESTAMP" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/kotlin-api/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/flutter-spring-kotlin-web/kotlin-api/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/kotlin-api/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/kotlin-api/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "flutter-api" 2 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/kotlin-api/src/main/kotlin/pl/codeaddict/flutterapi/ApiController.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.flutterapi 2 | 3 | import org.springframework.security.access.prepost.PreAuthorize 4 | import org.springframework.web.bind.annotation.GetMapping 5 | import org.springframework.web.bind.annotation.RestController 6 | import reactor.core.publisher.Mono 7 | 8 | @RestController 9 | class ApiController { 10 | 11 | @PreAuthorize("permitAll()") 12 | @GetMapping("/not-secured") 13 | fun getNonSecuredMessage() = Mono.just(ApiResponse("Server return non secured message")) 14 | 15 | @PreAuthorize("hasRole('USER')") 16 | @GetMapping("/secured") 17 | fun getSecuredMessage() = Mono.just(ApiResponse("Server return SECURED message")) 18 | } -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/kotlin-api/src/main/kotlin/pl/codeaddict/flutterapi/ApiResponse.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.flutterapi 2 | 3 | data class ApiResponse(val message: String) 4 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/kotlin-api/src/main/kotlin/pl/codeaddict/flutterapi/FlutterApiApplication.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.flutterapi 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication 4 | import org.springframework.boot.runApplication 5 | 6 | @SpringBootApplication 7 | class FlutterApiApplication 8 | 9 | fun main(args: Array) { 10 | runApplication(*args) 11 | } 12 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/kotlin-api/src/main/kotlin/pl/codeaddict/flutterapi/config/nonreactive/KeycloakJwtAuthenticationConverter.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.flutterapi.config.nonreactive 2 | 3 | import org.springframework.core.convert.converter.Converter 4 | import org.springframework.security.authentication.AbstractAuthenticationToken 5 | import org.springframework.security.oauth2.jwt.Jwt 6 | import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken 7 | import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter 8 | import java.util.stream.Collectors 9 | import java.util.stream.Stream 10 | 11 | /** 12 | * Keycloak realm converter converts custom keycloak jwt token properties 13 | * and default JWT properties into granted authorities 14 | */ 15 | class KeycloakJwtAuthenticationConverter : Converter { 16 | 17 | private val keycloakRealmRoleConverter = KeycloakRealmRoleConverter() 18 | private val defaultGrantedAuthoritiesConverter = JwtGrantedAuthoritiesConverter() 19 | 20 | override fun convert(source: Jwt): AbstractAuthenticationToken { 21 | val authorities = Stream.concat( 22 | defaultGrantedAuthoritiesConverter.convert(source)!!.stream(), 23 | keycloakRealmRoleConverter.convert(source).stream() 24 | ).collect(Collectors.toSet()) 25 | return JwtAuthenticationToken(source, authorities) 26 | } 27 | } -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/kotlin-api/src/main/kotlin/pl/codeaddict/flutterapi/config/nonreactive/KeycloakRealmRoleConverter.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.flutterapi.config.nonreactive 2 | 3 | import org.springframework.core.convert.converter.Converter 4 | import org.springframework.security.core.GrantedAuthority 5 | import org.springframework.security.core.authority.SimpleGrantedAuthority 6 | import org.springframework.security.oauth2.jwt.Jwt 7 | import java.util.Collections.emptyList 8 | import java.util.Collections.emptyMap 9 | import java.util.stream.Collectors 10 | 11 | /** 12 | * Keycloak realm converter converts keycloak jwt token into granted authorities 13 | */ 14 | class KeycloakRealmRoleConverter : Converter> { 15 | 16 | private val authorityPrefix = "ROLE_" 17 | 18 | override fun convert(jwt: Jwt): Collection { 19 | val realmAccess = jwt.getClaim>>("realm_access") ?: emptyMap() 20 | return realmAccess.getOrDefault("roles", emptyList()) 21 | .stream() 22 | .map { roleName -> "$authorityPrefix${roleName.toUpperCase()}" } 23 | .map { role -> SimpleGrantedAuthority(role) } 24 | .collect(Collectors.toSet()) 25 | } 26 | } -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/kotlin-api/src/main/kotlin/pl/codeaddict/flutterapi/config/nonreactive/NonReactiveSecurityConfig.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.flutterapi.config.nonreactive 2 | 3 | import org.slf4j.LoggerFactory 4 | import org.springframework.context.annotation.Configuration 5 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity 6 | import org.springframework.security.config.annotation.web.builders.HttpSecurity 7 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter 8 | import org.springframework.security.config.http.SessionCreationPolicy 9 | 10 | /** 11 | * For standard Spring Web applications (non Reactive) 12 | **/ 13 | //@Configuration 14 | //@EnableGlobalMethodSecurity(prePostEnabled = true) 15 | class NonReactiveSecurityConfig : WebSecurityConfigurerAdapter() { 16 | 17 | private val log = LoggerFactory.getLogger(this.javaClass) 18 | 19 | override fun configure(http: HttpSecurity) { 20 | log.info("Customizing security configuration (standard)") 21 | http.httpBasic() 22 | .disable() 23 | .csrf() 24 | .disable() 25 | .cors() 26 | .disable() 27 | .authorizeRequests() 28 | .and() 29 | .sessionManagement() 30 | .sessionCreationPolicy(SessionCreationPolicy.STATELESS) 31 | .and() 32 | .oauth2ResourceServer() 33 | .jwt() 34 | .jwtAuthenticationConverter(KeycloakJwtAuthenticationConverter()) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/kotlin-api/src/main/kotlin/pl/codeaddict/flutterapi/config/reactive/CorsConfiguration.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.flutterapi.config.reactive 2 | 3 | import org.springframework.context.annotation.Configuration 4 | import org.springframework.web.reactive.config.CorsRegistry 5 | import org.springframework.web.reactive.config.EnableWebFlux 6 | import org.springframework.web.reactive.config.WebFluxConfigurer 7 | 8 | 9 | @Configuration 10 | @EnableWebFlux 11 | class CorsGlobalConfiguration : WebFluxConfigurer { 12 | override fun addCorsMappings(corsRegistry: CorsRegistry) { 13 | corsRegistry.addMapping("/**") 14 | .allowedOrigins("*") 15 | .allowedMethods("PUT", "GET", "POST") 16 | .maxAge(3600) 17 | } 18 | } -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/kotlin-api/src/main/kotlin/pl/codeaddict/flutterapi/config/reactive/KeycloakRealmRoleConverter.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.flutterapi.config.reactive 2 | 3 | import org.springframework.security.core.authority.SimpleGrantedAuthority 4 | import org.springframework.security.oauth2.jwt.Jwt 5 | import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter 6 | import java.util.Collections.emptyList 7 | import java.util.Collections.emptyMap 8 | 9 | /** 10 | * Keycloak realm converter converts keycloak jwt token into granted authorities 11 | */ 12 | class KeycloakRealmRoleConverter : JwtAuthenticationConverter() { 13 | private val authorityPrefix = "ROLE_" 14 | 15 | override fun extractAuthorities(jwt: Jwt): Collection { 16 | val authorities = jwt.claims["realm_access"] as Map>? ?: emptyMap() 17 | return authorities.getOrDefault("roles", emptyList()) 18 | .map { roleName -> "$authorityPrefix${roleName.toUpperCase()}" } 19 | .map { role -> SimpleGrantedAuthority(role) } 20 | } 21 | } -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/kotlin-api/src/main/kotlin/pl/codeaddict/flutterapi/config/reactive/ReactiveSecurityConfig.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.flutterapi.config.reactive 2 | 3 | import org.slf4j.LoggerFactory 4 | import org.springframework.context.annotation.Bean 5 | import org.springframework.security.config.annotation.method.configuration.EnableReactiveMethodSecurity 6 | import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity 7 | import org.springframework.security.config.web.server.ServerHttpSecurity 8 | import org.springframework.security.oauth2.server.resource.authentication.ReactiveJwtAuthenticationConverterAdapter 9 | import org.springframework.security.web.server.SecurityWebFilterChain 10 | 11 | 12 | /** 13 | * For Reactive web applications (WebFlux) 14 | **/ 15 | @EnableWebFluxSecurity 16 | @EnableReactiveMethodSecurity 17 | class ReactiveSecurityConfig { 18 | 19 | private val log = LoggerFactory.getLogger(this.javaClass) 20 | 21 | @Bean 22 | fun springSecurityFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain? { 23 | log.info("Customizing security configuration (reactive)") 24 | http 25 | .authorizeExchange { exchanges -> 26 | exchanges 27 | .anyExchange().permitAll() 28 | } 29 | .oauth2ResourceServer { oauth2ResourceServer -> 30 | oauth2ResourceServer 31 | .jwt { jwt -> 32 | jwt.jwtAuthenticationConverter( 33 | ReactiveJwtAuthenticationConverterAdapter( 34 | KeycloakRealmRoleConverter() 35 | ) 36 | ) 37 | } 38 | } 39 | return http.build() 40 | } 41 | } 42 | 43 | 44 | -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/kotlin-api/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | security: 3 | oauth2: 4 | resourceserver: 5 | jwt: 6 | jwk-set-uri: http://localhost:8081/auth/realms/kotlin-flutter-demo-realm/protocol/openid-connect/certs 7 | 8 | logging: 9 | level: 10 | org.springframework: 11 | security: INFO -------------------------------------------------------------------------------- /flutter-spring-kotlin-web/kotlin-api/src/test/kotlin/pl/codeaddict/flutterapi/FlutterApiApplicationTests.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.flutterapi 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.springframework.boot.test.context.SpringBootTest 5 | 6 | @SpringBootTest 7 | class FlutterApiApplicationTests { 8 | 9 | @Test 10 | fun contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /hazelcast-demo/README.md: -------------------------------------------------------------------------------- 1 | # Hazelcast Demo 2 | 3 | Aim of the project is to show how to use Hazelcast in Spring Boot 2 application. Whole idea is described in my blog 4 | post [Code-Addict](http://code-addict.pl/hazelcast-distributed-cache/) 5 | 6 | ## Functionalities: 7 | There are two applications run in separate Docker containers. One is writing to Hazelcast map, and second is reading 8 | from it 9 | and stream to 10 | web 11 | controller. 12 | 13 | ## Dependencies 14 | Project is very simple and uses following dependencies: 15 | - Spring Boot 2.1.1 16 | - Hazelcast 17 | - Spring WebFlux 18 | - Kotlin 19 | 20 | ## Running 21 | First please run gradle build command with docker image build task: 22 | `./gradlew build appDocker` 23 | Now you can start docker by run simple docker-compose command: 24 | `cd docker && docker-compose up` 25 | Go to `localhost:8080/hazelcast/stream` and see how it works. 26 | 27 | ## Licence 28 | 29 | Project uses a MIT licence . 30 | 31 | MIT License 32 | 33 | Copyright (c) 2018 Michal Kostewicz 34 | 35 | Permission is hereby granted, free of charge, to any person obtaining a copy 36 | of this software and associated documentation files (the "Software"), to deal 37 | in the Software without restriction, including without limitation the rights 38 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 39 | copies of the Software, and to permit persons to whom the Software is 40 | furnished to do so, subject to the following conditions: 41 | 42 | The above copyright notice and this permission notice shall be included in all 43 | copies or substantial portions of the Software. 44 | 45 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 46 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 47 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 48 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 49 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 50 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 51 | SOFTWARE. 52 | -------------------------------------------------------------------------------- /hazelcast-demo/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | kotlinVersion = '1.2.71' 4 | springBootVersion = '2.1.1.RELEASE' 5 | gradleDockerVersion = "1.2" 6 | } 7 | repositories { 8 | mavenCentral() 9 | } 10 | dependencies { 11 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 12 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}") 13 | classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}") 14 | classpath("se.transmode.gradle:gradle-docker:${gradleDockerVersion}") 15 | } 16 | 17 | } 18 | 19 | 20 | allprojects { 21 | group = 'pl.codeaddict' 22 | version = '0.0.1-SNAPSHOT' 23 | } 24 | 25 | subprojects { 26 | repositories { 27 | mavenLocal() 28 | mavenCentral() 29 | } 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /hazelcast-demo/demo-hazelcast-cache/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | /out/ 20 | 21 | ### NetBeans ### 22 | /nbproject/private/ 23 | /nbbuild/ 24 | /dist/ 25 | /nbdist/ 26 | /.nb-gradle/ -------------------------------------------------------------------------------- /hazelcast-demo/demo-hazelcast-cache/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'kotlin' 3 | id 'kotlin-spring' 4 | id 'eclipse' 5 | id 'org.springframework.boot' 6 | id 'io.spring.dependency-management' 7 | id 'application' 8 | id 'docker' 9 | } 10 | 11 | mainClassName = 'pl.codeaddict.demohazelcast.cache.DemoHazelcastApplicationCacheKt' 12 | sourceCompatibility = 1.8 13 | compileKotlin { 14 | kotlinOptions { 15 | freeCompilerArgs = ["-Xjsr305=strict"] 16 | jvmTarget = "1.8" 17 | } 18 | } 19 | compileTestKotlin { 20 | kotlinOptions { 21 | freeCompilerArgs = ["-Xjsr305=strict"] 22 | jvmTarget = "1.8" 23 | } 24 | } 25 | 26 | jar { 27 | manifest { attributes 'Main-Class': "$mainClassName" } 28 | from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } 29 | } 30 | 31 | docker { 32 | maintainer = 'Michal Kostewicz ' 33 | baseImage "frolvlad/alpine-oraclejdk8:slim" 34 | } 35 | 36 | task copyTar(type: Copy) { 37 | from file("$buildDir/distributions/demo-hazelcast-cache-0.0.1-SNAPSHOT.tar") 38 | into file("$buildDir/docker") 39 | } 40 | 41 | task appDocker(type: Docker) { 42 | dependsOn 'copyTar' 43 | addFile('demo-hazelcast-cache-0.0.1-SNAPSHOT.tar', '/') 44 | entryPoint( ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/demo-hazelcast-cache-0.0.1-SNAPSHOT/lib/demo-hazelcast-cache-0.0.1-SNAPSHOT.jar"]) 45 | } 46 | 47 | dependencies { 48 | implementation('org.springframework.boot:spring-boot-starter') 49 | implementation('com.fasterxml.jackson.module:jackson-module-kotlin') 50 | implementation('com.hazelcast:hazelcast:3.11.1') 51 | implementation('com.hazelcast:hazelcast-spring:3.11.1') 52 | implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") 53 | implementation("org.jetbrains.kotlin:kotlin-reflect") 54 | testImplementation('org.springframework.boot:spring-boot-starter-test') 55 | testImplementation('io.projectreactor:reactor-test') 56 | } 57 | -------------------------------------------------------------------------------- /hazelcast-demo/demo-hazelcast-cache/src/main/kotlin/pl/codeaddict/demohazelcast/cache/DemoHazelcastApplicationCache.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.demohazelcast.cache 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication 4 | import org.springframework.boot.runApplication 5 | import org.springframework.scheduling.annotation.EnableScheduling 6 | 7 | 8 | @SpringBootApplication 9 | @EnableScheduling 10 | class DemoHazelcastApplicationCache 11 | 12 | fun main(args: Array) { 13 | runApplication(*args) 14 | } -------------------------------------------------------------------------------- /hazelcast-demo/demo-hazelcast-cache/src/main/kotlin/pl/codeaddict/demohazelcast/cache/HazelcastConfiguration.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.demohazelcast.cache 2 | 3 | import com.hazelcast.config.Config 4 | import com.hazelcast.config.EvictionPolicy 5 | import com.hazelcast.config.MaxSizeConfig 6 | import com.hazelcast.config.MapConfig 7 | import org.springframework.context.annotation.Bean 8 | import org.springframework.context.annotation.Configuration 9 | 10 | 11 | @Configuration 12 | class HazelcastConfiguration { 13 | @Bean 14 | fun hazelCastConfig(): Config { 15 | val config = Config() 16 | config 17 | .addMapConfig( 18 | MapConfig() 19 | .setName("configuration") 20 | .setMaxSizeConfig(MaxSizeConfig(200, MaxSizeConfig.MaxSizePolicy.FREE_HEAP_SIZE)) 21 | .setEvictionPolicy(EvictionPolicy.LRU) 22 | .setTimeToLiveSeconds(-1)) 23 | return config 24 | } 25 | } -------------------------------------------------------------------------------- /hazelcast-demo/demo-hazelcast-cache/src/main/kotlin/pl/codeaddict/demohazelcast/cache/ScheduledTasks.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.demohazelcast.cache 2 | 3 | import com.hazelcast.core.HazelcastInstance 4 | import com.hazelcast.core.IMap 5 | import org.springframework.beans.factory.annotation.Autowired 6 | import org.springframework.scheduling.annotation.Scheduled 7 | import org.springframework.stereotype.Service 8 | 9 | @Service 10 | class ScheduledTasks { 11 | val key = "MY_KEY" 12 | 13 | @Autowired 14 | private val hazelcastInstance: HazelcastInstance? = null 15 | 16 | @Scheduled(fixedRate = 1000) 17 | fun changeHazelcastMap() { 18 | val hazelcastMap: IMap = hazelcastInstance?.getMap("my-map")!! 19 | if(!hazelcastMap.containsKey(key)){ 20 | hazelcastMap.put(key,0) 21 | }else{ 22 | var previousInteger: Int = hazelcastMap.get(key)!! 23 | val nextInteger = ++previousInteger 24 | hazelcastMap.put(key, nextInteger) 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /hazelcast-demo/demo-hazelcast-cache/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.main.web-application-type=NONE 2 | spring.application.name: demo-hazelcast-cache 3 | -------------------------------------------------------------------------------- /hazelcast-demo/demo-hazelcast-cache/src/test/kotlin/pl/codeaddict/demohazelcast/cache/DemoHazelcastApplicationCacheTests.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.demohazelcast.cache 2 | 3 | import org.junit.Test 4 | import org.junit.runner.RunWith 5 | import org.springframework.boot.test.context.SpringBootTest 6 | import org.springframework.test.context.junit4.SpringRunner 7 | 8 | @RunWith(SpringRunner::class) 9 | @SpringBootTest 10 | class DemoHazelcastApplicationCacheTests { 11 | 12 | @Test 13 | fun contextLoads() { 14 | } 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /hazelcast-demo/demo-hazelcast-client/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /build/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | 5 | ### STS ### 6 | .apt_generated 7 | .classpath 8 | .factorypath 9 | .project 10 | .settings 11 | .springBeans 12 | .sts4-cache 13 | 14 | ### IntelliJ IDEA ### 15 | .idea 16 | *.iws 17 | *.iml 18 | *.ipr 19 | /out/ 20 | 21 | ### NetBeans ### 22 | /nbproject/private/ 23 | /nbbuild/ 24 | /dist/ 25 | /nbdist/ 26 | /.nb-gradle/ -------------------------------------------------------------------------------- /hazelcast-demo/demo-hazelcast-client/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'kotlin' 3 | id 'kotlin-spring' 4 | id 'eclipse' 5 | id 'org.springframework.boot' 6 | id 'io.spring.dependency-management' 7 | id 'application' 8 | id 'docker' 9 | } 10 | 11 | mainClassName = 'pl.codeaddict.demohazelcast.client.DemoHazelcastApplicationClientKt' 12 | sourceCompatibility = 1.8 13 | compileKotlin { 14 | kotlinOptions { 15 | freeCompilerArgs = ["-Xjsr305=strict"] 16 | jvmTarget = "1.8" 17 | } 18 | } 19 | compileTestKotlin { 20 | kotlinOptions { 21 | freeCompilerArgs = ["-Xjsr305=strict"] 22 | jvmTarget = "1.8" 23 | } 24 | } 25 | 26 | jar { 27 | manifest { attributes 'Main-Class': "$mainClassName" } 28 | from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } 29 | } 30 | 31 | docker { 32 | maintainer = 'Michal Kostewicz ' 33 | baseImage "frolvlad/alpine-oraclejdk8:slim" 34 | } 35 | 36 | task copyTar(type: Copy) { 37 | from file("$buildDir/distributions/demo-hazelcast-client-0.0.1-SNAPSHOT.tar") 38 | into file("$buildDir/docker") 39 | } 40 | 41 | task appDocker(type: Docker) { 42 | dependsOn 'copyTar' 43 | addFile('demo-hazelcast-client-0.0.1-SNAPSHOT.tar', '/') 44 | entryPoint( ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/demo-hazelcast-client-0.0.1-SNAPSHOT/lib/demo-hazelcast-client-0.0.1-SNAPSHOT.jar"]) 45 | } 46 | 47 | dependencies { 48 | implementation('org.springframework.boot:spring-boot-starter-web') 49 | implementation('org.springframework.boot:spring-boot-starter-webflux') 50 | implementation('com.fasterxml.jackson.module:jackson-module-kotlin') 51 | implementation('com.hazelcast:hazelcast-client:3.11.1') 52 | implementation('com.hazelcast:hazelcast-spring:3.11.1') 53 | implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") 54 | implementation("org.jetbrains.kotlin:kotlin-reflect") 55 | testImplementation('org.springframework.boot:spring-boot-starter-test') 56 | testImplementation('io.projectreactor:reactor-test') 57 | } 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /hazelcast-demo/demo-hazelcast-client/src/main/kotlin/pl/codeaddict/demohazelcast/client/DemoHazelcastApplicationClient.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.demohazelcast.client 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication 4 | import org.springframework.boot.runApplication 5 | 6 | @SpringBootApplication 7 | class DemoHazelcastApplicationClient 8 | 9 | fun main(args: Array) { 10 | runApplication(*args) 11 | } 12 | 13 | -------------------------------------------------------------------------------- /hazelcast-demo/demo-hazelcast-client/src/main/kotlin/pl/codeaddict/demohazelcast/client/HazelcastClientController.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.demohazelcast.client 2 | 3 | import com.hazelcast.core.HazelcastInstance 4 | import com.hazelcast.core.IMap 5 | import org.springframework.beans.factory.annotation.Autowired 6 | import org.springframework.http.MediaType 7 | import org.springframework.web.bind.annotation.GetMapping 8 | import org.springframework.web.bind.annotation.ResponseBody 9 | import org.springframework.web.bind.annotation.RestController 10 | import reactor.core.publisher.Flux 11 | import java.time.Duration 12 | import java.time.Duration.ofMillis 13 | 14 | 15 | 16 | @RestController 17 | class HazelcastClientController { 18 | val key = "MY_KEY" 19 | 20 | @Autowired 21 | private val hazelcastInstance: HazelcastInstance? = null 22 | 23 | @GetMapping(value = "/hazelcast/stream", produces = arrayOf(MediaType.TEXT_EVENT_STREAM_VALUE)) 24 | @ResponseBody 25 | fun streamHazelcastMap(): Flux { 26 | val hazelcastMap: IMap = hazelcastInstance?.getMap("my-map")!! 27 | return Flux 28 | .interval(Duration.ofMillis(1100)) 29 | .map { tick -> "NEW VALUE: " + hazelcastMap.get(key) } 30 | } 31 | } -------------------------------------------------------------------------------- /hazelcast-demo/demo-hazelcast-client/src/main/kotlin/pl/codeaddict/demohazelcast/client/HazelcastConfiguration.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.demohazelcast.client 2 | 3 | import com.hazelcast.client.HazelcastClient 4 | import com.hazelcast.client.config.ClientConfig 5 | import com.hazelcast.core.HazelcastInstance 6 | import org.springframework.context.annotation.Bean 7 | import org.springframework.context.annotation.Configuration 8 | 9 | @Configuration 10 | class HazelcastConfiguration { 11 | @Bean 12 | fun clientConfig(): ClientConfig { 13 | val clientConfig = ClientConfig() 14 | val networkConfig = clientConfig.getNetworkConfig() 15 | networkConfig.addAddress("demo-hazelcast-cache:5701", "demo-hazelcast-cache:5702") 16 | .setSmartRouting(true) 17 | .addOutboundPortDefinition("34700-34710") 18 | .setRedoOperation(true) 19 | .setConnectionTimeout(5000) 20 | .setConnectionAttemptLimit(5) 21 | 22 | return clientConfig 23 | 24 | } 25 | 26 | @Bean 27 | fun hazelcastInstance(clientConfig: ClientConfig): HazelcastInstance { 28 | return HazelcastClient.newHazelcastClient(clientConfig) 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /hazelcast-demo/demo-hazelcast-client/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name: demo-hazelcast-client 2 | -------------------------------------------------------------------------------- /hazelcast-demo/docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | demo-hazelcast-cache: 4 | image: pl.codeaddict/demo-hazelcast-cache:0.0.1-SNAPSHOT 5 | demo-hazelcast-client: 6 | image: pl.codeaddict/demo-hazelcast-client:0.0.1-SNAPSHOT 7 | ports: 8 | - "8080:8080" 9 | -------------------------------------------------------------------------------- /hazelcast-demo/docker/run.sh: -------------------------------------------------------------------------------- 1 | docker-compose up --force-recreate 2 | -------------------------------------------------------------------------------- /hazelcast-demo/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/hazelcast-demo/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /hazelcast-demo/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /hazelcast-demo/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'demo-hazelcast' 2 | 3 | include 'demo-hazelcast-cache', 'demo-hazelcast-client' 4 | -------------------------------------------------------------------------------- /kafka-demo/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | kotlinVersion = '1.2.51' 4 | springBootVersion = '2.0.6.RELEASE' 5 | } 6 | repositories { 7 | mavenCentral() 8 | } 9 | dependencies { 10 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 11 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}") 12 | classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}") 13 | } 14 | } 15 | 16 | apply plugin: 'kotlin' 17 | apply plugin: 'kotlin-spring' 18 | apply plugin: 'eclipse' 19 | apply plugin: 'org.springframework.boot' 20 | apply plugin: 'io.spring.dependency-management' 21 | 22 | group = 'pl.codeaddict' 23 | version = '0.0.1-SNAPSHOT' 24 | sourceCompatibility = 1.8 25 | compileKotlin { 26 | kotlinOptions { 27 | freeCompilerArgs = ["-Xjsr305=strict"] 28 | jvmTarget = "1.8" 29 | } 30 | } 31 | compileTestKotlin { 32 | kotlinOptions { 33 | freeCompilerArgs = ["-Xjsr305=strict"] 34 | jvmTarget = "1.8" 35 | } 36 | } 37 | 38 | repositories { 39 | mavenCentral() 40 | } 41 | 42 | dependencies { 43 | implementation('org.springframework.boot:spring-boot-starter-data-mongodb-reactive') 44 | implementation('org.springframework.boot:spring-boot-starter-webflux') 45 | implementation('org.springframework.kafka:spring-kafka') 46 | implementation('io.projectreactor.kafka:reactor-kafka') 47 | implementation('com.fasterxml.jackson.module:jackson-module-kotlin') 48 | implementation('org.apache.kafka:kafka-streams') 49 | implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") 50 | implementation("org.jetbrains.kotlin:kotlin-reflect") 51 | testImplementation('org.springframework.boot:spring-boot-starter-test') 52 | testImplementation('io.projectreactor:reactor-test') 53 | } 54 | -------------------------------------------------------------------------------- /kafka-demo/docker/broker-list.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CONTAINERS=$(docker ps | grep 9092 | awk '{print $1}') 4 | BROKERS=$(for CONTAINER in ${CONTAINERS}; do docker port "$CONTAINER" 9092 | sed -e "s/0.0.0.0:/$HOST_IP:/g"; done) 5 | echo "${BROKERS/$'\n'/,}" 6 | -------------------------------------------------------------------------------- /kafka-demo/docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | mongo-db: 4 | image: "mongo:4.0.3" 5 | ports: 6 | - "27017:27017" 7 | zookeeper: 8 | image: wurstmeister/zookeeper 9 | ports: 10 | - "2181:2181" 11 | kafka: 12 | image: wurstmeister/kafka 13 | ports: 14 | - "9092:9092" 15 | environment: 16 | KAFKA_ADVERTISED_HOST_NAME: localhost 17 | KAFKA_CREATE_TOPICS: "proxy:1:1,dhcp:1:1 " 18 | KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 19 | volumes: 20 | - /var/run/docker.sock:/var/run/docker.sock 21 | -------------------------------------------------------------------------------- /kafka-demo/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/kafka-demo/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /kafka-demo/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Oct 25 18:56:11 CEST 2018 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.8.1-all.zip 7 | -------------------------------------------------------------------------------- /kafka-demo/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'kafka-demo' 2 | -------------------------------------------------------------------------------- /kafka-demo/src/main/kotlin/pl/codeaddict/kafkademo/KafkaDemoApplication.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.kafkademo 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication 4 | import org.springframework.boot.runApplication 5 | import org.springframework.data.mongodb.repository.config.EnableReactiveMongoRepositories 6 | import org.springframework.kafka.annotation.EnableKafka 7 | import org.springframework.kafka.annotation.EnableKafkaStreams 8 | import org.springframework.scheduling.annotation.EnableScheduling 9 | 10 | @EnableKafka 11 | @EnableKafkaStreams 12 | @EnableScheduling 13 | @EnableReactiveMongoRepositories 14 | @SpringBootApplication 15 | class KafkaDemoApplication 16 | 17 | fun main(args: Array) { 18 | runApplication(*args) 19 | } 20 | -------------------------------------------------------------------------------- /kafka-demo/src/main/kotlin/pl/codeaddict/kafkademo/config/KafkaProducerConfig.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.kafkademo.config 2 | 3 | import org.apache.kafka.clients.producer.ProducerConfig 4 | import org.apache.kafka.common.serialization.StringSerializer 5 | import org.springframework.beans.factory.annotation.Value 6 | import org.springframework.context.annotation.Bean 7 | import org.springframework.context.annotation.Configuration 8 | import org.springframework.kafka.core.DefaultKafkaProducerFactory 9 | import org.springframework.kafka.core.KafkaTemplate 10 | import org.springframework.kafka.core.ProducerFactory 11 | import java.util.* 12 | 13 | 14 | @Configuration 15 | class KafkaProducerConfig { 16 | @Value("\${messaging.kafka-dp.brokers.url:localhost:9092}") 17 | private val brokersUrl: String? = null 18 | 19 | @Bean 20 | fun producerFactory(): ProducerFactory { 21 | val configProps = HashMap() 22 | configProps[ProducerConfig.BOOTSTRAP_SERVERS_CONFIG] = brokersUrl as String 23 | configProps[ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG] = StringSerializer::class.java 24 | configProps[ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG] = StringSerializer::class.java 25 | return DefaultKafkaProducerFactory(configProps) 26 | } 27 | 28 | @Bean 29 | fun kafkaTemplate(): KafkaTemplate { 30 | return KafkaTemplate(producerFactory()) 31 | } 32 | } -------------------------------------------------------------------------------- /kafka-demo/src/main/kotlin/pl/codeaddict/kafkademo/config/MongoConfig.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.kafkademo.config 2 | 3 | import com.mongodb.reactivestreams.client.MongoClient 4 | import com.mongodb.reactivestreams.client.MongoClients 5 | import org.springframework.beans.factory.annotation.Autowired 6 | import org.springframework.context.annotation.Bean 7 | import org.springframework.context.annotation.Configuration 8 | import org.springframework.data.mongodb.config.AbstractReactiveMongoConfiguration 9 | import org.springframework.data.mongodb.core.CollectionOptions 10 | import org.springframework.data.mongodb.core.ReactiveMongoTemplate 11 | import pl.codeaddict.kafkademo.domain.FraudData 12 | 13 | 14 | @Configuration 15 | class MongoConfig : AbstractReactiveMongoConfiguration() { 16 | @Autowired 17 | val reactiveMongoClient: MongoClient? = null 18 | 19 | @Bean 20 | override fun reactiveMongoClient(): MongoClient { 21 | return MongoClients.create() 22 | } 23 | 24 | override fun getDatabaseName(): String { 25 | return "test" 26 | } 27 | 28 | @Bean 29 | override fun reactiveMongoTemplate(): ReactiveMongoTemplate { 30 | val reactiveMongoTemplate = ReactiveMongoTemplate(reactiveMongoClient!!, databaseName) 31 | if (reactiveMongoTemplate.collectionExists(FraudData::class.java).block() == false) { 32 | val options = CollectionOptions(4, 4, true) 33 | reactiveMongoTemplate.createCollection(FraudData::class.java, options) 34 | } 35 | return reactiveMongoTemplate 36 | } 37 | } -------------------------------------------------------------------------------- /kafka-demo/src/main/kotlin/pl/codeaddict/kafkademo/config/Topics.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.kafkademo.config 2 | 3 | enum class Topics { 4 | PROXY, DHCP, FRAUD 5 | } -------------------------------------------------------------------------------- /kafka-demo/src/main/kotlin/pl/codeaddict/kafkademo/domain/DhcpData.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.kafkademo.domain 2 | 3 | data class DhcpData( 4 | val rt: Long = 0, 5 | val smac: String = "", 6 | val shost: String = "", 7 | val src: String = "") { 8 | constructor(str: String) : this() 9 | } -------------------------------------------------------------------------------- /kafka-demo/src/main/kotlin/pl/codeaddict/kafkademo/domain/FraudData.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.kafkademo.domain 2 | 3 | import org.springframework.data.mongodb.core.mapping.Document 4 | 5 | @Document 6 | data class FraudData( 7 | var dhcpData: DhcpData? = null, 8 | var proxyData: ProxyData? = null, 9 | val timeStr: String? = "", 10 | var id: String? = null 11 | ) -------------------------------------------------------------------------------- /kafka-demo/src/main/kotlin/pl/codeaddict/kafkademo/domain/ProxyData.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.kafkademo.domain 2 | 3 | data class ProxyData( 4 | var rt: Long = 0, 5 | var src: String = "", 6 | var dst: String = "", 7 | var request: String = "") { 8 | constructor(str: String) : this() {} 9 | } -------------------------------------------------------------------------------- /kafka-demo/src/main/kotlin/pl/codeaddict/kafkademo/producers/KafkaMessageProducer.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.kafkademo.producers 2 | 3 | import org.springframework.beans.factory.annotation.Autowired 4 | import org.springframework.kafka.core.KafkaTemplate 5 | import org.springframework.scheduling.annotation.Scheduled 6 | import org.springframework.stereotype.Service 7 | import pl.codeaddict.kafkademo.config.Topics 8 | 9 | 10 | @Service 11 | class KafkaMessageProducer { 12 | private val PROXY_LOG: String = "{\"rt\": 1504812385296, \"src\": \"192.168.100.252\"," + 13 | " \"dst\": \"192.168.100.180\",\"request\": \"http://example.com/lorem/ipsum/A!sCDn\"}" 14 | private val PROXY_STRANGE: String = "{\"rt\": 1504812385296, \"src\": \"192.168.100.174\"," + 15 | " \"dst\": \"192.168.100.252\",\"request\": \"http://strange.com\"}" 16 | private val DHCP_LOG: String = "{\"rt\": 1504785607870, \"smac\": \"AB:E9:24:26:6C:1C\"," + 17 | " \"shost\":\"station6.workstation.bank.pl\",\"src\": \"192.168.100.252\"}" 18 | private val DHCP_STRANGE: String = "{\"rt\": 1504785607870, \"smac\": \"AB:E9:24:26:6C:1X\", " + 19 | "\"shost\":\"station666.workstation.bank.pl\", \"src\": \"192.168.100.174\"}" 20 | 21 | @Autowired 22 | private val kafkaTemplate: KafkaTemplate? = null 23 | 24 | fun sendMessage(msg: String, topic: String) { 25 | kafkaTemplate!!.send(topic, msg) 26 | } 27 | 28 | @Scheduled(fixedRate = 5000) 29 | fun sendDhcpLogMessage() { 30 | sendMessage(DHCP_LOG, Topics.DHCP.name) 31 | } 32 | 33 | @Scheduled(fixedRate = 10000) 34 | fun sendStrangeDhcpLogMessage() { 35 | sendMessage(DHCP_STRANGE, Topics.DHCP.name) 36 | } 37 | 38 | @Scheduled(fixedRate = 10000) 39 | fun sendStrangeProxyLogMessage() { 40 | sendMessage(PROXY_STRANGE, Topics.PROXY.name) 41 | } 42 | 43 | @Scheduled(fixedRate = 5000) 44 | fun sendProxyLogMessage() { 45 | sendMessage(PROXY_LOG, Topics.PROXY.name) 46 | } 47 | } -------------------------------------------------------------------------------- /kafka-demo/src/main/kotlin/pl/codeaddict/kafkademo/repositories/FraudDataRepository.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.kafkademo.repositories 2 | 3 | import reactor.core.publisher.Mono 4 | import reactor.core.publisher.Flux 5 | import org.springframework.data.mongodb.repository.Tailable 6 | import org.springframework.data.mongodb.repository.ReactiveMongoRepository 7 | import org.springframework.data.repository.reactive.ReactiveCrudRepository 8 | import pl.codeaddict.kafkademo.domain.FraudData 9 | 10 | 11 | interface FraudDataRepository : ReactiveCrudRepository { 12 | @Tailable 13 | fun findWithTailableCursorBy(): Flux 14 | 15 | fun findFraudById(id: String): Mono 16 | } -------------------------------------------------------------------------------- /kafka-demo/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | logging.level.org.springframework.data.mongodb=DEBUG 2 | spring.jackson.serialization.indent_output=true -------------------------------------------------------------------------------- /kafka-demo/src/test/kotlin/pl/codeaddict/kafkademo/KafkaDemoApplicationTests.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.kafkademo 2 | 3 | import org.junit.Test 4 | import org.junit.runner.RunWith 5 | import org.springframework.boot.test.context.SpringBootTest 6 | import org.springframework.test.context.junit4.SpringRunner 7 | 8 | @RunWith(SpringRunner::class) 9 | @SpringBootTest 10 | class KafkaDemoApplicationTests { 11 | 12 | @Test 13 | fun contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /minecraft-camera-drawing/README.md: -------------------------------------------------------------------------------- 1 | # Drawing camera frame in Minecraft using OpenCV and Raspberry Jam Mod 2 | 3 | Aim of the project is to play with Raspberry Jam Mod and draw picture captured with camera in Mincraft world. Whole idea is described in my blog post [Code-Addict](http://code-addict.pl/minecraft-opencv-face-draw/) 4 | 5 | ## Dependencies 6 | Project is very simple and uses following dependencies: 7 | - Python 3.5 8 | - NumPy 1.14.4 9 | - OpenCV 3.4.1 10 | - Raspberry Jam Mod 0.94 11 | - Minecraft 1.8 with Forge Mod 12 | 13 | ## Running 14 | 15 | Please see blog post for details 16 | 17 | ## Licence 18 | 19 | Project uses a MIT licence . 20 | 21 | MIT License 22 | 23 | Copyright (c) 2018 Michal Kostewicz 24 | 25 | Permission is hereby granted, free of charge, to any person obtaining a copy 26 | of this software and associated documentation files (the "Software"), to deal 27 | in the Software without restriction, including without limitation the rights 28 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 29 | copies of the Software, and to permit persons to whom the Software is 30 | furnished to do so, subject to the following conditions: 31 | 32 | The above copyright notice and this permission notice shall be included in all 33 | copies or substantial portions of the Software. 34 | 35 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 36 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 37 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 38 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 39 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 40 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 41 | SOFTWARE. 42 | -------------------------------------------------------------------------------- /permission-evaluator-boot2/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /permission-evaluator-boot2/src/main/java/com/example/permissionevaluatorboot2/ConfidentialDocument.java: -------------------------------------------------------------------------------- 1 | package com.example.permissionevaluatorboot2; 2 | 3 | 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.ToString; 7 | 8 | @ToString 9 | @AllArgsConstructor 10 | @Data 11 | public class ConfidentialDocument { 12 | private Integer id; 13 | private String fileName; 14 | private String owner; 15 | } 16 | -------------------------------------------------------------------------------- /permission-evaluator-boot2/src/main/java/com/example/permissionevaluatorboot2/ConfidentialDocumentsController.java: -------------------------------------------------------------------------------- 1 | package com.example.permissionevaluatorboot2; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.security.access.prepost.PreAuthorize; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.ui.Model; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RequestBody; 11 | 12 | import java.security.Principal; 13 | import java.util.Collection; 14 | 15 | @PreAuthorize("isAuthenticated()") 16 | @Controller 17 | public class ConfidentialDocumentsController { 18 | @Autowired 19 | private ConfidentialDocumentsRepository repository; 20 | 21 | @PostMapping("/document") 22 | String create(@RequestBody ConfidentialDocument documentsStream, Principal principal, final Model model) { 23 | final ConfidentialDocument document = 24 | this.repository.save(documentsStream, principal.getName()); 25 | model.addAttribute("document", document); 26 | return "document"; 27 | } 28 | 29 | @GetMapping("/") 30 | String list(final Model model) { 31 | final Collection documentsStream = 32 | this.repository.findAll(); 33 | model.addAttribute("documents", documentsStream); 34 | return "documents"; 35 | } 36 | 37 | @PreAuthorize("hasPermission(#id, 'ConfidentialDocument', 'read')") 38 | @GetMapping("/document/{id}") 39 | String findById(@PathVariable Integer id, final Model model) { 40 | final ConfidentialDocument document = 41 | this.repository.findOne(id); 42 | model.addAttribute("document", document); 43 | return "document"; 44 | } 45 | } -------------------------------------------------------------------------------- /permission-evaluator-boot2/src/main/java/com/example/permissionevaluatorboot2/ConfidentialDocumentsRepository.java: -------------------------------------------------------------------------------- 1 | package com.example.permissionevaluatorboot2; 2 | 3 | import java.util.Collection; 4 | 5 | public interface ConfidentialDocumentsRepository { 6 | ConfidentialDocument save(ConfidentialDocument document, String userLogin); 7 | 8 | Collection findAll(); 9 | 10 | ConfidentialDocument findOne(Integer documentId); 11 | } 12 | -------------------------------------------------------------------------------- /permission-evaluator-boot2/src/main/java/com/example/permissionevaluatorboot2/CustomPermissionEvaluator.java: -------------------------------------------------------------------------------- 1 | package com.example.permissionevaluatorboot2; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.security.access.PermissionEvaluator; 5 | import org.springframework.security.core.Authentication; 6 | import org.springframework.security.core.userdetails.UserDetails; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.io.Serializable; 10 | import java.util.Objects; 11 | 12 | @Component 13 | public class CustomPermissionEvaluator implements PermissionEvaluator { 14 | @Autowired 15 | private ConfidentialDocumentsRepository confidentialDocumentsRepository; 16 | 17 | @Override 18 | public boolean hasPermission(Authentication auth, Object targetDomainObject, Object permission) { 19 | // I will not implement this method just because I don't needed in this demo. 20 | throw new UnsupportedOperationException(); 21 | } 22 | 23 | @Override 24 | public boolean hasPermission(Authentication auth, Serializable targetId, String targetType, Object permission) { 25 | if ((auth == null) || (targetType == null) || !(permission instanceof String)) { 26 | return false; 27 | } 28 | ConfidentialDocument confidentialDocument = 29 | confidentialDocumentsRepository.findOne((Integer) targetId); 30 | String documentOwner = confidentialDocument.getOwner(); 31 | UserDetails userDetails = (UserDetails) auth.getPrincipal(); 32 | String principalLogin = userDetails.getUsername(); 33 | // if current user is owner of document permission is granted 34 | if (Objects.equals(documentOwner, principalLogin)) { 35 | return true; 36 | } 37 | return false; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /permission-evaluator-boot2/src/main/java/com/example/permissionevaluatorboot2/DummyConfidentialDocumentsRepository.java: -------------------------------------------------------------------------------- 1 | package com.example.permissionevaluatorboot2; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | import java.util.Collection; 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | @Service 10 | public class DummyConfidentialDocumentsRepository implements ConfidentialDocumentsRepository { 11 | private static final Map DATA = new HashMap<>(); 12 | 13 | static { 14 | DATA.put(1, new ConfidentialDocument(1, "file1.txt", "user1")); 15 | DATA.put(2, new ConfidentialDocument(2, "file2.txt", "user1")); 16 | DATA.put(3, new ConfidentialDocument(3, "file3.txt", "user2")); 17 | } 18 | 19 | @Override 20 | public ConfidentialDocument save(ConfidentialDocument document, String userLogin) { 21 | Integer maxId = DATA 22 | .entrySet() 23 | .stream() 24 | .map(x -> x.getKey()) 25 | .max(Integer::compareTo) 26 | .orElse(1); 27 | document.setId(maxId); 28 | DATA.put(maxId, document); 29 | return document; 30 | } 31 | 32 | @Override 33 | public Collection findAll() { 34 | return DATA.values(); 35 | } 36 | 37 | @Override 38 | public ConfidentialDocument findOne(Integer documentId) { 39 | ConfidentialDocument confidentialDocument = 40 | DATA.get(documentId); 41 | return confidentialDocument; 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /permission-evaluator-boot2/src/main/java/com/example/permissionevaluatorboot2/MethodSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.example.permissionevaluatorboot2; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler; 6 | import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler; 7 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 8 | import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration; 9 | 10 | @Configuration 11 | @EnableGlobalMethodSecurity(prePostEnabled = true) 12 | public class MethodSecurityConfig extends GlobalMethodSecurityConfiguration { 13 | @Bean 14 | public CustomPermissionEvaluator customPermissionEvaluator() { 15 | return new CustomPermissionEvaluator(); 16 | } 17 | 18 | @Override 19 | protected MethodSecurityExpressionHandler createExpressionHandler() { 20 | DefaultMethodSecurityExpressionHandler expressionHandler = 21 | new DefaultMethodSecurityExpressionHandler(); 22 | expressionHandler.setPermissionEvaluator(customPermissionEvaluator()); 23 | return expressionHandler; 24 | } 25 | } -------------------------------------------------------------------------------- /permission-evaluator-boot2/src/main/java/com/example/permissionevaluatorboot2/PermissionEvaluatorBoot2Application.java: -------------------------------------------------------------------------------- 1 | package com.example.permissionevaluatorboot2; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class PermissionEvaluatorBoot2Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(PermissionEvaluatorBoot2Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /permission-evaluator-boot2/src/main/java/com/example/permissionevaluatorboot2/WebSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.example.permissionevaluatorboot2; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.security.config.annotation.web.builders.WebSecurity; 7 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 8 | import org.springframework.security.core.userdetails.User; 9 | import org.springframework.security.core.userdetails.UserDetailsService; 10 | import org.springframework.security.provisioning.InMemoryUserDetailsManager; 11 | import org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler; 12 | 13 | @Configuration 14 | public class WebSecurityConfig extends WebSecurityConfigurerAdapter { 15 | @Autowired 16 | private CustomPermissionEvaluator customPermissionEvaluator; 17 | 18 | @Bean 19 | public UserDetailsService userDetailsService() { 20 | // Spring Boot 2 default PasswordEncoder is built as a DelegatingPasswordEncoder. Using 21 | // {noop} will force DelegatingPasswordEncoder to use NoOpPasswordEncoder 22 | InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager(); 23 | manager.createUser(User.withUsername("user1").password("{noop}pass").roles("USER") 24 | .build()); 25 | manager.createUser(User.withUsername("user2").password("{noop}pass").roles("USER").build()); 26 | return manager; 27 | } 28 | 29 | @Override 30 | public void configure(WebSecurity web) throws Exception { 31 | DefaultWebSecurityExpressionHandler handler = new DefaultWebSecurityExpressionHandler(); 32 | handler.setPermissionEvaluator(customPermissionEvaluator); 33 | web.expressionHandler(handler); 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /permission-evaluator-boot2/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/permission-evaluator-boot2/src/main/resources/application.properties -------------------------------------------------------------------------------- /permission-evaluator-boot2/src/main/resources/templates/document.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Custom Permission Evaluator + Thymeleaf demo 7 | 8 | 9 | 10 | 11 |

Confidential Document Details

12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /permission-evaluator-boot2/src/main/resources/templates/documents.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | Custom Permission Evaluator + Thymeleaf demo 9 | 10 | 11 | 12 | 13 |

Confidential Documents

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 |
IdFile Name
[[${doc.id}]][[${doc.fileName}]] 25 | 26 | 27 | 28 |
32 |
33 | Only for admin 34 |
35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /permission-evaluator-boot2/src/test/java/com/example/permissionevaluatorboot2/PermissionEvaluatorBoot2ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.permissionevaluatorboot2; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class PermissionEvaluatorBoot2ApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /reporting-services/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /reporting-services/README.md: -------------------------------------------------------------------------------- 1 | # Reporting Services URL Client Demo 2 | 3 | Aim of the project is to show how to connect and download report from Microsoft Reporting Services using URL request. Whole idea is described in my blog post [Code-Addict](http://code-addict.pl/reporting-services-rest-url-client/) 4 | 5 | ## Functionalities: 6 | 7 | - Connect to Reporting Services and download URL 8 | 9 | ## Dependencies 10 | Project is very simple and uses following dependencies: 11 | - Spring Boot 1.5 12 | - Apache HTTP Client 4.5 13 | - Lombok 1.16.20 14 | 15 | ## Running 16 | 17 | You can run application using maven `mvn spring-boot:run` command. Please see blog post and configure the appropriate program parameters. 18 | 19 | ## Testing 20 | There is a simple test class to show how URL Client works. 21 | 22 | ## Licence 23 | 24 | Project uses a MIT licence . 25 | 26 | MIT License 27 | 28 | Copyright (c) 2018 Michal Kostewicz 29 | 30 | Permission is hereby granted, free of charge, to any person obtaining a copy 31 | of this software and associated documentation files (the "Software"), to deal 32 | in the Software without restriction, including without limitation the rights 33 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 34 | copies of the Software, and to permit persons to whom the Software is 35 | furnished to do so, subject to the following conditions: 36 | 37 | The above copyright notice and this permission notice shall be included in all 38 | copies or substantial portions of the Software. 39 | 40 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 41 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 42 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 43 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 44 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 45 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 46 | SOFTWARE. 47 | -------------------------------------------------------------------------------- /reporting-services/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.example 7 | reporting-services 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | reporting-services 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.5.9.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-test 36 | test 37 | 38 | 39 | 40 | org.apache.httpcomponents 41 | httpclient 42 | 4.5.3 43 | 44 | 45 | 46 | org.projectlombok 47 | lombok 48 | 1.16.20 49 | provided 50 | 51 | 52 | 53 | 54 | 55 | 56 | org.springframework.boot 57 | spring-boot-maven-plugin 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /reporting-services/src/main/java/com/example/reportingservices/ReportingServicesApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.reportingservices; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class ReportingServicesApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(ReportingServicesApplication.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /reporting-services/src/main/java/com/example/reportingservices/ReportingServicesClient.java: -------------------------------------------------------------------------------- 1 | package com.example.reportingservices; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.http.HttpEntity; 5 | import org.springframework.http.HttpMethod; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.stereotype.Component; 8 | import org.springframework.web.client.RestTemplate; 9 | 10 | /** 11 | * Created by Michal Kostewicz on 23.01.18. 12 | */ 13 | @Component 14 | public class ReportingServicesClient { 15 | private static String FORMAT_URL_PART = "&rs:Format="; 16 | private static String REPORTING_SERVICES_URL = 17 | "http://ReportingServicesDomainOrUrl/ConfiguredUrl?"; 18 | @Autowired 19 | private RestTemplate restTemplate; 20 | 21 | 22 | public byte[] getReport(String reportName, String reportFormat) { 23 | HttpEntity requestEntity = new HttpEntity<>(null, null); 24 | String reportURL = REPORTING_SERVICES_URL + reportName + FORMAT_URL_PART + reportFormat; 25 | ResponseEntity responseEntity = restTemplate.exchange(reportURL, HttpMethod.GET, 26 | requestEntity, byte[].class); 27 | return responseEntity.getBody(); 28 | } 29 | 30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /reporting-services/src/main/java/com/example/reportingservices/ReportingServicesHTTPClientConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.example.reportingservices; 2 | 3 | import org.apache.http.auth.AuthScope; 4 | import org.apache.http.auth.NTCredentials; 5 | import org.apache.http.client.CredentialsProvider; 6 | import org.apache.http.impl.client.BasicCredentialsProvider; 7 | import org.apache.http.impl.client.CloseableHttpClient; 8 | import org.apache.http.impl.client.HttpClientBuilder; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; 12 | import org.springframework.web.client.RestTemplate; 13 | 14 | /** 15 | * Created by Michal Kostewicz on 23.01.18. 16 | */ 17 | @Configuration 18 | public class ReportingServicesHTTPClientConfiguration { 19 | 20 | @Bean 21 | public RestTemplate restTemplate() { 22 | RestTemplate template = new RestTemplate(); 23 | HttpComponentsClientHttpRequestFactory requestFactory = new 24 | HttpComponentsClientHttpRequestFactory(httpClient()); 25 | template.setRequestFactory(requestFactory); 26 | 27 | return template; 28 | } 29 | 30 | @Bean 31 | public CloseableHttpClient httpClient() { 32 | String user = "UserName"; 33 | String password = "userPass"; 34 | String domain = "USER_DOMAIN"; 35 | CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); 36 | credentialsProvider.setCredentials(AuthScope.ANY, 37 | new NTCredentials(user, password, null, domain)); 38 | 39 | CloseableHttpClient httpclient = HttpClientBuilder 40 | .create() 41 | .setDefaultCredentialsProvider(credentialsProvider) 42 | .build(); 43 | return httpclient; 44 | } 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /reporting-services/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/reporting-services/src/main/resources/application.properties -------------------------------------------------------------------------------- /reporting-services/src/test/java/com/example/reportingservices/ReportingServicesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.reportingservices; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class ReportingServicesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /reporting-services/src/test/java/com/example/reportingservices/ReportingServicesClientTest.java: -------------------------------------------------------------------------------- 1 | package com.example.reportingservices; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | import static org.junit.Assert.*; 10 | 11 | @RunWith(SpringRunner.class) 12 | @SpringBootTest 13 | public class ReportingServicesClientTest { 14 | @Autowired 15 | private ReportingServicesClient reportingServicesClient; 16 | 17 | @Test 18 | public void getReport_givenSimpleReportName_returnReportByteArray() throws Exception { 19 | //given 20 | String reportNamePath = "/RaportTestowy/Departments"; 21 | String reportFormat = "PDF"; 22 | 23 | //when 24 | byte[] reportByteArray = reportingServicesClient.getReport(reportNamePath, reportFormat); 25 | 26 | //then 27 | assertTrue(reportByteArray.length > 0); 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /siddhi-demo/HELP.md: -------------------------------------------------------------------------------- 1 | # Getting Started 2 | 3 | ### Reference Documentation 4 | For further reference, please consider the following sections: 5 | 6 | * [Official Gradle documentation](https://docs.gradle.org) 7 | * [Spring Boot Gradle Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.2.4.RELEASE/gradle-plugin/reference/html/) 8 | * [Coroutines section of the Spring Framework Documentation](https://docs.spring.io/spring/docs/5.2.3.RELEASE/spring-framework-reference/languages.html#coroutines) 9 | * [Spring for RabbitMQ](https://docs.spring.io/spring-boot/docs/2.2.4.RELEASE/reference/htmlsingle/#boot-features-amqp) 10 | 11 | ### Guides 12 | The following guides illustrate how to use some features concretely: 13 | 14 | * [Messaging with RabbitMQ](https://spring.io/guides/gs/messaging-rabbitmq/) 15 | 16 | ### Additional Links 17 | These additional references should also help you: 18 | 19 | * [Gradle Build Scans – insights for your project's build](https://scans.gradle.com#gradle) 20 | 21 | -------------------------------------------------------------------------------- /siddhi-demo/docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | siddhi-demo-rabbit-mq: 4 | container_name: siddhi-demo-rabbit-mq 5 | image: rabbitmq:3-management 6 | ports: 7 | - "15672:15672" 8 | - "5672:5672" 9 | siddhi-demo-siddhi-core: 10 | container_name: siddhi-demo-siddhi-core 11 | image: siddhiio/siddhi-runner-alpine 12 | ports: 13 | - "8006:8006" 14 | volumes: 15 | - ./siddhi/jobs:/apps 16 | command: -Dapps=/apps/ 17 | siddhi-demo-app: 18 | container_name: siddhi-demo-app 19 | image: pl.codeaddict/siddhidemoclient:0.0.1-SNAPSHOT 20 | ports: 21 | - "8080:8080" 22 | -------------------------------------------------------------------------------- /siddhi-demo/docker/run.sh: -------------------------------------------------------------------------------- 1 | docker-compose up --force-recreate 2 | -------------------------------------------------------------------------------- /siddhi-demo/docker/siddhi/jobs/SIMPLE_ALERT_FILTER.siddhi: -------------------------------------------------------------------------------- 1 | @App:name('SIMPLE_ALERT_FILTER') 2 | 3 | @info(name = 'stream from messages queue') 4 | @source(type ='rabbitmq', 5 | uri = 'amqp://guest:guest@siddhi-demo-rabbit-mq:5672', 6 | routing.key= 'messages', 7 | exchange.name= 'direct', 8 | queue.name= 'messages', 9 | @map(type='json')) 10 | define stream MessageStream (msg string); 11 | 12 | @sink(type = 'log') 13 | @sink(type ='rabbitmq', 14 | uri = 'amqp://guest:guest@siddhi-demo-rabbit-mq:5672', 15 | routing.key= 'alerts', 16 | exchange.name= 'direct_alerts', 17 | queue.name= 'alerts', 18 | @map(type='json')) 19 | define stream AlertStream (msg string, msg_count long); 20 | 21 | @info(name = 'count messages that equals alert in batches in 30 seconds window') 22 | from MessageStream#window.timeBatch(30 sec, 0, true) 23 | select msg, count() as msg_count 24 | group by msg 25 | having msg_count > 3 and msg == "alert" 26 | insert into AlertStream; 27 | -------------------------------------------------------------------------------- /siddhi-demo/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/siddhi-demo/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /siddhi-demo/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /siddhi-demo/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "siddhidemoclient" 2 | -------------------------------------------------------------------------------- /siddhi-demo/src/main/kotlin/pl/codeaddict/siddhidemoclient/MessageQueueController.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.siddhidemoclient 2 | 3 | import org.springframework.web.bind.annotation.PostMapping 4 | import org.springframework.web.bind.annotation.RequestBody 5 | import org.springframework.web.bind.annotation.RestController 6 | 7 | @RestController 8 | class MessageQueueController( 9 | private val rabbitMQSender: RabbitMQSenderService) { 10 | 11 | @PostMapping(value = ["/messages"]) 12 | fun addMessageToQueue(@RequestBody msg: String): String { 13 | rabbitMQSender.send(msg); 14 | return "Message sent to the RabbitMQ Successfully"; 15 | } 16 | } -------------------------------------------------------------------------------- /siddhi-demo/src/main/kotlin/pl/codeaddict/siddhidemoclient/RabbitMQAlarmReceiver.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.siddhidemoclient 2 | 3 | import org.springframework.amqp.rabbit.annotation.Exchange 4 | import org.springframework.amqp.rabbit.annotation.Queue 5 | import org.springframework.amqp.rabbit.annotation.QueueBinding 6 | import org.springframework.amqp.rabbit.annotation.RabbitListener 7 | import org.springframework.stereotype.Component 8 | 9 | @Component 10 | class RabbitMQAlarmReceiver { 11 | 12 | @RabbitListener(bindings = [QueueBinding(value = Queue(value = "\${siddhidemo.rabbitmq.alertsQueue}", durable = "true"), 13 | exchange = Exchange(value = "\${siddhidemo.rabbitmq.alertsExchange}", durable = "false", ignoreDeclarationExceptions = "true"), 14 | key = ["\${siddhidemo.rabbitmq.alertsRoutingKey}"])] 15 | ) 16 | fun receiver(`in`: String) { 17 | println(" [x] Received '$`in`'") 18 | } 19 | } -------------------------------------------------------------------------------- /siddhi-demo/src/main/kotlin/pl/codeaddict/siddhidemoclient/RabbitMQConfig.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.siddhidemoclient 2 | 3 | import org.springframework.amqp.core.Queue 4 | import org.springframework.beans.factory.annotation.Value 5 | import org.springframework.context.annotation.Bean 6 | import org.springframework.context.annotation.Configuration 7 | 8 | @Configuration 9 | class RabbitMQConfig { 10 | @Value("\${siddhidemo.rabbitmq.messageQueue}") 11 | val messageQueue: String? = null 12 | 13 | @Bean 14 | fun queue(): Queue { 15 | return Queue(messageQueue, false); 16 | } 17 | } -------------------------------------------------------------------------------- /siddhi-demo/src/main/kotlin/pl/codeaddict/siddhidemoclient/RabbitMQSenderService.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.siddhidemoclient 2 | 3 | import org.springframework.amqp.core.Queue 4 | import org.springframework.amqp.rabbit.core.RabbitTemplate 5 | import org.springframework.stereotype.Service 6 | 7 | 8 | @Service 9 | class RabbitMQSenderService( 10 | private val rabbitTemplate: RabbitTemplate, 11 | private val queue: Queue) { 12 | 13 | fun send(message: String) { 14 | rabbitTemplate.convertAndSend(queue.name, message); 15 | println(" [x] Sent '$message'"); 16 | } 17 | } -------------------------------------------------------------------------------- /siddhi-demo/src/main/kotlin/pl/codeaddict/siddhidemoclient/SiddhidemoclientApplication.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.siddhidemoclient 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication 4 | import org.springframework.boot.runApplication 5 | 6 | @SpringBootApplication 7 | class SiddhidemoclientApplication 8 | 9 | fun main(args: Array) { 10 | runApplication(*args) 11 | } 12 | -------------------------------------------------------------------------------- /siddhi-demo/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | siddhidemo.rabbitmq: 2 | messageQueue: 'messages' 3 | alertsQueue: 'alerts' 4 | alertsRoutingKey: 'alerts' 5 | alertsExchange: 'direct_alerts' 6 | spring: 7 | rabbitmq: 8 | host: siddhi-demo-rabbit-mq 9 | port: 5672 10 | username: guest 11 | password: guest 12 | 13 | logging.level.root: DEBUG -------------------------------------------------------------------------------- /siddhi-demo/src/main/resources/static/message.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 |
9 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /siddhi-demo/src/test/kotlin/pl/codeaddict/siddhidemoclient/SiddhidemoclientApplicationTests.kt: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.siddhidemoclient 2 | 3 | import org.junit.jupiter.api.Test 4 | import org.springframework.boot.test.context.SpringBootTest 5 | 6 | @SpringBootTest 7 | class SiddhidemoclientApplicationTests { 8 | 9 | @Test 10 | fun contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spockapidocks/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/** 6 | !**/src/test/** 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | out/ 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | 31 | ### VS Code ### 32 | .vscode/ 33 | -------------------------------------------------------------------------------- /spockapidocks/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.2.2.RELEASE' 3 | id 'io.spring.dependency-management' version '1.0.8.RELEASE' 4 | id 'org.asciidoctor.convert' version '1.6.1' 5 | id 'groovy' 6 | } 7 | 8 | group = 'pl.codeaddict' 9 | version = '0.0.1-SNAPSHOT' 10 | sourceCompatibility = '11' 11 | 12 | repositories { 13 | mavenCentral() 14 | } 15 | 16 | ext { 17 | snippetsDir = "$buildDir/generated-snippets" 18 | spockVersion = '1.3-groovy-2.5' 19 | springRestDocsVersion = '2.0.4.RELEASE' 20 | lombokVersion = '1.18.10' 21 | } 22 | 23 | dependencies { 24 | implementation 'org.springframework.boot:spring-boot-starter-web' 25 | 26 | compileOnly "org.projectlombok:lombok:$lombokVersion" 27 | 28 | testImplementation "org.spockframework:spock-core:$spockVersion" 29 | testImplementation "org.spockframework:spock-spring:$spockVersion" 30 | testImplementation('org.springframework.boot:spring-boot-starter-test') { 31 | exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' 32 | } 33 | asciidoctor "org.springframework.restdocs:spring-restdocs-asciidoctor:$springRestDocsVersion" 34 | testImplementation("org.springframework.restdocs:spring-restdocs-restassured:$springRestDocsVersion") { 35 | exclude group: 'com.sun.xml.bind', module: 'jaxb-osgi' 36 | } 37 | 38 | annotationProcessor "org.projectlombok:lombok:$lombokVersion" 39 | } 40 | 41 | test { 42 | outputs.dir snippetsDir 43 | } 44 | 45 | task copyAsciidocTemplate(type: Copy) { 46 | dependsOn test 47 | from "src/docs/asciidoc" 48 | into snippetsDir 49 | } 50 | 51 | asciidoctor { 52 | dependsOn copyAsciidocTemplate 53 | sourceDir snippetsDir 54 | doLast { 55 | copy { 56 | from "$buildDir/asciidoc/html5" 57 | into "$buildDir/resources/main/public/docs" 58 | include "**/*.html" 59 | } 60 | } 61 | } 62 | 63 | bootRun.dependsOn(asciidoctor) -------------------------------------------------------------------------------- /spockapidocks/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/k0staa/Code-Addict-Repos/9d6af1b13a2197a26f27a56b2136142b4d433494/spockapidocks/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /spockapidocks/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /spockapidocks/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'spockapidocs' 2 | -------------------------------------------------------------------------------- /spockapidocks/src/docs/asciidoc/api.adoc: -------------------------------------------------------------------------------- 1 | = Blog demo API 2 | 3 | == Login 4 | 5 | operation::login[snippets="curl-request,response-headers"] 6 | 7 | == Add Post 8 | 9 | operation::add_post[snippets="curl-request,request-headers,request-body,request-fields,response-body,response-fields"] 10 | 11 | == Modify Post 12 | 13 | operation::modify_post[snippets="curl-request,path-parameters,request-headers,request-body,request-fields"] 14 | 15 | == Get Post 16 | 17 | operation::get_post[snippets="curl-request,path-parameters,request-headers,response-body,response-fields"] -------------------------------------------------------------------------------- /spockapidocks/src/main/java/pl/codeaddict/spockapidocs/AddPostRequest.java: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.spockapidocs; 2 | 3 | import lombok.Data; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Value; 6 | 7 | @Value 8 | class AddPostRequest { 9 | private String text = null; 10 | } 11 | -------------------------------------------------------------------------------- /spockapidocks/src/main/java/pl/codeaddict/spockapidocs/AddPostResponse.java: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.spockapidocs; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | class AddPostResponse { 7 | private String id; 8 | } 9 | -------------------------------------------------------------------------------- /spockapidocks/src/main/java/pl/codeaddict/spockapidocs/BlogApiController.java: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.spockapidocs; 2 | 3 | import org.springframework.http.ResponseEntity; 4 | import org.springframework.web.bind.annotation.*; 5 | 6 | @RestController 7 | @RequestMapping("/api") 8 | public class BlogApiController { 9 | 10 | @PostMapping("/login") 11 | public ResponseEntity login(LoginRequest loginRequest) { 12 | return ResponseEntity.ok().header("Set-Auth-Token", "TOKEN").build(); 13 | } 14 | 15 | @PostMapping("/post") 16 | public ResponseEntity addPost(AddPostRequest addPostRequest) { 17 | return ResponseEntity.ok().body(new AddPostResponse("111-333")); 18 | } 19 | 20 | @PutMapping("/post/{id}") 21 | public ResponseEntity modifyPost(@PathVariable String id, ModifyPostRequest modifyPostRequest) { 22 | return ResponseEntity.ok().build(); 23 | } 24 | 25 | @GetMapping("/post/{id}") 26 | public ResponseEntity getPostDetails(@PathVariable String id) { 27 | return ResponseEntity.ok().body(new GetPostDetailsResponse("111-333","Blog post text")); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /spockapidocks/src/main/java/pl/codeaddict/spockapidocs/GetPostDetailsResponse.java: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.spockapidocs; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | class GetPostDetailsResponse { 7 | private String id; 8 | private String text; 9 | } 10 | -------------------------------------------------------------------------------- /spockapidocks/src/main/java/pl/codeaddict/spockapidocs/LoginRequest.java: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.spockapidocs; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | class LoginRequest { 7 | private String username; 8 | private String password; 9 | } 10 | -------------------------------------------------------------------------------- /spockapidocks/src/main/java/pl/codeaddict/spockapidocs/ModifyPostRequest.java: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.spockapidocs; 2 | 3 | import lombok.Value; 4 | 5 | @Value 6 | public class ModifyPostRequest { 7 | private String text; 8 | } 9 | -------------------------------------------------------------------------------- /spockapidocks/src/main/java/pl/codeaddict/spockapidocs/SpockApidDocsApplication.java: -------------------------------------------------------------------------------- 1 | package pl.codeaddict.spockapidocs; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpockApidDocsApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpockApidDocsApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spockapidocks/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | --------------------------------------------------------------------------------