├── .github └── workflows │ ├── build.yaml │ ├── milestone.yaml │ └── release.yaml ├── .gitignore ├── .mvn ├── jvm.config └── wrapper │ └── maven-wrapper.properties ├── Jenkinsfile ├── LICENSE.txt ├── README.markdown ├── core ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── springframework │ │ └── plugin │ │ └── core │ │ ├── OrderAwarePluginRegistry.java │ │ ├── Plugin.java │ │ ├── PluginRegistry.java │ │ ├── PluginRegistrySupport.java │ │ ├── SimplePluginRegistry.java │ │ ├── config │ │ ├── EnablePluginRegistries.java │ │ ├── PluginRegistriesBeanDefinitionRegistrar.java │ │ └── package-info.java │ │ ├── package-info.java │ │ └── support │ │ ├── PluginRegistryFactoryBean.java │ │ └── package-info.java │ └── test │ ├── java │ └── org │ │ └── springframework │ │ └── plugin │ │ └── core │ │ ├── OrderAwarePluginRegistryUnitTest.java │ │ ├── SamplePlugin.java │ │ ├── SamplePluginHost.java │ │ ├── SamplePluginImplementation.java │ │ ├── SimplePluginRegistryUnitTest.java │ │ ├── config │ │ ├── EnablePluginRegistriesIntegrationTest.java │ │ └── PluginConfigurationIntegrationTest.java │ │ └── support │ │ └── OrderAwarePluginRegistryIntegrationTest.java │ └── resources │ └── logback.xml ├── etc └── mappings.txt ├── mvnw ├── mvnw.cmd ├── pom.xml ├── settings.xml └── src └── main └── resources ├── license.txt └── notice.txt /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | name: CI Build 2 | 3 | on: 4 | push: 5 | branches: [ main, 4.0.x ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | build: 11 | name: Build project 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | 16 | - name: Check out sources 17 | uses: actions/checkout@v4 18 | 19 | - name: Set up JDK 23 20 | uses: actions/setup-java@v4 21 | with: 22 | distribution: 'temurin' 23 | java-version: 23 24 | cache: 'maven' 25 | 26 | - name: Build and deploy to Artifactory 27 | env: 28 | ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} 29 | ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} 30 | run: ./mvnw -B clean deploy -Pci,artifactory,nullaway 31 | -------------------------------------------------------------------------------- /.github/workflows/milestone.yaml: -------------------------------------------------------------------------------- 1 | name: Release Milestones 2 | 3 | on: 4 | push: 5 | branches: [ release/milestone ] 6 | 7 | jobs: 8 | build: 9 | name: Release project 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | 14 | - name: Check out sources 15 | uses: actions/checkout@v2 16 | 17 | - name: Set up JDK 17 18 | uses: actions/setup-java@v2 19 | with: 20 | distribution: 'temurin' 21 | java-version: 17 22 | cache: 'maven' 23 | 24 | - name: Build with Maven 25 | run: ./mvnw -B clean verify 26 | 27 | - name: Deploy to Artifactory 28 | env: 29 | ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} 30 | ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} 31 | run: ./mvnw -B clean deploy -Pci,artifactory 32 | -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | name: Release to Maven Central 2 | 3 | on: 4 | push: 5 | branches: [ release/release ] 6 | 7 | jobs: 8 | build: 9 | name: Release project 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | 14 | - name: Check out sources 15 | uses: actions/checkout@v4 16 | 17 | - name: Set up JDK 17 18 | uses: actions/setup-java@v4 19 | with: 20 | distribution: 'temurin' 21 | java-version: 17 22 | cache: 'maven' 23 | 24 | - name: Install GPG key 25 | run: | 26 | echo "${{ secrets.GPG_PRIVATE_KEY }}" > gpg.asc 27 | echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --batch --yes --passphrase-fd 0 --import gpg.asc 28 | 29 | - name: Release to Sonatype OSSRH 30 | env: 31 | SONATYPE_USER: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }} 32 | SONATYPE_PASSWORD: ${{ secrets.OSSRH_S01_TOKEN_PASSWORD }} 33 | GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} 34 | run: | 35 | ./mvnw -B clean install -DskipTests 36 | ./mvnw -B clean deploy -Pci,sonatype -s settings.xml 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .project 3 | .settings/ 4 | .springBeans 5 | target/ 6 | .idea 7 | *.iml 8 | .flattened-pom.xml 9 | -------------------------------------------------------------------------------- /.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED 2 | --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED 3 | --add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED 4 | --add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED 5 | --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED 6 | --add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED 7 | --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED 8 | --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED 9 | --add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED 10 | --add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED 11 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent none 3 | 4 | triggers { 5 | pollSCM 'H/10 * * * *' 6 | } 7 | 8 | options { 9 | disableConcurrentBuilds() 10 | buildDiscarder(logRotator(numToKeepStr: '14')) 11 | } 12 | 13 | stages { 14 | stage("test: baseline (JDK 17)") { 15 | agent { 16 | docker { 17 | image 'openjdk:17' 18 | args '-v $HOME/.m2:/tmp/jenkins-home/.m2' 19 | } 20 | } 21 | options { timeout(time: 30, unit: 'MINUTES') } 22 | steps { 23 | sh 'rm -rf ?' 24 | sh 'PROFILE=none ci/test.sh' 25 | } 26 | } 27 | 28 | stage('Deploy to Artifactory') { 29 | agent { 30 | docker { 31 | image 'openjdk:17' 32 | args '-v $HOME/.m2:/tmp/jenkins-home/.m2' 33 | } 34 | } 35 | options { timeout(time: 20, unit: 'MINUTES') } 36 | 37 | environment { 38 | ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c') 39 | } 40 | 41 | steps { 42 | script { 43 | sh 'rm -rf ?' 44 | 45 | // Warm up this plugin quietly before using it. 46 | sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version' 47 | 48 | // Extract project's version number 49 | PROJECT_VERSION = sh( 50 | script: 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -o | grep -v INFO', 51 | returnStdout: true 52 | ).trim() 53 | 54 | RELEASE_TYPE = 'milestone' // .RC? or .M? 55 | 56 | if (PROJECT_VERSION.endsWith('SNAPSHOT')) { 57 | RELEASE_TYPE = 'snapshot' 58 | } else if (PROJECT_VERSION.endsWith('RELEASE')) { 59 | RELEASE_TYPE = 'release' 60 | } 61 | 62 | // Capture build output... 63 | OUTPUT = sh( 64 | script: "PROFILE=ci,${RELEASE_TYPE} ci/build.sh", 65 | returnStdout: true 66 | ).trim() 67 | 68 | echo "$OUTPUT" 69 | 70 | // ...to extract artifactory build info 71 | build_info_path = OUTPUT.split('\n') 72 | .find { it.contains('Artifactory Build Info Recorder') } 73 | .split('Saving Build Info to ')[1] 74 | .trim()[1..-2] 75 | 76 | // Stash the JSON build info to support promotion to bintray 77 | dir(build_info_path + '/..') { 78 | stash name: 'build_info', includes: "*.json" 79 | } 80 | } 81 | } 82 | } 83 | stage('Promote to Bintray') { 84 | when { 85 | branch 'release' 86 | } 87 | agent { 88 | docker { 89 | image 'openjdk:17' 90 | args '-v $HOME/.m2:/tmp/jenkins-home/.m2' 91 | } 92 | } 93 | options { timeout(time: 20, unit: 'MINUTES') } 94 | 95 | environment { 96 | ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c') 97 | } 98 | 99 | steps { 100 | script { 101 | sh 'rm -rf ?' 102 | 103 | // Warm up this plugin quietly before using it. 104 | sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version' 105 | 106 | PROJECT_VERSION = sh( 107 | script: 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -o | grep -v INFO', 108 | returnStdout: true 109 | ).trim() 110 | 111 | if (PROJECT_VERSION.endsWith('RELEASE')) { 112 | unstash name: 'build_info' 113 | sh "ci/promote-to-bintray.sh" 114 | } else { 115 | echo "${PROJECT_VERSION} is not a candidate for promotion to Bintray." 116 | } 117 | } 118 | } 119 | } 120 | stage('Sync to Maven Central') { 121 | when { 122 | branch 'release' 123 | } 124 | agent { 125 | docker { 126 | image 'openjdk:17' 127 | args '-v $HOME/.m2:/tmp/jenkins-home/.m2' 128 | } 129 | } 130 | options { timeout(time: 20, unit: 'MINUTES') } 131 | 132 | environment { 133 | BINTRAY = credentials('Bintray-spring-operator') 134 | SONATYPE = credentials('oss-token') 135 | } 136 | 137 | steps { 138 | script { 139 | sh 'rm -rf ?' 140 | 141 | // Warm up this plugin quietly before using it. 142 | sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version' 143 | 144 | PROJECT_VERSION = sh( 145 | script: 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -o | grep -v INFO', 146 | returnStdout: true 147 | ).trim() 148 | 149 | if (PROJECT_VERSION.endsWith('RELEASE')) { 150 | unstash name: 'build_info' 151 | sh "ci/sync-to-maven-central.sh" 152 | } else { 153 | echo "${PROJECT_VERSION} is not a candidate for syncing to Maven Central." 154 | } 155 | } 156 | } 157 | } 158 | } 159 | 160 | post { 161 | changed { 162 | script { 163 | slackSend( 164 | color: (currentBuild.currentResult == 'SUCCESS') ? 'good' : 'danger', 165 | channel: '#spring-hateoas', 166 | message: "${currentBuild.fullDisplayName} - `${currentBuild.currentResult}`\n${env.BUILD_URL}") 167 | emailext( 168 | subject: "[${currentBuild.fullDisplayName}] ${currentBuild.currentResult}", 169 | mimeType: 'text/html', 170 | recipientProviders: [[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider']], 171 | body: "${currentBuild.fullDisplayName} is reported as ${currentBuild.currentResult}") 172 | } 173 | } 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | https://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | https://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | ======================================================================= 204 | 205 | To the extent any open source subcomponents are licensed under the EPL and/or other 206 | similar licenses that require the source code and/or modifications to 207 | source code to be made available (as would be noted above), you may obtain a 208 | copy of the source code corresponding to the binaries for such open source 209 | components and modifications thereto, if any, (the "Source Files"), by 210 | downloading the Source Files from https://www.springsource.org/download, 211 | or by sending a request, with your name and address to: VMware, Inc., 3401 Hillview 212 | Avenue, Palo Alto, CA 94304, United States of America or email info@vmware.com. All 213 | such requests should clearly specify: OPEN SOURCE FILES REQUEST, Attention General 214 | Counsel. VMware shall mail a copy of the Source Files to you on a CD or equivalent 215 | physical medium. This offer to obtain a copy of the Source Files is valid for three 216 | years from the date you acquired this Software product. 217 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | # The smallest plugin system ever 2 | 3 | ## Preface 4 | 5 | ### Introduction 6 | 7 | Building extensible architectures nowadays is a core principle to create maintainable applications. This is why fully fledged plugin environments like *OSGi* are so popular these days. Unfortunately the introduction of *OSGi* introduces a lot of complexity to projects. 8 | 9 | Spring Plugin provides a more pragmatic approach to plugin development by providing the core flexibility of having plugin implementations extending a core system's functionality but of course not delivering core OSGi features like dynamic class loading or runtime installation and deployment of plugins. Although Spring Plugin thus is not nearly as powerful as OSGi, it serves a poor man's requirements to build a modular 10 | extensible application. 11 | 12 | ### Context 13 | 14 | - You want to build an extensible architecture minimizing overhead as much as possible 15 | - You cannot use OSGi as fully fledged plugin architecture for whatever reasons 16 | - You want to express extensibility by providing dedicated plugin interfaces 17 | - You want to extend the core system by simply providing an implementation of the plugin interface bundled in a JAR file and available in the classpath 18 | - (You use Spring in your application) 19 | 20 | The last point actually is not essential although Spring Plugin gains a 21 | lot of momentum in collaborative use with Spring. 22 | 23 | ### Technologies 24 | 25 | #### Spring 26 | 27 | Spring is the de-facto standard application framework for Java applications. Its consistent programming model, easy configuration and wide support for all kinds of third party libraries makes it the first class citizen of application frameworks. Spring Plugin tightly integrates into Spring's component model and extends the core container 28 | with some custom functionality. 29 | 30 | ## Core 31 | 32 | ### Introduction 33 | 34 | Host system provides a plugin interface providers have to implement. 35 | Core system is build to hold a container of instances of this interface 36 | and works with them. 37 | 38 | **Example 1.1. Basic example of plugin interface and host** 39 | 40 | ```java 41 | /** 42 | * Interface contract for the providers to be implemented. 43 | */ 44 | public interface MyPluginInterface { 45 | public void bar(); 46 | } 47 | 48 | 49 | /** 50 | * A host application class working with instances of the plugin 51 | * interface. 52 | */ 53 | public class HostImpl implements Host { 54 | 55 | private final List plugins; 56 | 57 | public HostImpl(List plugins) { 58 | Assert.notNull(plugins); 59 | this.plugins = plugins; 60 | } 61 | 62 | /** 63 | * Some business method actually working with the given plugins. 64 | */ 65 | public void someBusinessMethod() { 66 | for (MyPluginInterface plugin : plugins) { 67 | plugin.bar(); 68 | } 69 | } 70 | } 71 | ``` 72 | 73 | This is the way you would typically construct a host component in general. Leveraging dependency injection via setters allows flexible usage in a variety of environments. Thus you could easily provide a factory class that is able to lookup `MyPluginInterface` 74 | implementations from the classpath, instantiate them and inject them into `HostImpl`. 75 | 76 | Using Spring as component container you could configure something like this: 77 | 78 | **Example 1.2. Configuring HostImpl with Spring** 79 | 80 | ```xml 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | ``` 89 | 90 | This is pretty much well known to Spring developers and let's us face the wall that this is rather static. Everytime you want to add a new plugin implementation instance you have to modify configuration of the core. Let's see how we can get this dance a little more. 91 | 92 | ### Collecting Spring beans dynamically 93 | 94 | With the `BeanListBeanFactory` Spring Plugin provides a Spring container extension, that allows to lookup beans of a given type in the current `ApplicationContext` and register them as list under a given name. Take a look at the configuration now: 95 | 96 | **Example 1.3. Host and plugin configuration with Spring Plugin 97 | support** 98 | 99 | ```xml 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | ``` 114 | 115 | ```xml 116 | 117 | 118 | ``` 119 | 120 | You can see that we include a wildcarded configuration file that allows plugin projects to easily contribute plugin implementations by declaring them as beans in configuration files matching the wildcarded path. If you use Spring 2.5 component scanning you don't have to use the import trick at all as Spring would detect the implementation automatically as long as it is annotated with `@Component`, `@Service` a.s.o. 121 | 122 | The `BeanListBeanFactory` in turn allows registering a map of lists to be created, where the maps entry key is the id under which the list will be registered and the entry's value is the type to be looked up. 123 | 124 | > #### Note 125 | > 126 | > The design of the `BeanListBeanFactory` might seem a little confusing at first 127 | > (especially to set a map on a property named lists). This is due to the possibility to 128 | > register more than one list to be looked up. We think about dropping this 129 | > functionality for the sake of simplicity in future versions. 130 | 131 | ### A whole lotta XML - namespace to help! 132 | 133 | Actually this already serves a lot of requirements we listed in [Section “Context”](#context). Nevertheless the amount of XML to be written is quite large. Furthermore it's rather not intuitive to configure a bean id as key, and a type as value. We can heavily shrink the XML required to a single line by providing a Spring namespace boiling configuration down to this: 134 | 135 | **Example 1.4. Host configuration using the plugin namespace** 136 | 137 | ```xml 138 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | ``` 153 | 154 | Assuming you have added the namespace XSD into Eclipse and installed Spring IDE, you should get code completion on filling the class attribute. 155 | 156 | ### Using inner beans 157 | 158 | The listing above features an indirection for the `plugin` bean definition. Defining the plugin list as top level bean can have advantages: you easily could place all plugin lists in a dedicated configuration file, presenting all application extension points in one single place. Nevertheless you also might choose to define the list directly in the property declaration: 159 | 160 | **Example 1.5. Using inner bean definition** 161 | 162 | ```xml 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | ``` 171 | 172 | This way you have a more compact configuration, paying the prica of tangling all extention points though possibly various config files. 173 | 174 | #### Plugin beans 175 | 176 | Using plain interfaces and `BeanListBeanFactory` offers an easy way to dynamically lookup beans in Spring environments. Nevertheless, very often you face the situation that you want to have dedicated access to a subset of all plugins, choose plugins by a given criteria or use a decent default plugin or the like. Thus we need a basic infrastructure interface for plugin interfaces to extend and a more sophisticated plugin container. 177 | 178 | #### Plugin 179 | 180 | Hera's central infrastructure interfacte is `Plugin`, where `S` defines the delimiter type you want to let implementations decide on, whether they shall be invoked or not. Thus the plugin implementation have to implement `supports(S delimiter)` to come to the decision. Consider the following example: 181 | 182 | **Example 1.6. Usage of Plugin interface** 183 | 184 | ```java 185 | public enum ProductType { 186 | SOFTWARE, HARDWARE; 187 | } 188 | 189 | public interface ProductProcessor extends Plugin { 190 | public void process(Product product); 191 | } 192 | ``` 193 | 194 | This design would allow plugin providers to implement `supports(ProductType productType)` to decide which product types they want to process and provide actual processing logic in `process(Product product)`. 195 | 196 | #### PluginRegistry 197 | 198 | Using a `List` as plugin container as well as the `Plugin` interface you can now select plugins supporting the given delimiter. To not reimplement the lookup logic for common 199 | cases Spring Plugin provides a `PluginRegistry, S>` interface that provides sophisticated methods to access certain plugins: 200 | 201 | **Example 1.7. Usage of the PluginRegistry** 202 | 203 | ```java 204 | PluginRegistry registry = SimplePluginRegistry.of(new FooImplementation()); 205 | 206 | // Returns the first plugin supporting SOFTWARE if available 207 | Optional plugin = registry.getPluginFor(ProductType.SOFTWARE); 208 | // Returns the first plugin supporting SOFTWARE, or DefaultPlugin if none found 209 | ProductProcessor plugin = registry.getPluginOrDefaultFor(ProductType.SOFTWARE, () -> new DefaultPlugin()); 210 | // Returns all plugins supporting HARDWARE, throwing the given exception if none found 211 | List plugin = registry.getPluginsFor(ProductType.HARDWARE, () -> new MyException("Damn!"); 212 | ``` 213 | 214 | #### Configuration, XML namespace and @EnablePluginRegistries 215 | 216 | Similar to the `BeanListBeanFactory` described in [Collecting Spring beans 217 | dynamically](#core.beans-dynamically) Spring Plugin provides a `PluginRegistryBeanFactory` to automatically lookup beans of a dedicated type to be aggregated in a `PluginRegistry`. Note that the type has to be assignable to `Plugin` to let the registry work as expected. 218 | 219 | Furthermore there is also an element in the namespace to shrink down configuration XML: 220 | 221 | **Example 1.8. Using the XML namespace to configure a registry** 222 | 223 | ```xml 224 | 225 | ``` 226 | 227 | As of version 0.8 creating a `PluginRegistry` can also be achieved using the `@EnablePluginRegistries` annotation: 228 | 229 | ```java 230 | @Configuration 231 | @EnablePluginRegistries(MyPluginInterface.class) 232 | class ApplicationConfiguration { … } 233 | ``` 234 | 235 | This configuration snippet will register a `OrderAwarePluginRegistry` for `MyPluginInterface` within the `ApplicationContext` and thus make it available for injection into client beans. The registered bean will be named `myPluginInterfaceRegistry` so that it can be explicitly referenced on the client side using the `@Qualifier` annotation if necessary. The bean name can be customized using `@Qualifier` on the plugin interface definition. 236 | 237 | ### Ordering plugins 238 | 239 | Declaring plugin beans sometimes it is necessary to preserve a certain order of plugins. Suppose you have a plugin host that already defines one plugin that shall always be executed after all plugins declared by extensions. Actually the Spring container typically returns beans in the order they were declared, so that you could import you wildcarded config files right before declaring the default plugin. Unfortunately the order of the beans is not contracted to be preserved for the Spring container. Thus we need a different solution. 240 | 241 | Spring provides two ways to order beans. First, you can implement `Ordered` interface and implement `getOrder` to place a plugin at a certain point in the list. Secondly you can user the `@Order` annotation. For more information on ordering capabilities of Spring see the [section on this topic in the Spring reference documentation](https://docs.spring.io/spring/docs/3.1.x/javadoc-api/org/springframework/core/Ordered.html). 242 | 243 | Using the Spring Plugin namespace you will get a `PluginRegistry` instance that is capable of preserving the order defined by the mentioned means. Using Spring Plugin 244 | programmatically use `OrderAwarePluginRegistry`. 245 | 246 | ## Metadata 247 | 248 | For plugin architectures it is essential to capture metadata information about plugin instances. A very core set of metadata (name, version) also serves as identifier of a plugin and thus can be used. The Spring Plugin metadata module provides support to capture metadata. 249 | 250 | ### Core concepts 251 | 252 | The metadata module actually builds around two core interfaces, `PluginMetadata` and `MetadataProvider`: 253 | 254 | **Example 2.1. Core concepts** 255 | 256 | ```java 257 | public interface PluginMetadata { 258 | String getName(); 259 | String getVersion(); 260 | } 261 | 262 | public interface MetadataProvider { 263 | PluginMetadata getMetadata(); 264 | } 265 | ``` 266 | 267 | The `PluginMetadata` interface captures the required properties to define an identifiable plugin. This means, that implementations should ensure uniqueness through these two properties. With `SimplePluginMetadata` Spring Plugin provides a Java bean style class to capture metadata. Of course applications can and should provide extended metadata information according to their needs. The very narrow interface is only targeted at integrating the metadata concept with the `PluginRegistry` (see [the section called “PluginRegistry”](#core.plugin-registry)) without bothering developers with too much information required. 268 | 269 | The `MetadataProvider` interface is to be used in application plugin interfaces to indicate that they can provide metadata. To ease plugin implementation we provide 270 | `AbstractMetadataBasedPlugin` that uses the internal metadata to implement `supports(…)` method of `Plugin`. Extending this base class plugins with metadata as selection criteria can easily be build. This way you could store the metadata in user specific configuration files and use this to select a distinct plugin specific to a given user. 271 | 272 | ## Glossary 273 | 274 | 275 | ### O 276 | 277 | OSGi 278 | 279 | * Open Services Gateway Initiative - a fully fledged plugin runtime environment on top of the Java VM - [https://en.wikipedia.org/wiki/OSGi](https://en.wikipedia.org/wiki/OSGi). 280 | 281 | ### X 282 | 283 | XML 284 | 285 | * eXtensible Markup Language 286 | 287 | XSD 288 | 289 | * Xml Schema Definition 290 | -------------------------------------------------------------------------------- /core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | spring-plugin-core 6 | 7 | Spring Plugin - Core 8 | Core plugin infrastructure 9 | 10 | 11 | org.springframework.plugin 12 | spring-plugin 13 | 4.0.0-SNAPSHOT 14 | 15 | 16 | 17 | spring.plugin.core 18 | 19 | 20 | 21 | 22 | 23 | src/main/resources 24 | true 25 | 26 | 27 | ../src/main/resources 28 | true 29 | META-INF 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.springframework 38 | spring-beans 39 | ${spring.version} 40 | 41 | 42 | 43 | org.springframework 44 | spring-context 45 | ${spring.version} 46 | 47 | 48 | 49 | org.springframework 50 | spring-aop 51 | ${spring.version} 52 | 53 | 54 | 55 | org.springframework 56 | spring-test 57 | ${spring.version} 58 | test 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /core/src/main/java/org/springframework/plugin/core/OrderAwarePluginRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.plugin.core; 17 | 18 | import java.util.ArrayList; 19 | import java.util.Arrays; 20 | import java.util.Collections; 21 | import java.util.Comparator; 22 | import java.util.List; 23 | import java.util.function.Supplier; 24 | 25 | import org.springframework.core.annotation.AnnotationAwareOrderComparator; 26 | import org.springframework.util.Assert; 27 | import org.springframework.util.function.SingletonSupplier; 28 | 29 | /** 30 | * {@link PluginRegistry} implementation that be made aware of a certain ordering of {@link Plugin}s. By default it 31 | * orders {@link Plugin}s by regarding {@link org.springframework.core.Ordered} interface or 32 | * {@link org.springframework.core.annotation.Order} annotation. To alter ordering behaviour use one of the factory 33 | * methods accepting a {@link Comparator} as parameter. 34 | * 35 | * @author Oliver Gierke 36 | */ 37 | public class OrderAwarePluginRegistry, S> extends SimplePluginRegistry { 38 | 39 | /** 40 | * Comparator regarding {@link org.springframework.core.Ordered} interface or 41 | * {@link org.springframework.core.annotation.Order} annotation. 42 | */ 43 | static final Comparator DEFAULT_COMPARATOR = new AnnotationAwareOrderComparator(); 44 | 45 | /** 46 | * Comparator reverting the {@value #DEFAULT_COMPARATOR}. 47 | */ 48 | static final Comparator DEFAULT_REVERSE_COMPARATOR = DEFAULT_COMPARATOR.reversed(); 49 | 50 | private final Comparator comparator; 51 | 52 | /** 53 | * Creates a new {@link OrderAwarePluginRegistry} with the given {@link Plugin}s and {@link Comparator}. 54 | * 55 | * @param plugins the {@link Plugin}s to be contained in the registry or {@literal null} if the registry shall be 56 | * empty initally. 57 | * @param comparator the {@link Comparator} to be used for ordering the {@link Plugin}s or {@literal null} if the 58 | * {@code #DEFAULT_COMPARATOR} shall be used. 59 | */ 60 | protected OrderAwarePluginRegistry(Supplier> plugins, Comparator comparator) { 61 | 62 | super(SingletonSupplier.of(() -> { 63 | 64 | var result = new ArrayList<>(plugins.get()); 65 | Collections.sort(result, comparator); 66 | 67 | return result; 68 | })); 69 | 70 | Assert.notNull(comparator, "Comparator must not be null!"); 71 | 72 | this.comparator = comparator; 73 | } 74 | 75 | /** 76 | * Creates a new {@link OrderAwarePluginRegistry} using the {@code #DEFAULT_COMPARATOR}. 77 | * 78 | * @return 79 | * @since 2.0 80 | */ 81 | public static > OrderAwarePluginRegistry empty() { 82 | return of(Collections.emptyList()); 83 | } 84 | 85 | /** 86 | * Creates a new {@link OrderAwarePluginRegistry} using the given {@link Comparator} for ordering contained 87 | * {@link Plugin}s. 88 | * 89 | * @param comparator must not be {@literal null}. 90 | * @return 91 | * @since 2.0 92 | */ 93 | public static > OrderAwarePluginRegistry of(Comparator comparator) { 94 | 95 | Assert.notNull(comparator, "Comparator must not be null!"); 96 | 97 | return of(Collections.emptyList(), comparator); 98 | } 99 | 100 | /** 101 | * Creates a new {@link OrderAwarePluginRegistry} with the given plugins. 102 | * 103 | * @param plugins must not be {@literal null}. 104 | * @return 105 | * @since 2.0 106 | */ 107 | @SafeVarargs 108 | public static > OrderAwarePluginRegistry of(T... plugins) { 109 | return of(Arrays.asList(plugins), DEFAULT_COMPARATOR); 110 | } 111 | 112 | /** 113 | * Creates a new {@link OrderAwarePluginRegistry} with the given plugins. 114 | * 115 | * @param plugins must not be {@literal null}. 116 | * @return 117 | * @since 2.0 118 | */ 119 | public static > OrderAwarePluginRegistry of(List plugins) { 120 | return of(plugins, DEFAULT_COMPARATOR); 121 | } 122 | 123 | /** 124 | * Creates a new {@link OrderAwarePluginRegistry} with the given {@link Plugin}s and the order of the {@link Plugin}s 125 | * reverted. 126 | * 127 | * @param plugins must not be {@literal null}. 128 | * @return 129 | * @since 2.0 130 | */ 131 | public static > OrderAwarePluginRegistry ofReverse(List plugins) { 132 | return of(plugins, DEFAULT_REVERSE_COMPARATOR); 133 | } 134 | 135 | public static > OrderAwarePluginRegistry ofReverse(Supplier> plugins) { 136 | return of(plugins, DEFAULT_REVERSE_COMPARATOR); 137 | } 138 | 139 | /** 140 | * Creates a new {@link OrderAwarePluginRegistry} with the given plugins. 141 | * 142 | * @param plugins 143 | * @return 144 | * @since 2.0 145 | */ 146 | public static > OrderAwarePluginRegistry of(List plugins, 147 | Comparator comparator) { 148 | 149 | Assert.notNull(plugins, "Plugins must not be null!"); 150 | Assert.notNull(comparator, "Comparator must not be null!"); 151 | 152 | return of(() -> plugins, comparator); 153 | } 154 | 155 | public static > OrderAwarePluginRegistry of(Supplier> plugins) { 156 | return of(plugins, DEFAULT_COMPARATOR); 157 | } 158 | 159 | public static > OrderAwarePluginRegistry of(Supplier> plugins, 160 | Comparator comparator) { 161 | return new OrderAwarePluginRegistry<>(plugins, comparator); 162 | } 163 | 164 | /** 165 | * Returns a new {@link OrderAwarePluginRegistry} with the order of the plugins reverted. 166 | * 167 | * @return 168 | */ 169 | public OrderAwarePluginRegistry reverse() { 170 | 171 | List copy = new ArrayList<>(getPlugins()); 172 | return of(copy, comparator.reversed()); 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /core/src/main/java/org/springframework/plugin/core/Plugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.plugin.core; 17 | 18 | /** 19 | * Central interface for plugins for the system. This interface is meant to be extended by concrete plugin interfaces. 20 | * Its core responsibility is to define a delimiter type and a selection callback with the delimiter as parameter. The 21 | * delimiter is some kind of decision object concrete plugin implementations can use to decide if they are capable to be 22 | * executed. 23 | * 24 | * @author Oliver Gierke 25 | */ 26 | public interface Plugin { 27 | 28 | /** 29 | * Returns if a plugin should be invoked according to the given delimiter. 30 | * 31 | * @param delimiter must not be {@literal null}. 32 | * @return if the plugin should be invoked 33 | */ 34 | boolean supports(S delimiter); 35 | } 36 | -------------------------------------------------------------------------------- /core/src/main/java/org/springframework/plugin/core/PluginRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.plugin.core; 17 | 18 | import java.util.Arrays; 19 | import java.util.Collections; 20 | import java.util.Comparator; 21 | import java.util.List; 22 | import java.util.Optional; 23 | import java.util.function.Supplier; 24 | 25 | import org.springframework.util.Assert; 26 | 27 | /** 28 | * Registry for {@link Plugin}s. Allows sophisticated typesafe access to implementations of interfaces extending {link 29 | * Plugin}. 30 | * 31 | * @param the concrete {@link Plugin} interface 32 | * @param the delimiter type 33 | * @author Oliver Gierke 34 | */ 35 | public interface PluginRegistry, S> extends Iterable { 36 | 37 | /** 38 | * Creates a new {@link PluginRegistry} using the {@code #DEFAULT_COMPARATOR}. 39 | * 40 | * @return 41 | * @since 2.0 42 | */ 43 | public static > PluginRegistry empty() { 44 | return of(Collections.emptyList()); 45 | } 46 | 47 | /** 48 | * Creates a new {@link PluginRegistry} using the given {@link Comparator} for ordering contained {@link Plugin}s. 49 | * 50 | * @param comparator must not be {@literal null}. 51 | * @return 52 | * @since 2.0 53 | */ 54 | public static > PluginRegistry of(Comparator comparator) { 55 | 56 | Assert.notNull(comparator, "Comparator must not be null!"); 57 | 58 | return of(Collections.emptyList(), comparator); 59 | } 60 | 61 | /** 62 | * Creates a new {@link PluginRegistry} with the given plugins. 63 | * 64 | * @param plugins must not be {@literal null}. 65 | * @return 66 | * @since 2.0 67 | */ 68 | @SafeVarargs 69 | public static > PluginRegistry of(T... plugins) { 70 | return of(Arrays.asList(plugins), OrderAwarePluginRegistry.DEFAULT_COMPARATOR); 71 | } 72 | 73 | /** 74 | * Creates a new {@link OrderAwarePluginRegistry} with the given plugins. 75 | * 76 | * @param plugins must not be {@literal null}. 77 | * @return 78 | * @since 2.0 79 | */ 80 | public static > PluginRegistry of(List plugins) { 81 | return of(plugins, OrderAwarePluginRegistry.DEFAULT_COMPARATOR); 82 | } 83 | 84 | /** 85 | * Creates a new {@link OrderAwarePluginRegistry} with the given plugins. 86 | * 87 | * @param plugins 88 | * @return 89 | * @since 2.0 90 | */ 91 | public static > PluginRegistry of(List plugins, 92 | Comparator comparator) { 93 | 94 | Assert.notNull(plugins, "Plugins must not be null!"); 95 | Assert.notNull(comparator, "Comparator must not be null!"); 96 | 97 | return OrderAwarePluginRegistry.of(plugins, comparator); 98 | } 99 | 100 | /** 101 | * Returns the first {@link Plugin} found for the given delimiter. Thus, further configured {@link Plugin}s are 102 | * ignored. 103 | * 104 | * @param delimiter must not be {@literal null}. 105 | * @return a plugin for the given delimiter or {@link Optional#empty()} if none found. 106 | */ 107 | Optional getPluginFor(S delimiter); 108 | 109 | /** 110 | * Returns the first {@link Plugin} found for the given delimiter. Thus, further configured {@link Plugin}s are 111 | * ignored. 112 | * 113 | * @param delimiter must not be {@literal null}. 114 | * @return a {@link Plugin} for the given originating system or {@link Optional#empty()} if none found. 115 | * @throws IllegalArgumentException in case no {@link Plugin} for the given delimiter 116 | */ 117 | T getRequiredPluginFor(S delimiter) throws IllegalArgumentException; 118 | 119 | /** 120 | * Returns the first {@link Plugin} found for the given delimiter. Thus, further configured {@link Plugin}s are 121 | * ignored. 122 | * 123 | * @param delimiter must not be {@literal null}. 124 | * @param message a {@link Supplier} to produce an exception message in case no plugin is found. 125 | * @return a {@link Plugin} for the given originating system or {@link Optional#empty()} if none found. 126 | * @throws IllegalArgumentException in case no {@link Plugin} for the given delimiter 127 | */ 128 | T getRequiredPluginFor(S delimiter, Supplier message) throws IllegalArgumentException; 129 | 130 | /** 131 | * Returns all plugins for the given delimiter. 132 | * 133 | * @param delimiter must not be {@literal null}. 134 | * @return a list of plugins or an empty list if none found 135 | */ 136 | List getPluginsFor(S delimiter); 137 | 138 | /** 139 | * Retrieves a required plugin from the registry or throw the given exception if none can be found. If more than one 140 | * plugins are found the first one will be returned. 141 | * 142 | * @param the exception type to be thrown in case no plugin can be found. 143 | * @param delimiter must not be {@literal null}. 144 | * @param ex a lazy {@link Supplier} to produce an exception in case no plugin can be found, must not be 145 | * {@literal null}. 146 | * @return a single plugin for the given delimiter 147 | * @throws E if no plugin can be found for the given delimiter 148 | */ 149 | T getPluginFor(S delimiter, Supplier ex) throws E; 150 | 151 | /** 152 | * Retrieves all plugins for the given delimiter or throws an exception if no plugin can be found. 153 | * 154 | * @param the exception type to be thrown. 155 | * @param delimiter must not be {@literal null}. 156 | * @param ex a lazy {@link Supplier} to produce an exception in case no plugin can be found, must not be 157 | * {@literal null}. 158 | * @return all plugins for the given delimiter 159 | * @throws E if no plugin can be found 160 | */ 161 | List getPluginsFor(S delimiter, Supplier ex) throws E; 162 | 163 | /** 164 | * Returns the first {@link Plugin} supporting the given delimiter or the given plugin if none can be found. 165 | * 166 | * @param delimiter must not be {@literal null}. 167 | * @param plugin must not be {@literal null}. 168 | * @return a single {@link Plugin} supporting the given delimiter or the given {@link Plugin} if none found 169 | */ 170 | T getPluginOrDefaultFor(S delimiter, T plugin); 171 | 172 | /** 173 | * Returns the first {@link Plugin} supporting the given delimiter or the given lazily-provided plugin if none can be 174 | * found. 175 | * 176 | * @param delimiter can be {@literal null}. 177 | * @param defaultSupplier must not be {@literal null}. 178 | * @return a single {@link Plugin} supporting the given delimiter or the given lazily provided {@link Plugin} if none 179 | * found. 180 | */ 181 | T getPluginOrDefaultFor(S delimiter, Supplier defaultSupplier); 182 | 183 | /** 184 | * Returns all {@link Plugin}s supporting the given delimiter or the given plugins if none found. 185 | * 186 | * @param delimiter must not be {@literal null}. 187 | * @param plugins must not be {@literal null}. 188 | * @return all {@link Plugin}s supporting the given delimiter or the given {@link Plugin}s if none found, will never 189 | * be {@literal null}. 190 | */ 191 | List getPluginsFor(S delimiter, List plugins); 192 | 193 | /** 194 | * Returns the number of registered plugins. 195 | * 196 | * @return the number of plugins in the registry 197 | */ 198 | int countPlugins(); 199 | 200 | /** 201 | * Returns whether the registry contains a given plugin. 202 | * 203 | * @param plugin must not be {@literal null}. 204 | * @return 205 | */ 206 | boolean contains(T plugin); 207 | 208 | /** 209 | * Returns whether the registry contains a {@link Plugin} matching the given delimiter. 210 | * 211 | * @param delimiter must not be {@literal null}. 212 | * @return 213 | */ 214 | boolean hasPluginFor(S delimiter); 215 | 216 | /** 217 | * Returns all {@link Plugin}s contained in this registry. Will return an immutable {@link List} to prevent outside 218 | * modifications of the {@link PluginRegistry} content. 219 | * 220 | * @return will never be {@literal null}. 221 | */ 222 | List getPlugins(); 223 | } 224 | -------------------------------------------------------------------------------- /core/src/main/java/org/springframework/plugin/core/PluginRegistrySupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.plugin.core; 17 | 18 | import java.util.Iterator; 19 | import java.util.List; 20 | import java.util.function.Supplier; 21 | 22 | import org.springframework.util.Assert; 23 | import org.springframework.util.function.SingletonSupplier; 24 | 25 | /** 26 | * Base class for {@link PluginRegistry} implementations. Implements an initialization mechanism triggered on forst 27 | * invocation of {@link #getPlugins()}. 28 | * 29 | * @author Oliver Gierke 30 | */ 31 | abstract class PluginRegistrySupport, S> implements PluginRegistry, Iterable { 32 | 33 | private final Supplier> plugins; 34 | 35 | /** 36 | * Creates a new {@link PluginRegistrySupport} instance using the given plugins. 37 | * 38 | * @param plugins must not be {@literal null}. 39 | */ 40 | @SuppressWarnings("unchecked") 41 | public PluginRegistrySupport(List plugins) { 42 | 43 | Assert.notNull(plugins, "Plugins must not be null!"); 44 | 45 | this.plugins = SingletonSupplier.of((List) plugins.stream().filter(it -> it != null).toList()); 46 | } 47 | 48 | @SuppressWarnings("unchecked") 49 | protected PluginRegistrySupport(Supplier> plugins) { 50 | 51 | this.plugins = () -> (List) plugins.get().stream() 52 | .filter(it -> it != null) 53 | .toList(); 54 | } 55 | 56 | /** 57 | * Returns all registered plugins. Only use this method if you really need to access all plugins. For distinguished 58 | * access to certain plugins favour accessor methods like {link #getPluginFor} over this one. This method should only 59 | * be used for testing purposes to check registry configuration. 60 | * 61 | * @return all plugins of the registry 62 | */ 63 | public List getPlugins() { 64 | return plugins.get(); 65 | } 66 | 67 | /* 68 | * (non-Javadoc) 69 | * @see java.lang.Iterable#iterator() 70 | */ 71 | @Override 72 | public Iterator iterator() { 73 | return getPlugins().iterator(); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /core/src/main/java/org/springframework/plugin/core/SimplePluginRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.plugin.core; 17 | 18 | import java.util.ArrayList; 19 | import java.util.Arrays; 20 | import java.util.Collections; 21 | import java.util.List; 22 | import java.util.Optional; 23 | import java.util.function.Supplier; 24 | import java.util.stream.Collectors; 25 | 26 | import org.springframework.util.Assert; 27 | 28 | /** 29 | * Basic implementation of {@link PluginRegistry}. Simply holds all given plugins in a list dropping {@literal null} 30 | * values silently on adding. 31 | * 32 | * @author Oliver Gierke 33 | */ 34 | class SimplePluginRegistry, S> extends PluginRegistrySupport { 35 | 36 | /** 37 | * Creates a new {@code SimplePluginRegistry}. Will create an empty registry if {@literal null} is provided. 38 | * 39 | * @param plugins must not be {@literal null}. 40 | */ 41 | protected SimplePluginRegistry(List plugins) { 42 | super(plugins); 43 | } 44 | 45 | protected SimplePluginRegistry(Supplier> plugins) { 46 | super(plugins); 47 | } 48 | 49 | /** 50 | * Creates a new {@link SimplePluginRegistry}. 51 | * 52 | * @return 53 | */ 54 | public static > SimplePluginRegistry empty() { 55 | return of(Collections.emptyList()); 56 | } 57 | 58 | /** 59 | * Creates a new {@link SimplePluginRegistry} with the given {@link Plugin} s. 60 | * 61 | * @return 62 | */ 63 | @SafeVarargs 64 | public static > SimplePluginRegistry of(T... plugins) { 65 | return of(Arrays.asList(plugins)); 66 | } 67 | 68 | /** 69 | * Creates a new {@link SimplePluginRegistry} with the given {@link Plugin} s. 70 | * 71 | * @return 72 | */ 73 | public static > SimplePluginRegistry of(List plugins) { 74 | return new SimplePluginRegistry<>(plugins); 75 | } 76 | 77 | /* (non-Javadoc) 78 | * @see org.springframework.plugin.core.PluginRegistrySupport#getPlugins() 79 | */ 80 | @Override 81 | public List getPlugins() { 82 | return Collections.unmodifiableList(super.getPlugins()); 83 | } 84 | 85 | /* 86 | * (non-Javadoc) 87 | * @see org.springframework.plugin.core.PluginRegistry#getPluginFor(java.lang.Object) 88 | */ 89 | @Override 90 | public Optional getPluginFor(S delimiter) { 91 | 92 | Assert.notNull(delimiter, "Delimiter must not be null!"); 93 | 94 | return super.getPlugins().stream()// 95 | .filter(it -> it.supports(delimiter))// 96 | .findFirst(); 97 | } 98 | 99 | /* 100 | * (non-Javadoc) 101 | * @see org.springframework.plugin.core.PluginRegistry#getRequiredPluginFor(java.lang.Object) 102 | */ 103 | @Override 104 | public T getRequiredPluginFor(S delimiter) { 105 | 106 | Assert.notNull(delimiter, "Delimiter must not be null!"); 107 | 108 | return getRequiredPluginFor(delimiter, 109 | () -> String.format("No plugin found for delimiter %s! Registered plugins: %s.", delimiter, getPlugins())); 110 | } 111 | 112 | /* 113 | * (non-Javadoc) 114 | * @see org.springframework.plugin.core.PluginRegistry#getRequiredPluginFor(java.lang.Object, java.util.function.Supplier) 115 | */ 116 | @Override 117 | public T getRequiredPluginFor(S delimiter, Supplier message) throws IllegalArgumentException { 118 | 119 | Assert.notNull(delimiter, "Delimiter must not be null!"); 120 | Assert.notNull(message, "Message must not be null!"); 121 | 122 | return getPluginFor(delimiter, () -> new IllegalArgumentException(message.get())); 123 | } 124 | 125 | /* 126 | * (non-Javadoc) 127 | * @see org.springframework.plugin.core.PluginRegistry#getPluginsFor(java.lang.Object) 128 | */ 129 | @Override 130 | public List getPluginsFor(S delimiter) { 131 | 132 | Assert.notNull(delimiter, "Delimiter must not be null!"); 133 | 134 | return super.getPlugins().stream()// 135 | .filter(it -> it.supports(delimiter))// 136 | .collect(Collectors.toList()); 137 | } 138 | 139 | /* 140 | * (non-Javadoc) 141 | * @see org.springframework.plugin.core.PluginRegistry#getPluginFor(java.lang.Object, org.springframework.plugin.core.PluginRegistry.Supplier) 142 | */ 143 | @Override 144 | public T getPluginFor(S delimiter, Supplier ex) throws E { 145 | 146 | Assert.notNull(delimiter, "Delimiter must not be null!"); 147 | Assert.notNull(ex, "Exception supplier must not be null!"); 148 | 149 | return getPluginFor(delimiter).orElseThrow(ex); 150 | } 151 | 152 | /* 153 | * (non-Javadoc) 154 | * @see org.springframework.plugin.core.PluginRegistry#getPluginsFor(java.lang.Object, org.springframework.plugin.core.PluginRegistry.ExceptionProvider) 155 | */ 156 | @Override 157 | public List getPluginsFor(S delimiter, Supplier ex) throws E { 158 | 159 | Assert.notNull(delimiter, "Delimiter must not be null!"); 160 | Assert.notNull(ex, "Exception supplier must not be null!"); 161 | 162 | List result = getPluginsFor(delimiter); 163 | 164 | if (result.isEmpty()) { 165 | throw ex.get(); 166 | } 167 | 168 | return result; 169 | } 170 | 171 | /* 172 | * (non-Javadoc) 173 | * @see org.springframework.plugin.core.PluginRegistry#getPluginOrDefaultFor(java.lang.Object, org.springframework.plugin.core.Plugin) 174 | */ 175 | @Override 176 | public T getPluginOrDefaultFor(S delimiter, T plugin) { 177 | return getPluginOrDefaultFor(delimiter, () -> plugin); 178 | } 179 | 180 | /* 181 | * (non-Javadoc) 182 | * @see org.springframework.plugin.core.PluginRegistry#getPluginOrDefaultFor(java.lang.Object, java.util.function.Supplier) 183 | */ 184 | @Override 185 | public T getPluginOrDefaultFor(S delimiter, Supplier defaultSupplier) { 186 | 187 | Assert.notNull(delimiter, "Delimiter must not be null!"); 188 | Assert.notNull(defaultSupplier, "Default supplier must not be null!"); 189 | 190 | return getPluginFor(delimiter).orElseGet(defaultSupplier); 191 | } 192 | 193 | /* 194 | * (non-Javadoc) 195 | * @see org.springframework.plugin.core.PluginRegistry#getPluginsFor(java.lang.Object, java.util.List) 196 | */ 197 | @Override 198 | public List getPluginsFor(S delimiter, List plugins) { 199 | 200 | Assert.notNull(delimiter, "Delimiter must not be null!"); 201 | Assert.notNull(plugins, "Plugins must not be null!"); 202 | 203 | List candidates = getPluginsFor(delimiter); 204 | 205 | return candidates.isEmpty() ? new ArrayList(plugins) : candidates; 206 | } 207 | 208 | /* 209 | * (non-Javadoc) 210 | * @see org.springframework.plugin.core.PluginRegistry#countPlugins() 211 | */ 212 | @Override 213 | public int countPlugins() { 214 | return super.getPlugins().size(); 215 | } 216 | 217 | /* 218 | * (non-Javadoc) 219 | * @see org.springframework.plugin.core.PluginRegistry#contains(org.springframework.plugin.core.Plugin) 220 | */ 221 | @Override 222 | public boolean contains(T plugin) { 223 | return super.getPlugins().contains(plugin); 224 | } 225 | 226 | /* 227 | * (non-Javadoc) 228 | * @see org.springframework.plugin.core.PluginRegistry#hasPluginFor(java.lang.Object) 229 | */ 230 | @Override 231 | public boolean hasPluginFor(S delimiter) { 232 | return getPluginFor(delimiter).isPresent(); 233 | } 234 | } 235 | -------------------------------------------------------------------------------- /core/src/main/java/org/springframework/plugin/core/config/EnablePluginRegistries.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.plugin.core.config; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Inherited; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | import org.springframework.beans.factory.annotation.Qualifier; 26 | import org.springframework.context.annotation.Import; 27 | import org.springframework.plugin.core.Plugin; 28 | import org.springframework.plugin.core.PluginRegistry; 29 | 30 | /** 31 | * Enables exposure of {@link PluginRegistry} instances for the configured {@link Plugin} types 32 | * 33 | * @see #value() 34 | * @author Oliver Gierke 35 | */ 36 | @Target(ElementType.TYPE) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @Inherited 39 | @Documented 40 | @Import(PluginRegistriesBeanDefinitionRegistrar.class) 41 | public @interface EnablePluginRegistries { 42 | 43 | /** 44 | * The {@link Plugin} types to register {@link PluginRegistry} instances for. The registries will be named after the 45 | * uncapitalized plugin type extended with {@code Registry}. So for a plugin interface {@code SamplePlugin} the 46 | * exposed bean name will be {@code samplePluginRegistry}. This can be used on the client side to make sure you get 47 | * the right {@link PluginRegistry} injected by using the {@link Qualifier} annotation and referring to that bean 48 | * name. If the auto-generated bean name collides with one already in your application you can use the 49 | * {@link Qualifier} annotation right at the plugin interface to define a custom name. 50 | * 51 | * @return 52 | */ 53 | Class>[] value(); 54 | } 55 | -------------------------------------------------------------------------------- /core/src/main/java/org/springframework/plugin/core/config/PluginRegistriesBeanDefinitionRegistrar.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.plugin.core.config; 17 | 18 | import java.util.Map; 19 | 20 | import org.jspecify.annotations.Nullable; 21 | import org.slf4j.Logger; 22 | import org.slf4j.LoggerFactory; 23 | import org.springframework.beans.factory.annotation.Qualifier; 24 | import org.springframework.beans.factory.support.AutowireCandidateQualifier; 25 | import org.springframework.beans.factory.support.BeanDefinitionRegistry; 26 | import org.springframework.beans.factory.support.RootBeanDefinition; 27 | import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; 28 | import org.springframework.core.ResolvableType; 29 | import org.springframework.core.type.AnnotationMetadata; 30 | import org.springframework.plugin.core.OrderAwarePluginRegistry; 31 | import org.springframework.plugin.core.Plugin; 32 | import org.springframework.plugin.core.support.PluginRegistryFactoryBean; 33 | import org.springframework.util.Assert; 34 | import org.springframework.util.StringUtils; 35 | 36 | /** 37 | * {@link ImportBeanDefinitionRegistrar} to register {@link PluginRegistryFactoryBean} instances for type listed in 38 | * {@link EnablePluginRegistries}. Picks up {@link Qualifier} annotations used on the plugin interface and forwards them 39 | * to the bean definition for the factory. 40 | * 41 | * @author Oliver Gierke 42 | */ 43 | public class PluginRegistriesBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar { 44 | 45 | private static final Logger LOG = LoggerFactory.getLogger(PluginRegistriesBeanDefinitionRegistrar.class); 46 | 47 | /* 48 | * (non-Javadoc) 49 | * @see org.springframework.context.annotation.ImportBeanDefinitionRegistrar#registerBeanDefinitions(org.springframework.core.type.AnnotationMetadata, org.springframework.beans.factory.support.BeanDefinitionRegistry) 50 | */ 51 | @Override 52 | public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { 53 | 54 | Map annotationAttributes = importingClassMetadata 55 | .getAnnotationAttributes(EnablePluginRegistries.class.getName()); 56 | 57 | if (annotationAttributes == null) { 58 | LOG.info("No EnablePluginRegistries annotation found on type {}!", importingClassMetadata.getClassName()); 59 | return; 60 | } 61 | 62 | @Nullable 63 | Class[] types = (Class[]) annotationAttributes.get("value"); 64 | 65 | if (types == null) { 66 | return; 67 | } 68 | 69 | for (Class type : types) { 70 | 71 | RootBeanDefinition beanDefinition = new RootBeanDefinition(PluginRegistryFactoryBean.class); 72 | beanDefinition.setTargetType(getTargetType(type, OrderAwarePluginRegistry.class)); 73 | beanDefinition.getPropertyValues().addPropertyValue("type", type); 74 | 75 | Qualifier annotation = type.getAnnotation(Qualifier.class); 76 | 77 | // If the plugin interface has a Qualifier annotation, propagate that to the bean definition of the registry 78 | if (annotation != null) { 79 | AutowireCandidateQualifier qualifierMetadata = new AutowireCandidateQualifier(Qualifier.class); 80 | qualifierMetadata.setAttribute(AutowireCandidateQualifier.VALUE_KEY, annotation.value()); 81 | beanDefinition.addQualifier(qualifierMetadata); 82 | } 83 | 84 | // Default 85 | String beanName = annotation == null // 86 | ? StringUtils.uncapitalize(type.getSimpleName() + "Registry") // 87 | : annotation.value(); 88 | 89 | registry.registerBeanDefinition(beanName, beanDefinition); 90 | } 91 | } 92 | 93 | /** 94 | * Returns the target type of the {@link PluginRegistry} for the given plugin type. 95 | * 96 | * @param pluginType must not be {@literal null}. 97 | * @return 98 | */ 99 | private static ResolvableType getTargetType(Class pluginClass, Class wrapper) { 100 | 101 | Assert.notNull(pluginClass, "Plugin type must not be null!"); 102 | 103 | ResolvableType delimiterType = ResolvableType.forClass(Plugin.class, pluginClass).getGeneric(0); 104 | ResolvableType pluginType = ResolvableType.forClass(pluginClass); 105 | 106 | return ResolvableType.forClassWithGenerics(wrapper, pluginType, delimiterType); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /core/src/main/java/org/springframework/plugin/core/config/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains configuration support classes to ease registry configuration with Spring namespaces. 3 | */ 4 | @org.jspecify.annotations.NullMarked 5 | package org.springframework.plugin.core.config; 6 | -------------------------------------------------------------------------------- /core/src/main/java/org/springframework/plugin/core/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains the core plugin API. It allows other modules implementing components that extend functionality 3 | * defined by a plugin interface. Plugin clients can be equipped with plugin implementations. 4 | */ 5 | @org.jspecify.annotations.NullMarked 6 | package org.springframework.plugin.core; 7 | -------------------------------------------------------------------------------- /core/src/main/java/org/springframework/plugin/core/support/PluginRegistryFactoryBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.plugin.core.support; 17 | 18 | import java.util.Arrays; 19 | import java.util.Collection; 20 | import java.util.Collections; 21 | import java.util.List; 22 | import java.util.function.Predicate; 23 | import java.util.function.Supplier; 24 | 25 | import org.jspecify.annotations.NonNull; 26 | import org.jspecify.annotations.Nullable; 27 | import org.springframework.beans.BeansException; 28 | import org.springframework.beans.factory.BeanFactory; 29 | import org.springframework.beans.factory.BeanFactoryAware; 30 | import org.springframework.beans.factory.FactoryBean; 31 | import org.springframework.beans.factory.InitializingBean; 32 | import org.springframework.beans.factory.ListableBeanFactory; 33 | import org.springframework.context.ApplicationContext; 34 | import org.springframework.context.ApplicationContextAware; 35 | import org.springframework.plugin.core.OrderAwarePluginRegistry; 36 | import org.springframework.plugin.core.Plugin; 37 | import org.springframework.plugin.core.PluginRegistry; 38 | 39 | /** 40 | * {@link FactoryBean} to create {@link PluginRegistry} instances. 41 | * 42 | * @author Oliver Gierke 43 | */ 44 | public class PluginRegistryFactoryBean, S> 45 | implements FactoryBean>, BeanFactoryAware, ApplicationContextAware, InitializingBean { 46 | 47 | private Collection> exclusions = Collections.emptySet(); 48 | private @Nullable Class type; 49 | private @Nullable ListableBeanFactory factory; 50 | 51 | /** 52 | * Configures the type of beans to be looked up. 53 | * 54 | * @param type the type to set 55 | */ 56 | public void setType(Class type) { 57 | this.type = type; 58 | } 59 | 60 | /** 61 | * Configures the types to be excluded from the lookup. 62 | * 63 | * @param exclusions 64 | */ 65 | public void setExclusions(Class[] exclusions) { 66 | this.exclusions = Arrays.asList(exclusions); 67 | } 68 | 69 | /* 70 | * (non-Javadoc) 71 | * @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory) 72 | */ 73 | @Override 74 | public void setBeanFactory(BeanFactory beanFactory) throws BeansException { 75 | 76 | if (!(beanFactory instanceof ListableBeanFactory factory)) { 77 | throw new IllegalArgumentException("Expected a ListableBeanFactory!"); 78 | } 79 | 80 | this.factory = factory; 81 | } 82 | 83 | /** 84 | * @see ApplicationContextAware#setApplicationContext(ApplicationContext) 85 | * @deprecated since 4.0, in favor of {@link #setBeanFactory(BeanFactory)}. 86 | */ 87 | @Override 88 | @Deprecated 89 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 90 | setBeanFactory(applicationContext); 91 | } 92 | 93 | /* 94 | * (non-Javadoc) 95 | * @see org.springframework.beans.factory.FactoryBean#getObject() 96 | */ 97 | @NonNull 98 | public OrderAwarePluginRegistry getObject() { 99 | 100 | var type = this.type; 101 | 102 | if (type == null) { 103 | throw new IllegalStateException("No plugin type configured!"); 104 | } 105 | 106 | var factory = this.factory; 107 | 108 | if (factory == null) { 109 | throw new IllegalStateException("No ListableBeanFactory configured!"); 110 | } 111 | 112 | Supplier> plugins = () -> factory.getBeanProvider(type, false) 113 | .stream(Predicate.not(exclusions::contains)) 114 | .toList(); 115 | 116 | return OrderAwarePluginRegistry.of(plugins); 117 | } 118 | 119 | /* 120 | * (non-Javadoc) 121 | * @see org.springframework.beans.factory.FactoryBean#getObjectType() 122 | */ 123 | @NonNull 124 | public Class getObjectType() { 125 | return OrderAwarePluginRegistry.class; 126 | } 127 | 128 | /* 129 | * (non-Javadoc) 130 | * @see org.springframework.beans.factory.FactoryBean#isSingleton() 131 | */ 132 | public boolean isSingleton() { 133 | return true; 134 | } 135 | 136 | /** 137 | * @see InitializingBean#afterPropertiesSet() 138 | * @deprecated since 4.0, not needed anymore. 139 | */ 140 | @Override 141 | @Deprecated 142 | public void afterPropertiesSet() { 143 | // Only here for backwards-compatibility 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /core/src/main/java/org/springframework/plugin/core/support/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains support classes to create bean lists or plugin registry instances out of beans implementing a 3 | * certain interface. 4 | */ 5 | @org.jspecify.annotations.NullMarked 6 | package org.springframework.plugin.core.support; 7 | -------------------------------------------------------------------------------- /core/src/test/java/org/springframework/plugin/core/OrderAwarePluginRegistryUnitTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.plugin.core; 17 | 18 | import static org.assertj.core.api.Assertions.*; 19 | import static org.springframework.plugin.core.PluginRegistry.*; 20 | 21 | import java.util.Collections; 22 | import java.util.List; 23 | 24 | import org.junit.jupiter.api.BeforeEach; 25 | import org.junit.jupiter.api.Test; 26 | import org.springframework.aop.framework.ProxyFactory; 27 | import org.springframework.core.Ordered; 28 | import org.springframework.core.annotation.Order; 29 | import org.springframework.test.util.ReflectionTestUtils; 30 | 31 | /** 32 | * Unit test for {@link OrderAwarePluginRegistry} that especially concentrates on testing ordering functionality. 33 | * 34 | * @author Oliver Gierke 35 | */ 36 | class OrderAwarePluginRegistryUnitTest extends SimplePluginRegistryUnitTest { 37 | 38 | TestPlugin firstPlugin; 39 | TestPlugin secondPlugin; 40 | 41 | @Override 42 | @BeforeEach 43 | void setUp() { 44 | 45 | super.setUp(); 46 | 47 | firstPlugin = new FirstImplementation(); 48 | secondPlugin = new SecondImplementation(); 49 | } 50 | 51 | @Test 52 | void honorsOrderOnAddPlugins() throws Exception { 53 | 54 | PluginRegistry registry = of(firstPlugin, secondPlugin); 55 | assertOrder(registry, secondPlugin, firstPlugin); 56 | } 57 | 58 | @Test 59 | void createsRevertedRegistryCorrectly() throws Exception { 60 | 61 | OrderAwarePluginRegistry registry = OrderAwarePluginRegistry.of(firstPlugin, secondPlugin); 62 | PluginRegistry reverse = registry.reverse(); 63 | 64 | assertOrder(registry, secondPlugin, firstPlugin); 65 | assertOrder(reverse, firstPlugin, secondPlugin); 66 | } 67 | 68 | /** 69 | * @see #1 70 | */ 71 | @Test 72 | void considersJdkProxiedOrderedImplementation() { 73 | 74 | ThirdImplementation plugin = new ThirdImplementation(); 75 | TestPlugin thirdPlugin = (TestPlugin) new ProxyFactory(plugin).getProxy(); 76 | 77 | OrderAwarePluginRegistry registry = OrderAwarePluginRegistry.of(firstPlugin, secondPlugin, 78 | thirdPlugin); 79 | 80 | assertOrder(registry, secondPlugin, thirdPlugin, firstPlugin); 81 | assertOrder(registry.reverse(), firstPlugin, thirdPlugin, secondPlugin); 82 | } 83 | 84 | @Test 85 | void defaultSetupUsesDefaultComparator() { 86 | assertDefaultComparator(OrderAwarePluginRegistry.empty()); 87 | } 88 | 89 | @Test 90 | void defaultSetupUsesDefaultReverseComparator() { 91 | 92 | OrderAwarePluginRegistry, Object> registry = OrderAwarePluginRegistry 93 | .ofReverse(Collections.emptyList()); 94 | Object field = ReflectionTestUtils.getField(registry, "comparator"); 95 | 96 | assertThat(field).isEqualTo(ReflectionTestUtils.getField(registry, "DEFAULT_REVERSE_COMPARATOR")); 97 | } 98 | 99 | private static void assertOrder(PluginRegistry registry, TestPlugin... plugins) { 100 | 101 | List result = registry.getPluginsFor("delimiter"); 102 | 103 | assertThat(plugins.length).isEqualTo(result.size()); 104 | 105 | for (int i = 0; i < plugins.length; i++) { 106 | assertThat(result.get(i)).isEqualTo(plugins[i]); 107 | } 108 | 109 | assertThat(registry.getPluginFor("delimiter")).hasValue(plugins[0]); 110 | } 111 | 112 | private static void assertDefaultComparator(OrderAwarePluginRegistry registry) { 113 | 114 | Object field = ReflectionTestUtils.getField(registry, "comparator"); 115 | assertThat(field).isEqualTo(ReflectionTestUtils.getField(registry, "DEFAULT_COMPARATOR")); 116 | } 117 | 118 | private static interface TestPlugin extends Plugin { 119 | 120 | } 121 | 122 | @Order(5) 123 | private static class FirstImplementation implements TestPlugin { 124 | 125 | /* 126 | * (non-Javadoc) 127 | * 128 | * @see org.springframework.plugin.core.Plugin#supports(java.lang.Object) 129 | */ 130 | public boolean supports(String delimiter) { 131 | return true; 132 | } 133 | } 134 | 135 | @Order(1) 136 | private static class SecondImplementation implements TestPlugin { 137 | 138 | /* 139 | * (non-Javadoc) 140 | * 141 | * @see org.springframework.plugin.core.Plugin#supports(java.lang.Object) 142 | */ 143 | public boolean supports(String delimiter) { 144 | return true; 145 | } 146 | } 147 | 148 | private static class ThirdImplementation implements TestPlugin, Ordered { 149 | 150 | @Override 151 | public int getOrder() { 152 | return 3; 153 | } 154 | 155 | @Override 156 | public boolean supports(String delimiter) { 157 | return true; 158 | } 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /core/src/test/java/org/springframework/plugin/core/SamplePlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.plugin.core; 17 | 18 | /** 19 | * @author Oliver Gierke 20 | */ 21 | public interface SamplePlugin extends Plugin { 22 | void pluginMethod(); 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/java/org/springframework/plugin/core/SamplePluginHost.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.plugin.core; 17 | 18 | /** 19 | * @author Oliver Gierke 20 | */ 21 | public class SamplePluginHost { 22 | 23 | private PluginRegistry registry = SimplePluginRegistry.empty(); 24 | 25 | /** 26 | * @param registry the registry to set 27 | */ 28 | public void setRegistry(PluginRegistry registry) { 29 | this.registry = registry; 30 | } 31 | 32 | /** 33 | * @return the registry 34 | */ 35 | public PluginRegistry getRegistry() { 36 | return registry; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/test/java/org/springframework/plugin/core/SamplePluginImplementation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.plugin.core; 17 | 18 | /** 19 | * @author Oliver Gierke 20 | */ 21 | public class SamplePluginImplementation implements SamplePlugin { 22 | 23 | /* 24 | * (non-Javadoc) 25 | * @see org.springframework.plugin.core.Plugin#supports(java.lang.Object) 26 | */ 27 | public boolean supports(String delimiter) { 28 | return "FOO".equals(delimiter); 29 | } 30 | 31 | /* 32 | * (non-Javadoc) 33 | * @see org.springframework.plugin.core.SamplePlugin#pluginMethod() 34 | */ 35 | public void pluginMethod() { 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/test/java/org/springframework/plugin/core/SimplePluginRegistryUnitTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.plugin.core; 17 | 18 | import static org.assertj.core.api.Assertions.*; 19 | 20 | import java.util.ArrayList; 21 | import java.util.Arrays; 22 | import java.util.Collections; 23 | import java.util.List; 24 | 25 | import org.junit.jupiter.api.BeforeEach; 26 | import org.junit.jupiter.api.Test; 27 | 28 | /** 29 | * Unit test for {@link SimplePluginRegistry}. 30 | * 31 | * @author Oliver Gierke 32 | */ 33 | class SimplePluginRegistryUnitTest { 34 | 35 | SamplePlugin plugin; 36 | 37 | SimplePluginRegistry registry; 38 | 39 | /** 40 | * Initializes a {@code PluginRegistry} and equips it with an {@code EmailNotificationProvider}. 41 | */ 42 | @BeforeEach 43 | void setUp() { 44 | 45 | plugin = new SamplePluginImplementation(); 46 | registry = SimplePluginRegistry.empty(); 47 | } 48 | 49 | /** 50 | * Asserts that the registry contains the plugin it was initialized with. 51 | * 52 | * @throws Exception 53 | */ 54 | @Test 55 | void assertRegistryInitialized() throws Exception { 56 | 57 | registry = SimplePluginRegistry.of(plugin); 58 | 59 | assertThat(registry.countPlugins()).isEqualTo(1); 60 | assertThat(registry.contains(plugin)).isTrue(); 61 | } 62 | 63 | /** 64 | * Asserts asking for a plugin with the {@code PluginMetadata} provided by the {@link EmailNotificationProvider}. 65 | */ 66 | @Test 67 | void assertFindsEmailNotificationProvider() { 68 | 69 | registry = SimplePluginRegistry.of(plugin); 70 | 71 | String delimiter = "FOO"; 72 | 73 | List plugins = registry.getPluginsFor(delimiter); 74 | assertThat(plugins).isNotNull(); 75 | assertThat(plugins).hasSize(1); 76 | 77 | SamplePlugin provider = plugins.get(0); 78 | assertThat(provider).isInstanceOf(SamplePluginImplementation.class); 79 | } 80 | 81 | /** 82 | * Expects the given exception to be thrown if no {@link Plugin} found. 83 | */ 84 | @Test 85 | void throwsExceptionIfNoPluginFound() { 86 | 87 | assertThatIllegalArgumentException() 88 | .isThrownBy(() -> registry.getPluginFor("BAR", () -> new IllegalArgumentException())); 89 | } 90 | 91 | /** 92 | * Expects the given exception to be thrown if no {@link Plugin}s found. 93 | */ 94 | @Test 95 | void throwsExceptionIfNoPluginsFound() { 96 | 97 | assertThatIllegalArgumentException() 98 | .isThrownBy(() -> registry.getPluginsFor("BAR", () -> new IllegalArgumentException())); 99 | } 100 | 101 | /** 102 | * Expect the defualt plugin to be returned if none found. 103 | */ 104 | @Test 105 | void returnsDefaultIfNoneFound() { 106 | 107 | SamplePlugin defaultPlugin = new SamplePluginImplementation(); 108 | 109 | assertThat(registry.getPluginOrDefaultFor("BAR", defaultPlugin)).isEqualTo(defaultPlugin); 110 | } 111 | 112 | /** 113 | * Expect the given default plugins to be returned if none found. 114 | */ 115 | @Test 116 | void returnsDefaultsIfNoneFound() { 117 | 118 | List defaultPlugins = Arrays.asList(new SamplePluginImplementation()); 119 | 120 | List result = registry.getPluginsFor("BAR", defaultPlugins); 121 | assertThat(result).containsAll(defaultPlugins); 122 | } 123 | 124 | @Test 125 | void handlesAddingNullPluginsCorrecty() throws Exception { 126 | 127 | List plugins = new ArrayList(); 128 | plugins.add(null); 129 | 130 | registry = SimplePluginRegistry.of(plugins); 131 | 132 | assertThat(registry.countPlugins()).isEqualTo(0); 133 | } 134 | 135 | @Test // #19 136 | void throwsExceptionFromSupplier() throws Exception { 137 | 138 | registry = SimplePluginRegistry.empty(); 139 | 140 | assertThatIllegalStateException() 141 | .isThrownBy(() -> registry.getPluginFor("FOO", () -> new IllegalStateException())); 142 | } 143 | 144 | @Test // #41 145 | void throwsExceptionIfRequiredPluginIsNotFound() { 146 | 147 | registry = SimplePluginRegistry.empty(); 148 | 149 | assertThatIllegalArgumentException() 150 | .isThrownBy(() -> registry.getRequiredPluginFor("FOO")); 151 | } 152 | 153 | @Test // #41 154 | void throwsExceptionWithMessafeIfRequiredPluginIsNotFound() { 155 | 156 | registry = SimplePluginRegistry.of(Collections.emptyList()); 157 | 158 | assertThatIllegalArgumentException() 159 | .isThrownBy(() -> registry.getRequiredPluginFor("FOO", () -> "message")) 160 | .withMessage("message"); 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /core/src/test/java/org/springframework/plugin/core/config/EnablePluginRegistriesIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.plugin.core.config; 17 | 18 | import static org.assertj.core.api.Assertions.*; 19 | 20 | import org.junit.jupiter.api.Test; 21 | import org.junit.jupiter.api.extension.ExtendWith; 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | import org.springframework.beans.factory.annotation.Qualifier; 24 | import org.springframework.context.annotation.Bean; 25 | import org.springframework.context.annotation.Configuration; 26 | import org.springframework.plugin.core.Plugin; 27 | import org.springframework.plugin.core.PluginRegistry; 28 | import org.springframework.plugin.core.SamplePlugin; 29 | import org.springframework.plugin.core.SamplePluginImplementation; 30 | import org.springframework.test.context.ContextConfiguration; 31 | import org.springframework.test.context.junit.jupiter.SpringExtension; 32 | 33 | /** 34 | * Integration tests for {@link EnablePluginRegistries}. 35 | * 36 | * @author Oliver Gierke 37 | */ 38 | @ContextConfiguration 39 | @ExtendWith(SpringExtension.class) 40 | class EnablePluginRegistriesIntegrationTest { 41 | 42 | @Configuration 43 | @EnablePluginRegistries({ SamplePlugin.class, AnotherPlugin.class }) 44 | static class Config { 45 | 46 | @Bean 47 | public SamplePluginImplementation pluginImpl() { 48 | return new SamplePluginImplementation(); 49 | } 50 | } 51 | 52 | @Autowired PluginRegistry registry; 53 | 54 | @Test 55 | void registersPluginRegistries() { 56 | assertThat(registry).isNotNull(); 57 | } 58 | 59 | @Qualifier("myQualifier") 60 | interface AnotherPlugin extends Plugin {} 61 | 62 | static class AnotherSamplePluginImplementation implements AnotherPlugin { 63 | 64 | @Override 65 | public boolean supports(String delimiter) { 66 | return true; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /core/src/test/java/org/springframework/plugin/core/config/PluginConfigurationIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.plugin.core.config; 17 | 18 | import static org.assertj.core.api.Assertions.*; 19 | 20 | import org.junit.jupiter.api.Test; 21 | import org.junit.jupiter.api.extension.ExtendWith; 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | import org.springframework.context.annotation.Bean; 24 | import org.springframework.context.annotation.Configuration; 25 | import org.springframework.plugin.core.PluginRegistry; 26 | import org.springframework.plugin.core.SamplePlugin; 27 | import org.springframework.plugin.core.SamplePluginHost; 28 | import org.springframework.plugin.core.SamplePluginImplementation; 29 | import org.springframework.test.context.junit.jupiter.SpringExtension; 30 | 31 | /** 32 | * Integration test to simply check if the configuration gets parsed correctly. 33 | * 34 | * @author Oliver Gierke 35 | */ 36 | @ExtendWith(SpringExtension.class) 37 | class PluginConfigurationIntegrationTest { 38 | 39 | @Configuration 40 | @EnablePluginRegistries(SamplePlugin.class) 41 | static class Config { 42 | 43 | @Bean 44 | SamplePluginHost samplePluginHost(PluginRegistry registry) { 45 | 46 | var host = new SamplePluginHost(); 47 | host.setRegistry(registry); 48 | 49 | return host; 50 | } 51 | 52 | @Bean 53 | SamplePluginImplementation samplePluginImplementation() { 54 | return new SamplePluginImplementation(); 55 | } 56 | } 57 | 58 | @Autowired PluginRegistry pluginRegistry; 59 | @Autowired SamplePluginHost host; 60 | @Autowired SamplePlugin plugin; 61 | 62 | @Test 63 | void test() throws Exception { 64 | 65 | assertThat(pluginRegistry).isSameAs(host.getRegistry()); 66 | assertThat(pluginRegistry).contains(plugin); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /core/src/test/java/org/springframework/plugin/core/support/OrderAwarePluginRegistryIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package org.springframework.plugin.core.support; 2 | 3 | import static org.assertj.core.api.Assertions.*; 4 | 5 | import java.util.List; 6 | 7 | import org.junit.jupiter.api.Test; 8 | import org.junit.jupiter.api.extension.ExtendWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.context.ApplicationContext; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.Configuration; 13 | import org.springframework.core.Ordered; 14 | import org.springframework.core.annotation.Order; 15 | import org.springframework.plugin.core.OrderAwarePluginRegistry; 16 | import org.springframework.plugin.core.Plugin; 17 | import org.springframework.plugin.core.config.EnablePluginRegistries; 18 | import org.springframework.test.context.ContextConfiguration; 19 | import org.springframework.test.context.junit.jupiter.SpringExtension; 20 | 21 | /** 22 | * Integration test for {@link OrderAwarePluginRegistry}. 23 | * 24 | * @author Oliver Gierke 25 | */ 26 | @ExtendWith(SpringExtension.class) 27 | @ContextConfiguration 28 | class OrderAwarePluginRegistryIntegrationTest { 29 | 30 | @Configuration 31 | @EnablePluginRegistries(TestPlugin.class) 32 | static class Config { 33 | 34 | @Bean 35 | public FirstImplementation firstImplementation() { 36 | return new FirstImplementation(); 37 | } 38 | 39 | @Bean 40 | public SecondImplementation secondImplementation() { 41 | return new SecondImplementation(); 42 | } 43 | 44 | @Bean 45 | public ThirdImplementation thirdImplementation() { 46 | return new ThirdImplementation(); 47 | } 48 | } 49 | 50 | @Autowired ApplicationContext context; 51 | 52 | @Autowired FirstImplementation first; 53 | @Autowired SecondImplementation second; 54 | @Autowired ThirdImplementation third; 55 | 56 | @Autowired OrderAwarePluginRegistry registry; 57 | 58 | @Test 59 | void considersJdkProxiedOrderedImplementation() { 60 | 61 | List plugins = registry.getPlugins(); 62 | 63 | assertThat(plugins).hasSize(3); 64 | assertThat(plugins.get(0)).isEqualTo(second); 65 | assertThat(plugins.get(1)).isEqualTo(third); 66 | assertThat(plugins.get(2)).isEqualTo(first); 67 | 68 | plugins = registry.reverse().getPlugins(); 69 | 70 | assertThat(plugins.get(2)).isEqualTo(second); 71 | assertThat(plugins.get(1)).isEqualTo(third); 72 | assertThat(plugins.get(0)).isEqualTo(first); 73 | } 74 | 75 | private static interface TestPlugin extends Plugin { 76 | 77 | } 78 | 79 | @Order(5) 80 | private static class FirstImplementation implements TestPlugin { 81 | 82 | @Override 83 | public boolean supports(String delimiter) { 84 | 85 | return true; 86 | } 87 | } 88 | 89 | @Order(1) 90 | private static class SecondImplementation implements TestPlugin { 91 | 92 | @Override 93 | public boolean supports(String delimiter) { 94 | 95 | return true; 96 | } 97 | } 98 | 99 | private static class ThirdImplementation implements TestPlugin, Ordered { 100 | 101 | @Override 102 | public int getOrder() { 103 | return 3; 104 | } 105 | 106 | @Override 107 | public boolean supports(String delimiter) { 108 | return true; 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /core/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d %5p %40.40c:%4L - %m%n 7 | 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /etc/mappings.txt: -------------------------------------------------------------------------------- 1 | junit=JUnit 2 | logback=Logback 3 | mockito=Mockito 4 | slf4j=Slf4j 5 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Apache Maven Wrapper startup batch script, version 3.3.2 23 | # 24 | # Optional ENV vars 25 | # ----------------- 26 | # JAVA_HOME - location of a JDK home dir, required when download maven via java source 27 | # MVNW_REPOURL - repo url base for downloading maven distribution 28 | # MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven 29 | # MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output 30 | # ---------------------------------------------------------------------------- 31 | 32 | set -euf 33 | [ "${MVNW_VERBOSE-}" != debug ] || set -x 34 | 35 | # OS specific support. 36 | native_path() { printf %s\\n "$1"; } 37 | case "$(uname)" in 38 | CYGWIN* | MINGW*) 39 | [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")" 40 | native_path() { cygpath --path --windows "$1"; } 41 | ;; 42 | esac 43 | 44 | # set JAVACMD and JAVACCMD 45 | set_java_home() { 46 | # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched 47 | if [ -n "${JAVA_HOME-}" ]; then 48 | if [ -x "$JAVA_HOME/jre/sh/java" ]; then 49 | # IBM's JDK on AIX uses strange locations for the executables 50 | JAVACMD="$JAVA_HOME/jre/sh/java" 51 | JAVACCMD="$JAVA_HOME/jre/sh/javac" 52 | else 53 | JAVACMD="$JAVA_HOME/bin/java" 54 | JAVACCMD="$JAVA_HOME/bin/javac" 55 | 56 | if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then 57 | echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2 58 | echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2 59 | return 1 60 | fi 61 | fi 62 | else 63 | JAVACMD="$( 64 | 'set' +e 65 | 'unset' -f command 2>/dev/null 66 | 'command' -v java 67 | )" || : 68 | JAVACCMD="$( 69 | 'set' +e 70 | 'unset' -f command 2>/dev/null 71 | 'command' -v javac 72 | )" || : 73 | 74 | if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then 75 | echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2 76 | return 1 77 | fi 78 | fi 79 | } 80 | 81 | # hash string like Java String::hashCode 82 | hash_string() { 83 | str="${1:-}" h=0 84 | while [ -n "$str" ]; do 85 | char="${str%"${str#?}"}" 86 | h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296)) 87 | str="${str#?}" 88 | done 89 | printf %x\\n $h 90 | } 91 | 92 | verbose() { :; } 93 | [ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; } 94 | 95 | die() { 96 | printf %s\\n "$1" >&2 97 | exit 1 98 | } 99 | 100 | trim() { 101 | # MWRAPPER-139: 102 | # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds. 103 | # Needed for removing poorly interpreted newline sequences when running in more 104 | # exotic environments such as mingw bash on Windows. 105 | printf "%s" "${1}" | tr -d '[:space:]' 106 | } 107 | 108 | # parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties 109 | while IFS="=" read -r key value; do 110 | case "${key-}" in 111 | distributionUrl) distributionUrl=$(trim "${value-}") ;; 112 | distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;; 113 | esac 114 | done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties" 115 | [ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties" 116 | 117 | case "${distributionUrl##*/}" in 118 | maven-mvnd-*bin.*) 119 | MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ 120 | case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in 121 | *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;; 122 | :Darwin*x86_64) distributionPlatform=darwin-amd64 ;; 123 | :Darwin*arm64) distributionPlatform=darwin-aarch64 ;; 124 | :Linux*x86_64*) distributionPlatform=linux-amd64 ;; 125 | *) 126 | echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2 127 | distributionPlatform=linux-amd64 128 | ;; 129 | esac 130 | distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip" 131 | ;; 132 | maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;; 133 | *) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;; 134 | esac 135 | 136 | # apply MVNW_REPOURL and calculate MAVEN_HOME 137 | # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ 138 | [ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}" 139 | distributionUrlName="${distributionUrl##*/}" 140 | distributionUrlNameMain="${distributionUrlName%.*}" 141 | distributionUrlNameMain="${distributionUrlNameMain%-bin}" 142 | MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}" 143 | MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")" 144 | 145 | exec_maven() { 146 | unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || : 147 | exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD" 148 | } 149 | 150 | if [ -d "$MAVEN_HOME" ]; then 151 | verbose "found existing MAVEN_HOME at $MAVEN_HOME" 152 | exec_maven "$@" 153 | fi 154 | 155 | case "${distributionUrl-}" in 156 | *?-bin.zip | *?maven-mvnd-?*-?*.zip) ;; 157 | *) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;; 158 | esac 159 | 160 | # prepare tmp dir 161 | if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then 162 | clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; } 163 | trap clean HUP INT TERM EXIT 164 | else 165 | die "cannot create temp dir" 166 | fi 167 | 168 | mkdir -p -- "${MAVEN_HOME%/*}" 169 | 170 | # Download and Install Apache Maven 171 | verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." 172 | verbose "Downloading from: $distributionUrl" 173 | verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" 174 | 175 | # select .zip or .tar.gz 176 | if ! command -v unzip >/dev/null; then 177 | distributionUrl="${distributionUrl%.zip}.tar.gz" 178 | distributionUrlName="${distributionUrl##*/}" 179 | fi 180 | 181 | # verbose opt 182 | __MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR='' 183 | [ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v 184 | 185 | # normalize http auth 186 | case "${MVNW_PASSWORD:+has-password}" in 187 | '') MVNW_USERNAME='' MVNW_PASSWORD='' ;; 188 | has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;; 189 | esac 190 | 191 | if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then 192 | verbose "Found wget ... using wget" 193 | wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl" 194 | elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then 195 | verbose "Found curl ... using curl" 196 | curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl" 197 | elif set_java_home; then 198 | verbose "Falling back to use Java to download" 199 | javaSource="$TMP_DOWNLOAD_DIR/Downloader.java" 200 | targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName" 201 | cat >"$javaSource" <<-END 202 | public class Downloader extends java.net.Authenticator 203 | { 204 | protected java.net.PasswordAuthentication getPasswordAuthentication() 205 | { 206 | return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() ); 207 | } 208 | public static void main( String[] args ) throws Exception 209 | { 210 | setDefault( new Downloader() ); 211 | java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() ); 212 | } 213 | } 214 | END 215 | # For Cygwin/MinGW, switch paths to Windows format before running javac and java 216 | verbose " - Compiling Downloader.java ..." 217 | "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java" 218 | verbose " - Running Downloader.java ..." 219 | "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")" 220 | fi 221 | 222 | # If specified, validate the SHA-256 sum of the Maven distribution zip file 223 | if [ -n "${distributionSha256Sum-}" ]; then 224 | distributionSha256Result=false 225 | if [ "$MVN_CMD" = mvnd.sh ]; then 226 | echo "Checksum validation is not supported for maven-mvnd." >&2 227 | echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 228 | exit 1 229 | elif command -v sha256sum >/dev/null; then 230 | if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then 231 | distributionSha256Result=true 232 | fi 233 | elif command -v shasum >/dev/null; then 234 | if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then 235 | distributionSha256Result=true 236 | fi 237 | else 238 | echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 239 | echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2 240 | exit 1 241 | fi 242 | if [ $distributionSha256Result = false ]; then 243 | echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2 244 | echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2 245 | exit 1 246 | fi 247 | fi 248 | 249 | # unzip and move 250 | if command -v unzip >/dev/null; then 251 | unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip" 252 | else 253 | tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar" 254 | fi 255 | printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url" 256 | mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME" 257 | 258 | clean || : 259 | exec_maven "$@" 260 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | <# : batch portion 2 | @REM ---------------------------------------------------------------------------- 3 | @REM Licensed to the Apache Software Foundation (ASF) under one 4 | @REM or more contributor license agreements. See the NOTICE file 5 | @REM distributed with this work for additional information 6 | @REM regarding copyright ownership. The ASF licenses this file 7 | @REM to you under the Apache License, Version 2.0 (the 8 | @REM "License"); you may not use this file except in compliance 9 | @REM with the License. You may obtain a copy of the License at 10 | @REM 11 | @REM http://www.apache.org/licenses/LICENSE-2.0 12 | @REM 13 | @REM Unless required by applicable law or agreed to in writing, 14 | @REM software distributed under the License is distributed on an 15 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | @REM KIND, either express or implied. See the License for the 17 | @REM specific language governing permissions and limitations 18 | @REM under the License. 19 | @REM ---------------------------------------------------------------------------- 20 | 21 | @REM ---------------------------------------------------------------------------- 22 | @REM Apache Maven Wrapper startup batch script, version 3.3.2 23 | @REM 24 | @REM Optional ENV vars 25 | @REM MVNW_REPOURL - repo url base for downloading maven distribution 26 | @REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven 27 | @REM MVNW_VERBOSE - true: enable verbose log; others: silence the output 28 | @REM ---------------------------------------------------------------------------- 29 | 30 | @IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0) 31 | @SET __MVNW_CMD__= 32 | @SET __MVNW_ERROR__= 33 | @SET __MVNW_PSMODULEP_SAVE=%PSModulePath% 34 | @SET PSModulePath= 35 | @FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @( 36 | IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B) 37 | ) 38 | @SET PSModulePath=%__MVNW_PSMODULEP_SAVE% 39 | @SET __MVNW_PSMODULEP_SAVE= 40 | @SET __MVNW_ARG0_NAME__= 41 | @SET MVNW_USERNAME= 42 | @SET MVNW_PASSWORD= 43 | @IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*) 44 | @echo Cannot start maven from wrapper >&2 && exit /b 1 45 | @GOTO :EOF 46 | : end batch / begin powershell #> 47 | 48 | $ErrorActionPreference = "Stop" 49 | if ($env:MVNW_VERBOSE -eq "true") { 50 | $VerbosePreference = "Continue" 51 | } 52 | 53 | # calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties 54 | $distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl 55 | if (!$distributionUrl) { 56 | Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties" 57 | } 58 | 59 | switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) { 60 | "maven-mvnd-*" { 61 | $USE_MVND = $true 62 | $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip" 63 | $MVN_CMD = "mvnd.cmd" 64 | break 65 | } 66 | default { 67 | $USE_MVND = $false 68 | $MVN_CMD = $script -replace '^mvnw','mvn' 69 | break 70 | } 71 | } 72 | 73 | # apply MVNW_REPOURL and calculate MAVEN_HOME 74 | # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-,maven-mvnd--}/ 75 | if ($env:MVNW_REPOURL) { 76 | $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" } 77 | $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')" 78 | } 79 | $distributionUrlName = $distributionUrl -replace '^.*/','' 80 | $distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$','' 81 | $MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain" 82 | if ($env:MAVEN_USER_HOME) { 83 | $MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain" 84 | } 85 | $MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join '' 86 | $MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME" 87 | 88 | if (Test-Path -Path "$MAVEN_HOME" -PathType Container) { 89 | Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME" 90 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 91 | exit $? 92 | } 93 | 94 | if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) { 95 | Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl" 96 | } 97 | 98 | # prepare tmp dir 99 | $TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile 100 | $TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir" 101 | $TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null 102 | trap { 103 | if ($TMP_DOWNLOAD_DIR.Exists) { 104 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 105 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 106 | } 107 | } 108 | 109 | New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null 110 | 111 | # Download and Install Apache Maven 112 | Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..." 113 | Write-Verbose "Downloading from: $distributionUrl" 114 | Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName" 115 | 116 | $webclient = New-Object System.Net.WebClient 117 | if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) { 118 | $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD) 119 | } 120 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 121 | $webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null 122 | 123 | # If specified, validate the SHA-256 sum of the Maven distribution zip file 124 | $distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum 125 | if ($distributionSha256Sum) { 126 | if ($USE_MVND) { 127 | Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." 128 | } 129 | Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash 130 | if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) { 131 | Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property." 132 | } 133 | } 134 | 135 | # unzip and move 136 | Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null 137 | Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null 138 | try { 139 | Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null 140 | } catch { 141 | if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) { 142 | Write-Error "fail to move MAVEN_HOME" 143 | } 144 | } finally { 145 | try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null } 146 | catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" } 147 | } 148 | 149 | Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD" 150 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | org.springframework.plugin 5 | spring-plugin 6 | pom 7 | Spring Plugin 8 | 4.0.0-SNAPSHOT 9 | Simple plugin infrastructure 10 | 11 | 12 | VMware, Inc. 13 | https://www.vmware.com 14 | 15 | 2008 16 | https://github.com/spring-projects/spring-plugin 17 | 18 | 19 | 20 | Apache License, Version 2.0 21 | https://www.apache.org/licenses/LICENSE-2.0 22 | 23 | Copyright 2010-2022 the original author or authors. 24 | 25 | Licensed under the Apache License, Version 2.0 (the "License"); 26 | you may not use this file except in compliance with the License. 27 | You may obtain a copy of the License at 28 | 29 | https://www.apache.org/licenses/LICENSE-2.0 30 | 31 | Unless required by applicable law or agreed to in writing, software 32 | distributed under the License is distributed on an "AS IS" BASIS, 33 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 34 | implied. 35 | See the License for the specific language governing permissions and 36 | limitations under the License. 37 | 38 | 39 | 40 | 41 | 42 | core 43 | 44 | 45 | 46 | UTF-8 47 | 48 | 3.27.3 49 | 2.36.0 50 | 5.12.2 51 | 1.5.18 52 | 5.17.0 53 | 0.12.3 54 | 7.0.0-M4 55 | 17 56 | 2.0.17 57 | 58 | 3.4.0 59 | 60 | spring.plugin 61 | 62 | 63 | 64 | 65 | drotbohm 66 | Oliver Drotbohm 67 | odrotbohm@vmware.com 68 | VMware 69 | https://www.spring.io 70 | 71 | Project lead 72 | 73 | +1 74 | 75 | 76 | 77 | 78 | 79 | 80 | spring-next 81 | 82 | 7.0.0-SNAPSHOT 83 | 84 | 85 | 86 | spring-snapshots 87 | https://repo.spring.io/snapshot 88 | 89 | 90 | 91 | 92 | 93 | 94 | ci 95 | 96 | 97 | 98 | 99 | 100 | org.apache.maven.plugins 101 | maven-javadoc-plugin 102 | 3.11.2 103 | 104 | 105 | create-javadoc-jar 106 | 107 | jar 108 | 109 | package 110 | 111 | 112 | 113 | 114 | -Xdoclint:none 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | artifactory 125 | 126 | true 127 | 128 | 129 | 130 | 131 | org.jfrog.buildinfo 132 | artifactory-maven-plugin 133 | ${artifactory-maven-plugin.version} 134 | false 135 | 136 | 137 | deploy-to-artifactory 138 | 139 | publish 140 | 141 | 142 | 143 | https://repo.spring.io 144 | ${env.ARTIFACTORY_USERNAME} 145 | ${env.ARTIFACTORY_PASSWORD} 146 | libs-milestone-local 147 | libs-snapshot-local 148 | 149 | 150 | CI build for Spring Plugin ${project.version} 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | sonatype 162 | 163 | true 164 | 165 | 166 | 167 | 168 | org.apache.maven.plugins 169 | maven-gpg-plugin 170 | 3.2.7 171 | 172 | 173 | sign-artifacts 174 | verify 175 | 176 | sign 177 | 178 | 179 | 180 | 181 | ${env.GPG_PASSPHRASE} 182 | 183 | 184 | 185 | 186 | 187 | 188 | sonatype-new 189 | https://s01.oss.sonatype.org/service/local/staging/deploy/maven2 190 | 191 | 192 | 193 | 194 | 195 | nullaway 196 | 197 | 198 | 199 | org.apache.maven.plugins 200 | maven-compiler-plugin 201 | 202 | true 203 | 204 | 205 | com.google.errorprone 206 | error_prone_core 207 | ${errorprone.version} 208 | 209 | 210 | com.uber.nullaway 211 | nullaway 212 | ${nullaway.version} 213 | 214 | 215 | 216 | 217 | 218 | default-compile 219 | none 220 | 221 | 222 | default-testCompile 223 | none 224 | 225 | 226 | java-compile 227 | compile 228 | 229 | compile 230 | 231 | 232 | 233 | -XDcompilePolicy=simple 234 | --should-stop=ifError=FLOW 235 | -Xplugin:ErrorProne -XepDisableAllChecks -Xep:NullAway:ERROR -XepOpt:NullAway:OnlyNullMarked=true -XepOpt:NullAway:CustomContractAnnotations=org.springframework.lang.Contract 236 | 237 | 238 | 239 | 240 | java-test-compile 241 | test-compile 242 | 243 | testCompile 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | org.junit.jupiter 260 | junit-jupiter 261 | ${junit.version} 262 | test 263 | 264 | 265 | 266 | org.assertj 267 | assertj-core 268 | ${assertj.version} 269 | test 270 | 271 | 272 | 273 | org.mockito 274 | mockito-core 275 | ${mockito.version} 276 | test 277 | 278 | 279 | 280 | org.mockito 281 | mockito-junit-jupiter 282 | ${mockito.version} 283 | test 284 | 285 | 286 | 287 | 288 | org.slf4j 289 | slf4j-api 290 | ${slf4j.version} 291 | 292 | 293 | 294 | org.jspecify 295 | jspecify 296 | 1.0.0 297 | 298 | 299 | 300 | org.slf4j 301 | jcl-over-slf4j 302 | ${slf4j.version} 303 | test 304 | 305 | 306 | 307 | ch.qos.logback 308 | logback-classic 309 | ${logback.version} 310 | test 311 | 312 | 313 | 314 | 315 | 316 | 317 | verify 318 | 319 | 320 | 321 | org.apache.maven.plugins 322 | maven-compiler-plugin 323 | 3.13.0 324 | 325 | ${source.level} 326 | 327 | 328 | 329 | 330 | org.apache.maven.plugins 331 | maven-surefire-plugin 332 | 3.5.2 333 | 334 | 335 | 336 | org.apache.maven.plugins 337 | maven-source-plugin 338 | 3.2.1 339 | 340 | 341 | attach-sources 342 | 343 | jar 344 | 345 | 346 | 347 | 348 | 349 | 350 | org.apache.maven.plugins 351 | maven-jar-plugin 352 | 3.4.2 353 | 354 | 355 | 356 | ${project.name} 357 | ${project.version} 358 | ${java-module-name} 359 | 360 | 361 | 362 | 363 | 364 | 365 | org.codehaus.mojo 366 | flatten-maven-plugin 367 | 1.6.0 368 | 369 | 370 | flatten 371 | process-resources 372 | 373 | flatten 374 | 375 | 376 | true 377 | oss 378 | 379 | remove 380 | remove 381 | remove 382 | remove 383 | 384 | 385 | 386 | 387 | flatten-clean 388 | clean 389 | 390 | clean 391 | 392 | 393 | 394 | 395 | 396 | 397 | org.apache.maven.plugins 398 | maven-release-plugin 399 | 3.1.1 400 | 401 | sonatype 402 | true 403 | false 404 | @{project.version} 405 | true 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | https://github.com/spring-projects/spring-plugin 414 | scm:git:git://github.com/spring-projects/spring-plugin.git 415 | scm:git:ssh://git@github.com:spring-projects/spring-plugin.git 416 | HEAD 417 | 418 | 419 | 420 | Bamboo 421 | https://build.springsource.org/browse/PLUGIN-MASTER 422 | 423 | 424 | 425 | Github 426 | https://github.com/spring-projects/spring-plugin/issues 427 | 428 | 429 | 430 | 431 | spring-milestone 432 | https://repo.spring.io/milestone 433 | 434 | false 435 | 436 | 437 | 438 | spring-snapshot 439 | https://repo.spring.io/snapshot 440 | 441 | false 442 | 443 | 444 | 445 | 446 | 447 | -------------------------------------------------------------------------------- /settings.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | sonatype-new 8 | ${env.SONATYPE_USER} 9 | ${env.SONATYPE_PASSWORD} 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/resources/license.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | https://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | https://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | ======================================================================= 204 | 205 | To the extent any open source subcomponents are licensed under the EPL and/or other 206 | similar licenses that require the source code and/or modifications to 207 | source code to be made available (as would be noted above), you may obtain a 208 | copy of the source code corresponding to the binaries for such open source 209 | components and modifications thereto, if any, (the "Source Files"), by 210 | downloading the Source Files from https://www.springsource.org/download, 211 | or by sending a request, with your name and address to: VMware, Inc., 3401 Hillview 212 | Avenue, Palo Alto, CA 94304, United States of America or email info@vmware.com. All 213 | such requests should clearly specify: OPEN SOURCE FILES REQUEST, Attention General 214 | Counsel. VMware shall mail a copy of the Source Files to you on a CD or equivalent 215 | physical medium. This offer to obtain a copy of the Source Files is valid for three 216 | years from the date you acquired this Software product. 217 | -------------------------------------------------------------------------------- /src/main/resources/notice.txt: -------------------------------------------------------------------------------- 1 | ${project.name} ${project.version} 2 | Copyright (c) [2008-2019] Pivotal Software, Inc. 3 | 4 | This product is licensed to you under the Apache License, Version 2.0 (the "License"). 5 | You may not use this product except in compliance with the License. 6 | 7 | This product may include a number of subcomponents with 8 | separate copyright notices and license terms. Your use of the source 9 | code for the these subcomponents is subject to the terms and 10 | conditions of the subcomponent's license, as noted in the LICENSE file. 11 | --------------------------------------------------------------------------------