Compare commits
1 Commits
main
...
dependabot
Author | SHA1 | Date |
---|---|---|
dependabot[bot] | b16c83cb56 | 1 year ago |
190 changed files with 3169 additions and 4937 deletions
@ -1,49 +0,0 @@
@@ -1,49 +0,0 @@
|
||||
version: 2 |
||||
updates: |
||||
- package-ecosystem: "github-actions" |
||||
directory: "/" |
||||
target-branch: "3.1.x" # oldest OSS supported branch |
||||
schedule: |
||||
interval: "weekly" |
||||
- package-ecosystem: "github-actions" |
||||
directory: "/" |
||||
target-branch: "4.0.x" # oldest OSS supported branch |
||||
schedule: |
||||
interval: "weekly" |
||||
- package-ecosystem: "github-actions" |
||||
directory: "/" |
||||
target-branch: "main" |
||||
schedule: |
||||
interval: "weekly" |
||||
- package-ecosystem: maven |
||||
directory: / |
||||
schedule: |
||||
interval: daily |
||||
target-branch: 3.1.x |
||||
ignore: |
||||
# only upgrade patch versions for maintenance branch |
||||
- dependency-name: "*" |
||||
update-types: |
||||
- version-update:semver-major |
||||
- version-update:semver-minor |
||||
- package-ecosystem: maven |
||||
directory: / |
||||
schedule: |
||||
interval: daily |
||||
target-branch: 4.0.x |
||||
ignore: |
||||
# only upgrade patch versions for maintenance branch |
||||
- dependency-name: "*" |
||||
update-types: |
||||
- version-update:semver-major |
||||
- version-update:semver-minor |
||||
- package-ecosystem: maven |
||||
directory: / |
||||
schedule: |
||||
interval: daily |
||||
target-branch: main |
||||
ignore: |
||||
# only upgrade by minor or patch |
||||
- dependency-name: "*" |
||||
update-types: |
||||
- version-update:semver-major |
@ -1,32 +0,0 @@
@@ -1,32 +0,0 @@
|
||||
name: Deploy Docs |
||||
on: |
||||
push: |
||||
branches-ignore: [ gh-pages ] |
||||
tags: '**' |
||||
repository_dispatch: |
||||
types: request-build-reference # legacy |
||||
#schedule: |
||||
#- cron: '0 10 * * *' # Once per day at 10am UTC |
||||
workflow_dispatch: |
||||
permissions: |
||||
actions: write |
||||
jobs: |
||||
build: |
||||
runs-on: ubuntu-latest |
||||
# if: github.repository_owner == 'spring-cloud' |
||||
steps: |
||||
- name: Checkout |
||||
uses: actions/checkout@v4 |
||||
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) |
@ -1,2 +1 @@
@@ -1,2 +1 @@
|
||||
-DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/libs-snapshot-local |
||||
-P spring |
||||
-DaltSnapshotDeploymentRepository=repo.spring.io::default::https://repo.spring.io/libs-snapshot-local -P spring |
||||
|
Binary file not shown.
@ -1,18 +1 @@
@@ -1,18 +1 @@
|
||||
# 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 |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, |
||||
# software distributed under the License is distributed on an |
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
||||
# KIND, either express or implied. See the License for the |
||||
# specific language governing permissions and limitations |
||||
# under the License. |
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip |
||||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar |
||||
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip |
@ -1,3 +1,3 @@
@@ -1,3 +1,3 @@
|
||||
# Enable auto-env through the sdkman_auto_env config |
||||
# Add key=value pairs of SDKs to use below |
||||
java=17.0.1-tem |
||||
java=8.0.292.hs-adpt |
||||
|
@ -1,39 +0,0 @@
@@ -1,39 +0,0 @@
|
||||
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-openfeign' |
||||
- '@springio/antora-extensions/static-page-extension' |
||||
site: |
||||
title: Spring Cloud Openfeign |
||||
url: https://docs.spring.io/spring-cloud-openfeign/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.4.2/ui-bundle.zip |
@ -1,12 +0,0 @@
@@ -1,12 +0,0 @@
|
||||
name: cloud-openfeign |
||||
version: true |
||||
title: Spring Cloud OpenFeign |
||||
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/ |
@ -1,4 +0,0 @@
@@ -1,4 +0,0 @@
|
||||
* xref:index.adoc[Introduction] |
||||
* xref:spring-cloud-openfeign.adoc[] |
||||
* xref:appendix.adoc[] |
||||
** xref:configprops.adoc[] |
@ -1,6 +0,0 @@
@@ -1,6 +0,0 @@
|
||||
[[configuration-properties]] |
||||
= Configuration Properties |
||||
|
||||
Below you can find a list of configuration properties. |
||||
|
||||
include::partial$_configprops.adoc[] |
@ -1 +0,0 @@
@@ -1 +0,0 @@
|
||||
include::intro.adoc[] |
@ -1,3 +0,0 @@
@@ -1,3 +0,0 @@
|
||||
:sc-ext: java |
||||
:project-full-name: Spring Cloud OpenFeign |
||||
:all: {asterisk}{asterisk} |
@ -1,113 +0,0 @@
@@ -1,113 +0,0 @@
|
||||
|=== |
||||
|Name | Default | Description |
||||
|
||||
|spring.cloud.compatibility-verifier.compatible-boot-versions | `+++3.2.x+++` | Default accepted versions for the Spring Boot dependency. You can set {@code x} for the patch version if you don't want to specify a concrete value. Example: {@code 3.4.x} |
||||
|spring.cloud.compatibility-verifier.enabled | `+++false+++` | Enables creation of Spring Cloud compatibility verification. |
||||
|spring.cloud.config.allow-override | `+++true+++` | Flag to indicate that {@link #isOverrideSystemProperties() systemPropertiesOverride} can be used. Set to false to prevent users from changing the default accidentally. Default true. |
||||
|spring.cloud.config.initialize-on-context-refresh | `+++false+++` | Flag to initialize bootstrap configuration on context refresh event. Default false. |
||||
|spring.cloud.config.override-none | `+++false+++` | Flag to indicate that when {@link #setAllowOverride(boolean) allowOverride} is true, external properties should take lowest priority and should not override any existing property sources (including local config files). Default false. This will only have an effect when using config first bootstrap. |
||||
|spring.cloud.config.override-system-properties | `+++true+++` | Flag to indicate that the external properties should override system properties. Default true. |
||||
|spring.cloud.decrypt-environment-post-processor.enabled | `+++true+++` | Enable the DecryptEnvironmentPostProcessor. |
||||
|spring.cloud.discovery.client.composite-indicator.enabled | `+++true+++` | Enables discovery client composite health indicator. |
||||
|spring.cloud.discovery.client.health-indicator.enabled | `+++true+++` | |
||||
|spring.cloud.discovery.client.health-indicator.include-description | `+++false+++` | |
||||
|spring.cloud.discovery.client.health-indicator.use-services-query | `+++true+++` | Whether or not the indicator should use {@link DiscoveryClient#getServices} to check its health. When set to {@code false} the indicator instead uses the lighter {@link DiscoveryClient#probe()}. This can be helpful in large deployments where the number of services returned makes the operation unnecessarily heavy. |
||||
|spring.cloud.discovery.client.simple.instances | | |
||||
|spring.cloud.discovery.client.simple.local.host | | |
||||
|spring.cloud.discovery.client.simple.local.instance-id | | |
||||
|spring.cloud.discovery.client.simple.local.metadata | | |
||||
|spring.cloud.discovery.client.simple.local.port | `+++0+++` | |
||||
|spring.cloud.discovery.client.simple.local.secure | `+++false+++` | |
||||
|spring.cloud.discovery.client.simple.local.service-id | | |
||||
|spring.cloud.discovery.client.simple.local.uri | | |
||||
|spring.cloud.discovery.client.simple.order | | |
||||
|spring.cloud.discovery.enabled | `+++true+++` | Enables discovery client health indicators. |
||||
|spring.cloud.features.enabled | `+++true+++` | Enables the features endpoint. |
||||
|spring.cloud.httpclientfactories.apache.enabled | `+++true+++` | Enables creation of Apache Http Client factory beans. |
||||
|spring.cloud.httpclientfactories.ok.enabled | `+++true+++` | Enables creation of OK Http Client factory beans. |
||||
|spring.cloud.hypermedia.refresh.fixed-delay | `+++5000+++` | |
||||
|spring.cloud.hypermedia.refresh.initial-delay | `+++10000+++` | |
||||
|spring.cloud.inetutils.default-hostname | `+++localhost+++` | The default hostname. Used in case of errors. |
||||
|spring.cloud.inetutils.default-ip-address | `+++127.0.0.1+++` | The default IP address. Used in case of errors. |
||||
|spring.cloud.inetutils.ignored-interfaces | | List of Java regular expressions for network interfaces that will be ignored. |
||||
|spring.cloud.inetutils.preferred-networks | | List of Java regular expressions for network addresses that will be preferred. |
||||
|spring.cloud.inetutils.timeout-seconds | `+++1+++` | Timeout, in seconds, for calculating hostname. |
||||
|spring.cloud.inetutils.use-only-site-local-interfaces | `+++false+++` | Whether to use only interfaces with site local addresses. See {@link InetAddress#isSiteLocalAddress()} for more details. |
||||
|spring.cloud.loadbalancer.call-get-with-request-on-delegates | `+++true+++` | If this flag is set to {@code true}, {@code ServiceInstanceListSupplier#get(Request request)} method will be implemented to call {@code delegate.get(request)} in classes assignable from {@code DelegatingServiceInstanceListSupplier} that don't already implement that method, with the exclusion of {@code CachingServiceInstanceListSupplier} and {@code HealthCheckServiceInstanceListSupplier}, which should be placed in the instance supplier hierarchy directly after the supplier performing instance retrieval over the network, before any request-based filtering is done, {@code true} by default. |
||||
|spring.cloud.loadbalancer.clients | | |
||||
|spring.cloud.loadbalancer.eager-load.clients | | |
||||
|spring.cloud.loadbalancer.health-check.initial-delay | `+++0+++` | Initial delay value for the HealthCheck scheduler. |
||||
|spring.cloud.loadbalancer.health-check.interval | `+++25s+++` | Interval for rerunning the HealthCheck scheduler. |
||||
|spring.cloud.loadbalancer.health-check.interval | `+++25s+++` | Interval for rerunning the HealthCheck scheduler. |
||||
|spring.cloud.loadbalancer.health-check.path | | Path at which the health-check request should be made. Can be set up per `serviceId`. A `default` value can be set up as well. If none is set up, `/actuator/health` will be used. |
||||
|spring.cloud.loadbalancer.health-check.port | | Path at which the health-check request should be made. If none is set, the port under which the requested service is available at the service instance. |
||||
|spring.cloud.loadbalancer.health-check.refetch-instances | `+++false+++` | Indicates whether the instances should be refetched by the `HealthCheckServiceInstanceListSupplier`. This can be used if the instances can be updated and the underlying delegate does not provide an ongoing flux. |
||||
|spring.cloud.loadbalancer.health-check.refetch-instances-interval | `+++25s+++` | Interval for refetching available service instances. |
||||
|spring.cloud.loadbalancer.health-check.repeat-health-check | `+++true+++` | Indicates whether health checks should keep repeating. It might be useful to set it to `false` if periodically refetching the instances, as every refetch will also trigger a healthcheck. |
||||
|spring.cloud.loadbalancer.health-check.update-results-list | `+++true+++` | Indicates whether the {@code healthCheckFlux} should emit on each alive {@link ServiceInstance} that has been retrieved. If set to {@code false}, the entire alive instances sequence is first collected into a list and only then emitted. |
||||
|spring.cloud.loadbalancer.hint | | Allows setting the value of <code>hint</code> that is passed on to the LoadBalancer request and can subsequently be used in {@link ReactiveLoadBalancer} implementations. |
||||
|spring.cloud.loadbalancer.hint-header-name | `+++X-SC-LB-Hint+++` | Allows setting the name of the header used for passing the hint for hint-based service instance filtering. |
||||
|spring.cloud.loadbalancer.retry.backoff.enabled | `+++false+++` | Indicates whether Reactor Retry backoffs should be applied. |
||||
|spring.cloud.loadbalancer.retry.backoff.jitter | `+++0.5+++` | Used to set `RetryBackoffSpec.jitter`. |
||||
|spring.cloud.loadbalancer.retry.backoff.max-backoff | `+++Long.MAX ms+++` | Used to set `RetryBackoffSpec.maxBackoff`. |
||||
|spring.cloud.loadbalancer.retry.backoff.min-backoff | `+++5 ms+++` | Used to set `RetryBackoffSpec#minBackoff`. |
||||
|spring.cloud.loadbalancer.retry.enabled | `+++true+++` | Enables LoadBalancer retries. |
||||
|spring.cloud.loadbalancer.retry.max-retries-on-next-service-instance | `+++1+++` | Number of retries to be executed on the next `ServiceInstance`. A `ServiceInstance` is chosen before each retry call. |
||||
|spring.cloud.loadbalancer.retry.max-retries-on-same-service-instance | `+++0+++` | Number of retries to be executed on the same `ServiceInstance`. |
||||
|spring.cloud.loadbalancer.retry.retry-on-all-exceptions | `+++false+++` | Indicates retries should be attempted for all exceptions, not only those specified in `retryableExceptions`. |
||||
|spring.cloud.loadbalancer.retry.retry-on-all-operations | `+++false+++` | Indicates retries should be attempted on operations other than `HttpMethod.GET`. |
||||
|spring.cloud.loadbalancer.retry.retryable-exceptions | `+++{}+++` | A `Set` of `Throwable` classes that should trigger a retry. |
||||
|spring.cloud.loadbalancer.retry.retryable-status-codes | `+++{}+++` | A `Set` of status codes that should trigger a retry. |
||||
|spring.cloud.loadbalancer.sticky-session.add-service-instance-cookie | `+++false+++` | Indicates whether a cookie with the newly selected instance should be added by LoadBalancer. |
||||
|spring.cloud.loadbalancer.sticky-session.instance-id-cookie-name | `+++sc-lb-instance-id+++` | The name of the cookie holding the preferred instance id. |
||||
|spring.cloud.loadbalancer.x-forwarded.enabled | `+++false+++` | To Enable X-Forwarded Headers. |
||||
|spring.cloud.openfeign.autoconfiguration.jackson.enabled | `+++true+++` | If true, PageJacksonModule and SortJacksonModule bean will be provided for Jackson page decoding. |
||||
|spring.cloud.openfeign.circuitbreaker.alphanumeric-ids.enabled | `+++false+++` | If true, Circuit Breaker ids will only contain alphanumeric characters to allow for configuration via configuration properties. |
||||
|spring.cloud.openfeign.circuitbreaker.enabled | `+++false+++` | If true, an OpenFeign client will be wrapped with a Spring Cloud CircuitBreaker circuit breaker. |
||||
|spring.cloud.openfeign.circuitbreaker.group.enabled | `+++false+++` | If true, an OpenFeign client will be wrapped with a Spring Cloud CircuitBreaker circuit breaker with with group. |
||||
|spring.cloud.openfeign.client.config | | |
||||
|spring.cloud.openfeign.client.decode-slash | `+++true+++` | Feign clients do not encode slash `/` characters by default. To change this behavior, set the `decodeSlash` to `false`. |
||||
|spring.cloud.openfeign.client.default-config | `+++default+++` | |
||||
|spring.cloud.openfeign.client.default-to-properties | `+++true+++` | |
||||
|spring.cloud.openfeign.client.refresh-enabled | `+++false+++` | Enables options value refresh capability for Feign. |
||||
|spring.cloud.openfeign.compression.request.enabled | `+++false+++` | Enables the request sent by Feign to be compressed. |
||||
|spring.cloud.openfeign.compression.request.mime-types | `+++[text/xml, application/xml, application/json]+++` | The list of supported mime types. |
||||
|spring.cloud.openfeign.compression.request.min-request-size | `+++2048+++` | The minimum threshold content size. |
||||
|spring.cloud.openfeign.compression.response.enabled | `+++false+++` | Enables the response from Feign to be compressed. |
||||
|spring.cloud.openfeign.encoder.charset-from-content-type | `+++false+++` | Indicates whether the charset should be derived from the {@code Content-Type} header. |
||||
|spring.cloud.openfeign.http2client.enabled | `+++false+++` | Enables the use of the Java11 HTTP 2 Client by Feign. |
||||
|spring.cloud.openfeign.httpclient.connection-timeout | `+++2000+++` | |
||||
|spring.cloud.openfeign.httpclient.connection-timer-repeat | `+++3000+++` | |
||||
|spring.cloud.openfeign.httpclient.disable-ssl-validation | `+++false+++` | |
||||
|spring.cloud.openfeign.httpclient.enabled | `+++true+++` | Enables the use of the Apache HTTP Client by Feign. |
||||
|spring.cloud.openfeign.httpclient.follow-redirects | `+++true+++` | |
||||
|spring.cloud.openfeign.httpclient.hc5.connection-request-timeout | `+++3+++` | Default value for connection request timeout. |
||||
|spring.cloud.openfeign.httpclient.hc5.connection-request-timeout-unit | | Default value for connection request timeout unit. |
||||
|spring.cloud.openfeign.httpclient.hc5.enabled | `+++false+++` | Enables the use of the Apache HTTP Client 5 by Feign. |
||||
|spring.cloud.openfeign.httpclient.hc5.pool-concurrency-policy | | Pool concurrency policies. |
||||
|spring.cloud.openfeign.httpclient.hc5.pool-reuse-policy | | Pool connection re-use policies. |
||||
|spring.cloud.openfeign.httpclient.hc5.socket-timeout | `+++5+++` | Default value for socket timeout. |
||||
|spring.cloud.openfeign.httpclient.hc5.socket-timeout-unit | | Default value for socket timeout unit. |
||||
|spring.cloud.openfeign.httpclient.http2.version | `+++HTTP_2+++` | Configure the protocols used by this client to communicate with remote servers. Uses {@link String} value of {@link HttpClient.Version}. |
||||
|spring.cloud.openfeign.httpclient.max-connections | `+++200+++` | |
||||
|spring.cloud.openfeign.httpclient.max-connections-per-route | `+++50+++` | |
||||
|spring.cloud.openfeign.httpclient.ok-http.protocols | | Configure the protocols used by this client to communicate with remote servers. Uses {@link String} values of {@link Protocol}. |
||||
|spring.cloud.openfeign.httpclient.ok-http.read-timeout | `+++60s+++` | {@link OkHttpClient} read timeout; defaults to 60 seconds. |
||||
|spring.cloud.openfeign.httpclient.time-to-live | `+++900+++` | |
||||
|spring.cloud.openfeign.httpclient.time-to-live-unit | | |
||||
|spring.cloud.openfeign.lazy-attributes-resolution | `+++false+++` | Switches @FeignClient attributes resolution mode to lazy. |
||||
|spring.cloud.openfeign.micrometer.enabled | `+++true+++` | Enables Micrometer capabilities for Feign. |
||||
|spring.cloud.openfeign.oauth2.clientRegistrationId | | Provides a clientId to be used with OAuth2. |
||||
|spring.cloud.openfeign.oauth2.enabled | `+++false+++` | Enables feign interceptor for managing oauth2 access token. |
||||
|spring.cloud.openfeign.okhttp.enabled | `+++false+++` | Enables the use of the OK HTTP Client by Feign. |
||||
|spring.cloud.refresh.additional-property-sources-to-retain | | Additional property sources to retain during a refresh. Typically only system property sources are retained. This property allows property sources, such as property sources created by EnvironmentPostProcessors to be retained as well. |
||||
|spring.cloud.refresh.enabled | `+++true+++` | Enables autoconfiguration for the refresh scope and associated features. |
||||
|spring.cloud.refresh.extra-refreshable | `+++true+++` | Additional class names for beans to post process into refresh scope. |
||||
|spring.cloud.refresh.never-refreshable | `+++true+++` | Comma separated list of class names for beans to never be refreshed or rebound. |
||||
|spring.cloud.refresh.on-restart.enabled | `+++true+++` | Enable refreshing context on start. |
||||
|spring.cloud.service-registry.auto-registration.enabled | `+++true+++` | Whether service auto-registration is enabled. Defaults to true. |
||||
|spring.cloud.service-registry.auto-registration.fail-fast | `+++false+++` | Whether startup fails if there is no AutoServiceRegistration. Defaults to false. |
||||
|spring.cloud.service-registry.auto-registration.register-management | `+++true+++` | Whether to register the management as a service. Defaults to true. |
||||
|spring.cloud.util.enabled | `+++true+++` | Enables creation of Spring Cloud utility beans. |
||||
|
||||
|=== |
@ -1,6 +0,0 @@
@@ -1,6 +0,0 @@
|
||||
[[observability-conventions]] |
||||
=== Observability - Conventions |
||||
|
||||
Below you can find a list of all `GlobalObservationConvention` and `ObservationConvention` declared by this project. |
||||
|
||||
|
@ -1,6 +0,0 @@
@@ -1,6 +0,0 @@
|
||||
[[observability-metrics]] |
||||
=== Observability - Metrics |
||||
|
||||
Below you can find a list of all metrics declared by this project. |
||||
|
||||
|
@ -1,6 +0,0 @@
@@ -1,6 +0,0 @@
|
||||
[[observability-spans]] |
||||
=== Observability - Spans |
||||
|
||||
Below you can find a list of all spans declared by this project. |
||||
|
||||
|
@ -1,20 +0,0 @@
@@ -1,20 +0,0 @@
|
||||
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@ |
@ -1,24 +1,23 @@
@@ -1,24 +1,23 @@
|
||||
image::https://github.com/spring-cloud/spring-cloud-openfeign/workflows/Build/badge.svg?branch=main&style=svg["Build",link="https://github.com/spring-cloud/spring-cloud-openfeign/actions"] |
||||
image::https://github.com/spring-cloud/spring-cloud-openfeign/workflows/Build/badge.svg?branch=3.1.x&style=svg["Build",link="https://github.com/spring-cloud/spring-cloud-openfeign/actions"] |
||||
|
||||
image:https://codecov.io/gh/spring-cloud/spring-cloud-openfeign/branch/main/graph/badge.svg["Codecov", link="https://app.codecov.io/gh/spring-cloud/spring-cloud-openfeign/tree/main"] |
||||
image:https://codecov.io/gh/spring-cloud/spring-cloud-openfeign/branch/3.1.x/graph/badge.svg["Codecov", link="https://app.codecov.io/gh/spring-cloud/spring-cloud-openfeign/tree/3.1.x"] |
||||
|
||||
include::_attributes.adoc[] |
||||
|
||||
include::intro.adoc[] |
||||
|
||||
[[features]] |
||||
== Features |
||||
|
||||
* Declarative REST Client: Feign creates a dynamic implementation of an interface decorated with JAX-RS or Spring MVC annotations |
||||
|
||||
[[building]] |
||||
== Building |
||||
|
||||
include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/modules/ROOT/partials/building.adoc[] |
||||
include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/src/main/asciidoc/building-jdk8.adoc[] |
||||
|
||||
[[contributing]] |
||||
== Contributing |
||||
|
||||
include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/modules/ROOT/partials/contributing-docs.adoc[] |
||||
include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/src/main/asciidoc/contributing.adoc[] |
||||
|
||||
[[license]] |
||||
== License |
||||
|
||||
The project license file is available https://raw.githubusercontent.com/spring-cloud/spring-cloud-openfeign/main/LICENSE.txt[here]. |
||||
|
@ -1,6 +1,8 @@
@@ -1,6 +1,8 @@
|
||||
:doctype: book |
||||
:idprefix: |
||||
:idseparator: - |
||||
:toc: left |
||||
:toclevels: 4 |
||||
:tabsize: 4 |
||||
:numbered: |
||||
:sectanchors: |
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
|=== |
||||
|Name | Default | Description |
||||
|
||||
|feign.autoconfiguration.jackson.enabled | `+++false+++` | If true, PageJacksonModule and SortJacksonModule bean will be provided for Jackson page decoding. |
||||
|feign.circuitbreaker.alphanumeric-ids.enabled | `+++false+++` | If true, Circuit Breaker ids will only contain alphanumeric characters to allow for configuration via configuration properties. |
||||
|feign.circuitbreaker.enabled | `+++false+++` | If true, an OpenFeign client will be wrapped with a Spring Cloud CircuitBreaker circuit breaker. |
||||
|feign.circuitbreaker.group.enabled | `+++false+++` | If true, an OpenFeign client will be wrapped with a Spring Cloud CircuitBreaker circuit breaker with group. |
||||
|feign.client.config | | |
||||
|feign.client.decode-slash | `+++true+++` | Feign clients do not encode slash `/` characters by default. To change this behavior, set the `decodeSlash` to `false`. |
||||
|feign.client.default-config | `+++default+++` | |
||||
|feign.client.default-to-properties | `+++true+++` | |
||||
|feign.client.refresh-enabled | `+++false+++` | Enables options value refresh capability for Feign. |
||||
|feign.compression.request.enabled | `+++false+++` | Enables the request sent by Feign to be compressed. |
||||
|feign.compression.request.mime-types | `+++[text/xml, application/xml, application/json]+++` | The list of supported mime types. |
||||
|feign.compression.request.min-request-size | `+++2048+++` | The minimum threshold content size. |
||||
|feign.compression.response.enabled | `+++false+++` | Enables the response from Feign to be compressed. |
||||
|feign.encoder.charset-from-content-type | `+++false+++` | Indicates whether the charset should be derived from the {@code Content-Type} header. |
||||
|feign.httpclient.connection-timeout | `+++2000+++` | |
||||
|feign.httpclient.connection-timer-repeat | `+++3000+++` | |
||||
|feign.httpclient.disable-ssl-validation | `+++false+++` | |
||||
|feign.httpclient.enabled | `+++true+++` | Enables the use of the Apache HTTP Client by Feign. |
||||
|feign.httpclient.follow-redirects | `+++true+++` | |
||||
|feign.httpclient.hc5.connection-request-timeout | `+++3+++` | Default value for connection request timeout. |
||||
|feign.httpclient.hc5.connection-request-timeout-unit | | Default value for connection request timeout unit. |
||||
|feign.httpclient.hc5.enabled | `+++false+++` | Enables the use of the Apache HTTP Client 5 by Feign. |
||||
|feign.httpclient.hc5.pool-concurrency-policy | | Pool concurrency policies. |
||||
|feign.httpclient.hc5.pool-reuse-policy | | Pool connection re-use policies. |
||||
|feign.httpclient.hc5.socket-timeout | `+++5+++` | Default value for socket timeout. |
||||
|feign.httpclient.hc5.socket-timeout-unit | | Default value for socket timeout unit. |
||||
|feign.httpclient.max-connections | `+++200+++` | |
||||
|feign.httpclient.max-connections-per-route | `+++50+++` | |
||||
|feign.httpclient.ok-http.read-timeout | `+++60s+++` | {@link OkHttpClient} read timeout; defaults to 60 seconds. |
||||
|feign.httpclient.time-to-live | `+++900+++` | |
||||
|feign.httpclient.time-to-live-unit | | |
||||
|feign.metrics.enabled | `+++true+++` | Enables metrics capability for Feign. |
||||
|feign.oauth2.clientRegistrationId | | Provides a clientRegistrationId to be used with OAuth2. |
||||
|feign.oauth2.enabled | `+++false+++` | Enables feign interceptor for managing oauth2 access token. |
||||
|feign.oauth2.load-balanced | `+++false+++` | Enables load balancing for oauth2 access token provider. |
||||
|feign.okhttp.enabled | `+++false+++` | Enables the use of the OK HTTP Client by Feign. |
||||
|
||||
|=== |
@ -1,13 +1,14 @@
@@ -1,13 +1,14 @@
|
||||
:numbered!: |
||||
[appendix] |
||||
[[common-application-properties]] |
||||
= Common application properties |
||||
:page-section-summary-toc: 1 |
||||
== Common application properties |
||||
|
||||
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 Spring Cloud OpenFeign properties and references to the underlying classes that consume them. |
||||
This appendix provides a list of common {project-full-name} properties and references to the underlying classes that consume them. |
||||
|
||||
NOTE: Property contributions can come from additional jar files on your classpath, so you should not consider this an exhaustive list. |
||||
Also, you can define your own properties. |
||||
|
||||
include::_configprops.adoc[] |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
include::spring-cloud-openfeign.adoc[] |
@ -1,6 +1,3 @@
@@ -1,6 +1,3 @@
|
||||
[[introduction]] |
||||
= Spring Cloud OpenFeign |
||||
|
||||
This project provides OpenFeign integrations for Spring Boot apps through autoconfiguration |
||||
and binding to the Spring Environment and other Spring programming model idioms. |
||||
|
@ -1,49 +0,0 @@
@@ -1,49 +0,0 @@
|
||||
/* |
||||
* Copyright 2013-2023 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.cloud.openfeign; |
||||
|
||||
import feign.Target; |
||||
|
||||
/** |
||||
* A {@link HardCodedTarget} implementation that resolves url from properties when the |
||||
* initial call is made. Using it allows specifying the url at runtime in an AOT-packaged |
||||
* application or a native image by setting the value of the |
||||
* `spring.cloud.openfeign.client.config.[clientId].url`. |
||||
* |
||||
* @author Olga Maciaszek-Sharma |
||||
* @see FeignClientProperties.FeignClientConfiguration#getUrl() |
||||
*/ |
||||
public class PropertyBasedTarget<T> extends Target.HardCodedTarget<T> { |
||||
|
||||
private String url; |
||||
|
||||
private final FeignClientProperties.FeignClientConfiguration config; |
||||
|
||||
public PropertyBasedTarget(Class<T> type, String name, FeignClientProperties.FeignClientConfiguration config) { |
||||
super(type, name, config.getUrl()); |
||||
this.config = config; |
||||
} |
||||
|
||||
@Override |
||||
public String url() { |
||||
if (url == null) { |
||||
url = config.getUrl(); |
||||
} |
||||
return url; |
||||
} |
||||
|
||||
} |
@ -1,38 +0,0 @@
@@ -1,38 +0,0 @@
|
||||
/* |
||||
* Copyright 2013-2022 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.cloud.openfeign; |
||||
|
||||
/** |
||||
* This class wraps url inside an object so that relevant proxy instance can be created |
||||
* using {@link RefreshableUrlFactoryBean}. |
||||
* |
||||
* @author Jasbir Singh |
||||
* @since 4.0.0 |
||||
*/ |
||||
public class RefreshableUrl { |
||||
|
||||
private final String url; |
||||
|
||||
public RefreshableUrl(String url) { |
||||
this.url = url; |
||||
} |
||||
|
||||
public String getUrl() { |
||||
return url; |
||||
} |
||||
|
||||
} |
@ -1,75 +0,0 @@
@@ -1,75 +0,0 @@
|
||||
/* |
||||
* Copyright 2013-2022 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.cloud.openfeign; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
import org.springframework.beans.BeansException; |
||||
import org.springframework.beans.factory.FactoryBean; |
||||
import org.springframework.context.ApplicationContext; |
||||
import org.springframework.context.ApplicationContextAware; |
||||
import org.springframework.util.StringUtils; |
||||
|
||||
/** |
||||
* This factory bean creates {@link RefreshableUrl} instance as per the applicable |
||||
* configurations. |
||||
* |
||||
* @author Jasbir Singh |
||||
* @since 4.0.0 |
||||
*/ |
||||
public class RefreshableUrlFactoryBean implements FactoryBean<RefreshableUrl>, ApplicationContextAware { |
||||
|
||||
private ApplicationContext applicationContext; |
||||
|
||||
private String contextId; |
||||
|
||||
private RefreshableUrl refreshableUrl; |
||||
|
||||
@Override |
||||
public Class<?> getObjectType() { |
||||
return RefreshableUrl.class; |
||||
} |
||||
|
||||
@Override |
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { |
||||
this.applicationContext = applicationContext; |
||||
} |
||||
|
||||
@Override |
||||
public RefreshableUrl getObject() { |
||||
if (refreshableUrl != null) { |
||||
return refreshableUrl; |
||||
} |
||||
|
||||
FeignClientProperties properties = applicationContext.getBean(FeignClientProperties.class); |
||||
if (Objects.isNull(properties.getConfig())) { |
||||
return new RefreshableUrl(null); |
||||
} |
||||
FeignClientProperties.FeignClientConfiguration configuration = properties.getConfig().get(contextId); |
||||
if (Objects.isNull(configuration) || !StringUtils.hasText(configuration.getUrl())) { |
||||
return new RefreshableUrl(null); |
||||
} |
||||
|
||||
refreshableUrl = new RefreshableUrl(FeignClientsRegistrar.getUrl(configuration.getUrl())); |
||||
return refreshableUrl; |
||||
} |
||||
|
||||
public void setContextId(String contextId) { |
||||
this.contextId = contextId; |
||||
} |
||||
|
||||
} |
@ -1,126 +0,0 @@
@@ -1,126 +0,0 @@
|
||||
/* |
||||
* Copyright 2022-2022 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.cloud.openfeign.aot; |
||||
|
||||
import java.util.Collection; |
||||
import java.util.HashMap; |
||||
import java.util.HashSet; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
import java.util.stream.Collectors; |
||||
|
||||
import javax.lang.model.element.Modifier; |
||||
|
||||
import org.springframework.aot.generate.GeneratedMethod; |
||||
import org.springframework.aot.generate.GenerationContext; |
||||
import org.springframework.beans.factory.BeanFactory; |
||||
import org.springframework.beans.factory.aot.BeanRegistrationAotContribution; |
||||
import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor; |
||||
import org.springframework.beans.factory.aot.BeanRegistrationCode; |
||||
import org.springframework.beans.factory.support.RegisteredBean; |
||||
import org.springframework.cloud.openfeign.FeignClientFactory; |
||||
import org.springframework.cloud.openfeign.FeignClientSpecification; |
||||
import org.springframework.context.ApplicationContext; |
||||
import org.springframework.context.ConfigurableApplicationContext; |
||||
import org.springframework.context.aot.ApplicationContextAotGenerator; |
||||
import org.springframework.context.support.GenericApplicationContext; |
||||
import org.springframework.javapoet.ClassName; |
||||
import org.springframework.util.Assert; |
||||
|
||||
/** |
||||
* A {@link BeanRegistrationAotProcessor} that creates an |
||||
* {@link BeanRegistrationAotContribution} for Feign child contexts. |
||||
* |
||||
* @author Olga Maciaszek-Sharma |
||||
* @since 4.0.0 |
||||
*/ |
||||
public class FeignChildContextInitializer implements BeanRegistrationAotProcessor { |
||||
|
||||
private final ApplicationContext applicationContext; |
||||
|
||||
private final FeignClientFactory feignClientFactory; |
||||
|
||||
public FeignChildContextInitializer(ApplicationContext applicationContext, FeignClientFactory feignClientFactory) { |
||||
this.applicationContext = applicationContext; |
||||
this.feignClientFactory = feignClientFactory; |
||||
} |
||||
|
||||
@Override |
||||
public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) { |
||||
Assert.isInstanceOf(ConfigurableApplicationContext.class, applicationContext); |
||||
ConfigurableApplicationContext context = ((ConfigurableApplicationContext) applicationContext); |
||||
BeanFactory applicationBeanFactory = context.getBeanFactory(); |
||||
if (!((registeredBean.getBeanClass().equals(FeignClientFactory.class)) |
||||
&& registeredBean.getBeanFactory().equals(applicationBeanFactory))) { |
||||
return null; |
||||
} |
||||
Set<String> contextIds = new HashSet<>(getContextIdsFromConfig()); |
||||
Map<String, GenericApplicationContext> childContextAotContributions = contextIds.stream() |
||||
.map(contextId -> Map.entry(contextId, buildChildContext(contextId))) |
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); |
||||
return new AotContribution(childContextAotContributions); |
||||
} |
||||
|
||||
private GenericApplicationContext buildChildContext(String contextId) { |
||||
GenericApplicationContext childContext = feignClientFactory.buildContext(contextId); |
||||
feignClientFactory.registerBeans(contextId, childContext); |
||||
return childContext; |
||||
} |
||||
|
||||
private Collection<String> getContextIdsFromConfig() { |
||||
Map<String, FeignClientSpecification> configurations = feignClientFactory.getConfigurations(); |
||||
return configurations.keySet().stream().filter(key -> !key.startsWith("default.")).collect(Collectors.toSet()); |
||||
} |
||||
|
||||
private static class AotContribution implements BeanRegistrationAotContribution { |
||||
|
||||
private final Map<String, GenericApplicationContext> childContexts; |
||||
|
||||
AotContribution(Map<String, GenericApplicationContext> childContexts) { |
||||
this.childContexts = childContexts.entrySet().stream().filter(entry -> entry.getValue() != null) |
||||
.map(entry -> Map.entry(entry.getKey(), entry.getValue())) |
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); |
||||
} |
||||
|
||||
@Override |
||||
public void applyTo(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode) { |
||||
Map<String, ClassName> generatedInitializerClassNames = childContexts.entrySet().stream().map(entry -> { |
||||
String name = entry.getValue().getDisplayName(); |
||||
name = name.replaceAll("[-]", "_"); |
||||
GenerationContext childGenerationContext = generationContext.withName(name); |
||||
ClassName initializerClassName = new ApplicationContextAotGenerator() |
||||
.processAheadOfTime(entry.getValue(), childGenerationContext); |
||||
return Map.entry(entry.getKey(), initializerClassName); |
||||
}).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); |
||||
GeneratedMethod postProcessorMethod = beanRegistrationCode.getMethods() |
||||
.add("addFeignChildContextInitializer", method -> { |
||||
method.addJavadoc("Use AOT child context management initialization") |
||||
.addModifiers(Modifier.PRIVATE, Modifier.STATIC) |
||||
.addParameter(RegisteredBean.class, "registeredBean") |
||||
.addParameter(FeignClientFactory.class, "instance").returns(FeignClientFactory.class) |
||||
.addStatement("$T<String, Object> initializers = new $T<>()", Map.class, HashMap.class); |
||||
generatedInitializerClassNames.keySet() |
||||
.forEach(contextId -> method.addStatement("initializers.put($S, new $L())", contextId, |
||||
generatedInitializerClassNames.get(contextId))); |
||||
method.addStatement("return instance.withApplicationContextInitializers(initializers)"); |
||||
}); |
||||
beanRegistrationCode.addInstancePostProcessor(postProcessorMethod.toMethodReference()); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
@ -1,215 +0,0 @@
@@ -1,215 +0,0 @@
|
||||
/* |
||||
* Copyright 2022-2023 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.cloud.openfeign.aot; |
||||
|
||||
import java.lang.reflect.Method; |
||||
import java.lang.reflect.Parameter; |
||||
import java.util.Map; |
||||
import java.util.Objects; |
||||
import java.util.Set; |
||||
import java.util.stream.Collectors; |
||||
|
||||
import javax.lang.model.element.Modifier; |
||||
|
||||
import org.springframework.aot.generate.GenerationContext; |
||||
import org.springframework.aot.generate.MethodReference; |
||||
import org.springframework.aot.hint.BindingReflectionHintsRegistrar; |
||||
import org.springframework.aot.hint.ReflectionHints; |
||||
import org.springframework.aot.hint.RuntimeHints; |
||||
import org.springframework.beans.MutablePropertyValues; |
||||
import org.springframework.beans.factory.BeanFactory; |
||||
import org.springframework.beans.factory.FactoryBean; |
||||
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution; |
||||
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor; |
||||
import org.springframework.beans.factory.aot.BeanFactoryInitializationCode; |
||||
import org.springframework.beans.factory.aot.BeanRegistrationExcludeFilter; |
||||
import org.springframework.beans.factory.config.BeanDefinition; |
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder; |
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; |
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition; |
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder; |
||||
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils; |
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry; |
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory; |
||||
import org.springframework.beans.factory.support.GenericBeanDefinition; |
||||
import org.springframework.beans.factory.support.RegisteredBean; |
||||
import org.springframework.cloud.openfeign.FeignClientFactory; |
||||
import org.springframework.cloud.openfeign.FeignClientFactoryBean; |
||||
import org.springframework.cloud.openfeign.FeignClientSpecification; |
||||
import org.springframework.context.support.GenericApplicationContext; |
||||
import org.springframework.core.MethodParameter; |
||||
import org.springframework.javapoet.MethodSpec; |
||||
import org.springframework.util.Assert; |
||||
import org.springframework.util.ClassUtils; |
||||
|
||||
/** |
||||
* A {@link BeanFactoryInitializationAotProcessor} that creates an |
||||
* {@link BeanFactoryInitializationAotContribution} that registers bean definitions and |
||||
* proxy and reflection hints for Feign client beans. |
||||
* |
||||
* @author Olga Maciaszek-Sharma |
||||
* @since 4.0.0 |
||||
*/ |
||||
public class FeignClientBeanFactoryInitializationAotProcessor |
||||
implements BeanRegistrationExcludeFilter, BeanFactoryInitializationAotProcessor { |
||||
|
||||
private final GenericApplicationContext context; |
||||
|
||||
private final Map<String, BeanDefinition> feignClientBeanDefinitions; |
||||
|
||||
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar(); |
||||
|
||||
public FeignClientBeanFactoryInitializationAotProcessor(GenericApplicationContext context, |
||||
FeignClientFactory feignClientFactory) { |
||||
this.context = context; |
||||
this.feignClientBeanDefinitions = getFeignClientBeanDefinitions(feignClientFactory); |
||||
} |
||||
|
||||
@Override |
||||
public boolean isExcludedFromAotProcessing(RegisteredBean registeredBean) { |
||||
return registeredBean.getBeanClass().equals(FeignClientFactoryBean.class) |
||||
|| feignClientBeanDefinitions.containsKey(registeredBean.getBeanClass().getName()); |
||||
} |
||||
|
||||
private Map<String, BeanDefinition> getFeignClientBeanDefinitions(FeignClientFactory feignClientFactory) { |
||||
Map<String, FeignClientSpecification> configurations = feignClientFactory.getConfigurations(); |
||||
return configurations.values().stream().map(FeignClientSpecification::getClassName).filter(Objects::nonNull) |
||||
.filter(className -> !className.equals("default")) |
||||
.map(className -> Map.entry(className, context.getBeanDefinition(className))) |
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); |
||||
} |
||||
|
||||
@SuppressWarnings("NullableProblems") |
||||
@Override |
||||
public BeanFactoryInitializationAotContribution processAheadOfTime(ConfigurableListableBeanFactory beanFactory) { |
||||
BeanFactory applicationBeanFactory = context.getBeanFactory(); |
||||
if (feignClientBeanDefinitions.isEmpty() || !beanFactory.equals(applicationBeanFactory)) { |
||||
return null; |
||||
} |
||||
return new AotContribution(feignClientBeanDefinitions); |
||||
} |
||||
|
||||
private void registerMethodHints(ReflectionHints hints, Class<?> clazz) { |
||||
for (Method method : clazz.getDeclaredMethods()) { |
||||
registerMethodHints(hints, method); |
||||
} |
||||
} |
||||
|
||||
private void registerMethodHints(ReflectionHints hints, Method method) { |
||||
for (Parameter parameter : method.getParameters()) { |
||||
bindingRegistrar.registerReflectionHints(hints, |
||||
MethodParameter.forParameter(parameter).getGenericParameterType()); |
||||
} |
||||
MethodParameter returnTypeParameter = MethodParameter.forExecutable(method, -1); |
||||
if (!void.class.equals(returnTypeParameter.getParameterType())) { |
||||
bindingRegistrar.registerReflectionHints(hints, returnTypeParameter.getGenericParameterType()); |
||||
} |
||||
|
||||
} |
||||
|
||||
// Visible for tests
|
||||
final class AotContribution implements BeanFactoryInitializationAotContribution { |
||||
|
||||
private final Map<String, BeanDefinition> feignClientBeanDefinitions; |
||||
|
||||
private AotContribution(Map<String, BeanDefinition> feignClientBeanDefinitions) { |
||||
this.feignClientBeanDefinitions = feignClientBeanDefinitions; |
||||
} |
||||
|
||||
@Override |
||||
public void applyTo(GenerationContext generationContext, |
||||
BeanFactoryInitializationCode beanFactoryInitializationCode) { |
||||
RuntimeHints hints = generationContext.getRuntimeHints(); |
||||
Set<String> feignClientRegistrationMethods = feignClientBeanDefinitions.values().stream() |
||||
.map(beanDefinition -> { |
||||
Assert.notNull(beanDefinition, "beanDefinition cannot be null"); |
||||
Assert.isInstanceOf(GenericBeanDefinition.class, beanDefinition); |
||||
GenericBeanDefinition registeredBeanDefinition = (GenericBeanDefinition) beanDefinition; |
||||
MutablePropertyValues feignClientProperties = registeredBeanDefinition.getPropertyValues(); |
||||
String className = (String) feignClientProperties.get("type"); |
||||
Assert.notNull(className, "className cannot be null"); |
||||
Class<?> clazz = ClassUtils.resolveClassName(className, null); |
||||
hints.proxies().registerJdkProxy(clazz); |
||||
registerMethodHints(hints.reflection(), clazz); |
||||
return beanFactoryInitializationCode.getMethods() |
||||
.add(buildMethodName(className), method -> generateFeignClientRegistrationMethod(method, |
||||
feignClientProperties, registeredBeanDefinition)) |
||||
.getName(); |
||||
}).collect(Collectors.toSet()); |
||||
MethodReference initializerMethod = beanFactoryInitializationCode.getMethods() |
||||
.add("initialize", method -> generateInitializerMethod(method, feignClientRegistrationMethods)) |
||||
.toMethodReference(); |
||||
beanFactoryInitializationCode.addInitializer(initializerMethod); |
||||
} |
||||
|
||||
private String buildMethodName(String clientName) { |
||||
return "register" + clientName + "FeignClient"; |
||||
} |
||||
|
||||
private void generateInitializerMethod(MethodSpec.Builder method, Set<String> feignClientRegistrationMethods) { |
||||
method.addModifiers(Modifier.PUBLIC); |
||||
method.addParameter(DefaultListableBeanFactory.class, "registry"); |
||||
feignClientRegistrationMethods.forEach(feignClientRegistrationMethod -> method.addStatement("$N(registry)", |
||||
feignClientRegistrationMethod)); |
||||
} |
||||
|
||||
private void generateFeignClientRegistrationMethod(MethodSpec.Builder method, |
||||
MutablePropertyValues feignClientPropertyValues, GenericBeanDefinition registeredBeanDefinition) { |
||||
Object feignQualifiers = feignClientPropertyValues.get("qualifiers"); |
||||
Assert.notNull(feignQualifiers, "Feign qualifiers cannot be null"); |
||||
String qualifiers = "{\"" + String.join("\",\"", (String[]) feignQualifiers) + "\"}"; |
||||
method.addJavadoc("register Feign Client: $L", feignClientPropertyValues.get("type")) |
||||
.addModifiers(Modifier.PUBLIC, Modifier.STATIC) |
||||
.addParameter(BeanDefinitionRegistry.class, "registry") |
||||
.addStatement("Class clazz = $T.resolveClassName(\"$L\", null)", ClassUtils.class, |
||||
feignClientPropertyValues.get("type")) |
||||
.addStatement("$T definition = $T.genericBeanDefinition($T.class)", BeanDefinitionBuilder.class, |
||||
BeanDefinitionBuilder.class, FeignClientFactoryBean.class) |
||||
.addStatement("definition.addPropertyValue(\"name\",\"$L\")", feignClientPropertyValues.get("name")) |
||||
.addStatement("definition.addPropertyValue(\"contextId\", \"$L\")", |
||||
feignClientPropertyValues.get("contextId")) |
||||
.addStatement("definition.addPropertyValue(\"type\", clazz)") |
||||
.addStatement("definition.addPropertyValue(\"url\", \"$L\")", feignClientPropertyValues.get("url")) |
||||
.addStatement("definition.addPropertyValue(\"path\", \"$L\")", |
||||
feignClientPropertyValues.get("path")) |
||||
.addStatement("definition.addPropertyValue(\"dismiss404\", $L)", |
||||
feignClientPropertyValues.get("dismiss404")) |
||||
.addStatement("definition.addPropertyValue(\"fallback\", $T.class)", |
||||
feignClientPropertyValues.get("fallback")) |
||||
.addStatement("definition.addPropertyValue(\"fallbackFactory\", $T.class)", |
||||
feignClientPropertyValues.get("fallbackFactory")) |
||||
.addStatement("definition.setAutowireMode($L)", registeredBeanDefinition.getAutowireMode()) |
||||
.addStatement("definition.setLazyInit($L)", |
||||
registeredBeanDefinition.getLazyInit() != null ? registeredBeanDefinition.getLazyInit() |
||||
: false) |
||||
.addStatement("$T beanDefinition = definition.getBeanDefinition()", AbstractBeanDefinition.class) |
||||
.addStatement("beanDefinition.setAttribute(\"$L\", clazz)", FactoryBean.OBJECT_TYPE_ATTRIBUTE) |
||||
.addStatement("beanDefinition.setPrimary($L)", registeredBeanDefinition.isPrimary()) |
||||
.addStatement("$T holder = new $T(beanDefinition, \"$L\", new String[]$L)", |
||||
BeanDefinitionHolder.class, BeanDefinitionHolder.class, |
||||
feignClientPropertyValues.get("type"), qualifiers) |
||||
.addStatement("$T.registerBeanDefinition(holder, registry) ", BeanDefinitionReaderUtils.class); |
||||
} |
||||
|
||||
// Visible for tests
|
||||
Map<String, BeanDefinition> getFeignClientBeanDefinitions() { |
||||
return feignClientBeanDefinitions; |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
@ -1,45 +0,0 @@
@@ -1,45 +0,0 @@
|
||||
/* |
||||
* Copyright 2013-2023 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.cloud.openfeign.clientconfig; |
||||
|
||||
import java.net.http.HttpClient; |
||||
import java.time.Duration; |
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
||||
import org.springframework.cloud.openfeign.support.FeignHttpClientProperties; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
/** |
||||
* Default configuration for {@link HttpClient}. |
||||
* |
||||
* @author changjin wei(魏昌进) |
||||
*/ |
||||
@Configuration(proxyBeanMethods = false) |
||||
@ConditionalOnMissingBean(HttpClient.class) |
||||
public class Http2ClientFeignConfiguration { |
||||
|
||||
@Bean |
||||
public HttpClient httpClient(FeignHttpClientProperties httpClientProperties) { |
||||
return HttpClient.newBuilder() |
||||
.followRedirects(httpClientProperties.isFollowRedirects() ? HttpClient.Redirect.ALWAYS |
||||
: HttpClient.Redirect.NEVER) |
||||
.version(HttpClient.Version.valueOf(httpClientProperties.getHttp2().getVersion())) |
||||
.connectTimeout(Duration.ofMillis(httpClientProperties.getConnectionTimeout())).build(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,125 @@
@@ -0,0 +1,125 @@
|
||||
/* |
||||
* Copyright 2013-2022 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.cloud.openfeign.clientconfig; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.Timer; |
||||
import java.util.TimerTask; |
||||
|
||||
import javax.annotation.PreDestroy; |
||||
|
||||
import org.apache.commons.logging.Log; |
||||
import org.apache.commons.logging.LogFactory; |
||||
import org.apache.http.client.config.RequestConfig; |
||||
import org.apache.http.config.RegistryBuilder; |
||||
import org.apache.http.conn.HttpClientConnectionManager; |
||||
import org.apache.http.impl.client.CloseableHttpClient; |
||||
import org.apache.http.impl.client.HttpClientBuilder; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
||||
import org.springframework.cloud.commons.httpclient.ApacheHttpClientConnectionManagerFactory; |
||||
import org.springframework.cloud.commons.httpclient.ApacheHttpClientFactory; |
||||
import org.springframework.cloud.openfeign.support.FeignHttpClientProperties; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
/** |
||||
* Default configuration for {@link CloseableHttpClient}. |
||||
* |
||||
* @author Ryan Baxter |
||||
* @author Marcin Grzejszczak |
||||
* @author Spencer Gibb |
||||
* @author Olga Maciaszek-Sharma |
||||
*/ |
||||
@Configuration(proxyBeanMethods = false) |
||||
@ConditionalOnMissingBean(CloseableHttpClient.class) |
||||
public class HttpClientFeignConfiguration { |
||||
|
||||
private static final Log LOG = LogFactory.getLog(HttpClientFeignConfiguration.class); |
||||
|
||||
private final Timer connectionManagerTimer = new Timer("FeignApacheHttpClientConfiguration.connectionManagerTimer", |
||||
true); |
||||
|
||||
private CloseableHttpClient httpClient; |
||||
|
||||
@Autowired(required = false) |
||||
private RegistryBuilder registryBuilder; |
||||
|
||||
@Bean |
||||
@ConditionalOnMissingBean(HttpClientConnectionManager.class) |
||||
public HttpClientConnectionManager connectionManager( |
||||
ApacheHttpClientConnectionManagerFactory connectionManagerFactory, |
||||
FeignHttpClientProperties httpClientProperties) { |
||||
final HttpClientConnectionManager connectionManager = connectionManagerFactory.newConnectionManager( |
||||
httpClientProperties.isDisableSslValidation(), httpClientProperties.getMaxConnections(), |
||||
httpClientProperties.getMaxConnectionsPerRoute(), httpClientProperties.getTimeToLive(), |
||||
httpClientProperties.getTimeToLiveUnit(), this.registryBuilder); |
||||
this.connectionManagerTimer.schedule(new TimerTask() { |
||||
@Override |
||||
public void run() { |
||||
connectionManager.closeExpiredConnections(); |
||||
} |
||||
}, 30000, httpClientProperties.getConnectionTimerRepeat()); |
||||
return connectionManager; |
||||
} |
||||
|
||||
@Bean |
||||
@ConditionalOnProperty(value = "feign.compression.response.enabled", havingValue = "true") |
||||
public CloseableHttpClient customHttpClient(HttpClientConnectionManager httpClientConnectionManager, |
||||
FeignHttpClientProperties httpClientProperties) { |
||||
HttpClientBuilder builder = HttpClientBuilder.create().disableCookieManagement().useSystemProperties(); |
||||
this.httpClient = createClient(builder, httpClientConnectionManager, httpClientProperties); |
||||
return this.httpClient; |
||||
} |
||||
|
||||
@Bean |
||||
@ConditionalOnProperty(value = "feign.compression.response.enabled", havingValue = "false", matchIfMissing = true) |
||||
public CloseableHttpClient httpClient(ApacheHttpClientFactory httpClientFactory, |
||||
HttpClientConnectionManager httpClientConnectionManager, FeignHttpClientProperties httpClientProperties) { |
||||
this.httpClient = createClient(httpClientFactory.createBuilder(), httpClientConnectionManager, |
||||
httpClientProperties); |
||||
return this.httpClient; |
||||
} |
||||
|
||||
private CloseableHttpClient createClient(HttpClientBuilder builder, |
||||
HttpClientConnectionManager httpClientConnectionManager, FeignHttpClientProperties httpClientProperties) { |
||||
RequestConfig defaultRequestConfig = RequestConfig.custom() |
||||
.setConnectTimeout(httpClientProperties.getConnectionTimeout()) |
||||
.setRedirectsEnabled(httpClientProperties.isFollowRedirects()).build(); |
||||
CloseableHttpClient httpClient = builder.setDefaultRequestConfig(defaultRequestConfig) |
||||
.setConnectionManager(httpClientConnectionManager).build(); |
||||
return httpClient; |
||||
} |
||||
|
||||
@PreDestroy |
||||
public void destroy() { |
||||
this.connectionManagerTimer.cancel(); |
||||
if (this.httpClient != null) { |
||||
try { |
||||
this.httpClient.close(); |
||||
} |
||||
catch (IOException e) { |
||||
if (LOG.isErrorEnabled()) { |
||||
LOG.error("Could not correctly close httpClient."); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,78 @@
@@ -0,0 +1,78 @@
|
||||
/* |
||||
* Copyright 2013-2022 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.cloud.openfeign.clientconfig; |
||||
|
||||
import java.time.Duration; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
import javax.annotation.PreDestroy; |
||||
|
||||
import okhttp3.ConnectionPool; |
||||
import okhttp3.OkHttpClient; |
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
||||
import org.springframework.cloud.commons.httpclient.OkHttpClientConnectionPoolFactory; |
||||
import org.springframework.cloud.commons.httpclient.OkHttpClientFactory; |
||||
import org.springframework.cloud.openfeign.support.FeignHttpClientProperties; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
/** |
||||
* Defualt configuration for {@link OkHttpClient}. |
||||
* |
||||
* @author Ryan Baxter |
||||
* @author Marcin Grzejszczak |
||||
* @author Spencer Gibb |
||||
* @author Olga Maciaszek-Sharma |
||||
*/ |
||||
@Configuration(proxyBeanMethods = false) |
||||
@ConditionalOnMissingBean(okhttp3.OkHttpClient.class) |
||||
public class OkHttpFeignConfiguration { |
||||
|
||||
private okhttp3.OkHttpClient okHttpClient; |
||||
|
||||
@Bean |
||||
@ConditionalOnMissingBean(ConnectionPool.class) |
||||
public ConnectionPool httpClientConnectionPool(FeignHttpClientProperties httpClientProperties, |
||||
OkHttpClientConnectionPoolFactory connectionPoolFactory) { |
||||
int maxTotalConnections = httpClientProperties.getMaxConnections(); |
||||
long timeToLive = httpClientProperties.getTimeToLive(); |
||||
TimeUnit ttlUnit = httpClientProperties.getTimeToLiveUnit(); |
||||
return connectionPoolFactory.create(maxTotalConnections, timeToLive, ttlUnit); |
||||
} |
||||
|
||||
@Bean |
||||
public okhttp3.OkHttpClient client(OkHttpClientFactory httpClientFactory, ConnectionPool connectionPool, |
||||
FeignHttpClientProperties httpClientProperties) { |
||||
boolean followRedirects = httpClientProperties.isFollowRedirects(); |
||||
int connectTimeout = httpClientProperties.getConnectionTimeout(); |
||||
Duration reaTimeout = httpClientProperties.getOkHttp().getReadTimeout(); |
||||
this.okHttpClient = httpClientFactory.createBuilder(httpClientProperties.isDisableSslValidation()) |
||||
.connectTimeout(connectTimeout, TimeUnit.MILLISECONDS).followRedirects(followRedirects) |
||||
.readTimeout(reaTimeout).connectionPool(connectionPool).build(); |
||||
return this.okHttpClient; |
||||
} |
||||
|
||||
@PreDestroy |
||||
public void destroy() { |
||||
if (this.okHttpClient != null) { |
||||
this.okHttpClient.dispatcher().executorService().shutdown(); |
||||
this.okHttpClient.connectionPool().evictAll(); |
||||
} |
||||
} |
||||
|
||||
} |
@ -1,47 +0,0 @@
@@ -1,47 +0,0 @@
|
||||
/* |
||||
* Copyright 2013-2022 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.cloud.openfeign.loadbalancer; |
||||
|
||||
import feign.Request; |
||||
|
||||
import org.springframework.cloud.client.ServiceInstance; |
||||
import org.springframework.core.annotation.Order; |
||||
|
||||
/** |
||||
* Allows applications to transform the load-balanced {@link Request} given the chosen |
||||
* {@link org.springframework.cloud.client.ServiceInstance}. |
||||
* |
||||
* @author changjin wei(魏昌进) |
||||
*/ |
||||
@Order(LoadBalancerFeignRequestTransformer.DEFAULT_ORDER) |
||||
public interface LoadBalancerFeignRequestTransformer { |
||||
|
||||
/** |
||||
* Order for the {@link LoadBalancerFeignRequestTransformer}. |
||||
*/ |
||||
int DEFAULT_ORDER = 0; |
||||
|
||||
/** |
||||
* Allows transforming load-balanced requests based on the provided |
||||
* {@link ServiceInstance}. |
||||
* @param request Original request. |
||||
* @param instance ServiceInstance returned from LoadBalancer. |
||||
* @return New request or original request |
||||
*/ |
||||
Request transformRequest(Request request, ServiceInstance instance); |
||||
|
||||
} |
@ -1,63 +0,0 @@
@@ -1,63 +0,0 @@
|
||||
/* |
||||
* Copyright 2013-2022 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.cloud.openfeign.loadbalancer; |
||||
|
||||
import java.net.URI; |
||||
import java.util.Collection; |
||||
import java.util.Collections; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
import feign.Request; |
||||
|
||||
import org.springframework.cloud.client.ServiceInstance; |
||||
import org.springframework.cloud.client.loadbalancer.LoadBalancerProperties; |
||||
import org.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalancer; |
||||
|
||||
/** |
||||
* To add X-Forwarded-Host and X-Forwarded-Proto Headers. |
||||
* |
||||
* @author changjin wei(魏昌进) |
||||
*/ |
||||
public class XForwardedHeadersTransformer implements LoadBalancerFeignRequestTransformer { |
||||
|
||||
private final ReactiveLoadBalancer.Factory<ServiceInstance> factory; |
||||
|
||||
public XForwardedHeadersTransformer(ReactiveLoadBalancer.Factory<ServiceInstance> factory) { |
||||
this.factory = factory; |
||||
} |
||||
|
||||
@Override |
||||
public Request transformRequest(Request request, ServiceInstance instance) { |
||||
if (instance == null) { |
||||
return request; |
||||
} |
||||
LoadBalancerProperties.XForwarded xForwarded = factory.getProperties(instance.getServiceId()).getXForwarded(); |
||||
if (xForwarded.isEnabled()) { |
||||
Map<String, Collection<String>> headers = new HashMap<>(request.headers()); |
||||
URI uri = URI.create(request.url()); |
||||
String xForwardedHost = uri.getHost(); |
||||
String xForwardedProto = uri.getScheme(); |
||||
headers.put("X-Forwarded-Host", Collections.singleton(xForwardedHost)); |
||||
headers.put("X-Forwarded-Proto", Collections.singleton(xForwardedProto)); |
||||
request = Request.create(request.httpMethod(), request.url(), headers, request.body(), request.charset(), |
||||
request.requestTemplate()); |
||||
} |
||||
return request; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,184 @@
@@ -0,0 +1,184 @@
|
||||
/* |
||||
* Copyright 2015-2022 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.cloud.openfeign.security; |
||||
|
||||
import java.util.Arrays; |
||||
|
||||
import feign.RequestInterceptor; |
||||
import feign.RequestTemplate; |
||||
|
||||
import org.springframework.security.oauth2.client.OAuth2ClientContext; |
||||
import org.springframework.security.oauth2.client.http.AccessTokenRequiredException; |
||||
import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails; |
||||
import org.springframework.security.oauth2.client.resource.UserRedirectRequiredException; |
||||
import org.springframework.security.oauth2.client.token.AccessTokenProvider; |
||||
import org.springframework.security.oauth2.client.token.AccessTokenProviderChain; |
||||
import org.springframework.security.oauth2.client.token.AccessTokenRequest; |
||||
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsAccessTokenProvider; |
||||
import org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeAccessTokenProvider; |
||||
import org.springframework.security.oauth2.client.token.grant.implicit.ImplicitAccessTokenProvider; |
||||
import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordAccessTokenProvider; |
||||
import org.springframework.security.oauth2.common.OAuth2AccessToken; |
||||
|
||||
/** |
||||
* Pre-defined custom RequestInterceptor for Feign Requests. It uses the |
||||
* {@link OAuth2ClientContext OAuth2ClientContext} provided from the environment and |
||||
* construct a new header on the request before it is made by Feign. |
||||
* |
||||
* @author Joao Pedro Evangelista |
||||
* @author Tim Ysewyn |
||||
* @since 3.0.0 |
||||
* @deprecated in favour of {@link OAuth2AccessTokenInterceptor} |
||||
*/ |
||||
@Deprecated // spring-security-oauth2 reached EOL
|
||||
public class OAuth2FeignRequestInterceptor implements RequestInterceptor { |
||||
|
||||
/** |
||||
* The name of the token. |
||||
*/ |
||||
public static final String BEARER = "Bearer"; |
||||
|
||||
/** |
||||
* The name of the header. |
||||
*/ |
||||
public static final String AUTHORIZATION = "Authorization"; |
||||
|
||||
private final OAuth2ClientContext oAuth2ClientContext; |
||||
|
||||
private final OAuth2ProtectedResourceDetails resource; |
||||
|
||||
private final String tokenType; |
||||
|
||||
private final String header; |
||||
|
||||
private AccessTokenProvider accessTokenProvider = new AccessTokenProviderChain(Arrays.<AccessTokenProvider>asList( |
||||
new AuthorizationCodeAccessTokenProvider(), new ImplicitAccessTokenProvider(), |
||||
new ResourceOwnerPasswordAccessTokenProvider(), new ClientCredentialsAccessTokenProvider())); |
||||
|
||||
/** |
||||
* Default constructor which uses the provided OAuth2ClientContext and Bearer tokens |
||||
* within Authorization header. |
||||
* @param oAuth2ClientContext provided context |
||||
* @param resource type of resource to be accessed |
||||
*/ |
||||
public OAuth2FeignRequestInterceptor(OAuth2ClientContext oAuth2ClientContext, |
||||
OAuth2ProtectedResourceDetails resource) { |
||||
this(oAuth2ClientContext, resource, BEARER, AUTHORIZATION); |
||||
} |
||||
|
||||
/** |
||||
* Fully customizable constructor for changing token type and header name, in cases of |
||||
* Bearer and Authorization is not the default such as "bearer", "authorization". |
||||
* @param oAuth2ClientContext current oAuth2 Context |
||||
* @param resource type of resource to be accessed |
||||
* @param tokenType type of token e.g. "token", "Bearer" |
||||
* @param header name of the header e.g. "Authorization", "authorization" |
||||
*/ |
||||
public OAuth2FeignRequestInterceptor(OAuth2ClientContext oAuth2ClientContext, |
||||
OAuth2ProtectedResourceDetails resource, String tokenType, String header) { |
||||
this.oAuth2ClientContext = oAuth2ClientContext; |
||||
this.resource = resource; |
||||
this.tokenType = tokenType; |
||||
this.header = header; |
||||
} |
||||
|
||||
/** |
||||
* Create a template with the header of provided name and extracted extract. |
||||
* |
||||
* @see RequestInterceptor#apply(RequestTemplate) |
||||
*/ |
||||
@Override |
||||
public void apply(RequestTemplate template) { |
||||
template.header(header); // Clears out the header, no "clear" method available.
|
||||
template.header(header, extract(tokenType)); |
||||
} |
||||
|
||||
/** |
||||
* Extracts the token extract id the access token exists or returning an empty extract |
||||
* if there is no one on the context it may occasionally causes Unauthorized response |
||||
* since the token extract is empty. |
||||
* @param tokenType type name of token |
||||
* @return token value from context if it exists otherwise empty String |
||||
*/ |
||||
protected String extract(String tokenType) { |
||||
OAuth2AccessToken accessToken = getToken(); |
||||
return String.format("%s %s", tokenType, accessToken.getValue()); |
||||
} |
||||
|
||||
/** |
||||
* Extract the access token within the request or try to acquire a new one by |
||||
* delegating it to {@link #acquireAccessToken()}. |
||||
* @return valid token |
||||
*/ |
||||
public OAuth2AccessToken getToken() { |
||||
|
||||
OAuth2AccessToken accessToken = oAuth2ClientContext.getAccessToken(); |
||||
if (accessToken == null || accessToken.isExpired()) { |
||||
try { |
||||
accessToken = acquireAccessToken(); |
||||
} |
||||
catch (UserRedirectRequiredException e) { |
||||
oAuth2ClientContext.setAccessToken(null); |
||||
String stateKey = e.getStateKey(); |
||||
if (stateKey != null) { |
||||
Object stateToPreserve = e.getStateToPreserve(); |
||||
if (stateToPreserve == null) { |
||||
stateToPreserve = "NONE"; |
||||
} |
||||
oAuth2ClientContext.setPreservedState(stateKey, stateToPreserve); |
||||
} |
||||
throw e; |
||||
} |
||||
} |
||||
return accessToken; |
||||
} |
||||
|
||||
/** |
||||
* Try to acquire the token using a access token provider. |
||||
* @return valid access token |
||||
* @throws UserRedirectRequiredException in case the user needs to be redirected to an |
||||
* approval page or login page |
||||
*/ |
||||
protected OAuth2AccessToken acquireAccessToken() throws UserRedirectRequiredException { |
||||
AccessTokenRequest tokenRequest = oAuth2ClientContext.getAccessTokenRequest(); |
||||
if (tokenRequest == null) { |
||||
throw new AccessTokenRequiredException( |
||||
"Cannot find valid context on request for resource '" + resource.getId() + "'.", resource); |
||||
} |
||||
String stateKey = tokenRequest.getStateKey(); |
||||
if (stateKey != null) { |
||||
tokenRequest.setPreservedState(oAuth2ClientContext.removePreservedState(stateKey)); |
||||
} |
||||
OAuth2AccessToken existingToken = oAuth2ClientContext.getAccessToken(); |
||||
if (existingToken != null) { |
||||
oAuth2ClientContext.setAccessToken(existingToken); |
||||
} |
||||
OAuth2AccessToken obtainableAccessToken; |
||||
obtainableAccessToken = accessTokenProvider.obtainAccessToken(resource, tokenRequest); |
||||
if (obtainableAccessToken == null || obtainableAccessToken.getValue() == null) { |
||||
throw new IllegalStateException( |
||||
" Access token provider returned a null token, which is illegal according to the contract."); |
||||
} |
||||
oAuth2ClientContext.setAccessToken(obtainableAccessToken); |
||||
return obtainableAccessToken; |
||||
} |
||||
|
||||
public void setAccessTokenProvider(AccessTokenProvider accessTokenProvider) { |
||||
this.accessTokenProvider = accessTokenProvider; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,83 @@
@@ -0,0 +1,83 @@
|
||||
/* |
||||
* Copyright 2015-2021 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.cloud.openfeign.security; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
|
||||
import org.springframework.http.client.ClientHttpRequestInterceptor; |
||||
import org.springframework.security.oauth2.client.OAuth2ClientContext; |
||||
import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails; |
||||
import org.springframework.security.oauth2.client.token.AccessTokenProvider; |
||||
import org.springframework.security.oauth2.client.token.AccessTokenProviderChain; |
||||
import org.springframework.security.oauth2.client.token.OAuth2AccessTokenSupport; |
||||
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsAccessTokenProvider; |
||||
import org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeAccessTokenProvider; |
||||
import org.springframework.security.oauth2.client.token.grant.implicit.ImplicitAccessTokenProvider; |
||||
import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordAccessTokenProvider; |
||||
|
||||
/** |
||||
* Allows to customize pre-defined {@link OAuth2FeignRequestInterceptor} using configurer |
||||
* beans of class {@link OAuth2FeignRequestInterceptorConfigurer}. Each configurer |
||||
* instance can add {@link AccessTokenProvider} new {@link ClientHttpRequestInterceptor} |
||||
* instances. |
||||
* |
||||
* @author Wojciech Mąka |
||||
* @since 3.1.1 |
||||
* @deprecated since spring-security-oauth2 reached EOL |
||||
*/ |
||||
@Deprecated // spring-security-oauth2 reached EOL
|
||||
public class OAuth2FeignRequestInterceptorBuilder { |
||||
|
||||
private final AccessTokenProvider accessTokenProvider; |
||||
|
||||
private final List<ClientHttpRequestInterceptor> accessTokenProviderInterceptors = new ArrayList<>(); |
||||
|
||||
public OAuth2FeignRequestInterceptorBuilder() { |
||||
accessTokenProvider = new AccessTokenProviderChain(Arrays.<AccessTokenProvider>asList( |
||||
new AuthorizationCodeAccessTokenProvider(), new ImplicitAccessTokenProvider(), |
||||
new ResourceOwnerPasswordAccessTokenProvider(), new ClientCredentialsAccessTokenProvider())); |
||||
} |
||||
|
||||
public OAuth2FeignRequestInterceptorBuilder withAccessTokenProviderInterceptors( |
||||
ClientHttpRequestInterceptor... interceptors) { |
||||
accessTokenProviderInterceptors.addAll(Arrays.asList(interceptors)); |
||||
return this; |
||||
} |
||||
|
||||
OAuth2FeignRequestInterceptor build(OAuth2ClientContext oAuth2ClientContext, |
||||
OAuth2ProtectedResourceDetails resource) { |
||||
if (OAuth2AccessTokenSupport.class.isAssignableFrom(accessTokenProvider.getClass())) { |
||||
((OAuth2AccessTokenSupport) accessTokenProvider).setInterceptors(accessTokenProviderInterceptors); |
||||
} |
||||
final OAuth2FeignRequestInterceptor feignRequestInterceptor = new OAuth2FeignRequestInterceptor( |
||||
oAuth2ClientContext, resource); |
||||
feignRequestInterceptor.setAccessTokenProvider(accessTokenProvider); |
||||
return feignRequestInterceptor; |
||||
} |
||||
|
||||
public static OAuth2FeignRequestInterceptor buildWithConfigurers(OAuth2ClientContext oAuth2ClientContext, |
||||
OAuth2ProtectedResourceDetails resource, List<OAuth2FeignRequestInterceptorConfigurer> buildConfigurers) { |
||||
final OAuth2FeignRequestInterceptorBuilder builder = new OAuth2FeignRequestInterceptorBuilder(); |
||||
for (OAuth2FeignRequestInterceptorConfigurer configurer : buildConfigurers) { |
||||
configurer.customize(builder); |
||||
} |
||||
return builder.build(oAuth2ClientContext, resource); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
/* |
||||
* Copyright 2015-2022 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.cloud.openfeign.security; |
||||
|
||||
import org.springframework.security.oauth2.client.token.AccessTokenProvider; |
||||
|
||||
/** |
||||
* Interface for configurer beans working with |
||||
* {@link OAuth2FeignRequestInterceptorBuilder} in order to provide custom interceptors |
||||
* for {@link AccessTokenProvider} managed internally by |
||||
* {@link OAuth2FeignRequestInterceptor}. |
||||
* |
||||
* @author Wojciech Mąka |
||||
* @since 3.1.1 |
||||
* @deprecated since spring-security-oauth2 reached EOL |
||||
*/ |
||||
@Deprecated // spring-security-oauth2 reached EOL
|
||||
@FunctionalInterface |
||||
public interface OAuth2FeignRequestInterceptorConfigurer { |
||||
|
||||
void customize(OAuth2FeignRequestInterceptorBuilder requestInterceptorBuilder); |
||||
|
||||
} |
@ -1,5 +1,6 @@
@@ -1,5 +1,6 @@
|
||||
org.springframework.cloud.openfeign.hateoas.FeignHalAutoConfiguration |
||||
org.springframework.cloud.openfeign.FeignAutoConfiguration |
||||
org.springframework.cloud.openfeign.encoding.FeignAcceptGzipEncodingAutoConfiguration |
||||
org.springframework.cloud.openfeign.encoding.FeignContentGzipEncodingAutoConfiguration |
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ |
||||
org.springframework.cloud.openfeign.hateoas.FeignHalAutoConfiguration,\ |
||||
org.springframework.cloud.openfeign.FeignAutoConfiguration,\ |
||||
org.springframework.cloud.openfeign.encoding.FeignAcceptGzipEncodingAutoConfiguration,\ |
||||
org.springframework.cloud.openfeign.encoding.FeignContentGzipEncodingAutoConfiguration,\ |
||||
org.springframework.cloud.openfeign.loadbalancer.FeignLoadBalancerAutoConfiguration |
@ -1,2 +0,0 @@
@@ -1,2 +0,0 @@
|
||||
org.springframework.aot.hint.RuntimeHintsRegistrar=\ |
||||
org.springframework.cloud.openfeign.FeignHints |
@ -1,169 +0,0 @@
@@ -1,169 +0,0 @@
|
||||
/* |
||||
* Copyright 2013-2022 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.cloud.openfeign; |
||||
|
||||
import java.lang.reflect.Field; |
||||
import java.util.List; |
||||
|
||||
import feign.Capability; |
||||
import feign.Feign; |
||||
import feign.Logger; |
||||
import feign.RequestInterceptor; |
||||
import feign.micrometer.MicrometerObservationCapability; |
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
import org.springframework.cloud.openfeign.clientconfig.FeignClientConfigurer; |
||||
import org.springframework.context.ApplicationContext; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.test.annotation.DirtiesContext; |
||||
import org.springframework.util.ReflectionUtils; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
/** |
||||
* @author matt king |
||||
* @author Jonatan Ivanov |
||||
* @author Olga Maciaszek-Sharma |
||||
*/ |
||||
@DirtiesContext |
||||
@SpringBootTest(classes = EagerInitFeignClientUsingConfigurerTests.Application.class, value = { |
||||
"spring.cloud.openfeign.client.config.default.loggerLevel=full", |
||||
"spring.cloud.openfeign.client.config.default.requestInterceptors[0]=org.springframework.cloud.openfeign.FeignClientUsingPropertiesTests.FooRequestInterceptor", |
||||
"spring.cloud.openfeign.client.config.default.requestInterceptors[1]=org.springframework.cloud.openfeign.FeignClientUsingPropertiesTests.BarRequestInterceptor" }) |
||||
class EagerInitFeignClientUsingConfigurerTests { |
||||
|
||||
@Autowired |
||||
private ApplicationContext applicationContext; |
||||
|
||||
@Autowired |
||||
private FeignClientFactory context; |
||||
|
||||
private static final String BEAN_NAME_PREFIX = "&org.springframework.cloud.openfeign.EagerInitFeignClientUsingConfigurerTests$"; |
||||
|
||||
@Test |
||||
public void testFeignClient() { |
||||
FeignClientFactoryBean factoryBean = (FeignClientFactoryBean) applicationContext |
||||
.getBean(BEAN_NAME_PREFIX + "TestFeignClient"); |
||||
Feign.Builder builder = factoryBean.feign(context); |
||||
|
||||
List<RequestInterceptor> interceptors = (List) getBuilderValue(builder, "requestInterceptors"); |
||||
assertThat(interceptors.size()).as("interceptors not set").isEqualTo(3); |
||||
assertThat(getBuilderValue(builder, "logLevel")).as("log level not set").isEqualTo(Logger.Level.FULL); |
||||
|
||||
List<Capability> capabilities = (List) getBuilderValue(builder, "capabilities"); |
||||
assertThat(capabilities).hasSize(2).hasAtLeastOneElementOfType(NoOpCapability.class) |
||||
.hasAtLeastOneElementOfType(MicrometerObservationCapability.class); |
||||
} |
||||
|
||||
private Object getBuilderValue(Feign.Builder builder, String member) { |
||||
Field builderField = ReflectionUtils.findField(Feign.Builder.class, member); |
||||
ReflectionUtils.makeAccessible(builderField); |
||||
|
||||
return ReflectionUtils.getField(builderField, builder); |
||||
} |
||||
|
||||
@Test |
||||
public void testNoInheritFeignClient() { |
||||
FeignClientFactoryBean factoryBean = (FeignClientFactoryBean) applicationContext |
||||
.getBean(BEAN_NAME_PREFIX + "NoInheritFeignClient"); |
||||
Feign.Builder builder = factoryBean.feign(context); |
||||
|
||||
List<RequestInterceptor> interceptors = (List) getBuilderValue(builder, "requestInterceptors"); |
||||
assertThat(interceptors).as("interceptors not set").isEmpty(); |
||||
assertThat(factoryBean.isInheritParentContext()).as("is inheriting from parent configuration").isFalse(); |
||||
|
||||
List<Capability> capabilities = (List) getBuilderValue(builder, "capabilities"); |
||||
assertThat(capabilities).hasSize(2).hasAtLeastOneElementOfType(NoOpCapability.class) |
||||
.hasAtLeastOneElementOfType(MicrometerObservationCapability.class); |
||||
} |
||||
|
||||
@Test |
||||
public void testNoInheritFeignClient_ignoreProperties() { |
||||
FeignClientFactoryBean factoryBean = (FeignClientFactoryBean) applicationContext |
||||
.getBean(BEAN_NAME_PREFIX + "NoInheritFeignClient"); |
||||
Feign.Builder builder = factoryBean.feign(context); |
||||
|
||||
assertThat(getBuilderValue(builder, "logLevel")).as("log level not set").isEqualTo(Logger.Level.HEADERS); |
||||
|
||||
List<Capability> capabilities = (List) getBuilderValue(builder, "capabilities"); |
||||
assertThat(capabilities).hasSize(2).hasAtLeastOneElementOfType(NoOpCapability.class) |
||||
.hasAtLeastOneElementOfType(MicrometerObservationCapability.class); |
||||
} |
||||
|
||||
@EnableAutoConfiguration |
||||
@Configuration(proxyBeanMethods = false) |
||||
@EnableFeignClients(clients = { TestFeignClient.class, NoInheritFeignClient.class }) |
||||
protected static class Application { |
||||
|
||||
@Bean |
||||
public RequestInterceptor requestInterceptor() { |
||||
return requestTemplate -> { |
||||
}; |
||||
} |
||||
|
||||
@Bean |
||||
public NoOpCapability noOpCapability() { |
||||
return new NoOpCapability(); |
||||
} |
||||
|
||||
} |
||||
|
||||
public static class NoInheritConfiguration { |
||||
|
||||
@Bean |
||||
public Logger.Level logLevel() { |
||||
return Logger.Level.HEADERS; |
||||
} |
||||
|
||||
@Bean |
||||
public NoOpCapability noOpCapability() { |
||||
return new NoOpCapability(); |
||||
} |
||||
|
||||
@Bean |
||||
public FeignClientConfigurer feignClientConfigurer() { |
||||
return new FeignClientConfigurer() { |
||||
|
||||
@Override |
||||
public boolean inheritParentConfiguration() { |
||||
return false; |
||||
} |
||||
}; |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
@FeignClient("testFeignClient") |
||||
interface TestFeignClient { |
||||
|
||||
} |
||||
|
||||
@FeignClient(name = "noInheritFeignClient", configuration = NoInheritConfiguration.class) |
||||
interface NoInheritFeignClient { |
||||
|
||||
} |
||||
|
||||
private static class NoOpCapability implements Capability { |
||||
|
||||
} |
||||
|
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue