You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
on any Spring bean or `@Bean` factory method. `RuntimeHintsRegistrar` implementations are
610
+
detected and invoked at build time.
608
611
609
612
include-code::./SpellCheckService[]
610
613
@@ -620,8 +623,10 @@ It is also possible to register an implementation statically by adding an entry
620
623
{spring-framework-api}/aot/hint/annotation/Reflective.html[`@Reflective`] provides an idiomatic way to flag the need for reflection on an annotated element.
621
624
For instance, `@EventListener` is meta-annotated with `@Reflective` since the underlying implementation invokes the annotated method using reflection.
622
625
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:
625
630
626
631
include-code::./MyConfiguration[]
627
632
@@ -638,18 +643,18 @@ An example of such customization is covered in the next section.
638
643
[[aot.hints.register-reflection]]
639
644
=== `@RegisterReflection`
640
645
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.
642
647
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`.
644
649
645
650
In the following example, public constructors and public methods can be invoked via reflection on `AccountService`:
`@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.
650
655
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.
653
658
A typical use case is the use of DTOs that the container cannot infer, such as using a web client within a method body.
654
659
655
660
The following example registers `Order` for serialization.
@@ -664,7 +669,7 @@ In other words, if `Order` exposes others types, hints are registered for those
664
669
=== Testing Runtime Hints
665
670
666
671
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.
668
673
We can write a test for our `SpellCheckService` and ensure that we will be able to load a dictionary at runtime:
0 commit comments