@Documented @Retention(value=RUNTIME) @Target(value={ANNOTATION_TYPE,METHOD}) @DefaultScope(value=javax.inject.Singleton.class) @Executable 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.
Modifier and Type | Required Element and Description |
---|---|
java.lang.Class<?> |
value
The target interface to adapt.
|