Search in sources :

Example 1 with AdditionalBeanBuildItem

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()));
    }
}
Also used : AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 2 with AdditionalBeanBuildItem

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();
}
Also used : AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) Builder(io.quarkus.undertow.deployment.ServletBuildItem.Builder) List(java.util.List)

Example 3 with AdditionalBeanBuildItem

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);
}
Also used : ConfigurationServiceRecorder(io.quarkiverse.operatorsdk.runtime.ConfigurationServiceRecorder) UnremovableBeanBuildItem(io.quarkus.arc.deployment.UnremovableBeanBuildItem) JandexUtil(io.quarkus.deployment.util.JandexUtil) RunTimeOperatorConfiguration(io.quarkiverse.operatorsdk.runtime.RunTimeOperatorConfiguration) Version(io.quarkiverse.operatorsdk.runtime.Version) ClassInfo(org.jboss.jandex.ClassInfo) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) RECONCILER(io.quarkiverse.operatorsdk.common.Constants.RECONCILER) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) MetricsCapabilityBuildItem(io.quarkus.deployment.metrics.MetricsCapabilityBuildItem) BooleanSupplier(java.util.function.BooleanSupplier) Reconciler(io.javaoperatorsdk.operator.api.reconciler.Reconciler) AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) ObserverConfiguratorBuildItem(io.quarkus.arc.deployment.ObserverRegistrationPhaseBuildItem.ObserverConfiguratorBuildItem) BuildException(io.quarkus.builder.BuildException) FeatureBuildItem(io.quarkus.deployment.builditem.FeatureBuildItem) Operator(io.javaoperatorsdk.operator.Operator) ClassUtils.loadClass(io.quarkiverse.operatorsdk.common.ClassUtils.loadClass) ConfigurationUtils(io.quarkiverse.operatorsdk.common.ConfigurationUtils) CRDGenerationInfo(io.quarkiverse.operatorsdk.runtime.CRDGenerationInfo) Instance(javax.enterprise.inject.Instance) AnnotationValue(org.jboss.jandex.AnnotationValue) CUSTOM_RESOURCE(io.quarkiverse.operatorsdk.common.Constants.CUSTOM_RESOURCE) NoOpMetricsProvider(io.quarkiverse.operatorsdk.runtime.NoOpMetricsProvider) ObserverRegistrationPhaseBuildItem(io.quarkus.arc.deployment.ObserverRegistrationPhaseBuildItem) ExecutionTime(io.quarkus.deployment.annotations.ExecutionTime) ForceNonWeakReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ForceNonWeakReflectiveClassBuildItem) DecoratorBuildItem(io.quarkus.kubernetes.spi.DecoratorBuildItem) CDI(javax.enterprise.inject.spi.CDI) Collectors(java.util.stream.Collectors) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) APPLICATION_SCOPED(io.quarkus.arc.processor.DotNames.APPLICATION_SCOPED) List(java.util.List) AnnotationInstance(org.jboss.jandex.AnnotationInstance) Annotation(java.lang.annotation.Annotation) Optional(java.util.Optional) QuarkusControllerConfiguration(io.quarkiverse.operatorsdk.runtime.QuarkusControllerConfiguration) ResultHandle(io.quarkus.gizmo.ResultHandle) CustomResource(io.fabric8.kubernetes.client.CustomResource) SyntheticBeanBuildItem(io.quarkus.arc.deployment.SyntheticBeanBuildItem) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) Record(io.quarkus.deployment.annotations.Record) AppEventListener(io.quarkiverse.operatorsdk.runtime.AppEventListener) ClassUtils(io.quarkiverse.operatorsdk.common.ClassUtils) Logger(org.jboss.logging.Logger) MethodCreator(io.quarkus.gizmo.MethodCreator) DotName(org.jboss.jandex.DotName) HashMap(java.util.HashMap) Singleton(javax.inject.Singleton) MetricsFactory(io.quarkus.runtime.metrics.MetricsFactory) IndexDependencyBuildItem(io.quarkus.deployment.builditem.IndexDependencyBuildItem) OperatorProducer(io.quarkiverse.operatorsdk.runtime.OperatorProducer) BuildStep(io.quarkus.deployment.annotations.BuildStep) ResourceInfo(io.quarkiverse.operatorsdk.common.ResourceInfo) AssignableResultHandle(io.quarkus.gizmo.AssignableResultHandle) IndexView(org.jboss.jandex.IndexView) ConfigurationService(io.javaoperatorsdk.operator.api.config.ConfigurationService) MethodDescriptor(io.quarkus.gizmo.MethodDescriptor) BuildTimeOperatorConfiguration(io.quarkiverse.operatorsdk.runtime.BuildTimeOperatorConfiguration) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CONTROLLER_CONFIGURATION(io.quarkiverse.operatorsdk.common.Constants.CONTROLLER_CONFIGURATION) ReconcilerUtils(io.javaoperatorsdk.operator.ReconcilerUtils) ObserverConfigurator(io.quarkus.arc.processor.ObserverConfigurator) CRDConfiguration(io.quarkiverse.operatorsdk.runtime.CRDConfiguration) OutputTargetBuildItem(io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem) DelayRegistrationUntil(io.quarkiverse.operatorsdk.runtime.DelayRegistrationUntil) QuarkusApplication(io.quarkus.runtime.QuarkusApplication) QuarkusConfigurationService(io.quarkiverse.operatorsdk.runtime.QuarkusConfigurationService) Collections(java.util.Collections) LiveReloadBuildItem(io.quarkus.deployment.builditem.LiveReloadBuildItem) Optional(java.util.Optional) QuarkusControllerConfiguration(io.quarkiverse.operatorsdk.runtime.QuarkusControllerConfiguration) QuarkusApplication(io.quarkus.runtime.QuarkusApplication) CRDConfiguration(io.quarkiverse.operatorsdk.runtime.CRDConfiguration) CRDGenerationInfo(io.quarkiverse.operatorsdk.runtime.CRDGenerationInfo) OperatorProducer(io.quarkiverse.operatorsdk.runtime.OperatorProducer) Singleton(javax.inject.Singleton) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 4 with AdditionalBeanBuildItem

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());
}
Also used : AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) ClassInfo(org.jboss.jandex.ClassInfo) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 5 with AdditionalBeanBuildItem

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);
}
Also used : GitHubService(io.quarkiverse.githubapp.runtime.github.GitHubService) DotNames(io.quarkus.arc.processor.DotNames) GeneratedClassGizmoAdaptor(io.quarkus.deployment.GeneratedClassGizmoAdaptor) Arrays(java.util.Arrays) GHRepository(org.kohsuke.github.GHRepository) ClassOutput(io.quarkus.gizmo.ClassOutput) ShutdownContextBuildItem(io.quarkus.deployment.builditem.ShutdownContextBuildItem) AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) AnnotationLiteral(javax.enterprise.util.AnnotationLiteral) Map(java.util.Map) BytecodeCreator(io.quarkus.gizmo.BytecodeCreator) GHEventPayload(org.kohsuke.github.GHEventPayload) PayloadHelper(io.quarkiverse.githubapp.runtime.github.PayloadHelper) EVENT(io.quarkiverse.githubapp.deployment.GitHubAppDotNames.EVENT) MethodParameterInfo(org.jboss.jandex.MethodParameterInfo) AnnotationsTransformerBuildItem(io.quarkus.arc.deployment.AnnotationsTransformerBuildItem) AnnotationValue(org.jboss.jandex.AnnotationValue) ReflectiveHierarchyBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyBuildItem) EventDispatchingMethod(io.quarkiverse.githubapp.deployment.DispatchingConfiguration.EventDispatchingMethod) Set(java.util.Set) EventAnnotationLiteral(io.quarkiverse.githubapp.deployment.DispatchingConfiguration.EventAnnotationLiteral) Reader(java.io.Reader) BuiltinScope(io.quarkus.arc.processor.BuiltinScope) CompletionStage(java.util.concurrent.CompletionStage) AnnotationInstance(org.jboss.jandex.AnnotationInstance) HashUtil(io.quarkus.runtime.util.HashUtil) ResultHandle(io.quarkus.gizmo.ResultHandle) TryBlock(io.quarkus.gizmo.TryBlock) Record(io.quarkus.deployment.annotations.Record) CatchBlockCreator(io.quarkus.gizmo.CatchBlockCreator) DotName(org.jboss.jandex.DotName) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) MultiplexedEvent(io.quarkiverse.githubapp.runtime.MultiplexedEvent) ConfigFileReader(io.quarkiverse.githubapp.runtime.ConfigFileReader) CONFIG_FILE(io.quarkiverse.githubapp.deployment.GitHubAppDotNames.CONFIG_FILE) Gizmo(io.quarkus.gizmo.Gizmo) Opcodes(org.objectweb.asm.Opcodes) GitHubAppRecorder(io.quarkiverse.githubapp.runtime.GitHubAppRecorder) IOException(java.io.IOException) FieldDescriptor(io.quarkus.gizmo.FieldDescriptor) GeneratedBeanGizmoAdaptor(io.quarkus.arc.deployment.GeneratedBeanGizmoAdaptor) StringReader(java.io.StringReader) GeneratedClassBuildItem(io.quarkus.deployment.builditem.GeneratedClassBuildItem) LaunchModeBuildItem(io.quarkus.deployment.builditem.LaunchModeBuildItem) FieldCreator(io.quarkus.gizmo.FieldCreator) BytecodeTransformerBuildItem(io.quarkus.deployment.builditem.BytecodeTransformerBuildItem) GitHubEvent(io.quarkiverse.githubapp.GitHubEvent) WebJarResultsBuildItem(io.quarkus.vertx.http.deployment.webjar.WebJarResultsBuildItem) MethodVisitor(org.objectweb.asm.MethodVisitor) DefaultErrorHandler(io.quarkiverse.githubapp.runtime.error.DefaultErrorHandler) ClassInfo(org.jboss.jandex.ClassInfo) RoutingContext(io.vertx.ext.web.RoutingContext) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) Multiplexer(io.quarkiverse.githubapp.runtime.Multiplexer) GeneratedBeanBuildItem(io.quarkus.arc.deployment.GeneratedBeanBuildItem) MethodInfo(org.jboss.jandex.MethodInfo) FeatureBuildItem(io.quarkus.deployment.builditem.FeatureBuildItem) NotFoundPageDisplayableEndpointBuildItem(io.quarkus.vertx.http.deployment.devmode.NotFoundPageDisplayableEndpointBuildItem) ClassVisitor(org.objectweb.asm.ClassVisitor) GitHub(org.kohsuke.github.GitHub) Collection(java.util.Collection) ExecutionTime(io.quarkus.deployment.annotations.ExecutionTime) Collectors(java.util.stream.Collectors) MethodDescriptors(io.quarkus.arc.processor.MethodDescriptors) List(java.util.List) GitHubApiClassWithBridgeMethodsBuildItem(io.quarkiverse.githubapi.deployment.GitHubApiClassWithBridgeMethodsBuildItem) Actions(io.quarkiverse.githubapp.event.Actions) GACT(io.quarkus.maven.dependency.GACT) WebJarBuildItem(io.quarkus.vertx.http.deployment.webjar.WebJarBuildItem) Modifier(java.lang.reflect.Modifier) Annotation(java.lang.annotation.Annotation) Entry(java.util.Map.Entry) EventAnnotation(io.quarkiverse.githubapp.deployment.DispatchingConfiguration.EventAnnotation) Optional(java.util.Optional) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) RouteBuildItem(io.quarkus.vertx.http.deployment.RouteBuildItem) Logger(org.jboss.logging.Logger) MethodCreator(io.quarkus.gizmo.MethodCreator) Type(org.jboss.jandex.Type) AnnotatedElement(io.quarkus.gizmo.AnnotatedElement) LaunchMode(io.quarkus.runtime.LaunchMode) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) ClassCreator(io.quarkus.gizmo.ClassCreator) Singleton(javax.inject.Singleton) ErrorHandlerBridgeFunction(io.quarkiverse.githubapp.runtime.error.ErrorHandlerBridgeFunction) Function(java.util.function.Function) HttpRootPathBuildItem(io.quarkus.vertx.http.deployment.HttpRootPathBuildItem) Inject(javax.inject.Inject) BuildStep(io.quarkus.deployment.annotations.BuildStep) Kind(org.jboss.jandex.AnnotationTarget.Kind) PrintStream(java.io.PrintStream) Event(javax.enterprise.event.Event) IndexView(org.jboss.jandex.IndexView) MethodDescriptor(io.quarkus.gizmo.MethodDescriptor) DynamicGraphQLClient(io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient) EventDispatchingConfiguration(io.quarkiverse.githubapp.deployment.DispatchingConfiguration.EventDispatchingConfiguration) GITHUB(io.quarkiverse.githubapp.deployment.GitHubAppDotNames.GITHUB) DYNAMIC_GRAPHQL_CLIENT(io.quarkiverse.githubapp.deployment.GitHubAppDotNames.DYNAMIC_GRAPHQL_CLIENT) Handler(io.vertx.core.Handler) Collections(java.util.Collections) AnnotationsTransformerBuildItem(io.quarkus.arc.deployment.AnnotationsTransformerBuildItem) AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) EventDispatchingConfiguration(io.quarkiverse.githubapp.deployment.DispatchingConfiguration.EventDispatchingConfiguration) ClassOutput(io.quarkus.gizmo.ClassOutput) GeneratedBeanGizmoAdaptor(io.quarkus.arc.deployment.GeneratedBeanGizmoAdaptor) GeneratedClassGizmoAdaptor(io.quarkus.deployment.GeneratedClassGizmoAdaptor) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Aggregations

AdditionalBeanBuildItem (io.quarkus.arc.deployment.AdditionalBeanBuildItem)16 Test (org.junit.jupiter.api.Test)10 BuildStep (io.quarkus.deployment.annotations.BuildStep)5 ReflectiveClassBuildItem (io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem)4 MetricsCapabilityBuildItem (io.quarkus.deployment.metrics.MetricsCapabilityBuildItem)4 BuildProducer (io.quarkus.deployment.annotations.BuildProducer)3 CombinedIndexBuildItem (io.quarkus.deployment.builditem.CombinedIndexBuildItem)3 FeatureBuildItem (io.quarkus.deployment.builditem.FeatureBuildItem)3 List (java.util.List)3 ClassInfo (org.jboss.jandex.ClassInfo)3 GitHubApiClassWithBridgeMethodsBuildItem (io.quarkiverse.githubapi.deployment.GitHubApiClassWithBridgeMethodsBuildItem)2 ExecutionTime (io.quarkus.deployment.annotations.ExecutionTime)2 Record (io.quarkus.deployment.annotations.Record)2 MethodCreator (io.quarkus.gizmo.MethodCreator)2 MethodDescriptor (io.quarkus.gizmo.MethodDescriptor)2 ResultHandle (io.quarkus.gizmo.ResultHandle)2 Annotation (java.lang.annotation.Annotation)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 Optional (java.util.Optional)2