use of io.quarkus.arc.deployment.AdditionalBeanBuildItem in project camel-quarkus by apache.
the class JtaProcessor method transactedPolicy.
@BuildStep
void transactedPolicy(BuildProducer<AdditionalBeanBuildItem> additionalBeans, BuildProducer<ReflectiveClassBuildItem> reflectiveClass, Capabilities capabilities) {
if (capabilities.isPresent(Capability.TRANSACTIONS)) {
AdditionalBeanBuildItem.Builder builder = AdditionalBeanBuildItem.builder();
builder.addBeanClass(RequiredJtaTransactionPolicy.class);
builder.addBeanClass(RequiresNewJtaTransactionPolicy.class);
builder.addBeanClass(MandatoryJtaTransactionPolicy.class);
builder.addBeanClass(NeverJtaTransactionPolicy.class);
builder.addBeanClass(NotSupportedJtaTransactionPolicy.class);
builder.addBeanClass(SupportsJtaTransactionPolicy.class);
additionalBeans.produce(builder.build());
reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, IllegalStateException.class.getName()));
}
}
use of io.quarkus.arc.deployment.AdditionalBeanBuildItem in project camel-quarkus by apache.
the class ServletProcessor method newServlet.
static ServletBuildItem newServlet(String key, ServletConfig servletConfig, BuildProducer<AdditionalBeanBuildItem> additionalBean) {
final String servletName = servletConfig.getEffectiveServletName(key);
final Optional<List<String>> urlPatterns = servletConfig.urlPatterns;
if (!urlPatterns.isPresent() || urlPatterns.get().isEmpty()) {
throw new IllegalStateException(String.format("Missing quarkus.camel.servlet%s.url-patterns", ServletConfig.DEFAULT_SERVLET_NAME.equals(servletName) ? "" : "." + servletName));
}
final Builder builder = ServletBuildItem.builder(servletName, servletConfig.servletClass);
additionalBean.produce(new AdditionalBeanBuildItem(servletConfig.servletClass));
for (String pattern : urlPatterns.get()) {
builder.addMapping(pattern);
}
return builder.build();
}
use of io.quarkus.arc.deployment.AdditionalBeanBuildItem in project quarkus-operator-sdk by quarkiverse.
the class OperatorSDKProcessor method createConfigurationServiceAndOperator.
@BuildStep
ConfigurationServiceBuildItem createConfigurationServiceAndOperator(OutputTargetBuildItem outputTarget, CombinedIndexBuildItem combinedIndexBuildItem, BuildProducer<AdditionalBeanBuildItem> additionalBeans, BuildProducer<ReflectiveClassBuildItem> reflectionClasses, BuildProducer<ForceNonWeakReflectiveClassBuildItem> forcedReflectionClasses, BuildProducer<GeneratedCRDInfoBuildItem> generatedCRDInfo, LiveReloadBuildItem liveReload) {
final CRDConfiguration crdConfig = buildTimeConfiguration.crd;
final boolean validateCustomResources = ConfigurationUtils.shouldValidateCustomResources(buildTimeConfiguration.checkCRDAndValidateLocalModel, buildTimeConfiguration.crd.validate, log);
// apply should imply generate: we cannot apply if we're not generating!
final var crdGeneration = new CRDGeneration(crdConfig.generate || crdConfig.apply);
final var index = combinedIndexBuildItem.getIndex();
final List<QuarkusControllerConfiguration> controllerConfigs = ClassUtils.getKnownReconcilers(index, log).map(ci -> createControllerConfiguration(ci, additionalBeans, reflectionClasses, forcedReflectionClasses, index, crdGeneration, liveReload)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
// retrieve the known CRD information to make sure we always have a full view
var storedCRDInfos = liveReload.getContextObject(ContextStoredCRDInfos.class);
if (storedCRDInfos == null) {
storedCRDInfos = new ContextStoredCRDInfos();
}
CRDGenerationInfo crdInfo = crdGeneration.generate(outputTarget, crdConfig, validateCustomResources, storedCRDInfos.getExisting());
storedCRDInfos.putAll(crdInfo.getCrds());
// record CRD generation info in context for future use
liveReload.setContextObject(ContextStoredCRDInfos.class, storedCRDInfos);
additionalBeans.produce(AdditionalBeanBuildItem.unremovableOf(OperatorProducer.class));
// if the app doesn't provide a main class, add the AppEventListener
if (index.getAllKnownImplementors(DotName.createSimple(QuarkusApplication.class.getName())).isEmpty()) {
additionalBeans.produce(AdditionalBeanBuildItem.builder().addBeanClass(AppEventListener.class).setDefaultScope(DotName.createSimple(Singleton.class.getName())).setUnremovable().build());
}
generatedCRDInfo.produce(new GeneratedCRDInfoBuildItem(crdInfo));
return new ConfigurationServiceBuildItem(Version.loadFromProperties(), controllerConfigs);
}
use of io.quarkus.arc.deployment.AdditionalBeanBuildItem in project quarkus-github-app by quarkiverse.
the class GitHubAppProcessor method additionalBeans.
@BuildStep
void additionalBeans(CombinedIndexBuildItem index, BuildProducer<AdditionalBeanBuildItem> additionalBeans) {
AdditionalBeanBuildItem.Builder additionalBeanBuildItemBuilder = new AdditionalBeanBuildItem.Builder().addBeanClasses(GitHubService.class, DefaultErrorHandler.class).setUnremovable().setDefaultScope(DotNames.SINGLETON);
for (ClassInfo errorHandler : index.getIndex().getAllKnownImplementors(GitHubAppDotNames.ERROR_HANDLER)) {
additionalBeanBuildItemBuilder.addBeanClass(errorHandler.name().toString());
}
additionalBeans.produce(additionalBeanBuildItemBuilder.build());
}
use of io.quarkus.arc.deployment.AdditionalBeanBuildItem in project quarkus-github-app by quarkiverse.
the class GitHubAppProcessor method generateClasses.
@BuildStep
void generateClasses(CombinedIndexBuildItem combinedIndex, LaunchModeBuildItem launchMode, BuildProducer<AdditionalBeanBuildItem> additionalBeans, BuildProducer<GeneratedBeanBuildItem> generatedBeans, BuildProducer<GeneratedClassBuildItem> generatedClasses, BuildProducer<ReflectiveClassBuildItem> reflectiveClasses, BuildProducer<AnnotationsTransformerBuildItem> annotationsTransformer) {
Collection<EventDefinition> allEventDefinitions = getAllEventDefinitions(combinedIndex.getIndex());
// Add @Vetoed to all the user-defined event listening classes
annotationsTransformer.produce(new AnnotationsTransformerBuildItem(new VetoUserDefinedEventListeningClassesAnnotationsTransformer(allEventDefinitions.stream().map(d -> d.getAnnotation()).collect(Collectors.toSet()))));
// Add the qualifiers as beans
String[] subscriberAnnotations = allEventDefinitions.stream().map(d -> d.getAnnotation().toString()).toArray(String[]::new);
additionalBeans.produce(new AdditionalBeanBuildItem(subscriberAnnotations));
DispatchingConfiguration dispatchingConfiguration = getDispatchingConfiguration(combinedIndex.getIndex(), allEventDefinitions);
ClassOutput classOutput = new GeneratedClassGizmoAdaptor(generatedClasses, true);
generateAnnotationLiterals(classOutput, dispatchingConfiguration);
ClassOutput beanClassOutput = new GeneratedBeanGizmoAdaptor(generatedBeans);
generateDispatcher(beanClassOutput, combinedIndex, launchMode, dispatchingConfiguration, reflectiveClasses);
generateMultiplexers(beanClassOutput, dispatchingConfiguration, reflectiveClasses);
}
Aggregations