Package io.micronaut.aop
Annotation Interface Adapter
@Documented
@Retention(RUNTIME)
@Target({ANNOTATION_TYPE,METHOD})
@DefaultScope(jakarta.inject.Singleton.class)
@Executable
@Inherited
public @interface Adapter
An Adapter
is advice applicable to a method that will create an entirely new bean definition that delegates to the
annotated method.
Typically used in conjunction with an interface or class that provides a "Single Abstract Method" (or SAM) type.
An example of usage could be to introduce a ApplicationEventListener
:
For example:
@Adapter(ApplicationEventListener)
public void onStartup(StartupEvent startupEvent) {
}
The above example will create a new bean that delegates to the onStartup
method that is an instance of ApplicationEventListener
.
The generic types are aligned and populated from the types defined in the method signature
This annotation can be used as a stereotype annotation. If for some reason the generated class cannot delegate to the method then a compilation error should occur.
- Since:
- 1.0
- Author:
- graemerocher
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Internal attributes for the adapter annotation. -
Required Element Summary
-
Element Details
-
value
Class<?> valueThe target interface to adapt.- Returns:
- An interface to adapt
-