Package io.micronaut.aop
Annotation Type Adapter
-
@Documented @Retention(RUNTIME) @Target({ANNOTATION_TYPE,METHOD}) @DefaultScope(jakarta.inject.Singleton.class) @Executable @Inherited public @interface AdapterAn
Adapteris 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
onStartupmethod that is an instance ofApplicationEventListener. The generic types are aligned and populated from the types defined in the method signatureThis 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
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.Class<?>valueThe target interface to adapt.
-