@Documented @Retention(value=RUNTIME) @Target(value={ANNOTATION_TYPE,METHOD}) @DefaultScope(value=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.
public abstract Class<?> value