Java Code Examples for io.quarkus.deployment.annotations.BuildProducer

The following examples show how to use io.quarkus.deployment.annotations.BuildProducer. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: camel-quarkus   Source File: CamelProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep
void userServicePatterns(
        CamelConfig camelConfig,
        BuildProducer<CamelServicePatternBuildItem> services) {

    camelConfig.service.discovery.includePatterns.ifPresent(list -> services.produce(new CamelServicePatternBuildItem(
            CamelServiceDestination.DISCOVERY,
            true,
            list)));

    camelConfig.service.discovery.excludePatterns.ifPresent(list -> services.produce(new CamelServicePatternBuildItem(
            CamelServiceDestination.DISCOVERY,
            false,
            list)));

    camelConfig.service.registry.includePatterns.ifPresent(list -> services.produce(new CamelServicePatternBuildItem(
            CamelServiceDestination.REGISTRY,
            true,
            list)));

    camelConfig.service.registry.excludePatterns.ifPresent(list -> services.produce(new CamelServicePatternBuildItem(
            CamelServiceDestination.REGISTRY,
            false,
            list)));
}
 
Example 2
Source Project: camel-quarkus   Source File: GoogleSheetsProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep
void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
        BuildProducer<UnbannedReflectiveBuildItem> unbannedClass, CombinedIndexBuildItem combinedIndex) {
    IndexView index = combinedIndex.getIndex();

    // Google sheets component configuration class reflection
    Collection<AnnotationInstance> uriParams = index
            .getAnnotations(DotName.createSimple("org.apache.camel.spi.UriParams"));

    String[] googleMailConfigClasses = uriParams.stream()
            .map(annotation -> annotation.target())
            .filter(annotationTarget -> annotationTarget.kind().equals(AnnotationTarget.Kind.CLASS))
            .map(annotationTarget -> annotationTarget.asClass().name().toString())
            .filter(className -> className.startsWith("org.apache.camel.component.google.sheets"))
            .toArray(String[]::new);

    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, googleMailConfigClasses));
    unbannedClass.produce(new UnbannedReflectiveBuildItem(googleMailConfigClasses));
}
 
Example 3
Source Project: camel-quarkus   Source File: Aws2SnsProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep(applicationArchiveMarkers = { AWS_SDK_APPLICATION_ARCHIVE_MARKERS })
void process(CombinedIndexBuildItem combinedIndexBuildItem,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClasses,
        BuildProducer<NativeImageResourceBuildItem> resource) {

    INTERCEPTOR_PATHS.forEach(path -> resource.produce(new NativeImageResourceBuildItem(path)));

    List<String> knownInterceptorImpls = combinedIndexBuildItem.getIndex()
            .getAllKnownImplementors(EXECUTION_INTERCEPTOR_NAME)
            .stream()
            .map(c -> c.name().toString()).collect(Collectors.toList());

    reflectiveClasses.produce(new ReflectiveClassBuildItem(false, false,
            knownInterceptorImpls.toArray(new String[knownInterceptorImpls.size()])));

    reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false,
            String.class.getCanonicalName()));
}
 
Example 4
Source Project: camel-k-runtime   Source File: DeploymentProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep
void registerServices(
        BuildProducer<ServiceProviderBuildItem> serviceProvider,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
        CombinedIndexBuildItem combinedIndexBuildItem) {

    final IndexView view = combinedIndexBuildItem.getIndex();
    final String serviceType = "org.apache.camel.k.Runtime$Listener";

    getAllKnownImplementors(view, serviceType).forEach(i -> {
        serviceProvider.produce(
            new ServiceProviderBuildItem(
                serviceType,
                i.name().toString())
        );
    });
}
 
Example 5
Source Project: camel-quarkus   Source File: GoogleMailProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep
void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
        BuildProducer<UnbannedReflectiveBuildItem> unbannedClass, CombinedIndexBuildItem combinedIndex) {
    IndexView index = combinedIndex.getIndex();

    // Google mail component configuration class reflection
    Collection<AnnotationInstance> uriParams = index
            .getAnnotations(DotName.createSimple("org.apache.camel.spi.UriParams"));

    String[] googleMailConfigClasses = uriParams.stream()
            .map(annotation -> annotation.target())
            .filter(annotationTarget -> annotationTarget.kind().equals(AnnotationTarget.Kind.CLASS))
            .map(annotationTarget -> annotationTarget.asClass().name().toString())
            .filter(className -> className.startsWith("org.apache.camel.component.google.mail"))
            .toArray(String[]::new);

    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, googleMailConfigClasses));
    unbannedClass.produce(new UnbannedReflectiveBuildItem(googleMailConfigClasses));
}
 
Example 6
Source Project: camel-quarkus   Source File: Aws2KmsProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep(applicationArchiveMarkers = { AWS_SDK_APPLICATION_ARCHIVE_MARKERS })
void process(CombinedIndexBuildItem combinedIndexBuildItem,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClasses,
        BuildProducer<NativeImageResourceBuildItem> resource) {

    INTERCEPTOR_PATHS.forEach(path -> resource.produce(new NativeImageResourceBuildItem(path)));

    List<String> knownInterceptorImpls = combinedIndexBuildItem.getIndex()
            .getAllKnownImplementors(EXECUTION_INTERCEPTOR_NAME)
            .stream()
            .map(c -> c.name().toString()).collect(Collectors.toList());

    reflectiveClasses.produce(new ReflectiveClassBuildItem(false, false,
            knownInterceptorImpls.toArray(new String[knownInterceptorImpls.size()])));

    reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false,
            String.class.getCanonicalName()));
}
 
Example 7
Source Project: camel-quarkus   Source File: ServletProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep
void build(BuildProducer<ServletBuildItem> servlet, BuildProducer<AdditionalBeanBuildItem> additionalBean) {
    boolean servletCreated = false;
    if (camelServletConfig.defaultServlet.isValid()) {
        servlet.produce(
                newServlet(ServletConfig.DEFAULT_SERVLET_NAME, camelServletConfig.defaultServlet, additionalBean));
        servletCreated = true;
    }

    for (Entry<String, ServletConfig> e : camelServletConfig.namedServlets.entrySet()) {
        if (ServletConfig.DEFAULT_SERVLET_NAME.equals(e.getKey())) {
            throw new IllegalStateException(
                    String.format("Use quarkus.camel.servlet.url-patterns instead of quarkus.camel.servlet.%s.url-patterns",
                            ServletConfig.DEFAULT_SERVLET_NAME));
        }
        servlet.produce(newServlet(e.getKey(), e.getValue(), additionalBean));
        servletCreated = true;
    }

    if (!servletCreated) {
        throw new IllegalStateException(
                "Map at least one servlet to a path using quarkus.camel.servlet.url-patterns or quarkus.camel.servlet.[your-servlet-name].url-patterns");
    }

}
 
Example 8
Source Project: camel-quarkus   Source File: ServletProcessor.java    License: Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 9
Source Project: camel-quarkus   Source File: Aws2MqProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep(applicationArchiveMarkers = { AWS_SDK_APPLICATION_ARCHIVE_MARKERS })
void process(CombinedIndexBuildItem combinedIndexBuildItem,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClasses,
        BuildProducer<NativeImageResourceBuildItem> resource) {

    INTERCEPTOR_PATHS.forEach(path -> resource.produce(new NativeImageResourceBuildItem(path)));

    List<String> knownInterceptorImpls = combinedIndexBuildItem.getIndex()
            .getAllKnownImplementors(EXECUTION_INTERCEPTOR_NAME)
            .stream()
            .map(c -> c.name().toString()).collect(Collectors.toList());

    reflectiveClasses.produce(new ReflectiveClassBuildItem(false, false,
            knownInterceptorImpls.toArray(new String[knownInterceptorImpls.size()])));

    reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false,
            String.class.getCanonicalName()));
}
 
Example 10
Source Project: camel-quarkus   Source File: MicroProfileHealthProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep
void disableCamelMicroProfileHealthChecks(BuildProducer<AnnotationsTransformerBuildItem> transformers,
        CamelMicroProfileHealthConfig config) {
    if (!config.enabled) {
        // Veto the Camel MicroProfile checks to disable them
        transformers.produce(new AnnotationsTransformerBuildItem(context -> {
            if (context.isClass()) {
                AnnotationTarget target = context.getTarget();
                if (isCamelMicroProfileHealthCheck(target.asClass())) {
                    AnnotationInstance annotationInstance = AnnotationInstance.create(VETOED_DOTNAME, target,
                            new AnnotationValue[0]);
                    context.transform().add(annotationInstance).done();
                }
            }
        }));
    }
}
 
Example 11
Source Project: camel-quarkus   Source File: Aws2DdbProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep(applicationArchiveMarkers = { AWS_SDK_APPLICATION_ARCHIVE_MARKERS })
void process(CombinedIndexBuildItem combinedIndexBuildItem,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClasses,
        BuildProducer<NativeImageResourceBuildItem> resource) {

    INTERCEPTOR_PATHS.forEach(path -> resource.produce(new NativeImageResourceBuildItem(path)));

    List<String> knownInterceptorImpls = combinedIndexBuildItem.getIndex()
            .getAllKnownImplementors(EXECUTION_INTERCEPTOR_NAME)
            .stream()
            .map(c -> c.name().toString()).collect(Collectors.toList());

    reflectiveClasses.produce(new ReflectiveClassBuildItem(false, false,
            knownInterceptorImpls.toArray(new String[knownInterceptorImpls.size()])));

    reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false,
            String.class.getCanonicalName()));
}
 
Example 12
Source Project: camel-quarkus   Source File: JtaProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep
void transactedPolicy(
        BuildProducer<AdditionalBeanBuildItem> additionalBeans,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
        Capabilities capabilities) {
    if (capabilities.isCapabilityPresent(Capabilities.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()));
    }
}
 
Example 13
Source Project: camel-quarkus   Source File: Aws2EcsProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep(applicationArchiveMarkers = { AWS_SDK_APPLICATION_ARCHIVE_MARKERS })
void process(CombinedIndexBuildItem combinedIndexBuildItem,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClasses,
        BuildProducer<NativeImageResourceBuildItem> resource) {

    INTERCEPTOR_PATHS.forEach(path -> resource.produce(new NativeImageResourceBuildItem(path)));

    List<String> knownInterceptorImpls = combinedIndexBuildItem.getIndex()
            .getAllKnownImplementors(EXECUTION_INTERCEPTOR_NAME)
            .stream()
            .map(c -> c.name().toString()).collect(Collectors.toList());

    reflectiveClasses.produce(new ReflectiveClassBuildItem(false, false,
            knownInterceptorImpls.toArray(new String[knownInterceptorImpls.size()])));

    reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false,
            String.class.getCanonicalName()));
}
 
Example 14
Source Project: camel-quarkus   Source File: XmlSupportProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep
void reflective(BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
    reflectiveClass.produce(
            new ReflectiveClassBuildItem(
                    false,
                    false,
                    "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl",
                    "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl",
                    "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl",
                    "com.sun.org.apache.xerces.internal.parsers.SAXParser",
                    "com.sun.xml.internal.stream.XMLInputFactoryImpl",
                    "com.sun.xml.internal.stream.XMLOutputFactoryImpl"));

    reflectiveClass.produce(
            new ReflectiveClassBuildItem(
                    false,
                    false,
                    "org.apache.camel.converter.jaxp.XmlConverter"));

    // javax.xml.namespace.QName is needed as it is used as part of the processor
    // definitions in the DSL and parsers like Jackson (used in camel-k YAML DSL)
    // fails if this class is cannot be instantiated reflectively.
    reflectiveClass.produce(
            new ReflectiveClassBuildItem(true, false, "javax.xml.namespace.QName"));
}
 
Example 15
Source Project: camel-quarkus   Source File: Aws2IamProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep(applicationArchiveMarkers = { AWS_SDK_APPLICATION_ARCHIVE_MARKERS })
void process(CombinedIndexBuildItem combinedIndexBuildItem,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClasses,
        BuildProducer<NativeImageResourceBuildItem> resource) {

    INTERCEPTOR_PATHS.forEach(path -> resource.produce(new NativeImageResourceBuildItem(path)));

    List<String> knownInterceptorImpls = combinedIndexBuildItem.getIndex()
            .getAllKnownImplementors(EXECUTION_INTERCEPTOR_NAME)
            .stream()
            .map(c -> c.name().toString()).collect(Collectors.toList());

    reflectiveClasses.produce(new ReflectiveClassBuildItem(false, false,
            knownInterceptorImpls.toArray(new String[knownInterceptorImpls.size()])));

    reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false,
            String.class.getCanonicalName()));
}
 
Example 16
Source Project: camel-quarkus   Source File: Aws2EksProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep(applicationArchiveMarkers = { AWS_SDK_APPLICATION_ARCHIVE_MARKERS })
void process(CombinedIndexBuildItem combinedIndexBuildItem,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClasses,
        BuildProducer<NativeImageResourceBuildItem> resource) {

    INTERCEPTOR_PATHS.forEach(path -> resource.produce(new NativeImageResourceBuildItem(path)));

    List<String> knownInterceptorImpls = combinedIndexBuildItem.getIndex()
            .getAllKnownImplementors(EXECUTION_INTERCEPTOR_NAME)
            .stream()
            .map(c -> c.name().toString()).collect(Collectors.toList());

    reflectiveClasses.produce(new ReflectiveClassBuildItem(false, false,
            knownInterceptorImpls.toArray(new String[knownInterceptorImpls.size()])));

    reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false,
            String.class.getCanonicalName()));
}
 
Example 17
Source Project: camel-quarkus   Source File: Aws2TranslateProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep(applicationArchiveMarkers = { AWS_SDK_APPLICATION_ARCHIVE_MARKERS })
void process(CombinedIndexBuildItem combinedIndexBuildItem,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClasses,
        BuildProducer<NativeImageResourceBuildItem> resource) {

    INTERCEPTOR_PATHS.forEach(path -> resource.produce(new NativeImageResourceBuildItem(path)));

    List<String> knownInterceptorImpls = combinedIndexBuildItem.getIndex()
            .getAllKnownImplementors(EXECUTION_INTERCEPTOR_NAME)
            .stream()
            .map(c -> c.name().toString()).collect(Collectors.toList());

    reflectiveClasses.produce(new ReflectiveClassBuildItem(false, false,
            knownInterceptorImpls.toArray(new String[knownInterceptorImpls.size()])));

    reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false,
            String.class.getCanonicalName()));
}
 
Example 18
Source Project: camel-quarkus   Source File: Aws2SqsProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep(applicationArchiveMarkers = { AWS_SDK_APPLICATION_ARCHIVE_MARKERS })
void process(CombinedIndexBuildItem combinedIndexBuildItem,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClasses,
        BuildProducer<NativeImageResourceBuildItem> resource) {

    INTERCEPTOR_PATHS.forEach(path -> resource.produce(new NativeImageResourceBuildItem(path)));

    List<String> knownInterceptorImpls = combinedIndexBuildItem.getIndex()
            .getAllKnownImplementors(EXECUTION_INTERCEPTOR_NAME)
            .stream()
            .map(c -> c.name().toString()).collect(Collectors.toList());

    reflectiveClasses.produce(new ReflectiveClassBuildItem(false, false,
            knownInterceptorImpls.toArray(new String[knownInterceptorImpls.size()])));

    reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false,
            String.class.getCanonicalName()));
}
 
Example 19
Source Project: camel-quarkus   Source File: Aws2S3Processor.java    License: Apache License 2.0 6 votes vote down vote up
@BuildStep(applicationArchiveMarkers = { AWS_SDK_APPLICATION_ARCHIVE_MARKERS })
void process(CombinedIndexBuildItem combinedIndexBuildItem,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClasses,
        BuildProducer<NativeImageResourceBuildItem> resource) {

    INTERCEPTOR_PATHS.forEach(path -> resource.produce(new NativeImageResourceBuildItem(path)));

    List<String> knownInterceptorImpls = combinedIndexBuildItem.getIndex()
            .getAllKnownImplementors(EXECUTION_INTERCEPTOR_NAME)
            .stream()
            .map(c -> c.name().toString()).collect(Collectors.toList());

    reflectiveClasses.produce(new ReflectiveClassBuildItem(false, false,
            knownInterceptorImpls.toArray(new String[knownInterceptorImpls.size()])));

    reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false,
            String.class.getCanonicalName()));
}
 
Example 20
Source Project: camel-quarkus   Source File: AwsCommonsProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@BuildStep(loadsApplicationClasses = true)
void client(BeanRegistrationPhaseBuildItem beanRegistrationPhase,
        BuildProducer<ServiceProviderBuildItem> serviceProvider,
        BuildProducer<NativeImageProxyDefinitionBuildItem> proxyDefinition) {
    checkClasspath(APACHE_HTTP_SERVICE, "apache-client");

    serviceProvider.produce(new ServiceProviderBuildItem(SdkHttpService.class.getName(), APACHE_HTTP_SERVICE));

}
 
Example 21
Source Project: camel-quarkus   Source File: CamelProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@BuildStep
void coreServicePatterns(BuildProducer<CamelServicePatternBuildItem> services) {
    services.produce(new CamelServicePatternBuildItem(
            CamelServiceDestination.REGISTRY,
            true,
            "META-INF/services/org/apache/camel/component/*",
            "META-INF/services/org/apache/camel/language/constant",
            "META-INF/services/org/apache/camel/language/file",
            "META-INF/services/org/apache/camel/language/header",
            "META-INF/services/org/apache/camel/language/ref",
            "META-INF/services/org/apache/camel/language/simple"));

    services.produce(new CamelServicePatternBuildItem(
            CamelServiceDestination.DISCOVERY,
            true,
            "META-INF/services/org/apache/camel/*",
            "META-INF/services/org/apache/camel/management/*",
            "META-INF/services/org/apache/camel/model/*",
            "META-INF/services/org/apache/camel/configurer/*",
            "META-INF/services/org/apache/camel/language/*",
            "META-INF/services/org/apache/camel/dataformat/*",
            "META-INF/services/org/apache/camel/send-dynamic/*"));

    // TODO: Remove this after upgrade to Camel versions > 3.4.0
    services.produce(new CamelServicePatternBuildItem(
            CamelServiceDestination.DISCOVERY,
            false,
            "META-INF/services/org/apache/camel/configurer/ThreadPoolProfileConfigurationProperties"));
}
 
Example 22
Source Project: camel-quarkus   Source File: CamelNativeImageProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@BuildStep
void embedSelectResourcesInNativeExecutable(CamelConfig config, ApplicationArchivesBuildItem archives,
        BuildProducer<NativeImageResourceBuildItem> resources) {

    final ResourcesConfig resourcesConfig = config.native_.resources;
    if (!resourcesConfig.includePatterns.isPresent()) {
        LOGGER.debug("Not scanning resources for native inclusion as include-patterns is not set");
        return;
    }

    LOGGER.debug("Scanning resources for native inclusion from include-patterns {}",
            resourcesConfig.includePatterns.get());

    PathFilter pathFilter = new PathFilter.Builder()
            .include(resourcesConfig.includePatterns)
            .exclude(resourcesConfig.excludePatterns)
            .build();

    for (ApplicationArchive archive : archives.getAllApplicationArchives()) {
        LOGGER.debug("Scanning resources for native inclusion from archive at {}", archive.getPaths());

        for (Path rootPath : archive.getRootDirs()) {
            CamelSupport.safeWalk(rootPath).filter(path -> Files.isRegularFile(path))
                    .map(rootPath::relativize)
                    .filter(pathFilter.asPathPredicate())
                    .forEach(filteredPath -> {
                        resources.produce(new NativeImageResourceBuildItem(filteredPath.toString()));
                        LOGGER.debug("Embedding resource in native executable: {}", filteredPath.toString());
                    });
        }
    }
}
 
Example 23
Source Project: camel-quarkus   Source File: CamelNativeImageProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@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();

    for (ApplicationArchive archive : archives.getAllApplicationArchives()) {
        LOGGER.debug("Scanning resources for native inclusion from archive at {}", archive.getPaths());

        for (Path rootPath : archive.getRootDirs()) {
            String[] selectedClassNames = pathFilter.scanClassNames(rootPath, CamelSupport.safeWalk(rootPath),
                    Files::isRegularFile);
            if (selectedClassNames.length > 0) {
                reflectiveClasses.produce(new ReflectiveClassBuildItem(true, true, selectedClassNames));
            }
        }
    }
}
 
Example 24
Source Project: camel-quarkus   Source File: CamelNativeImageProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@BuildStep
void reflectiveRoutes(
        List<CamelRoutesBuilderClassBuildItem> camelRoutesBuilders,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {

    // Register routes as reflection aware as camel may use reflection
    // to perform post process tasks (i.e. for Camel's own DI)
    camelRoutesBuilders.forEach(camelRoutesBuilderClassBuildItem -> {
        reflectiveClass.produce(
                // Register fields and methods as they may be used by the bean post processor to
                // properly support @BindToRegistry
                new ReflectiveClassBuildItem(true, true, camelRoutesBuilderClassBuildItem.getDotName().toString()));
    });
}
 
Example 25
Source Project: camel-quarkus   Source File: ValidatorProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@BuildStep
void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
    reflectiveClass.produce(
            new ReflectiveClassBuildItem(
                    false,
                    false,
                    "org.apache.camel.support.processor.validation.DefaultValidationErrorHandler"));

    reflectiveClass.produce(
            new ReflectiveClassBuildItem(
                    false,
                    false,
                    "com.sun.org.apache.xerces.internal.impl.dv.xs.SchemaDVFactoryImpl"));
}
 
Example 26
Source Project: camel-quarkus   Source File: AwsKmsProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@BuildStep(applicationArchiveMarkers = { AWS_KMS_APPLICATION_ARCHIVE_MARKERS })
void process(CombinedIndexBuildItem combinedIndexBuildItem,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
        BuildProducer<NativeImageResourceBuildItem> resource) {

    resource.produce(new NativeImageResourceBuildItem("com/amazonaws/partitions/endpoints.json"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, false,
            Partitions.class.getCanonicalName(),
            Partition.class.getCanonicalName(),
            Endpoint.class.getCanonicalName(),
            Region.class.getCanonicalName(),
            Service.class.getCanonicalName(),
            CredentialScope.class.getCanonicalName()));
}
 
Example 27
Source Project: camel-quarkus   Source File: AwsSNSProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@BuildStep(applicationArchiveMarkers = { AWS_SNS_APPLICATION_ARCHIVE_MARKERS })
void process(CombinedIndexBuildItem combinedIndexBuildItem,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
        BuildProducer<NativeImageResourceBuildItem> resource) {

    resource.produce(new NativeImageResourceBuildItem("com/amazonaws/partitions/endpoints.json"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, false,
            Partitions.class.getCanonicalName(),
            Partition.class.getCanonicalName(),
            Endpoint.class.getCanonicalName(),
            Region.class.getCanonicalName(),
            Service.class.getCanonicalName(),
            CredentialScope.class.getCanonicalName(),
            AWS4Signer.class.getCanonicalName()));
}
 
Example 28
Source Project: camel-quarkus   Source File: HttpClientProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@BuildStep
void registerForReflection(
        CombinedIndexBuildItem index,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) {

    IndexView view = index.getIndex();

    for (ClassInfo info : view.getAllKnownSubclasses(HTTP_REQUEST_BASE_NAME)) {
        reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false, info.name().toString()));
    }
}
 
Example 29
Source Project: camel-quarkus   Source File: AwsTranslateProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@BuildStep(applicationArchiveMarkers = { AWS_TRANSLATE_APPLICATION_ARCHIVE_MARKERS })
void process(CombinedIndexBuildItem combinedIndexBuildItem,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
        BuildProducer<NativeImageResourceBuildItem> resource) {

    resource.produce(new NativeImageResourceBuildItem("com/amazonaws/partitions/endpoints.json"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, false,
            Partitions.class.getCanonicalName(),
            Partition.class.getCanonicalName(),
            Endpoint.class.getCanonicalName(),
            Region.class.getCanonicalName(),
            Service.class.getCanonicalName(),
            CredentialScope.class.getCanonicalName(),
            AWS4Signer.class.getCanonicalName()));
}
 
Example 30
Source Project: camel-quarkus   Source File: HystrixProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@BuildStep
void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
        BuildProducer<NativeImageSystemPropertyBuildItem> systemProperty) {

    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true,
            HystrixConfigurationCommon.class,
            HystrixConfigurationDefinition.class,
            CircuitBreakerDefinition.class,
            OnFallbackDefinition.class));

    // Force RxJava to not use Unsafe API
    systemProperty.produce(new NativeImageSystemPropertyBuildItem("rx.unsafe-disable", "true"));
}