Skip to content

Commit 0e906dc

Browse files
committed
Use convention based code imports
Closes gh-29647
1 parent 71695d2 commit 0e906dc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+250
-967
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/cloud-foundry.adoc

+1-4
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,4 @@ If you expect the Cloud Foundry endpoints to always be available at `/cloudfound
4747
The configuration differs, depending on the web server in use.
4848
For Tomcat, you can add the following configuration:
4949

50-
[source,java,indent=0,subs="verbatim"]
51-
----
52-
include::{docs-java}/actuator/cloudfoundry/customcontextpath/MyCloudFoundryConfiguration.java[]
53-
----
50+
include::code:MyCloudFoundryConfiguration[]

spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/endpoints.adoc

+7-28
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,7 @@ If you wish to configure custom security for HTTP endpoints (for example, to all
328328

329329
A typical Spring Security configuration might look something like the following example:
330330

331-
[source,java,indent=0,subs="verbatim"]
332-
----
333-
include::{docs-java}/actuator/endpoints/security/typical/MySecurityConfiguration.java[]
334-
----
331+
include::code:typical/MySecurityConfiguration[]
335332

336333
The preceding example uses `EndpointRequest.toAnyEndpoint()` to match a request to any endpoint and then ensures that all have the `ENDPOINT_ADMIN` role.
337334
Several other matcher methods are also available on `EndpointRequest`.
@@ -351,10 +348,7 @@ You can do so by changing the configprop:management.endpoints.web.exposure.inclu
351348

352349
Additionally, if Spring Security is present, you would need to add custom security configuration that allows unauthenticated access to the endpoints, as the following example shows:
353350

354-
[source,java,indent=0,subs="verbatim"]
355-
----
356-
include::{docs-java}/actuator/endpoints/security/exposeall/MySecurityConfiguration.java[]
357-
----
351+
include::code:exposeall/MySecurityConfiguration[]
358352

359353
NOTE: In both of the preceding examples, the configuration applies only to the actuator endpoints.
360354
Since Spring Boot's security configuration backs off completely in the presence of any `SecurityFilterChain` bean, you need to configure an additional `SecurityFilterChain` bean with rules that apply to the rest of the application.
@@ -443,10 +437,7 @@ If both Jersey and Spring MVC are available, Spring MVC is used.
443437

444438
The following example exposes a read operation that returns a custom object:
445439

446-
[source,java,indent=0,subs="verbatim"]
447-
----
448-
include::{docs-java}/actuator/endpoints/implementingcustom/MyEndpoint.java[tag=read]
449-
----
440+
include::code:MyEndpoint[tag=read]
450441

451442
You can also write technology-specific endpoints by using `@JmxEndpoint` or `@WebEndpoint`.
452443
These endpoints are restricted to their respective technologies.
@@ -480,10 +471,7 @@ Consider the following JSON request body:
480471

481472
You can use this to invoke a write operation that takes `String name` and `int counter` parameters, as the following example shows:
482473

483-
[source,java,indent=0,subs="verbatim"]
484-
----
485-
include::{docs-java}/actuator/endpoints/implementingcustom/input/../MyEndpoint.java[tag=write]
486-
----
474+
include::code:../MyEndpoint[tag=write]
487475

488476
TIP: Because endpoints are technology agnostic, only simple types can be specified in the method signature.
489477
In particular, declaring a single parameter with a `CustomData` type that defines a `name` and `counter` properties is not supported.
@@ -759,10 +747,7 @@ You need to provide an implementation of the `health()` method and return a `Hea
759747
The `Health` response should include a status and can optionally include additional details to be displayed.
760748
The following code shows a sample `HealthIndicator` implementation:
761749

762-
[source,java,indent=0,subs="verbatim"]
763-
----
764-
include::{docs-java}/actuator/endpoints/health/writingcustomhealthindicators/MyHealthIndicator.java[]
765-
----
750+
include::code:MyHealthIndicator[]
766751

767752
NOTE: The identifier for a given `HealthIndicator` is the name of the bean without the `HealthIndicator` suffix, if it exists.
768753
In the preceding example, the health information is available in an entry named `my`.
@@ -837,10 +822,7 @@ If you need to register a regular `HealthContributor`, you should wrap it with `
837822
To provide custom health information from a reactive API, you can register Spring beans that implement the {spring-boot-actuator-module-code}/health/ReactiveHealthIndicator.java[`ReactiveHealthIndicator`] interface.
838823
The following code shows a sample `ReactiveHealthIndicator` implementation:
839824

840-
[source,java,indent=0,subs="verbatim"]
841-
----
842-
include::{docs-java}/actuator/endpoints/health/reactivehealthindicators/MyReactiveHealthIndicator.java[]
843-
----
825+
include::code:MyReactiveHealthIndicator[]
844826

845827
TIP: To handle the error automatically, consider extending from `AbstractReactiveHealthIndicator`.
846828

@@ -1283,10 +1265,7 @@ To provide custom application information, you can register Spring beans that im
12831265

12841266
The following example contributes an `example` entry with a single value:
12851267

1286-
[source,java,indent=0,subs="verbatim"]
1287-
----
1288-
include::{docs-java}/actuator/endpoints/info/writingcustominfocontributors/MyInfoContributor.java[]
1289-
----
1268+
include::code:MyInfoContributor[]
12901269

12911270
If you reach the `info` endpoint, you should see a response that contains the following additional entry:
12921271

spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/metrics.adoc

+12-48
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,11 @@ Spring Boot also adds any auto-configured registries to the global static compos
6565

6666
You can register any number of `MeterRegistryCustomizer` beans to further configure the registry, such as applying common tags, before any meters are registered with the registry:
6767

68-
[source,java,indent=0,subs="verbatim"]
69-
----
70-
include::{docs-java}/actuator/metrics/gettingstarted/commontags/MyMeterRegistryConfiguration.java[]
71-
----
68+
include::code:commontags/MyMeterRegistryConfiguration[]
7269

7370
You can apply customizations to particular registry implementations by being more specific about the generic type:
7471

75-
[source,java,indent=0,subs="verbatim"]
76-
----
77-
include::{docs-java}/actuator/metrics/gettingstarted/specifictype/MyMeterRegistryConfiguration.java[]
78-
----
72+
include::code:specifictype/MyMeterRegistryConfiguration[]
7973

8074
Spring Boot also <<actuator#actuator.metrics.supported,configures built-in instrumentation>> that you can control through configuration or dedicated annotation markers.
8175

@@ -308,10 +302,7 @@ Micrometer provides a default `HierarchicalNameMapper` that governs how a dimens
308302
To take control over this behavior, define your `GraphiteMeterRegistry` and supply your own `HierarchicalNameMapper`.
309303
An auto-configured `GraphiteConfig` and `Clock` beans are provided unless you define your own:
310304
311-
[source,java,indent=0,subs="verbatim"]
312-
----
313-
include::{docs-java}/actuator/metrics/export/graphite/MyGraphiteConfiguration.java[]
314-
----
305+
include::code:MyGraphiteConfiguration[]
315306
====
316307

317308

@@ -384,10 +375,7 @@ Micrometer provides a default `HierarchicalNameMapper` that governs how a dimens
384375
To take control over this behavior, define your `JmxMeterRegistry` and supply your own `HierarchicalNameMapper`.
385376
An auto-configured `JmxConfig` and `Clock` beans are provided unless you define your own:
386377
387-
[source,java,indent=0,subs="verbatim"]
388-
----
389-
include::{docs-java}/actuator/metrics/export/jmx/MyJmxConfiguration.java[]
390-
----
378+
include::code:MyJmxConfiguration[]
391379
====
392380

393381

@@ -1045,10 +1033,7 @@ Each metric is tagged with the following information by default:
10451033

10461034
To replace the default metric tags, define a `MongoCommandTagsProvider` bean, as the following example shows:
10471035

1048-
[source,java,indent=0,subs="verbatim"]
1049-
----
1050-
include::{docs-java}/actuator/metrics/supported/mongodb/command/MyCommandTagsProviderConfiguration.java[]
1051-
----
1036+
include::code:MyCommandTagsProviderConfiguration[]
10521037

10531038
To disable the auto-configured command metrics, set the following property:
10541039

@@ -1086,10 +1071,7 @@ Each metric is tagged with the following information by default:
10861071

10871072
To replace the default metric tags, define a `MongoConnectionPoolTagsProvider` bean:
10881073

1089-
[source,java,indent=0,subs="verbatim"]
1090-
----
1091-
include::{docs-java}/actuator/metrics/supported/mongodb/connectionpool/MyConnectionPoolTagsProviderConfiguration.java[]
1092-
----
1074+
include::code:MyConnectionPoolTagsProviderConfiguration[]
10931075

10941076
To disable the auto-configured connection pool metrics, set the following property:
10951077

@@ -1118,24 +1100,15 @@ If supported, you can use the annotation at either the class level or the method
11181100

11191101
For example, the following code shows how you can use the annotation to instrument all request mappings in a `@RestController`:
11201102

1121-
[source,java,indent=0,subs="verbatim"]
1122-
----
1123-
include::{docs-java}/actuator/metrics/supported/timedannotation/all/MyController.java[]
1124-
----
1103+
include::code:all/MyController[]
11251104

11261105
If you want only to instrument a single mapping, you can use the annotation on the method instead of the class:
11271106

1128-
[source,java,indent=0,subs="verbatim"]
1129-
----
1130-
include::{docs-java}/actuator/metrics/supported/timedannotation/single/MyController.java[]
1131-
----
1107+
include::code:single/MyController[]
11321108

11331109
You can also combine class-level and method-level annotations if you want to change the timing details for a specific method:
11341110

1135-
[source,java,indent=0,subs="verbatim"]
1136-
----
1137-
include::{docs-java}/actuator/metrics/supported/timedannotation/change/MyController.java[]
1138-
----
1111+
include::code:change/MyController[]
11391112

11401113
NOTE: A `@Timed` annotation with `longTask = true` enables a long task timer for the method.
11411114
Long task timers require a separate metric name and can be stacked with a short task timer.
@@ -1153,17 +1126,11 @@ For more detail, see the {lettuce-docs}#command.latency.metrics.micrometer[Micro
11531126
=== Registering Custom Metrics
11541127
To register custom metrics, inject `MeterRegistry` into your component:
11551128

1156-
[source,java,indent=0,subs="verbatim"]
1157-
----
1158-
include::{docs-java}/actuator/metrics/registeringcustom/MyBean.java[]
1159-
----
1129+
include::code:MyBean[]
11601130

11611131
If your metrics depend on other beans, we recommend that you use a `MeterBinder` to register them:
11621132

1163-
[source,java,indent=0,subs="verbatim"]
1164-
----
1165-
include::{docs-java}/actuator/metrics/registeringcustom/MyMeterBinderConfiguration.java[]
1166-
----
1133+
include::code:MyMeterBinderConfiguration[]
11671134

11681135
Using a `MeterBinder` ensures that the correct dependency relationships are set up and that the bean is available when the metric's value is retrieved.
11691136
A `MeterBinder` implementation can also be useful if you find that you repeatedly instrument a suite of metrics across components or applications.
@@ -1178,10 +1145,7 @@ If you need to apply customizations to specific `Meter` instances, you can use t
11781145

11791146
For example, if you want to rename the `mytag.region` tag to `mytag.area` for all meter IDs beginning with `com.example`, you can do the following:
11801147

1181-
[source,java,indent=0,subs="verbatim"]
1182-
----
1183-
include::{docs-java}/actuator/metrics/customizing/MyMetricsFilterConfiguration.java[]
1184-
----
1148+
include::code:MyMetricsFilterConfiguration[]
11851149

11861150
NOTE: By default, all `MeterFilter` beans are automatically bound to the Spring-managed `MeterRegistry`.
11871151
Make sure to register your metrics by using the Spring-managed `MeterRegistry` and not any of the static methods on `Metrics`.

spring-boot-project/spring-boot-docs/src/docs/asciidoc/attributes.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
:github-raw: https://raw.githubusercontent.com/{github-repo}/{github-tag}
1919
:github-issues: https://github.com/{github-repo}/issues/
2020
:github-wiki: https://github.com/{github-repo}/wiki
21-
:docs-java: ../../main/java/org/springframework/boot/docs
22-
:docs-groovy: ../../main/groovy/org/springframework/boot/docs
21+
:docs-java: {docdir}/../main/java/org/springframework/boot/docs
22+
:docs-groovy: {docdir}/../main/groovy/org/springframework/boot/docs
2323
:docs-resources: ../../main/resources
2424
:spring-boot-code: https://github.com/{github-repo}/tree/{github-tag}
2525
:spring-boot-api: https://docs.spring.io/spring-boot/docs/{spring-boot-version}/api

spring-boot-project/spring-boot-docs/src/docs/asciidoc/build-tool-plugins/other-build-systems.adoc

+1-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,4 @@ An exception is thrown if more than one candidate is found.
3737
=== Example Repackage Implementation
3838
The following example shows a typical repackage implementation:
3939

40-
[source,java,indent=0,subs="verbatim"]
41-
----
42-
include::{docs-java}/buildtoolplugins/otherbuildsystems/examplerepackageimplementation/MyBuildTool.java[]
43-
----
40+
include::code:MyBuildTool[]

spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/annotation-processor.adoc

+3-12
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ The annotation processor also supports the use of the `@Data`, `@Value`, `@Gette
6969

7070
Consider the following example:
7171

72-
[source,java,indent=0,subs="verbatim"]
73-
----
74-
include::{docs-java}/configurationmetadata/annotationprocessor/automaticmetadatageneration/MyServerProperties.java[]
75-
----
72+
include::code:MyServerProperties[]
7673

7774
This exposes three properties where `my.server.name` has no default and `my.server.ip` and `my.server.port` defaults to `"127.0.0.1"` and `9797` respectively.
7875
The Javadoc on fields is used to populate the `description` attribute. For instance, the description of `my.server.ip` is "IP address to listen to.".
@@ -86,10 +83,7 @@ Also, the annotation processor cannot auto-detect default values for ``Enum``s a
8683
For cases where the default value could not be detected, <<configuration-metadata#configuration-metadata.annotation-processor.adding-additional-metadata,manual metadata>> should be provided.
8784
Consider the following example:
8885

89-
[source,java,indent=0,subs="verbatim"]
90-
----
91-
include::{docs-java}/configurationmetadata/annotationprocessor/automaticmetadatageneration/MyMessagingProperties.java[]
92-
----
86+
include::code:MyMessagingProperties[]
9387

9488
In order to document default values for properties in the class above, you could add the following content to <<configuration-metadata#configuration-metadata.annotation-processor.adding-additional-metadata,the manual metadata of the module>>:
9589

@@ -117,10 +111,7 @@ The annotation processor automatically considers inner classes as nested propert
117111
Rather than documenting the `ip` and `port` at the root of the namespace, we could create a sub-namespace for it.
118112
Consider the updated example:
119113

120-
[source,java,indent=0,subs="verbatim"]
121-
----
122-
include::{docs-java}/configurationmetadata/annotationprocessor/automaticmetadatageneration/nestedproperties/MyServerProperties.java[]
123-
----
114+
include::code:MyServerProperties[]
124115

125116
The preceding example produces metadata information for `my.server.name`, `my.server.host.ip`, and `my.server.host.port` properties.
126117
You can use the `@NestedConfigurationProperty` annotation on a field to indicate that a regular (non-inner) class should be treated as if it were nested.

spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/format.adoc

+1-4
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,7 @@ Deprecation can also be specified declaratively in code by adding the `@Deprecat
208208
For instance, assume that the `my.app.target` property was confusing and was renamed to `my.app.name`.
209209
The following example shows how to handle that situation:
210210

211-
[source,java,indent=0,subs="verbatim"]
212-
----
213-
include::{docs-java}/configurationmetadata/format/property/MyProperties.java[]
214-
----
211+
include::code:MyProperties[]
215212

216213
NOTE: There is no way to set a `level`.
217214
`warning` is always assumed, since code is still handling the property.

spring-boot-project/spring-boot-docs/src/docs/asciidoc/configuration-metadata/manual-hints.adoc

+1-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ The special `.keys` and `.values` suffixes must refer to the keys and the values
1818

1919
Assume a `my.contexts` maps magic `String` values to an integer, as shown in the following example:
2020

21-
[source,java,indent=0,subs="verbatim"]
22-
----
23-
include::{docs-java}/configurationmetadata/manualhints/valuehint/MyProperties.java[]
24-
----
21+
include::code:MyProperties[]
2522

2623
The magic values are (in this example) are `sample1` and `sample2`.
2724
In order to offer additional content assistance for the keys, you could add the following JSON to <<configuration-metadata#configuration-metadata.annotation-processor.adding-additional-metadata,the manual metadata of the module>>:

spring-boot-project/spring-boot-docs/src/docs/asciidoc/data.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ include::data/sql.adoc[]
88

99
include::data/nosql.adoc[]
1010

11-
include::data/whats-next.adoc[]
11+
include::data/whats-next.adoc[]

0 commit comments

Comments
 (0)