diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml
new file mode 100644
index 000000000..be4b92dfc
--- /dev/null
+++ b/.github/workflows/deploy-docs.yml
@@ -0,0 +1,32 @@
+name: Deploy Docs
+on:
+ push:
+ branches-ignore: [ gh-pages ]
+ tags: '**'
+ repository_dispatch:
+ types: request-build-reference # legacy
+ #schedule:
+ #- cron: '0 10 * * *' # Once per day at 10am UTC
+ workflow_dispatch:
+permissions:
+ actions: write
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ # if: github.repository_owner == 'spring-cloud'
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ with:
+ ref: docs-build
+ fetch-depth: 1
+ - name: Dispatch (partial build)
+ if: github.ref_type == 'branch'
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD) -f build-refname=${{ github.ref_name }}
+ - name: Dispatch (full build)
+ if: github.ref_type == 'tag'
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: gh workflow run deploy-docs.yml -r $(git rev-parse --abbrev-ref HEAD)
diff --git a/.gitignore b/.gitignore
index 84d578d91..393da56de 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,9 @@ _site/
.DS_Store
.vscode/
.flattened-pom.xml
+
+node
+node_modules
+build
+package.json
+package-lock.json
diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
index 56bb0164e..6686a643d 100644
--- a/.mvn/wrapper/maven-wrapper.properties
+++ b/.mvn/wrapper/maven-wrapper.properties
@@ -1 +1,18 @@
-distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
\ No newline at end of file
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.0/apache-maven-3.9.0-bin.zip
+wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
diff --git a/README.adoc b/README.adoc
index ba34bba3e..b2d1f90e2 100644
--- a/README.adoc
+++ b/README.adoc
@@ -5,300 +5,32 @@ Edit the files in the src/main/asciidoc/ directory instead.
////
-image::https://travis-ci.org/spring-cloud/spring-cloud-zookeeper.svg?branch=master[Build Status, link=https://travis-ci.org/spring-cloud/spring-cloud-zookeeper]
+image::https://github.com/spring-cloud/spring-cloud-zookeeper/workflows/Build/badge.svg?style=svg["Actions Status", link="https://github.com/spring-cloud/spring-cloud-zookeeper/actions"]
-:doctype: book
-:idprefix:
-:idseparator: -
-:toc: left
-:toclevels: 4
-:tabsize: 4
-:numbered:
-:sectanchors:
-:sectnums:
-:icons: font
-:hide-uri-scheme:
-:docinfo: shared,private
+[[quick-start]]
+= Quick Start
-:sc-ext: java
-:project-full-name: Spring Cloud Zookeeper
-This project provides Zookeeper integrations for Spring Boot applications through
-autoconfiguration and binding to the Spring Environment and other Spring programming model
-idioms. With a few annotations, you can quickly enable and configure the common patterns
-inside your application and build large distributed systems with Zookeeper based
-components. The provided patterns include Service Discovery and Configuration. The project
-also provides client-side load-balancing via integration with Spring Cloud LoadBalancer.
-
-
-:doctype: book
-:idprefix:
-:idseparator: -
-:toc: left
-:toclevels: 4
-:tabsize: 4
-:numbered:
-:sectanchors:
-:sectnums:
-:icons: font
-:hide-uri-scheme:
-:docinfo: shared,private
-
-:sc-ext: java
-:project-full-name: Spring Cloud Zookeeper
-
-== Quick Start
-
-This quick start walks through using Spring Cloud Zookeeper for Service Discovery and Distributed Configuration.
-
-First, run Zookeeper on your machine. Then you can access it and use it as a Service Registry and Configuration source with Spring Cloud Zookeeper.
-
-=== Discovery Client Usage
-
-To use these features in an application, you can build it as a Spring Boot application that depends on `spring-cloud-zookeeper-core` and `spring-cloud-zookeeper-discovery`.
-The most convenient way to add the dependency is with a Spring Boot starter: `org.springframework.cloud:spring-cloud-starter-zookeeper-discovery`.
-We recommend using dependency management and `spring-boot-starter-parent`.
-The following example shows a typical Maven configuration:
-
-[source,xml,indent=0]
-.pom.xml
-----
-
-
- org.springframework.boot
- spring-boot-starter-parent
- {spring-boot-version}
-
-
-
-
-
- org.springframework.cloud
- spring-cloud-starter-zookeeper-discovery
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
-
- org.springframework.cloud
- spring-cloud-dependencies
- ${spring-cloud.version}
- pom
- import
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
-----
-
-The following example shows a typical Gradle setup:
-
-[source,groovy,indent=0]
-.build.gradle
-----
-plugins {
- id 'org.springframework.boot' version ${spring-boot-version}
- id 'io.spring.dependency-management' version ${spring-dependency-management-version}
- id 'java'
-}
-
-repositories {
- mavenCentral()
-}
-
-dependencies {
- implementation 'org.springframework.cloud:spring-cloud-starter-zookeeper-discovery'
- testImplementation 'org.springframework.boot:spring-boot-starter-test'
-}
-dependencyManagement {
- imports {
- mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
- }
-}
-----
-
-WARNING: Depending on the version you are using, you might need to adjust Apache Zookeeper version used in your project.
-You can read more about it in the <>.
-
-Now you can create a standard Spring Boot application, such as the following HTTP server:
-
-----
-@SpringBootApplication
-@RestController
-public class Application {
-
- @GetMapping("/")
- public String home() {
- return "Hello World!";
- }
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-
-}
-----
-
-When this HTTP server runs, it connects to Zookeeper, which runs on the default local port (2181).
-To modify the startup behavior, you can change the location of Zookeeper by using `application.properties`, as shown in the following example:
-
-----
-spring:
- cloud:
- zookeeper:
- connect-string: localhost:2181
-----
-
-You can now use `DiscoveryClient`, `@LoadBalanced RestTemplate`, or `@LoadBalanced WebClient.Builder` to retrieve services and instances data from Zookeeper, as shown in the following example:
-
-[source,java,indent=0]
-----
-@Autowired
-private DiscoveryClient discoveryClient;
-
-public String serviceUrl() {
- List list = discoveryClient.getInstances("STORES");
- if (list != null && list.size() > 0 ) {
- return list.get(0).getUri().toString();
- }
- return null;
-}
-----
-
-=== Distributed Configuration Usage
-
-To use these features in an application, you can build it as a Spring Boot application that depends on `spring-cloud-zookeeper-core` and `spring-cloud-zookeeper-config`.
-The most convenient way to add the dependency is with a Spring Boot starter: `org.springframework.cloud:spring-cloud-starter-zookeeper-config`.
-We recommend using dependency management and `spring-boot-starter-parent`.
-The following example shows a typical Maven configuration:
-
-[source,xml,indent=0]
-.pom.xml
-----
-
-
- org.springframework.boot
- spring-boot-starter-parent
- {spring-boot-version}
-
-
-
-
-
- org.springframework.cloud
- spring-cloud-starter-zookeeper-config
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
-
- org.springframework.cloud
- spring-cloud-dependencies
- ${spring-cloud.version}
- pom
- import
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
-----
-
-The following example shows a typical Gradle setup:
-
-[source,groovy,indent=0]
-.build.gradle
-----
-plugins {
- id 'org.springframework.boot' version ${spring-boot-version}
- id 'io.spring.dependency-management' version ${spring-dependency-management-version}
- id 'java'
-}
-
-repositories {
- mavenCentral()
-}
-
-dependencies {
- implementation 'org.springframework.cloud:spring-cloud-starter-zookeeper-config'
- testImplementation 'org.springframework.boot:spring-boot-starter-test'
-}
-dependencyManagement {
- imports {
- mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
- }
-}
-----
-
-WARNING: Depending on the version you are using, you might need to adjust Apache Zookeeper version used in your project.
-You can read more about it in the <>.
-
-Now you can create a standard Spring Boot application, such as the following HTTP server:
-
-----
-@SpringBootApplication
-@RestController
-public class Application {
-
- @GetMapping("/")
- public String home() {
- return "Hello World!";
- }
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-
-}
-----
-
-The application retrieves configuration data from Zookeeper.
-
-WARNING: If you use Spring Cloud Zookeeper Config, you need to set the `spring.config.import` property in order to bind to Zookeeper.
-You can read more about it in the <>.
-
-== Zookeeper overview
+[[zookeeper-overview]]
+= Zookeeper overview
ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services.
See the
https://zookeeper.apache.org[Zookeeper site] for more information.
Spring Cloud Zookeeper also builds on the https://curator.apache.org[Apache Curator] project, which started life at Netflix.
-== Spring Cloud Zookeeper Features
+[[spring-cloud-zookeeper-features]]
+= Spring Cloud Zookeeper Features
Spring Cloud Zookeeper includes the following features:
* Spring Cloud `DiscoveryClient` implementation (supports Spring Cloud LoadBalancer)
* Zookeeper-based `PropertySource` loaded during the 'bootstrap' phase
-== Running the Sample
+[[running-the-sample]]
+= Running the Sample
. https://zookeeper.apache.org/doc/current/zookeeperStarted.html#sc_Download[Install
zookeeper] (On a mac with homebrew, use `brew install zookeeper`).
@@ -313,11 +45,13 @@ Doing so brings in the required Spring Cloud Maven repositories and Build.
. Run `java -jar spring-cloud-zookeeper-sample/target/spring-cloud-zookeeper-sample-1.2.0.BUILD-SNAPSHOT.jar --server.port=8081`
. Visit http://localhost:8080 again to verify that `{"serviceId":"testZookeeperApp","host":"","port":8081}` eventually shows up in the results in a round-robin fashion. (It may take a minute or so.)
-== Building
+[[building]]
+= Building
:jdkversion: 17
-=== Basic Compile and Test
+[[basic-compile-and-test]]
+== Basic Compile and Test
To build the source you will need to install JDK {jdkversion}.
@@ -344,31 +78,36 @@ source control.
The projects that require middleware (i.e. Redis) for testing generally
require that a local instance of [Docker](https://www.docker.com/get-started) is installed and running.
-
-=== Documentation
+[[documentation]]
+== Documentation
The spring-cloud-build module has a "docs" profile, and if you switch
-that on it will try to build asciidoc sources from
-`src/main/asciidoc`. As part of that process it will look for a
-`README.adoc` and process it by loading all the includes, but not
+that on it will try to build asciidoc sources using https://docs.antora.org/antora/latest/[Antora] from
+`modules/ROOT/`.
+
+As part of that process it will look for a
+`docs/src/main/asciidoc/README.adoc` and process it by loading all the includes, but not
parsing or rendering it, just copying it to `${main.basedir}`
-(defaults to `${basedir}`, i.e. the root of the project). If there are
+(defaults to `$\{basedir}`, i.e. the root of the project). If there are
any changes in the README it will then show up after a Maven build as
a modified file in the correct place. Just commit it and push the change.
-=== Working with the code
+[[working-with-the-code]]
+== Working with the code
If you don't have an IDE preference we would recommend that you use
https://www.springsource.com/developer/sts[Spring Tools Suite] or
https://eclipse.org[Eclipse] when working with the code. We use the
https://eclipse.org/m2e/[m2eclipse] eclipse plugin for maven support. Other IDEs and tools
should also work without issue as long as they use Maven 3.3.3 or better.
-==== Activate the Spring Maven profile
+[[activate-the-spring-maven-profile]]
+=== Activate the Spring Maven profile
Spring Cloud projects require the 'spring' Maven profile to be activated to resolve
the spring milestone and snapshot repositories. Use your preferred IDE to set this
profile to be active, or you may experience build errors.
-==== Importing into eclipse with m2eclipse
+[[importing-into-eclipse-with-m2eclipse]]
+=== Importing into eclipse with m2eclipse
We recommend the https://eclipse.org/m2e/[m2eclipse] eclipse plugin when working with
eclipse. If you don't already have m2eclipse installed it is available from the "eclipse
marketplace".
@@ -382,7 +121,8 @@ add the "spring" profile to your `settings.xml`. Alternatively you can
copy the repository settings from the "spring" profile of the parent
pom into your `settings.xml`.
-==== Importing into eclipse without m2eclipse
+[[importing-into-eclipse-without-m2eclipse]]
+=== Importing into eclipse without m2eclipse
If you prefer not to use m2eclipse you can generate eclipse project metadata using the
following command:
@@ -395,17 +135,20 @@ The generated eclipse projects can be imported by selecting `import existing pro
from the `file` menu.
-== Contributing
+[[contributing]]
+= Contributing
-:spring-cloud-build-branch: master
+:spring-cloud-build-branch: main
Spring Cloud is released under the non-restrictive Apache 2.0 license,
and follows a very standard Github development process, using Github
-tracker for issues and merging pull requests into master. If you want
+tracker for issues and merging pull requests into main. If you want
to contribute even something trivial please do not hesitate, but
follow the guidelines below.
-=== Sign the Contributor License Agreement
+[[sign-the-contributor-license-agreement]]
+== Sign the Contributor License Agreement
+
Before we accept a non-trivial patch or pull request we will need you to sign the
https://cla.pivotal.io/sign/spring[Contributor License Agreement].
Signing the contributor's agreement does not grant anyone commit rights to the main
@@ -413,19 +156,21 @@ repository, but it does mean that we can accept your contributions, and you will
author credit if we do. Active contributors might be asked to join the core team, and
given the ability to merge pull requests.
-=== Code of Conduct
-This project adheres to the Contributor Covenant https://github.com/spring-cloud/spring-cloud-build/blob/master/docs/src/main/asciidoc/code-of-conduct.adoc[code of
+[[code-of-conduct]]
+== Code of Conduct
+This project adheres to the Contributor Covenant https://github.com/spring-cloud/spring-cloud-build/blob/main/docs/src/main/asciidoc/code-of-conduct.adoc[code of
conduct]. By participating, you are expected to uphold this code. Please report
unacceptable behavior to spring-code-of-conduct@pivotal.io.
-=== Code Conventions and Housekeeping
+[[code-conventions-and-housekeeping]]
+== Code Conventions and Housekeeping
None of these is essential for a pull request, but they will all help. They can also be
added after the original pull request but before a merge.
* Use the Spring Framework code format conventions. If you use Eclipse
you can import formatter settings using the
`eclipse-code-formatter.xml` file from the
- https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-dependencies-parent/eclipse-code-formatter.xml[Spring
+ https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/spring-cloud-dependencies-parent/eclipse-code-formatter.xml[Spring
Cloud Build] project. If using IntelliJ, you can use the
https://plugins.jetbrains.com/plugin/6546[Eclipse Code Formatter
Plugin] to import the same file.
@@ -438,13 +183,14 @@ added after the original pull request but before a merge.
than cosmetic changes).
* Add some Javadocs and, if you change the namespace, some XSD doc elements.
* A few unit tests would help a lot as well -- someone has to do it.
-* If no-one else is using your branch, please rebase it against the current master (or
+* If no-one else is using your branch, please rebase it against the current main (or
other target branch in the main project).
* When writing a commit message please follow https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html[these conventions],
if you are fixing an existing issue please add `Fixes gh-XXXX` at the end of the commit
message (where XXXX is the issue number).
-=== Checkstyle
+[[checkstyle]]
+== Checkstyle
Spring Cloud Build comes with a set of checkstyle rules. You can find them in the `spring-cloud-build-tools` module. The most notable files under the module are:
@@ -462,7 +208,8 @@ Spring Cloud Build comes with a set of checkstyle rules. You can find them in th
<2> File header setup
<3> Default suppression rules
-==== Checkstyle configuration
+[[checkstyle-configuration]]
+=== Checkstyle configuration
Checkstyle rules are *disabled by default*. To add checkstyle to your project just define the following properties and plugins.
@@ -521,16 +268,18 @@ If you need to suppress some rules (e.g. line length needs to be longer), then i
It's advisable to copy the `${spring-cloud-build.rootFolder}/.editorconfig` and `${spring-cloud-build.rootFolder}/.springformat` to your project. That way, some default formatting rules will be applied. You can do so by running this script:
```bash
-$ curl https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/.editorconfig -o .editorconfig
+$ curl https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/.editorconfig -o .editorconfig
$ touch .springformat
```
-=== IDE setup
+[[ide-setup]]
+== IDE setup
-==== Intellij IDEA
+[[intellij-idea]]
+=== Intellij IDEA
In order to setup Intellij you should import our coding conventions, inspection profiles and set up the checkstyle plugin.
-The following files can be found in the https://github.com/spring-cloud/spring-cloud-build/tree/master/spring-cloud-build-tools[Spring Cloud Build] project.
+The following files can be found in the https://github.com/spring-cloud/spring-cloud-build/tree/main/spring-cloud-build-tools[Spring Cloud Build] project.
.spring-cloud-build-tools/
----
@@ -553,13 +302,13 @@ The following files can be found in the https://github.com/spring-cloud/spring-c
.Code style
-image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-code-style.png[Code style]
+image::intellij-code-style.png[Code style]
Go to `File` -> `Settings` -> `Editor` -> `Code style`. There click on the icon next to the `Scheme` section. There, click on the `Import Scheme` value and pick the `Intellij IDEA code style XML` option. Import the `spring-cloud-build-tools/src/main/resources/intellij/Intellij_Spring_Boot_Java_Conventions.xml` file.
.Inspection profiles
-image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-inspections.png[Code style]
+image::intellij-inspections.png[Code style]
Go to `File` -> `Settings` -> `Editor` -> `Inspections`. There click on the icon next to the `Profile` section. There, click on the `Import Profile` and import the `spring-cloud-build-tools/src/main/resources/intellij/Intellij_Project_Defaults.xml` file.
@@ -567,21 +316,23 @@ Go to `File` -> `Settings` -> `Editor` -> `Inspections`. There click on the icon
To have Intellij work with Checkstyle, you have to install the `Checkstyle` plugin. It's advisable to also install the `Assertions2Assertj` to automatically convert the JUnit assertions
-image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring-cloud-build-branch}/docs/src/main/asciidoc/images/intellij-checkstyle.png[Checkstyle]
+image::intellij-checkstyle.png[Checkstyle]
-Go to `File` -> `Settings` -> `Other settings` -> `Checkstyle`. There click on the `+` icon in the `Configuration file` section. There, you'll have to define where the checkstyle rules should be picked from. In the image above, we've picked the rules from the cloned Spring Cloud Build repository. However, you can point to the Spring Cloud Build's GitHub repository (e.g. for the `checkstyle.xml` : `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle.xml`). We need to provide the following variables:
+Go to `File` -> `Settings` -> `Other settings` -> `Checkstyle`. There click on the `+` icon in the `Configuration file` section. There, you'll have to define where the checkstyle rules should be picked from. In the image above, we've picked the rules from the cloned Spring Cloud Build repository. However, you can point to the Spring Cloud Build's GitHub repository (e.g. for the `checkstyle.xml` : `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/spring-cloud-build-tools/src/main/resources/checkstyle.xml`). We need to provide the following variables:
-- `checkstyle.header.file` - please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` URL.
-- `checkstyle.suppressions.file` - default suppressions. Please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` URL.
+- `checkstyle.header.file` - please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` URL.
+- `checkstyle.suppressions.file` - default suppressions. Please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` URL.
- `checkstyle.additional.suppressions.file` - this variable corresponds to suppressions in your local project. E.g. you're working on `spring-cloud-contract`. Then point to the `project-root/src/checkstyle/checkstyle-suppressions.xml` folder. Example for `spring-cloud-contract` would be: `/home/username/spring-cloud-contract/src/checkstyle/checkstyle-suppressions.xml`.
IMPORTANT: Remember to set the `Scan Scope` to `All sources` since we apply checkstyle rules for production and test sources.
-=== Duplicate Finder
+[[duplicate-finder]]
+== Duplicate Finder
Spring Cloud Build brings along the `basepom:duplicate-finder-maven-plugin`, that enables flagging duplicate and conflicting classes and resources on the java classpath.
-==== Duplicate Finder configuration
+[[duplicate-finder-configuration]]
+=== Duplicate Finder configuration
Duplicate finder is *enabled by default* and will run in the `verify` phase of your Maven build, but it will only take effect in your project if you add the `duplicate-finder-maven-plugin` to the `build` section of the projecst's `pom.xml`.
diff --git a/docs/antora-playbook.yml b/docs/antora-playbook.yml
new file mode 100644
index 000000000..45fde2731
--- /dev/null
+++ b/docs/antora-playbook.yml
@@ -0,0 +1,38 @@
+antora:
+ extensions:
+ - '@springio/antora-extensions/partial-build-extension'
+ - require: '@springio/antora-extensions/latest-version-extension'
+ - require: '@springio/antora-extensions/inject-collector-cache-config-extension'
+ - '@antora/collector-extension'
+ - '@antora/atlas-extension'
+ - require: '@springio/antora-extensions/root-component-extension'
+ root_component_name: 'cloud-zookeeper'
+site:
+ title: Spring Cloud Zookeeper
+ url: https://docs.spring.io/spring-cloud-zookeeper/reference/
+content:
+ sources:
+ - url: ./..
+ branches: HEAD
+ start_path: docs
+ worktrees: true
+asciidoc:
+ attributes:
+ page-stackoverflow-url: https://stackoverflow.com/tags/spring-cloud
+ page-pagination: ''
+ hide-uri-scheme: '@'
+ tabs-sync-option: '@'
+ chomp: 'all'
+ extensions:
+ - '@asciidoctor/tabs'
+ - '@springio/asciidoctor-extensions'
+ sourcemap: true
+urls:
+ latest_version_segment: ''
+runtime:
+ log:
+ failure_level: warn
+ format: pretty
+ui:
+ bundle:
+ url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.3.5/ui-bundle.zip
diff --git a/docs/antora.yml b/docs/antora.yml
new file mode 100644
index 000000000..928048fb1
--- /dev/null
+++ b/docs/antora.yml
@@ -0,0 +1,12 @@
+name: cloud-zookeeper
+version: true
+title: spring-cloud-zookeeper
+nav:
+ - modules/ROOT/nav.adoc
+ext:
+ collector:
+ run:
+ command: ./mvnw --no-transfer-progress -B process-resources -Pdocs -pl docs -Dantora-maven-plugin.phase=none -Dgenerate-docs.phase=none -Dgenerate-readme.phase=none -Dgenerate-cloud-resources.phase=none -Dmaven-dependency-plugin-for-docs.phase=none -Dmaven-dependency-plugin-for-docs-classes.phase=none -DskipTests
+ local: true
+ scan:
+ dir: ./target/classes/antora-resources/
diff --git a/docs/modules/ROOT/assets/images/.gitkeep b/docs/modules/ROOT/assets/images/.gitkeep
new file mode 100644
index 000000000..e69de29bb
diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
new file mode 100644
index 000000000..11533cba8
--- /dev/null
+++ b/docs/modules/ROOT/nav.adoc
@@ -0,0 +1,10 @@
+* xref:index.adoc[]
+* xref:quickstart.adoc[]
+* xref:install.adoc[]
+* xref:discovery.adoc[]
+* xref:other-componentes.adoc[]
+* xref:service-registry.adoc[]
+* xref:dependencies.adoc[]
+* xref:dependency-watcher.adoc[]
+* xref:config.adoc[]
+* xref:appendix.adoc[]
diff --git a/docs/src/main/asciidoc/_attributes.adoc b/docs/modules/ROOT/pages/_attributes.adoc
similarity index 70%
rename from docs/src/main/asciidoc/_attributes.adoc
rename to docs/modules/ROOT/pages/_attributes.adoc
index 2da4a3781..c26a2d097 100644
--- a/docs/src/main/asciidoc/_attributes.adoc
+++ b/docs/modules/ROOT/pages/_attributes.adoc
@@ -2,8 +2,6 @@
:doctype: book
:idprefix:
:idseparator: -
-:toc: left
-:toclevels: 4
:tabsize: 4
:numbered:
:sectanchors:
@@ -13,4 +11,4 @@
:docinfo: shared,private
:sc-ext: java
-:project-full-name: Spring Cloud Zookeeper
\ No newline at end of file
+:project-full-name: Spring Cloud Zookeeper
diff --git a/docs/src/main/asciidoc/appendix.adoc b/docs/modules/ROOT/pages/appendix.adoc
similarity index 62%
rename from docs/src/main/asciidoc/appendix.adoc
rename to docs/modules/ROOT/pages/appendix.adoc
index 2c18b8653..484ecf75b 100644
--- a/docs/src/main/asciidoc/appendix.adoc
+++ b/docs/modules/ROOT/pages/appendix.adoc
@@ -1,14 +1,14 @@
:numbered!:
[appendix]
[[common-application-properties]]
-== Common application properties
+= Common application properties
+:page-section-summary-toc: 1
-include::_attributes.adoc[]
Various properties can be specified inside your `application.properties` file, inside your `application.yml` file, or as command line switches.
-This appendix provides a list of common {project-full-name} properties and references to the underlying classes that consume them.
+This appendix provides a list of common Spring Cloud Zookeeper properties and references to the underlying classes that consume them.
NOTE: Property contributions can come from additional jar files on your classpath, so you should not consider this an exhaustive list.
Also, you can define your own properties.
-include::_configprops.adoc[]
\ No newline at end of file
+include::partial$_configprops.adoc[]
diff --git a/docs/modules/ROOT/pages/config.adoc b/docs/modules/ROOT/pages/config.adoc
new file mode 100644
index 000000000..feeb8153a
--- /dev/null
+++ b/docs/modules/ROOT/pages/config.adoc
@@ -0,0 +1,143 @@
+[[spring-cloud-zookeeper-config]]
+= Distributed Configuration with Zookeeper
+
+Zookeeper provides a
+https://zookeeper.apache.org/doc/current/zookeeperOver.html#sc_dataModelNameSpace[hierarchical namespace]
+that lets clients store arbitrary data, such as configuration data. Spring Cloud Zookeeper
+Config is an alternative to the
+https://github.com/spring-cloud/spring-cloud-config[Config Server and Client].
+Configuration is loaded into the Spring Environment during the special "`bootstrap`"
+phase. Configuration is stored in the `/config` namespace by default. Multiple
+`PropertySource` instances are created, based on the application's name and the active
+profiles, to mimic the Spring Cloud Config order of resolving properties. For example, an
+application with a name of `testApp` and with the `dev` profile has the following property
+sources created for it:
+
+* `config/testApp,dev`
+* `config/testApp`
+* `config/application,dev`
+* `config/application`
+
+The most specific property source is at the top, with the least specific at the bottom.
+Properties in the `config/application` namespace apply to all applications that use
+zookeeper for configuration. Properties in the `config/testApp` namespace are available
+only to the instances of the service named `testApp`.
+
+Configuration is currently read on startup of the application. Sending a HTTP `POST`
+request to `/refresh` causes the configuration to be reloaded. Watching the configuration
+namespace (which Zookeeper supports) is not currently implemented.
+
+[[activating]]
+== Activating
+
+Including a dependency on
+`org.springframework.cloud:spring-cloud-starter-zookeeper-config` enables
+autoconfiguration that sets up Spring Cloud Zookeeper Config.
+
+CAUTION: When working with version 3.4 of Zookeeper you need to change
+the way you include the dependency as described xref:install.adoc[here].
+
+[[config-data-import]]
+== Spring Boot Config Data Import
+
+Spring Boot 2.4 introduced a new way to import configuration data via the `spring.config.import` property. This is now the default way to get configuration from Zookeeper.
+
+To optionally connect to Zookeeper for configuration set the following in application.properties:
+
+.application.properties
+[source,properties]
+----
+spring.config.import=optional:zookeeper:
+----
+
+This will connect to Zookeeper at the default location of "localhost:2181". Removing the `optional:` prefix will cause Zookeeper Config to fail if it is unable to connect to Zookeeper. To change the connection properties of Zookeeper Config either set `spring.cloud.zookeeper.connect-string` or add the connect string to the `spring.config.import` statement such as, `spring.config.import=optional:zookeeper:myhost:2818`. The location in the import property has precedence over the `connect-string` property.
+
+Zookeeper Config will try to load values from four automatic contexts based on `spring.cloud.zookeeper.config.name` (which defaults to the value of the `spring.application.name` property) and `spring.cloud.zookeeper.config.default-context` (which defaults to `application`). If you want to specify the contexts rather than using the computed ones, you can add that information to the `spring.config.import` statement.
+
+.application.properties
+[source,properties]
+----
+spring.config.import=optional:zookeeper:myhost:2181/contextone;/context/two
+----
+
+This will optionally load configuration only from `/contextone` and `/context/two`.
+
+NOTE: A `bootstrap` file (properties or yaml) is *not* needed for the Spring Boot Config Data method of import via `spring.config.import`.
+
+[[customizing]]
+== Customizing
+
+Zookeeper Config may be customized by setting the following properties:
+
+[source,yml,indent=0]
+----
+spring:
+ cloud:
+ zookeeper:
+ config:
+ enabled: true
+ root: configuration
+ defaultContext: apps
+ profileSeparator: '::'
+----
+
+* `enabled`: Setting this value to `false` disables Zookeeper Config.
+* `root`: Sets the base namespace for configuration values.
+* `defaultContext`: Sets the name used by all applications.
+* `profileSeparator`: Sets the value of the separator used to separate the profile name in
+property sources with profiles.
+
+CAUTION: If you have set `spring.cloud.bootstrap.enabled=true` or `spring.config.use-legacy-processing=true`, or included `spring-cloud-starter-bootstrap`, then the above values will need to be placed in `bootstrap.yml` instead of `application.yml`.
+
+[[access-control-lists-acls]]
+== Access Control Lists (ACLs)
+
+You can add authentication information for Zookeeper ACLs by calling the `addAuthInfo`
+method of a `CuratorFramework` bean. One way to accomplish this is to provide your own
+`CuratorFramework` bean, as shown in the following example:
+
+[source,java,indent=0]
+----
+@BoostrapConfiguration
+public class CustomCuratorFrameworkConfig {
+
+ @Bean
+ public CuratorFramework curatorFramework() {
+ CuratorFramework curator = new CuratorFramework();
+ curator.addAuthInfo("digest", "user:password".getBytes());
+ return curator;
+ }
+
+}
+----
+Consult
+https://github.com/spring-cloud/spring-cloud-zookeeper/blob/main/spring-cloud-zookeeper-core/src/main/java/org/springframework/cloud/zookeeper/ZookeeperAutoConfiguration.java[the ZookeeperAutoConfiguration class]
+to see how the `CuratorFramework` bean's default configuration.
+
+Alternatively, you can add your credentials from a class that depends on the existing
+`CuratorFramework` bean, as shown in the following example:
+
+[source,java,indent=0]
+----
+@BoostrapConfiguration
+public class DefaultCuratorFrameworkConfig {
+
+ public ZookeeperConfig(CuratorFramework curator) {
+ curator.addAuthInfo("digest", "user:password".getBytes());
+ }
+
+}
+----
+
+The creation of this bean must occur during the boostrapping phase. You can register
+configuration classes to run during this phase by annotating them with
+`@BootstrapConfiguration` and including them in a comma-separated list that you set as the
+value of the `org.springframework.cloud.bootstrap.BootstrapConfiguration` property in the
+`resources/META-INF/spring.factories` file, as shown in the following example:
+
+.resources/META-INF/spring.factories
+----
+org.springframework.cloud.bootstrap.BootstrapConfiguration=\
+my.project.CustomCuratorFrameworkConfig,\
+my.project.DefaultCuratorFrameworkConfig
+----
diff --git a/docs/modules/ROOT/pages/configprops.adoc b/docs/modules/ROOT/pages/configprops.adoc
new file mode 100644
index 000000000..32cbb8e58
--- /dev/null
+++ b/docs/modules/ROOT/pages/configprops.adoc
@@ -0,0 +1,6 @@
+[[configuration-properties]]
+= Configuration Properties
+
+Below you can find a list of configuration properties.
+
+include::partial$_configprops.adoc[]
diff --git a/docs/modules/ROOT/pages/dependencies.adoc b/docs/modules/ROOT/pages/dependencies.adoc
new file mode 100644
index 000000000..17f477c5e
--- /dev/null
+++ b/docs/modules/ROOT/pages/dependencies.adoc
@@ -0,0 +1,205 @@
+[[spring-cloud-zookeeper-dependencies]]
+= Zookeeper Dependencies
+
+The following topics cover how to work with Spring Cloud Zookeeper dependencies:
+
+* xref:dependencies.adoc#spring-cloud-zookeeper-dependencies-using[Using the Zookeeper Dependencies]
+* xref:dependencies.adoc#spring-cloud-zookeeper-dependencies-activating[Activating Zookeeper Dependencies]
+* xref:dependencies.adoc#spring-cloud-zookeeper-dependencies-setting-up[Setting up Zookeeper Dependencies]
+* xref:dependencies.adoc#spring-cloud-zookeeper-dependencies-configuring[Configuring Spring Cloud Zookeeper Dependencies]
+
+[[spring-cloud-zookeeper-dependencies-using]]
+== Using the Zookeeper Dependencies
+
+Spring Cloud Zookeeper gives you a possibility to provide dependencies of your application
+as properties. As dependencies, you can understand other applications that are registered
+in Zookeeper and which you would like to call through
+https://docs.spring.io/spring-cloud-openfeign/docs/current/reference/html/[OpenFeign]
+(a REST client builder), `RestTemplate` and `WebClient` via https://docs.spring.io/spring-cloud-commons/reference/spring-cloud-commons/loadbalancer.html#spring-cloud-loadbalancer-integrations[Spring Cloud Loadbalancer].
+
+You can also use the Zookeeper Dependency Watchers functionality to control and monitor
+the state of your dependencies.
+
+[[spring-cloud-zookeeper-dependencies-activating]]
+== Activating Zookeeper Dependencies
+
+Including a dependency on
+`org.springframework.cloud:spring-cloud-starter-zookeeper-discovery` enables
+autoconfiguration that sets up Spring Cloud Zookeeper Dependencies. Even if you provide
+the dependencies in your properties, you can turn off the dependencies. To do so, set the
+`spring.cloud.zookeeper.dependency.enabled` property to false (it defaults to `true`).
+
+[[spring-cloud-zookeeper-dependencies-setting-up]]
+== Setting up Zookeeper Dependencies
+
+Consider the following example of dependency representation:
+
+[source,yml,indent=0]
+.application.yml
+----
+spring.application.name: yourServiceName
+spring.cloud.zookeeper:
+ dependencies:
+ newsletter:
+ path: /path/where/newsletter/has/registered/in/zookeeper
+ loadBalancerType: ROUND_ROBIN
+ contentTypeTemplate: application/vnd.newsletter.$version+json
+ version: v1
+ headers:
+ header1:
+ - value1
+ header2:
+ - value2
+ required: false
+ stubs: org.springframework:foo:stubs
+ mailing:
+ path: /path/where/mailing/has/registered/in/zookeeper
+ loadBalancerType: ROUND_ROBIN
+ contentTypeTemplate: application/vnd.mailing.$version+json
+ version: v1
+ required: true
+----
+
+The next few sections go through each part of the dependency one by one. The root property
+name is `spring.cloud.zookeeper.dependencies`.
+
+[[spring-cloud-zookeeper-dependencies-setting-up-aliases]]
+=== Aliases
+
+Below the root property you have to represent each dependency as an alias.
+This is due to the constraints of Spring Cloud LoadBalancer, which requires that the application ID be placed in the URL.
+Consequently, you cannot pass any complex path, suchas `/myApp/myRoute/name`).
+The alias is the name you use instead of the `serviceId` for `DiscoveryClient`, `Feign`, or
+`RestTemplate`.
+
+In the previous examples, the aliases are `newsletter` and `mailing`.
+The following example shows Feign usage with a `newsletter` alias:
+
+[source,java,indent=0]
+----
+@FeignClient("newsletter")
+public interface NewsletterService {
+ @RequestMapping(method = RequestMethod.GET, value = "/newsletter")
+ String getNewsletters();
+}
+----
+
+[[path]]
+=== Path
+
+The path is represented by the `path` YAML property and is the path under which the dependency is registered under Zookeeper.
+As described in the
+xref:dependencies.adoc#spring-cloud-zookeeper-dependencies-setting-up-aliases[previous section], Spring Cloud LoadBalancer operates on URLs.
+As a result, this path is not compliant with its requirement.
+That is why Spring Cloud Zookeeper maps the alias to the proper path.
+
+[[load-balancer-type]]
+=== Load Balancer Type
+
+The load balancer type is represented by `loadBalancerType` YAML property.
+
+If you know what kind of load-balancing strategy has to be applied when calling this particular dependency, you can provide it in the YAML file, and it is automatically applied.
+You can choose one of the following load balancing strategies:
+
+* STICKY: Once chosen, the instance is always called.
+* RANDOM: Picks an instance randomly.
+* ROUND_ROBIN: Iterates over instances over and over again.
+
+[[content-type-template-and-version]]
+=== `Content-Type` Template and Version
+
+The `Content-Type` template and version are represented by the `contentTypeTemplate` and
+`version` YAML properties.
+
+If you version your API in the `Content-Type` header, you do not want to add this header
+to each of your requests. Also, if you want to call a new version of the API, you do not
+want to roam around your code to bump up the API version. That is why you can provide a
+`contentTypeTemplate` with a special `$version` placeholder. That placeholder will be filled by the value of the
+`version` YAML property. Consider the following example of a `contentTypeTemplate`:
+
+----
+application/vnd.newsletter.$version+json
+----
+
+Further consider the following `version`:
+
+----
+v1
+----
+
+The combination of `contentTypeTemplate` and version results in the creation of a
+`Content-Type` header for each request, as follows:
+
+----
+application/vnd.newsletter.v1+json
+----
+
+[[default-headers]]
+=== Default Headers
+
+Default headers are represented by the `headers` map in YAML.
+
+Sometimes, each call to a dependency requires setting up of some default headers. To not
+do that in code, you can set them up in the YAML file, as shown in the following example
+`headers` section:
+
+[source,yml,indent=0]
+----
+headers:
+ Accept:
+ - text/html
+ - application/xhtml+xml
+ Cache-Control:
+ - no-cache
+----
+
+That `headers` section results in adding the `Accept` and `Cache-Control` headers with
+appropriate list of values in your HTTP request.
+
+[[required-dependencies]]
+=== Required Dependencies
+
+Required dependencies are represented by `required` property in YAML.
+
+If one of your dependencies is required to be up when your application boots, you can set
+the `required: true` property in the YAML file.
+
+If your application cannot localize the required dependency during boot time, it throws an
+exception, and the Spring Context fails to set up. In other words, your application cannot
+start if the required dependency is not registered in Zookeeper.
+
+You can read more about Spring Cloud Zookeeper Presence Checker
+xref:dependency-watcher.adoc#spring-cloud-zookeeper-dependency-watcher-presence-checker[later in this document].
+
+[[stubs]]
+=== Stubs
+
+You can provide a colon-separated path to the JAR containing stubs of the dependency, as
+shown in the following example:
+
+`stubs: org.springframework:myApp:stubs`
+
+where:
+
+* `org.springframework` is the `groupId`.
+* `myApp` is the `artifactId`.
+* `stubs` is the classifier. (Note that `stubs` is the default value.)
+
+Because `stubs` is the default classifier, the preceding example is equal to the following
+example:
+
+`stubs: org.springframework:myApp`
+
+[[spring-cloud-zookeeper-dependencies-configuring]]
+== Configuring Spring Cloud Zookeeper Dependencies
+
+You can set the following properties to enable or disable parts of Zookeeper Dependencies functionalities:
+
+* `spring.cloud.zookeeper.dependencies`: If you do not set this property, you cannot use Zookeeper Dependencies.
+* `spring.cloud.zookeeper.dependency.loadbalancer.enabled` (enabled by default): Turns on Zookeeper-specific custom load-balancing strategies, including `ZookeeperServiceInstanceListSupplier` and dependency-based load-balanced `RestTemplate` setup.
+* `spring.cloud.zookeeper.dependency.headers.enabled` (enabled by default): This property registers a `FeignBlockingLoadBalancerClient` that automatically appends appropriate headers and content types with their versions, as presented in the Dependency configuration.
+Without this setting, those two parameters do not work.
+* `spring.cloud.zookeeper.dependency.resttemplate.enabled` (enabled by default): When enabled, this property modifies the request headers of a `@LoadBalanced`-annotated
+`RestTemplate` such that it passes headers and content type with the version set in dependency configuration.
+Without this setting, those two parameters do not work.
+
diff --git a/docs/modules/ROOT/pages/dependency-watcher.adoc b/docs/modules/ROOT/pages/dependency-watcher.adoc
new file mode 100644
index 000000000..24017e101
--- /dev/null
+++ b/docs/modules/ROOT/pages/dependency-watcher.adoc
@@ -0,0 +1,53 @@
+[[spring-cloud-zookeeper-dependency-watcher]]
+= Spring Cloud Zookeeper Dependency Watcher
+
+The Dependency Watcher mechanism lets you register listeners to your dependencies. The
+functionality is, in fact, an implementation of the `Observator` pattern. When a
+dependency changes, its state (to either UP or DOWN), some custom logic can be applied.
+
+[[activating]]
+== Activating
+
+Spring Cloud Zookeeper Dependencies functionality needs to be enabled for you to use the
+Dependency Watcher mechanism.
+// TODO: How can the reader do that?
+
+[[registering-a-listener]]
+== Registering a Listener
+
+To register a listener, you must implement an interface called
+`org.springframework.cloud.zookeeper.discovery.watcher.DependencyWatcherListener` and
+register it as a bean. The interface gives you one method:
+
+[source,java,indent=0]
+----
+void stateChanged(String dependencyName, DependencyState newState);
+----
+
+If you want to register a listener for a particular dependency, the `dependencyName` would
+be the discriminator for your concrete implementation. `newState` provides you with
+information about whether your dependency has changed to `CONNECTED` or `DISCONNECTED`.
+
+[[spring-cloud-zookeeper-dependency-watcher-presence-checker]]
+== Using the Presence Checker
+
+Bound with the Dependency Watcher is the functionality called Presence Checker. It lets
+you provide custom behavior when your application boots, to react according to the state
+of your dependencies.
+
+The default implementation of the abstract
+`org.springframework.cloud.zookeeper.discovery.watcher.presence.DependencyPresenceOnStartupVerifier`
+class is the
+`org.springframework.cloud.zookeeper.discovery.watcher.presence.DefaultDependencyPresenceOnStartupVerifier`,
+which works in the following way.
+
+. If the dependency is marked us `required` and is not in Zookeeper, when your application
+boots, it throws an exception and shuts down.
+. If the dependency is not `required`, the
+`org.springframework.cloud.zookeeper.discovery.watcher.presence.LogMissingDependencyChecker`
+logs that the dependency is missing at the `WARN` level.
+
+Because the `DefaultDependencyPresenceOnStartupVerifier` is registered only when there is
+no bean of type `DependencyPresenceOnStartupVerifier`, this functionality can be
+overridden.
+
diff --git a/docs/modules/ROOT/pages/discovery.adoc b/docs/modules/ROOT/pages/discovery.adoc
new file mode 100644
index 000000000..65290a89e
--- /dev/null
+++ b/docs/modules/ROOT/pages/discovery.adoc
@@ -0,0 +1,102 @@
+[[spring-cloud-zookeeper-discovery]]
+= Service Discovery with Zookeeper
+
+Service Discovery is one of the key tenets of a microservice based architecture. Trying to
+hand-configure each client or some form of convention can be difficult to do and can be
+brittle. https://curator.apache.org[Curator](A Java library for Zookeeper) provides Service
+Discovery through a https://curator.apache.org/curator-x-discovery/[Service Discovery
+Extension]. Spring Cloud Zookeeper uses this extension for service registration and
+discovery.
+
+[[activating]]
+== Activating
+
+Including a dependency on
+`org.springframework.cloud:spring-cloud-starter-zookeeper-discovery` enables
+autoconfiguration that sets up Spring Cloud Zookeeper Discovery.
+
+NOTE: For web functionality, you still need to include
+`org.springframework.boot:spring-boot-starter-web`.
+
+CAUTION: When working with version 3.4 of Zookeeper you need to change
+the way you include the dependency as described xref:install.adoc[here].
+
+[[registering-with-zookeeper]]
+== Registering with Zookeeper
+
+When a client registers with Zookeeper, it provides metadata (such as host and port, ID,
+and name) about itself.
+
+The following example shows a Zookeeper client:
+
+[source,java,indent=0]
+----
+@SpringBootApplication
+@RestController
+public class Application {
+
+ @RequestMapping("/")
+ public String home() {
+ return "Hello world";
+ }
+
+ public static void main(String[] args) {
+ new SpringApplicationBuilder(Application.class).web(true).run(args);
+ }
+
+}
+----
+
+NOTE: The preceding example is a normal Spring Boot application.
+
+If Zookeeper is located somewhere other than `localhost:2181`, the configuration must
+provide the location of the server, as shown in the following example:
+
+[source,yml,indent=0]
+.application.yml
+----
+spring:
+ cloud:
+ zookeeper:
+ connect-string: localhost:2181
+----
+
+CAUTION: If you use xref:config.adoc[Spring Cloud Zookeeper Config], the
+values shown in the preceding example need to be in `bootstrap.yml` instead of
+`application.yml`.
+
+The default service name, instance ID, and port (taken from the `Environment`) are
+`${spring.application.name}`, the Spring Context ID, and `${server.port}`, respectively.
+
+Having `spring-cloud-starter-zookeeper-discovery` on the classpath makes the app into both
+a Zookeeper "`service`" (that is, it registers itself) and a "`client`" (that is, it can
+query Zookeeper to locate other services).
+
+If you would like to disable the Zookeeper Discovery Client, you can set
+`spring.cloud.zookeeper.discovery.enabled` to `false`.
+
+[[using-the-discoveryclient]]
+== Using the DiscoveryClient
+
+Spring Cloud has support for
+https://docs.spring.io/spring-cloud-openfeign/docs/current/reference/html/[OpenFeign]
+(a REST client builder), `RestTemplate` and `WebClient` via https://docs.spring.io/spring-cloud-commons/reference/spring-cloud-commons/loadbalancer.html#spring-cloud-loadbalancer-integrations[Spring Cloud Loadbalancer], using logical service names instead of physical URLs.
+
+You can also use the `org.springframework.cloud.client.discovery.DiscoveryClient`, which
+provides a simple API for discovery clients that is not specific to Netflix, as shown in
+the following example:
+
+[source,java,indent=0]
+----
+@Autowired
+private DiscoveryClient discoveryClient;
+
+public String serviceUrl() {
+ List list = discoveryClient.getInstances("STORES");
+ if (list != null && list.size() > 0 ) {
+ return list.get(0).getUri().toString();
+ }
+ return null;
+}
+----
+
diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc
new file mode 100755
index 000000000..58168dfbe
--- /dev/null
+++ b/docs/modules/ROOT/pages/index.adoc
@@ -0,0 +1 @@
+include::intro.adoc[]
\ No newline at end of file
diff --git a/docs/modules/ROOT/pages/install.adoc b/docs/modules/ROOT/pages/install.adoc
new file mode 100644
index 000000000..46f84243f
--- /dev/null
+++ b/docs/modules/ROOT/pages/install.adoc
@@ -0,0 +1,8 @@
+[[spring-cloud-zookeeper-install]]
+= Working with Zookeeper
+
+See the https://zookeeper.apache.org/doc/current/zookeeperStarted.html[installation
+documentation] for instructions on how to install Zookeeper.
+
+// TODO: describe Testcontainers and zk
+
diff --git a/docs/src/main/asciidoc/intro.adoc b/docs/modules/ROOT/pages/intro.adoc
similarity index 91%
rename from docs/src/main/asciidoc/intro.adoc
rename to docs/modules/ROOT/pages/intro.adoc
index 5930b9670..7fce78a99 100644
--- a/docs/src/main/asciidoc/intro.adoc
+++ b/docs/modules/ROOT/pages/intro.adoc
@@ -1,5 +1,5 @@
-
-include::_attributes.adoc[]
+[[spring-cloud-gateway-intro]]
+= Introduction
This project provides Zookeeper integrations for Spring Boot applications through
autoconfiguration and binding to the Spring Environment and other Spring programming model
diff --git a/docs/modules/ROOT/pages/other-componentes.adoc b/docs/modules/ROOT/pages/other-componentes.adoc
new file mode 100644
index 000000000..5de6f8c2e
--- /dev/null
+++ b/docs/modules/ROOT/pages/other-componentes.adoc
@@ -0,0 +1,16 @@
+[[spring-cloud-zookeeper-other-componentes]]
+= Using Spring Cloud Zookeeper with Spring Cloud Components
+:page-section-summary-toc: 1
+
+Feign, Spring Cloud Gateway and Spring Cloud LoadBalancer all work with Spring Cloud Zookeeper.
+
+[[spring-cloud-loadbalancer-with-zookeeper]]
+== Spring Cloud LoadBalancer with Zookeeper
+
+Spring Cloud Zookeeper provides an implementation of Spring Cloud LoadBalancer `ServiceInstanceListSupplier`.
+When you use the `spring-cloud-starter-zookeeper-discovery`, Spring Cloud LoadBalancer is autoconfigured to use the
+`ZookeeperServiceInstanceListSupplier` by default.
+
+TIP: If you were previously using the StickyRule in Zookeeper, its replacement in the current stack
+is the `SameInstancePreferenceServiceInstanceListSupplier` in SC LoadBalancer. You can read on how to set it up in the https://docs.spring.io/spring-cloud-commons/docs/current/reference/html/#spring-cloud-loadbalancer[Spring Cloud Commons documentation].
+
diff --git a/docs/src/main/asciidoc/quickstart.adoc b/docs/modules/ROOT/pages/quickstart.adoc
similarity index 94%
rename from docs/src/main/asciidoc/quickstart.adoc
rename to docs/modules/ROOT/pages/quickstart.adoc
index fe5f74b77..a36b6cf36 100644
--- a/docs/src/main/asciidoc/quickstart.adoc
+++ b/docs/modules/ROOT/pages/quickstart.adoc
@@ -1,8 +1,12 @@
+[[quick-start]]
+= Quick Start
+
This quick start walks through using Spring Cloud Zookeeper for Service Discovery and Distributed Configuration.
First, run Zookeeper on your machine. Then you can access it and use it as a Service Registry and Configuration source with Spring Cloud Zookeeper.
-=== Discovery Client Usage
+[[discovery-client-usage]]
+== Discovery Client Usage
To use these features in an application, you can build it as a Spring Boot application that depends on `spring-cloud-zookeeper-core` and `spring-cloud-zookeeper-discovery`.
The most convenient way to add the dependency is with a Spring Boot starter: `org.springframework.cloud:spring-cloud-starter-zookeeper-discovery`.
@@ -80,7 +84,7 @@ dependencyManagement {
----
WARNING: Depending on the version you are using, you might need to adjust Apache Zookeeper version used in your project.
-You can read more about it in the <>.
+You can read more about it in the xref:install.adoc[Install Zookeeper section].
Now you can create a standard Spring Boot application, such as the following HTTP server:
@@ -127,7 +131,8 @@ public String serviceUrl() {
}
----
-=== Distributed Configuration Usage
+[[distributed-configuration-usage]]
+== Distributed Configuration Usage
To use these features in an application, you can build it as a Spring Boot application that depends on `spring-cloud-zookeeper-core` and `spring-cloud-zookeeper-config`.
The most convenient way to add the dependency is with a Spring Boot starter: `org.springframework.cloud:spring-cloud-starter-zookeeper-config`.
@@ -205,7 +210,7 @@ dependencyManagement {
----
WARNING: Depending on the version you are using, you might need to adjust Apache Zookeeper version used in your project.
-You can read more about it in the <>.
+You can read more about it in the xref:install.adoc[Install Zookeeper section].
Now you can create a standard Spring Boot application, such as the following HTTP server:
@@ -229,4 +234,4 @@ public class Application {
The application retrieves configuration data from Zookeeper.
WARNING: If you use Spring Cloud Zookeeper Config, you need to set the `spring.config.import` property in order to bind to Zookeeper.
-You can read more about it in the <>.
\ No newline at end of file
+You can read more about it in the xref:config.adoc#config-data-import[Spring Boot Config Data Import section].
diff --git a/docs/modules/ROOT/pages/service-registry.adoc b/docs/modules/ROOT/pages/service-registry.adoc
new file mode 100644
index 000000000..88e56c060
--- /dev/null
+++ b/docs/modules/ROOT/pages/service-registry.adoc
@@ -0,0 +1,45 @@
+[[spring-cloud-zookeeper-service-registry]]
+= Spring Cloud Zookeeper and Service Registry
+
+Spring Cloud Zookeeper implements the `ServiceRegistry` interface, letting developers
+register arbitrary services in a programmatic way.
+
+The `ServiceInstanceRegistration` class offers a `builder()` method to create a
+`Registration` object that can be used by the `ServiceRegistry`, as shown in the following
+example:
+
+[source,java,indent=0]
+----
+@Autowired
+private ZookeeperServiceRegistry serviceRegistry;
+
+public void registerThings() {
+ ZookeeperRegistration registration = ServiceInstanceRegistration.builder()
+ .defaultUriSpec()
+ .address("anyUrl")
+ .port(10)
+ .name("/a/b/c/d/anotherservice")
+ .build();
+ this.serviceRegistry.register(registration);
+}
+----
+
+[[instance-status]]
+== Instance Status
+
+Netflix Eureka supports having instances that are `OUT_OF_SERVICE` registered with the server.
+These instances are not returned as active service instances.
+This is useful for behaviors such as blue/green deployments.
+(Note that the Curator Service Discovery recipe does not support this behavior.) Taking advantage of the flexible payload has let Spring Cloud Zookeeper implement `OUT_OF_SERVICE` by updating some specific metadata and then filtering on that metadata in the Spring Cloud LoadBalancer `ZookeeperServiceInstanceListSupplier`.
+The `ZookeeperServiceInstanceListSupplier` filters out all non-null instance statuses that do not equal `UP`.
+If the instance status field is empty, it is considered to be `UP` for backwards compatibility.
+To change the status of an instance, make a `POST` with `OUT_OF_SERVICE` to the `ServiceRegistry`
+instance status actuator endpoint, as shown in the following example:
+
+[source,sh,indent=0]
+----
+$ http POST http://localhost:8081/service-registry status=OUT_OF_SERVICE
+----
+
+NOTE: The preceding example uses the `http` command from https://httpie.org.
+
diff --git a/docs/src/main/asciidoc/_configprops.adoc b/docs/modules/ROOT/partials/_configprops.adoc
similarity index 100%
rename from docs/src/main/asciidoc/_configprops.adoc
rename to docs/modules/ROOT/partials/_configprops.adoc
diff --git a/docs/pom.xml b/docs/pom.xml
index ebceb1862..4fbed91e9 100644
--- a/docs/pom.xml
+++ b/docs/pom.xml
@@ -1,25 +1,30 @@
-
4.0.0
org.springframework.cloud
spring-cloud-zookeeper
4.1.0-SNAPSHOT
+ ..
spring-cloud-zookeeper-docs
jar
Spring Cloud Zookeeper Docs
- Spring Cloud Docs
+ Spring Cloud Zookeeper Docs
spring-cloud-zookeeper
${basedir}/..
- spring.cloud.zookeeper.*|
-
- deploy
+ spring.cloud.zookeeper.*
none
+
+
+ 1.0.2
+ ${maven.multiModuleProjectDirectory}/
+ .*
+ ${maven.multiModuleProjectDirectory}/docs/modules/ROOT/partials/
@@ -34,26 +39,35 @@
docs
+
+
+ src/main/antora/resources/antora-resources
+ true
+
+
pl.project13.maven
git-commit-id-plugin
+ org.apache.maven.plugins
maven-dependency-plugin
-
- maven-resources-plugin
-
org.codehaus.mojo
exec-maven-plugin
- org.asciidoctor
- asciidoctor-maven-plugin
+ io.spring.maven.antora
+ antora-component-version-maven-plugin
+
+
+ io.spring.maven.antora
+ antora-maven-plugin
+ org.apache.maven.plugins
maven-antrun-plugin
diff --git a/docs/src/main/antora/resources/antora-resources/antora.yml b/docs/src/main/antora/resources/antora-resources/antora.yml
new file mode 100644
index 000000000..9148923fa
--- /dev/null
+++ b/docs/src/main/antora/resources/antora-resources/antora.yml
@@ -0,0 +1,20 @@
+version: @antora-component.version@
+prerelease: @antora-component.prerelease@
+
+asciidoc:
+ attributes:
+ attribute-missing: 'warn'
+ chomp: 'all'
+ project-root: @maven.multiModuleProjectDirectory@
+ github-repo: @docs.main@
+ github-raw: https://raw.githubusercontent.com/spring-cloud/@docs.main@/@github-tag@
+ github-code: https://github.com/spring-cloud/@docs.main@/tree/@github-tag@
+ github-issues: https://github.com/spring-cloud/@docs.main@/issues/
+ github-wiki: https://github.com/spring-cloud/@docs.main@/wiki
+ spring-cloud-version: @project.version@
+ github-tag: @github-tag@
+ version-type: @version-type@
+ docs-url: https://docs.spring.io/@docs.main@/docs/@project.version@
+ raw-docs-url: https://raw.githubusercontent.com/spring-cloud/@docs.main@/@github-tag@
+ project-version: @project.version@
+ project-name: @docs.main@
diff --git a/docs/src/main/asciidoc/README.adoc b/docs/src/main/asciidoc/README.adoc
index 453a501bf..aac2ac4c7 100644
--- a/docs/src/main/asciidoc/README.adoc
+++ b/docs/src/main/asciidoc/README.adoc
@@ -1,28 +1,29 @@
-image::https://travis-ci.org/spring-cloud/spring-cloud-zookeeper.svg?branch=master[Build Status, link=https://travis-ci.org/spring-cloud/spring-cloud-zookeeper]
+image::https://github.com/spring-cloud/spring-cloud-zookeeper/workflows/Build/badge.svg?style=svg["Actions Status", link="https://github.com/spring-cloud/spring-cloud-zookeeper/actions"]
-include::intro.adoc[]
-include::_attributes.adoc[]
-== Quick Start
+[[quick-start]]
+= Quick Start
-include::quickstart.adoc[]
-== Zookeeper overview
+[[zookeeper-overview]]
+= Zookeeper overview
ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services.
See the
https://zookeeper.apache.org[Zookeeper site] for more information.
Spring Cloud Zookeeper also builds on the https://curator.apache.org[Apache Curator] project, which started life at Netflix.
-== Spring Cloud Zookeeper Features
+[[spring-cloud-zookeeper-features]]
+= Spring Cloud Zookeeper Features
Spring Cloud Zookeeper includes the following features:
* Spring Cloud `DiscoveryClient` implementation (supports Spring Cloud LoadBalancer)
* Zookeeper-based `PropertySource` loaded during the 'bootstrap' phase
-== Running the Sample
+[[running-the-sample]]
+= Running the Sample
. https://zookeeper.apache.org/doc/current/zookeeperStarted.html#sc_Download[Install
zookeeper] (On a mac with homebrew, use `brew install zookeeper`).
@@ -37,10 +38,12 @@ Doing so brings in the required Spring Cloud Maven repositories and Build.
. Run `java -jar spring-cloud-zookeeper-sample/target/spring-cloud-zookeeper-sample-1.2.0.BUILD-SNAPSHOT.jar --server.port=8081`
. Visit http://localhost:8080 again to verify that `{"serviceId":"testZookeeperApp","host":"","port":8081}` eventually shows up in the results in a round-robin fashion. (It may take a minute or so.)
-== Building
+[[building]]
+= Building
-include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/building.adoc[]
+include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/modules/ROOT/partials/building.adoc[]
-== Contributing
+[[contributing]]
+= Contributing
-include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/contributing.adoc[]
+include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/modules/ROOT/partials/contributing.adoc[]
diff --git a/docs/src/main/asciidoc/index.adoc b/docs/src/main/asciidoc/index.adoc
deleted file mode 100755
index 8508bf359..000000000
--- a/docs/src/main/asciidoc/index.adoc
+++ /dev/null
@@ -1 +0,0 @@
-include::spring-cloud-zookeeper.adoc[]
diff --git a/docs/src/main/asciidoc/sagan-boot.adoc b/docs/src/main/asciidoc/sagan-boot.adoc
deleted file mode 100644
index 3523bf65d..000000000
--- a/docs/src/main/asciidoc/sagan-boot.adoc
+++ /dev/null
@@ -1,2 +0,0 @@
-
-include::_attributes.adoc[]
\ No newline at end of file
diff --git a/docs/src/main/asciidoc/sagan-index.adoc b/docs/src/main/asciidoc/sagan-index.adoc
deleted file mode 100644
index f6e45cd22..000000000
--- a/docs/src/main/asciidoc/sagan-index.adoc
+++ /dev/null
@@ -1,39 +0,0 @@
-
-include::_attributes.adoc[]
-
-Spring Cloud Zookeeper provides http://zookeeper.apache.org/[Apache Zookeeper] integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms. With a few simple annotations you can quickly enable and configure the common patterns inside your application and build large distributed systems with Zookeeper. The patterns provided include Service Discovery and Distributed Configuration.
-
-## Features
-
-* Service Discovery: instances can be registered with Zookeeper and clients can discover the instances using Spring-managed beans
- * Supports Spring Cloud LoadBalancer - client-side load-balancing solution
- * Supports Spring Cloud OpenFeign
-* Distributed Configuration: using Zookeeper as a data store
-
-## Quick Start
-
-As long as Spring Cloud Zookeeper, http://curator.apache.org/[Apache Curator] and the Zookeeper Java Client are on the
-classpath any Spring Boot application with `@EnableDiscoveryClient` will try to contact a Zookeeper
-agent on `localhost:2181` (the default value of
-`zookeeper.connectString`).
-
-```java
-@Configuration
-@EnableAutoConfiguration
-@EnableDiscoveryClient
-@RestController
-public class Application {
-
- @RequestMapping("/")
- public String home() {
- return "Hello World";
- }
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-
-}
-```
-
-A local Zookeeper server must be running. See the http://zookeeper.apache.org/[Zookeeper documentation] on how to run a Zookeeper server.
diff --git a/docs/src/main/asciidoc/spring-cloud-zookeeper.adoc b/docs/src/main/asciidoc/spring-cloud-zookeeper.adoc
deleted file mode 100644
index c6eed2760..000000000
--- a/docs/src/main/asciidoc/spring-cloud-zookeeper.adoc
+++ /dev/null
@@ -1,617 +0,0 @@
-
-= Spring Cloud Zookeeper
-
-include::intro.adoc[]
-
-include::_attributes.adoc[]
-
-== Quick Start
-
-include::quickstart.adoc[]
-
-[[spring-cloud-zookeeper-install]]
-== Install Zookeeper
-See the https://zookeeper.apache.org/doc/current/zookeeperStarted.html[installation
-documentation] for instructions on how to install Zookeeper.
-
-Spring Cloud Zookeeper uses Apache Curator behind the scenes.
-While Zookeeper 3.5.x is still considered "beta" by the Zookeeper development team,
-the reality is that it is used in production by many users.
-However, Zookeeper 3.4.x is also used in production.
-Prior to Apache Curator 4.0, both versions of Zookeeper were supported via two versions of Apache Curator.
-Starting with Curator 4.0 both versions of Zookeeper are supported via the same Curator libraries.
-
-In case you are integrating with version 3.4 you need to change the Zookeeper dependency
-that comes shipped with `curator`, and thus `spring-cloud-zookeeper`.
-To do so simply exclude that dependency and add the 3.4.x version like shown below.
-
-.maven
-[source,xml,indent=0]
-----
-
- org.springframework.cloud
- spring-cloud-starter-zookeeper-all
-
-
- org.apache.zookeeper
- zookeeper
-
-
-
-
- org.apache.zookeeper
- zookeeper
- 3.4.12
-
-
- org.slf4j
- slf4j-log4j12
-
-
-
-----
-
-.gradle
-[source,groovy,indent=0]
-----
-compile('org.springframework.cloud:spring-cloud-starter-zookeeper-all') {
- exclude group: 'org.apache.zookeeper', module: 'zookeeper'
-}
-compile('org.apache.zookeeper:zookeeper:3.4.12') {
- exclude group: 'org.slf4j', module: 'slf4j-log4j12'
-}
-----
-
-[[spring-cloud-zookeeper-discovery]]
-== Service Discovery with Zookeeper
-
-Service Discovery is one of the key tenets of a microservice based architecture. Trying to
-hand-configure each client or some form of convention can be difficult to do and can be
-brittle. https://curator.apache.org[Curator](A Java library for Zookeeper) provides Service
-Discovery through a https://curator.apache.org/curator-x-discovery/[Service Discovery
-Extension]. Spring Cloud Zookeeper uses this extension for service registration and
-discovery.
-
-=== Activating
-
-Including a dependency on
-`org.springframework.cloud:spring-cloud-starter-zookeeper-discovery` enables
-autoconfiguration that sets up Spring Cloud Zookeeper Discovery.
-
-NOTE: For web functionality, you still need to include
-`org.springframework.boot:spring-boot-starter-web`.
-
-CAUTION: When working with version 3.4 of Zookeeper you need to change
-the way you include the dependency as described <>.
-
-=== Registering with Zookeeper
-
-When a client registers with Zookeeper, it provides metadata (such as host and port, ID,
-and name) about itself.
-
-The following example shows a Zookeeper client:
-
-[source,java,indent=0]
-----
-@SpringBootApplication
-@RestController
-public class Application {
-
- @RequestMapping("/")
- public String home() {
- return "Hello world";
- }
-
- public static void main(String[] args) {
- new SpringApplicationBuilder(Application.class).web(true).run(args);
- }
-
-}
-----
-
-NOTE: The preceding example is a normal Spring Boot application.
-
-If Zookeeper is located somewhere other than `localhost:2181`, the configuration must
-provide the location of the server, as shown in the following example:
-
-[source,yml,indent=0]
-.application.yml
-----
-spring:
- cloud:
- zookeeper:
- connect-string: localhost:2181
-----
-
-CAUTION: If you use <>, the
-values shown in the preceding example need to be in `bootstrap.yml` instead of
-`application.yml`.
-
-The default service name, instance ID, and port (taken from the `Environment`) are
-`${spring.application.name}`, the Spring Context ID, and `${server.port}`, respectively.
-
-Having `spring-cloud-starter-zookeeper-discovery` on the classpath makes the app into both
-a Zookeeper "`service`" (that is, it registers itself) and a "`client`" (that is, it can
-query Zookeeper to locate other services).
-
-If you would like to disable the Zookeeper Discovery Client, you can set
-`spring.cloud.zookeeper.discovery.enabled` to `false`.
-
-=== Using the DiscoveryClient
-
-Spring Cloud has support for
-https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#spring-cloud-feign[Feign]
-(a REST client builder),
-https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/ascii[Spring
-`RestTemplate`] and
-https://cloud.spring.io/spring-cloud-commons/reference/html/#loadbalanced-webclient[Spring WebFlux], using logical service names instead of physical URLs.
-
-You can also use the `org.springframework.cloud.client.discovery.DiscoveryClient`, which
-provides a simple API for discovery clients that is not specific to Netflix, as shown in
-the following example:
-
-[source,java,indent=0]
-----
-@Autowired
-private DiscoveryClient discoveryClient;
-
-public String serviceUrl() {
- List list = discoveryClient.getInstances("STORES");
- if (list != null && list.size() > 0 ) {
- return list.get(0).getUri().toString();
- }
- return null;
-}
-----
-
-[[spring-cloud-zookeeper-other-componentes]]
-== Using Spring Cloud Zookeeper with Spring Cloud Components
-
-Feign, Spring Cloud Gateway and Spring Cloud LoadBalancer all work with Spring Cloud Zookeeper.
-
-=== Spring Cloud LoadBalancer with Zookeeper
-
-Spring Cloud Zookeeper provides an implementation of Spring Cloud LoadBalancer `ServiceInstanceListSupplier`.
-When you use the `spring-cloud-starter-zookeeper-discovery`, Spring Cloud LoadBalancer is autoconfigured to use the
-`ZookeeperServiceInstanceListSupplier` by default.
-
-TIP: If you were previously using the StickyRule in Zookeeper, its replacement in the current stack
-is the `SameInstancePreferenceServiceInstanceListSupplier` in SC LoadBalancer. You can read on how to set it up in the https://docs.spring.io/spring-cloud-commons/docs/current/reference/html/#spring-cloud-loadbalancer[Spring Cloud Commons documentation].
-
-[[spring-cloud-zookeeper-service-registry]]
-== Spring Cloud Zookeeper and Service Registry
-
-Spring Cloud Zookeeper implements the `ServiceRegistry` interface, letting developers
-register arbitrary services in a programmatic way.
-
-The `ServiceInstanceRegistration` class offers a `builder()` method to create a
-`Registration` object that can be used by the `ServiceRegistry`, as shown in the following
-example:
-
-[source,java,indent=0]
-----
-@Autowired
-private ZookeeperServiceRegistry serviceRegistry;
-
-public void registerThings() {
- ZookeeperRegistration registration = ServiceInstanceRegistration.builder()
- .defaultUriSpec()
- .address("anyUrl")
- .port(10)
- .name("/a/b/c/d/anotherservice")
- .build();
- this.serviceRegistry.register(registration);
-}
-----
-
-=== Instance Status
-
-Netflix Eureka supports having instances that are `OUT_OF_SERVICE` registered with the server.
-These instances are not returned as active service instances.
-This is useful for behaviors such as blue/green deployments.
-(Note that the Curator Service Discovery recipe does not support this behavior.) Taking advantage of the flexible payload has let Spring Cloud Zookeeper implement `OUT_OF_SERVICE` by updating some specific metadata and then filtering on that metadata in the Spring Cloud LoadBalancer `ZookeeperServiceInstanceListSupplier`.
-The `ZookeeperServiceInstanceListSupplier` filters out all non-null instance statuses that do not equal `UP`.
-If the instance status field is empty, it is considered to be `UP` for backwards compatibility.
-To change the status of an instance, make a `POST` with `OUT_OF_SERVICE` to the `ServiceRegistry`
-instance status actuator endpoint, as shown in the following example:
-
-[source,sh,indent=0]
-----
-$ http POST http://localhost:8081/service-registry status=OUT_OF_SERVICE
-----
-
-NOTE: The preceding example uses the `http` command from https://httpie.org.
-
-[[spring-cloud-zookeeper-dependencies]]
-== Zookeeper Dependencies
-
-The following topics cover how to work with Spring Cloud Zookeeper dependencies:
-
-* <>
-* <>
-* <>
-* <>
-
-[[spring-cloud-zookeeper-dependencies-using]]
-=== Using the Zookeeper Dependencies
-
-Spring Cloud Zookeeper gives you a possibility to provide dependencies of your application
-as properties. As dependencies, you can understand other applications that are registered
-in Zookeeper and which you would like to call through
-https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/asciidoc/spring-cloud-netflix.adoc#spring-cloud-feign[Feign]
-(a REST client builder),
-https://github.com/spring-cloud/spring-cloud-netflix/blob/master/docs/src/main/ascii[Spring
-`RestTemplate`] and
-https://cloud.spring.io/spring-cloud-commons/reference/html/#loadbalanced-webclient[Spring WebFlux].
-
-You can also use the Zookeeper Dependency Watchers functionality to control and monitor
-the state of your dependencies.
-
-[[spring-cloud-zookeeper-dependencies-activating]]
-=== Activating Zookeeper Dependencies
-
-Including a dependency on
-`org.springframework.cloud:spring-cloud-starter-zookeeper-discovery` enables
-autoconfiguration that sets up Spring Cloud Zookeeper Dependencies. Even if you provide
-the dependencies in your properties, you can turn off the dependencies. To do so, set the
-`spring.cloud.zookeeper.dependency.enabled` property to false (it defaults to `true`).
-
-[[spring-cloud-zookeeper-dependencies-setting-up]]
-=== Setting up Zookeeper Dependencies
-
-Consider the following example of dependency representation:
-
-[source,yml,indent=0]
-.application.yml
-----
-spring.application.name: yourServiceName
-spring.cloud.zookeeper:
- dependencies:
- newsletter:
- path: /path/where/newsletter/has/registered/in/zookeeper
- loadBalancerType: ROUND_ROBIN
- contentTypeTemplate: application/vnd.newsletter.$version+json
- version: v1
- headers:
- header1:
- - value1
- header2:
- - value2
- required: false
- stubs: org.springframework:foo:stubs
- mailing:
- path: /path/where/mailing/has/registered/in/zookeeper
- loadBalancerType: ROUND_ROBIN
- contentTypeTemplate: application/vnd.mailing.$version+json
- version: v1
- required: true
-----
-
-The next few sections go through each part of the dependency one by one. The root property
-name is `spring.cloud.zookeeper.dependencies`.
-
-[[spring-cloud-zookeeper-dependencies-setting-up-aliases]]
-==== Aliases
-
-Below the root property you have to represent each dependency as an alias.
-This is due to the constraints of Spring Cloud LoadBalancer, which requires that the application ID be placed in the URL.
-Consequently, you cannot pass any complex path, suchas `/myApp/myRoute/name`).
-The alias is the name you use instead of the `serviceId` for `DiscoveryClient`, `Feign`, or
-`RestTemplate`.
-
-In the previous examples, the aliases are `newsletter` and `mailing`.
-The following example shows Feign usage with a `newsletter` alias:
-
-[source,java,indent=0]
-----
-@FeignClient("newsletter")
-public interface NewsletterService {
- @RequestMapping(method = RequestMethod.GET, value = "/newsletter")
- String getNewsletters();
-}
-----
-
-==== Path
-
-The path is represented by the `path` YAML property and is the path under which the dependency is registered under Zookeeper.
-As described in the
-<>, Spring Cloud LoadBalancer operates on URLs.
-As a result, this path is not compliant with its requirement.
-That is why Spring Cloud Zookeeper maps the alias to the proper path.
-
-==== Load Balancer Type
-
-The load balancer type is represented by `loadBalancerType` YAML property.
-
-If you know what kind of load-balancing strategy has to be applied when calling this particular dependency, you can provide it in the YAML file, and it is automatically applied.
-You can choose one of the following load balancing strategies:
-
-* STICKY: Once chosen, the instance is always called.
-* RANDOM: Picks an instance randomly.
-* ROUND_ROBIN: Iterates over instances over and over again.
-
-==== `Content-Type` Template and Version
-
-The `Content-Type` template and version are represented by the `contentTypeTemplate` and
-`version` YAML properties.
-
-If you version your API in the `Content-Type` header, you do not want to add this header
-to each of your requests. Also, if you want to call a new version of the API, you do not
-want to roam around your code to bump up the API version. That is why you can provide a
-`contentTypeTemplate` with a special `$version` placeholder. That placeholder will be filled by the value of the
-`version` YAML property. Consider the following example of a `contentTypeTemplate`:
-
-----
-application/vnd.newsletter.$version+json
-----
-
-Further consider the following `version`:
-
-----
-v1
-----
-
-The combination of `contentTypeTemplate` and version results in the creation of a
-`Content-Type` header for each request, as follows:
-
-----
-application/vnd.newsletter.v1+json
-----
-
-==== Default Headers
-
-Default headers are represented by the `headers` map in YAML.
-
-Sometimes, each call to a dependency requires setting up of some default headers. To not
-do that in code, you can set them up in the YAML file, as shown in the following example
-`headers` section:
-
-[source,yml,indent=0]
-----
-headers:
- Accept:
- - text/html
- - application/xhtml+xml
- Cache-Control:
- - no-cache
-----
-
-That `headers` section results in adding the `Accept` and `Cache-Control` headers with
-appropriate list of values in your HTTP request.
-
-==== Required Dependencies
-
-Required dependencies are represented by `required` property in YAML.
-
-If one of your dependencies is required to be up when your application boots, you can set
-the `required: true` property in the YAML file.
-
-If your application cannot localize the required dependency during boot time, it throws an
-exception, and the Spring Context fails to set up. In other words, your application cannot
-start if the required dependency is not registered in Zookeeper.
-
-You can read more about Spring Cloud Zookeeper Presence Checker
-<>.
-
-==== Stubs
-
-You can provide a colon-separated path to the JAR containing stubs of the dependency, as
-shown in the following example:
-
-`stubs: org.springframework:myApp:stubs`
-
-where:
-
-* `org.springframework` is the `groupId`.
-* `myApp` is the `artifactId`.
-* `stubs` is the classifier. (Note that `stubs` is the default value.)
-
-Because `stubs` is the default classifier, the preceding example is equal to the following
-example:
-
-`stubs: org.springframework:myApp`
-
-[[spring-cloud-zookeeper-dependencies-configuring]]
-=== Configuring Spring Cloud Zookeeper Dependencies
-
-You can set the following properties to enable or disable parts of Zookeeper Dependencies functionalities:
-
-* `spring.cloud.zookeeper.dependencies`: If you do not set this property, you cannot use Zookeeper Dependencies.
-* `spring.cloud.zookeeper.dependency.loadbalancer.enabled` (enabled by default): Turns on Zookeeper-specific custom load-balancing strategies, including `ZookeeperServiceInstanceListSupplier` and dependency-based load-balanced `RestTemplate` setup.
-* `spring.cloud.zookeeper.dependency.headers.enabled` (enabled by default): This property registers a `FeignBlockingLoadBalancerClient` that automatically appends appropriate headers and content types with their versions, as presented in the Dependency configuration.
-Without this setting, those two parameters do not work.
-* `spring.cloud.zookeeper.dependency.resttemplate.enabled` (enabled by default): When enabled, this property modifies the request headers of a `@LoadBalanced`-annotated
-`RestTemplate` such that it passes headers and content type with the version set in dependency configuration.
-Without this setting, those two parameters do not work.
-
-[[spring-cloud-zookeeper-dependency-watcher]]
-== Spring Cloud Zookeeper Dependency Watcher
-
-The Dependency Watcher mechanism lets you register listeners to your dependencies. The
-functionality is, in fact, an implementation of the `Observator` pattern. When a
-dependency changes, its state (to either UP or DOWN), some custom logic can be applied.
-
-=== Activating
-
-Spring Cloud Zookeeper Dependencies functionality needs to be enabled for you to use the
-Dependency Watcher mechanism.
-// TODO: How can the reader do that?
-
-=== Registering a Listener
-
-To register a listener, you must implement an interface called
-`org.springframework.cloud.zookeeper.discovery.watcher.DependencyWatcherListener` and
-register it as a bean. The interface gives you one method:
-
-[source,java,indent=0]
-----
-void stateChanged(String dependencyName, DependencyState newState);
-----
-
-If you want to register a listener for a particular dependency, the `dependencyName` would
-be the discriminator for your concrete implementation. `newState` provides you with
-information about whether your dependency has changed to `CONNECTED` or `DISCONNECTED`.
-
-[[spring-cloud-zookeeper-dependency-watcher-presence-checker]]
-=== Using the Presence Checker
-
-Bound with the Dependency Watcher is the functionality called Presence Checker. It lets
-you provide custom behavior when your application boots, to react according to the state
-of your dependencies.
-
-The default implementation of the abstract
-`org.springframework.cloud.zookeeper.discovery.watcher.presence.DependencyPresenceOnStartupVerifier`
-class is the
-`org.springframework.cloud.zookeeper.discovery.watcher.presence.DefaultDependencyPresenceOnStartupVerifier`,
-which works in the following way.
-
-. If the dependency is marked us `required` and is not in Zookeeper, when your application
-boots, it throws an exception and shuts down.
-. If the dependency is not `required`, the
-`org.springframework.cloud.zookeeper.discovery.watcher.presence.LogMissingDependencyChecker`
-logs that the dependency is missing at the `WARN` level.
-
-Because the `DefaultDependencyPresenceOnStartupVerifier` is registered only when there is
-no bean of type `DependencyPresenceOnStartupVerifier`, this functionality can be
-overridden.
-
-[[spring-cloud-zookeeper-config]]
-== Distributed Configuration with Zookeeper
-
-Zookeeper provides a
-https://zookeeper.apache.org/doc/current/zookeeperOver.html#sc_dataModelNameSpace[hierarchical namespace]
-that lets clients store arbitrary data, such as configuration data. Spring Cloud Zookeeper
-Config is an alternative to the
-https://github.com/spring-cloud/spring-cloud-config[Config Server and Client].
-Configuration is loaded into the Spring Environment during the special "`bootstrap`"
-phase. Configuration is stored in the `/config` namespace by default. Multiple
-`PropertySource` instances are created, based on the application's name and the active
-profiles, to mimic the Spring Cloud Config order of resolving properties. For example, an
-application with a name of `testApp` and with the `dev` profile has the following property
-sources created for it:
-
-* `config/testApp,dev`
-* `config/testApp`
-* `config/application,dev`
-* `config/application`
-
-The most specific property source is at the top, with the least specific at the bottom.
-Properties in the `config/application` namespace apply to all applications that use
-zookeeper for configuration. Properties in the `config/testApp` namespace are available
-only to the instances of the service named `testApp`.
-
-Configuration is currently read on startup of the application. Sending a HTTP `POST`
-request to `/refresh` causes the configuration to be reloaded. Watching the configuration
-namespace (which Zookeeper supports) is not currently implemented.
-
-=== Activating
-
-Including a dependency on
-`org.springframework.cloud:spring-cloud-starter-zookeeper-config` enables
-autoconfiguration that sets up Spring Cloud Zookeeper Config.
-
-CAUTION: When working with version 3.4 of Zookeeper you need to change
-the way you include the dependency as described <>.
-
-[[config-data-import]]
-=== Spring Boot Config Data Import
-
-Spring Boot 2.4 introduced a new way to import configuration data via the `spring.config.import` property. This is now the default way to get configuration from Zookeeper.
-
-To optionally connect to Zookeeper for configuration set the following in application.properties:
-
-.application.properties
-[source,properties]
-----
-spring.config.import=optional:zookeeper:
-----
-
-This will connect to Zookeeper at the default location of "localhost:2181". Removing the `optional:` prefix will cause Zookeeper Config to fail if it is unable to connect to Zookeeper. To change the connection properties of Zookeeper Config either set `spring.cloud.zookeeper.connect-string` or add the connect string to the `spring.config.import` statement such as, `spring.config.import=optional:zookeeper:myhost:2818`. The location in the import property has precedence over the `connect-string` property.
-
-Zookeeper Config will try to load values from four automatic contexts based on `spring.cloud.zookeeper.config.name` (which defaults to the value of the `spring.application.name` property) and `spring.cloud.zookeeper.config.default-context` (which defaults to `application`). If you want to specify the contexts rather than using the computed ones, you can add that information to the `spring.config.import` statement.
-
-.application.properties
-[source,properties]
-----
-spring.config.import=optional:zookeeper:myhost:2181/contextone;/context/two
-----
-
-This will optionally load configuration only from `/contextone` and `/context/two`.
-
-NOTE: A `bootstrap` file (properties or yaml) is *not* needed for the Spring Boot Config Data method of import via `spring.config.import`.
-
-=== Customizing
-
-Zookeeper Config may be customized by setting the following properties:
-
-[source,yml,indent=0]
-----
-spring:
- cloud:
- zookeeper:
- config:
- enabled: true
- root: configuration
- defaultContext: apps
- profileSeparator: '::'
-----
-
-* `enabled`: Setting this value to `false` disables Zookeeper Config.
-* `root`: Sets the base namespace for configuration values.
-* `defaultContext`: Sets the name used by all applications.
-* `profileSeparator`: Sets the value of the separator used to separate the profile name in
-property sources with profiles.
-
-CAUTION: If you have set `spring.cloud.bootstrap.enabled=true` or `spring.config.use-legacy-processing=true`, or included `spring-cloud-starter-bootstrap`, then the above values will need to be placed in `bootstrap.yml` instead of `application.yml`.
-
-=== Access Control Lists (ACLs)
-
-You can add authentication information for Zookeeper ACLs by calling the `addAuthInfo`
-method of a `CuratorFramework` bean. One way to accomplish this is to provide your own
-`CuratorFramework` bean, as shown in the following example:
-
-[source,java,indent=0]
-----
-@BoostrapConfiguration
-public class CustomCuratorFrameworkConfig {
-
- @Bean
- public CuratorFramework curatorFramework() {
- CuratorFramework curator = new CuratorFramework();
- curator.addAuthInfo("digest", "user:password".getBytes());
- return curator;
- }
-
-}
-----
-Consult
-https://github.com/spring-cloud/spring-cloud-zookeeper/blob/master/spring-cloud-zookeeper-core/src/main/java/org/springframework/cloud/zookeeper/ZookeeperAutoConfiguration.java[the ZookeeperAutoConfiguration class]
-to see how the `CuratorFramework` bean's default configuration.
-
-Alternatively, you can add your credentials from a class that depends on the existing
-`CuratorFramework` bean, as shown in the following example:
-
-[source,java,indent=0]
-----
-@BoostrapConfiguration
-public class DefaultCuratorFrameworkConfig {
-
- public ZookeeperConfig(CuratorFramework curator) {
- curator.addAuthInfo("digest", "user:password".getBytes());
- }
-
-}
-----
-
-The creation of this bean must occur during the boostrapping phase. You can register
-configuration classes to run during this phase by annotating them with
-`@BootstrapConfiguration` and including them in a comma-separated list that you set as the
-value of the `org.springframework.cloud.bootstrap.BootstrapConfiguration` property in the
-`resources/META-INF/spring.factories` file, as shown in the following example:
-
-.resources/META-INF/spring.factories
-----
-org.springframework.cloud.bootstrap.BootstrapConfiguration=\
-my.project.CustomCuratorFrameworkConfig,\
-my.project.DefaultCuratorFrameworkConfig
-----