io.inverno.core.annotation.Lazy Maven / Gradle / Ivy
/**
*
*/
package io.inverno.core.annotation;
import static java.lang.annotation.ElementType.PARAMETER;
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.CLASS;
import java.lang.annotation.Target;
import java.util.function.Supplier;
/**
*
* Used on a bean socket variable to inject a bean instance supplier instead of an actual bean instance.
*
*
*
* Lazy socket must then be of type {@link Supplier} and its formal parameter must designate the type dependency expected by the socket.
*
*
*
* Lazy sockets allow to lazily retrieve bean instances, this doesn't mean that the bean to inject is created on demand in the module, but that the instance retrieval is called on demand in the
* dependent bean instance. This is particularly interesting when prototype beans are wired into a lazy socket, the dependent bean can then create new instances on demand during application operation.
*
*
* @author Jeremy Kuhn
* @since 1.0
*/
@Retention(CLASS)
@Target({ PARAMETER })
public @interface Lazy {
}