All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.cdi.common.util.ContextualLifecycle Maven / Gradle / Ivy

The newest version!
package org.infinispan.cdi.common.util;

import jakarta.enterprise.context.spi.CreationalContext;
import jakarta.enterprise.inject.spi.Bean;

/**
 * Callbacks used by {@link BeanBuilder} and {@link ImmutableBean} to allow control
 * of the creation and destruction of a custom bean.
 *
 * @param  the class of the bean instance
 * @author Stuart Douglas
 */
public interface ContextualLifecycle {
    /**
     * Callback invoked by a created bean when
     * {@link Bean#create(CreationalContext)} is called.
     *
     * @param bean              the bean initiating the callback
     * @param creationalContext the context in which this instance was created
     */
    public T create(Bean bean, CreationalContext creationalContext);

    /**
     * Callback invoked by a created bean when
     * {@link Bean#destroy(Object, CreationalContext)} is called.
     *
     * @param bean              the bean initiating the callback
     * @param instance          the contextual instance to destroy
     * @param creationalContext the context in which this instance was created
     */
    default void destroy(Bean bean, T instance, CreationalContext creationalContext) {
       // No-op
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy