Skip to content

Commit 40f9ac5

Browse files
committed
Further polishing of AOT section
1 parent 95ad25e commit 40f9ac5

File tree

1 file changed

+16
-11
lines changed
  • framework-docs/modules/ROOT/pages/core

1 file changed

+16
-11
lines changed

framework-docs/modules/ROOT/pages/core/aot.adoc

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ build time.
271271
While your application may interact with an interface that a bean implements, it is still very important to declare the most precise type.
272272
The AOT engine performs additional checks on the bean type, such as detecting the presence of `@Autowired` members or lifecycle callback methods.
273273

274-
For `@Configuration` classes, make sure that the return type of a `@Bean` factory method is as precise as possible.
274+
For `@Configuration` classes, make sure that the return type of an `@Bean` factory method is as precise as possible.
275275
Consider the following example:
276276

277277
[tabs]
@@ -602,9 +602,12 @@ A number of convenient annotations are also provided for common use cases.
602602
[[aot.hints.import-runtime-hints]]
603603
=== `@ImportRuntimeHints`
604604

605-
`RuntimeHintsRegistrar` implementations allow you to get a callback to the `RuntimeHints` instance managed by the AOT engine.
606-
Implementations of this interface can be registered using `@ImportRuntimeHints` on any Spring bean or `@Bean` factory method.
607-
`RuntimeHintsRegistrar` implementations are detected and invoked at build time.
605+
{spring-framework-api}/aot/hint/RuntimeHintsRegistrar.html[`RuntimeHintsRegistrar`]
606+
implementations allow you to get a callback to the `RuntimeHints` instance managed by the
607+
AOT engine. Implementations of this interface can be registered using
608+
{spring-framework-api}/context/annotation/ImportRuntimeHints.html[`@ImportRuntimeHints`]
609+
on any Spring bean or `@Bean` factory method. `RuntimeHintsRegistrar` implementations are
610+
detected and invoked at build time.
608611

609612
include-code::./SpellCheckService[]
610613

@@ -620,8 +623,10 @@ It is also possible to register an implementation statically by adding an entry
620623
{spring-framework-api}/aot/hint/annotation/Reflective.html[`@Reflective`] provides an idiomatic way to flag the need for reflection on an annotated element.
621624
For instance, `@EventListener` is meta-annotated with `@Reflective` since the underlying implementation invokes the annotated method using reflection.
622625

623-
Out-of-the-box, only Spring beans are considered, but you can opt-in for scanning using `@ReflectiveScan`.
624-
In the example below, all types in the `com.example.app` package and its subpackages are considered:
626+
Out-of-the-box, only Spring beans are considered, but you can opt-in for scanning using
627+
{spring-framework-api}/context/annotation/ReflectiveScan.html[`@ReflectiveScan`]. In the
628+
example below, all types in the `com.example.app` package and its subpackages are
629+
considered:
625630

626631
include-code::./MyConfiguration[]
627632

@@ -638,18 +643,18 @@ An example of such customization is covered in the next section.
638643
[[aot.hints.register-reflection]]
639644
=== `@RegisterReflection`
640645

641-
{spring-framework-api}/aot/hint/annotation/RegisterReflection.html[`@RegisterReflection`] is a specialization of `@Reflective` that provides a declarative way of registering reflection for arbitrary types.
646+
{spring-framework-api}/aot/hint/annotation/RegisterReflection.html[`@RegisterReflection`] is a specialization of `@Reflective` that provides a declarative way to register reflection for arbitrary types.
642647

643-
NOTE: As a specialization of `@Reflective`, this is also detected if you are using `@ReflectiveScan`.
648+
NOTE: As a specialization of `@Reflective`, `@RegisterReflection` is also detected if you are using `@ReflectiveScan`.
644649

645650
In the following example, public constructors and public methods can be invoked via reflection on `AccountService`:
646651

647652
include-code::./MyConfiguration[tag=snippet,indent=0]
648653

649654
`@RegisterReflection` can be applied to any target type at the class level, but it can also be applied directly to a method to better indicate where the hints are actually required.
650655

651-
`@RegisterReflection` can be used as a meta-annotation to provide more specific needs.
652-
{spring-framework-api}/aot/hint/annotation/RegisterReflectionForBinding.html[`@RegisterReflectionForBinding`] is such composed annotation and registers the need for serializing arbitrary types.
656+
`@RegisterReflection` can be used as a meta-annotation to support more specific needs.
657+
{spring-framework-api}/aot/hint/annotation/RegisterReflectionForBinding.html[`@RegisterReflectionForBinding`] is a composed annotation that is meta-annotated with `@RegisterReflection` and registers the need for serializing arbitrary types.
653658
A typical use case is the use of DTOs that the container cannot infer, such as using a web client within a method body.
654659

655660
The following example registers `Order` for serialization.
@@ -664,7 +669,7 @@ In other words, if `Order` exposes others types, hints are registered for those
664669
=== Testing Runtime Hints
665670

666671
Spring Core also ships `RuntimeHintsPredicates`, a utility for checking that existing hints match a particular use case.
667-
This can be used in your own tests to validate that a `RuntimeHintsRegistrar` contains the expected results.
672+
This can be used in your own tests to validate that a `RuntimeHintsRegistrar` produces the expected results.
668673
We can write a test for our `SpellCheckService` and ensure that we will be able to load a dictionary at runtime:
669674

670675
include-code::./SpellCheckServiceTests[tag=hintspredicates]

0 commit comments

Comments
 (0)