├── .github └── workflows │ ├── build.yml │ └── maven-settings.xml ├── .gitignore ├── LICENSE.txt ├── README.adoc ├── install.sh ├── pom.xml ├── spring-retrosocket-docs ├── pom.xml └── src │ └── main │ └── asciidoc │ └── index.adoc ├── spring-retrosocket-samples ├── hello-client │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ ├── maven-wrapper.jar │ │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── test │ │ │ │ └── client │ │ │ │ └── TestApplication.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── test │ │ └── TestApplicationTests.java └── hello-service │ ├── .gitignore │ ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── test │ │ │ └── service │ │ │ └── TestApplication.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── example │ └── test │ └── TestApplicationTests.java ├── spring-retrosocket ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── retrosocket │ │ │ ├── EnableRSocketClients.java │ │ │ ├── RSocketClient.java │ │ │ ├── RSocketClientAutoConfiguration.java │ │ │ ├── RSocketClientBuilder.java │ │ │ ├── RSocketClientFactoryBean.java │ │ │ ├── RSocketClientsRegistrar.java │ │ │ └── nativex │ │ │ └── RetrosocketBeanFactoryNativeConfigurationProcessor.java │ └── resources │ │ └── META-INF │ │ └── spring.factories │ └── test │ ├── java │ └── org │ │ └── springframework │ │ └── retrosocket │ │ ├── metadata │ │ ├── Constants.java │ │ ├── GreetingClient.java │ │ ├── GreetingResponse.java │ │ ├── GreetingsController.java │ │ ├── RSocketClientConfiguration.java │ │ ├── RSocketClientTest.java │ │ └── RSocketServerConfiguration.java │ │ ├── qualifiers │ │ ├── Constants.java │ │ ├── GreetingQualifier.java │ │ ├── GreetingServiceConfiguration.java │ │ ├── PeopleServerConfiguration.java │ │ ├── PersonQualifier.java │ │ ├── RSocketClientConfiguration.java │ │ ├── RSocketQualifierClientTest.java │ │ ├── greetings │ │ │ ├── Greeting.java │ │ │ ├── GreetingClient.java │ │ │ └── GreetingsController.java │ │ └── people │ │ │ ├── Person.java │ │ │ ├── PersonClient.java │ │ │ └── PersonController.java │ │ └── simple │ │ ├── GreetingClient.java │ │ ├── GreetingResponse.java │ │ ├── GreetingsController.java │ │ ├── RSocketClientConfiguration.java │ │ ├── RSocketClientTest.java │ │ └── RSocketServerConfiguration.java │ └── resources │ ├── application-service.properties │ └── application.properties ├── test_aot.sh └── test_native.sh /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Spring Retrosocket build 2 | 3 | 4 | env: 5 | CI_USERNAME: ${{ secrets.CI_USERNAME }} 6 | CI_PASSWORD: ${{ secrets.CI_PASSWORD }} 7 | GH_PASSWORD: ${{ secrets.GH_PASSWORD }} 8 | GH_USERNAME: ${{ secrets.GH_USERNAME }} 9 | 10 | on: 11 | push: 12 | branches: [ main ] 13 | pull_request: 14 | branches: [ main ] 15 | 16 | jobs: 17 | build: 18 | runs-on: ubuntu-latest 19 | steps: 20 | 21 | - uses: actions/checkout@v2 22 | 23 | - name: Set up JDK 8 24 | uses: actions/setup-java@v1 25 | with: 26 | java-version: 8 27 | 28 | - name: Cache Maven packages 29 | uses: actions/cache@v1 30 | with: 31 | path: ~/.m2/repository 32 | key: ${{ runner.os }}-m2 33 | restore-keys: ${{ runner.os }}-m2 34 | 35 | - name: Build the application and deploy 36 | run: mvn -Pspring,docs -Dasciidoctor.attributes="foo=baz foo2=baz2" -s .github/workflows/maven-settings.xml deploy 37 | 38 | - name: Deploy the documentation to Github Pages 39 | run: | 40 | GHP=$HOME/ghp 41 | GD=$HOME/gd 42 | rm -rf $GHP 43 | rm -rf $GD 44 | git config --global user.email "retrosocket-docs@spring.io" 45 | git config --global user.name "Retrosocket Docs" 46 | cp -r spring-retrosocket-docs/target/generated-docs/ $GD 47 | git clone https://${GH_USERNAME}:${GH_PASSWORD}@github.com/spring-projects-experimental/spring-retrosocket.git -b gh-pages $GHP 48 | cp -r $GD/* $GHP 49 | cd $GHP 50 | git add * 51 | git commit -am "adding docs..." 52 | git push origin gh-pages 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /.github/workflows/maven-settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | repo.spring.io 6 | ${env.CI_USERNAME} 7 | ${env.CI_PASSWORD} 8 | 9 | 10 | 11 | 12 | 18 | spring 19 | 20 | true 21 | 22 | 23 | 24 | spring-snapshots 25 | Spring Snapshots 26 | https://repo.spring.io/libs-snapshot-local 27 | 28 | true 29 | 30 | 31 | 32 | spring-milestones 33 | Spring Milestones 34 | https://repo.spring.io/libs-milestone-local 35 | 36 | false 37 | 38 | 39 | 40 | spring-releases 41 | Spring Releases 42 | https://repo.spring.io/release 43 | 44 | false 45 | 46 | 47 | 48 | 49 | 50 | spring-snapshots 51 | Spring Snapshots 52 | https://repo.spring.io/libs-snapshot-local 53 | 54 | true 55 | 56 | 57 | 58 | spring-milestones 59 | Spring Milestones 60 | https://repo.spring.io/libs-milestone-local 61 | 62 | false 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | = Spring Retrosocket 2 | 3 | image:https://github.com/spring-projects-experimental/spring-retrosocket/workflows/Spring%20Retrosocket%20build/badge.svg["Build Status"] 4 | 5 | Spring Retrosocket aims to provide a Feign-like or Retrofit-like experience for declarative http://RSocket.io[RSocket]-based clients. 6 | 7 | == Documentation 8 | 9 | You can find the much more complete https://spring-projects-experimental.github.io/spring-retrosocket/[documentation here]. 10 | 11 | == GitHub issues 12 | 13 | We choose not to use GitHub issues for general usage questions and support, preferring to use Issues solely to track bugs and enhancements. If you have a general usage question, please do not open a http://github.com/spring-projects-experimental/spring-retrosocket[GitHub issue], but use one of the other channels described below. 14 | 15 | If you are reporting a bug, please help speed up problem diagnosis by providing as much information as possible. Ideally, that would include a small sample project that reproduces the problem. 16 | 17 | == License 18 | 19 | This code is licensed under the https://www.apache.org/licenses/LICENSE-2.0[Apache License v2.0] 20 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | mvn -Pspring -DskipTests=true clean install -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | org.springframework.retrosocket 7 | spring-retrosocket-parent 8 | 0.0.1-SNAPSHOT 9 | pom 10 | 11 | 12 | https://github.com/spring-projects-experimental/spring-retrosocket 13 | 14 | 15 | scm:git:git://github.com/spring-projects-experimental/spring-retrosocket.git 16 | 17 | 18 | scm:git:ssh://git@github.com/spring-projects-experimental/spring-retrosocket.git 19 | 20 | 21 | 22 | 23 | Josh Long 24 | josh@joshlong.com 25 | http://spring.io/team/jlong 26 | PST 27 | 28 | 29 | 30 | Pivotal Software, Inc. 31 | https://www.spring.io 32 | 33 | 34 | 35 | Apache License, Version 2.0 36 | https://www.apache.org/licenses/LICENSE-2.0 37 | 38 | Copyright 2020 the original author or authors. 39 | 40 | Licensed under the Apache License, Version 2.0 (the "License"); 41 | you may not use this file except in compliance with the License. 42 | You may obtain a copy of the License at 43 | 44 | https://www.apache.org/licenses/LICENSE-2.0 45 | 46 | Unless required by applicable law or agreed to in writing, 47 | software 48 | distributed under the License is distributed on an "AS IS" 49 | BASIS, 50 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 51 | implied. 52 | 53 | See the License for the specific language governing permissions 54 | and 55 | limitations under the License. 56 | 57 | 58 | 59 | 60 | 61 | 62 | spring 63 | 64 | 65 | spring-snapshots 66 | Spring Snapshots 67 | https://repo.spring.io/libs-snapshot-local 68 | 69 | true 70 | 71 | 72 | false 73 | 74 | 75 | 76 | spring-milestones 77 | Spring Milestones 78 | https://repo.spring.io/libs-milestone-local 79 | 80 | false 81 | 82 | 83 | 84 | spring-releases 85 | Spring Releases 86 | https://repo.spring.io/release 87 | 88 | false 89 | 90 | 91 | 92 | 93 | 94 | spring-snapshots 95 | Spring Snapshots 96 | https://repo.spring.io/libs-snapshot-local 97 | 98 | true 99 | 100 | 101 | false 102 | 103 | 104 | 105 | spring-releases 106 | Spring Releases 107 | https://repo.spring.io/release 108 | 109 | false 110 | 111 | 112 | 113 | spring-milestones 114 | Spring Milestones 115 | https://repo.spring.io/libs-milestone-local 116 | 117 | false 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | central 126 | 127 | 128 | 129 | org.apache.maven.plugins 130 | maven-gpg-plugin 131 | 3.0.1 132 | 133 | 134 | sign-artifacts 135 | verify 136 | 137 | sign 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | https://repo.spring.io/libs-release-local 147 | 148 | 149 | 150 | 151 | 152 | milestone 153 | 154 | 155 | repo.spring.io 156 | Spring Milestone Repository 157 | https://repo.spring.io/libs-milestone-local 158 | 159 | 160 | 161 | 162 | https://repo.spring.io/libs-milestone-local 163 | 164 | 165 | 166 | 167 | 168 | 169 | https://github.com/spring-projects-experimental/spring-retrosocket 170 | 171 | 177 | 178 | sonatype-nexus-staging 179 | Nexus Release Repository 180 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 181 | 182 | 183 | 184 | repo.spring.io 185 | Spring Snapshot Repository 186 | https://repo.spring.io/libs-snapshot-local 187 | 188 | 189 | 190 | 191 | org.springframework.boot 192 | spring-boot-starter 193 | 194 | 195 | org.junit.jupiter 196 | junit-jupiter 197 | 198 | 199 | 200 | 0.2.1.RELEASE 201 | UTF-8 202 | 1.6 203 | 1.8 204 | 1.8 205 | 2.6.1 206 | 5.8.1 207 | 0.11.0 208 | 209 | 210 | spring-retrosocket 211 | spring-retrosocket-docs 212 | 213 | 214 | 215 | 216 | 217 | 218 | org.junit.jupiter 219 | junit-jupiter 220 | ${junit-jupiter.version} 221 | 222 | 223 | org.springframework.boot 224 | spring-boot-dependencies 225 | ${spring-boot.version} 226 | pom 227 | import 228 | 229 | 230 | 231 | org.springframework.experimental 232 | spring-native 233 | ${spring-native.version} 234 | 235 | 236 | org.springframework.experimental 237 | spring-aot 238 | ${spring-native.version} 239 | 240 | 241 | 242 | 243 | 244 | 245 | 264 | 265 | org.apache.maven.plugins 266 | maven-surefire-plugin 267 | 2.22.2 268 | 269 | 270 | io.spring.javaformat 271 | spring-javaformat-maven-plugin 272 | 0.0.23 273 | 274 | 275 | 276 | 277 | 278 | -------------------------------------------------------------------------------- /spring-retrosocket-docs/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | 7 | org.springframework.retrosocket 8 | spring-retrosocket-parent 9 | 0.0.1-SNAPSHOT 10 | ../pom.xml 11 | 12 | 13 | spring-retrosocket-docs 14 | pom 15 | 16 | 17 | docs 18 | 19 | 20 | io.spring.docresources 21 | spring-doc-resources 22 | ${docs.resources.version} 23 | zip 24 | true 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.apache.maven.plugins 32 | maven-dependency-plugin 33 | 34 | 35 | unpack-doc-resources 36 | 37 | unpack-dependencies 38 | 39 | generate-resources 40 | false 41 | 42 | io.spring.docresources 43 | spring-doc-resources 44 | zip 45 | true 46 | ${project.build.directory}/refdocs/ 47 | 48 | 49 | 50 | 51 | 52 | org.apache.maven.plugins 53 | maven-resources-plugin 54 | 55 | 56 | copy-asciidoc-resources 57 | generate-resources 58 | false 59 | 60 | copy-resources 61 | 62 | 63 | ${project.build.directory}/refdocs/ 64 | 65 | 66 | src/main/asciidoc 67 | false 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | org.asciidoctor 76 | asciidoctor-maven-plugin 77 | 1.5.6 78 | 79 | 80 | org.asciidoctor 81 | asciidoctorj-pdf 82 | 1.5.0-alpha.15 83 | 84 | 85 | 86 | 87 | html 88 | generate-resources 89 | false 90 | 91 | process-asciidoc 92 | 93 | 94 | 95 | 96 | 97 | html5 98 | highlight.js 99 | 100 | 101 | 102 | ${project.version} 103 | ${spring-boot.version} 104 | 105 | 106 | 107 | shared 108 | css/ 109 | spring.css 110 | true 111 | font 112 | js/highlight 113 | github 114 | true 115 | 116 | 117 | 118 | 119 | 120 | pdf 121 | generate-resources 122 | false 123 | 124 | process-asciidoc 125 | 126 | 127 | pdf 128 | coderay 129 | 130 | 131 | 132 | 133 | 134 | ${project.build.directory}/refdocs/ 135 | index.adoc 136 | book 137 | 138 | 139 | ${project.version} 140 | ${spring-boot.version} 141 | 142 | 143 | 144 | ${project.version} 145 | ${project.name} 146 | ${project.version} 147 | true 148 | 4 149 | true 150 | ${project.basedir} 151 | 152 | 153 | 154 | 155 | 156 | org.apache.maven.plugins 157 | maven-antrun-plugin 158 | 159 | 160 | package-and-attach-docs-zip 161 | 162 | run 163 | 164 | package 165 | false 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | org.codehaus.mojo 178 | build-helper-maven-plugin 179 | 1.10 180 | 181 | 182 | attach-zip 183 | 184 | attach-artifact 185 | 186 | 187 | 188 | 189 | 190 | ${project.build.directory}/${project.artifactId}-${project.version}.zip 191 | 192 | zip 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | -------------------------------------------------------------------------------- /spring-retrosocket-docs/src/main/asciidoc/index.adoc: -------------------------------------------------------------------------------- 1 | :toc: left 2 | :toclevels: 4 3 | :numbered: 4 | :icons: font 5 | :hide-uri-scheme: 6 | :project-home: https://github.com/spring-projects-experimental/spring-retrosocket 7 | :github-repository: https://github.com/spring-projects-experimental/spring-retrosocket 8 | 9 | 10 | = Spring Retrosocket {project-version} Reference Guide 11 | Josh Long ; Mario Gray 12 | 13 | 14 | [[introduction]] 15 | Spring Retrosocket aims to provide a Feign-like or Retrofit-like experience for declarative http://rsocket.io[RSocket]-based clients. This guide introduces Retrosocket functionality and their uses. 16 | 17 | [[building-the-code]] 18 | == Build the Code 19 | 20 | You can find the {github-repository}[code on Github]. 21 | 22 | Build the code: 23 | 24 | 25 | ```shell 26 | mvn clean install 27 | ``` 28 | 29 | It's early days yet, so there may be some build breaks. Skip the tests if needed: 30 | 31 | 32 | ```shell 33 | mvn -DskipTests=true clean install 34 | ``` 35 | 36 | 37 | [[your-build]] 38 | == Configuring Your Build 39 | 40 | 41 | The easiest way might be to go to the Spring Initializr and generate a new project. Make sure that you specify the `spring-milestones` or `spring-snapshots` repositories defined in your build. Add the following to your build, taking care to replace `$PROJECT-VERSION` with the correct version of the library. The latest is **{project-version}**. This version has been built against Spring Boot **{spring-boot-version}**. 42 | 43 | 44 | [source,xml,indent=0] 45 | ---- 46 | 47 | org.springframework.retrosocket 48 | spring-retrosocket 49 | $PROJECT-VERSION 50 | 51 | ---- 52 | 53 | If you have an existing build, make sure that you have the `spring-milestones` or `spring-snapshots` Spring repositories. 54 | 55 | 56 | [source,xml,indent=0] 57 | ---- 58 | 59 | 60 | spring-milestones 61 | Spring Milestones 62 | https://repo.spring.io/milestone 63 | 64 | 65 | spring-snapshots 66 | Spring Snapshots 67 | https://repo.spring.io/snapshot 68 | 69 | true 70 | 71 | 72 | 73 | ---- 74 | 75 | 76 | [[basic-usage]] 77 | == Basic Usage 78 | 79 | 80 | In your Java code, you need to enable the RSocket client support. Use the `@EnableRSocketClient` annotation. You'll also need to define an `RSocketRequester` bean. 81 | 82 | 83 | [source,java,indent=0] 84 | ---- 85 | 86 | @SpringBootApplication 87 | @EnableRSocketClient 88 | class RSocketClientApplication { 89 | 90 | @Bean 91 | RSocketRequester requester(RSocketRequester.Builder builder) { 92 | return builder.connectTcp("localhost", 8888).block(); 93 | } 94 | } 95 | ---- 96 | 97 | then, define an RSocket client interface, like this: 98 | 99 | 100 | [source,java,indent=0] 101 | ---- 102 | 103 | @RSocketClient 104 | interface GreetingClient { 105 | 106 | @MessageMapping("supplier") 107 | Mono greet(); 108 | 109 | @MessageMapping("request-response") 110 | Mono requestResponse(Mono name); 111 | 112 | @MessageMapping("fire-and-forget") 113 | Mono fireAndForget(Mono name); 114 | 115 | @MessageMapping("destination.variables.and.payload.annotations.{name}.{age}") 116 | Mono greetMonoNameDestinationVariable( 117 | @DestinationVariable("name") String name, 118 | @DestinationVariable("age") int age, 119 | @Payload Mono payload); 120 | } 121 | 122 | ---- 123 | 124 | If you invoke methods on this interface, it'll, in turn, invoke endpoints using the configured `RSocketRequester` for you, turning destination variables into route variables and turning your payload into the data for the request. 125 | 126 | [[mapping-headers-to-metadata]] 127 | == Mapping Headers (RSocket metadata) to the RSocket request 128 | 129 | You can map `@Header` elements to parameters in the method invocation. The header parameters get sent as composite RSocket metadata. Normal invocations of RSocket metadata would require two parts - a mime type and a value that can be encoded. The encoding is a separate issue - Spring ships with a ton of encoders/decoders out of the box, but by default, Spring Framework's built-in support uses something called `CBOR`. There is still the question of how to communicate the mime-type. We expect the mime-type as the `value()` attribute for the `@Header` annotation. Thus: 130 | 131 | [source,java,indent=0] 132 | ---- 133 | import com.joshlong.rsocket.client.RSocketClient; 134 | import org.springframework.messaging.handler.annotation.Header; 135 | import org.springframework.messaging.handler.annotation.MessageMapping; 136 | import org.springframework.messaging.handler.annotation.Payload; 137 | import reactor.core.publisher.Mono; 138 | 139 | @RSocketClient 140 | interface GreetingClient { 141 | 142 | @MessageMapping("greetings") 143 | Mono greet(@Header( "messaging/x.bootiful.client-id") String clientId, @Payload Mono name); 144 | 145 | } 146 | ---- 147 | 148 | This method definition should line up with the expectations for composite metadata on the responder side, of course. 149 | 150 | [[multiple-rsocket-requesters]] 151 | == Pairing `RSocketRequesters` to `@RSocketClient` interfaces 152 | 153 | You can annotate your interfaces with a `@Qualifier` annotation (or a meta-annotated qualifier of your own making ) and then annotate an `RSocketRequester`. This module will use that `RSocketRequester` when servicing methods on a particular interface. 154 | 155 | The following demonstrates the concept in action. RSocket connections are stateful. Once they've connected, they stay connected, and all subsequent interactions are assumed to be against the already established connection. Therefore, each `RSocketRequester` talks to a different logical (and physical) service, unlike, e.g., a `WebClient`, which may you may use to talk to any arbitrary host and port. 156 | 157 | [source,java,indent=0] 158 | ---- 159 | 160 | @RSocketClient 161 | @Qualifier(Constants.QUALIFIER_2) 162 | interface GreetingClient { 163 | 164 | @MessageMapping("greetings-with-name") 165 | Mono greet(Mono name); 166 | 167 | } 168 | 169 | @RSocketClient 170 | @PersonQualifier 171 | interface PersonClient { 172 | 173 | @MessageMapping("people") 174 | Flux people(); 175 | 176 | } 177 | 178 | @EnableRSocketClients 179 | @SpringBootApplication 180 | class RSocketClientConfiguration { 181 | 182 | @Bean 183 | @PersonQualifier // meta-annotation 184 | // @Qualifier(Constants.QUALIFIER_1) 185 | RSocketRequester one(@Value("${" + Constants.QUALIFIER_1 + ".port}") int port, RSocketRequester.Builder builder) { 186 | return builder.connectTcp("localhost", port).block(); 187 | } 188 | 189 | 190 | @Bean 191 | @Qualifier(Constants.QUALIFIER_2) // direct-annotation 192 | RSocketRequester two(@Value("${" + Constants.QUALIFIER_2 + ".port}") int port, RSocketRequester.Builder builder) { 193 | return builder.connectTcp("localhost", port).block(); 194 | } 195 | } 196 | 197 | @Target({ ElementType.FIELD, ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER }) 198 | @Retention(RetentionPolicy.RUNTIME) 199 | @Qualifier(Constants.QUALIFIER_1) 200 | @interface PersonQualifier { 201 | } 202 | 203 | ---- 204 | 205 | == Contact us 206 | 207 | Did you not find what you sought? We're happy to help! We're always available on the Github Issues section for this repository. 208 | -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-client/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-client/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-client/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects-experimental/spring-retrosocket/5321e16798d0fa025a30fc5e2e7bb0dc87ff8655/spring-retrosocket-samples/hello-client/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-client/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-client/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-client/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-client/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.springframework.boot 8 | spring-boot-starter-parent 9 | 2.6.1 10 | 11 | 12 | com.example 13 | hello-client 14 | 0.0.1-SNAPSHOT 15 | hello-client 16 | Demo project for Spring Boot 17 | 18 | 11 19 | 20 | 0.11.0 21 | 22 | 23 | 24 | org.springframework.retrosocket 25 | spring-retrosocket 26 | 0.0.1-SNAPSHOT 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-rsocket 31 | 32 | 33 | org.springframework.retrosocket 34 | 0.0.1-SNAPSHOT 35 | spring-retrosocket-native 36 | 37 | 38 | org.springframework.experimental 39 | spring-native 40 | ${spring-native.version} 41 | 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter-test 46 | test 47 | 48 | 49 | io.projectreactor 50 | reactor-test 51 | test 52 | 53 | 54 | 55 | 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-maven-plugin 60 | 61 | ${repackage.classifier} 62 | 63 | paketobuildpacks/builder:tiny 64 | 65 | true 66 | 67 | 68 | 69 | 70 | 71 | org.springframework.experimental 72 | spring-aot-maven-plugin 73 | ${spring-native.version} 74 | 75 | 76 | test-generate 77 | 78 | test-generate 79 | 80 | 81 | 82 | generate 83 | 84 | generate 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | spring-snapshots 94 | Spring Snapshots 95 | https://repo.spring.io/snapshot 96 | 97 | false 98 | 99 | 100 | 101 | spring-milestones 102 | Spring Milestones 103 | https://repo.spring.io/milestone 104 | 105 | false 106 | 107 | 108 | 109 | 110 | 111 | spring-snapshots 112 | Spring Snapshots 113 | https://repo.spring.io/snapshot 114 | 115 | false 116 | 117 | 118 | 119 | spring-milestones 120 | Spring Milestones 121 | https://repo.spring.io/milestone 122 | 123 | false 124 | 125 | 126 | 127 | 128 | 129 | 130 | native 131 | 132 | exec 133 | 0.9.8 134 | 135 | 136 | 137 | org.junit.platform 138 | junit-platform-launcher 139 | test 140 | 141 | 142 | 143 | 144 | 145 | org.graalvm.buildtools 146 | native-maven-plugin 147 | ${native-buildtools.version} 148 | true 149 | 150 | 151 | test-native 152 | test 153 | 154 | test 155 | 156 | 157 | 158 | build-native 159 | package 160 | 161 | build 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-client/src/main/java/com/example/test/client/TestApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.test.client; 2 | 3 | import lombok.SneakyThrows; 4 | import org.springframework.boot.ApplicationRunner; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.messaging.handler.annotation.MessageMapping; 9 | import org.springframework.messaging.rsocket.RSocketRequester; 10 | import org.springframework.retrosocket.EnableRSocketClients; 11 | import org.springframework.retrosocket.RSocketClient; 12 | import reactor.core.publisher.Mono; 13 | 14 | @EnableRSocketClients 15 | @SpringBootApplication 16 | public class TestApplication { 17 | 18 | @Bean 19 | RSocketRequester rSocketRequester(RSocketRequester.Builder builder) { 20 | return builder.tcp("localhost", 8888); 21 | } 22 | 23 | @SneakyThrows 24 | public static void main(String[] args) { 25 | SpringApplication.run(TestApplication.class, args); 26 | Thread.currentThread().join(); 27 | } 28 | 29 | @Bean 30 | ApplicationRunner runner(GreetingsClient greetingsClient) { 31 | return args -> greetingsClient.hello(Mono.just("world!")).subscribe(System.out::println); 32 | } 33 | 34 | } 35 | 36 | @RSocketClient 37 | interface GreetingsClient { 38 | 39 | @MessageMapping("hello") 40 | Mono hello(Mono name); 41 | } -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-client/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects-experimental/spring-retrosocket/5321e16798d0fa025a30fc5e2e7bb0dc87ff8655/spring-retrosocket-samples/hello-client/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-client/src/test/java/com/example/test/TestApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.test; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class TestApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-service/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-service/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects-experimental/spring-retrosocket/5321e16798d0fa025a30fc5e2e7bb0dc87ff8655/spring-retrosocket-samples/hello-service/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-service/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-service/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.6.2-SNAPSHOT 9 | 10 | 11 | com.example 12 | hello-service 13 | 0.0.1-SNAPSHOT 14 | hello-service 15 | Demo project for Spring Boot 16 | 17 | 17 18 | 19 | 0.11.0-SNAPSHOT 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-rsocket 25 | 26 | 27 | org.springframework.experimental 28 | spring-native 29 | ${spring-native.version} 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-test 35 | test 36 | 37 | 38 | io.projectreactor 39 | reactor-test 40 | test 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-maven-plugin 49 | 50 | ${repackage.classifier} 51 | 52 | paketobuildpacks/builder:tiny 53 | 54 | true 55 | 56 | 57 | 58 | 59 | 60 | org.springframework.experimental 61 | spring-aot-maven-plugin 62 | ${spring-native.version} 63 | 64 | 65 | test-generate 66 | 67 | test-generate 68 | 69 | 70 | 71 | generate 72 | 73 | generate 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | spring-snapshots 83 | Spring Snapshots 84 | https://repo.spring.io/snapshot 85 | 86 | false 87 | 88 | 89 | 90 | spring-milestones 91 | Spring Milestones 92 | https://repo.spring.io/milestone 93 | 94 | false 95 | 96 | 97 | 98 | 99 | 100 | spring-snapshots 101 | Spring Snapshots 102 | https://repo.spring.io/snapshot 103 | 104 | false 105 | 106 | 107 | 108 | spring-milestones 109 | Spring Milestones 110 | https://repo.spring.io/milestone 111 | 112 | false 113 | 114 | 115 | 116 | 117 | 118 | 119 | native 120 | 121 | exec 122 | 0.9.8 123 | 124 | 125 | 126 | org.junit.platform 127 | junit-platform-launcher 128 | test 129 | 130 | 131 | 132 | 133 | 134 | org.graalvm.buildtools 135 | native-maven-plugin 136 | ${native-buildtools.version} 137 | true 138 | 139 | 140 | test-native 141 | test 142 | 143 | test 144 | 145 | 146 | 147 | build-native 148 | package 149 | 150 | build 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-service/src/main/java/com/example/test/service/TestApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.test.service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.messaging.handler.annotation.MessageMapping; 6 | import org.springframework.stereotype.Controller; 7 | 8 | 9 | @SpringBootApplication 10 | public class TestApplication { 11 | 12 | public static void main(String[] args) { 13 | System.setProperty("spring.profiles.active", "service"); 14 | System.setProperty("spring.rsocket.server.port", "8888"); 15 | SpringApplication.run(TestApplication.class, args); 16 | } 17 | 18 | } 19 | 20 | 21 | @Controller 22 | class GreetingsController { 23 | 24 | @MessageMapping("hello") 25 | String hello(String name) { 26 | return "Hello, " + name + "!"; 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects-experimental/spring-retrosocket/5321e16798d0fa025a30fc5e2e7bb0dc87ff8655/spring-retrosocket-samples/hello-service/src/main/resources/application.properties -------------------------------------------------------------------------------- /spring-retrosocket-samples/hello-service/src/test/java/com/example/test/TestApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.test; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class TestApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-retrosocket/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /spring-retrosocket/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects-experimental/spring-retrosocket/5321e16798d0fa025a30fc5e2e7bb0dc87ff8655/spring-retrosocket/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /spring-retrosocket/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /spring-retrosocket/mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /spring-retrosocket/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /spring-retrosocket/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.retrosocket 7 | spring-retrosocket-parent 8 | 0.0.1-SNAPSHOT 9 | 10 | spring-retrosocket 11 | 12 | 13 | 14 | org.springframework 15 | spring-context-indexer 16 | 17 | 18 | org.springframework.boot 19 | spring-boot-starter-rsocket 20 | 21 | 22 | org.springframework.experimental 23 | spring-native 24 | 25 | 26 | org.springframework.experimental 27 | spring-aot 28 | 29 | 30 | org.projectlombok 31 | lombok 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-test 36 | test 37 | 38 | 39 | org.junit.vintage 40 | junit-vintage-engine 41 | 42 | 43 | 44 | 45 | io.projectreactor 46 | reactor-test 47 | test 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /spring-retrosocket/src/main/java/org/springframework/retrosocket/EnableRSocketClients.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket; 2 | 3 | import org.springframework.context.annotation.Import; 4 | 5 | import java.lang.annotation.*; 6 | 7 | /** 8 | * @author Josh Long 9 | */ 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Target(ElementType.TYPE) 12 | @Documented 13 | @Import(RSocketClientsRegistrar.class) 14 | public @interface EnableRSocketClients { 15 | 16 | String[] value() default {}; 17 | 18 | String[] basePackages() default {}; 19 | 20 | Class[] basePackageClasses() default {}; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-retrosocket/src/main/java/org/springframework/retrosocket/RSocketClient.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket; 2 | 3 | import org.springframework.stereotype.Indexed; 4 | 5 | import java.lang.annotation.*; 6 | 7 | import static java.lang.annotation.ElementType.TYPE; 8 | 9 | /** 10 | * @author Josh Long 11 | */ 12 | @Target(TYPE) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Documented 15 | @Inherited 16 | @Indexed 17 | public @interface RSocketClient { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-retrosocket/src/main/java/org/springframework/retrosocket/RSocketClientAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket; 2 | 3 | import lombok.extern.log4j.Log4j2; 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.messaging.rsocket.RSocketRequester; 8 | 9 | /** 10 | * @author Josh Long 11 | */ 12 | @Log4j2 13 | @Configuration 14 | class RSocketClientAutoConfiguration { 15 | 16 | @Bean 17 | @ConditionalOnBean(RSocketRequester.class) 18 | RSocketClientBuilder rSocketClientBuilder() { 19 | return new RSocketClientBuilder(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-retrosocket/src/main/java/org/springframework/retrosocket/RSocketClientBuilder.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.aopalliance.intercept.MethodInterceptor; 6 | import org.aopalliance.intercept.MethodInvocation; 7 | import org.springframework.aop.framework.ProxyFactory; 8 | import org.springframework.core.ResolvableType; 9 | import org.springframework.messaging.handler.annotation.DestinationVariable; 10 | import org.springframework.messaging.handler.annotation.Header; 11 | import org.springframework.messaging.handler.annotation.MessageMapping; 12 | import org.springframework.messaging.handler.annotation.Payload; 13 | import org.springframework.messaging.rsocket.RSocketRequester; 14 | import org.springframework.util.Assert; 15 | import org.springframework.util.MimeType; 16 | import org.springframework.util.MimeTypeUtils; 17 | import org.springframework.util.StringUtils; 18 | import reactor.core.publisher.Flux; 19 | import reactor.core.publisher.Mono; 20 | 21 | import java.lang.reflect.Method; 22 | import java.lang.reflect.Parameter; 23 | import java.util.ArrayList; 24 | import java.util.HashMap; 25 | import java.util.List; 26 | import java.util.Map; 27 | 28 | /** 29 | * @author Josh Long 30 | */ 31 | @Slf4j 32 | @RequiredArgsConstructor 33 | public class RSocketClientBuilder { 34 | 35 | private static Object[] findDestinationVariables(Object[] arguments, Parameter[] parameters) { 36 | List destinationVariableValues = new ArrayList<>(); 37 | for (int i = 0; i < arguments.length; i++) { 38 | Parameter parameter = parameters[i]; 39 | Object arg = arguments[i]; 40 | if (parameter.getAnnotationsByType(DestinationVariable.class).length > 0) { 41 | destinationVariableValues.add(arg); 42 | } 43 | } 44 | return destinationVariableValues.toArray(new Object[0]); 45 | } 46 | 47 | private static Object findPayloadArgument(Object[] arguments, Parameter[] parameters) { 48 | Object payloadArgument = Mono.empty(); 49 | if (arguments.length == 0) { 50 | payloadArgument = Mono.empty(); 51 | } 52 | else if (arguments.length == 1) { 53 | payloadArgument = arguments[0]; 54 | } 55 | else { 56 | Assert.isTrue(parameters.length == arguments.length, 57 | "there should be " + "an equal number of " + Parameter.class.getName() + " and objects"); 58 | for (int i = 0; i < parameters.length; i++) { 59 | Parameter annotations = parameters[i]; 60 | Object argument = arguments[i]; 61 | if (annotations.getAnnotationsByType(Payload.class).length > 0) { 62 | payloadArgument = argument; 63 | } 64 | } 65 | } 66 | Assert.notNull(payloadArgument, 67 | "you must specify a @" + Payload.class.getName() + " parameter OR just one parameter"); 68 | return payloadArgument; 69 | } 70 | 71 | private static Map findCompositeMetadata(Object[] arguments, Parameter[] parameters) { 72 | Map metadata = new HashMap<>(); 73 | Assert.isTrue(parameters.length == arguments.length, 74 | "there should be an equal number of " + Parameter.class.getName() + " and objects"); 75 | for (int i = 0; i < parameters.length; i++) { 76 | Parameter annotations = parameters[i]; 77 | Object argument = arguments[i]; 78 | Header[] headers = annotations.getAnnotationsByType(Header.class); 79 | if (headers.length > 0) { 80 | Header header = headers[0]; 81 | Assert.state(StringUtils.hasText(header.value()) || StringUtils.hasText(header.name()), 82 | () -> "you can not use the @" + Header.class.getName() 83 | + " annotation unless you provide a mimetype"); 84 | MimeType mimeType = MimeTypeUtils.parseMimeType(header.value()); 85 | metadata.put(mimeType, argument); 86 | } 87 | } 88 | return metadata; 89 | } 90 | 91 | private static class RSocketClientMethodInterceptor implements MethodInterceptor { 92 | 93 | private final RSocketRequester rSocketRequester; 94 | 95 | RSocketClientMethodInterceptor(RSocketRequester rSocketRequester) { 96 | this.rSocketRequester = rSocketRequester; 97 | } 98 | 99 | @Override 100 | public Object invoke(MethodInvocation methodInvocation) throws Throwable { 101 | Method method = methodInvocation.getMethod(); 102 | String methodName = method.getName(); 103 | Class returnType = method.getReturnType(); 104 | Object[] arguments = methodInvocation.getArguments(); 105 | Parameter[] parameters = method.getParameters(); 106 | MessageMapping annotation = method.getAnnotation(MessageMapping.class); 107 | String route = annotation.value()[0]; 108 | ResolvableType resolvableType = ResolvableType.forMethodReturnType(method); 109 | Class rawClassForReturnType = resolvableType.getGenerics()[0].getRawClass(); 110 | Object[] routeArguments = findDestinationVariables(arguments, parameters); 111 | Object payloadArgument = findPayloadArgument(arguments, parameters); 112 | Map compositeMetadata = findCompositeMetadata(arguments, parameters); 113 | 114 | log.debug("invoking " + methodName + " accepting " + arguments.length + " argument(s) for route " + route 115 | + " with destination variables (" + StringUtils.arrayToDelimitedString(routeArguments, ", ") + ")" 116 | + '.' + " The payload is " + payloadArgument); 117 | 118 | if (Mono.class.isAssignableFrom(returnType)) { 119 | // special case for fire-and-forget 120 | if (Void.class.isAssignableFrom(rawClassForReturnType)) { 121 | if (log.isDebugEnabled()) { 122 | log.debug("fire-and-forget"); 123 | } 124 | return enrichMetadata(rSocketRequester.route(route, routeArguments), compositeMetadata) 125 | .data(payloadArgument)// 126 | .send(); 127 | } 128 | else { 129 | if (log.isDebugEnabled()) { 130 | log.debug("request-response"); 131 | } 132 | return enrichMetadata(rSocketRequester.route(route, routeArguments), compositeMetadata)// 133 | .data(payloadArgument)// 134 | .retrieveMono(rawClassForReturnType); 135 | } 136 | } 137 | 138 | if (Flux.class.isAssignableFrom(returnType)) { 139 | if (log.isDebugEnabled()) { 140 | log.debug("request-stream or channel"); 141 | } 142 | return enrichMetadata(rSocketRequester.route(route, routeArguments), compositeMetadata) 143 | .data(payloadArgument).retrieveFlux(rawClassForReturnType); 144 | } 145 | // is there something more sensible to return? 146 | return Mono.empty(); 147 | } 148 | 149 | private RSocketRequester.RequestSpec enrichMetadata(RSocketRequester.RequestSpec route, 150 | Map compositeMetadata) { 151 | 152 | if (!compositeMetadata.isEmpty()) { 153 | for (Map.Entry entry : compositeMetadata.entrySet()) { 154 | route = route.metadata(entry.getValue(), entry.getKey()); 155 | } 156 | } 157 | return route; 158 | } 159 | 160 | } 161 | 162 | public T buildClientFor(Class clazz, RSocketRequester rSocketRequester) { 163 | log.debug("trying to build client for " + clazz.getName() + " with RsocketRequester " 164 | + (rSocketRequester == null)); 165 | Assert.notNull(rSocketRequester, "the requester must not be null"); 166 | Assert.notNull(clazz, "the Class must not be null"); 167 | MethodInterceptor methodInterceptor = new RSocketClientMethodInterceptor(rSocketRequester); 168 | return (T) ProxyFactory.getProxy(clazz, methodInterceptor); 169 | } 170 | 171 | } 172 | -------------------------------------------------------------------------------- /spring-retrosocket/src/main/java/org/springframework/retrosocket/RSocketClientFactoryBean.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket; 2 | 3 | import lombok.SneakyThrows; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.BeansException; 6 | import org.springframework.beans.factory.BeanFactory; 7 | import org.springframework.beans.factory.BeanFactoryAware; 8 | import org.springframework.beans.factory.FactoryBean; 9 | import org.springframework.beans.factory.ListableBeanFactory; 10 | import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; 11 | import org.springframework.beans.factory.annotation.Qualifier; 12 | import org.springframework.core.annotation.MergedAnnotation; 13 | import org.springframework.core.annotation.MergedAnnotations; 14 | import org.springframework.messaging.rsocket.RSocketRequester; 15 | import org.springframework.util.Assert; 16 | 17 | import java.util.Map; 18 | 19 | /** 20 | * @author Josh Long 21 | */ 22 | @Slf4j 23 | public class RSocketClientFactoryBean implements BeanFactoryAware, FactoryBean { 24 | 25 | private Class type; 26 | 27 | private ListableBeanFactory context; 28 | 29 | private static RSocketRequester forInterface(Class clientInterface, ListableBeanFactory context) { 30 | Map rSocketRequestersInContext = context.getBeansOfType(RSocketRequester.class); 31 | int rSocketRequestersCount = rSocketRequestersInContext.size(); 32 | Assert.state(rSocketRequestersCount > 0, () -> "there should be at least one " 33 | + RSocketRequester.class.getName() + " in the context. Please consider defining one."); 34 | RSocketRequester rSocketRequester = null; 35 | Assert.notNull(clientInterface, "the client interface must be non-null"); 36 | Assert.notNull(context, () -> "the " + ListableBeanFactory.class.getName() + " interface must be non-null"); 37 | MergedAnnotation qualifier = MergedAnnotations.from(clientInterface).get(Qualifier.class); 38 | if (qualifier.isPresent()) { 39 | String valueOfQualifierAnnotation = qualifier.getString(MergedAnnotation.VALUE); 40 | Map beans = BeanFactoryAnnotationUtils.qualifiedBeansOfType(context, 41 | RSocketRequester.class, valueOfQualifierAnnotation); 42 | Assert.state(beans.size() == 1, 43 | () -> "I need just one " + RSocketRequester.class.getName() + " but I got " + beans.keySet()); 44 | for (Map.Entry entry : beans.entrySet()) { 45 | rSocketRequester = entry.getValue(); 46 | if (log.isDebugEnabled()) { 47 | log.debug("found " + rSocketRequester + " with bean name " + entry.getKey() + " for @" 48 | + RSocketClient.class.getName() + " interface " + clientInterface.getName() + '.'); 49 | } 50 | } 51 | } 52 | else { 53 | Assert.state(rSocketRequestersCount == 1, () -> "there should be no more and no less than one unqualified " 54 | + RSocketRequester.class.getName() + " instances in the context."); 55 | return rSocketRequestersInContext.values().iterator().next(); 56 | } 57 | Assert.notNull(rSocketRequester, () -> "we could not find an " + RSocketRequester.class.getName() 58 | + " for the @RSocketClient interface " + clientInterface.getName() + '.'); 59 | return rSocketRequester; 60 | } 61 | 62 | @SneakyThrows 63 | public void setType(String type) { 64 | this.type = Class.forName(type); 65 | } 66 | 67 | @Override 68 | public T getObject() { 69 | RSocketRequester rSocketRequester = forInterface(this.type, this.context); 70 | log.debug("getObject(): we have a valid RSocketRequester: " + (null != rSocketRequester)); 71 | RSocketClientBuilder clientBuilder = this.context.getBean(RSocketClientBuilder.class); 72 | // RSocketClientBuilder clientBuilder = new RSocketClientBuilder(); 73 | return (T) clientBuilder.buildClientFor(this.type, rSocketRequester); 74 | } 75 | 76 | @Override 77 | public Class getObjectType() { 78 | return this.type; 79 | } 80 | 81 | @Override 82 | public void setBeanFactory(BeanFactory beanFactory) throws BeansException { 83 | Assert.state(beanFactory instanceof ListableBeanFactory, () -> "the " + BeanFactory.class.getName() 84 | + " is not an instance of a " + ListableBeanFactory.class.getName()); 85 | log.debug("got the bean factory " + beanFactory.getClass().getName()); 86 | this.context = (ListableBeanFactory) beanFactory; 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /spring-retrosocket/src/main/java/org/springframework/retrosocket/RSocketClientsRegistrar.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket; 2 | 3 | import lombok.SneakyThrows; 4 | import lombok.extern.log4j.Log4j2; 5 | import org.springframework.beans.factory.FactoryBean; 6 | import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; 7 | import org.springframework.beans.factory.config.BeanDefinitionHolder; 8 | import org.springframework.beans.factory.support.*; 9 | import org.springframework.context.EnvironmentAware; 10 | import org.springframework.context.ResourceLoaderAware; 11 | import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; 12 | import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; 13 | import org.springframework.core.env.Environment; 14 | import org.springframework.core.io.ResourceLoader; 15 | import org.springframework.core.type.AnnotationMetadata; 16 | import org.springframework.core.type.classreading.MetadataReader; 17 | import org.springframework.core.type.filter.AnnotationTypeFilter; 18 | import org.springframework.util.ClassUtils; 19 | import org.springframework.util.StringUtils; 20 | 21 | import java.io.IOException; 22 | import java.util.Collection; 23 | import java.util.HashSet; 24 | import java.util.Map; 25 | import java.util.Set; 26 | 27 | /** 28 | * @author Josh Long 29 | * @author Andy Clement 30 | */ 31 | @Log4j2 32 | class RSocketClientsRegistrar implements ImportBeanDefinitionRegistrar, EnvironmentAware, ResourceLoaderAware { 33 | 34 | private Environment environment; 35 | 36 | private ResourceLoader resourceLoader; 37 | 38 | @Override 39 | public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry, 40 | BeanNameGenerator importBeanNameGenerator) { 41 | Collection basePackages = this.getBasePackages(importingClassMetadata); 42 | ClassPathScanningCandidateComponentProvider scanner = this.buildScanner(); 43 | basePackages.forEach(basePackage -> scanner.findCandidateComponents(basePackage)// 44 | .stream()// 45 | .filter(cc -> cc instanceof AnnotatedBeanDefinition)// 46 | .map(abd -> (AnnotatedBeanDefinition) abd)// 47 | .forEach(beanDefinition -> { 48 | AnnotationMetadata annotationMetadata = beanDefinition.getMetadata(); 49 | boolean isClient = annotationMetadata.getAnnotationTypes().stream() 50 | .anyMatch(s -> s.equals(RSocketClient.class.getName())); 51 | if (!isClient) 52 | return; 53 | this.registerClient(annotationMetadata, registry); 54 | })); 55 | } 56 | 57 | @SneakyThrows 58 | private void registerClient(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry) { 59 | String className = annotationMetadata.getClassName(); 60 | log.debug("going to build a client for " + className); 61 | Class rSocketClientFactoryBeanClass = RSocketClientFactoryBean.class; 62 | BeanDefinitionBuilder definition = BeanDefinitionBuilder.genericBeanDefinition(rSocketClientFactoryBeanClass); 63 | definition.addPropertyValue("type", className); 64 | definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE); 65 | 66 | AbstractBeanDefinition beanDefinition = definition.getBeanDefinition(); 67 | beanDefinition.setAttribute(FactoryBean.OBJECT_TYPE_ATTRIBUTE, className); 68 | beanDefinition.setPrimary(true); 69 | beanDefinition.setBeanClass(rSocketClientFactoryBeanClass); 70 | BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDefinition, className, new String[0]); 71 | BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry); 72 | } 73 | 74 | private Set getBasePackages(AnnotationMetadata importingClassMetadata) { 75 | Map attributes = importingClassMetadata 76 | .getAnnotationAttributes(EnableRSocketClients.class.getCanonicalName()); 77 | 78 | Set basePackages = new HashSet<>(); 79 | for (String pkg : (String[]) attributes.get("value")) { 80 | if (StringUtils.hasText(pkg)) { 81 | basePackages.add(pkg); 82 | } 83 | } 84 | for (String pkg : (String[]) attributes.get("basePackages")) { 85 | if (StringUtils.hasText(pkg)) { 86 | basePackages.add(pkg); 87 | } 88 | } 89 | for (Class clazz : (Class[]) attributes.get("basePackageClasses")) { 90 | basePackages.add(ClassUtils.getPackageName(clazz)); 91 | } 92 | if (basePackages.isEmpty()) { 93 | basePackages.add(ClassUtils.getPackageName(importingClassMetadata.getClassName())); 94 | } 95 | 96 | return basePackages; 97 | } 98 | 99 | private ClassPathScanningCandidateComponentProvider buildScanner() { 100 | ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false, 101 | this.environment) { 102 | 103 | @Override 104 | protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) { 105 | return beanDefinition.getMetadata().isIndependent(); 106 | } 107 | 108 | @Override 109 | protected boolean isCandidateComponent(MetadataReader metadataReader) { 110 | return !metadataReader.getClassMetadata().isAnnotation(); 111 | } 112 | }; 113 | scanner.addIncludeFilter(new AnnotationTypeFilter(RSocketClient.class)); 114 | scanner.setResourceLoader(this.resourceLoader); 115 | return scanner; 116 | } 117 | 118 | @Override 119 | public void setResourceLoader(ResourceLoader resourceLoader) { 120 | this.resourceLoader = resourceLoader; 121 | } 122 | 123 | @Override 124 | public void setEnvironment(Environment environment) { 125 | this.environment = environment; 126 | } 127 | 128 | } 129 | -------------------------------------------------------------------------------- /spring-retrosocket/src/main/java/org/springframework/retrosocket/nativex/RetrosocketBeanFactoryNativeConfigurationProcessor.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.nativex; 2 | 3 | import lombok.SneakyThrows; 4 | import lombok.extern.log4j.Log4j2; 5 | import org.springframework.aot.context.bootstrap.generator.infrastructure.nativex.BeanFactoryNativeConfigurationProcessor; 6 | import org.springframework.aot.context.bootstrap.generator.infrastructure.nativex.NativeConfigurationRegistry; 7 | import org.springframework.aot.context.bootstrap.generator.infrastructure.nativex.NativeProxyEntry; 8 | import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; 9 | import org.springframework.nativex.hint.TypeAccess; 10 | import org.springframework.retrosocket.RSocketClient; 11 | 12 | import java.util.Map; 13 | 14 | /** 15 | * See 16 | * https://github.com/spring-projects-experimental/spring-native/blob/main/spring-aot/src/main/java/org/springframework/data/RepositoryDefinitionConfigurationProcessor.java 17 | * 18 | * @author Josh Long 19 | */ 20 | @Log4j2 21 | public class RetrosocketBeanFactoryNativeConfigurationProcessor implements BeanFactoryNativeConfigurationProcessor { 22 | 23 | @Override 24 | @SneakyThrows 25 | public void process(ConfigurableListableBeanFactory beanFactory, NativeConfigurationRegistry registry) { 26 | Map beansWithAnnotation = beanFactory.getBeansWithAnnotation(RSocketClient.class); 27 | log.debug("there are " + beansWithAnnotation.size() + " beans with this annotation."); 28 | beansWithAnnotation.forEach((bn, e) -> { 29 | log.debug("found a bean of type " + e.getClass().getCanonicalName()); 30 | registry.reflection().forType(e.getClass()).withAccess(TypeAccess.values()).build(); 31 | 32 | for (Class i : e.getClass().getInterfaces()) { 33 | registry.reflection().forType(i).withAccess(TypeAccess.values()).build(); 34 | log.debug("registering the interface " + i.getName() + '.'); 35 | } 36 | 37 | registry.reflection().forType(e.getClass()).withAccess(TypeAccess.values()).build(); 38 | registry.proxy().add(NativeProxyEntry.ofInterfaces(e.getClass().getInterfaces())); 39 | }); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /spring-retrosocket/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.aot.context.bootstrap.generator.infrastructure.nativex.BeanFactoryNativeConfigurationProcessor =\ 2 | org.springframework.retrosocket.nativex.RetrosocketBeanFactoryNativeConfigurationProcessor 3 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=org.springframework.retrosocket.RSocketClientAutoConfiguration -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/metadata/Constants.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.metadata; 2 | 3 | import org.springframework.util.MimeType; 4 | 5 | /** 6 | * @author Josh Long 7 | */ 8 | class Constants { 9 | 10 | public static final String CLIENT_ID_HEADER = "client-id"; 11 | 12 | public static final String LANG_HEADER = "lang"; 13 | 14 | public static final String CLIENT_ID_MIME_TYPE_VALUE = "messaging/x.bootiful." + CLIENT_ID_HEADER; 15 | 16 | public static final String LANG_MIME_TYPE_VALUE = "messaging/x.bootiful." + LANG_HEADER; 17 | 18 | public static final MimeType CLIENT_ID_MIME_TYPE = MimeType.valueOf(CLIENT_ID_MIME_TYPE_VALUE); 19 | 20 | public static final MimeType LANG_MIME_TYPE = MimeType.valueOf(LANG_MIME_TYPE_VALUE); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/metadata/GreetingClient.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.metadata; 2 | 3 | import org.springframework.messaging.handler.annotation.Header; 4 | import org.springframework.messaging.handler.annotation.MessageMapping; 5 | import org.springframework.messaging.handler.annotation.Payload; 6 | import org.springframework.retrosocket.RSocketClient; 7 | import reactor.core.publisher.Mono; 8 | 9 | import java.util.Map; 10 | 11 | /** 12 | * @author Josh Long 13 | */ 14 | @RSocketClient 15 | interface GreetingClient { 16 | 17 | @MessageMapping("greetings") 18 | Mono> greet(@Header(Constants.CLIENT_ID_MIME_TYPE_VALUE) String clientId, 19 | @Payload Mono name); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/metadata/GreetingResponse.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.metadata; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * @author Josh Long 9 | */ 10 | @Data 11 | @NoArgsConstructor 12 | @AllArgsConstructor 13 | public class GreetingResponse { 14 | 15 | private String message; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/metadata/GreetingsController.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.metadata; 2 | 3 | import lombok.extern.log4j.Log4j2; 4 | import org.springframework.context.annotation.Profile; 5 | import org.springframework.messaging.handler.annotation.Headers; 6 | import org.springframework.messaging.handler.annotation.MessageMapping; 7 | import org.springframework.messaging.handler.annotation.Payload; 8 | import org.springframework.stereotype.Controller; 9 | import reactor.core.publisher.Mono; 10 | 11 | import java.util.Collections; 12 | import java.util.Map; 13 | 14 | /** 15 | * @author Josh Long 16 | */ 17 | @Log4j2 18 | @Profile("service") 19 | @Controller 20 | class GreetingsController { 21 | 22 | @MessageMapping("greetings") 23 | Mono> greet(@Headers Map headers, @Payload Mono in) { 24 | headers.forEach((k, v) -> log.info(k + '=' + v)); 25 | Map data = Collections.singletonMap(Constants.CLIENT_ID_MIME_TYPE_VALUE, 26 | headers.get(Constants.CLIENT_ID_HEADER)); 27 | return Mono.just(data); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/metadata/RSocketClientConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.metadata; 2 | 3 | import lombok.extern.log4j.Log4j2; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Profile; 8 | import org.springframework.messaging.rsocket.RSocketRequester; 9 | import org.springframework.retrosocket.EnableRSocketClients; 10 | 11 | /** 12 | * @author Josh Long 13 | */ 14 | @Log4j2 15 | @Profile("client") 16 | @EnableRSocketClients 17 | @SpringBootApplication 18 | class RSocketClientConfiguration { 19 | 20 | @Bean 21 | RSocketRequester rSocketRequester(@Value("${service.port}") int port, RSocketRequester.Builder builder) { 22 | return builder.connectTcp("localhost", port).block(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/metadata/RSocketClientTest.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.metadata; 2 | 3 | import lombok.extern.log4j.Log4j2; 4 | import org.junit.jupiter.api.Test; 5 | import org.springframework.boot.WebApplicationType; 6 | import org.springframework.boot.builder.SpringApplicationBuilder; 7 | import org.springframework.context.ConfigurableApplicationContext; 8 | import org.springframework.messaging.rsocket.RSocketRequester; 9 | import org.springframework.util.SocketUtils; 10 | import reactor.core.publisher.Mono; 11 | import reactor.test.StepVerifier; 12 | 13 | /** 14 | * @author Josh Long 15 | */ 16 | @Log4j2 17 | public class RSocketClientTest { 18 | 19 | private static ConfigurableApplicationContext runService(int port) { 20 | return new SpringApplicationBuilder(RSocketServerConfiguration.class)// 21 | .web(WebApplicationType.NONE) 22 | .run("--spring.profiles.active=service", "--spring.rsocket.server.port=" + port); 23 | } 24 | 25 | @Test 26 | public void monoInAndOut() { 27 | int servicePort = SocketUtils.findAvailableTcpPort(); 28 | ConfigurableApplicationContext service = runService(servicePort); 29 | ConfigurableApplicationContext client = runClient(servicePort); 30 | RSocketRequester rSocketRequester = client.getBean(RSocketRequester.class); 31 | GreetingClient gc = client.getBean(GreetingClient.class); 32 | StepVerifier.create(gc.greet("123", Mono.just("A Name"))) 33 | .expectNextMatches( 34 | map -> map.containsKey(Constants.CLIENT_ID_MIME_TYPE_VALUE) && map.containsValue("123")) 35 | .verifyComplete(); 36 | client.stop(); 37 | service.stop(); 38 | } 39 | 40 | private ConfigurableApplicationContext runClient(int port) { 41 | ConfigurableApplicationContext context = new SpringApplicationBuilder(RSocketClientConfiguration.class)// 42 | .web(WebApplicationType.NONE)// 43 | .run("--service.port=" + port, "--spring.profiles.active=client"); 44 | return context; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/metadata/RSocketServerConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.metadata; 2 | 3 | import lombok.extern.log4j.Log4j2; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.boot.rsocket.messaging.RSocketStrategiesCustomizer; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.context.annotation.Profile; 9 | import org.springframework.core.codec.StringDecoder; 10 | 11 | import javax.annotation.PostConstruct; 12 | 13 | /** 14 | * @author Josh Long 15 | */ 16 | @Log4j2 17 | @Profile("service") 18 | @Configuration 19 | @EnableAutoConfiguration 20 | class RSocketServerConfiguration { 21 | 22 | @Bean 23 | RSocketStrategiesCustomizer rSocketStrategiesCustomizer() { 24 | return strategies -> strategies// 25 | .metadataExtractorRegistry(registry -> { 26 | registry.metadataToExtract(Constants.CLIENT_ID_MIME_TYPE, String.class, Constants.CLIENT_ID_HEADER); 27 | registry.metadataToExtract(Constants.LANG_MIME_TYPE, String.class, Constants.LANG_HEADER); 28 | })// 29 | .decoders(decoders -> decoders.add(StringDecoder.allMimeTypes())); 30 | } 31 | 32 | @Bean 33 | GreetingsController greetingsController() { 34 | return new GreetingsController(); 35 | } 36 | 37 | @PostConstruct 38 | public void start() { 39 | log.info("starting " + RSocketServerConfiguration.class.getName() + '.'); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/qualifiers/Constants.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.qualifiers; 2 | 3 | /** 4 | * @author Josh Long 5 | */ 6 | public class Constants { 7 | 8 | public final static String QUALIFIER_1 = "service1"; 9 | 10 | public final static String QUALIFIER_2 = "service2"; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/qualifiers/GreetingQualifier.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.qualifiers; 2 | 3 | import org.springframework.beans.factory.annotation.Qualifier; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * @author Josh Long 12 | */ 13 | @Target({ ElementType.FIELD, ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER }) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @Qualifier(Constants.QUALIFIER_2) 16 | @interface GreetingQualifier { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/qualifiers/GreetingServiceConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.qualifiers; 2 | 3 | import lombok.extern.log4j.Log4j2; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.context.annotation.Profile; 8 | import org.springframework.retrosocket.qualifiers.greetings.GreetingsController; 9 | 10 | /** 11 | * @author Josh Long 12 | */ 13 | @Log4j2 14 | @Profile("service2") 15 | @Configuration 16 | @EnableAutoConfiguration 17 | class GreetingServiceConfiguration { 18 | 19 | @Bean 20 | GreetingsController greetingsController() { 21 | return new GreetingsController(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/qualifiers/PeopleServerConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.qualifiers; 2 | 3 | import lombok.extern.log4j.Log4j2; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.context.annotation.Profile; 8 | import org.springframework.retrosocket.qualifiers.people.PersonController; 9 | 10 | /** 11 | * @author Josh Long 12 | */ 13 | @Log4j2 14 | @Profile("service1") 15 | @Configuration 16 | @EnableAutoConfiguration 17 | class PeopleServerConfiguration { 18 | 19 | @Bean 20 | PersonController personController() { 21 | return new PersonController(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/qualifiers/PersonQualifier.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.qualifiers; 2 | 3 | import org.springframework.beans.factory.annotation.Qualifier; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * @author Josh Long 12 | */ 13 | @Target({ ElementType.FIELD, ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER }) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @Qualifier(Constants.QUALIFIER_1) 16 | @interface PersonQualifier { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/qualifiers/RSocketClientConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.qualifiers; 2 | 3 | import org.springframework.beans.factory.annotation.Qualifier; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Profile; 8 | import org.springframework.messaging.rsocket.RSocketRequester; 9 | import org.springframework.retrosocket.EnableRSocketClients; 10 | 11 | /** 12 | * @author Josh Long 13 | */ 14 | @Profile("client") 15 | @EnableRSocketClients 16 | @SpringBootApplication 17 | class RSocketClientConfiguration { 18 | 19 | // people 20 | @Bean 21 | @PersonQualifier 22 | // @Qualifier(Constants.QUALIFIER_1) 23 | RSocketRequester one(@Value("${" + Constants.QUALIFIER_1 + ".port}") int port, RSocketRequester.Builder builder) { 24 | return builder.connectTcp("localhost", port).block(); 25 | } 26 | 27 | // greetings 28 | @Bean 29 | @Qualifier(Constants.QUALIFIER_2) 30 | // @GreetingQualifier 31 | RSocketRequester two(@Value("${" + Constants.QUALIFIER_2 + ".port}") int port, RSocketRequester.Builder builder) { 32 | return builder.connectTcp("localhost", port).block(); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/qualifiers/RSocketQualifierClientTest.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.qualifiers; 2 | 3 | import lombok.extern.log4j.Log4j2; 4 | import org.junit.jupiter.api.AfterAll; 5 | import org.junit.jupiter.api.BeforeAll; 6 | import org.junit.jupiter.api.Test; 7 | import org.springframework.boot.WebApplicationType; 8 | import org.springframework.boot.builder.SpringApplicationBuilder; 9 | import org.springframework.context.ConfigurableApplicationContext; 10 | import org.springframework.retrosocket.qualifiers.greetings.GreetingClient; 11 | import org.springframework.retrosocket.qualifiers.people.PersonClient; 12 | import org.springframework.util.Assert; 13 | import org.springframework.util.SocketUtils; 14 | import reactor.core.publisher.Mono; 15 | import reactor.test.StepVerifier; 16 | 17 | /** 18 | * @author Josh Long 19 | */ 20 | @Log4j2 21 | public class RSocketQualifierClientTest { 22 | 23 | private static final int port1 = SocketUtils.findAvailableTcpPort(); 24 | 25 | private static final int port2 = SocketUtils.findAvailableTcpPort(); 26 | static String SERVICE_1 = Constants.QUALIFIER_1; 27 | static String SERVICE_2 = Constants.QUALIFIER_2; 28 | static ConfigurableApplicationContext serviceApplicationContext1; 29 | static ConfigurableApplicationContext serviceApplicationContext2; 30 | 31 | private static ConfigurableApplicationContext runServer(Class clzz, String profileName, int port) { 32 | return new SpringApplicationBuilder(clzz)// 33 | .web(WebApplicationType.NONE)// 34 | .run("--spring.profiles.active=" + profileName, "--spring.rsocket.server.port=" + port); 35 | } 36 | 37 | @BeforeAll 38 | public static void begin() { 39 | serviceApplicationContext1 = runServer(PeopleServerConfiguration.class, SERVICE_1, port1); 40 | serviceApplicationContext2 = runServer(GreetingServiceConfiguration.class, SERVICE_2, port2); 41 | } 42 | 43 | @AfterAll 44 | public static void destroy() { 45 | serviceApplicationContext1.stop(); 46 | serviceApplicationContext2.stop(); 47 | } 48 | 49 | @Test 50 | public void noValueInMonoOut() { 51 | ConfigurableApplicationContext svc = buildClient(); 52 | PersonClient personClient = svc.getBean(PersonClient.class); 53 | GreetingClient greetingClient = svc.getBean(GreetingClient.class); 54 | Assert.notNull(personClient, "the " + PersonClient.class.getName() + " is not null"); 55 | Assert.notNull(greetingClient, "the " + GreetingClient.class.getName() + " is not null"); 56 | 57 | StepVerifier.create(greetingClient.greetMono(Mono.just("Spring"))).expectNextCount(1).verifyComplete(); 58 | StepVerifier.create(personClient.people()).expectNextCount(4).verifyComplete(); 59 | } 60 | 61 | private ConfigurableApplicationContext buildClient() { 62 | return new SpringApplicationBuilder(RSocketClientConfiguration.class)// 63 | .web(WebApplicationType.NONE)// 64 | .run("--service1.port=" + port1, "--service2.port=" + port2, "--spring.profiles.active=client"); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/qualifiers/greetings/Greeting.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.qualifiers.greetings; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * @author Josh Long 9 | */ 10 | @Data 11 | @NoArgsConstructor 12 | @AllArgsConstructor 13 | public class Greeting { 14 | 15 | private String message; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/qualifiers/greetings/GreetingClient.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.qualifiers.greetings; 2 | 3 | import org.springframework.beans.factory.annotation.Qualifier; 4 | import org.springframework.messaging.handler.annotation.MessageMapping; 5 | import org.springframework.retrosocket.RSocketClient; 6 | import reactor.core.publisher.Mono; 7 | 8 | import static org.springframework.retrosocket.qualifiers.Constants.QUALIFIER_2; 9 | 10 | /** 11 | * @author Josh Long 12 | */ 13 | @RSocketClient 14 | @Qualifier(QUALIFIER_2) 15 | public interface GreetingClient { 16 | 17 | @MessageMapping("greetings-with-name") 18 | Mono greetMono(Mono name); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/qualifiers/greetings/GreetingsController.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.qualifiers.greetings; 2 | 3 | import lombok.extern.log4j.Log4j2; 4 | import org.springframework.context.annotation.Profile; 5 | import org.springframework.messaging.handler.annotation.MessageMapping; 6 | import org.springframework.stereotype.Controller; 7 | import reactor.core.publisher.Mono; 8 | 9 | import javax.annotation.PostConstruct; 10 | 11 | /** 12 | * @author Josh Long 13 | */ 14 | @Log4j2 15 | @Profile("service") 16 | @Controller 17 | public class GreetingsController { 18 | 19 | @PostConstruct 20 | public void go() { 21 | log.info(getClass().getName()); 22 | } 23 | 24 | @MessageMapping("greetings-with-name") 25 | Mono greetMono(Mono name) { 26 | return name.map(Greeting::new); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/qualifiers/people/Person.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.qualifiers.people; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * @author Josh Long 9 | */ 10 | @Data 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | class Person { 14 | 15 | private String name; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/qualifiers/people/PersonClient.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.qualifiers.people; 2 | 3 | import org.springframework.beans.factory.annotation.Qualifier; 4 | import org.springframework.messaging.handler.annotation.MessageMapping; 5 | import org.springframework.retrosocket.RSocketClient; 6 | import org.springframework.retrosocket.qualifiers.Constants; 7 | import reactor.core.publisher.Flux; 8 | 9 | /** 10 | * @author Josh Long 11 | */ 12 | @RSocketClient 13 | @Qualifier(Constants.QUALIFIER_1) 14 | public interface PersonClient { 15 | 16 | @MessageMapping("people") 17 | Flux people(); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/qualifiers/people/PersonController.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.qualifiers.people; 2 | 3 | import lombok.extern.log4j.Log4j2; 4 | import org.springframework.context.annotation.Profile; 5 | import org.springframework.messaging.handler.annotation.MessageMapping; 6 | import org.springframework.stereotype.Controller; 7 | import reactor.core.publisher.Flux; 8 | 9 | import javax.annotation.PostConstruct; 10 | 11 | /** 12 | * @author Josh Long 13 | */ 14 | @Log4j2 15 | @Profile("service") 16 | @Controller 17 | public class PersonController { 18 | 19 | @PostConstruct 20 | public void go() { 21 | log.info(getClass().getName()); 22 | } 23 | 24 | @MessageMapping("people") 25 | Flux people() { 26 | return Flux.just(new Person("Yuxin"), new Person("Jane"), new Person("John"), new Person("Sergei")); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/simple/GreetingClient.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.simple; 2 | 3 | import org.springframework.messaging.handler.annotation.DestinationVariable; 4 | import org.springframework.messaging.handler.annotation.MessageMapping; 5 | import org.springframework.messaging.handler.annotation.Payload; 6 | import org.springframework.retrosocket.RSocketClient; 7 | import reactor.core.publisher.Flux; 8 | import reactor.core.publisher.Mono; 9 | 10 | /** 11 | * @author Josh Long 12 | */ 13 | @RSocketClient 14 | interface GreetingClient { 15 | 16 | @MessageMapping("greetings") 17 | Mono greet(); 18 | 19 | @MessageMapping("greetings-with-channel") 20 | Flux greetParams(Flux names); 21 | 22 | @MessageMapping("greetings-stream") 23 | Flux greetStream(Mono name); 24 | 25 | @MessageMapping("greetings-with-name") 26 | Mono greet(Mono name); 27 | 28 | @MessageMapping("fire-and-forget") 29 | Mono greetFireAndForget(Mono name); 30 | 31 | @MessageMapping("greetings-mono-name.{name}.{age}") 32 | Mono greetMonoNameDestinationVariable(@DestinationVariable("name") String name, 33 | @DestinationVariable("age") int age, @Payload Mono payload); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/simple/GreetingResponse.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.simple; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * @author Josh Long 9 | */ 10 | @Data 11 | @NoArgsConstructor 12 | @AllArgsConstructor 13 | public class GreetingResponse { 14 | 15 | private String message; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/simple/GreetingsController.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.simple; 2 | 3 | import lombok.extern.log4j.Log4j2; 4 | import org.springframework.context.annotation.Profile; 5 | import org.springframework.messaging.handler.annotation.DestinationVariable; 6 | import org.springframework.messaging.handler.annotation.MessageMapping; 7 | import org.springframework.messaging.handler.annotation.Payload; 8 | import org.springframework.stereotype.Controller; 9 | import reactor.core.publisher.Flux; 10 | import reactor.core.publisher.Mono; 11 | 12 | import javax.annotation.PostConstruct; 13 | import java.util.concurrent.atomic.AtomicReference; 14 | import java.util.stream.Stream; 15 | 16 | /** 17 | * @author Josh Long 18 | */ 19 | @Log4j2 20 | @Profile("service") 21 | @Controller 22 | class GreetingsController { 23 | 24 | static AtomicReference fireAndForget = new AtomicReference<>(); 25 | 26 | @PostConstruct 27 | public void begin() { 28 | log.info("begin()"); 29 | } 30 | 31 | @MessageMapping("greetings-mono-name.{name}.{age}") 32 | Mono greetMonoNameDestinationVariable(@DestinationVariable("name") String name, 33 | @DestinationVariable("age") int age, @Payload Mono payload) { 34 | log.info("name=" + name); 35 | log.info("age=" + age); 36 | return payload; 37 | } 38 | 39 | @MessageMapping("fire-and-forget") 40 | Mono fireAndForget(Mono valueIn) { 41 | return valueIn// 42 | .doOnNext(value -> { 43 | log.info("received fire-and-forget " + value + '.'); 44 | fireAndForget.set(value); 45 | })// 46 | .then(); 47 | } 48 | 49 | @MessageMapping("greetings-with-channel") 50 | Flux greetParams(Flux names) { 51 | return names.map(String::toUpperCase).map(GreetingResponse::new); 52 | } 53 | 54 | @MessageMapping("greetings-stream") 55 | Flux greetFlux(Mono name) { 56 | return name.flatMapMany( 57 | leNom -> Flux.fromStream(Stream.generate(() -> new GreetingResponse(leNom.toUpperCase()))).take(2)); 58 | } 59 | 60 | @MessageMapping("greetings-with-name") 61 | Mono greetMono(Mono name) { 62 | return name.map(GreetingResponse::new); 63 | } 64 | 65 | @MessageMapping("greetings") 66 | Mono greet() { 67 | log.info("invoking greetings and returning a GreetingsResponse."); 68 | return Mono.just(new GreetingResponse("Hello, world!")); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/simple/RSocketClientConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.simple; 2 | 3 | import lombok.extern.log4j.Log4j2; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Profile; 8 | import org.springframework.messaging.rsocket.RSocketRequester; 9 | import org.springframework.retrosocket.EnableRSocketClients; 10 | 11 | import javax.annotation.PostConstruct; 12 | 13 | /** 14 | * @author Josh Long 15 | */ 16 | @Log4j2 17 | @Profile("client") 18 | @EnableRSocketClients 19 | @SpringBootApplication 20 | class RSocketClientConfiguration { 21 | 22 | @PostConstruct 23 | public void start() { 24 | log.info("starting " + RSocketClientConfiguration.class.getName() + '.'); 25 | } 26 | 27 | @Bean 28 | RSocketRequester rSocketRequester(@Value("${service.port}") int port, RSocketRequester.Builder builder) { 29 | return builder.connectTcp("localhost", port).block(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/simple/RSocketClientTest.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.simple; 2 | 3 | import lombok.extern.log4j.Log4j2; 4 | import org.junit.jupiter.api.AfterAll; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.BeforeAll; 7 | import org.junit.jupiter.api.Test; 8 | import org.springframework.boot.WebApplicationType; 9 | import org.springframework.boot.builder.SpringApplicationBuilder; 10 | import org.springframework.context.ConfigurableApplicationContext; 11 | import org.springframework.util.SocketUtils; 12 | import reactor.core.publisher.Flux; 13 | import reactor.core.publisher.Mono; 14 | import reactor.test.StepVerifier; 15 | 16 | import java.util.concurrent.atomic.AtomicInteger; 17 | 18 | /** 19 | * @author Josh Long 20 | */ 21 | 22 | @Log4j2 23 | public class RSocketClientTest { 24 | 25 | static ConfigurableApplicationContext serviceApplicationContext; 26 | 27 | static AtomicInteger port = new AtomicInteger(SocketUtils.findAvailableTcpPort()); 28 | 29 | @BeforeAll 30 | public static void begin() { 31 | serviceApplicationContext = new SpringApplicationBuilder(RSocketServerConfiguration.class)// 32 | .web(WebApplicationType.NONE) 33 | .run("--spring.profiles.active=service", "--spring.rsocket.server.port=" + port.get()); 34 | } 35 | 36 | @AfterAll 37 | public static void destroy() { 38 | serviceApplicationContext.stop(); 39 | } 40 | 41 | @Test 42 | public void destinationVariablesAndPayload() { 43 | GreetingClient greetingClient = buildClient(); 44 | Mono greetingResponseFlux = greetingClient.greetMonoNameDestinationVariable("jlong", 36, 45 | Mono.just("Hello")); 46 | StepVerifier// 47 | .create(greetingResponseFlux)// 48 | .expectNextMatches(gr -> gr.equalsIgnoreCase("Hello"))// 49 | .verifyComplete(); 50 | } 51 | 52 | @Test 53 | public void monoInFluxOut() { 54 | GreetingClient greetingClient = buildClient(); 55 | Flux greetingResponseFlux = greetingClient.greetStream(Mono.just("a")); 56 | StepVerifier// 57 | .create(greetingResponseFlux)// 58 | .expectNextCount(1).expectNextMatches(gr -> gr.getMessage().equalsIgnoreCase("A"))// 59 | .verifyComplete(); 60 | 61 | } 62 | 63 | @Test 64 | public void fluxInFluxOut() { 65 | GreetingClient greetingClient = buildClient(); 66 | Flux greetingResponseFlux = greetingClient.greetParams(Flux.just("a", "b")); 67 | StepVerifier// 68 | .create(greetingResponseFlux)// 69 | .expectNextMatches(gr -> gr.getMessage().equalsIgnoreCase("A"))// 70 | .expectNextMatches(gr -> gr.getMessage().equalsIgnoreCase("B"))// 71 | .verifyComplete(); 72 | 73 | } 74 | 75 | @Test 76 | public void monoInMonoOut() { 77 | GreetingClient greetingClient = buildClient(); 78 | Mono greet = greetingClient.greet(Mono.just("Hello, Mario")); 79 | StepVerifier// 80 | .create(greet)// 81 | .expectNextMatches(gr -> gr.getMessage().equalsIgnoreCase("Hello, Mario"))// 82 | .verifyComplete(); 83 | 84 | } 85 | 86 | @Test 87 | public void noValueInMonoOut() throws Exception { 88 | GreetingClient greetingClient = buildClient(); 89 | Mono greet = greetingClient.greet(); 90 | StepVerifier// 91 | .create(greet)// 92 | .expectNextMatches(gr -> gr.getMessage().equalsIgnoreCase("Hello, world!"))// 93 | .verifyComplete(); 94 | 95 | } 96 | 97 | @Test 98 | public void fireAndForget() throws Exception { 99 | GreetingClient greetingClient = buildClient(); 100 | String name = "Kimly"; 101 | Mono greet = greetingClient.greetFireAndForget(Mono.just(name)); 102 | StepVerifier// 103 | .create(greet)// 104 | .verifyComplete(); 105 | 106 | Thread.sleep(1000); 107 | boolean kimly = GreetingsController.fireAndForget.get().equalsIgnoreCase(name); 108 | Assertions.assertTrue(kimly, "the name perceived on the service is the same as we sent."); 109 | } 110 | 111 | private GreetingClient buildClient() { 112 | ConfigurableApplicationContext context = new SpringApplicationBuilder(RSocketClientConfiguration.class)// 113 | .web(WebApplicationType.NONE)// 114 | .run("--service.port=" + port.get(), "--spring.profiles.active=client"); 115 | return context.getBean(GreetingClient.class); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/java/org/springframework/retrosocket/simple/RSocketServerConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.springframework.retrosocket.simple; 2 | 3 | import lombok.extern.log4j.Log4j2; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.context.annotation.Profile; 8 | 9 | import javax.annotation.PostConstruct; 10 | 11 | /** 12 | * @author Josh Long 13 | */ 14 | @Log4j2 15 | @Profile("service") 16 | @Configuration 17 | @EnableAutoConfiguration 18 | class RSocketServerConfiguration { 19 | 20 | @Bean 21 | GreetingsController greetingsController() { 22 | return new GreetingsController(); 23 | } 24 | 25 | @PostConstruct 26 | public void start() { 27 | log.info("starting " + RSocketServerConfiguration.class.getName() + '.'); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /spring-retrosocket/src/test/resources/application-service.properties: -------------------------------------------------------------------------------- 1 | spring.rsocket.server.port=8888 -------------------------------------------------------------------------------- /spring-retrosocket/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | logging.level.org.springframework.retrosocket=DEBUG 2 | -------------------------------------------------------------------------------- /test_aot.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | CLIENT_DIR=spring-retrosocket-samples/hello-client/ 3 | ./install.sh && mvn -f $CLIENT_DIR/pom.xml -DskipTests=true spring-aot:generate 2>&1 | tee $HOME/Desktop/aot.logs 4 | -------------------------------------------------------------------------------- /test_native.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | CLIENT_DIR=spring-retrosocket-samples/hello-client/ 3 | ./install.sh && mvn -f $CLIENT_DIR/pom.xml -DskipTests=true -Pnative clean package && $CLIENT_DIR/target/hello-client 4 | --------------------------------------------------------------------------------