Annotation Interface RegisterReflection
When using this annotation directly, only the defined member categories are registered for each target class. The target classes can be specified by class or class names. When both are specified, they are all considered. If no target class is specified, the current class is used.
This annotation can be used as a meta-annotation to customize how hints are registered against each target class.
You can use this annotation on any bean that is contributed to the context:
@Configuration
@RegisterReflection(classes = CustomerEntry.class, memberCategories = PUBLIC_FIELDS)
class MyConfig {
// ...
}
If scanning of Reflective
is enabled, any type in the configured
packages can use this annotation as well.
To register reflection hints for the type itself, only member categories should be specified:
@Component
@RegisterReflection(memberCategories = INVOKE_PUBLIC_METHODS)
class MyComponent {
// ...
}
Reflection hints can be registered from a method. In this case, at least one target class should be specified:
class MyProcessor {
@RegisterReflection(classes = CustomerEntry.class, memberCategories = PUBLIC_FIELDS)
CustomerEntry process() { ... }
// ...
}
If the class is not available, classNames()
allows to specify the
fully qualified name, rather than the Class
reference.
The annotated element can also be any test class that uses the Spring
TestContext Framework to load an ApplicationContext
.
- Since:
- 6.2
- Author:
- Stephane Nicoll
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionClass<?>[]
Classes for which reflection hints should be registered.String[]
Alternative toclasses()
to specify the classes as class names.Specify the member categories to enable.
-
Element Details
-
classes
Class<?>[] classesClasses for which reflection hints should be registered. Consider usingclassNames()
for classes that are not public in the current scope. If bothclasses
andclassNames
are specified, they are merged into a single set.By default, the annotated type is the target of the registration. When placed on a method, at least one class must be specified.
- See Also:
- Default:
- {}
-
classNames
String[] classNamesAlternative toclasses()
to specify the classes as class names.- See Also:
- Default:
- {}
-
memberCategories
MemberCategory[] memberCategoriesSpecify the member categories to enable.- Default:
- {}
-