br.com.jarch.bpm.cdi.extension.StartupBeanExtension Maven / Gradle / Ivy
package br.com.jarch.bpm.cdi.extension;
import br.com.jarch.util.LogUtils;
import javax.ejb.Startup;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.AfterDeploymentValidation;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.Extension;
import javax.enterprise.inject.spi.ProcessBean;
import java.util.LinkedHashSet;
import java.util.Set;
public class StartupBeanExtension implements Extension {
private final Set> startupBeans = new LinkedHashSet<>();
void processBean(@Observes ProcessBean event) {
if (event.getAnnotated().isAnnotationPresent(Startup.class) &&
event.getAnnotated().isAnnotationPresent(ApplicationScoped.class)) {
startupBeans.add(event.getBean());
}
}
void afterDeploymentValidation(@Observes AfterDeploymentValidation event, BeanManager manager) {
for (Bean> bean : startupBeans) {
LogUtils.generate("CDI = " + bean.getName());
manager.getReference(bean, bean.getBeanClass(), manager.createCreationalContext(bean)).toString();
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy