
templates.cdi.container.factory.vm Maven / Gradle / Ivy
package ${basePackage}.cdi;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.collections4.CollectionUtils;
import org.jboss.weld.environment.se.WeldContainer;
import com.boozallen.aissemble.core.cdi.CdiContainer;
import com.boozallen.aissemble.core.cdi.CdiContext;
import com.boozallen.aissemble.messaging.core.cdi.MessagingCdiContext;
import com.boozallen.aissemble.kafka.context.KafkaConnectorCdiContext;
#if ($pipeline.isAlertingSupportNeeded())
import com.boozallen.aissemble.alerting.core.cdi.AlertingCdiContext;
#end
#if ($pipeline.getDataLineage())
import com.boozallen.aissemble.data.lineage.cdi.DataLineageCdiSelector;
#end
/**
* Factory that creates the proper CDI Context for this series of pipelines.
*
* Please **DO** modify with your customizations, as appropriate.
*
* Originally generated from: ${templateName}
*/
public final class CdiContainerFactory {
private CdiContainerFactory() {
// private construct to prevent instantiation of all static class
}
/**
* Creates a new WeldContainer with the set of {@link CdiContext}
* implementations needed for these pipelines.
*
* @return Weld Container instance
*/
public static WeldContainer getCdiContainer() {
return getCdiContainer(null);
}
/**
* Creates a new WeldContainer with the set of {@link CdiContext}
* implementations needed for these pipelines with the ability to add in
* additional contexts in an ad-hoc fashion.
*
* @param additionalContexts
* @return Weld Container instance
*/
public static WeldContainer getCdiContainer(List additionalContexts) {
List contexts = getContexts();
if (CollectionUtils.isNotEmpty(additionalContexts)) {
contexts.addAll(additionalContexts);
}
return CdiContainer.create(contexts);
}
protected static List getContexts() {
List contexts = new ArrayList<>();
contexts.add(new PipelinesCdiContext());
## TODO: would be nice to only include if we need messaging, but right now we assume kafka messaging everywhere
contexts.add(new MessagingCdiContext());
contexts.add(new KafkaConnectorCdiContext());
## TODO: pull generated functionality into an overwritable template so we can adapt to MDA model changes
#if ($pipeline.isAlertingSupportNeeded())
contexts.add(new AlertingCdiContext());
#end
#if ($pipeline.getDataLineage())
contexts.add(DataLineageCdiSelector.getDataLineageCdiContext());
#end
return contexts;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy