Search in sources :

Example 1 with ApplicationArchivesBuildItem

use of io.quarkus.deployment.builditem.ApplicationArchivesBuildItem in project camel-quarkus by apache.

the class CamelProcessor method typeConverterRegistry.

/*
     * Discover {@link TypeConverterLoader}.
     */
@SuppressWarnings("unchecked")
@Record(ExecutionTime.STATIC_INIT)
@BuildStep
CamelTypeConverterRegistryBuildItem typeConverterRegistry(CamelRecorder recorder, ApplicationArchivesBuildItem applicationArchives, List<CamelTypeConverterLoaderBuildItem> additionalLoaders, CombinedIndexBuildItem combinedIndex, BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) {
    IndexView index = combinedIndex.getIndex();
    RuntimeValue<TypeConverterRegistry> typeConverterRegistry = recorder.createTypeConverterRegistry();
    // 
    // This should be simplified by searching for classes implementing TypeConverterLoader but that
    // would lead to have org.apache.camel.impl.converter.AnnotationTypeConverterLoader taken into
    // account even if it should not.
    // 
    final ClassLoader TCCL = Thread.currentThread().getContextClassLoader();
    for (ApplicationArchive archive : applicationArchives.getAllApplicationArchives()) {
        for (Path root : archive.getRootDirs()) {
            Path path = root.resolve(BaseTypeConverterRegistry.META_INF_SERVICES_TYPE_CONVERTER_LOADER);
            if (!Files.isRegularFile(path)) {
                continue;
            }
            try {
                Files.readAllLines(path, StandardCharsets.UTF_8).stream().map(String::trim).filter(l -> !l.isEmpty()).filter(l -> !l.startsWith("#")).map(l -> (Class<? extends TypeConverterLoader>) CamelSupport.loadClass(l, TCCL)).forEach(loader -> recorder.addTypeConverterLoader(typeConverterRegistry, loader));
            } catch (IOException e) {
                throw new RuntimeException("Error discovering TypeConverterLoader", e);
            }
        }
    }
    Set<String> internalConverters = new HashSet<>();
    // ignore all @converters from org.apache.camel:camel-* dependencies
    for (ApplicationArchive archive : applicationArchives.getAllApplicationArchives()) {
        ArtifactKey artifactKey = archive.getKey();
        if (artifactKey != null && "org.apache.camel".equals(artifactKey.getGroupId()) && artifactKey.getArtifactId().startsWith("camel-")) {
            internalConverters.addAll(archive.getIndex().getAnnotations(DotName.createSimple(Converter.class.getName())).stream().filter(a -> a.target().kind() == AnnotationTarget.Kind.CLASS).map(a -> a.target().asClass().name().toString()).collect(Collectors.toSet()));
        }
    }
    Set<Class> convertersClasses = index.getAnnotations(DotName.createSimple(Converter.class.getName())).stream().filter(a -> a.target().kind() == AnnotationTarget.Kind.CLASS && (a.value("generateBulkLoader") == null || !a.value("generateBulkLoader").asBoolean()) && (a.value("generateLoader") == null || !a.value("generateLoader").asBoolean())).map(a -> a.target().asClass().name().toString()).filter(s -> !internalConverters.contains(s)).map(s -> CamelSupport.loadClass(s, TCCL)).collect(Collectors.toSet());
    recorder.loadAnnotatedConverters(typeConverterRegistry, convertersClasses);
    // 
    for (CamelTypeConverterLoaderBuildItem item : additionalLoaders) {
        recorder.addTypeConverterLoader(typeConverterRegistry, item.getValue());
    }
    return new CamelTypeConverterRegistryBuildItem(typeConverterRegistry);
}
Also used : Path(java.nio.file.Path) UnremovableBeanBuildItem(io.quarkus.arc.deployment.UnremovableBeanBuildItem) CamelComponentNameResolverBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelComponentNameResolverBuildItem) LoggerFactory(org.slf4j.LoggerFactory) Overridable(io.quarkus.deployment.annotations.Overridable) CamelTypeConverterRegistryBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelTypeConverterRegistryBuildItem) CamelServicePatternBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelServicePatternBuildItem) ClassInfo(org.jboss.jandex.ClassInfo) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) Capabilities(io.quarkus.deployment.Capabilities) AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) BaseTypeConverterRegistry(org.apache.camel.impl.converter.BaseTypeConverterRegistry) CamelModelJAXBContextFactoryBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelModelJAXBContextFactoryBuildItem) CamelRecorder(org.apache.camel.quarkus.core.CamelRecorder) CamelServiceDestination(org.apache.camel.quarkus.core.deployment.spi.CamelServiceDestination) AnnotationTarget(org.jboss.jandex.AnnotationTarget) Path(java.nio.file.Path) TypeConverterLoader(org.apache.camel.spi.TypeConverterLoader) Builder(org.apache.camel.quarkus.core.FastFactoryFinderResolver.Builder) BeanRegistrationPhaseBuildItem(io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem) Predicate(java.util.function.Predicate) CamelModelToXMLDumperBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelModelToXMLDumperBuildItem) ExecutionTime(io.quarkus.deployment.annotations.ExecutionTime) Set(java.util.Set) NativeImageResourceBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) List(java.util.List) RoutesBuilderClassExcludeBuildItem(org.apache.camel.quarkus.core.deployment.spi.RoutesBuilderClassExcludeBuildItem) Modifier(java.lang.reflect.Modifier) CamelProducers(org.apache.camel.quarkus.core.CamelProducers) CamelRoutesBuilderClassBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelRoutesBuilderClassBuildItem) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) Record(io.quarkus.deployment.annotations.Record) CamelSupport(org.apache.camel.quarkus.core.deployment.util.CamelSupport) DotName(org.jboss.jandex.DotName) Type(org.jboss.jandex.Type) ContainerBeansBuildItem(org.apache.camel.quarkus.core.deployment.spi.ContainerBeansBuildItem) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) BuildStep(io.quarkus.deployment.annotations.BuildStep) ArtifactKey(io.quarkus.maven.dependency.ArtifactKey) RuntimeValue(io.quarkus.runtime.RuntimeValue) TypeConverterRegistry(org.apache.camel.spi.TypeConverterRegistry) IndexView(org.jboss.jandex.IndexView) CamelCapabilities(org.apache.camel.quarkus.core.CamelCapabilities) SchemaResource(org.apache.camel.quarkus.core.deployment.catalog.SchemaResource) CamelFactoryFinderResolverBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelFactoryFinderResolverBuildItem) Logger(org.slf4j.Logger) ApplicationArchivesBuildItem(io.quarkus.deployment.builditem.ApplicationArchivesBuildItem) FileUtils(org.apache.camel.quarkus.core.util.FileUtils) Files(java.nio.file.Files) PathFilter(org.apache.camel.quarkus.core.deployment.util.PathFilter) CamelTypeConverterLoaderBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelTypeConverterLoaderBuildItem) IOException(java.io.IOException) CamelServiceFilterBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelServiceFilterBuildItem) BuildTimeCamelCatalog(org.apache.camel.quarkus.core.deployment.catalog.BuildTimeCamelCatalog) Converter(org.apache.camel.Converter) ApplicationArchive(io.quarkus.deployment.ApplicationArchive) CamelConfig(org.apache.camel.quarkus.core.CamelConfig) BuildTimeCamelCatalogBuildItem(org.apache.camel.quarkus.core.deployment.spi.BuildTimeCamelCatalogBuildItem) CamelServiceBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelServiceBuildItem) BuildTimeJsonSchemaResolver(org.apache.camel.quarkus.core.deployment.catalog.BuildTimeJsonSchemaResolver) BuildExtension(io.quarkus.arc.processor.BuildExtension) CamelConfigFlags(org.apache.camel.quarkus.core.CamelConfigFlags) CamelServiceFilter(org.apache.camel.quarkus.core.deployment.spi.CamelServiceFilter) ArtifactKey(io.quarkus.maven.dependency.ArtifactKey) CamelTypeConverterLoaderBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelTypeConverterLoaderBuildItem) IndexView(org.jboss.jandex.IndexView) CamelTypeConverterRegistryBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelTypeConverterRegistryBuildItem) IOException(java.io.IOException) ApplicationArchive(io.quarkus.deployment.ApplicationArchive) TypeConverterLoader(org.apache.camel.spi.TypeConverterLoader) BaseTypeConverterRegistry(org.apache.camel.impl.converter.BaseTypeConverterRegistry) TypeConverterRegistry(org.apache.camel.spi.TypeConverterRegistry) Converter(org.apache.camel.Converter) HashSet(java.util.HashSet) Record(io.quarkus.deployment.annotations.Record) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 2 with ApplicationArchivesBuildItem

use of io.quarkus.deployment.builditem.ApplicationArchivesBuildItem in project camel-quarkus by apache.

the class CamelRegistryProcessor method bindBeansToRegistry.

@Record(ExecutionTime.STATIC_INIT)
@BuildStep
public void bindBeansToRegistry(CamelRecorder recorder, CamelConfig camelConfig, ApplicationArchivesBuildItem applicationArchives, ContainerBeansBuildItem containerBeans, CamelRegistryBuildItem registry, // CamelContextBuildItem placeholder ensures this build step runs after the CamelContext is created
CamelContextBuildItem camelContextBuildItem, List<CamelBeanBuildItem> registryItems, List<CamelServiceFilterBuildItem> serviceFilters, List<CamelServicePatternBuildItem> servicePatterns) {
    final ClassLoader TCCL = Thread.currentThread().getContextClassLoader();
    final PathFilter pathFilter = servicePatterns.stream().filter(patterns -> patterns.getDestination() == CamelServiceDestination.REGISTRY).collect(PathFilter.Builder::new, (builder, patterns) -> builder.patterns(patterns.isInclude(), patterns.getPatterns()), PathFilter.Builder::combine).include(camelConfig.service.registry.includePatterns).exclude(camelConfig.service.registry.excludePatterns).build();
    CamelSupport.services(applicationArchives, pathFilter).filter(si -> !containerBeans.getBeans().contains(si)).filter(si -> {
        // 
        // by default all the service found in META-INF/service/org/apache/camel are
        // bound to the registry but some of the services are then replaced or set
        // to the camel context directly by extension so it does not make sense to
        // instantiate them in this phase.
        // 
        boolean blacklisted = serviceFilters.stream().anyMatch(filter -> filter.getPredicate().test(si));
        if (blacklisted) {
            LOGGER.debug("Ignore service: {}", si);
        }
        return !blacklisted;
    }).forEach(si -> {
        LOGGER.debug("Binding bean with name: {}, type {}", si.name, si.type);
        recorder.bind(registry.getRegistry(), si.name, CamelSupport.loadClass(si.type, TCCL));
    });
    registryItems.stream().filter(item -> !containerBeans.getBeans().contains(item)).forEach(item -> {
        LOGGER.debug("Binding bean with name: {}, type {}", item.getName(), item.getType());
        if (item.getValue().isPresent()) {
            recorder.bind(registry.getRegistry(), item.getName(), CamelSupport.loadClass(item.getType(), TCCL), item.getValue().get());
        } else {
            // the instance of the service will be instantiated by the recorder, this avoid
            // creating a recorder for trivial services.
            recorder.bind(registry.getRegistry(), item.getName(), CamelSupport.loadClass(item.getType(), TCCL));
        }
    });
}
Also used : CamelRuntimeTaskBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelRuntimeTaskBuildItem) Record(io.quarkus.deployment.annotations.Record) CamelSupport(org.apache.camel.quarkus.core.deployment.util.CamelSupport) CamelContextBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelContextBuildItem) Logger(org.slf4j.Logger) ApplicationArchivesBuildItem(io.quarkus.deployment.builditem.ApplicationArchivesBuildItem) CamelBeanBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelBeanBuildItem) CamelRuntimeBeanBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelRuntimeBeanBuildItem) PathFilter(org.apache.camel.quarkus.core.deployment.util.PathFilter) ExecutionTime(io.quarkus.deployment.annotations.ExecutionTime) LoggerFactory(org.slf4j.LoggerFactory) CamelServiceFilterBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelServiceFilterBuildItem) ContainerBeansBuildItem(org.apache.camel.quarkus.core.deployment.spi.ContainerBeansBuildItem) CamelRegistryBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelRegistryBuildItem) CamelServicePatternBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelServicePatternBuildItem) BuildStep(io.quarkus.deployment.annotations.BuildStep) List(java.util.List) CamelConfig(org.apache.camel.quarkus.core.CamelConfig) CamelRecorder(org.apache.camel.quarkus.core.CamelRecorder) CamelServiceDestination(org.apache.camel.quarkus.core.deployment.spi.CamelServiceDestination) PathFilter(org.apache.camel.quarkus.core.deployment.util.PathFilter) Record(io.quarkus.deployment.annotations.Record) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 3 with ApplicationArchivesBuildItem

use of io.quarkus.deployment.builditem.ApplicationArchivesBuildItem in project camel-quarkus by apache.

the class CamelNativeImageProcessor method reflection.

@BuildStep
void reflection(CamelConfig config, ApplicationArchivesBuildItem archives, BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) {
    final ReflectionConfig reflectionConfig = config.native_.reflection;
    if (!reflectionConfig.includePatterns.isPresent()) {
        LOGGER.debug("No classes registered for reflection via quarkus.camel.native.reflection.include-patterns");
        return;
    }
    LOGGER.debug("Scanning resources for native inclusion from include-patterns {}", reflectionConfig.includePatterns.get());
    final PathFilter.Builder builder = new PathFilter.Builder();
    reflectionConfig.includePatterns.map(Collection::stream).orElseGet(Stream::empty).map(className -> className.replace('.', '/')).forEach(builder::include);
    reflectionConfig.excludePatterns.map(Collection::stream).orElseGet(Stream::empty).map(className -> className.replace('.', '/')).forEach(builder::exclude);
    final PathFilter pathFilter = builder.build();
    Stream<Path> archiveRootDirs = archives.getAllApplicationArchives().stream().peek(archive -> LOGGER.debug("Scanning resources for native inclusion from archive at {}", archive.getResolvedPaths())).flatMap(archive -> archive.getRootDirectories().stream());
    String[] selectedClassNames = pathFilter.scanClassNames(archiveRootDirs);
    if (selectedClassNames.length > 0) {
        reflectiveClasses.produce(new ReflectiveClassBuildItem(true, true, selectedClassNames));
    }
}
Also used : PropertiesComponent(org.apache.camel.spi.PropertiesComponent) Arrays(java.util.Arrays) CamelContextHelper(org.apache.camel.support.CamelContextHelper) LoggerFactory(org.slf4j.LoggerFactory) Endpoint(org.apache.camel.Endpoint) CamelServicePatternBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelServicePatternBuildItem) ClassInfo(org.jboss.jandex.ClassInfo) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) Consumer(org.apache.camel.Consumer) DefaultComponentResolver(org.apache.camel.impl.engine.DefaultComponentResolver) ReflectionConfig(org.apache.camel.quarkus.core.CamelConfig.ReflectionConfig) Path(java.nio.file.Path) ExchangeFormatter(org.apache.camel.spi.ExchangeFormatter) AnnotationValue(org.jboss.jandex.AnnotationValue) Collection(java.util.Collection) NativeImageResourceBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) ScheduledPollConsumerScheduler(org.apache.camel.spi.ScheduledPollConsumerScheduler) StreamCachingStrategy(org.apache.camel.spi.StreamCachingStrategy) CamelRoutesBuilderClassBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelRoutesBuilderClassBuildItem) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) CamelSupport(org.apache.camel.quarkus.core.deployment.util.CamelSupport) ResourcesConfig(org.apache.camel.quarkus.core.CamelConfig.ResourcesConfig) DotName(org.jboss.jandex.DotName) Component(org.apache.camel.Component) ArrayList(java.util.ArrayList) BuildStep(io.quarkus.deployment.annotations.BuildStep) ReflectiveMethodBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveMethodBuildItem) Kind(org.jboss.jandex.AnnotationTarget.Kind) ClassUtils.getPackageName(org.apache.commons.lang3.ClassUtils.getPackageName) DefaultDataFormatResolver(org.apache.camel.impl.engine.DefaultDataFormatResolver) IndexView(org.jboss.jandex.IndexView) CamelContext(org.apache.camel.CamelContext) Logger(org.slf4j.Logger) ApplicationArchivesBuildItem(io.quarkus.deployment.builditem.ApplicationArchivesBuildItem) Files(java.nio.file.Files) PathFilter(org.apache.camel.quarkus.core.deployment.util.PathFilter) Producer(org.apache.camel.Producer) DefaultLanguageResolver(org.apache.camel.impl.engine.DefaultLanguageResolver) Converter(org.apache.camel.Converter) ApplicationArchive(io.quarkus.deployment.ApplicationArchive) DataFormat(org.apache.camel.spi.DataFormat) TypeConverter(org.apache.camel.TypeConverter) CamelConfig(org.apache.camel.quarkus.core.CamelConfig) CamelServiceBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelServiceBuildItem) CamelConfigFlags(org.apache.camel.quarkus.core.CamelConfigFlags) Path(java.nio.file.Path) PathFilter(org.apache.camel.quarkus.core.deployment.util.PathFilter) Stream(java.util.stream.Stream) ReflectionConfig(org.apache.camel.quarkus.core.CamelConfig.ReflectionConfig) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 4 with ApplicationArchivesBuildItem

use of io.quarkus.deployment.builditem.ApplicationArchivesBuildItem in project camel-quarkus by apache.

the class CamelNativeImageProcessor method camelRuntimeCatalog.

/*
     * Add camel catalog files to the native image.
     */
@BuildStep(onlyIf = CamelConfigFlags.RuntimeCatalogEnabled.class)
List<NativeImageResourceBuildItem> camelRuntimeCatalog(CamelConfig config, ApplicationArchivesBuildItem archives, List<CamelServicePatternBuildItem> servicePatterns) {
    List<NativeImageResourceBuildItem> resources = new ArrayList<>();
    final PathFilter pathFilter = servicePatterns.stream().collect(PathFilter.Builder::new, (builder, patterns) -> builder.patterns(patterns.isInclude(), patterns.getPatterns()), PathFilter.Builder::combine).build();
    CamelSupport.services(archives, pathFilter).filter(service -> service.name != null && service.type != null && service.path != null).forEach(service -> {
        String packageName = getPackageName(service.type);
        String jsonPath = String.format("%s/%s.json", packageName.replace('.', '/'), service.name);
        if (config.runtimeCatalog.components && service.path.startsWith(DefaultComponentResolver.RESOURCE_PATH)) {
            resources.add(new NativeImageResourceBuildItem(jsonPath));
        }
        if (config.runtimeCatalog.dataformats && service.path.startsWith(DefaultDataFormatResolver.DATAFORMAT_RESOURCE_PATH)) {
            resources.add(new NativeImageResourceBuildItem(jsonPath));
        }
        if (config.runtimeCatalog.languages && service.path.startsWith(DefaultLanguageResolver.LANGUAGE_RESOURCE_PATH)) {
            resources.add(new NativeImageResourceBuildItem(jsonPath));
        }
    });
    if (config.runtimeCatalog.models) {
        for (ApplicationArchive archive : archives.getAllApplicationArchives()) {
            for (Path root : archive.getRootDirectories()) {
                final Path resourcePath = root.resolve(CamelContextHelper.MODEL_DOCUMENTATION_PREFIX);
                if (!Files.isDirectory(resourcePath)) {
                    continue;
                }
                List<String> items = CamelSupport.safeWalk(resourcePath).filter(Files::isRegularFile).map(root::relativize).map(Path::toString).collect(Collectors.toList());
                LOGGER.debug("Register catalog json: {}", items);
                resources.add(new NativeImageResourceBuildItem(items));
            }
        }
    }
    return resources;
}
Also used : NativeImageResourceBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem) PropertiesComponent(org.apache.camel.spi.PropertiesComponent) Arrays(java.util.Arrays) CamelContextHelper(org.apache.camel.support.CamelContextHelper) LoggerFactory(org.slf4j.LoggerFactory) Endpoint(org.apache.camel.Endpoint) CamelServicePatternBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelServicePatternBuildItem) ClassInfo(org.jboss.jandex.ClassInfo) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) Consumer(org.apache.camel.Consumer) DefaultComponentResolver(org.apache.camel.impl.engine.DefaultComponentResolver) ReflectionConfig(org.apache.camel.quarkus.core.CamelConfig.ReflectionConfig) Path(java.nio.file.Path) ExchangeFormatter(org.apache.camel.spi.ExchangeFormatter) AnnotationValue(org.jboss.jandex.AnnotationValue) Collection(java.util.Collection) NativeImageResourceBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) ScheduledPollConsumerScheduler(org.apache.camel.spi.ScheduledPollConsumerScheduler) StreamCachingStrategy(org.apache.camel.spi.StreamCachingStrategy) CamelRoutesBuilderClassBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelRoutesBuilderClassBuildItem) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) CamelSupport(org.apache.camel.quarkus.core.deployment.util.CamelSupport) ResourcesConfig(org.apache.camel.quarkus.core.CamelConfig.ResourcesConfig) DotName(org.jboss.jandex.DotName) Component(org.apache.camel.Component) ArrayList(java.util.ArrayList) BuildStep(io.quarkus.deployment.annotations.BuildStep) ReflectiveMethodBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveMethodBuildItem) Kind(org.jboss.jandex.AnnotationTarget.Kind) ClassUtils.getPackageName(org.apache.commons.lang3.ClassUtils.getPackageName) DefaultDataFormatResolver(org.apache.camel.impl.engine.DefaultDataFormatResolver) IndexView(org.jboss.jandex.IndexView) CamelContext(org.apache.camel.CamelContext) Logger(org.slf4j.Logger) ApplicationArchivesBuildItem(io.quarkus.deployment.builditem.ApplicationArchivesBuildItem) Files(java.nio.file.Files) PathFilter(org.apache.camel.quarkus.core.deployment.util.PathFilter) Producer(org.apache.camel.Producer) DefaultLanguageResolver(org.apache.camel.impl.engine.DefaultLanguageResolver) Converter(org.apache.camel.Converter) ApplicationArchive(io.quarkus.deployment.ApplicationArchive) DataFormat(org.apache.camel.spi.DataFormat) TypeConverter(org.apache.camel.TypeConverter) CamelConfig(org.apache.camel.quarkus.core.CamelConfig) CamelServiceBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelServiceBuildItem) CamelConfigFlags(org.apache.camel.quarkus.core.CamelConfigFlags) Path(java.nio.file.Path) PathFilter(org.apache.camel.quarkus.core.deployment.util.PathFilter) ArrayList(java.util.ArrayList) ApplicationArchive(io.quarkus.deployment.ApplicationArchive) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 5 with ApplicationArchivesBuildItem

use of io.quarkus.deployment.builditem.ApplicationArchivesBuildItem in project automatiko-engine by automatiko-io.

the class AutomatikoQuarkusProcessor method reflectiveClassesRegistrationStep.

@BuildStep
public void reflectiveClassesRegistrationStep(ApplicationArchivesBuildItem archives, BuildProducer<ReflectiveHierarchyIgnoreWarningBuildItem> reflectiveHierarchy, BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "io.automatiko.engine.api.event.AbstractDataEvent"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "io.automatiko.engine.services.event.AbstractProcessDataEvent"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "io.automatiko.engine.services.event.ProcessInstanceDataEvent"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "io.automatiko.engine.services.event.UserTaskInstanceDataEvent"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "io.automatiko.engine.services.event.VariableInstanceDataEvent"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "io.automatiko.engine.services.event.impl.ProcessInstanceEventBody"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "io.automatiko.engine.services.event.impl.NodeInstanceEventBody"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "io.automatiko.engine.services.event.impl.ProcessErrorEventBody"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "io.automatiko.engine.services.event.impl.VariableInstanceEventBody"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "io.automatiko.engine.services.event.impl.UserTaskInstanceEventBody"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, "org.mvel2.optimizers.dynamic.DynamicOptimizer"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, "org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, ArrayList.class.getCanonicalName()));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, byte[].class.getName()));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, BaseWorkItem.class));
    List<IndexView> archiveIndexes = new ArrayList<>();
    for (ApplicationArchive i : archives.getAllApplicationArchives()) {
        archiveIndexes.add(i.getIndex());
    }
    CompositeIndex archivesIndex = CompositeIndex.create(archiveIndexes);
    // add functions classes found
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, "io.automatiko.engine.services.execution.BaseFunctions"));
    archivesIndex.getAllKnownImplementors(createDotName("io.automatiko.engine.api.Functions")).stream().map(c -> c.name().toString()).forEach(c -> reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, c)));
    // DMN related
    DotName classDotName = createDotName(CodeGenConstants.DMN_CLASS);
    if (!archivesIndex.getAnnotations(classDotName).isEmpty() || archivesIndex.getClassByName(classDotName) != null) {
        reflectiveHierarchy.produce(new ReflectiveHierarchyIgnoreWarningBuildItem(createDotName("org.kie.api.builder.Message$Level")));
        reflectiveHierarchy.produce(new ReflectiveHierarchyIgnoreWarningBuildItem(createDotName("org.kie.dmn.api.core.DMNContext")));
        reflectiveHierarchy.produce(new ReflectiveHierarchyIgnoreWarningBuildItem(createDotName("org.kie.dmn.api.core.DMNDecisionResult")));
        reflectiveHierarchy.produce(new ReflectiveHierarchyIgnoreWarningBuildItem(createDotName("org.kie.dmn.api.core.DMNDecisionResult$DecisionEvaluationStatus")));
        reflectiveHierarchy.produce(new ReflectiveHierarchyIgnoreWarningBuildItem(createDotName("org.kie.dmn.api.core.DMNMessage")));
        reflectiveHierarchy.produce(new ReflectiveHierarchyIgnoreWarningBuildItem(createDotName("org.kie.dmn.api.core.DMNMessage$Severity")));
        reflectiveHierarchy.produce(new ReflectiveHierarchyIgnoreWarningBuildItem(createDotName("org.kie.dmn.api.core.DMNMessageType")));
        reflectiveHierarchy.produce(new ReflectiveHierarchyIgnoreWarningBuildItem(createDotName("org.kie.dmn.api.feel.runtime.events.FEELEvent")));
    }
    // jackson node classes for serializing JSON tree instances
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "com.fasterxml.jackson.databind.node.TextNode"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "com.fasterxml.jackson.databind.node.BinaryNode"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "com.fasterxml.jackson.databind.node.BooleanNode"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "com.fasterxml.jackson.databind.node.NullNode"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "com.fasterxml.jackson.databind.node.BigIntegerNode"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "com.fasterxml.jackson.databind.node.DecimalNode"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "com.fasterxml.jackson.databind.node.DoubleNode"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "com.fasterxml.jackson.databind.node.FloatNode"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "com.fasterxml.jackson.databind.node.IntNode"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "com.fasterxml.jackson.databind.node.LongNode"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "com.fasterxml.jackson.databind.node.ShortNode"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "com.fasterxml.jackson.databind.node.POJONode"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "com.fasterxml.jackson.databind.node.ObjectNode"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, "com.fasterxml.jackson.databind.node.ArrayNode"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, Long.class.getCanonicalName()));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, Integer.class.getCanonicalName()));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, Boolean.class.getCanonicalName()));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, String.class.getCanonicalName()));
}
Also used : BiFunction(java.util.function.BiFunction) LoggerFactory(org.slf4j.LoggerFactory) GeneratorContext(io.automatiko.engine.codegen.GeneratorContext) ClassInfo(org.jboss.jandex.ClassInfo) TestRunListener(io.quarkus.deployment.dev.testing.TestRunListener) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) CodeGenConstants(io.automatiko.engine.codegen.CodeGenConstants) GeneratedBeanBuildItem(io.quarkus.arc.deployment.GeneratedBeanBuildItem) MethodInfo(org.jboss.jandex.MethodInfo) ArchiveRootBuildItem(io.quarkus.deployment.builditem.ArchiveRootBuildItem) FeatureBuildItem(io.quarkus.deployment.builditem.FeatureBuildItem) CompilationTask(javax.tools.JavaCompiler.CompilationTask) CompositeIndex(org.jboss.jandex.CompositeIndex) Diagnostic(javax.tools.Diagnostic) Map(java.util.Map) CDIDependencyInjectionAnnotator(io.automatiko.engine.codegen.di.CDIDependencyInjectionAnnotator) URI(java.net.URI) Path(java.nio.file.Path) DiagnosticCollector(javax.tools.DiagnosticCollector) TestListener(io.quarkus.deployment.dev.testing.TestListener) TestListenerBuildItem(io.quarkus.deployment.dev.testing.TestListenerBuildItem) SimpleJavaFileObject(javax.tools.SimpleJavaFileObject) IoUtils(io.automatiko.engine.services.utils.IoUtils) StandardLocation(javax.tools.StandardLocation) Model(io.automatiko.engine.api.Model) JavaCompiler(javax.tools.JavaCompiler) AutomatikoMessages(io.automatiko.engine.workflow.marshalling.impl.AutomatikoMessages) Collection(java.util.Collection) Set(java.util.Set) NativeImageResourceBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem) QuarkusClassLoader(io.quarkus.bootstrap.classloading.QuarkusClassLoader) Collectors(java.util.stream.Collectors) PackageConfig(io.quarkus.deployment.pkg.PackageConfig) JavaFileObject(javax.tools.JavaFileObject) List(java.util.List) ApplicationModel(io.quarkus.bootstrap.model.ApplicationModel) ConfigProvider(org.eclipse.microprofile.config.ConfigProvider) ResolvedDependency(io.quarkus.maven.dependency.ResolvedDependency) ServiceProviderBuildItem(io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem) QuarkusApplicationBuildContext(io.automatiko.engine.codegen.context.QuarkusApplicationBuildContext) ReflectiveHierarchyIgnoreWarningBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyIgnoreWarningBuildItem) ToolProvider(javax.tools.ToolProvider) IndexingUtil(io.quarkus.deployment.index.IndexingUtil) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) ProcessCodegen(io.automatiko.engine.codegen.process.ProcessCodegen) DotName(org.jboss.jandex.DotName) PersistenceGenerator(io.automatiko.engine.codegen.process.persistence.PersistenceGenerator) LaunchMode(io.quarkus.runtime.LaunchMode) CurateOutcomeBuildItem(io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) PathsCollection(io.quarkus.bootstrap.model.PathsCollection) Indexer(org.jboss.jandex.Indexer) BuildStep(io.quarkus.deployment.annotations.BuildStep) BaseWorkItem(io.automatiko.engine.workflow.BaseWorkItem) Index(org.jboss.jandex.Index) LinkedHashSet(java.util.LinkedHashSet) IndexView(org.jboss.jandex.IndexView) GeneratedResourceBuildItem(io.quarkus.deployment.builditem.GeneratedResourceBuildItem) GeneratedFile(io.automatiko.engine.codegen.GeneratedFile) RuntimeInitializedClassBuildItem(io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem) Logger(org.slf4j.Logger) MemoryClassPathElement(io.quarkus.bootstrap.classloading.MemoryClassPathElement) ClassPathElement(io.quarkus.bootstrap.classloading.ClassPathElement) ApplicationArchivesBuildItem(io.quarkus.deployment.builditem.ApplicationArchivesBuildItem) Files(java.nio.file.Files) ApplicationGenerator(io.automatiko.engine.codegen.ApplicationGenerator) IOException(java.io.IOException) Field(java.lang.reflect.Field) File(java.io.File) Consumer(java.util.function.Consumer) DecisionCodegen(io.automatiko.engine.codegen.decision.DecisionCodegen) ApplicationArchive(io.quarkus.deployment.ApplicationArchive) StandardJavaFileManager(javax.tools.StandardJavaFileManager) BootstrapDependencyProcessingException(io.quarkus.bootstrap.BootstrapDependencyProcessingException) AdditionalIndexedClassesBuildItem(io.quarkus.deployment.builditem.AdditionalIndexedClassesBuildItem) Paths(java.nio.file.Paths) LaunchModeBuildItem(io.quarkus.deployment.builditem.LaunchModeBuildItem) AutomatikoBuildTimeConfig(io.automatiko.engine.quarkus.AutomatikoBuildTimeConfig) Collections(java.util.Collections) AutomatikoConfigProperties(io.automatiko.engine.api.codegen.AutomatikoConfigProperties) LiveReloadBuildItem(io.quarkus.deployment.builditem.LiveReloadBuildItem) ReflectiveHierarchyIgnoreWarningBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyIgnoreWarningBuildItem) IndexView(org.jboss.jandex.IndexView) ArrayList(java.util.ArrayList) CompositeIndex(org.jboss.jandex.CompositeIndex) ApplicationArchive(io.quarkus.deployment.ApplicationArchive) DotName(org.jboss.jandex.DotName) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) BaseWorkItem(io.automatiko.engine.workflow.BaseWorkItem) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Aggregations

BuildStep (io.quarkus.deployment.annotations.BuildStep)6 ApplicationArchivesBuildItem (io.quarkus.deployment.builditem.ApplicationArchivesBuildItem)6 List (java.util.List)6 ApplicationArchive (io.quarkus.deployment.ApplicationArchive)5 BuildProducer (io.quarkus.deployment.annotations.BuildProducer)5 NativeImageResourceBuildItem (io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem)5 ReflectiveClassBuildItem (io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem)5 Files (java.nio.file.Files)5 Path (java.nio.file.Path)5 Collectors (java.util.stream.Collectors)5 CamelConfig (org.apache.camel.quarkus.core.CamelConfig)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 CombinedIndexBuildItem (io.quarkus.deployment.builditem.CombinedIndexBuildItem)4 Converter (org.apache.camel.Converter)4 CamelConfigFlags (org.apache.camel.quarkus.core.CamelConfigFlags)4 CamelServicePatternBuildItem (org.apache.camel.quarkus.core.deployment.spi.CamelServicePatternBuildItem)4 CamelSupport (org.apache.camel.quarkus.core.deployment.util.CamelSupport)4 PathFilter (org.apache.camel.quarkus.core.deployment.util.PathFilter)4 ClassInfo (org.jboss.jandex.ClassInfo)4