Annotation Interface ImportRuntimeHints


@Target({TYPE,METHOD}) @Retention(RUNTIME) @Documented public @interface ImportRuntimeHints
Indicates that one or more RuntimeHintsRegistrar implementations should be processed.

Unlike declaring RuntimeHintsRegistrar using spring/aot.factories, this annotation allows for more flexible registration where it is only processed if the annotated component or bean method is actually registered in the bean factory. To illustrate this behavior, consider the following example:

 @Configuration
 public class MyConfiguration {

     @Bean
     @ImportRuntimeHints(MyHints.class)
     @Conditional(MyCondition.class)
     public MyService myService() {
         return new MyService();
     }

 }
If the configuration class above is processed, MyHints will be contributed only if MyCondition matches. If it does not, and therefore MyService is not defined as a bean, the hints will not be processed either.

If several components refer to the same RuntimeHintsRegistrar implementation, it is invoked only once for a given bean factory processing.

Since:
6.0
Author:
Brian Clozel, Stephane Nicoll
See Also: