Module jakarta.cdi

Interface SyntheticBeanCreator<T>

  • Type Parameters:
    T - the bean class of the synthetic bean

    public interface SyntheticBeanCreator<T>
    Creation function for a synthetic bean defined by SyntheticBeanBuilder. CDI container will create an instance of the creation function every time when it needs to obtain an instance of the synthetic bean. Implementations must be public classes with a public zero-parameter constructor; they must not be beans.
    • Method Detail

      • create

        T create​(Instance<java.lang.Object> lookup,
                 Parameters params)
        Creates an instance of the synthetic bean. May only return null if the synthetic bean is @Dependent.

        The Instance parameter may be used to simulate producer method parameter injection. However, @Dependent bean instances obtained from the Instance during execution remain managed until the synthetic bean instance is destroyed. Therefore, implementations are encouraged to destroy unneeded @Dependent bean instances obtained from the Instance.

        If the synthetic bean is @Dependent, the InjectionPoint to which it is injected may be looked up from the Instance parameter.

        The parameter map contains the same values that were passed to the SyntheticBeanBuilder that defined the synthetic bean.

        lookup - an Instance that can be used to lookup other beans, never null
        params - the parameter map, never null
        an instance of the bean, may only be null if the synthetic bean is @Dependent