diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index e65ee453..00000000 --- a/.editorconfig +++ /dev/null @@ -1,14 +0,0 @@ -# EditorConfig is awesome: https://EditorConfig.org - -# top-most EditorConfig file -root = true - -[*] -indent_style = tab -indent_size = 4 -end_of_line = lf -insert_final_newline = true - -[*.yml] -indent_style = space -indent_size = 2 diff --git a/.flattened-pom.xml b/.flattened-pom.xml new file mode 100644 index 00000000..f0c05064 --- /dev/null +++ b/.flattened-pom.xml @@ -0,0 +1,134 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-build + 3.1.3 + + + org.springframework.cloud + spring-cloud-bus-parent + 3.1.2 + pom + spring-cloud-bus-parent + Spring Cloud Bus Parent + https://spring.io/spring-cloud/spring-cloud-bus-parent + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 the original author or authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. + + See the License for the specific language governing permissions and + limitations under the License. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-bus.git + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-bus.git + https://github.com/spring-cloud/spring-cloud-bus + + + + spring + + + + false + + + true + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + + + false + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + + false + + spring-releases + Spring Releases + https://repo.spring.io/release + + + + + diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md deleted file mode 100644 index eb9a16ae..00000000 --- a/.github/CONTRIBUTING.md +++ /dev/null @@ -1,45 +0,0 @@ - -# Contributing - -Spring Cloud is released under the non-restrictive Apache 2.0 license, -and follows a very standard Github development process, using Github -tracker for issues and merging pull requests into master. If you want -to contribute even something trivial please do not hesitate, but -follow the guidelines below. - -## Sign the Contributor License Agreement -Before we accept a non-trivial patch or pull request we will need you to sign the -[Contributor License Agreement](https://cla.pivotal.io/sign/spring). -Signing the contributor's agreement does not grant anyone commit rights to the main -repository, but it does mean that we can accept your contributions, and you will get an -author credit if we do. Active contributors might be asked to join the core team, and -given the ability to merge pull requests. - -## Code of Conduct -This project adheres to the Contributor Covenant [code of -conduct](https://github.com/spring-cloud/spring-cloud-build/blob/master/docs/src/main/asciidoc/code-of-conduct.adoc). By participating, you are expected to uphold this code. Please report -unacceptable behavior to spring-code-of-conduct@pivotal.io. - -## Code Conventions and Housekeeping -None of these is essential for a pull request, but they will all help. They can also be -added after the original pull request but before a merge. - -* Use the Spring Framework code format conventions. If you use Eclipse - you can import formatter settings using the - `eclipse-code-formatter.xml` file from the - [Spring Cloud Build](https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-dependencies-parent/eclipse-code-formatter.xml) project. If using IntelliJ, you can use the - [Eclipse Code Formatter Plugin](https://plugins.jetbrains.com/plugin/6546) to import the same file. -* Make sure all new `.java` files to have a simple Javadoc class comment with at least an - `@author` tag identifying you, and preferably at least a paragraph on what the class is - for. -* Add the ASF license header comment to all new `.java` files (copy from existing files - in the project) -* Add yourself as an `@author` to the .java files that you modify substantially (more - than cosmetic changes). -* Add some Javadocs and, if you change the namespace, some XSD doc elements. -* A few unit tests would help a lot as well -- someone has to do it. -* If no-one else is using your branch, please rebase it against the current master (or - other target branch in the main project). -* When writing a commit message please follow [these conventions](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), - if you are fixing an existing issue please add `Fixes gh-XXXX` at the end of the commit - message (where XXXX is the issue number). diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 0bc5ef4f..00000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,20 +0,0 @@ - diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index aeafef9d..00000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -**Describe the bug** -Please provide details of the problem, including the version of Spring Cloud that you -are using. - -**Sample** -If possible, please provide a test case or sample application that reproduces -the problem. This makes it much easier for us to diagnose the problem and to verify that -we have fixed it. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index bbcbbe7d..00000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 00000000..45932973 --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,53 @@ +name: Deploy Docs +run-name: ${{ format('{0} ({1})', github.workflow, github.event.inputs.build-refname || 'all') }} +on: + workflow_dispatch: + inputs: + build-refname: + description: Enter git refname to build (e.g., 5.7.x). + required: false + push: + branches: docs-build +env: + GRADLE_ENTERPRISE_SECRET_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} +permissions: + contents: write +jobs: + build: + if: github.repository_owner == 'spring-cloud' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 5 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Set up refname build + if: github.event.inputs.build-refname + run: | + git fetch --depth 1 https://github.com/$GITHUB_REPOSITORY ${{ github.event.inputs.build-refname }} + export BUILD_REFNAME=${{ github.event.inputs.build-refname }} + echo "BUILD_REFNAME=$BUILD_REFNAME" >> $GITHUB_ENV + export BUILD_VERSION=$(git cat-file --textconv FETCH_HEAD:pom.xml | python3 -c "import xml.etree.ElementTree as xml; from sys import stdin; print(xml.parse(stdin).getroot().find('{http://maven.apache.org/POM/4.0.0}version').text)") + echo BUILD_VERSION=$BUILD_VERSION >> $GITHUB_ENV + - name: Run Antora + run: | + ./mvnw --no-transfer-progress -B antora + - name: Publish Docs + uses: rwinch/spring-doc-actions/rsync-antora-reference@httpdocs-path + with: + docs-username: ${{ secrets.DOCS_USERNAME }} + docs-host: ${{ secrets.DOCS_HOST }} + docs-ssh-key: ${{ secrets.DOCS_SSH_KEY }} + docs-ssh-host-key: ${{ secrets.DOCS_SSH_HOST_KEY }} + site-path: target/antora/site + - name: Bust Cloudflare Cache + uses: spring-io/spring-doc-actions/bust-cloudflare-antora-cache@v0.0.11 + with: + context-root: spring-cloud-bus + cloudflare-zone-id: ${{ secrets.CLOUDFLARE_ZONE_ID }} + cloudflare-cache-token: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml deleted file mode 100644 index a55f1443..00000000 --- a/.github/workflows/maven.yaml +++ /dev/null @@ -1,38 +0,0 @@ -# This workflow will build a Java project with Maven -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven - -name: Build -on: - push: - branches: [ main, 3.1.x ] - pull_request: - branches: [ main, 3.1.x ] -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up JDK - uses: actions/setup-java@v2 - with: - distribution: 'temurin' - java-version: '17' - - name: Cache local Maven repository - uses: actions/cache@v2 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Build with Maven - run: ./mvnw -s .settings.xml clean org.jacoco:jacoco-maven-plugin:prepare-agent install -U -P sonar -nsu --batch-mode -Dmaven.test.redirectTestOutputToFile=true -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn - - name: Publish Test Report - uses: mikepenz/action-junit-report@v2 - if: always() # always run even if the previous step fails - with: - report_paths: '**/surefire-reports/TEST-*.xml' - - name: Archive code coverage results - uses: actions/upload-artifact@v2 - with: - name: surefire-reports - path: '**/surefire-reports/*' diff --git a/.gitignore b/.gitignore index 4ddab872..6be8a4a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,22 @@ -*~ -#* -*# -.#* -.classpath +target/ +.settings/ .project -.settings +.classpath +*.orig .springBeans -.gradle -build -bin -target/ -_site/ -*.swp -.idea -*.iml .factorypath -.vscode/ -.flattened-pom.xml - +.sts4-cache +.ant-targets-build.xml +src/ant/.ant-targets-upload-dist.xml +*.sonar4clipse* +.DS_Store +*.iml +*.ipr +*.iws +/.idea/ +*.graphml +node +node_modules +build +package.json +package-lock.json diff --git a/.mvn/maven.config b/.mvn/maven.config deleted file mode 100644 index 381df16f..00000000 --- a/.mvn/maven.config +++ /dev/null @@ -1 +0,0 @@ --DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/snapshot -P spring diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 00000000..b901097f --- /dev/null +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,117 @@ +/* + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar index 5fd4d502..2cc7d4a5 100644 Binary files a/.mvn/wrapper/maven-wrapper.jar and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 56bb0164..642d572c 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1 +1,2 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip \ No newline at end of file +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/.sdkmanrc b/.sdkmanrc deleted file mode 100644 index 415f9083..00000000 --- a/.sdkmanrc +++ /dev/null @@ -1,3 +0,0 @@ -# Enable auto-env through the sdkman_auto_env config -# Add key=value pairs of SDKs to use below -java=17.0.1-tem diff --git a/.settings.xml b/.settings.xml deleted file mode 100644 index a50de34a..00000000 --- a/.settings.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - repo.spring.io - ${env.CI_DEPLOY_USERNAME} - ${env.CI_DEPLOY_PASSWORD} - - - - - - spring - - true - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - diff --git a/.springformat b/.springformat deleted file mode 100644 index e69de29b..00000000 diff --git a/Guardfile b/Guardfile deleted file mode 100644 index b5561567..00000000 --- a/Guardfile +++ /dev/null @@ -1,12 +0,0 @@ -require 'asciidoctor' -require 'erb' -require './src/main/ruby/readme.rb' - -options = {:mkdirs => true, :safe => :unsafe, :attributes => ['linkcss', 'allow-uri-read']} - -guard 'shell' do - watch(/^src\/[A-Z-a-z][^#]*\.adoc$/) {|m| - SpringCloud::Build.render_file('src/main/asciidoc/README.adoc', :to_file => './README.adoc') - Asciidoctor.render_file('src/main/asciidoc/spring-cloud-bus.adoc', options.merge(:to_dir => 'target/generated-docs')) - } -end diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 62589edd..00000000 --- a/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - https://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/README.adoc b/README.adoc index 23f9de41..143a9a5f 100644 --- a/README.adoc +++ b/README.adoc @@ -1,376 +1,23 @@ -//// -DO NOT EDIT THIS FILE. IT WAS GENERATED. -Manual changes to this file will be lost when it is generated again. -Edit the files in the src/main/asciidoc/ directory instead. -//// += Spring Cloud Bus Docs Build +You're currently viewing the Antora playbook branch. +The playbook branch hosts the docs build that is used to build and publish the production docs site. -= Spring Cloud Bus -:doctype: book -:idprefix: -:idseparator: - -:toc: left -:toclevels: 4 -:tabsize: 4 -:numbered: -:sectanchors: -:sectnums: -:icons: font -:hide-uri-scheme: -:docinfo: shared,private +The Spring Cloud Bus reference docs are built using https://antora.org[Antora]. +This README covers how to build the docs in a software branch as well as how to build the production docs site locally. -:sc-ext: java -:project-full-name: Spring Cloud Bus +== Building the Site -Spring Cloud Bus links the nodes of a distributed system with a lightweight message -broker. This broker can then be used to broadcast state changes (such as configuration -changes) or other management instructions. A key idea is that the bus is like a -distributed actuator for a Spring Boot application that is scaled out. However, it can -also be used as a communication channel between apps. This project provides starters for -either an AMQP broker or Kafka as the transport. +You can build the entire site by invoking the following on the docs-build branch and then viewing the site at `target/site/index.html` -== Quick Start - -Spring Cloud Bus works by adding Spring Boot autconfiguration if it detects itself on the -classpath. To enable the bus, add `spring-cloud-starter-bus-amqp` or -`spring-cloud-starter-bus-kafka` to your dependency management. Spring Cloud takes care of -the rest. Make sure the broker (RabbitMQ or Kafka) is available and configured. When -running on localhost, you need not do anything. If you run remotely, use Spring Cloud -Connectors or Spring Boot conventions to define the broker credentials, as shown in the -following example for Rabbit: - -.application.yml ----- -spring: - rabbitmq: - host: mybroker.com - port: 5672 - username: user - password: secret ----- - -The bus currently supports sending messages to all nodes listening or all nodes for a -particular service (as defined by Eureka). The `/bus/*` actuator namespace has some HTTP -endpoints. Currently, two are implemented. The first, `/bus/env`, sends key/value pairs to -update each node's Spring Environment. The second, `/bus/refresh`, reloads each -application's configuration, as though they had all been pinged on their `/refresh` -endpoint. - -NOTE: The Spring Cloud Bus starters cover Rabbit and Kafka, because those are the two most -common implementations. However, Spring Cloud Stream is quite flexible, and the binder -works with `spring-cloud-bus`. - -== Building - -:jdkversion: 17 - -=== Basic Compile and Test - -To build the source you will need to install JDK {jdkversion}. - -Spring Cloud uses Maven for most build-related activities, and you -should be able to get off the ground quite quickly by cloning the -project you are interested in and typing - ----- -$ ./mvnw install ----- - -NOTE: You can also install Maven (>=3.3.3) yourself and run the `mvn` command -in place of `./mvnw` in the examples below. If you do that you also -might need to add `-P spring` if your local Maven settings do not -contain repository declarations for spring pre-release artifacts. - -NOTE: Be aware that you might need to increase the amount of memory -available to Maven by setting a `MAVEN_OPTS` environment variable with -a value like `-Xmx512m -XX:MaxPermSize=128m`. We try to cover this in -the `.mvn` configuration, so if you find you have to do it to make a -build succeed, please raise a ticket to get the settings added to -source control. - -The projects that require middleware (i.e. Redis) for testing generally -require that a local instance of [Docker](https://www.docker.com/get-started) is installed and running. - - -=== Documentation - -The spring-cloud-build module has a "docs" profile, and if you switch -that on it will try to build asciidoc sources from -`src/main/asciidoc`. As part of that process it will look for a -`README.adoc` and process it by loading all the includes, but not -parsing or rendering it, just copying it to `${main.basedir}` -(defaults to `${basedir}`, i.e. the root of the project). If there are -any changes in the README it will then show up after a Maven build as -a modified file in the correct place. Just commit it and push the change. - -=== Working with the code -If you don't have an IDE preference we would recommend that you use -https://www.springsource.com/developer/sts[Spring Tools Suite] or -https://eclipse.org[Eclipse] when working with the code. We use the -https://eclipse.org/m2e/[m2eclipse] eclipse plugin for maven support. Other IDEs and tools -should also work without issue as long as they use Maven 3.3.3 or better. - -==== Activate the Spring Maven profile -Spring Cloud projects require the 'spring' Maven profile to be activated to resolve -the spring milestone and snapshot repositories. Use your preferred IDE to set this -profile to be active, or you may experience build errors. - -==== Importing into eclipse with m2eclipse -We recommend the https://eclipse.org/m2e/[m2eclipse] eclipse plugin when working with -eclipse. If you don't already have m2eclipse installed it is available from the "eclipse -marketplace". - -NOTE: Older versions of m2e do not support Maven 3.3, so once the -projects are imported into Eclipse you will also need to tell -m2eclipse to use the right profile for the projects. If you -see many different errors related to the POMs in the projects, check -that you have an up to date installation. If you can't upgrade m2e, -add the "spring" profile to your `settings.xml`. Alternatively you can -copy the repository settings from the "spring" profile of the parent -pom into your `settings.xml`. - -==== Importing into eclipse without m2eclipse -If you prefer not to use m2eclipse you can generate eclipse project metadata using the -following command: - -[indent=0] +[source,bash] ---- - $ ./mvnw eclipse:eclipse +./mvnw antora ---- -The generated eclipse projects can be imported by selecting `import existing projects` -from the `file` menu. - - -== Contributing - -:spring-cloud-build-branch: master - -Spring Cloud is released under the non-restrictive Apache 2.0 license, -and follows a very standard Github development process, using Github -tracker for issues and merging pull requests into master. If you want -to contribute even something trivial please do not hesitate, but -follow the guidelines below. - -=== Sign the Contributor License Agreement -Before we accept a non-trivial patch or pull request we will need you to sign the -https://cla.pivotal.io/sign/spring[Contributor License Agreement]. -Signing the contributor's agreement does not grant anyone commit rights to the main -repository, but it does mean that we can accept your contributions, and you will get an -author credit if we do. Active contributors might be asked to join the core team, and -given the ability to merge pull requests. - -=== Code of Conduct -This project adheres to the Contributor Covenant https://github.com/spring-cloud/spring-cloud-build/blob/master/docs/src/main/asciidoc/code-of-conduct.adoc[code of -conduct]. By participating, you are expected to uphold this code. Please report -unacceptable behavior to spring-code-of-conduct@pivotal.io. +== Building a Specific Branch -=== Code Conventions and Housekeeping -None of these is essential for a pull request, but they will all help. They can also be -added after the original pull request but before a merge. - -* Use the Spring Framework code format conventions. If you use Eclipse - you can import formatter settings using the - `eclipse-code-formatter.xml` file from the - https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-dependencies-parent/eclipse-code-formatter.xml[Spring - Cloud Build] project. If using IntelliJ, you can use the - https://plugins.jetbrains.com/plugin/6546[Eclipse Code Formatter - Plugin] to import the same file. -* Make sure all new `.java` files to have a simple Javadoc class comment with at least an - `@author` tag identifying you, and preferably at least a paragraph on what the class is - for. -* Add the ASF license header comment to all new `.java` files (copy from existing files - in the project) -* Add yourself as an `@author` to the .java files that you modify substantially (more - than cosmetic changes). -* Add some Javadocs and, if you change the namespace, some XSD doc elements. -* A few unit tests would help a lot as well -- someone has to do it. -* If no-one else is using your branch, please rebase it against the current master (or - other target branch in the main project). -* When writing a commit message please follow https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html[these conventions], - if you are fixing an existing issue please add `Fixes gh-XXXX` at the end of the commit - message (where XXXX is the issue number). - -=== Checkstyle - -Spring Cloud Build comes with a set of checkstyle rules. You can find them in the `spring-cloud-build-tools` module. The most notable files under the module are: - -.spring-cloud-build-tools/ ----- -└── src -    ├── checkstyle -    │   └── checkstyle-suppressions.xml <3> -    └── main -    └── resources -    ├── checkstyle-header.txt <2> -    └── checkstyle.xml <1> +[source,bash] ---- -<1> Default Checkstyle rules -<2> File header setup -<3> Default suppression rules - -==== Checkstyle configuration - -Checkstyle rules are *disabled by default*. To add checkstyle to your project just define the following properties and plugins. - -.pom.xml +./mvnw antora ---- - -true <1> - true - <2> - true - <3> - - - - - <4> - io.spring.javaformat - spring-javaformat-maven-plugin - - <5> - org.apache.maven.plugins - maven-checkstyle-plugin - - - - - - <5> - org.apache.maven.plugins - maven-checkstyle-plugin - - - - ----- -<1> Fails the build upon Checkstyle errors -<2> Fails the build upon Checkstyle violations -<3> Checkstyle analyzes also the test sources -<4> Add the Spring Java Format plugin that will reformat your code to pass most of the Checkstyle formatting rules -<5> Add checkstyle plugin to your build and reporting phases - -If you need to suppress some rules (e.g. line length needs to be longer), then it's enough for you to define a file under `${project.root}/src/checkstyle/checkstyle-suppressions.xml` with your suppressions. Example: - -.projectRoot/src/checkstyle/checkstyle-suppresions.xml ----- - - - - - - ----- - -It's advisable to copy the `${spring-cloud-build.rootFolder}/.editorconfig` and `${spring-cloud-build.rootFolder}/.springformat` to your project. That way, some default formatting rules will be applied. You can do so by running this script: - -```bash -$ curl https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/.editorconfig -o .editorconfig -$ touch .springformat -``` - -=== IDE setup - -==== Intellij IDEA - -In order to setup Intellij you should import our coding conventions, inspection profiles and set up the checkstyle plugin. -The following files can be found in the https://github.com/spring-cloud/spring-cloud-build/tree/master/spring-cloud-build-tools[Spring Cloud Build] project. - -.spring-cloud-build-tools/ ----- -└── src -    ├── checkstyle -    │   └── checkstyle-suppressions.xml <3> -    └── main -    └── resources -    ├── checkstyle-header.txt <2> -    ├── checkstyle.xml <1> -    └── intellij -       ├── Intellij_Project_Defaults.xml <4> -       └── Intellij_Spring_Boot_Java_Conventions.xml <5> ----- -<1> Default Checkstyle rules -<2> File header setup -<3> Default suppression rules -<4> Project defaults for Intellij that apply most of Checkstyle rules -<5> Project style conventions for Intellij that apply most of Checkstyle rules - -.Code style - -image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-code-style.png[Code style] - -Go to `File` -> `Settings` -> `Editor` -> `Code style`. There click on the icon next to the `Scheme` section. There, click on the `Import Scheme` value and pick the `Intellij IDEA code style XML` option. Import the `spring-cloud-build-tools/src/main/resources/intellij/Intellij_Spring_Boot_Java_Conventions.xml` file. - -.Inspection profiles - -image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-inspections.png[Code style] - -Go to `File` -> `Settings` -> `Editor` -> `Inspections`. There click on the icon next to the `Profile` section. There, click on the `Import Profile` and import the `spring-cloud-build-tools/src/main/resources/intellij/Intellij_Project_Defaults.xml` file. - -.Checkstyle - -To have Intellij work with Checkstyle, you have to install the `Checkstyle` plugin. It's advisable to also install the `Assertions2Assertj` to automatically convert the JUnit assertions - -image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-checkstyle.png[Checkstyle] - -Go to `File` -> `Settings` -> `Other settings` -> `Checkstyle`. There click on the `+` icon in the `Configuration file` section. There, you'll have to define where the checkstyle rules should be picked from. In the image above, we've picked the rules from the cloned Spring Cloud Build repository. However, you can point to the Spring Cloud Build's GitHub repository (e.g. for the `checkstyle.xml` : `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle.xml`). We need to provide the following variables: - -- `checkstyle.header.file` - please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` URL. -- `checkstyle.suppressions.file` - default suppressions. Please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` URL. -- `checkstyle.additional.suppressions.file` - this variable corresponds to suppressions in your local project. E.g. you're working on `spring-cloud-contract`. Then point to the `project-root/src/checkstyle/checkstyle-suppressions.xml` folder. Example for `spring-cloud-contract` would be: `/home/username/spring-cloud-contract/src/checkstyle/checkstyle-suppressions.xml`. - -IMPORTANT: Remember to set the `Scan Scope` to `All sources` since we apply checkstyle rules for production and test sources. - -=== Duplicate Finder - -Spring Cloud Build brings along the `basepom:duplicate-finder-maven-plugin`, that enables flagging duplicate and conflicting classes and resources on the java classpath. - -==== Duplicate Finder configuration - -Duplicate finder is *enabled by default* and will run in the `verify` phase of your Maven build, but it will only take effect in your project if you add the `duplicate-finder-maven-plugin` to the `build` section of the projecst's `pom.xml`. - -.pom.xml -[source,xml] ----- - - - - org.basepom.maven - duplicate-finder-maven-plugin - - - ----- - -For other properties, we have set defaults as listed in the https://github.com/basepom/duplicate-finder-maven-plugin/wiki[plugin documentation]. - -You can easily override them but setting the value of the selected property prefixed with `duplicate-finder-maven-plugin`. For example, set `duplicate-finder-maven-plugin.skip` to `true` in order to skip duplicates check in your build. - -If you need to add `ignoredClassPatterns` or `ignoredResourcePatterns` to your setup, make sure to add them in the plugin configuration section of your project: - -[source,xml] ----- - - - - org.basepom.maven - duplicate-finder-maven-plugin - - - org.joda.time.base.BaseDateTime - .*module-info - - - changelog.txt - - - - - - - ----- - diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 04685956..00000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security Policy - -## Reporting a Vulnerability - -To report security vulnerabilities, please go to https://pivotal.io/security. diff --git a/docs/antora-playbook.yml b/antora-playbook.yml similarity index 62% rename from docs/antora-playbook.yml rename to antora-playbook.yml index 9a70e676..d04b0e72 100644 --- a/docs/antora-playbook.yml +++ b/antora-playbook.yml @@ -6,38 +6,39 @@ antora: - '@antora/collector-extension' - '@antora/atlas-extension' - require: '@springio/antora-extensions/root-component-extension' - root_component_name: 'PROJECT_WITHOUT_SPRING' - # FIXME: Run antora once using this extension to migrate to the Asciidoc Tabs syntax - # and then remove this extension - - require: '@springio/antora-extensions/tabs-migration-extension' - unwrap_example_block: always - save_result: true + root_component_name: 'cloud-bus' site: - title: PROJECT_FULL_NAME - url: https://docs.spring.io/PROJECT_NAME/reference/ + title: Spring Cloud Bus + url: https://docs.spring.io/spring-cloud-bus/reference + robots: allow +git: + ensure_git_suffix: false content: sources: - - url: ./.. - branches: HEAD + - url: https://github.com/spring-cloud/spring-cloud-bus + # Refname matching: + # https://docs.antora.org/antora/latest/playbook/content-refname-matching/ + branches: [ main ] + tags: [ '({4..9}).+({1..9}).+({0..9})?(-{RC,M}+({0..9}))', '!4.1.0-M1' ] start_path: docs - worktrees: true asciidoc: attributes: page-stackoverflow-url: https://stackoverflow.com/tags/spring-cloud page-pagination: '' hide-uri-scheme: '@' tabs-sync-option: '@' - chomp: 'all' extensions: - '@asciidoctor/tabs' - '@springio/asciidoctor-extensions' - sourcemap: true urls: + latest_version_segment_strategy: redirect:to latest_version_segment: '' + redirect_facility: httpd +ui: + bundle: + url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.3.5/ui-bundle.zip + snapshot: true runtime: log: failure_level: warn format: pretty -ui: - bundle: - url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.3.5/ui-bundle.zip diff --git a/docs/.flattened-pom.xml b/docs/.flattened-pom.xml new file mode 100644 index 00000000..3c34793e --- /dev/null +++ b/docs/.flattened-pom.xml @@ -0,0 +1,112 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-bus-parent + 3.1.2 + + org.springframework.cloud + spring-cloud-bus-docs + 3.1.2 + Spring Cloud Bus Docs + Spring Cloud Docs + https://spring.io/spring-cloud/spring-cloud-bus-parent/spring-cloud-bus-docs + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 the original author or authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. + + See the License for the specific language governing permissions and + limitations under the License. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-bus.git/spring-cloud-bus-docs + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-bus.git/spring-cloud-bus-docs + https://github.com/spring-cloud/spring-cloud-bus/spring-cloud-bus-docs + + + + org.springframework.cloud + spring-cloud-starter-bus-amqp + 3.1.2 + compile + + + org.springframework.cloud + spring-cloud-starter-bus-kafka + 3.1.2 + compile + + + diff --git a/docs/.github/workflows/deploy-docs.yml b/docs/.github/workflows/deploy-docs.yml deleted file mode 100644 index be4b92df..00000000 --- a/docs/.github/workflows/deploy-docs.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Deploy Docs -on: - push: - branches-ignore: [ gh-pages ] - tags: '**' - repository_dispatch: - types: request-build-reference # legacy - #schedule: - #- cron: '0 10 * * *' # Once per day at 10am UTC - workflow_dispatch: -permissions: - actions: write -jobs: - build: - runs-on: ubuntu-latest - # if: github.repository_owner == 'spring-cloud' - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - ref: docs-build - fetch-depth: 1 - - name: Dispatch (partial build) - if: github.ref_type == 'branch' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) -f build-refname=${{ github.ref_name }} - - name: Dispatch (full build) - if: github.ref_type == 'tag' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) diff --git a/docs/antora.yml b/docs/antora.yml deleted file mode 100644 index 15b346da..00000000 --- a/docs/antora.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: PROJECT_WITHOUT_SPRING -version: true -title: PROJECT_NAME -nav: - - modules/ROOT/nav.adoc -ext: - collector: - run: - command: ./mvnw --no-transfer-progress -B process-resources -Pdocs -pl docs -Dantora-maven-plugin.phase=none -Dgenerate-docs.phase=none -Dgenerate-readme.phase=none -Dgenerate-cloud-resources.phase=none -Dmaven-dependency-plugin-for-docs.phase=none -Dmaven-dependency-plugin-for-docs-classes.phase=none -DskipTests - local: true - scan: - dir: ./target/classes/antora-resources/ diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc deleted file mode 100644 index 5c1c7f40..00000000 --- a/docs/modules/ROOT/nav.adoc +++ /dev/null @@ -1,9 +0,0 @@ -* xref:index.adoc[] -* xref:spring-cloud-bus.adoc[] -* xref:_attributes.adoc[] -* xref:intro.adoc[] -* xref:quickstart.adoc[] -* xref:README.adoc[] -* xref:_configprops.adoc[] -* xref:appendix.adoc[] -* xref:sagan-index.adoc[] diff --git a/docs/modules/ROOT/pages/README.adoc b/docs/modules/ROOT/pages/README.adoc deleted file mode 100644 index 04fe248e..00000000 --- a/docs/modules/ROOT/pages/README.adoc +++ /dev/null @@ -1,18 +0,0 @@ -[[spring-cloud-bus]] -= Spring Cloud Bus -:page-section-summary-toc: 1 - - -[[quick-start]] -== Quick Start - - -[[building]] -== Building - -include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/building.adoc[] - -[[contributing]] -== Contributing - -include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/contributing.adoc[] diff --git a/docs/modules/ROOT/pages/_attributes.adoc b/docs/modules/ROOT/pages/_attributes.adoc deleted file mode 100644 index c84b3ee6..00000000 --- a/docs/modules/ROOT/pages/_attributes.adoc +++ /dev/null @@ -1,13 +0,0 @@ -:doctype: book -:idprefix: -:idseparator: - -:tabsize: 4 -:numbered: -:sectanchors: -:sectnums: -:icons: font -:hide-uri-scheme: -:docinfo: shared,private - -:sc-ext: java -:project-full-name: Spring Cloud Bus diff --git a/docs/modules/ROOT/pages/_configprops.adoc b/docs/modules/ROOT/pages/_configprops.adoc deleted file mode 100644 index d4cadd82..00000000 --- a/docs/modules/ROOT/pages/_configprops.adoc +++ /dev/null @@ -1,14 +0,0 @@ -|=== -|Name | Default | Description - -|spring.cloud.bus.ack.destination-service | | Service that wants to listen to acks. By default null (meaning all services). -|spring.cloud.bus.ack.enabled | `+++true+++` | Flag to switch off acks (default on). -|spring.cloud.bus.content-type | | The bus mime-type. -|spring.cloud.bus.destination | | Name of Spring Cloud Stream destination for messages. -|spring.cloud.bus.enabled | `+++true+++` | Flag to indicate that the bus is enabled. -|spring.cloud.bus.env.enabled | `+++true+++` | Flag to switch off environment change events (default on). -|spring.cloud.bus.id | `+++application+++` | The identifier for this application instance. -|spring.cloud.bus.refresh.enabled | `+++true+++` | Flag to switch off refresh events (default on). -|spring.cloud.bus.trace.enabled | `+++false+++` | Flag to switch on tracing of acks (default off). - -|=== diff --git a/docs/modules/ROOT/pages/appendix.adoc b/docs/modules/ROOT/pages/appendix.adoc deleted file mode 100644 index eef1c905..00000000 --- a/docs/modules/ROOT/pages/appendix.adoc +++ /dev/null @@ -1,13 +0,0 @@ -:numbered!: -[appendix] -[[common-application-properties]] -= Common application properties -:page-section-summary-toc: 1 - - -Various properties can be specified inside your `application.properties` file, inside your `application.yml` file, or as command line switches. -This appendix provides a list of common {project-full-name} properties and references to the underlying classes that consume them. - -NOTE: Property contributions can come from additional jar files on your classpath, so you should not consider this an exhaustive list. -Also, you can define your own properties. - diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc deleted file mode 100755 index e69de29b..00000000 diff --git a/docs/modules/ROOT/pages/intro.adoc b/docs/modules/ROOT/pages/intro.adoc deleted file mode 100644 index 7274b9f9..00000000 --- a/docs/modules/ROOT/pages/intro.adoc +++ /dev/null @@ -1,6 +0,0 @@ -Spring Cloud Bus links the nodes of a distributed system with a lightweight message -broker. This broker can then be used to broadcast state changes (such as configuration -changes) or other management instructions. A key idea is that the bus is like a -distributed actuator for a Spring Boot application that is scaled out. However, it can -also be used as a communication channel between apps. This project provides starters for -either an AMQP broker or Kafka as the transport. diff --git a/docs/modules/ROOT/pages/quickstart.adoc b/docs/modules/ROOT/pages/quickstart.adoc deleted file mode 100644 index 69e5cde6..00000000 --- a/docs/modules/ROOT/pages/quickstart.adoc +++ /dev/null @@ -1,28 +0,0 @@ -Spring Cloud Bus works by adding Spring Boot autconfiguration if it detects itself on the -classpath. To enable the bus, add `spring-cloud-starter-bus-amqp` or -`spring-cloud-starter-bus-kafka` to your dependency management. Spring Cloud takes care of -the rest. Make sure the broker (RabbitMQ or Kafka) is available and configured. When -running on localhost, you need not do anything. If you run remotely, use Spring Cloud -Connectors or Spring Boot conventions to define the broker credentials, as shown in the -following example for Rabbit: - -.application.yml ----- -spring: - rabbitmq: - host: mybroker.com - port: 5672 - username: user - password: secret ----- - -The bus currently supports sending messages to all nodes listening or all nodes for a -particular service (as defined by Eureka). The `/bus/*` actuator namespace has some HTTP -endpoints. Currently, two are implemented. The first, `/bus/env`, sends key/value pairs to -update each node's Spring Environment. The second, `/bus/refresh`, reloads each -application's configuration, as though they had all been pinged on their `/refresh` -endpoint. - -NOTE: The Spring Cloud Bus starters cover Rabbit and Kafka, because those are the two most -common implementations. However, Spring Cloud Stream is quite flexible, and the binder -works with `spring-cloud-bus`. diff --git a/docs/modules/ROOT/pages/sagan-index.adoc b/docs/modules/ROOT/pages/sagan-index.adoc deleted file mode 100644 index d56dc83b..00000000 --- a/docs/modules/ROOT/pages/sagan-index.adoc +++ /dev/null @@ -1,26 +0,0 @@ - -Spring Cloud Bus links nodes of a distributed system with a lightweight message broker. This can then be used to broadcast state changes (e.g. configuration changes) or other management instructions. AMQP and Kafka broker implementations are included with the project. Alternatively, any link:https://spring.io/projects/spring-cloud-stream[Spring Cloud Stream] binder found on the classpath will work out of the box as a transport. - -## Getting Started -As long as Spring Cloud Bus AMQP and RabbitMQ are on the -classpath any Spring Boot application will try to contact a RabbitMQ -server on `localhost:5672` (the default value of -`spring.rabbitmq.addresses`): - -```java -@Configuration -@EnableAutoConfiguration -@RestController -public class Application { - - @RequestMapping("/") - public String home() { - return "Hello World"; - } - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - -} -``` diff --git a/docs/modules/ROOT/pages/spring-cloud-bus.adoc b/docs/modules/ROOT/pages/spring-cloud-bus.adoc deleted file mode 100644 index 3242f883..00000000 --- a/docs/modules/ROOT/pages/spring-cloud-bus.adoc +++ /dev/null @@ -1,241 +0,0 @@ -[[spring-cloud-bus]] -= Spring Cloud Bus - - -include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/contributing-docs.adoc[] - -[[quick-start]] -== Quick Start - - -[[bus-endpoints]] -== Bus Endpoints - -Spring Cloud Bus provides two endpoints, `/actuator/busrefresh` and `/actuator/busenv` -that correspond to individual actuator endpoints in Spring Cloud Commons, -`/actuator/refresh` and `/actuator/env` respectively. - -[[bus-refresh-endpoint]] -=== Bus Refresh Endpoint -The `/actuator/busrefresh` endpoint clears the `RefreshScope` cache and rebinds -`@ConfigurationProperties`. See the <> documentation for -more information. - -To expose the `/actuator/busrefresh` endpoint, you need to add following configuration to your -application: - -[source,properties] ----- -management.endpoints.web.exposure.include=busrefresh ----- - -[[bus-env-endpoint]] -=== Bus Env Endpoint -The `/actuator/busenv` endpoint updates each instances environment with the specified -key/value pair across multiple instances. - -To expose the `/actuator/busenv` endpoint, you need to add following configuration to your -application: - -[source,properties] ----- -management.endpoints.web.exposure.include=busenv ----- - -The `/actuator/busenv` endpoint accepts `POST` requests with the following shape: - -[source,json] ----- -{ - "name": "key1", - "value": "value1" -} ----- - -[[addressing-an-instance]] -== Addressing an Instance - -Each instance of the application has a service ID, whose value can be set with -`spring.cloud.bus.id` and whose value is expected to be a colon-separated list of -identifiers, in order from least specific to most specific. The default value is -constructed from the environment as a combination of the `spring.application.name` and -`server.port` (or `spring.application.index`, if set). The default value of the ID is -constructed in the form of `app:index:id`, where: - -* `app` is the `vcap.application.name`, if it exists, or `spring.application.name` -* `index` is the `vcap.application.instance_index`, if it exists, -`spring.application.index`, `local.server.port`, `server.port`, or `0` (in that order). -* `id` is the `vcap.application.instance_id`, if it exists, or a random value. - -The HTTP endpoints accept a "`destination`" path parameter, such as -`/busrefresh/customers:9000`, where `destination` is a service ID. If the ID -is owned by an instance on the bus, it processes the message, and all other instances -ignore it. - -[[addressing-all-instances-of-a-service]] -== Addressing All Instances of a Service - -The "`destination`" parameter is used in a Spring `PathMatcher` (with the path separator -as a colon -- `:`) to determine if an instance processes the message. Using the example -from earlier, `/busenv/customers:**` targets all instances of the -"`customers`" service regardless of the rest of the service ID. - -[[service-id-must-be-unique]] -== Service ID Must Be Unique - -The bus tries twice to eliminate processing an event -- once from the original -`ApplicationEvent` and once from the queue. To do so, it checks the sending service ID -against the current service ID. If multiple instances of a service have the same ID, -events are not processed. When running on a local machine, each service is on a different -port, and that port is part of the ID. Cloud Foundry supplies an index to differentiate. -To ensure that the ID is unique outside Cloud Foundry, set `spring.application.index` to -something unique for each instance of a service. - -[[customizing-the-message-broker]] -== Customizing the Message Broker - -Spring Cloud Bus uses https://cloud.spring.io/spring-cloud-stream[Spring Cloud Stream] to -broadcast the messages. So, to get messages to flow, you need only include the binder -implementation of your choice in the classpath. There are convenient starters for the bus -with AMQP (RabbitMQ) and Kafka (`spring-cloud-starter-bus-[amqp|kafka]`). Generally -speaking, Spring Cloud Stream relies on Spring Boot autoconfiguration conventions for -configuring middleware. For instance, the AMQP broker address can be changed with -`spring.rabbitmq.{asterisk}` configuration properties. Spring Cloud Bus has a handful of -native configuration properties in `spring.cloud.bus.{asterisk}` (for example, -`spring.cloud.bus.destination` is the name of the topic to use as the external -middleware). Normally, the defaults suffice. - -To learn more about how to customize the message broker settings, consult the Spring Cloud -Stream documentation. - -[[tracing-bus-events]] -== Tracing Bus Events - -Bus events (subclasses of `RemoteApplicationEvent`) can be traced by setting -`spring.cloud.bus.trace.enabled=true`. If you do so, the Spring Boot `TraceRepository` -(if it is present) shows each event sent and all the acks from each service instance. The -following example comes from the `/trace` endpoint: - -[source,json] ----- -{ - "timestamp": "2015-11-26T10:24:44.411+0000", - "info": { - "signal": "spring.cloud.bus.ack", - "type": "RefreshRemoteApplicationEvent", - "id": "c4d374b7-58ea-4928-a312-31984def293b", - "origin": "stores:8081", - "destination": "*:**" - } - }, - { - "timestamp": "2015-11-26T10:24:41.864+0000", - "info": { - "signal": "spring.cloud.bus.sent", - "type": "RefreshRemoteApplicationEvent", - "id": "c4d374b7-58ea-4928-a312-31984def293b", - "origin": "customers:9000", - "destination": "*:**" - } - }, - { - "timestamp": "2015-11-26T10:24:41.862+0000", - "info": { - "signal": "spring.cloud.bus.ack", - "type": "RefreshRemoteApplicationEvent", - "id": "c4d374b7-58ea-4928-a312-31984def293b", - "origin": "customers:9000", - "destination": "*:**" - } -} ----- - -The preceding trace shows that a `RefreshRemoteApplicationEvent` was sent from -`customers:9000`, broadcast to all services, and received (acked) by `customers:9000` and -`stores:8081`. - -To handle the ack signals yourself, you could add an `@EventListener` for the -`AckRemoteApplicationEvent` and `SentApplicationEvent` types to your app (and enable -tracing). Alternatively, you could tap into the `TraceRepository` and mine the data from -there. - -NOTE: Any Bus application can trace acks. However, sometimes, it is -useful to do this in a central service that can do more complex -queries on the data or forward it to a specialized tracing service. - -[[broadcasting-your-own-events]] -== Broadcasting Your Own Events - -The Bus can carry any event of type `RemoteApplicationEvent`. The default transport is -JSON, and the deserializer needs to know which types are going to be used ahead of time. -To register a new type, you must put it in a subpackage of -`org.springframework.cloud.bus.event`. - -To customise the event name, you can use `@JsonTypeName` on your custom class or rely on -the default strategy, which is to use the simple name of the class. - -NOTE: Both the producer and the consumer need access to the class definition. - -[[registering-events-in-custom-packages]] -=== Registering events in custom packages - -If you cannot or do not want to use a subpackage of `org.springframework.cloud.bus.event` -for your custom events, you must specify which packages to scan for events of type -`RemoteApplicationEvent` by using the `@RemoteApplicationEventScan` annotation. Packages -specified with `@RemoteApplicationEventScan` include subpackages. - -For example, consider the following custom event, called `MyEvent`: - -[source,java] ----- -package com.acme; - -public class MyEvent extends RemoteApplicationEvent { - ... -} ----- - -You can register that event with the deserializer in the following way: - -[source,java] ----- -package com.acme; - -@Configuration -@RemoteApplicationEventScan -public class BusConfiguration { - ... -} ----- - -Without specifying a value, the package of the class where `@RemoteApplicationEventScan` -is used is registered. In this example, `com.acme` is registered by using the package of -`BusConfiguration`. - -You can also explicitly specify the packages to scan by using the `value`, `basePackages` -or `basePackageClasses` properties on `@RemoteApplicationEventScan`, as shown in the -following example: - -[source,java] ----- -package com.acme; - -@Configuration -//@RemoteApplicationEventScan({"com.acme", "foo.bar"}) -//@RemoteApplicationEventScan(basePackages = {"com.acme", "foo.bar", "fizz.buzz"}) -@RemoteApplicationEventScan(basePackageClasses = BusConfiguration.class) -public class BusConfiguration { - ... -} ----- - -All of the preceding examples of `@RemoteApplicationEventScan` are equivalent, in that the -`com.acme` package is registered by explicitly specifying the packages on -`@RemoteApplicationEventScan`. - -NOTE: You can specify multiple base packages to scan. - -[[configuration-properties]] -== Configuration properties - -To see the list of all Bus related configuration properties please check link:appendix.html[the Appendix page]. diff --git a/docs/pom.xml b/docs/pom.xml deleted file mode 100644 index e833f204..00000000 --- a/docs/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - 4.0.0 - org.springframework.cloud - spring-cloud-bus-docs - - org.springframework.cloud - spring-cloud-bus-parent - 4.1.0-SNAPSHOT - - jar - Spring Cloud Bus Docs - Spring Cloud Docs - - spring-cloud-bus - ${basedir}/.. - spring.cloud.bus.* - deploy - - - src/main/asciidoc - - - - ${project.groupId} - spring-cloud-starter-bus-amqp - - - ${project.groupId} - spring-cloud-starter-bus-kafka - - - - - docs - - - - pl.project13.maven - git-commit-id-plugin - - - org.codehaus.mojo - exec-maven-plugin - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.apache.maven.plugins - maven-resources-plugin - - - org.asciidoctor - asciidoctor-maven-plugin - - - org.apache.maven.plugins - maven-antrun-plugin - - - maven-deploy-plugin - - - - - - diff --git a/docs/src/main/asciidoc/ghpages.sh b/docs/src/main/asciidoc/ghpages.sh deleted file mode 100755 index afcc9b16..00000000 --- a/docs/src/main/asciidoc/ghpages.sh +++ /dev/null @@ -1,335 +0,0 @@ -#!/bin/bash -x - -set -e - -# Set default props like MAVEN_PATH, ROOT_FOLDER etc. -function set_default_props() { - # The script should be run from the root folder - ROOT_FOLDER=`pwd` - echo "Current folder is ${ROOT_FOLDER}" - - if [[ ! -e "${ROOT_FOLDER}/.git" ]]; then - echo "You're not in the root folder of the project!" - exit 1 - fi - - # Prop that will let commit the changes - COMMIT_CHANGES="no" - MAVEN_PATH=${MAVEN_PATH:-} - echo "Path to Maven is [${MAVEN_PATH}]" - REPO_NAME=${PWD##*/} - echo "Repo name is [${REPO_NAME}]" - SPRING_CLOUD_STATIC_REPO=${SPRING_CLOUD_STATIC_REPO:-git@github.com:spring-cloud/spring-cloud-static.git} - echo "Spring Cloud Static repo is [${SPRING_CLOUD_STATIC_REPO}" -} - -# Check if gh-pages exists and docs have been built -function check_if_anything_to_sync() { - git remote set-url --push origin `git config remote.origin.url | sed -e 's/^git:/https:/'` - - if ! (git remote set-branches --add origin gh-pages && git fetch -q); then - echo "No gh-pages, so not syncing" - exit 0 - fi - - if ! [ -d docs/target/generated-docs ] && ! [ "${BUILD}" == "yes" ]; then - echo "No gh-pages sources in docs/target/generated-docs, so not syncing" - exit 0 - fi -} - -function retrieve_current_branch() { - # Code getting the name of the current branch. For master we want to publish as we did until now - # https://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch - # If there is a branch already passed will reuse it - otherwise will try to find it - CURRENT_BRANCH=${BRANCH} - if [[ -z "${CURRENT_BRANCH}" ]] ; then - CURRENT_BRANCH=$(git symbolic-ref -q HEAD) - CURRENT_BRANCH=${CURRENT_BRANCH##refs/heads/} - CURRENT_BRANCH=${CURRENT_BRANCH:-HEAD} - fi - echo "Current branch is [${CURRENT_BRANCH}]" - git checkout ${CURRENT_BRANCH} || echo "Failed to check the branch... continuing with the script" -} - -# Switches to the provided value of the release version. We always prefix it with `v` -function switch_to_tag() { - git checkout v${VERSION} -} - -# Build the docs if switch is on -function build_docs_if_applicable() { - if [[ "${BUILD}" == "yes" ]] ; then - ./mvnw clean install -P docs -pl docs -DskipTests - fi -} - -# Get the name of the `docs.main` property -# Get allowed branches - assumes that a `docs` module is available under `docs` profile -function retrieve_doc_properties() { - MAIN_ADOC_VALUE=$("${MAVEN_PATH}"mvn -q \ - -Dexec.executable="echo" \ - -Dexec.args='${docs.main}' \ - --non-recursive \ - org.codehaus.mojo:exec-maven-plugin:1.3.1:exec) - echo "Extracted 'main.adoc' from Maven build [${MAIN_ADOC_VALUE}]" - - - ALLOW_PROPERTY=${ALLOW_PROPERTY:-"docs.allowed.branches"} - ALLOWED_BRANCHES_VALUE=$("${MAVEN_PATH}"mvn -q \ - -Dexec.executable="echo" \ - -Dexec.args="\${${ALLOW_PROPERTY}}" \ - org.codehaus.mojo:exec-maven-plugin:1.3.1:exec \ - -P docs \ - -pl docs) - echo "Extracted '${ALLOW_PROPERTY}' from Maven build [${ALLOWED_BRANCHES_VALUE}]" -} - -# Stash any outstanding changes -function stash_changes() { - git diff-index --quiet HEAD && dirty=$? || (echo "Failed to check if the current repo is dirty. Assuming that it is." && dirty="1") - if [ "$dirty" != "0" ]; then git stash; fi -} - -# Switch to gh-pages branch to sync it with current branch -function add_docs_from_target() { - local DESTINATION_REPO_FOLDER - if [[ -z "${DESTINATION}" && -z "${CLONE}" ]] ; then - DESTINATION_REPO_FOLDER=${ROOT_FOLDER} - elif [[ "${CLONE}" == "yes" ]]; then - mkdir -p ${ROOT_FOLDER}/target - local clonedStatic=${ROOT_FOLDER}/target/spring-cloud-static - if [[ ! -e "${clonedStatic}/.git" ]]; then - echo "Cloning Spring Cloud Static to target" - git clone ${SPRING_CLOUD_STATIC_REPO} ${clonedStatic} && git checkout gh-pages - else - echo "Spring Cloud Static already cloned - will pull changes" - cd ${clonedStatic} && git checkout gh-pages && git pull origin gh-pages - fi - DESTINATION_REPO_FOLDER=${clonedStatic}/${REPO_NAME} - mkdir -p ${DESTINATION_REPO_FOLDER} - else - if [[ ! -e "${DESTINATION}/.git" ]]; then - echo "[${DESTINATION}] is not a git repository" - exit 1 - fi - DESTINATION_REPO_FOLDER=${DESTINATION}/${REPO_NAME} - mkdir -p ${DESTINATION_REPO_FOLDER} - echo "Destination was provided [${DESTINATION}]" - fi - cd ${DESTINATION_REPO_FOLDER} - git checkout gh-pages - git pull origin gh-pages - - # Add git branches - ################################################################### - if [[ -z "${VERSION}" ]] ; then - copy_docs_for_current_version - else - copy_docs_for_provided_version - fi - commit_changes_if_applicable -} - - -# Copies the docs by using the retrieved properties from Maven build -function copy_docs_for_current_version() { - if [[ "${CURRENT_BRANCH}" == "master" ]] ; then - echo -e "Current branch is master - will copy the current docs only to the root folder" - for f in docs/target/generated-docs/*; do - file=${f#docs/target/generated-docs/*} - if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then - # Not ignored... - cp -rf $f ${ROOT_FOLDER}/ - git add -A ${ROOT_FOLDER}/$file - fi - done - COMMIT_CHANGES="yes" - else - echo -e "Current branch is [${CURRENT_BRANCH}]" -<<<<<<< Updated upstream - # https://stackoverflow.com/questions/29300806/a-bash-script-to-check-if-a-string-is-present-in-a-comma-separated-list-of-strin - if [[ ",${WHITELISTED_BRANCHES_VALUE}," = *",${CURRENT_BRANCH},"* ]] ; then -======= - # http://stackoverflow.com/questions/29300806/a-bash-script-to-check-if-a-string-is-present-in-a-comma-separated-list-of-strin - if [[ ",${ALLOWED_BRANCHES_VALUE}," = *",${CURRENT_BRANCH},"* ]] ; then ->>>>>>> Stashed changes - mkdir -p ${ROOT_FOLDER}/${CURRENT_BRANCH} - echo -e "Branch [${CURRENT_BRANCH}] is allowed! Will copy the current docs to the [${CURRENT_BRANCH}] folder" - for f in docs/target/generated-docs/*; do - file=${f#docs/target/generated-docs/*} - if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then - # Not ignored... - # We want users to access 1.0.0.RELEASE/ instead of 1.0.0.RELEASE/spring-cloud.sleuth.html - if [[ "${file}" == "${MAIN_ADOC_VALUE}.html" ]] ; then - # We don't want to copy the spring-cloud-sleuth.html - # we want it to be converted to index.html - cp -rf $f ${ROOT_FOLDER}/${CURRENT_BRANCH}/index.html - git add -A ${ROOT_FOLDER}/${CURRENT_BRANCH}/index.html - else - cp -rf $f ${ROOT_FOLDER}/${CURRENT_BRANCH} - git add -A ${ROOT_FOLDER}/${CURRENT_BRANCH}/$file - fi - fi - done - COMMIT_CHANGES="yes" - else - echo -e "Branch [${CURRENT_BRANCH}] is not on the allow list! Check out the Maven [${ALLOW_PROPERTY}] property in - [docs] module available under [docs] profile. Won't commit any changes to gh-pages for this branch." - fi - fi -} - -# Copies the docs by using the explicitly provided version -function copy_docs_for_provided_version() { - local FOLDER=${DESTINATION_REPO_FOLDER}/${VERSION} - mkdir -p ${FOLDER} - echo -e "Current tag is [v${VERSION}] Will copy the current docs to the [${FOLDER}] folder" - for f in ${ROOT_FOLDER}/docs/target/generated-docs/*; do - file=${f#${ROOT_FOLDER}/docs/target/generated-docs/*} - copy_docs_for_branch ${file} ${FOLDER} - done - COMMIT_CHANGES="yes" - CURRENT_BRANCH="v${VERSION}" -} - -# Copies the docs from target to the provided destination -# Params: -# $1 - file from target -# $2 - destination to which copy the files -function copy_docs_for_branch() { - local file=$1 - local destination=$2 - if ! git ls-files -i -o --exclude-standard --directory | grep -q ^${file}$; then - # Not ignored... - # We want users to access 1.0.0.RELEASE/ instead of 1.0.0.RELEASE/spring-cloud.sleuth.html - if [[ ("${file}" == "${MAIN_ADOC_VALUE}.html") || ("${file}" == "${REPO_NAME}.html") ]] ; then - # We don't want to copy the spring-cloud-sleuth.html - # we want it to be converted to index.html - cp -rf $f ${destination}/index.html - git add -A ${destination}/index.html - else - cp -rf $f ${destination} - git add -A ${destination}/$file - fi - fi -} - -function commit_changes_if_applicable() { - if [[ "${COMMIT_CHANGES}" == "yes" ]] ; then - COMMIT_SUCCESSFUL="no" - git commit -a -m "Sync docs from ${CURRENT_BRANCH} to gh-pages" && COMMIT_SUCCESSFUL="yes" || echo "Failed to commit changes" - - # Uncomment the following push if you want to auto push to - # the gh-pages branch whenever you commit to master locally. - # This is a little extreme. Use with care! - ################################################################### - if [[ "${COMMIT_SUCCESSFUL}" == "yes" ]] ; then - git push origin gh-pages - fi - fi -} - -# Switch back to the previous branch and exit block -function checkout_previous_branch() { - # If -version was provided we need to come back to root project - cd ${ROOT_FOLDER} - git checkout ${CURRENT_BRANCH} || echo "Failed to check the branch... continuing with the script" - if [ "$dirty" != "0" ]; then git stash pop; fi - exit 0 -} - -# Assert if properties have been properly passed -function assert_properties() { -echo "VERSION [${VERSION}], DESTINATION [${DESTINATION}], CLONE [${CLONE}]" -if [[ "${VERSION}" != "" && (-z "${DESTINATION}" && -z "${CLONE}") ]] ; then echo "Version was set but destination / clone was not!"; exit 1;fi -if [[ ("${DESTINATION}" != "" && "${CLONE}" != "") && -z "${VERSION}" ]] ; then echo "Destination / clone was set but version was not!"; exit 1;fi -if [[ "${DESTINATION}" != "" && "${CLONE}" == "yes" ]] ; then echo "Destination and clone was set. Pick one!"; exit 1;fi -} - -# Prints the usage -function print_usage() { -cat </` -- if the destination switch is passed (-d) then the script will check if the provided dir is a git repo and then will - switch to gh-pages of that repo and copy the generated docs to `docs//` - -USAGE: - -You can use the following options: - --v|--version - the script will apply the whole procedure for a particular library version --d|--destination - the root of destination folder where the docs should be copied. You have to use the full path. - E.g. point to spring-cloud-static folder. Can't be used with (-c) --b|--build - will run the standard build process after checking out the branch --c|--clone - will automatically clone the spring-cloud-static repo instead of providing the destination. - Obviously can't be used with (-d) - -EOF -} - - -# ========================================== -# ____ ____ _____ _____ _____ _______ -# / ____|/ ____| __ \|_ _| __ \__ __| -# | (___ | | | |__) | | | | |__) | | | -# \___ \| | | _ / | | | ___/ | | -# ____) | |____| | \ \ _| |_| | | | -# |_____/ \_____|_| \_\_____|_| |_| -# -# ========================================== - -while [[ $# > 0 ]] -do -key="$1" -case ${key} in - -v|--version) - VERSION="$2" - shift # past argument - ;; - -d|--destination) - DESTINATION="$2" - shift # past argument - ;; - -b|--build) - BUILD="yes" - ;; - -c|--clone) - CLONE="yes" - ;; - -h|--help) - print_usage - exit 0 - ;; - *) - echo "Invalid option: [$1]" - print_usage - exit 1 - ;; -esac -shift # past argument or value -done - -assert_properties -set_default_props -check_if_anything_to_sync -if [[ -z "${VERSION}" ]] ; then - retrieve_current_branch -else - switch_to_tag -fi -build_docs_if_applicable -retrieve_doc_properties -stash_changes -add_docs_from_target -checkout_previous_branch diff --git a/mvnw b/mvnw index a08b219e..41c0f0c2 100755 --- a/mvnw +++ b/mvnw @@ -8,7 +8,7 @@ # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # -# https://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script +# Maven Start Up Batch script # # Required ENV vars: # ------------------ @@ -54,38 +54,16 @@ case "`uname`" in CYGWIN*) cygwin=true ;; MINGW*) mingw=true;; Darwin*) darwin=true - # - # Look for the Apple JDKs first to preserve the existing behaviour, and then look - # for the new JDKs provided by Oracle. - # - if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then - # - # Apple JDKs - # - export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then - # - # Apple JDKs - # - export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then - # - # Oracle JDKs - # - export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then - # - # Apple JDKs - # - export JAVA_HOME=`/usr/libexec/java_home` - fi - ;; + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; esac if [ -z "$JAVA_HOME" ] ; then @@ -130,13 +108,12 @@ if $cygwin ; then CLASSPATH=`cygpath --path --unix "$CLASSPATH"` fi -# For Migwn, ensure paths are in UNIX format before anything is touched +# For Mingw, ensure paths are in UNIX format before anything is touched if $mingw ; then [ -n "$M2_HOME" ] && M2_HOME="`(cd "$M2_HOME"; pwd)`" [ -n "$JAVA_HOME" ] && JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? fi if [ -z "$JAVA_HOME" ]; then @@ -184,27 +161,28 @@ fi CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` -fi - # traverses directory structure from process work directory to filesystem root # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { - local basedir=$(pwd) - local wdir=$(pwd) + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" while [ "$wdir" != '/' ] ; do if [ -d "$wdir"/.mvn ] ; then basedir=$wdir break fi - wdir=$(cd "$wdir/.."; pwd) + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround done echo "${basedir}" } @@ -216,9 +194,108 @@ concat_lines() { fi } -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + # Provide a "standardized" way to retrieve the CLI args that will # work with both Windows and non-Windows executions. MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" @@ -226,28 +303,8 @@ export MAVEN_CMD_LINE_ARGS WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -echo "Running version check" -VERSION=$( sed '\!//' -e 's!.*$!!' ) -echo "The found version is [${VERSION}]" - -if echo $VERSION | egrep -q 'M|RC'; then - echo Activating \"milestone\" profile for version=\"$VERSION\" - echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pmilestone" -else - echo Deactivating \"milestone\" profile for version=\"$VERSION\" - echo $MAVEN_ARGS | grep -q milestone && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pmilestone//') -fi - -if echo $VERSION | egrep -q 'RELEASE'; then - echo Activating \"central\" profile for version=\"$VERSION\" - echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pcentral" -else - echo Deactivating \"central\" profile for version=\"$VERSION\" - echo $MAVEN_ARGS | grep -q central && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pcentral//') -fi - exec "$JAVACMD" \ $MAVEN_OPTS \ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} ${MAVEN_ARGS} "$@" + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd index 7ecd01d8..86115719 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -7,7 +7,7 @@ @REM "License"); you may not use this file except in compliance @REM with the License. You may obtain a copy of the License at @REM -@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM http://www.apache.org/licenses/LICENSE-2.0 @REM @REM Unless required by applicable law or agreed to in writing, @REM software distributed under the License is distributed on an @@ -18,7 +18,7 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script +@REM Maven Start Up Batch script @REM @REM Required ENV vars: @REM JAVA_HOME - location of a JDK home dir @@ -26,7 +26,7 @@ @REM Optional ENV vars @REM M2_HOME - location of maven2's installed home dir @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven @REM e.g. to debug Maven itself, use @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 @@ -35,7 +35,9 @@ @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' @echo off -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% @REM set %HOME% to equivalent of $HOME @@ -80,8 +82,6 @@ goto error :init -set MAVEN_CMD_LINE_ARGS=%* - @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". @REM Fallback to current working directory if not found. @@ -117,11 +117,48 @@ for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do s :endReadAdditionalConfig SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* if ERRORLEVEL 1 goto error goto end diff --git a/pom.xml b/pom.xml index 1a3db196..750df1b1 100644 --- a/pom.xml +++ b/pom.xml @@ -1,186 +1,70 @@ - - - 4.0.0 - - spring-cloud-bus-parent - 4.1.0-SNAPSHOT - pom + + - spring-cloud-bus-parent - Spring Cloud Bus Parent + 4.0.0 - - org.springframework.cloud - spring-cloud-build - 4.1.0-SNAPSHOT - - + org.springframework.cloud + spring-cloud-bus-docs-build + 0.0.1-SNAPSHOT - - spring-cloud-bus-dependencies - spring-cloud-bus - spring-cloud-bus-rsocket - spring-cloud-bus-tests - spring-cloud-starter-bus-amqp - spring-cloud-starter-bus-kafka - spring-cloud-starter-bus-stream - docs - + Spring Cloud Bus Docs Build + Builds Spring Cloud Bus Docs. + https://spring.io/projects/spring-cloud-bus + + scm:git:https://github.com/spring-cloud/spring-cloud-bus.git + + + scm:git:git@github.com:spring-cloud/spring-cloud-bus.git + + https://github.com/spring-cloud/spring-cloud-bus + + + https://github.com/spring-cloud/spring-cloud-bus/issues + - 4.1.0-SNAPSHOT - 4.1.0-SNAPSHOT - 4.1.0-SNAPSHOT - bus + 0.0.3 + - org.codehaus.mojo - flatten-maven-plugin - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - io.spring.javaformat - spring-javaformat-maven-plugin + io.spring.maven.antora + antora-maven-plugin + ${io.spring.maven.antora-version} + true + + + + + + + + 9d489079e5ec46dbb238909fee5c9c29 + WB1FQYI187 + springcloudbus + + - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - - - - - spring - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - - - - - org.springframework.cloud - spring-cloud-bus-dependencies - ${project.version} - pom - import - - - org.springframework.cloud - spring-cloud-commons-dependencies - ${spring-cloud-commons.version} - pom - import - - - org.springframework.cloud - spring-cloud-test-support - ${spring-cloud-commons.version} - - - org.springframework.cloud - spring-cloud-stream - ${spring-cloud-stream.version} - - - org.springframework.cloud - spring-cloud-stream-dependencies - ${spring-cloud-stream.version} - pom - import - - - org.springframework.cloud - spring-cloud-function-dependencies - ${spring-cloud-function.version} - pom - import - - - org.springframework.cloud - spring-cloud-function-rsocket - ${spring-cloud-function.version} - - - - - - https://github.com/spring-cloud/spring-cloud-bus - scm:git:git://github.com/spring-cloud/spring-cloud-bus.git - - - scm:git:ssh://git@github.com/spring-cloud/spring-cloud-bus.git - - HEAD - + + + spring-snapshot + https://repo.spring.io/snapshot + + true + + + false + + + + spring-milestone + https://repo.spring.io/milestone + + diff --git a/spring-cloud-bus-dependencies/pom.xml b/spring-cloud-bus-dependencies/pom.xml deleted file mode 100644 index 9fac9ba5..00000000 --- a/spring-cloud-bus-dependencies/pom.xml +++ /dev/null @@ -1,101 +0,0 @@ - - - 4.0.0 - - spring-cloud-dependencies-parent - org.springframework.cloud - 4.1.0-SNAPSHOT - - - spring-cloud-bus-dependencies - 4.1.0-SNAPSHOT - pom - spring-cloud-bus-dependencies - Spring Cloud Bus Dependencies - - - - org.springframework.cloud - spring-cloud-starter-bus-amqp - ${project.version} - - - org.springframework.cloud - spring-cloud-starter-bus-kafka - ${project.version} - - - org.springframework.cloud - spring-cloud-starter-bus-stream - ${project.version} - - - org.springframework.cloud - spring-cloud-bus - ${project.version} - - - org.springframework.cloud - spring-cloud-bus-rsocket - ${project.version} - - - - - - spring - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - spring-releases - Spring Releases - https://repo.spring.io/release - - false - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - false - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - diff --git a/spring-cloud-bus-rsocket/.flattened-pom.xml b/spring-cloud-bus-rsocket/.flattened-pom.xml new file mode 100644 index 00000000..9f99038e --- /dev/null +++ b/spring-cloud-bus-rsocket/.flattened-pom.xml @@ -0,0 +1,147 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-bus-parent + 3.1.2 + .. + + org.springframework.cloud + spring-cloud-bus-rsocket + 3.1.2 + spring-cloud-bus-rsocket + Spring Cloud Bus + https://spring.io/spring-cloud/spring-cloud-bus-parent/spring-cloud-bus-rsocket + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 the original author or authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. + + See the License for the specific language governing permissions and + limitations under the License. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-bus.git/spring-cloud-bus-rsocket + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-bus.git/spring-cloud-bus-rsocket + https://github.com/spring-cloud/spring-cloud-bus/spring-cloud-bus-rsocket + + + + org.springframework.boot + spring-boot-configuration-processor + 2.6.8 + compile + true + + + org.springframework.boot + spring-boot-starter-actuator + 2.6.8 + compile + true + + + org.springframework.cloud + spring-cloud-bus + 3.1.2 + compile + + + org.springframework.cloud + spring-cloud-function-rsocket + 3.2.5 + compile + + + com.fasterxml.jackson.dataformat + jackson-dataformat-cbor + 2.13.3 + compile + + + io.rsocket.routing + rsocket-routing-client-spring + 0.2.0 + compile + true + + + org.springframework.boot + spring-boot-autoconfigure-processor + 2.6.8 + compile + true + + + diff --git a/spring-cloud-bus-rsocket/pom.xml b/spring-cloud-bus-rsocket/pom.xml deleted file mode 100644 index af8a345b..00000000 --- a/spring-cloud-bus-rsocket/pom.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - 4.0.0 - - spring-cloud-bus-rsocket - jar - - spring-cloud-bus-rsocket - Spring Cloud Bus - - - org.springframework.cloud - spring-cloud-bus-parent - 4.1.0-SNAPSHOT - .. - - - - 0.2.0 - - - - - org.springframework.boot - spring-boot-configuration-processor - true - - - org.springframework.boot - spring-boot-starter-actuator - true - - - org.springframework.cloud - spring-cloud-bus - - - org.springframework.cloud - spring-cloud-function-rsocket - - - com.fasterxml.jackson.dataformat - jackson-dataformat-cbor - - - io.rsocket.routing - rsocket-routing-client-spring - ${rsocket-routing.version} - true - - - org.springframework.boot - spring-boot-autoconfigure-processor - true - - - org.springframework.boot - spring-boot-starter-test - test - - - org.junit.vintage - junit-vintage-engine - test - - - org.springframework.cloud - spring-cloud-test-support - test - - - - diff --git a/spring-cloud-bus-rsocket/src/main/java/org/springframework/cloud/bus/rsocket/BusRSocketAutoConfiguration.java b/spring-cloud-bus-rsocket/src/main/java/org/springframework/cloud/bus/rsocket/BusRSocketAutoConfiguration.java deleted file mode 100644 index 264173a2..00000000 --- a/spring-cloud-bus-rsocket/src/main/java/org/springframework/cloud/bus/rsocket/BusRSocketAutoConfiguration.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2015-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.rsocket; - -import io.rsocket.RSocket; -import io.rsocket.routing.client.spring.RoutingClientProperties; -import io.rsocket.routing.client.spring.RoutingRSocketRequester; - -import org.springframework.boot.autoconfigure.AutoConfigureBefore; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.bus.BusAutoConfiguration; -import org.springframework.cloud.bus.BusProperties; -import org.springframework.cloud.bus.BusRefreshAutoConfiguration; -import org.springframework.cloud.bus.ConditionalOnBusEnabled; -import org.springframework.cloud.bus.PathServiceMatcherAutoConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author Spencer Gibb - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnBusEnabled -@EnableConfigurationProperties(BusRSocketProperties.class) -@ConditionalOnClass({ RSocket.class, RoutingRSocketRequester.class }) -@AutoConfigureBefore({ BusAutoConfiguration.class, BusRefreshAutoConfiguration.class, - PathServiceMatcherAutoConfiguration.class }) -public class BusRSocketAutoConfiguration { - - @Bean - public RoutingClientDestinationFactory routingClientDestinationFactory(BusRSocketProperties properties) { - return new RoutingClientDestinationFactory(properties); - } - - @Bean - public RSocketRequesterBusBridge rSocketRequesterBusBridge(RoutingRSocketRequester requester) { - return new RSocketRequesterBusBridge(requester); - } - - @Bean - public RSocketServiceMatcher rSocketServiceMatcher(BusProperties properties, - RoutingClientProperties routingClientProperties) { - return new RSocketServiceMatcher(properties.getId(), routingClientProperties); - } - -} diff --git a/spring-cloud-bus-rsocket/src/main/java/org/springframework/cloud/bus/rsocket/BusRSocketEnvironmentPostProcessor.java b/spring-cloud-bus-rsocket/src/main/java/org/springframework/cloud/bus/rsocket/BusRSocketEnvironmentPostProcessor.java deleted file mode 100644 index 51af6f88..00000000 --- a/spring-cloud-bus-rsocket/src/main/java/org/springframework/cloud/bus/rsocket/BusRSocketEnvironmentPostProcessor.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.rsocket; - -import java.util.HashMap; -import java.util.Map; - -import io.rsocket.routing.client.spring.RoutingClientProperties; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.env.EnvironmentPostProcessor; -import org.springframework.core.env.ConfigurableEnvironment; - -import static org.springframework.cloud.bus.BusEnvironmentPostProcessor.addOrReplace; - -/** - * {@link EnvironmentPostProcessor} that sets the default properties for the RSocket - * Routing Client. - */ -public class BusRSocketEnvironmentPostProcessor implements EnvironmentPostProcessor { - - static final String DEFAULTS_PROPERTY_SOURCE_NAME = "springCloudBusRSocketDefaultProperties"; - - @Override - public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { - Map defaults = new HashMap<>(); - defaults.put(RoutingClientProperties.CONFIG_PREFIX + ".tags.bus", true); - addOrReplace(environment.getPropertySources(), defaults, DEFAULTS_PROPERTY_SOURCE_NAME, false); - } - -} diff --git a/spring-cloud-bus-rsocket/src/main/java/org/springframework/cloud/bus/rsocket/BusRSocketProperties.java b/spring-cloud-bus-rsocket/src/main/java/org/springframework/cloud/bus/rsocket/BusRSocketProperties.java deleted file mode 100644 index b183430d..00000000 --- a/spring-cloud-bus-rsocket/src/main/java/org/springframework/cloud/bus/rsocket/BusRSocketProperties.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2015-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.rsocket; - -import java.util.LinkedHashMap; -import java.util.Map; - -import io.rsocket.routing.common.MutableKey; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.core.style.ToStringCreator; -import org.springframework.util.CollectionUtils; - -@ConfigurationProperties("spring.cloud.bus.rsocket") -public class BusRSocketProperties implements InitializingBean { - - private final Map defaultTags = new LinkedHashMap<>(); - - @Override - public void afterPropertiesSet() { - if (CollectionUtils.isEmpty(defaultTags)) { - defaultTags.put(MutableKey.of("bus"), "true"); - } - } - - public Map getDefaultTags() { - return this.defaultTags; - } - - @Override - public String toString() { - return new ToStringCreator(this).append("defaultTags", defaultTags).toString(); - } - -} diff --git a/spring-cloud-bus-rsocket/src/main/java/org/springframework/cloud/bus/rsocket/RSocketRequesterBusBridge.java b/spring-cloud-bus-rsocket/src/main/java/org/springframework/cloud/bus/rsocket/RSocketRequesterBusBridge.java deleted file mode 100644 index e9404d0a..00000000 --- a/spring-cloud-bus-rsocket/src/main/java/org/springframework/cloud/bus/rsocket/RSocketRequesterBusBridge.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2015-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.rsocket; - -import java.util.HashMap; -import java.util.Map; - -import io.rsocket.routing.client.spring.RoutingRSocketRequester; -import io.rsocket.routing.common.Key; -import io.rsocket.routing.common.WellKnownKey; -import io.rsocket.routing.frames.RoutingType; - -import org.springframework.cloud.bus.BusBridge; -import org.springframework.cloud.bus.BusConstants; -import org.springframework.cloud.bus.event.RemoteApplicationEvent; -import org.springframework.util.StringUtils; - -public class RSocketRequesterBusBridge implements BusBridge { - - public RSocketRequesterBusBridge(RoutingRSocketRequester requester) { - this.requester = requester; - } - - private final RoutingRSocketRequester requester; - - @Override - public void send(RemoteApplicationEvent event) { - requester.route(BusConstants.BUS_CONSUMER).address(builder -> { - builder.routingType(RoutingType.MULTICAST); - // get tags out of destination - getTagsFromDestination(event.getDestinationService()).forEach(builder::with); - }).data(event).send().subscribe(); - } - - static Map getTagsFromDestination(String delimitedProperties) { - String[] properties = StringUtils.tokenizeToStringArray(delimitedProperties, ":"); - Map map = new HashMap<>(); - for (String property : properties) { - int index = lowestIndexOf(property, "="); - String key = (index > 0) ? property.substring(0, index) : property; - String value = (index > 0) ? property.substring(index + 1) : null; - - try { - WellKnownKey wellKnownKey = WellKnownKey.valueOf(key); - map.put(Key.of(wellKnownKey), value); - } - catch (IllegalArgumentException e) { - try { - WellKnownKey wellKnownKey = WellKnownKey.valueOf(key.toUpperCase()); - map.put(Key.of(wellKnownKey), value); - } - catch (IllegalArgumentException e2) { - // not a WellKnownKey, use string - map.put(Key.of(key), value); - } - } - - } - return map; - } - - private static int lowestIndexOf(String property, String... candidates) { - int index = -1; - for (String candidate : candidates) { - int candidateIndex = property.indexOf(candidate); - if (candidateIndex > 0) { - index = (index != -1) ? Math.min(index, candidateIndex) : candidateIndex; - } - } - return index; - } - -} diff --git a/spring-cloud-bus-rsocket/src/main/java/org/springframework/cloud/bus/rsocket/RSocketServiceMatcher.java b/spring-cloud-bus-rsocket/src/main/java/org/springframework/cloud/bus/rsocket/RSocketServiceMatcher.java deleted file mode 100644 index 8944f375..00000000 --- a/spring-cloud-bus-rsocket/src/main/java/org/springframework/cloud/bus/rsocket/RSocketServiceMatcher.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2015-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.rsocket; - -import java.util.HashMap; -import java.util.Map; - -import io.rsocket.routing.client.spring.RoutingClientProperties; -import io.rsocket.routing.common.Key; -import io.rsocket.routing.common.WellKnownKey; - -import org.springframework.cloud.bus.ServiceMatcher; -import org.springframework.cloud.bus.event.RemoteApplicationEvent; -import org.springframework.util.AntPathMatcher; - -import static org.springframework.cloud.bus.rsocket.RSocketRequesterBusBridge.getTagsFromDestination; - -/** - * A pass thru patcher that allows the RSocket Routing broker to determine which instances - * to send to. - */ -public class RSocketServiceMatcher implements ServiceMatcher { - - private final String busId; - - private final RoutingClientProperties properties; - - private final AntPathMatcher antPathMatcher = new AntPathMatcher(); - - private final Map localTags = new HashMap<>(); - - public RSocketServiceMatcher(String busId, RoutingClientProperties properties) { - this.busId = busId; - this.properties = properties; - convertLocalTags(properties); - } - - @Override - public boolean isFromSelf(RemoteApplicationEvent event) { - String originService = event.getOriginService(); - String serviceId = getBusId(); - return antPathMatcher.match(originService, serviceId); - } - - @Override - public boolean isForSelf(RemoteApplicationEvent event) { - Map tags = getTagsFromDestination(event.getDestinationService()); - for (Map.Entry entry : tags.entrySet()) { - String existingValue = localTags.get(entry.getKey()); - if (existingValue == null || !existingValue.equals(entry.getValue())) { - return false; - } - } - return true; - } - - private void convertLocalTags(RoutingClientProperties properties) { - properties.getTags().forEach((key, value) -> { - if (key.getWellKnownKey() != null) { - localTags.put(Key.of(key.getWellKnownKey()), value); - } - else { - localTags.put(Key.of(key.getKey()), value); - } - }); - localTags.put(Key.of(WellKnownKey.SERVICE_NAME), properties.getServiceName()); - } - - @Override - public String getBusId() { - return busId; - } - -} diff --git a/spring-cloud-bus-rsocket/src/main/java/org/springframework/cloud/bus/rsocket/RoutingClientDestinationFactory.java b/spring-cloud-bus-rsocket/src/main/java/org/springframework/cloud/bus/rsocket/RoutingClientDestinationFactory.java deleted file mode 100644 index 432e7c03..00000000 --- a/spring-cloud-bus-rsocket/src/main/java/org/springframework/cloud/bus/rsocket/RoutingClientDestinationFactory.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2015-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.rsocket; - -import java.util.ArrayList; - -import org.springframework.cloud.bus.event.Destination; -import org.springframework.util.ObjectUtils; -import org.springframework.util.StringUtils; - -public class RoutingClientDestinationFactory implements Destination.Factory { - - private final BusRSocketProperties properties; - - public RoutingClientDestinationFactory(BusRSocketProperties properties) { - this.properties = properties; - } - - @Override - public Destination getDestination(String originalDestination) { - ArrayList entries = new ArrayList<>(); - properties.getDefaultTags().forEach((key, s) -> { - String keyStr = (key.getWellKnownKey() != null) ? key.getWellKnownKey().name() : key.getKey(); - entries.add(keyStr + "=" + s); - }); - String defaultTags = StringUtils.collectionToDelimitedString(entries, ":"); - return () -> { - String destination = (ObjectUtils.isEmpty(originalDestination)) ? defaultTags - : defaultTags + ":" + originalDestination; - if (ObjectUtils.isEmpty(destination)) { - throw new IllegalArgumentException("destination may not be empty"); - } - return destination; - }; - } - -} diff --git a/spring-cloud-bus-rsocket/src/main/resources/META-INF/spring.factories b/spring-cloud-bus-rsocket/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 0d36dfe7..00000000 --- a/spring-cloud-bus-rsocket/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Environment Post Processor -org.springframework.boot.env.EnvironmentPostProcessor=\ -org.springframework.cloud.bus.rsocket.BusRSocketEnvironmentPostProcessor diff --git a/spring-cloud-bus-rsocket/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-cloud-bus-rsocket/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 91a5ae78..00000000 --- a/spring-cloud-bus-rsocket/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1 +0,0 @@ -org.springframework.cloud.bus.rsocket.BusRSocketAutoConfiguration diff --git a/spring-cloud-bus-tests/.flattened-pom.xml b/spring-cloud-bus-tests/.flattened-pom.xml new file mode 100644 index 00000000..375b0c41 --- /dev/null +++ b/spring-cloud-bus-tests/.flattened-pom.xml @@ -0,0 +1,99 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-bus-parent + 3.1.2 + .. + + org.springframework.cloud + spring-cloud-bus-tests + 3.1.2 + spring-cloud-bus-tests + Spring Cloud Bus Tests + https://spring.io/spring-cloud/spring-cloud-bus-parent/spring-cloud-bus-tests + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 the original author or authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. + + See the License for the specific language governing permissions and + limitations under the License. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-bus.git/spring-cloud-bus-tests + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-bus.git/spring-cloud-bus-tests + https://github.com/spring-cloud/spring-cloud-bus/spring-cloud-bus-tests + + diff --git a/spring-cloud-bus-tests/pom.xml b/spring-cloud-bus-tests/pom.xml deleted file mode 100644 index 9029c358..00000000 --- a/spring-cloud-bus-tests/pom.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - 4.0.0 - - spring-cloud-bus-tests - jar - - spring-cloud-bus-tests - Spring Cloud Bus Tests - - - org.springframework.cloud - spring-cloud-bus-parent - 4.1.0-SNAPSHOT - .. - - - - 1.17.6 - - - - - org.springframework.boot - spring-boot-starter-web - test - - - org.springframework.boot - spring-boot-starter-webflux - test - - - org.springframework.boot - spring-boot-starter-actuator - test - - - org.springframework.cloud - spring-cloud-starter-bus-amqp - test - - - org.springframework.boot - spring-boot-starter-test - test - - - org.testcontainers - junit-jupiter - ${testcontainers.version} - test - - - org.testcontainers - rabbitmq - ${testcontainers.version} - test - - - - diff --git a/spring-cloud-bus-tests/src/test/java/org/springframework/cloud/bus/BusAmqpIntegrationTests.java b/spring-cloud-bus-tests/src/test/java/org/springframework/cloud/bus/BusAmqpIntegrationTests.java deleted file mode 100644 index 07a5b890..00000000 --- a/spring-cloud-bus-tests/src/test/java/org/springframework/cloud/bus/BusAmqpIntegrationTests.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2015-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import java.util.HashMap; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.RabbitMQContainer; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.bus.event.EnvironmentChangeRemoteApplicationEvent; -import org.springframework.cloud.stream.binder.ProducerProperties; -import org.springframework.cloud.stream.config.BindingServiceProperties; -import org.springframework.context.ApplicationListener; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.test.context.DynamicPropertyRegistry; -import org.springframework.test.context.DynamicPropertySource; -import org.springframework.test.web.reactive.server.WebTestClient; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -@SpringBootTest(webEnvironment = RANDOM_PORT, properties = { "management.endpoints.web.exposure.include=*", - "spring.cloud.stream.bindings.springCloudBusOutput.producer.errorChannelEnabled=true", - "logging.level.org.springframework.cloud.bus=TRACE", "spring.cloud.bus.id=app:1", - "spring.autoconfigure.exclude=org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration" }) -@Testcontainers -public class BusAmqpIntegrationTests { - - @Container - private static final RabbitMQContainer rabbitMQContainer = new RabbitMQContainer( - "rabbitmq:3.7.25-management-alpine"); - - private static ConfigurableApplicationContext context; - - @Autowired - private BindingServiceProperties bindingServiceProperties; - - @DynamicPropertySource - static void properties(DynamicPropertyRegistry registry) { - registry.add("spring.rabbitmq.host", rabbitMQContainer::getHost); - registry.add("spring.rabbitmq.port", rabbitMQContainer::getAmqpPort); - } - - @BeforeAll - static void before() { - context = new SpringApplicationBuilder(TestConfig.class).properties("server.port=0", - "spring.rabbitmq.host=" + rabbitMQContainer.getHost(), - "spring.rabbitmq.port=" + rabbitMQContainer.getAmqpPort(), - "management.endpoints.web.exposure.include=*", "spring.cloud.bus.id=app:2", - "spring.autoconfigure.exclude=org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration") - .run(); - } - - @AfterAll - static void after() { - if (context != null) { - context.close(); - } - } - - @Test - void remoteEventsAreSentViaAmqp(@Autowired WebTestClient client, @Autowired TestConfig testConfig) - throws InterruptedException { - assertThat(rabbitMQContainer.isRunning()); - HashMap map = new HashMap<>(); - map.put("name", "foo"); - map.put("value", "bar"); - client.post().uri("/actuator/busenv").bodyValue(map).exchange().expectStatus().is2xxSuccessful(); - TestConfig remoteTestConfig = context.getBean(TestConfig.class); - assertThat(remoteTestConfig.latch.await(5, TimeUnit.SECONDS)).isTrue(); - assertThat(testConfig.latch.await(5, TimeUnit.SECONDS)).isTrue(); - ProducerProperties producerProperties = bindingServiceProperties.getProducerProperties(BusConstants.OUTPUT); - assertThat(producerProperties.isErrorChannelEnabled()).isTrue(); - } - - @SpringBootConfiguration - @EnableAutoConfiguration - static class TestConfig implements ApplicationListener { - - CountDownLatch latch = new CountDownLatch(1); - - @Override - public void onApplicationEvent(EnvironmentChangeRemoteApplicationEvent event) { - latch.countDown(); - } - - } - -} diff --git a/spring-cloud-bus-tests/src/test/java/org/springframework/cloud/bus/BusJmxEndpointTests.java b/spring-cloud-bus-tests/src/test/java/org/springframework/cloud/bus/BusJmxEndpointTests.java deleted file mode 100644 index 4c274921..00000000 --- a/spring-cloud-bus-tests/src/test/java/org/springframework/cloud/bus/BusJmxEndpointTests.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.bus.endpoint.EnvironmentBusEndpoint; -import org.springframework.cloud.bus.endpoint.RefreshBusEndpoint; - -import static org.assertj.core.api.Assertions.assertThat; - -@SpringBootTest(properties = { "spring.jmx.enabled=true", "endpoints.default.jmx.enabled=true", - "management.endpoints..jmx.exposure.include=busrefresh,busenv", "debug=true" }) -public class BusJmxEndpointTests { - - @Autowired(required = false) - private RefreshBusEndpoint refreshBusEndpoint; - - @Autowired(required = false) - private EnvironmentBusEndpoint environmentBusEndpoint; - - @Test - public void contextLoads() { - assertThat(this.refreshBusEndpoint).isNotNull(); - assertThat(this.environmentBusEndpoint).isNotNull(); - } - - @SpringBootConfiguration - @EnableAutoConfiguration - protected static class TestConfig { - - } - -} diff --git a/spring-cloud-bus-tests/src/test/java/org/springframework/cloud/bus/jackson/BusJacksonIntegrationTests.java b/spring-cloud-bus-tests/src/test/java/org/springframework/cloud/bus/jackson/BusJacksonIntegrationTests.java deleted file mode 100644 index ae3e9a23..00000000 --- a/spring-cloud-bus-tests/src/test/java/org/springframework/cloud/bus/jackson/BusJacksonIntegrationTests.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.jackson; - -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -import com.fasterxml.jackson.databind.SerializationFeature; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.cloud.bus.ServiceMatcher; -import org.springframework.cloud.bus.event.RemoteApplicationEvent; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.event.EventListener; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -@SpringBootTest(properties = "spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS:true", - webEnvironment = RANDOM_PORT) -@DirtiesContext -public class BusJacksonIntegrationTests { - - @LocalServerPort - private int port; - - @Autowired - private TestRestTemplate rest; - - @Autowired - private BusJacksonMessageConverter converter; - - @Test - @SuppressWarnings("unchecked") - public void testCustomEventSerializes() { - assertThat(this.converter.isMapperCreated()).isFalse(); - - // set by configuration - assertThat(this.converter.getMapper().getSerializationConfig() - .isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)).isTrue(); - - Map map = this.rest.getForObject("http://localhost:" + this.port + "/date", Map.class); - assertThat(map).containsOnlyKeys("date"); - assertThat(map.get("date")).isInstanceOf(Long.class); - - this.rest.put("http://localhost:" + this.port + "/names" + "/foo", null); - this.rest.put("http://localhost:" + this.port + "/names" + "/bar", null); - - ResponseEntity response = this.rest.getForEntity("http://localhost:" + this.port + "/names", List.class); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(response.getBody()).contains("foo", "bar"); - } - - public static class NameEvent extends RemoteApplicationEvent { - - private String name; - - protected NameEvent() { - } - - public NameEvent(Object source, String originService, String name) { - super(source, originService); - this.name = name; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - } - - @RestController - @EnableAutoConfiguration - @SpringBootConfiguration - @RemoteApplicationEventScan - protected static class Config { - - final private Set names = ConcurrentHashMap.newKeySet(); - - @Autowired - private ServiceMatcher busServiceMatcher; - - @Autowired - private ApplicationEventPublisher publisher; - - @GetMapping("/names") - public Collection names() { - return this.names; - } - - @PutMapping("/names/{name}") - public void sayName(@PathVariable String name) { - this.names.add(name); - this.publisher.publishEvent(new NameEvent(this, this.busServiceMatcher.getBusId(), name)); - } - - @GetMapping("/date") - public Map testTimeJsonSerialization() { - Map map = new HashMap<>(); - map.put("date", new Date()); - return map; - } - - @EventListener - public void handleNameSaid(NameEvent event) { - this.names.add(event.getName()); - } - - } - -} diff --git a/spring-cloud-bus/.flattened-pom.xml b/spring-cloud-bus/.flattened-pom.xml new file mode 100644 index 00000000..b8f0bc49 --- /dev/null +++ b/spring-cloud-bus/.flattened-pom.xml @@ -0,0 +1,155 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-bus-parent + 3.1.2 + .. + + org.springframework.cloud + spring-cloud-bus + 3.1.2 + spring-cloud-bus + Spring Cloud Bus + https://spring.io/spring-cloud/spring-cloud-bus-parent/spring-cloud-bus + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 the original author or authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. + + See the License for the specific language governing permissions and + limitations under the License. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-bus.git/spring-cloud-bus + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-bus.git/spring-cloud-bus + https://github.com/spring-cloud/spring-cloud-bus/spring-cloud-bus + + + + org.springframework.boot + spring-boot-configuration-processor + 2.6.8 + compile + true + + + org.springframework.boot + spring-boot-starter-actuator + 2.6.8 + compile + true + + + org.springframework.boot + spring-boot-starter-web + 2.6.8 + compile + true + + + org.springframework.cloud + spring-cloud-starter + 3.1.3 + compile + + + org.springframework.cloud + spring-cloud-stream + 3.2.4 + compile + true + + + org.springframework.integration + spring-integration-core + 5.5.12 + compile + + + com.fasterxml.jackson.dataformat + jackson-dataformat-cbor + 2.13.3 + compile + true + + + org.springframework.boot + spring-boot-autoconfigure-processor + 2.6.8 + compile + true + + + diff --git a/spring-cloud-bus/pom.xml b/spring-cloud-bus/pom.xml deleted file mode 100644 index df2ec48d..00000000 --- a/spring-cloud-bus/pom.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - 4.0.0 - - spring-cloud-bus - jar - - spring-cloud-bus - Spring Cloud Bus - - - org.springframework.cloud - spring-cloud-bus-parent - 4.1.0-SNAPSHOT - .. - - - - - org.springframework.boot - spring-boot-configuration-processor - true - - - org.springframework.boot - spring-boot-starter-actuator - true - - - org.springframework.boot - spring-boot-starter-web - true - - - org.springframework.cloud - spring-cloud-starter - - - org.springframework.cloud - spring-cloud-stream - true - - - org.springframework.integration - spring-integration-core - - - com.fasterxml.jackson.dataformat - jackson-dataformat-cbor - true - - - org.springframework.boot - spring-boot-autoconfigure-processor - true - - - org.springframework.boot - spring-boot-starter-test - test - - - org.junit.vintage - junit-vintage-engine - test - - - org.springframework.cloud - spring-cloud-test-support - test - - - org.springframework.cloud - spring-cloud-stream-test-binder - ${spring-cloud-stream.version} - test - - - - diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusAutoConfiguration.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusAutoConfiguration.java deleted file mode 100644 index cf4a8d85..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusAutoConfiguration.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint; -import org.springframework.boot.actuate.endpoint.annotation.Endpoint; -import org.springframework.boot.actuate.web.exchanges.HttpExchangeRepository; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.bus.endpoint.EnvironmentBusEndpoint; -import org.springframework.cloud.bus.event.Destination; -import org.springframework.cloud.bus.event.EnvironmentChangeListener; -import org.springframework.cloud.bus.event.PathDestinationFactory; -import org.springframework.cloud.bus.event.TraceListener; -import org.springframework.cloud.context.environment.EnvironmentManager; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import static org.springframework.cloud.bus.BusConstants.BUS_CONSUMER; - -/** - * @author Spencer Gibb - * @author Dave Syer - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnBusEnabled -@EnableConfigurationProperties(BusProperties.class) -public class BusAutoConfiguration { - - @Bean - @ConditionalOnMissingBean(Destination.Factory.class) - public PathDestinationFactory pathDestinationFactory() { - return new PathDestinationFactory(); - } - - @Bean - @ConditionalOnMissingBean - public RemoteApplicationEventListener busRemoteApplicationEventListener(ServiceMatcher serviceMatcher, - BusBridge busBridge) { - return new RemoteApplicationEventListener(serviceMatcher, busBridge); - } - - @Bean - @ConditionalOnMissingBean(name = BUS_CONSUMER) - public BusConsumer busConsumer(ApplicationEventPublisher applicationEventPublisher, ServiceMatcher serviceMatcher, - ObjectProvider busBridge, BusProperties properties, Destination.Factory destinationFactory) { - return new BusConsumer(applicationEventPublisher, serviceMatcher, busBridge, properties, destinationFactory); - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass({ Endpoint.class }) - @ConditionalOnBean(HttpExchangeRepository.class) - @ConditionalOnProperty(BusProperties.PREFIX + ".trace.enabled") - protected static class BusAckTraceConfiguration { - - @Bean - @ConditionalOnMissingBean - public TraceListener ackTraceListener(HttpExchangeRepository repository) { - return new TraceListener(repository); - } - - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass(EnvironmentManager.class) - @ConditionalOnBean(EnvironmentManager.class) - protected static class BusEnvironmentConfiguration { - - @Bean - @ConditionalOnProperty(value = "spring.cloud.bus.env.enabled", matchIfMissing = true) - public EnvironmentChangeListener environmentChangeListener() { - return new EnvironmentChangeListener(); - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass(Endpoint.class) - protected static class EnvironmentBusEndpointConfiguration { - - @Bean - @ConditionalOnAvailableEndpoint - public EnvironmentBusEndpoint environmentBusEndpoint(ApplicationEventPublisher publisher, BusProperties bus, - Destination.Factory destinationFactory) { - return new EnvironmentBusEndpoint(publisher, bus.getId(), destinationFactory); - } - - } - - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusBridge.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusBridge.java deleted file mode 100644 index be95194f..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusBridge.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2015-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import org.springframework.cloud.bus.event.RemoteApplicationEvent; - -public interface BusBridge { - - void send(RemoteApplicationEvent event); - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusConstants.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusConstants.java deleted file mode 100644 index 0d1ee110..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusConstants.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -/** - * @author Dave Syer - * - */ -public abstract class BusConstants { - - /** - * Name of the input channel for Spring Cloud Bus. - */ - public static final String INPUT = "springCloudBusInput"; - - /** - * Name of the output channel for Spring Cloud Bus. - */ - public static final String OUTPUT = "springCloudBusOutput"; - - /** - * Name of the binding destination for Spring Cloud Bus. - */ - public static final String DESTINATION = "springCloudBus"; - - /** - * Name of the Spring Cloud Bus function. - */ - public static final String BUS_CONSUMER = "busConsumer"; - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusConsumer.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusConsumer.java deleted file mode 100644 index dccf2748..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusConsumer.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2015-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import java.util.function.Consumer; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.cloud.bus.event.AckRemoteApplicationEvent; -import org.springframework.cloud.bus.event.Destination; -import org.springframework.cloud.bus.event.RemoteApplicationEvent; -import org.springframework.cloud.bus.event.SentApplicationEvent; -import org.springframework.context.ApplicationEventPublisher; - -public class BusConsumer implements Consumer { - - private final Log log = LogFactory.getLog(getClass()); - - private final ApplicationEventPublisher publisher; - - private final ServiceMatcher serviceMatcher; - - private final ObjectProvider busBridge; - - private final BusProperties properties; - - private final Destination.Factory destinationFactory; - - public BusConsumer(ApplicationEventPublisher publisher, ServiceMatcher serviceMatcher, - ObjectProvider busBridge, BusProperties properties, Destination.Factory destinationFactory) { - this.publisher = publisher; - this.serviceMatcher = serviceMatcher; - this.busBridge = busBridge; - this.properties = properties; - this.destinationFactory = destinationFactory; - } - - @Override - public void accept(RemoteApplicationEvent event) { - if (event instanceof AckRemoteApplicationEvent) { - if (this.properties.getTrace().isEnabled() && !this.serviceMatcher.isFromSelf(event) - && this.publisher != null) { - this.publisher.publishEvent(event); - } - // If it's an ACK we are finished processing at this point - return; - } - - if (log.isDebugEnabled()) { - log.debug("Received remote event from bus: " + event); - } - - if (this.serviceMatcher.isForSelf(event) && this.publisher != null) { - if (!this.serviceMatcher.isFromSelf(event)) { - this.publisher.publishEvent(event); - } - if (this.properties.getAck().isEnabled()) { - AckRemoteApplicationEvent ack = new AckRemoteApplicationEvent(this, this.serviceMatcher.getBusId(), - destinationFactory.getDestination(this.properties.getAck().getDestinationService()), - event.getDestinationService(), event.getId(), event.getClass()); - this.busBridge.ifAvailable(bridge -> bridge.send(ack)); - this.publisher.publishEvent(ack); - } - } - if (this.properties.getTrace().isEnabled() && this.publisher != null) { - // We are set to register sent events so publish it for local consumption, - // irrespective of the origin - this.publisher.publishEvent(new SentApplicationEvent(this, event.getOriginService(), - event.getDestinationService(), event.getId(), event.getClass())); - } - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusEnvironmentPostProcessor.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusEnvironmentPostProcessor.java deleted file mode 100644 index 78eaee0f..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusEnvironmentPostProcessor.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2012-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import java.util.HashMap; -import java.util.Map; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.env.EnvironmentPostProcessor; -import org.springframework.cloud.commons.util.IdUtils; -import org.springframework.cloud.function.context.FunctionProperties; -import org.springframework.core.env.ConfigurableEnvironment; -import org.springframework.core.env.MapPropertySource; -import org.springframework.core.env.MutablePropertySources; -import org.springframework.core.env.PropertySource; -import org.springframework.util.StringUtils; - -import static org.springframework.cloud.bus.BusProperties.PREFIX; - -/** - * {@link EnvironmentPostProcessor} that sets the default properties for the Bus. - * - * @author Dave Syer - * @since 1.0.0 - */ -public class BusEnvironmentPostProcessor implements EnvironmentPostProcessor { - - static final String DEFAULTS_PROPERTY_SOURCE_NAME = "springCloudBusDefaultProperties"; - - static final String OVERRIDES_PROPERTY_SOURCE_NAME = "springCloudBusOverridesProperties"; - - private static final String FN_DEF_PROP = FunctionProperties.PREFIX + ".definition"; - - @Override - public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { - if (environment.containsProperty(ConditionalOnBusEnabled.SPRING_CLOUD_BUS_ENABLED)) { - if (Boolean.FALSE.toString() - .equalsIgnoreCase(environment.getProperty(ConditionalOnBusEnabled.SPRING_CLOUD_BUS_ENABLED))) { - return; - } - } - Map overrides = new HashMap<>(); - String definition = BusConstants.BUS_CONSUMER; - if (environment.containsProperty(FN_DEF_PROP)) { - String property = environment.getProperty(FN_DEF_PROP); - if (property != null && property.contains(BusConstants.BUS_CONSUMER)) { - // in the case that EnvironmentPostProcessor are run more than once. - return; - } - definition = property + ";" + definition; - } - overrides.put(FN_DEF_PROP, definition); - addOrReplace(environment.getPropertySources(), overrides, OVERRIDES_PROPERTY_SOURCE_NAME, true); - - Map defaults = new HashMap<>(); - defaults.put("spring.cloud.stream.function.bindings." + BusConstants.BUS_CONSUMER + "-in-0", - BusConstants.INPUT); - String destination = environment.getProperty(PREFIX + ".destination", BusConstants.DESTINATION); - defaults.put("spring.cloud.stream.bindings." + BusConstants.INPUT + ".destination", destination); - defaults.put("spring.cloud.stream.bindings." + BusConstants.OUTPUT + ".destination", destination); - if (!environment.containsProperty(PREFIX + ".id")) { - String unresolvedServiceId = IdUtils.getUnresolvedServiceId(); - if (StringUtils.hasText(environment.getProperty("spring.profiles.active"))) { - unresolvedServiceId = IdUtils.getUnresolvedServiceIdWithActiveProfiles(); - } - defaults.put(PREFIX + ".id", unresolvedServiceId); - } - addOrReplace(environment.getPropertySources(), defaults, DEFAULTS_PROPERTY_SOURCE_NAME, false); - } - - public static void addOrReplace(MutablePropertySources propertySources, Map map, - String propertySourceName, boolean first) { - MapPropertySource target = null; - if (propertySources.contains(propertySourceName)) { - PropertySource source = propertySources.get(propertySourceName); - if (source instanceof MapPropertySource) { - target = (MapPropertySource) source; - for (String key : map.keySet()) { - if (!target.containsProperty(key)) { - target.getSource().put(key, map.get(key)); - } - } - } - } - if (target == null) { - target = new MapPropertySource(propertySourceName, map); - } - if (!propertySources.contains(propertySourceName)) { - if (first) { - propertySources.addFirst(target); - } - else { - propertySources.addLast(target); - } - } - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusPathMatcher.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusPathMatcher.java deleted file mode 100644 index 19ddb18f..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusPathMatcher.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.beans.factory.annotation.Qualifier; - -/** - * Qualifier annotation for components to do with matching paths in the bus. - * - * @author Dave Syer - * - */ -@Qualifier -@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE, ElementType.PARAMETER }) -@Retention(RetentionPolicy.RUNTIME) -@Inherited -@Documented -public @interface BusPathMatcher { - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusProperties.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusProperties.java deleted file mode 100644 index 0daa9a12..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusProperties.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.core.style.ToStringCreator; -import org.springframework.util.MimeType; -import org.springframework.util.MimeTypeUtils; - -/** - * @author Dave Syer - * - */ -@ConfigurationProperties(BusProperties.PREFIX) -public class BusProperties { - - /** - * Configuration prefix for spring cloud bus. - */ - public static final String PREFIX = "spring.cloud.bus"; - - /** - * Properties related to acks. - */ - private final Ack ack = new Ack(); - - /** - * Properties related to tracing of acks. - */ - private final Trace trace = new Trace(); - - /** - * Name of Spring Cloud Stream destination for messages. - */ - private String destination = BusConstants.DESTINATION; - - /** - * The identifier for this application instance. - */ - private String id = "application"; - - /** - * The bus mime-type. - */ - private MimeType contentType = MimeTypeUtils.APPLICATION_JSON; - - /** - * Flag to indicate that the bus is enabled. - */ - private boolean enabled = true; - - public Ack getAck() { - return this.ack; - } - - public Trace getTrace() { - return this.trace; - } - - public String getDestination() { - return this.destination; - } - - public void setDestination(String destination) { - this.destination = destination; - } - - public boolean isEnabled() { - return this.enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - public String getId() { - return this.id; - } - - public void setId(String id) { - this.id = id; - } - - public MimeType getContentType() { - return this.contentType; - } - - public void setContentType(MimeType contentType) { - this.contentType = contentType; - } - - @Override - public String toString() { - return new ToStringCreator(this).append("ack", ack).append("trace", trace).append("destination", destination) - .append("id", id).append("contentType", contentType).append("enabled", enabled).toString(); - - } - - /** - * Spring Cloud Bus properties related to acknowledgments. - */ - public static class Ack { - - /** - * Flag to switch off acks (default on). - */ - private boolean enabled = true; - - /** - * Service that wants to listen to acks. By default null (meaning all services). - */ - private String destinationService; - - public boolean isEnabled() { - return this.enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - public String getDestinationService() { - return this.destinationService; - } - - public void setDestinationService(String destinationService) { - this.destinationService = destinationService; - } - - @Override - public String toString() { - return new ToStringCreator(this).append("enabled", enabled).append("destinationService", destinationService) - .toString(); - } - - } - - /** - * Spring Cloud Bus trace properties. - */ - public static class Trace { - - /** - * Flag to switch on tracing of acks (default off). - */ - private boolean enabled = false; - - public boolean isEnabled() { - return this.enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - @Override - public String toString() { - return new ToStringCreator(this).append("enabled", enabled).toString(); - } - - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusRefreshAutoConfiguration.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusRefreshAutoConfiguration.java deleted file mode 100644 index de936dcf..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusRefreshAutoConfiguration.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint; -import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.cloud.bus.endpoint.RefreshBusEndpoint; -import org.springframework.cloud.bus.event.Destination; -import org.springframework.cloud.bus.event.RefreshListener; -import org.springframework.cloud.context.refresh.ContextRefresher; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author Ryan Baxter - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnBusEnabled -@AutoConfigureAfter(name = { "org.springframework.cloud.autoconfigure.RefreshAutoConfiguration" }) -public class BusRefreshAutoConfiguration { - - @Bean - @ConditionalOnProperty(value = "spring.cloud.bus.refresh.enabled", matchIfMissing = true) - @ConditionalOnBean(ContextRefresher.class) - public RefreshListener refreshListener(ContextRefresher contextRefresher, ServiceMatcher serviceMatcher) { - return new RefreshListener(contextRefresher, serviceMatcher); - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass(name = { "org.springframework.boot.actuate.endpoint.annotation.Endpoint", - "org.springframework.cloud.context.scope.refresh.RefreshScope" }) - protected static class BusRefreshEndpointConfiguration { - - @Bean - @ConditionalOnAvailableEndpoint - public RefreshBusEndpoint refreshBusEndpoint(ApplicationEventPublisher publisher, BusProperties bus, - Destination.Factory destinationFactory) { - return new RefreshBusEndpoint(publisher, bus.getId(), destinationFactory); - } - - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusStreamAutoConfiguration.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusStreamAutoConfiguration.java deleted file mode 100644 index 19ada031..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/BusStreamAutoConfiguration.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2015-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.AutoConfigureBefore; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.autoconfigure.LifecycleMvcEndpointAutoConfiguration; -import org.springframework.cloud.stream.config.BindingServiceConfiguration; -import org.springframework.cloud.stream.function.StreamBridge; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration(proxyBeanMethods = false) -@ConditionalOnBusEnabled -@ConditionalOnClass({ StreamBridge.class, BindingServiceConfiguration.class }) -@EnableConfigurationProperties(BusProperties.class) -@AutoConfigureBefore({ BindingServiceConfiguration.class, BusAutoConfiguration.class }) -// so stream bindings work properly -@AutoConfigureAfter({ LifecycleMvcEndpointAutoConfiguration.class, PathServiceMatcherAutoConfiguration.class }) -public class BusStreamAutoConfiguration { - - @Bean - @ConditionalOnMissingBean(BusBridge.class) - public StreamBusBridge streamBusBridge(StreamBridge streamBridge, BusProperties properties) { - return new StreamBusBridge(streamBridge, properties); - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/ConditionalOnBusEnabled.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/ConditionalOnBusEnabled.java deleted file mode 100644 index fb9aea27..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/ConditionalOnBusEnabled.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; - -/** - * @author Spencer Gibb - */ -@ConditionalOnProperty(value = ConditionalOnBusEnabled.SPRING_CLOUD_BUS_ENABLED, matchIfMissing = true) -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE, ElementType.METHOD }) -public @interface ConditionalOnBusEnabled { - - /** - * Property name to enable / disable Spring Cloud Bus. - */ - String SPRING_CLOUD_BUS_ENABLED = "spring.cloud.bus.enabled"; - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/DefaultBusPathMatcher.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/DefaultBusPathMatcher.java deleted file mode 100644 index 800f990a..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/DefaultBusPathMatcher.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import java.util.Comparator; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.util.PathMatcher; -import org.springframework.util.StringUtils; - -import static org.springframework.util.StringUtils.tokenizeToStringArray; - -/** - * {@link BusPathMatcher} that matches application context ids with multiple, - * comma-separated, profiles. Original - * https://gist.github.com/kelapure/61d3f948acf478cc95225ff1d7d239c4 - * - * See https://github.com/spring-cloud/spring-cloud-config/issues/678 - * - * @author Rohit Kelapure - * @author Spencer Gibb - */ -public class DefaultBusPathMatcher implements PathMatcher { - - private static final Log log = LogFactory.getLog(DefaultBusPathMatcher.class); - - private final PathMatcher delagateMatcher; - - public DefaultBusPathMatcher(PathMatcher delagateMatcher) { - this.delagateMatcher = delagateMatcher; - } - - protected boolean matchMultiProfile(String pattern, String idToMatch) { - - if (log.isDebugEnabled()) { - log.debug("matchMultiProfile : " + pattern + ", " + idToMatch); - } - - // parse the id - String[] tokens = tokenizeToStringArray(idToMatch, ":"); - if (tokens.length <= 1) { - // no parts, default to delegate which already returned false; - return false; - } - String selfProfiles = tokens[1]; - - // short circuit if possible - String[] profiles = tokenizeToStringArray(selfProfiles, ","); - - if (profiles.length == 1) { - // there aren't multiple profiles to check, the delegate match was - // originally false so return what delegate determined - return false; - } - - // gather candidate ids with a single profile rather than a comma separated list - String[] idsWithSingleProfile = new String[profiles.length]; - - for (int i = 0; i < profiles.length; i++) { - // replace comma separated profiles with single profile - String profile = profiles[i]; - String[] newTokens = new String[tokens.length]; - System.arraycopy(tokens, 0, newTokens, 0, tokens.length); - newTokens[1] = profile; - idsWithSingleProfile[i] = StringUtils.arrayToDelimitedString(newTokens, ":"); - } - - for (String id : idsWithSingleProfile) { - if (this.delagateMatcher.match(pattern, id)) { - if (log.isDebugEnabled()) { - log.debug("matched true"); - } - return true; - } - } - - if (log.isDebugEnabled()) { - log.debug("matched false"); - } - return false; - } - - @Override - public boolean isPattern(String path) { - return this.delagateMatcher.isPattern(path); - } - - @Override - public boolean match(String pattern, String path) { - if (log.isDebugEnabled()) { - log.debug("In match: " + pattern + ", " + path); - } - if (!this.delagateMatcher.match(pattern, path)) { - return matchMultiProfile(pattern, path); - } - return true; - } - - @Override - public boolean matchStart(String pattern, String path) { - return this.delagateMatcher.matchStart(pattern, path); - } - - @Override - public String extractPathWithinPattern(String pattern, String path) { - return this.delagateMatcher.extractPathWithinPattern(pattern, path); - } - - @Override - public Map extractUriTemplateVariables(String pattern, String path) { - return this.delagateMatcher.extractUriTemplateVariables(pattern, path); - } - - @Override - public Comparator getPatternComparator(String path) { - return this.delagateMatcher.getPatternComparator(path); - } - - @Override - public String combine(String pattern1, String pattern2) { - return this.delagateMatcher.combine(pattern1, pattern2); - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/PathServiceMatcher.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/PathServiceMatcher.java deleted file mode 100644 index b0e2534a..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/PathServiceMatcher.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import org.springframework.cloud.bus.event.RemoteApplicationEvent; -import org.springframework.util.PathMatcher; - -/** - * @author Spencer Gibb - */ -public class PathServiceMatcher implements ServiceMatcher { - - private final PathMatcher matcher; - - private final String id; - - private String[] configNames = new String[] {}; - - public PathServiceMatcher(PathMatcher matcher, String id) { - this.matcher = matcher; - this.id = id; - } - - public PathServiceMatcher(PathMatcher matcher, String id, String[] configNames) { - this(matcher, id); - - int colonIndex = id.indexOf(":"); - if (colonIndex >= 0) { - // if the id contains profiles and port, append them to the config names - String profilesAndPort = id.substring(colonIndex); - for (int i = 0; i < configNames.length; i++) { - configNames[i] = configNames[i] + profilesAndPort; - } - } - this.configNames = configNames; - } - - public boolean isFromSelf(RemoteApplicationEvent event) { - String originService = event.getOriginService(); - String serviceId = getBusId(); - return this.matcher.match(originService, serviceId); - } - - public boolean isForSelf(RemoteApplicationEvent event) { - String destinationService = event.getDestinationService(); - if (destinationService == null || destinationService.trim().isEmpty() - || this.matcher.match(destinationService, getBusId())) { - return true; - } - - // Check all potential config names instead of service name - for (String configName : this.configNames) { - if (this.matcher.match(destinationService, configName)) { - return true; - } - } - - return false; - } - - public String getBusId() { - return this.id; - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/PathServiceMatcherAutoConfiguration.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/PathServiceMatcherAutoConfiguration.java deleted file mode 100644 index fa745b85..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/PathServiceMatcherAutoConfiguration.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2012-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.env.Environment; -import org.springframework.util.AntPathMatcher; -import org.springframework.util.PathMatcher; - -/** - * @author Ryan Baxter - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnBusEnabled -@EnableConfigurationProperties(BusProperties.class) -public class PathServiceMatcherAutoConfiguration { - - /** - * Name of the Bus path matcher. - */ - public static final String BUS_PATH_MATCHER_NAME = "busPathMatcher"; - - /** - * Name of the Spring Cloud Config property. - */ - public static final String CLOUD_CONFIG_NAME_PROPERTY = "spring.cloud.config.name"; - - @BusPathMatcher - // There is a @Bean of type PathMatcher coming from Spring MVC - @ConditionalOnMissingBean(name = BUS_PATH_MATCHER_NAME) - @Bean(name = BUS_PATH_MATCHER_NAME) - public PathMatcher busPathMatcher() { - return new DefaultBusPathMatcher(new AntPathMatcher(":")); - } - - @Bean - @ConditionalOnMissingBean(ServiceMatcher.class) - public PathServiceMatcher pathServiceMatcher(@BusPathMatcher PathMatcher pathMatcher, BusProperties properties, - Environment environment) { - String[] configNames = environment.getProperty(CLOUD_CONFIG_NAME_PROPERTY, String[].class, new String[] {}); - return new PathServiceMatcher(pathMatcher, properties.getId(), configNames); - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/RemoteApplicationEventListener.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/RemoteApplicationEventListener.java deleted file mode 100644 index d7581f86..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/RemoteApplicationEventListener.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2015-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.cloud.bus.event.AckRemoteApplicationEvent; -import org.springframework.cloud.bus.event.RemoteApplicationEvent; -import org.springframework.context.ApplicationListener; - -public class RemoteApplicationEventListener implements ApplicationListener { - - private final Log log = LogFactory.getLog(getClass()); - - private final ServiceMatcher serviceMatcher; - - private final BusBridge busBridge; - - public RemoteApplicationEventListener(ServiceMatcher serviceMatcher, BusBridge busBridge) { - this.serviceMatcher = serviceMatcher; - this.busBridge = busBridge; - } - - @Override - public void onApplicationEvent(RemoteApplicationEvent event) { - if (this.serviceMatcher.isFromSelf(event) && !(event instanceof AckRemoteApplicationEvent)) { - if (log.isDebugEnabled()) { - log.debug("Sending remote event on bus: " + event); - } - // TODO: configurable mimetype? - this.busBridge.send(event); - } - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/ServiceMatcher.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/ServiceMatcher.java deleted file mode 100644 index e7d4c913..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/ServiceMatcher.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import org.springframework.cloud.bus.event.RemoteApplicationEvent; - -/** - * @author Spencer Gibb - */ -public interface ServiceMatcher { - - boolean isFromSelf(RemoteApplicationEvent event); - - boolean isForSelf(RemoteApplicationEvent event); - - String getBusId(); - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/StreamBusBridge.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/StreamBusBridge.java deleted file mode 100644 index eddc06d8..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/StreamBusBridge.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2015-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import org.springframework.cloud.bus.event.RemoteApplicationEvent; -import org.springframework.cloud.stream.function.StreamBridge; -import org.springframework.messaging.support.MessageBuilder; - -public class StreamBusBridge implements BusBridge { - - private final StreamBridge streamBridge; - - private final BusProperties properties; - - public StreamBusBridge(StreamBridge streamBridge, BusProperties properties) { - this.streamBridge = streamBridge; - this.properties = properties; - } - - public void send(RemoteApplicationEvent event) { - // TODO: configurable mimetype? - this.streamBridge.send(BusConstants.OUTPUT, MessageBuilder.withPayload(event).build()); - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/endpoint/AbstractBusEndpoint.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/endpoint/AbstractBusEndpoint.java deleted file mode 100644 index c48ab783..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/endpoint/AbstractBusEndpoint.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.endpoint; - -import org.springframework.cloud.bus.event.Destination; -import org.springframework.context.ApplicationEvent; -import org.springframework.context.ApplicationEventPublisher; - -/** - * @author Spencer Gibb - */ -public class AbstractBusEndpoint { - - private ApplicationEventPublisher publisher; - - private String appId; - - private final Destination.Factory destinationFactory; - - public AbstractBusEndpoint(ApplicationEventPublisher publisher, String appId, - Destination.Factory destinationFactory) { - this.publisher = publisher; - this.appId = appId; - this.destinationFactory = destinationFactory; - } - - protected String getInstanceId() { - return this.appId; - } - - protected Destination.Factory getDestinationFactory() { - return this.destinationFactory; - } - - protected Destination getDestination(String original) { - return destinationFactory.getDestination(original); - } - - protected void publish(ApplicationEvent event) { - this.publisher.publishEvent(event); - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/endpoint/EnvironmentBusEndpoint.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/endpoint/EnvironmentBusEndpoint.java deleted file mode 100644 index b2f93e35..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/endpoint/EnvironmentBusEndpoint.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.endpoint; - -import java.util.Collections; -import java.util.Map; - -import org.springframework.boot.actuate.endpoint.annotation.Endpoint; -import org.springframework.boot.actuate.endpoint.annotation.Selector; -import org.springframework.boot.actuate.endpoint.annotation.Selector.Match; -import org.springframework.boot.actuate.endpoint.annotation.WriteOperation; -import org.springframework.cloud.bus.event.Destination; -import org.springframework.cloud.bus.event.EnvironmentChangeRemoteApplicationEvent; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.util.StringUtils; - -/** - * @author Spencer Gibb - */ -@Endpoint(id = "busenv") // TODO: document -public class EnvironmentBusEndpoint extends AbstractBusEndpoint { - - public EnvironmentBusEndpoint(ApplicationEventPublisher publisher, String id, - Destination.Factory destinationFactory) { - super(publisher, id, destinationFactory); - } - - @WriteOperation - // TODO: document params - public void busEnvWithDestination(String name, String value, - @Selector(match = Match.ALL_REMAINING) String[] destinations) { - Map params = Collections.singletonMap(name, value); - String destination = StringUtils.arrayToDelimitedString(destinations, ":"); - publish(new EnvironmentChangeRemoteApplicationEvent(this, getInstanceId(), getDestination(destination), - params)); - } - - @WriteOperation - public void busEnv(String name, String value) { // TODO: document params - Map params = Collections.singletonMap(name, value); - publish(new EnvironmentChangeRemoteApplicationEvent(this, getInstanceId(), getDestination(null), params)); - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/endpoint/RefreshBusEndpoint.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/endpoint/RefreshBusEndpoint.java deleted file mode 100644 index 31b2297c..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/endpoint/RefreshBusEndpoint.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.endpoint; - -import org.springframework.boot.actuate.endpoint.annotation.Endpoint; -import org.springframework.boot.actuate.endpoint.annotation.Selector; -import org.springframework.boot.actuate.endpoint.annotation.Selector.Match; -import org.springframework.boot.actuate.endpoint.annotation.WriteOperation; -import org.springframework.cloud.bus.event.Destination; -import org.springframework.cloud.bus.event.RefreshRemoteApplicationEvent; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.util.StringUtils; - -/** - * @author Spencer Gibb - */ -@Endpoint(id = "busrefresh") // TODO: document new id -public class RefreshBusEndpoint extends AbstractBusEndpoint { - - public RefreshBusEndpoint(ApplicationEventPublisher publisher, String id, Destination.Factory destinationFactory) { - super(publisher, id, destinationFactory); - } - - @WriteOperation - public void busRefreshWithDestination(@Selector(match = Match.ALL_REMAINING) String[] destinations) { - String destination = StringUtils.arrayToDelimitedString(destinations, ":"); - publish(new RefreshRemoteApplicationEvent(this, getInstanceId(), getDestination(destination))); - } - - @WriteOperation - public void busRefresh() { - publish(new RefreshRemoteApplicationEvent(this, getInstanceId(), getDestination(null))); - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/AckRemoteApplicationEvent.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/AckRemoteApplicationEvent.java deleted file mode 100644 index 61c3c295..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/AckRemoteApplicationEvent.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.event; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * An event that signals an ack of a specific {@link RemoteApplicationEvent}. These events - * can be monitored by any applications that want to audit the responses to bus events. - * They behave like normal remote application events, in the sense that if the destination - * service matches the local service ID the application fires the event in its context. - * - * @author Dave Syer - * - */ -@SuppressWarnings("serial") -public class AckRemoteApplicationEvent extends RemoteApplicationEvent { - - private final String ackId; - - private final String ackDestinationService; - - private Class event; - - @SuppressWarnings("unused") - private AckRemoteApplicationEvent() { - super(); - this.ackDestinationService = null; - this.ackId = null; - this.event = null; - } - - public AckRemoteApplicationEvent(Object source, String originService, Destination destination, - String ackDestinationService, String ackId, Class type) { - super(source, originService, destination); - this.ackDestinationService = ackDestinationService; - this.ackId = ackId; - this.event = type; - } - - public String getAckId() { - return this.ackId; - } - - public String getAckDestinationService() { - return this.ackDestinationService; - } - - public Class getEvent() { - return this.event; - } - - /** - * Used by Jackson to set the remote class name of the event implementation. If the - * implementing class is unknown to this app, set the event to - * {@link UnknownRemoteApplicationEvent}. - * @param eventName the fq class name of the event implementation, not null - */ - @JsonProperty("event") - @SuppressWarnings("unchecked") - public void setEventName(String eventName) { - try { - this.event = (Class) Class.forName(eventName); - } - catch (ClassNotFoundException e) { - this.event = UnknownRemoteApplicationEvent.class; - } - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((this.ackDestinationService == null) ? 0 : this.ackDestinationService.hashCode()); - result = prime * result + ((this.ackId == null) ? 0 : this.ackId.hashCode()); - result = prime * result + ((this.event == null) ? 0 : this.event.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - AckRemoteApplicationEvent other = (AckRemoteApplicationEvent) obj; - if (this.ackDestinationService == null) { - if (other.ackDestinationService != null) { - return false; - } - } - else if (!this.ackDestinationService.equals(other.ackDestinationService)) { - return false; - } - if (this.ackId == null) { - if (other.ackId != null) { - return false; - } - } - else if (!this.ackId.equals(other.ackId)) { - return false; - } - if (this.event == null) { - if (other.event != null) { - return false; - } - } - else if (!this.event.equals(other.event)) { - return false; - } - return true; - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/Destination.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/Destination.java deleted file mode 100644 index efd0595e..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/Destination.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2015-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.event; - -public interface Destination { - - String getDestinationAsString(); - - @FunctionalInterface - interface Factory { - - Destination getDestination(String originalDestination); - - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/EnvironmentChangeListener.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/EnvironmentChangeListener.java deleted file mode 100644 index c5e4af9f..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/EnvironmentChangeListener.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.event; - -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cloud.context.environment.EnvironmentManager; -import org.springframework.context.ApplicationListener; - -/** - * @author Spencer Gibb - */ -public class EnvironmentChangeListener implements ApplicationListener { - - private static Log log = LogFactory.getLog(EnvironmentChangeListener.class); - - @Autowired - private EnvironmentManager env; - - @Override - public void onApplicationEvent(EnvironmentChangeRemoteApplicationEvent event) { - Map values = event.getValues(); - log.info("Received remote environment change request. Keys/values to update " + values); - for (Map.Entry entry : values.entrySet()) { - this.env.setProperty(entry.getKey(), entry.getValue()); - } - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/EnvironmentChangeRemoteApplicationEvent.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/EnvironmentChangeRemoteApplicationEvent.java deleted file mode 100644 index d0ef03f5..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/EnvironmentChangeRemoteApplicationEvent.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.event; - -import java.util.Map; - -import org.springframework.core.style.ToStringCreator; -import org.springframework.util.Assert; - -/** - * @author Spencer Gibb - */ -@SuppressWarnings("serial") -public class EnvironmentChangeRemoteApplicationEvent extends RemoteApplicationEvent { - - private final Map values; - - @SuppressWarnings("unused") - private EnvironmentChangeRemoteApplicationEvent() { - // for serializers - this.values = null; - } - - @Deprecated - public EnvironmentChangeRemoteApplicationEvent(Object source, String originService, String destinationService, - Map values) { - this(source, originService, new PathDestinationFactory().getDestination(destinationService), values); - } - - public EnvironmentChangeRemoteApplicationEvent(Object source, String originService, Destination destination, - Map values) { - super(source, originService, destination); - Assert.notNull(values, "values may not be null"); - this.values = values; - } - - public Map getValues() { - return this.values; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((this.values == null) ? 0 : this.values.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - EnvironmentChangeRemoteApplicationEvent other = (EnvironmentChangeRemoteApplicationEvent) obj; - if (this.values == null) { - if (other.values != null) { - return false; - } - } - else if (!this.values.equals(other.values)) { - return false; - } - return true; - } - - @Override - public String toString() { - return new ToStringCreator(this).append("id", getId()).append("originService", getOriginService()) - .append("destinationService", getDestinationService()).append("values", values).toString(); - - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/PathDestinationFactory.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/PathDestinationFactory.java deleted file mode 100644 index d63edd33..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/PathDestinationFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2015-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.event; - -import org.springframework.util.StringUtils; - -public class PathDestinationFactory implements Destination.Factory { - - public Destination getDestination(String originalDestination) { - String path = originalDestination; - if (path == null) { - path = "**"; - } - // If the path is not already a wildcard, match everything that - // follows if there at most two path elements, and last element is not a global - // wildcard already - if (!"**".equals(path)) { - if (StringUtils.countOccurrencesOf(path, ":") <= 1 && !StringUtils.endsWithIgnoreCase(path, ":**")) { - // All instances of the destination unless specifically requested - path = path + ":**"; - } - } - - final String finalPath = path; - return () -> finalPath; - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/RefreshListener.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/RefreshListener.java deleted file mode 100644 index af4998d9..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/RefreshListener.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.event; - -import java.util.Set; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.cloud.bus.ServiceMatcher; -import org.springframework.cloud.context.refresh.ContextRefresher; -import org.springframework.context.ApplicationListener; - -/** - * @author Spencer Gibb - * @author Ryan Baxter - */ -public class RefreshListener implements ApplicationListener { - - private static Log log = LogFactory.getLog(RefreshListener.class); - - private ContextRefresher contextRefresher; - - private ServiceMatcher serviceMatcher; - - public RefreshListener(ContextRefresher contextRefresher, ServiceMatcher serviceMatcher) { - this.contextRefresher = contextRefresher; - this.serviceMatcher = serviceMatcher; - } - - @Override - public void onApplicationEvent(RefreshRemoteApplicationEvent event) { - log.info("Received remote refresh request."); - if (serviceMatcher.isForSelf(event)) { - Set keys = this.contextRefresher.refresh(); - log.info("Keys refreshed " + keys); - } - else { - log.info("Refresh not performed, the event was targeting " + event.getDestinationService()); - } - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/RefreshRemoteApplicationEvent.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/RefreshRemoteApplicationEvent.java deleted file mode 100644 index dd0fa49c..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/RefreshRemoteApplicationEvent.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.event; - -/** - * @author Spencer Gibb - */ -@SuppressWarnings("serial") -public class RefreshRemoteApplicationEvent extends RemoteApplicationEvent { - - @SuppressWarnings("unused") - private RefreshRemoteApplicationEvent() { - // for serializers - } - - @Deprecated - public RefreshRemoteApplicationEvent(Object source, String originService, String destination) { - this(source, originService, new PathDestinationFactory().getDestination(destination)); - } - - public RefreshRemoteApplicationEvent(Object source, String originService, Destination destination) { - super(source, originService, destination); - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/RemoteApplicationEvent.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/RemoteApplicationEvent.java deleted file mode 100644 index 1445fe58..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/RemoteApplicationEvent.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.event; - -import java.util.UUID; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -import org.springframework.context.ApplicationEvent; -import org.springframework.core.style.ToStringCreator; -import org.springframework.util.Assert; - -/** - * @author Spencer Gibb - */ -@SuppressWarnings("serial") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") -@JsonIgnoreProperties("source") -public abstract class RemoteApplicationEvent extends ApplicationEvent { - - private static final Object TRANSIENT_SOURCE = new Object(); - - private static final String TRANSIENT_ORIGIN = "____transient_origin_service___"; - - private static final String TRANSIENT_DESTINATION = "____transient_destination___"; - - protected static final PathDestinationFactory DEFAULT_DESTINATION_FACTORY = new PathDestinationFactory(); - - private final String originService; - - private final String destinationService; - - private final String id; - - protected RemoteApplicationEvent() { - // for serialization libs like jackson - this(TRANSIENT_SOURCE, TRANSIENT_ORIGIN, DEFAULT_DESTINATION_FACTORY.getDestination(TRANSIENT_DESTINATION)); - } - - @Deprecated - protected RemoteApplicationEvent(Object source, String originService, String destinationService) { - this(source, originService, DEFAULT_DESTINATION_FACTORY.getDestination(destinationService)); - } - - protected RemoteApplicationEvent(Object source, String originService, Destination destination) { - super(source); - if (!originService.equals(TRANSIENT_ORIGIN)) { - Assert.notNull(originService, "originService may not be null"); - this.originService = originService; - } - else { - this.originService = null; - } - Assert.notNull(destination, "destination may not be null"); - this.destinationService = destination.getDestinationAsString(); - Assert.hasText(destinationService, "destinationService may not be empty"); - this.id = UUID.randomUUID().toString(); - } - - @Deprecated - protected RemoteApplicationEvent(Object source, String originService) { - this(source, originService, DEFAULT_DESTINATION_FACTORY.getDestination(null)); - } - - public String getOriginService() { - return this.originService; - } - - public String getDestinationService() { - return this.destinationService; - } - - public String getId() { - return this.id; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((this.destinationService == null) ? 0 : this.destinationService.hashCode()); - result = prime * result + ((this.id == null) ? 0 : this.id.hashCode()); - result = prime * result + ((this.originService == null) ? 0 : this.originService.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - RemoteApplicationEvent other = (RemoteApplicationEvent) obj; - if (this.destinationService == null) { - if (other.destinationService != null) { - return false; - } - } - else if (!this.destinationService.equals(other.destinationService)) { - return false; - } - if (this.id == null) { - if (other.id != null) { - return false; - } - } - else if (!this.id.equals(other.id)) { - return false; - } - if (this.originService == null) { - if (other.originService != null) { - return false; - } - } - else if (!this.originService.equals(other.originService)) { - return false; - } - return true; - } - - @Override - public String toString() { - return new ToStringCreator(this).append("id", id).append("originService", originService) - .append("destinationService", destinationService).toString(); - - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/SentApplicationEvent.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/SentApplicationEvent.java deleted file mode 100644 index 440d8d33..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/SentApplicationEvent.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.event; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -import org.springframework.context.ApplicationEvent; - -/** - * An event signalling that a remote event was sent somewhere in the system. This is not - * itself a {@link RemoteApplicationEvent}, so it isn't sent over the bus, instead it is - * generated locally (possibly in response to a remote event). Applications that want to - * audit remote events can listen for this one and the {@link AckRemoteApplicationEvent} - * from all the consumers (the {@link #getId() id} of this event is the - * {@link AckRemoteApplicationEvent#getAckId() ackId} of the corresponding ACK. - * - * @author Dave Syer - */ -@SuppressWarnings("serial") -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") -@JsonIgnoreProperties("source") -public class SentApplicationEvent extends ApplicationEvent { - - private static final Object TRANSIENT_SOURCE = new Object(); - - private final String originService; - - private final String destinationService; - - private final String id; - - private Class type; - - protected SentApplicationEvent() { - // for serialization libs like jackson - this(TRANSIENT_SOURCE, null, null, null, RemoteApplicationEvent.class); - } - - public SentApplicationEvent(Object source, String originService, String destinationService, String id, - Class type) { - super(source); - this.originService = originService; - this.type = type; - if (destinationService == null) { - destinationService = "*"; - } - if (!destinationService.contains(":")) { - // All instances of the destination unless specifically requested - destinationService = destinationService + ":**"; - } - this.destinationService = destinationService; - this.id = id; - } - - public Class getType() { - return this.type; - } - - public void setType(Class type) { - this.type = type; - } - - public String getOriginService() { - return this.originService; - } - - public String getDestinationService() { - return this.destinationService; - } - - public String getId() { - return this.id; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((this.destinationService == null) ? 0 : this.destinationService.hashCode()); - result = prime * result + ((this.id == null) ? 0 : this.id.hashCode()); - result = prime * result + ((this.originService == null) ? 0 : this.originService.hashCode()); - result = prime * result + ((this.type == null) ? 0 : this.type.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - SentApplicationEvent other = (SentApplicationEvent) obj; - if (this.destinationService == null) { - if (other.destinationService != null) { - return false; - } - } - else if (!this.destinationService.equals(other.destinationService)) { - return false; - } - if (this.id == null) { - if (other.id != null) { - return false; - } - } - else if (!this.id.equals(other.id)) { - return false; - } - if (this.originService == null) { - if (other.originService != null) { - return false; - } - } - else if (!this.originService.equals(other.originService)) { - return false; - } - if (this.type == null) { - if (other.type != null) { - return false; - } - } - else if (!this.type.equals(other.type)) { - return false; - } - return true; - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/TraceListener.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/TraceListener.java deleted file mode 100644 index 0dfcfda9..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/TraceListener.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.event; - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.boot.actuate.web.exchanges.HttpExchangeRepository; -import org.springframework.context.event.EventListener; - -/** - * A listener for sends and acks of remote application events. Inserts a record for each - * signal in the {@link HttpExchangeRepository}. - * - * @author Dave Syer - */ -public class TraceListener { - - private static Log log = LogFactory.getLog(TraceListener.class); - - private HttpExchangeRepository repository; - - public TraceListener(HttpExchangeRepository repository) { - this.repository = repository; - } - - @EventListener - public void onAck(AckRemoteApplicationEvent event) { - Map trace = getReceivedTrace(event); - // FIXME boot 2 this.repository.add(trace); - } - - @EventListener - public void onSend(SentApplicationEvent event) { - Map trace = getSentTrace(event); - // FIXME boot 2 this.repository.add(trace); - } - - protected Map getSentTrace(SentApplicationEvent event) { - Map map = new LinkedHashMap(); - map.put("signal", "spring.cloud.bus.sent"); - map.put("type", event.getType().getSimpleName()); - map.put("id", event.getId()); - map.put("origin", event.getOriginService()); - map.put("destination", event.getDestinationService()); - if (log.isDebugEnabled()) { - log.debug(map); - } - return map; - } - - protected Map getReceivedTrace(AckRemoteApplicationEvent event) { - Map map = new LinkedHashMap(); - map.put("signal", "spring.cloud.bus.ack"); - map.put("event", event.getEvent().getSimpleName()); - map.put("id", event.getAckId()); - map.put("origin", event.getOriginService()); - map.put("destination", event.getAckDestinationService()); - if (log.isDebugEnabled()) { - log.debug(map); - } - return map; - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/UnknownRemoteApplicationEvent.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/UnknownRemoteApplicationEvent.java deleted file mode 100644 index 25ab2420..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/event/UnknownRemoteApplicationEvent.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.event; - -import org.springframework.core.style.ToStringCreator; - -/** - * @author Stefan Pfeiffer - */ -public class UnknownRemoteApplicationEvent extends RemoteApplicationEvent { - - protected String typeInfo; - - protected byte[] payload; - - @SuppressWarnings("unused") - private UnknownRemoteApplicationEvent() { - super(); - this.typeInfo = null; - this.payload = null; - } - - public UnknownRemoteApplicationEvent(Object source, String typeInfo, byte[] payload) { - // Initialize originService with an empty String, to avoid NullPointer in - // AntPathMatcher. - super(source, "", () -> "unknown"); - this.typeInfo = typeInfo; - this.payload = payload; - } - - public String getTypeInfo() { - return this.typeInfo; - } - - public byte[] getPayload() { - return this.payload; - } - - public String getPayloadAsString() { - if (this.payload != null) { - return new String(this.payload); - } - return null; - } - - @Override - public String toString() { - return new ToStringCreator(this).append("id", getId()).append("originService", getOriginService()) - .append("destinationService", getDestinationService()).append("typeInfo", typeInfo) - .append("payload", getPayloadAsString()).toString(); - - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/jackson/BusJacksonAutoConfiguration.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/jackson/BusJacksonAutoConfiguration.java deleted file mode 100644 index c2825948..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/jackson/BusJacksonAutoConfiguration.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.jackson; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.exc.InvalidTypeIdException; -import com.fasterxml.jackson.dataformat.cbor.CBORFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.boot.autoconfigure.AutoConfigureBefore; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; -import org.springframework.cloud.bus.BusAutoConfiguration; -import org.springframework.cloud.bus.ConditionalOnBusEnabled; -import org.springframework.cloud.bus.endpoint.RefreshBusEndpoint; -import org.springframework.cloud.bus.event.RemoteApplicationEvent; -import org.springframework.cloud.bus.event.UnknownRemoteApplicationEvent; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.type.filter.AssignableTypeFilter; -import org.springframework.lang.Nullable; -import org.springframework.messaging.Message; -import org.springframework.messaging.converter.AbstractMessageConverter; -import org.springframework.util.ClassUtils; -import org.springframework.util.MimeType; -import org.springframework.util.MimeTypeUtils; - -/** - * @author Spencer Gibb - * @author Dave Syer - * @author Donovan Muller - * @author Stefan Pfeiffer - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnBusEnabled -@ConditionalOnClass({ RefreshBusEndpoint.class, ObjectMapper.class }) -@AutoConfigureBefore({ BusAutoConfiguration.class, JacksonAutoConfiguration.class }) -public class BusJacksonAutoConfiguration { - - // needed in the case where @RemoteApplicationEventScan is not used - // otherwise RemoteApplicationEventRegistrar will register the bean - @Bean - @ConditionalOnMissingBean(name = "busJsonConverter") - public AbstractMessageConverter busJsonConverter(@Autowired(required = false) ObjectMapper objectMapper) { - return new BusJacksonMessageConverter(objectMapper); - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnClass(CBORFactory.class) - protected static class CborConfiguration { - - @Bean - public AbstractMessageConverter busCborConverter() { - return new BusJacksonMessageConverter(new MimeType("application", "cbor"), - new ObjectMapper(new CBORFactory())); - } - - } - -} - -class BusJacksonMessageConverter extends AbstractMessageConverter implements InitializingBean { - - private static final Log log = LogFactory.getLog(BusJacksonMessageConverter.class); - - private static final String DEFAULT_PACKAGE = ClassUtils.getPackageName(RemoteApplicationEvent.class); - - private final ObjectMapper mapper; - - private final boolean mapperCreated; - - private String[] packagesToScan = new String[] { DEFAULT_PACKAGE }; - - private BusJacksonMessageConverter() { - this(null); - } - - @Autowired(required = false) - BusJacksonMessageConverter(@Nullable ObjectMapper objectMapper) { - this(MimeTypeUtils.APPLICATION_JSON, objectMapper); - } - - @Autowired(required = false) - BusJacksonMessageConverter(MimeType mimeType, @Nullable ObjectMapper objectMapper) { - super(mimeType); - - if (objectMapper != null) { - this.mapper = objectMapper; - this.mapperCreated = false; - } - else { - this.mapper = new ObjectMapper(); - this.mapperCreated = true; - } - } - - /* for testing */ boolean isMapperCreated() { - return this.mapperCreated; - } - - /* for testing */ ObjectMapper getMapper() { - return this.mapper; - } - - public void setPackagesToScan(String[] packagesToScan) { - List packages = new ArrayList<>(Arrays.asList(packagesToScan)); - if (!packages.contains(DEFAULT_PACKAGE)) { - packages.add(DEFAULT_PACKAGE); - } - this.packagesToScan = packages.toArray(new String[0]); - } - - private Class[] findSubTypes() { - List> types = new ArrayList<>(); - if (this.packagesToScan != null) { - for (String pkg : this.packagesToScan) { - ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider( - false); - provider.addIncludeFilter(new AssignableTypeFilter(RemoteApplicationEvent.class)); - - Set components = provider.findCandidateComponents(pkg); - for (BeanDefinition component : components) { - try { - types.add(Class.forName(component.getBeanClassName())); - } - catch (ClassNotFoundException e) { - throw new IllegalStateException("Failed to scan classpath for remote event classes", e); - } - } - } - } - if (log.isDebugEnabled()) { - log.debug("Found sub types: " + types); - } - return types.toArray(new Class[0]); - } - - @Override - protected boolean supports(Class aClass) { - // This converter applies only to RemoteApplicationEvent and subclasses - return RemoteApplicationEvent.class.isAssignableFrom(aClass); - } - - @Override - public Object convertFromInternal(Message message, Class targetClass, Object conversionHint) { - Object result = null; - try { - Object payload = message.getPayload(); - - if (payload instanceof byte[]) { - try { - result = this.mapper.readValue((byte[]) payload, targetClass); - } - catch (InvalidTypeIdException e) { - return new UnknownRemoteApplicationEvent(new Object(), e.getTypeId(), (byte[]) payload); - } - } - else if (payload instanceof String) { - try { - result = this.mapper.readValue((String) payload, targetClass); - } - catch (InvalidTypeIdException e) { - return new UnknownRemoteApplicationEvent(new Object(), e.getTypeId(), - ((String) payload).getBytes()); - } - // workaround for - // https://github.com/spring-cloud/spring-cloud-stream/issues/1564 - } - else if (payload instanceof RemoteApplicationEvent) { - return payload; - } - } - catch (Exception e) { - this.logger.error(e.getMessage(), e); - return null; - } - return result; - } - - @Override - public void afterPropertiesSet() throws Exception { - this.mapper.registerModule(new SubtypeModule(findSubTypes())); - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/jackson/RemoteApplicationEventRegistrar.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/jackson/RemoteApplicationEventRegistrar.java deleted file mode 100644 index ab1501b1..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/jackson/RemoteApplicationEventRegistrar.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.jackson; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.springframework.beans.factory.config.BeanDefinitionHolder; -import org.springframework.beans.factory.support.AbstractBeanDefinition; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; -import org.springframework.beans.factory.support.BeanDefinitionReaderUtils; -import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; -import org.springframework.core.type.AnnotationMetadata; -import org.springframework.util.ClassUtils; -import org.springframework.util.StringUtils; - -/** - * @author Donovan Muller - */ -public class RemoteApplicationEventRegistrar implements ImportBeanDefinitionRegistrar { - - private static final String PACKAGES_TO_SCAN = "packagesToScan"; - - private static final String BUS_JSON_CONVERTER = "busJsonConverter"; - - // patterned after Spring Integration IntegrationComponentScanRegistrar - - @Override - public void registerBeanDefinitions(final AnnotationMetadata importingClassMetadata, - final BeanDefinitionRegistry registry) { - - Map componentScan = importingClassMetadata - .getAnnotationAttributes(RemoteApplicationEventScan.class.getName(), false); - - Set basePackages = new HashSet<>(); - for (String pkg : (String[]) componentScan.get("value")) { - if (StringUtils.hasText(pkg)) { - basePackages.add(pkg); - } - } - for (String pkg : (String[]) componentScan.get("basePackages")) { - if (StringUtils.hasText(pkg)) { - basePackages.add(pkg); - } - } - for (Class clazz : (Class[]) componentScan.get("basePackageClasses")) { - basePackages.add(ClassUtils.getPackageName(clazz)); - } - - if (basePackages.isEmpty()) { - basePackages.add(ClassUtils.getPackageName(importingClassMetadata.getClassName())); - } - - if (!registry.containsBeanDefinition(BUS_JSON_CONVERTER)) { - BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder - .genericBeanDefinition(BusJacksonMessageConverter.class); - beanDefinitionBuilder.addPropertyValue(PACKAGES_TO_SCAN, - basePackages.toArray(new String[basePackages.size()])); - AbstractBeanDefinition beanDefinition = beanDefinitionBuilder.getBeanDefinition(); - - BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDefinition, BUS_JSON_CONVERTER); - BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry); - } - else { - basePackages.addAll(getEarlierPackagesToScan(registry)); - registry.getBeanDefinition(BUS_JSON_CONVERTER).getPropertyValues().addPropertyValue(PACKAGES_TO_SCAN, - basePackages.toArray(new String[basePackages.size()])); - } - } - - private Set getEarlierPackagesToScan(final BeanDefinitionRegistry registry) { - if (registry.containsBeanDefinition(BUS_JSON_CONVERTER) - && registry.getBeanDefinition(BUS_JSON_CONVERTER).getPropertyValues().get(PACKAGES_TO_SCAN) != null) { - String[] earlierValues = (String[]) registry.getBeanDefinition(BUS_JSON_CONVERTER).getPropertyValues() - .get(PACKAGES_TO_SCAN); - return new HashSet<>(Arrays.asList(earlierValues)); - } - - return new HashSet<>(); - } - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/jackson/RemoteApplicationEventScan.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/jackson/RemoteApplicationEventScan.java deleted file mode 100644 index be054ede..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/jackson/RemoteApplicationEventScan.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.jackson; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.context.annotation.Import; - -/** - * @author Donovan Muller - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Documented -@Import(RemoteApplicationEventRegistrar.class) -public @interface RemoteApplicationEventScan { - - String[] value() default {}; - - String[] basePackages() default {}; - - Class[] basePackageClasses() default {}; - -} diff --git a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/jackson/SubtypeModule.java b/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/jackson/SubtypeModule.java deleted file mode 100644 index 76f9e909..00000000 --- a/spring-cloud-bus/src/main/java/org/springframework/cloud/bus/jackson/SubtypeModule.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.jackson; - -import com.fasterxml.jackson.databind.module.SimpleModule; - -/** - * @author Spencer Gibb - */ -@SuppressWarnings("serial") -public class SubtypeModule extends SimpleModule { - - private Class[] subtypes; - - public SubtypeModule(Class... subtypes) { - this.subtypes = subtypes; - } - - @Override - public void setupModule(SetupContext context) { - context.registerSubtypes(this.subtypes); - super.setupModule(context); - } - -} diff --git a/spring-cloud-bus/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-cloud-bus/src/main/resources/META-INF/additional-spring-configuration-metadata.json deleted file mode 100644 index 06714087..00000000 --- a/spring-cloud-bus/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "properties": [ - { - "name": "spring.cloud.bus.env.enabled", - "type": "java.lang.Boolean", - "description": "Flag to switch off environment change events (default on).", - "defaultValue": true - }, - { - "name": "spring.cloud.bus.refresh.enabled", - "type": "java.lang.Boolean", - "description": "Flag to switch off refresh events (default on).", - "defaultValue": true - }, - { - "name": "spring.cloud.bus.trace.enabled", - "type": "java.lang.Boolean", - "description": "Flag to switch on tracing of acks (default off).", - "defaultValue": false - } - ] -} - diff --git a/spring-cloud-bus/src/main/resources/META-INF/spring.factories b/spring-cloud-bus/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 665f0a37..00000000 --- a/spring-cloud-bus/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -# Environment Post Processor -org.springframework.boot.env.EnvironmentPostProcessor=\ -org.springframework.cloud.bus.BusEnvironmentPostProcessor diff --git a/spring-cloud-bus/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-cloud-bus/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index ac7da219..00000000 --- a/spring-cloud-bus/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1,5 +0,0 @@ -org.springframework.cloud.bus.PathServiceMatcherAutoConfiguration -org.springframework.cloud.bus.BusAutoConfiguration -org.springframework.cloud.bus.BusRefreshAutoConfiguration -org.springframework.cloud.bus.BusStreamAutoConfiguration -org.springframework.cloud.bus.jackson.BusJacksonAutoConfiguration \ No newline at end of file diff --git a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/BusAutoConfigurationClassPathTests.java b/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/BusAutoConfigurationClassPathTests.java deleted file mode 100644 index 74906d6e..00000000 --- a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/BusAutoConfigurationClassPathTests.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import org.junit.Test; - -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.test.context.FilteredClassLoader; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration; -import org.springframework.cloud.bus.endpoint.RefreshBusEndpoint; -import org.springframework.cloud.bus.event.RefreshListener; - -import static org.assertj.core.api.Assertions.assertThat; - -public class BusAutoConfigurationClassPathTests { - - @Test - public void refreshListenerCreatedWithoutActuator() { - new ApplicationContextRunner().withClassLoader(new FilteredClassLoader("org.springframework.boot.actuate")) - .withConfiguration(AutoConfigurations.of(RefreshAutoConfiguration.class, - PathServiceMatcherAutoConfiguration.class, BusRefreshAutoConfiguration.class)) - .run(context -> assertThat(context).hasSingleBean(RefreshListener.class) - .doesNotHaveBean(RefreshBusEndpoint.class)); - } - -} diff --git a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/BusAutoConfigurationTests.java b/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/BusAutoConfigurationTests.java deleted file mode 100644 index d9cc93dc..00000000 --- a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/BusAutoConfigurationTests.java +++ /dev/null @@ -1,328 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import java.util.HashMap; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.junit.After; -import org.junit.Test; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; -import org.springframework.cloud.bus.event.AckRemoteApplicationEvent; -import org.springframework.cloud.bus.event.PathDestinationFactory; -import org.springframework.cloud.bus.event.RefreshRemoteApplicationEvent; -import org.springframework.cloud.bus.event.RemoteApplicationEvent; -import org.springframework.cloud.bus.event.SentApplicationEvent; -import org.springframework.cloud.bus.event.UnknownRemoteApplicationEvent; -import org.springframework.cloud.context.refresh.ContextRefresher; -import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration; -import org.springframework.cloud.stream.config.BindingProperties; -import org.springframework.cloud.stream.config.BindingServiceProperties; -import org.springframework.cloud.stream.function.StreamBridge; -import org.springframework.context.ApplicationListener; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.support.GenericMessage; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class BusAutoConfigurationTests { - - private ConfigurableApplicationContext context; - - @After - public void close() { - if (this.context != null) { - this.context.close(); - } - } - - @Test - public void defaultId() { - this.context = SpringApplication.run(InboundMessageHandlerConfiguration.class, "--server.port=0"); - assertThat(this.context.getBean(BusProperties.class).getId().startsWith("application:0:")) - .as("Wrong ID: " + this.context.getBean(BusProperties.class).getId()).isTrue(); - } - - @Test - public void inboundNotForSelf() { - this.context = SpringApplication.run(InboundMessageHandlerConfiguration.class, "--spring.cloud.bus.id=foo", - "--server.port=0"); - this.context.getBean(BusConstants.INPUT, MessageChannel.class) - .send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "bar", "bar"))); - assertThat(this.context.getBean(InboundMessageHandlerConfiguration.class).refresh).isNull(); - } - - @Test - public void inboundFromSelf() { - this.context = SpringApplication.run(InboundMessageHandlerConfiguration.class, "--spring.cloud.bus.id=foo", - "--server.port=0"); - this.context.getBean(BusConstants.INPUT, MessageChannel.class) - .send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "foo", (String) null))); - assertThat(this.context.getBean(InboundMessageHandlerConfiguration.class).refresh).isNull(); - } - - @Test - public void inboundNotFromSelf() { - this.context = SpringApplication.run(InboundMessageHandlerConfiguration.class, "--spring.cloud.bus.id=bar", - "--server.port=0"); - this.context.getBean(BusConstants.INPUT, MessageChannel.class) - .send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "foo", (String) null))); - assertThat(this.context.getBean(InboundMessageHandlerConfiguration.class).refresh).isNotNull(); - } - - @Test - public void inboundNotFromSelfWithAck() throws Exception { - this.context = SpringApplication.run( - new Class[] { InboundMessageHandlerConfiguration.class, OutboundMessageHandlerConfiguration.class, - SentMessageConfiguration.class }, - new String[] { "--spring.cloud.bus.id=bar", "--server.port=0", - "--spring.main.allow-bean-definition-overriding=true" }); - this.context.getBean(BusConstants.INPUT, MessageChannel.class) - .send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "foo", (String) null))); - RefreshRemoteApplicationEvent refresh = this.context.getBean(InboundMessageHandlerConfiguration.class).refresh; - assertThat(refresh).isNotNull(); - TestStreamBusBridge busBridge = this.context.getBean(TestStreamBusBridge.class); - busBridge.latch.await(200, TimeUnit.SECONDS); - assertThat(busBridge.message).isInstanceOf(AckRemoteApplicationEvent.class); - AckRemoteApplicationEvent message = (AckRemoteApplicationEvent) busBridge.message; - assertThat(message.getAckId()).as("Wrong ackId: %s", message).isEqualTo(refresh.getId()); - } - - @Test - public void inboundNotFromSelfWithTrace() { - this.context = SpringApplication.run( - new Class[] { InboundMessageHandlerConfiguration.class, OutboundMessageHandlerConfiguration.class, - SentMessageConfiguration.class }, - new String[] { "--spring.cloud.bus.trace.enabled=true", "--spring.cloud.bus.id=bar", - "--server.port=0" }); - this.context.getBean(BusConsumer.class).accept(new RefreshRemoteApplicationEvent(this, "foo", (String) null)); - RefreshRemoteApplicationEvent refresh = this.context.getBean(InboundMessageHandlerConfiguration.class).refresh; - assertThat(refresh).isNotNull(); - SentMessageConfiguration sent = this.context.getBean(SentMessageConfiguration.class); - assertThat(sent.event).isNotNull(); - assertThat(sent.count).isEqualTo(1); - } - - @Test - public void inboundAckWithTrace() throws InterruptedException { - this.context = SpringApplication.run( - new Class[] { InboundMessageHandlerConfiguration.class, OutboundMessageHandlerConfiguration.class, - AckMessageConfiguration.class }, - new String[] { "--spring.cloud.bus.trace.enabled=true", "--spring.cloud.bus.id=bar", - "--server.port=0" }); - this.context.getBean(BusConsumer.class).accept(new AckRemoteApplicationEvent(this, "foo", - new PathDestinationFactory().getDestination(null), "ID", "bar", RefreshRemoteApplicationEvent.class)); - AckMessageConfiguration ack = this.context.getBean(AckMessageConfiguration.class); - assertThat(ack.latch.await(5, TimeUnit.SECONDS)).isTrue(); - assertThat(ack.event).isNotNull(); - assertThat(ack.count).isEqualTo(1); - } - - @Test - public void outboundFromSelf() throws Exception { - this.context = SpringApplication.run(OutboundMessageHandlerConfiguration.class, "--debug=true", - "--spring.cloud.bus.id=foo", "--server.port=0"); - this.context.publishEvent(new RefreshRemoteApplicationEvent(this, "foo", (String) null)); - TestStreamBusBridge busBridge = this.context.getBean(TestStreamBusBridge.class); - busBridge.latch.await(2, TimeUnit.SECONDS); - assertThat(busBridge.message).as("message was null").isNotNull(); - } - - @Test - public void outboundNotFromSelf() { - this.context = SpringApplication.run(OutboundMessageHandlerConfiguration.class, "--spring.cloud.bus.id=bar", - "--server.port=0"); - this.context.publishEvent(new RefreshRemoteApplicationEvent(this, "foo", (String) null)); - assertThat(this.context.getBean(TestStreamBusBridge.class).message).isNull(); - } - - @Test - public void inboundNotFromSelfPathPattern() { - this.context = SpringApplication.run(InboundMessageHandlerConfiguration.class, "--spring.cloud.bus.id=bar:1000", - "--server.port=0"); - this.context.getBean(BusConstants.INPUT, MessageChannel.class) - .send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "foo", "bar:*"))); - assertThat(this.context.getBean(InboundMessageHandlerConfiguration.class).refresh).isNotNull(); - } - - @Test - public void inboundNotFromSelfDeepPathPattern() { - this.context = SpringApplication.run(InboundMessageHandlerConfiguration.class, - "--spring.cloud.bus.id=bar:test:1000", "--server.port=0"); - this.context.getBean(BusConstants.INPUT, MessageChannel.class) - .send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "foo", "bar:**"))); - assertThat(this.context.getBean(InboundMessageHandlerConfiguration.class).refresh).isNotNull(); - } - - @Test - public void inboundNotFromSelfFlatPattern() { - this.context = SpringApplication.run(InboundMessageHandlerConfiguration.class, "--spring.cloud.bus.id=bar", - "--server.port=0"); - this.context.getBean(BusConstants.INPUT, MessageChannel.class) - .send(new GenericMessage<>(new RefreshRemoteApplicationEvent(this, "foo", "bar*"))); - assertThat(this.context.getBean(InboundMessageHandlerConfiguration.class).refresh).isNotNull(); - } - - // see https://github.com/spring-cloud/spring-cloud-bus/issues/74 - @Test - public void inboundNotFromSelfUnknown() { - this.context = SpringApplication.run(InboundMessageHandlerConfiguration.class, "--spring.cloud.bus.id=bar", - "--server.port=0"); - this.context.getBean(BusConstants.INPUT, MessageChannel.class) - .send(new GenericMessage<>(new UnknownRemoteApplicationEvent(this, "UnknownEvent", "yada".getBytes()))); - // No Exception expected - } - - @Test - public void initDoesNotOverrideCustomDestination() { - HashMap properties = new HashMap<>(); - BindingProperties input = new BindingProperties(); - input.setDestination("mydestination"); - properties.put(BusConstants.INPUT, input); - BindingProperties output = new BindingProperties(); - output.setDestination("mydestination"); - properties.put(BusConstants.OUTPUT, output); - - setupBusAutoConfig(properties); - - BindingProperties inputProps = properties.get(BusConstants.INPUT); - assertThat(inputProps.getDestination()).isEqualTo("mydestination"); - - BindingProperties outputProps = properties.get(BusConstants.OUTPUT); - assertThat(outputProps.getDestination()).isEqualTo("mydestination"); - } - - private BusProperties setupBusAutoConfig(HashMap properties) { - BindingServiceProperties serviceProperties = mock(BindingServiceProperties.class); - when(serviceProperties.getBindings()).thenReturn(properties); - - BusProperties bus = new BusProperties(); - BusAutoConfiguration configuration = new BusAutoConfiguration(); - return bus; - } - - // see https://github.com/spring-cloud/spring-cloud-bus/issues/101 - @Test - public void serviceMatcherIdIsConstantAfterRefresh() { - this.context = SpringApplication.run(new Class[] { RefreshConfig.class, TestChannelBinderConfiguration.class }, - new String[] { "--server.port=0", "--spring.main.allow-bean-definition-overriding=true" }); - String originalServiceId = this.context.getBean(ServiceMatcher.class).getBusId(); - this.context.getBean(ContextRefresher.class).refresh(); - String newServiceId = this.context.getBean(ServiceMatcher.class).getBusId(); - assertThat(newServiceId).isEqualTo(originalServiceId); - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - protected static class RefreshConfig { - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @ImportAutoConfiguration({ BusAutoConfiguration.class, TestChannelBinderConfiguration.class, - PropertyPlaceholderAutoConfiguration.class }) - protected static class OutboundMessageHandlerConfiguration { - - @Bean - @Primary - StreamBusBridge testStreamBusBridge(StreamBridge streamBridge, BusProperties properties) { - return new TestStreamBusBridge(streamBridge, properties); - } - - } - - protected static class TestStreamBusBridge extends StreamBusBridge { - - private CountDownLatch latch = new CountDownLatch(1); - - private RemoteApplicationEvent message; - - public TestStreamBusBridge(StreamBridge streamBridge, BusProperties properties) { - super(streamBridge, properties); - } - - @Override - public void send(RemoteApplicationEvent event) { - latch.countDown(); - message = event; - super.send(event); - } - - } - - @Configuration(proxyBeanMethods = false) - @EnableAutoConfiguration - @ImportAutoConfiguration({ BusAutoConfiguration.class, TestChannelBinderConfiguration.class, - PropertyPlaceholderAutoConfiguration.class }) - protected static class InboundMessageHandlerConfiguration - implements ApplicationListener { - - private RefreshRemoteApplicationEvent refresh; - - @Override - public void onApplicationEvent(RefreshRemoteApplicationEvent event) { - this.refresh = event; - } - - } - - @Configuration(proxyBeanMethods = false) - protected static class SentMessageConfiguration implements ApplicationListener { - - private SentApplicationEvent event; - - private int count; - - @Override - public void onApplicationEvent(SentApplicationEvent event) { - this.event = event; - this.count++; - } - - } - - @Configuration(proxyBeanMethods = false) - protected static class AckMessageConfiguration implements ApplicationListener { - - private CountDownLatch latch = new CountDownLatch(1); - - private AckRemoteApplicationEvent event; - - private int count; - - @Override - public void onApplicationEvent(AckRemoteApplicationEvent event) { - this.event = event; - this.count++; - latch.countDown(); - } - - } - -} diff --git a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/BusEnvironmentPostProcessorTests.java b/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/BusEnvironmentPostProcessorTests.java deleted file mode 100644 index 1ae9343b..00000000 --- a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/BusEnvironmentPostProcessorTests.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2015-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import org.junit.jupiter.api.Test; - -import org.springframework.boot.SpringApplication; -import org.springframework.cloud.function.context.FunctionProperties; -import org.springframework.mock.env.MockEnvironment; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.springframework.cloud.bus.BusConstants.BUS_CONSUMER; -import static org.springframework.cloud.bus.BusConstants.DESTINATION; -import static org.springframework.cloud.bus.BusConstants.INPUT; -import static org.springframework.cloud.bus.BusConstants.OUTPUT; -import static org.springframework.cloud.bus.BusEnvironmentPostProcessor.DEFAULTS_PROPERTY_SOURCE_NAME; -import static org.springframework.cloud.bus.BusEnvironmentPostProcessor.OVERRIDES_PROPERTY_SOURCE_NAME; - -public class BusEnvironmentPostProcessorTests { - - @Test - void testDefaults() { - MockEnvironment env = new MockEnvironment().withProperty("cachedrandom.application.value", "123"); - new BusEnvironmentPostProcessor().postProcessEnvironment(env, mock(SpringApplication.class)); - assertThat(env.getProperty(FunctionProperties.PREFIX + ".definition")).isEqualTo(BUS_CONSUMER); - assertThat(env.getProperty("spring.cloud.stream.function.bindings." + BUS_CONSUMER + "-in-0")).isEqualTo(INPUT); - assertThat(env.getProperty("spring.cloud.stream.bindings." + INPUT + ".destination")).isEqualTo(DESTINATION); - assertThat(env.getProperty("spring.cloud.stream.bindings." + OUTPUT + ".destination")).isEqualTo(DESTINATION); - assertThat(env.getProperty(BusProperties.PREFIX + ".id")).isEqualTo("application:8080:123"); - assertThat(env.getPropertySources().contains(OVERRIDES_PROPERTY_SOURCE_NAME)); - assertThat(env.getPropertySources().contains(DEFAULTS_PROPERTY_SOURCE_NAME)); - } - - @Test - void testWithActiveProfile() { - MockEnvironment env = new MockEnvironment().withProperty("cachedrandom.application.value", "123") - .withProperty("spring.profiles.active", "dev"); - new BusEnvironmentPostProcessor().postProcessEnvironment(env, mock(SpringApplication.class)); - assertThat(env.getProperty(FunctionProperties.PREFIX + ".definition")).isEqualTo(BUS_CONSUMER); - assertThat(env.getProperty("spring.cloud.stream.function.bindings." + BUS_CONSUMER + "-in-0")).isEqualTo(INPUT); - assertThat(env.getProperty("spring.cloud.stream.bindings." + INPUT + ".destination")).isEqualTo(DESTINATION); - assertThat(env.getProperty("spring.cloud.stream.bindings." + OUTPUT + ".destination")).isEqualTo(DESTINATION); - assertThat(env.getProperty(BusProperties.PREFIX + ".id")).isEqualTo("application:dev:8080:123"); - assertThat(env.getPropertySources().contains(OVERRIDES_PROPERTY_SOURCE_NAME)); - assertThat(env.getPropertySources().contains(DEFAULTS_PROPERTY_SOURCE_NAME)); - } - - @Test - void testOverrides() { - String fnDefKey = FunctionProperties.PREFIX + ".definition"; - String idKey = BusProperties.PREFIX + ".id"; - MockEnvironment env = new MockEnvironment().withProperty("cachedrandom.application.value", "123") - .withProperty(BusProperties.PREFIX + ".destination", "mydestination").withProperty(idKey, "app:1") - .withProperty(fnDefKey, "uppercase"); - new BusEnvironmentPostProcessor().postProcessEnvironment(env, mock(SpringApplication.class)); - assertThat(env.getProperty(fnDefKey)).isEqualTo("uppercase;" + BUS_CONSUMER); - assertThat(env.getProperty("spring.cloud.stream.function.bindings." + BUS_CONSUMER + "-in-0")).isEqualTo(INPUT); - assertThat(env.getProperty("spring.cloud.stream.bindings." + INPUT + ".destination")) - .isEqualTo("mydestination"); - assertThat(env.getProperty("spring.cloud.stream.bindings." + OUTPUT + ".destination")) - .isEqualTo("mydestination"); - assertThat(env.getProperty(idKey)).isEqualTo("app:1"); - assertThat(env.getPropertySources().contains(OVERRIDES_PROPERTY_SOURCE_NAME)); - assertThat(env.getPropertySources().contains(DEFAULTS_PROPERTY_SOURCE_NAME)); - } - -} diff --git a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/ConditionalOnBusEnabledTests.java b/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/ConditionalOnBusEnabledTests.java deleted file mode 100644 index 2a119c3c..00000000 --- a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/ConditionalOnBusEnabledTests.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import org.junit.After; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import org.springframework.boot.test.util.TestPropertyValues; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Spencer Gibb - */ -public class ConditionalOnBusEnabledTests { - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - private AnnotationConfigApplicationContext context; - - @After - public void tearDown() { - if (this.context != null) { - this.context.close(); - } - } - - @Test - public void busEnabledTrue() { - load(MyBusEnabledConfig.class, ConditionalOnBusEnabled.SPRING_CLOUD_BUS_ENABLED + ":true"); - assertThat(this.context.containsBean("foo")).as("missing bean from @ConditionalOnBusEnabled config").isTrue(); - } - - @Test - public void busEnabledMissing() { - load(MyBusEnabledConfig.class); - assertThat(this.context.containsBean("foo")).as("missing bean from @ConditionalOnBusEnabled config").isTrue(); - } - - @Test - public void busDisabled() { - load(MyBusEnabledConfig.class, ConditionalOnBusEnabled.SPRING_CLOUD_BUS_ENABLED + ":false"); - assertThat(this.context.containsBean("foo")).as("bean exists from disabled @ConditionalOnBusEnabled config") - .isFalse(); - } - - private void load(Class config, String... environment) { - this.context = new AnnotationConfigApplicationContext(); - TestPropertyValues.of(environment).applyTo(this.context); - this.context.register(config); - this.context.refresh(); - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnBusEnabled - protected static class MyBusEnabledConfig { - - @Bean - public String foo() { - return "foo"; - } - - } - -} diff --git a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/PathServiceMatcherTests.java b/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/PathServiceMatcherTests.java deleted file mode 100644 index 30139108..00000000 --- a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/PathServiceMatcherTests.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import java.util.Collections; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; - -import org.springframework.cloud.bus.event.EnvironmentChangeRemoteApplicationEvent; -import org.springframework.util.AntPathMatcher; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Dave Syer - * - */ -public class PathServiceMatcherTests { - - private static final Map EMPTY_MAP = Collections.emptyMap(); - - private ServiceMatcher matcher; - - @Before - public void init() { - initMatcher("one:two:8888"); - } - - private void initMatcher(String id) { - BusProperties properties = new BusProperties(); - properties.setId(id); - DefaultBusPathMatcher pathMatcher = new DefaultBusPathMatcher(new AntPathMatcher(":")); - this.matcher = new PathServiceMatcher(pathMatcher, properties.getId()); - } - - @Test - public void fromSelf() { - assertThat(this.matcher.isFromSelf( - new EnvironmentChangeRemoteApplicationEvent(this, "one:two:8888", "foo:bar:spam", EMPTY_MAP))).isTrue(); - } - - @Test - public void forSelf() { - assertThat(this.matcher.isForSelf( - new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "one:two:8888", EMPTY_MAP))).isTrue(); - } - - @Test - public void forSelfWithWildcard() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "one:two:*", EMPTY_MAP))) - .isTrue(); - } - - @Test - public void forSelfWithGlobalWildcard() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "**", EMPTY_MAP))) - .isTrue(); - } - - @Test - public void forSelfWithWildcardName() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "o*", EMPTY_MAP))) - .isTrue(); - } - - @Test - public void forSelfWithWildcardNameAndProfile() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "o*:t*", EMPTY_MAP))) - .isTrue(); - } - - @Test - public void forSelfWithWildcardString() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "o*", EMPTY_MAP))) - .isTrue(); - } - - @Test - public void notForSelfWithWildCardNameAndMismatchingProfile() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "o*:f*", EMPTY_MAP))) - .isFalse(); - } - - @Test - public void forSelfWithDoubleWildcard() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "one:**", EMPTY_MAP))) - .isTrue(); - } - - @Test - public void forSelfWithNoWildcard() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "one", EMPTY_MAP))) - .isTrue(); - } - - @Test - public void forSelfWithProfileNoWildcard() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "one:two", EMPTY_MAP))) - .isTrue(); - } - - @Test - public void notForSelf() { - assertThat(this.matcher.isForSelf( - new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "one:two:9999", EMPTY_MAP))) - .isFalse(); - } - - @Test - public void notFromSelf() { - assertThat(this.matcher.isFromSelf( - new EnvironmentChangeRemoteApplicationEvent(this, "one:two:9999", "foo:bar:spam", EMPTY_MAP))) - .isFalse(); - } - - /** - * see gh-678 - */ - @Test - public void forSelfWithMultipleProfiles() { - initMatcher("customerportal:dev,cloud:80"); - assertThat(this.matcher.isForSelf( - new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "customerportal:cloud:*", EMPTY_MAP))) - .isTrue(); - } - - /** - * see gh-678 - */ - @Test - public void notForSelfWithMultipleProfiles() { - initMatcher("customerportal:dev,cloud:80"); - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "bar:cloud:*", EMPTY_MAP))) - .isFalse(); - } - - /** - * see gh-678 - */ - @Test - public void notForSelfWithMultipleProfilesDifferentPort() { - initMatcher("customerportal:dev,cloud:80"); - assertThat(this.matcher.isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", - "customerportal:cloud:8008", EMPTY_MAP))).isFalse(); - } - -} diff --git a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/PathServiceMatcherWithConfigNamesTests.java b/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/PathServiceMatcherWithConfigNamesTests.java deleted file mode 100644 index 867658e3..00000000 --- a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/PathServiceMatcherWithConfigNamesTests.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import java.util.Collections; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; - -import org.springframework.cloud.bus.event.EnvironmentChangeRemoteApplicationEvent; -import org.springframework.util.AntPathMatcher; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Stefan Pfeiffer - * - */ -public class PathServiceMatcherWithConfigNamesTests { - - private static final Map EMPTY_MAP = Collections.emptyMap(); - - private ServiceMatcher matcher; - - @Before - public void init() { - initMatcher("otherid:two:8888", new String[] { "one", "three" }); - } - - private void initMatcher(String id, String[] configNames) { - BusProperties properties = new BusProperties(); - properties.setId(id); - DefaultBusPathMatcher pathMatcher = new DefaultBusPathMatcher(new AntPathMatcher(":")); - this.matcher = new PathServiceMatcher(pathMatcher, properties.getId(), configNames); - } - - @Test - public void forSelfWithWildcard() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "one:two:*", EMPTY_MAP))) - .isTrue(); - } - - @Test - public void forSelfWithWildcardAndOtherConfigName() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "three:two:*", EMPTY_MAP))) - .isTrue(); - } - - @Test - public void forSelfWithGlobalWildcard() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "**", EMPTY_MAP))) - .isTrue(); - } - - @Test - public void forSelfWithWildcardName() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "o*", EMPTY_MAP))) - .isTrue(); - } - - @Test - public void forSelfWithWildcardNameAndProfile() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "o*:t*", EMPTY_MAP))) - .isTrue(); - } - - @Test - public void forSelfWithWildcardString() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "o*", EMPTY_MAP))) - .isTrue(); - } - - @Test - public void notForSelfWithWildCardNameAndMismatchingProfile() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "o*:f*", EMPTY_MAP))) - .isFalse(); - } - - @Test - public void forSelfWithDoubleWildcard() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "one:**", EMPTY_MAP))) - .isTrue(); - } - - @Test - public void forSelfWithNoWildcard() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "one", EMPTY_MAP))) - .isTrue(); - } - - @Test - public void forSelfWithProfileNoWildcard() { - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "one:two", EMPTY_MAP))) - .isTrue(); - } - - @Test - public void notForSelf() { - assertThat(this.matcher.isForSelf( - new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "one:two:9999", EMPTY_MAP))) - .isFalse(); - } - - @Test - public void forSelfWithMultipleProfiles() { - initMatcher("customerportal:dev,cloud:80", new String[] { "one", "three" }); - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "one:cloud:*", EMPTY_MAP))) - .isTrue(); - } - - @Test - public void notForSelfWithMultipleProfiles() { - initMatcher("customerportal:dev,cloud:80", new String[] { "one", "three" }); - assertThat(this.matcher - .isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", "bar:cloud:*", EMPTY_MAP))) - .isFalse(); - } - - @Test - public void notForSelfWithMultipleProfilesDifferentPort() { - initMatcher("customerportal:dev,cloud:80", new String[] { "one", "three" }); - assertThat(this.matcher.isForSelf(new EnvironmentChangeRemoteApplicationEvent(this, "foo:bar:spam", - "customerportal:cloud:8008", EMPTY_MAP))).isFalse(); - } - -} diff --git a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/RefreshListenerIntegrationTests.java b/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/RefreshListenerIntegrationTests.java deleted file mode 100644 index f5e9f4b0..00000000 --- a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/RefreshListenerIntegrationTests.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2013-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus; - -import java.util.HashMap; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration; -import org.springframework.context.annotation.Import; -import org.springframework.http.HttpStatus; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -/** - * @author Ryan Baxter - */ -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - classes = RefreshListenerIntegrationTests.MyApp.class, - properties = { "management.endpoints.web.exposure.include=*", "spring.application.name=foobar" }) -public class RefreshListenerIntegrationTests { - - @Autowired - private TestRestTemplate rest; - - @MockBean - private BusBridge busBridge; - - @Test - public void testEndpoint() { - System.out.println(rest.getForObject("/actuator", String.class)); - assertThat(rest.postForEntity("/actuator/busrefresh/demoapp", new HashMap<>(), String.class).getStatusCode()) - .isEqualTo(HttpStatus.NO_CONTENT); - assertThat(rest.postForEntity("/actuator/busrefresh/foobar", new HashMap<>(), String.class).getStatusCode()) - .isEqualTo(HttpStatus.NO_CONTENT); - verify(busBridge, times(2)).send(any()); - } - - @SpringBootApplication - @Import(TestChannelBinderConfiguration.class) - static class MyApp { - - } - -} diff --git a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/endpoint/RefreshBusEndpointTests.java b/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/endpoint/RefreshBusEndpointTests.java deleted file mode 100644 index 4284e8fa..00000000 --- a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/endpoint/RefreshBusEndpointTests.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.endpoint; - -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Dave Syer - */ -public class RefreshBusEndpointTests { - - @Test - public void instanceId() throws Exception { - RefreshBusEndpoint endpoint = new RefreshBusEndpoint(null, "foo", - originalDestination -> () -> originalDestination); - assertThat(endpoint.getInstanceId()).isEqualTo("foo"); - } - -} diff --git a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/event/test/TestRemoteApplicationEvent.java b/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/event/test/TestRemoteApplicationEvent.java deleted file mode 100644 index e3ab60c2..00000000 --- a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/event/test/TestRemoteApplicationEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.event.test; - -import org.springframework.cloud.bus.event.RemoteApplicationEvent; - -@SuppressWarnings("serial") -public class TestRemoteApplicationEvent extends RemoteApplicationEvent { - - @SuppressWarnings("unused") - private TestRemoteApplicationEvent() { - } - - protected TestRemoteApplicationEvent(Object source, String originService, String destinationService) { - super(source, originService, destinationService); - } - - protected TestRemoteApplicationEvent(Object source, String originService) { - super(source, originService); - } - -} diff --git a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/event/test/TypedRemoteApplicationEvent.java b/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/event/test/TypedRemoteApplicationEvent.java deleted file mode 100644 index 63d72e32..00000000 --- a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/event/test/TypedRemoteApplicationEvent.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.event.test; - -import com.fasterxml.jackson.annotation.JsonTypeName; - -import org.springframework.cloud.bus.event.RemoteApplicationEvent; - -@SuppressWarnings("serial") -@JsonTypeName("typed") -public class TypedRemoteApplicationEvent extends RemoteApplicationEvent { - - @SuppressWarnings("unused") - private TypedRemoteApplicationEvent() { - } - - protected TypedRemoteApplicationEvent(Object source, String originService, String destinationService) { - super(source, originService, destinationService); - } - - protected TypedRemoteApplicationEvent(Object source, String originService) { - super(source, originService); - } - -} diff --git a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/jackson/RemoteApplicationEventScanTests.java b/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/jackson/RemoteApplicationEventScanTests.java deleted file mode 100644 index 8aa68920..00000000 --- a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/jackson/RemoteApplicationEventScanTests.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.jackson; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedHashSet; -import java.util.List; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.jsontype.NamedType; -import org.junit.Test; -import test.foo.bar.FooBarTestRemoteApplicationEvent; - -import org.springframework.boot.Banner; -import org.springframework.boot.WebApplicationType; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.cloud.bus.event.AckRemoteApplicationEvent; -import org.springframework.cloud.bus.event.EnvironmentChangeRemoteApplicationEvent; -import org.springframework.cloud.bus.event.RefreshRemoteApplicationEvent; -import org.springframework.cloud.bus.event.UnknownRemoteApplicationEvent; -import org.springframework.cloud.bus.event.test.TestRemoteApplicationEvent; -import org.springframework.cloud.bus.event.test.TypedRemoteApplicationEvent; -import org.springframework.cloud.bus.jackson.SubtypeModuleTests.AnotherRemoteApplicationEvent; -import org.springframework.cloud.bus.jackson.SubtypeModuleTests.MyRemoteApplicationEvent; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.test.util.ReflectionTestUtils; - -import static org.assertj.core.api.Assertions.assertThat; - -public class RemoteApplicationEventScanTests { - - private BusJacksonMessageConverter converter; - - @Test - public void importingClassMetadataPackageRegistered() { - this.converter = createTestContext(DefaultConfig.class).getBean(BusJacksonMessageConverter.class); - - assertConverterBeanAfterPropertiesSet( - new String[] { "org.springframework.cloud.bus.jackson", "org.springframework.cloud.bus.event" }, - AnotherRemoteApplicationEvent.class, MyRemoteApplicationEvent.class, TestRemoteApplicationEvent.class, - TypedRemoteApplicationEvent.class); - } - - @Test - public void annotationValuePackagesRegistered() { - this.converter = createTestContext(ValueConfig.class).getBean(BusJacksonMessageConverter.class); - - assertConverterBeanAfterPropertiesSet( - new String[] { "test.foo.bar", "com.acme", "org.springframework.cloud.bus.event" }, - FooBarTestRemoteApplicationEvent.class, TestRemoteApplicationEvent.class, - TypedRemoteApplicationEvent.class); - } - - @Test - public void annotationValueBasePackagesRegistered() { - this.converter = createTestContext(BasePackagesConfig.class).getBean(BusJacksonMessageConverter.class); - - assertConverterBeanAfterPropertiesSet( - new String[] { "test.foo.bar", "fizz.buzz", "com.acme", "org.springframework.cloud.bus.event" }, - FooBarTestRemoteApplicationEvent.class, TestRemoteApplicationEvent.class, - TypedRemoteApplicationEvent.class); - } - - @Test - public void annotationBasePackagesRegistered() { - this.converter = createTestContext(BasePackageClassesConfig.class).getBean(BusJacksonMessageConverter.class); - - assertConverterBeanAfterPropertiesSet( - new String[] { "org.springframework.cloud.bus.event.test", "org.springframework.cloud.bus.event" }, - TestRemoteApplicationEvent.class, TypedRemoteApplicationEvent.class); - } - - private ConfigurableApplicationContext createTestContext(Class configuration) { - return new SpringApplicationBuilder(configuration).web(WebApplicationType.NONE).bannerMode(Banner.Mode.OFF) - .run(); - } - - private void assertConverterBeanAfterPropertiesSet(final String[] expectedPackageToScan, - final Class... expectedRegisterdClasses) { - final ObjectMapper mapper = (ObjectMapper) ReflectionTestUtils.getField(this.converter, "mapper"); - - @SuppressWarnings("unchecked") - final LinkedHashSet registeredSubtypes = (LinkedHashSet) ReflectionTestUtils - .getField(mapper.getSubtypeResolver(), "_registeredSubtypes"); - - final List> expectedRegisterdClassesAsList = new ArrayList<>(Arrays.asList(expectedRegisterdClasses)); - addStandardSpringCloudEventBusEvents(expectedRegisterdClassesAsList); - - assertThat(expectedRegisterdClassesAsList.size() == registeredSubtypes.size()) - .as("Wrong RemoteApplicationEvent classes are registerd in object mapper").isTrue(); - - for (final NamedType namedType : registeredSubtypes) { - assertThat(expectedRegisterdClassesAsList.contains(namedType.getType())).isTrue(); - } - - assertThat(Arrays.asList((String[]) ReflectionTestUtils.getField(this.converter, "packagesToScan"))) - .as("RemoteApplicationEvent packages not registered").contains(expectedPackageToScan); - - } - - private void addStandardSpringCloudEventBusEvents(final List> expectedRegisterdClassesAsList) { - expectedRegisterdClassesAsList.add(AckRemoteApplicationEvent.class); - expectedRegisterdClassesAsList.add(EnvironmentChangeRemoteApplicationEvent.class); - expectedRegisterdClassesAsList.add(RefreshRemoteApplicationEvent.class); - expectedRegisterdClassesAsList.add(UnknownRemoteApplicationEvent.class); - } - - @Configuration(proxyBeanMethods = false) - @RemoteApplicationEventScan - static class DefaultConfig { - - } - - @Configuration(proxyBeanMethods = false) - @RemoteApplicationEventScan({ "com.acme", "test.foo.bar" }) - static class ValueConfig { - - } - - @Configuration(proxyBeanMethods = false) - @Import(ExtraBasePackagesConfig.class) - @RemoteApplicationEventScan(basePackages = { "com.acme", "test.foo.bar" }) - static class BasePackagesConfig { - - } - - @Configuration(proxyBeanMethods = false) - @RemoteApplicationEventScan(basePackages = { "fizz.buzz" }) - static class ExtraBasePackagesConfig { - - } - - @Configuration(proxyBeanMethods = false) - @RemoteApplicationEventScan(basePackageClasses = TestRemoteApplicationEvent.class) - static class BasePackageClassesConfig { - - } - -} diff --git a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/jackson/SerializationTests.java b/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/jackson/SerializationTests.java deleted file mode 100644 index d1b55c05..00000000 --- a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/jackson/SerializationTests.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.jackson; - -import java.util.Collections; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; - -import org.springframework.cloud.bus.event.EnvironmentChangeRemoteApplicationEvent; -import org.springframework.cloud.bus.event.RefreshRemoteApplicationEvent; -import org.springframework.cloud.bus.event.RemoteApplicationEvent; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Dave Syer - * - */ -public class SerializationTests { - - ObjectMapper mapper = new ObjectMapper(); - - @Test - public void vanillaDeserialize() throws Exception { - this.mapper.registerModule( - new SubtypeModule(RefreshRemoteApplicationEvent.class, EnvironmentChangeRemoteApplicationEvent.class)); - EnvironmentChangeRemoteApplicationEvent source = new EnvironmentChangeRemoteApplicationEvent(this, "foo", "bar", - Collections.emptyMap()); - String value = this.mapper.writeValueAsString(source); - RemoteApplicationEvent event = this.mapper.readValue(value, RemoteApplicationEvent.class); - assertThat(event instanceof EnvironmentChangeRemoteApplicationEvent).isTrue(); - assertThat(event.getId()).isNotNull(); - assertThat(event.getId().equals(source.getId())).isTrue(); - } - - @Test - public void deserializeOldValueWithNoId() throws Exception { - this.mapper.registerModule( - new SubtypeModule(RefreshRemoteApplicationEvent.class, EnvironmentChangeRemoteApplicationEvent.class)); - EnvironmentChangeRemoteApplicationEvent source = new EnvironmentChangeRemoteApplicationEvent(this, "foo", "bar", - Collections.emptyMap()); - String value = this.mapper.writeValueAsString(source); - value = value.replaceAll(",\"id\":\"[a-f0-9-]*\"", ""); - RemoteApplicationEvent event = this.mapper.readValue(value, RemoteApplicationEvent.class); - assertThat(event instanceof EnvironmentChangeRemoteApplicationEvent).isTrue(); - assertThat(event.getId()).isNotNull(); - assertThat(event.getId().equals(source.getId())).isFalse(); - } - -} diff --git a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/jackson/SubtypeModuleTests.java b/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/jackson/SubtypeModuleTests.java deleted file mode 100644 index cd1f670e..00000000 --- a/spring-cloud-bus/src/test/java/org/springframework/cloud/bus/jackson/SubtypeModuleTests.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.bus.jackson; - -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.PropertyNamingStrategy; -import org.junit.Test; - -import org.springframework.cloud.bus.event.AckRemoteApplicationEvent; -import org.springframework.cloud.bus.event.RemoteApplicationEvent; -import org.springframework.cloud.bus.event.UnknownRemoteApplicationEvent; -import org.springframework.cloud.bus.event.test.TestRemoteApplicationEvent; -import org.springframework.cloud.bus.event.test.TypedRemoteApplicationEvent; -import org.springframework.messaging.support.MessageBuilder; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Spencer Gibb - * @author Stefan Pfeiffer - */ -public class SubtypeModuleTests { - - @Test - public void testDeserializeSubclass() throws Exception { - ObjectMapper mapper = new ObjectMapper(); - mapper.registerModule(new SubtypeModule(MyRemoteApplicationEvent.class)); - - RemoteApplicationEvent event = mapper.readValue( - "{\"type\":\"my\", \"destinationService\":\"myservice\", \"originService\":\"myorigin\"}", - RemoteApplicationEvent.class); - assertThat(event instanceof MyRemoteApplicationEvent).as("event is wrong type").isTrue(); - MyRemoteApplicationEvent myEvent = MyRemoteApplicationEvent.class.cast(event); - assertThat(myEvent.getOriginService()).as("originService was wrong").isEqualTo("myorigin"); - assertThat(myEvent.getDestinationService()).as("destinationService was wrong").isEqualTo("myservice"); - } - - @Test - public void testDeserializeWhenTypeIsKnown() throws Exception { - ObjectMapper mapper = new ObjectMapper(); - - RemoteApplicationEvent event = mapper.readValue("{\"type\":\"another\"}", AnotherRemoteApplicationEvent.class); - assertThat(event instanceof AnotherRemoteApplicationEvent).as("event is wrong type").isTrue(); - } - - @Test - public void testDeserializeCustomizedObjectMapper() throws Exception { - ObjectMapper mapper = new ObjectMapper(); - mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); - - BusJacksonMessageConverter converter = new BusJacksonMessageConverter(mapper); - converter.afterPropertiesSet(); - Object event = converter.fromMessage(MessageBuilder - .withPayload("{\"type\":\"TestRemoteApplicationEvent\", \"origin_service\":\"myorigin\"}").build(), - RemoteApplicationEvent.class); - assertThat(event).isNotNull().isInstanceOf(TestRemoteApplicationEvent.class); - assertThat(TestRemoteApplicationEvent.class.cast(event).getOriginService()).isEqualTo("myorigin"); - } - - @Test - public void testDeserializeWithMessageConverter() throws Exception { - BusJacksonMessageConverter converter = new BusJacksonMessageConverter(null); - converter.afterPropertiesSet(); - Object event = converter.fromMessage( - MessageBuilder.withPayload("{\"type\":\"TestRemoteApplicationEvent\"}").build(), - RemoteApplicationEvent.class); - assertThat(event instanceof TestRemoteApplicationEvent).as("event is wrong type").isTrue(); - } - - @Test - public void testDeserializeUnknownTypeWithMessageConverter() throws Exception { - BusJacksonMessageConverter converter = new BusJacksonMessageConverter(null); - converter.afterPropertiesSet(); - Object event = converter.fromMessage( - MessageBuilder.withPayload("{\"type\":\"NotDefinedTestRemoteApplicationEvent\"}").build(), - RemoteApplicationEvent.class); - assertThat(event instanceof UnknownRemoteApplicationEvent).as("event is wrong type").isTrue(); - assertThat(((UnknownRemoteApplicationEvent) event).getTypeInfo()).as("type information is wrong") - .isEqualTo("NotDefinedTestRemoteApplicationEvent"); - assertThat(((UnknownRemoteApplicationEvent) event).getPayloadAsString()).as("payload is wrong") - .isEqualTo("{\"type\":\"NotDefinedTestRemoteApplicationEvent\"}"); - } - - @Test - public void testDeserializeJsonTypeWithMessageConverter() throws Exception { - BusJacksonMessageConverter converter = new BusJacksonMessageConverter(null); - converter.afterPropertiesSet(); - Object event = converter.fromMessage(MessageBuilder.withPayload("{\"type\":\"typed\"}").build(), - RemoteApplicationEvent.class); - assertThat(event instanceof TypedRemoteApplicationEvent).as("event is wrong type").isTrue(); - } - - /** - * see https://github.com/spring-cloud/spring-cloud-bus/issues/74 - */ - @Test - public void testDeserializeAckRemoteApplicationEventWithKnownType() throws Exception { - BusJacksonMessageConverter converter = new BusJacksonMessageConverter(null); - converter.afterPropertiesSet(); - Object event = converter - .fromMessage(MessageBuilder - .withPayload("{\"type\":\"AckRemoteApplicationEvent\", " - + "\"event\":\"org.springframework.cloud.bus.event.test.TestRemoteApplicationEvent\"}") - .build(), RemoteApplicationEvent.class); - assertThat(event instanceof AckRemoteApplicationEvent).as("event is no ack").isTrue(); - AckRemoteApplicationEvent ackEvent = AckRemoteApplicationEvent.class.cast(event); - assertThat(ackEvent.getEvent()).as("inner ack event has wrong type") - .isEqualTo(TestRemoteApplicationEvent.class); - } - - /** - * see https://github.com/spring-cloud/spring-cloud-bus/issues/74 - */ - @Test - public void testDeserializeAckRemoteApplicationEventWithUnknownType() throws Exception { - BusJacksonMessageConverter converter = new BusJacksonMessageConverter(null); - converter.afterPropertiesSet(); - Object event = converter.fromMessage(MessageBuilder - .withPayload( - "{\"type\":\"AckRemoteApplicationEvent\", \"event\":\"foo.bar.TestRemoteApplicationEvent\"}") - .build(), RemoteApplicationEvent.class); - assertThat(event instanceof AckRemoteApplicationEvent).as("event is no ack").isTrue(); - AckRemoteApplicationEvent ackEvent = AckRemoteApplicationEvent.class.cast(event); - assertThat(ackEvent.getEvent()).as("inner ack event has wrong type") - .isEqualTo(UnknownRemoteApplicationEvent.class); - } - - @SuppressWarnings("serial") - @JsonTypeName("my") - public static class MyRemoteApplicationEvent extends RemoteApplicationEvent { - - @SuppressWarnings("unused") - private MyRemoteApplicationEvent() { - } - - protected MyRemoteApplicationEvent(Object source, String originService, String destinationService) { - super(source, originService, destinationService); - } - - protected MyRemoteApplicationEvent(Object source, String originService) { - super(source, originService); - } - - } - - @SuppressWarnings("serial") - @JsonTypeName("another") - public static class AnotherRemoteApplicationEvent extends RemoteApplicationEvent { - - @SuppressWarnings("unused") - private AnotherRemoteApplicationEvent() { - } - - protected AnotherRemoteApplicationEvent(Object source, String originService, String destinationService) { - super(source, originService, destinationService); - } - - protected AnotherRemoteApplicationEvent(Object source, String originService) { - super(source, originService); - } - - } - -} diff --git a/spring-cloud-bus/src/test/java/test/foo/bar/FooBarTestRemoteApplicationEvent.java b/spring-cloud-bus/src/test/java/test/foo/bar/FooBarTestRemoteApplicationEvent.java deleted file mode 100644 index 1e6cdf67..00000000 --- a/spring-cloud-bus/src/test/java/test/foo/bar/FooBarTestRemoteApplicationEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package test.foo.bar; - -import org.springframework.cloud.bus.event.RemoteApplicationEvent; - -@SuppressWarnings("serial") -public class FooBarTestRemoteApplicationEvent extends RemoteApplicationEvent { - - @SuppressWarnings("unused") - private FooBarTestRemoteApplicationEvent() { - } - - protected FooBarTestRemoteApplicationEvent(final Object source, final String originService, - final String destinationService) { - super(source, originService, destinationService); - } - - protected FooBarTestRemoteApplicationEvent(final Object source, final String originService) { - super(source, originService); - } - -} diff --git a/spring-cloud-bus/src/test/resources/application.properties b/spring-cloud-bus/src/test/resources/application.properties deleted file mode 100644 index c1902d29..00000000 --- a/spring-cloud-bus/src/test/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -spring.main.web-environment:false diff --git a/spring-cloud-starter-bus-amqp/.flattened-pom.xml b/spring-cloud-starter-bus-amqp/.flattened-pom.xml new file mode 100644 index 00000000..20d421d4 --- /dev/null +++ b/spring-cloud-starter-bus-amqp/.flattened-pom.xml @@ -0,0 +1,113 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-bus-parent + 3.1.2 + .. + + org.springframework.cloud + spring-cloud-starter-bus-amqp + 3.1.2 + spring-cloud-starter-bus-amqp + Spring Cloud Starter + https://projects.spring.io/spring-cloud + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 the original author or authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. + + See the License for the specific language governing permissions and + limitations under the License. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-bus.git/spring-cloud-starter-bus-amqp + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-bus.git/spring-cloud-starter-bus-amqp + https://github.com/spring-cloud/spring-cloud-bus/spring-cloud-starter-bus-amqp + + + + org.springframework.cloud + spring-cloud-starter-stream-rabbit + 3.2.4 + compile + + + org.springframework.cloud + spring-cloud-bus + 3.1.2 + compile + + + diff --git a/spring-cloud-starter-bus-amqp/pom.xml b/spring-cloud-starter-bus-amqp/pom.xml deleted file mode 100644 index aa6e2c86..00000000 --- a/spring-cloud-starter-bus-amqp/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - 4.0.0 - - org.springframework.cloud - spring-cloud-bus-parent - 4.1.0-SNAPSHOT - .. - - spring-cloud-starter-bus-amqp - spring-cloud-starter-bus-amqp - Spring Cloud Starter - https://projects.spring.io/spring-cloud - - Pivotal Software, Inc. - https://www.spring.io - - - ${basedir}/../.. - - - - org.springframework.cloud - spring-cloud-starter-stream-rabbit - - - org.springframework.cloud - spring-cloud-bus - - - diff --git a/spring-cloud-starter-bus-kafka/.flattened-pom.xml b/spring-cloud-starter-bus-kafka/.flattened-pom.xml new file mode 100644 index 00000000..a9bc636a --- /dev/null +++ b/spring-cloud-starter-bus-kafka/.flattened-pom.xml @@ -0,0 +1,113 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-bus-parent + 3.1.2 + .. + + org.springframework.cloud + spring-cloud-starter-bus-kafka + 3.1.2 + spring-cloud-starter-bus-kafka + Spring Cloud Starter + https://projects.spring.io/spring-cloud + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 the original author or authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. + + See the License for the specific language governing permissions and + limitations under the License. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-bus.git/spring-cloud-starter-bus-kafka + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-bus.git/spring-cloud-starter-bus-kafka + https://github.com/spring-cloud/spring-cloud-bus/spring-cloud-starter-bus-kafka + + + + org.springframework.cloud + spring-cloud-starter-stream-kafka + 3.2.4 + compile + + + org.springframework.cloud + spring-cloud-bus + 3.1.2 + compile + + + diff --git a/spring-cloud-starter-bus-kafka/pom.xml b/spring-cloud-starter-bus-kafka/pom.xml deleted file mode 100644 index 2ecf47ee..00000000 --- a/spring-cloud-starter-bus-kafka/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - 4.0.0 - - org.springframework.cloud - spring-cloud-bus-parent - 4.1.0-SNAPSHOT - .. - - spring-cloud-starter-bus-kafka - spring-cloud-starter-bus-kafka - Spring Cloud Starter - https://projects.spring.io/spring-cloud - - Pivotal Software, Inc. - https://www.spring.io - - - ${basedir}/../.. - - - - org.springframework.cloud - spring-cloud-starter-stream-kafka - - - org.springframework.cloud - spring-cloud-bus - - - diff --git a/spring-cloud-starter-bus-stream/.flattened-pom.xml b/spring-cloud-starter-bus-stream/.flattened-pom.xml new file mode 100644 index 00000000..c8351fa8 --- /dev/null +++ b/spring-cloud-starter-bus-stream/.flattened-pom.xml @@ -0,0 +1,113 @@ + + + 4.0.0 + + org.springframework.cloud + spring-cloud-bus-parent + 3.1.2 + .. + + org.springframework.cloud + spring-cloud-starter-bus-stream + 3.1.2 + spring-cloud-starter-bus-stream + Spring Cloud Starter + https://projects.spring.io/spring-cloud + + Pivotal Software, Inc. + https://www.spring.io + + + + Apache License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + Copyright 2014-2021 the original author or authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. + + See the License for the specific language governing permissions and + limitations under the License. + + + + + dsyer + Dave Syer + dsyer at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + sgibb + Spencer Gibb + sgibb at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + lead + + + + mgrzejszczak + Marcin Grzejszczak + mgrzejszczak at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + rbaxter + Ryan Baxter + rbaxter at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + omaciaszeksharma + Olga Maciaszek-Sharma + omaciaszeksharma at pivotal.io + Pivotal Software, Inc. + https://www.spring.io + + developer + + + + + scm:git:git://github.com/spring-cloud/spring-cloud-bus.git/spring-cloud-starter-bus-stream + scm:git:ssh://git@github.com/spring-cloud/spring-cloud-bus.git/spring-cloud-starter-bus-stream + https://github.com/spring-cloud/spring-cloud-bus/spring-cloud-starter-bus-stream + + + + org.springframework.cloud + spring-cloud-stream + 3.2.4 + compile + + + org.springframework.cloud + spring-cloud-bus + 3.1.2 + compile + + + diff --git a/spring-cloud-starter-bus-stream/pom.xml b/spring-cloud-starter-bus-stream/pom.xml deleted file mode 100644 index b0f21d07..00000000 --- a/spring-cloud-starter-bus-stream/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - 4.0.0 - - org.springframework.cloud - spring-cloud-bus-parent - 4.1.0-SNAPSHOT - .. - - spring-cloud-starter-bus-stream - spring-cloud-starter-bus-stream - Spring Cloud Starter - https://projects.spring.io/spring-cloud - - Pivotal Software, Inc. - https://www.spring.io - - - ${basedir}/../.. - - - - org.springframework.cloud - spring-cloud-stream - - - org.springframework.cloud - spring-cloud-bus - - - diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml deleted file mode 100644 index 9f9f71a8..00000000 --- a/src/checkstyle/checkstyle-suppressions.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/supplemental-ui/partials/nav-search.hbs b/supplemental-ui/partials/nav-search.hbs new file mode 100644 index 00000000..5e379552 --- /dev/null +++ b/supplemental-ui/partials/nav-search.hbs @@ -0,0 +1,11 @@ +{{#if env.ALGOLIA_API_KEY}} + +{{/if}} diff --git a/supplemental-ui/partials/search.hbs b/supplemental-ui/partials/search.hbs new file mode 100644 index 00000000..384e505f --- /dev/null +++ b/supplemental-ui/partials/search.hbs @@ -0,0 +1,27 @@ + +{{#if env.ALGOLIA_API_KEY}} + + + + + + + + +{{/if}}