Search in sources :

Example 6 with ServiceProviderBuildItem

use of io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem in project quarkus-tika by quarkiverse.

the class TikaProcessor method initializeTikaParser.

@BuildStep
@Record(ExecutionTime.STATIC_INIT)
void initializeTikaParser(BeanContainerBuildItem beanContainer, TikaRecorder recorder, BuildProducer<ServiceProviderBuildItem> serviceProvider, TikaConfiguration configuration) throws Exception {
    Map<String, List<TikaParserParameter>> parsers = getSupportedParserConfig(configuration.tikaConfigPath, configuration.parsers, configuration.parserOptions, configuration.parser);
    String tikaXmlConfiguration = generateTikaXmlConfiguration(parsers);
    serviceProvider.produce(new ServiceProviderBuildItem(Parser.class.getName(), new ArrayList<>(parsers.keySet())));
    serviceProvider.produce(new ServiceProviderBuildItem(Detector.class.getName(), getProviderNames(Detector.class.getName())));
    serviceProvider.produce(new ServiceProviderBuildItem(EncodingDetector.class.getName(), getProviderNames(EncodingDetector.class.getName())));
    recorder.initTikaParser(beanContainer.getValue(), configuration, tikaXmlConfiguration);
}
Also used : ServiceProviderBuildItem(io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem) EncodingDetector(org.apache.tika.detect.EncodingDetector) Detector(org.apache.tika.detect.Detector) EncodingDetector(org.apache.tika.detect.EncodingDetector) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) BuildStep(io.quarkus.deployment.annotations.BuildStep) Record(io.quarkus.deployment.annotations.Record)

Example 7 with ServiceProviderBuildItem

use of io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem in project quarkus-amazon-services by quarkiverse.

the class AmazonServicesClientsProcessor method setup.

@BuildStep
void setup(CombinedIndexBuildItem combinedIndexBuildItem, List<AmazonClientBuildItem> amazonClients, List<AmazonClientInterceptorsPathBuildItem> interceptors, BuildProducer<ReflectiveClassBuildItem> reflectiveClasses, BuildProducer<NativeImageResourceBuildItem> resource, BuildProducer<NativeImageProxyDefinitionBuildItem> proxyDefinition, BuildProducer<ServiceProviderBuildItem> serviceProvider) {
    interceptors.stream().map(AmazonClientInterceptorsPathBuildItem::getInterceptorsPath).forEach(path -> resource.produce(new NativeImageResourceBuildItem(path)));
    // Discover all interceptor implementations
    List<String> knownInterceptorImpls = combinedIndexBuildItem.getIndex().getAllKnownImplementors(EXECUTION_INTERCEPTOR_NAME).stream().map(c -> c.name().toString()).collect(Collectors.toList());
    // Validate configurations
    for (AmazonClientBuildItem client : amazonClients) {
        SdkBuildTimeConfig clientSdkConfig = client.getBuildTimeSdkConfig();
        if (clientSdkConfig != null) {
            clientSdkConfig.interceptors.orElse(Collections.emptyList()).forEach(interceptorClassName -> {
                interceptorClassName = interceptorClassName.trim();
                if (!knownInterceptorImpls.contains(interceptorClassName)) {
                    throw new ConfigurationException(String.format("quarkus.%s.interceptors (%s) - must list only existing implementations of software.amazon.awssdk.core.interceptor.ExecutionInterceptor", client.getAwsClientName(), clientSdkConfig.interceptors.toString()));
                }
            });
        }
    }
    reflectiveClasses.produce(new ReflectiveClassBuildItem(false, false, knownInterceptorImpls.toArray(new String[knownInterceptorImpls.size()])));
    reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false, "com.sun.xml.internal.stream.XMLInputFactoryImpl"));
    reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false, "com.sun.xml.internal.stream.XMLOutputFactoryImpl"));
    boolean syncTransportNeeded = amazonClients.stream().anyMatch(item -> item.getSyncClassName().isPresent());
    boolean asyncTransportNeeded = amazonClients.stream().anyMatch(item -> item.getAsyncClassName().isPresent());
    final Predicate<AmazonClientBuildItem> isSyncApache = client -> client.getBuildTimeSyncConfig().type == SyncClientType.APACHE;
    // Register what's needed depending on the clients in the classpath and the configuration.
    // We use the configuration to guide us but if we don't have any clients configured,
    // we still register what's needed depending on what is in the classpath.
    boolean isSyncApacheInClasspath = isInClasspath(AmazonHttpClients.APACHE_HTTP_SERVICE);
    boolean isSyncUrlConnectionInClasspath = isInClasspath(AmazonHttpClients.URL_CONNECTION_HTTP_SERVICE);
    boolean isAsyncInClasspath = isInClasspath(AmazonHttpClients.NETTY_HTTP_SERVICE);
    // Check that the clients required by the configuration are available
    if (syncTransportNeeded) {
        if (amazonClients.stream().filter(isSyncApache).findAny().isPresent()) {
            if (isSyncApacheInClasspath) {
                registerSyncApacheClient(proxyDefinition, serviceProvider);
            } else {
                throw missingDependencyException("apache-client");
            }
        } else if (isSyncUrlConnectionInClasspath) {
            registerSyncUrlConnectionClient(serviceProvider);
        } else {
            throw missingDependencyException("url-connection-client");
        }
    } else {
        // but this time only based on the classpath.
        if (isSyncApacheInClasspath) {
            registerSyncApacheClient(proxyDefinition, serviceProvider);
        } else if (isSyncUrlConnectionInClasspath) {
            registerSyncUrlConnectionClient(serviceProvider);
        }
    }
    if (isAsyncInClasspath) {
        registerAsyncNettyClient(serviceProvider);
    } else if (asyncTransportNeeded) {
        throw missingDependencyException("netty-nio-client");
    }
}
Also used : NativeImageResourceBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) RuntimeInitializedClassBuildItem(io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem) Predicate(java.util.function.Predicate) DeploymentException(javax.enterprise.inject.spi.DeploymentException) DotName(org.jboss.jandex.DotName) NativeImageResourceBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem) ExecutionInterceptor(software.amazon.awssdk.core.interceptor.ExecutionInterceptor) SyncClientType(io.quarkus.amazon.common.runtime.SyncHttpClientBuildTimeConfig.SyncClientType) Collectors(java.util.stream.Collectors) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) ConfigurationException(io.quarkus.runtime.configuration.ConfigurationException) BuildStep(io.quarkus.deployment.annotations.BuildStep) List(java.util.List) AdditionalApplicationArchiveMarkerBuildItem(io.quarkus.deployment.builditem.AdditionalApplicationArchiveMarkerBuildItem) NativeImageProxyDefinitionBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem) ServiceProviderBuildItem(io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem) Collections(java.util.Collections) SdkBuildTimeConfig(io.quarkus.amazon.common.runtime.SdkBuildTimeConfig) SdkHttpService(software.amazon.awssdk.http.SdkHttpService) SdkAsyncHttpService(software.amazon.awssdk.http.async.SdkAsyncHttpService) SdkBuildTimeConfig(io.quarkus.amazon.common.runtime.SdkBuildTimeConfig) ConfigurationException(io.quarkus.runtime.configuration.ConfigurationException) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 8 with ServiceProviderBuildItem

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

the class AwsCommonsProcessor method client.

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

Example 9 with ServiceProviderBuildItem

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

the class PgeventProcessor method registerNativeImageResources.

@BuildStep
void registerNativeImageResources(BuildProducer<ServiceProviderBuildItem> services) {
    Stream.of(ProcProvider.class.getName(), Driver.class.getName()).forEach(service -> {
        try {
            Set<String> implementations = ServiceUtil.classNamesNamedIn(Thread.currentThread().getContextClassLoader(), PGEVENT_SERVICE_BASE + service);
            services.produce(new ServiceProviderBuildItem(service, implementations.toArray(new String[0])));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    });
}
Also used : ServiceProviderBuildItem(io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem) IOException(java.io.IOException) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 10 with ServiceProviderBuildItem

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

the class StaxSupportProcessor method registerServices.

@BuildStep
void registerServices(BuildProducer<ServiceProviderBuildItem> serviceProvider) {
    Stream.concat(Stream.of(XMLEventFactory.class, XMLInputFactory.class, XMLOutputFactory.class).map(Class::getName), Stream.of(XMLValidationSchemaFactory.INTERNAL_ID_SCHEMA_DTD, XMLValidationSchemaFactory.INTERNAL_ID_SCHEMA_RELAXNG, XMLValidationSchemaFactory.INTERNAL_ID_SCHEMA_W3C).map(schemaId -> XMLValidationSchemaFactory.class.getName() + "." + schemaId)).forEach(serviceName -> {
        try {
            final Set<String> names = ServiceUtil.classNamesNamedIn(Thread.currentThread().getContextClassLoader(), SPI_ROOT + serviceName);
            serviceProvider.produce(new ServiceProviderBuildItem(serviceName, new ArrayList<>(names)));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    });
}
Also used : XMLOutputFactory(javax.xml.stream.XMLOutputFactory) ServiceProviderBuildItem(io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem) XMLValidationSchemaFactory(org.codehaus.stax2.validation.XMLValidationSchemaFactory) XMLEventFactory(javax.xml.stream.XMLEventFactory) ArrayList(java.util.ArrayList) IOException(java.io.IOException) XMLInputFactory(javax.xml.stream.XMLInputFactory) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Aggregations

ServiceProviderBuildItem (io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem)13 BuildStep (io.quarkus.deployment.annotations.BuildStep)12 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 ReflectiveClassBuildItem (io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem)4 NativeImageResourceBuildItem (io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem)3 List (java.util.List)3 BuildProducer (io.quarkus.deployment.annotations.BuildProducer)2 CombinedIndexBuildItem (io.quarkus.deployment.builditem.CombinedIndexBuildItem)2 NativeImageProxyDefinitionBuildItem (io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem)2 Collectors (java.util.stream.Collectors)2 XMLEventFactory (javax.xml.stream.XMLEventFactory)2 XMLInputFactory (javax.xml.stream.XMLInputFactory)2 XMLOutputFactory (javax.xml.stream.XMLOutputFactory)2 VerifierFactoryLoader (com.ctc.wstx.shaded.msv.org_isorelax.verifier.VerifierFactoryLoader)1 DatatypeLibraryFactory (com.ctc.wstx.shaded.msv.relaxng_datatype.DatatypeLibraryFactory)1 JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 ObjectCodec (com.fasterxml.jackson.core.ObjectCodec)1 SdkBuildTimeConfig (io.quarkus.amazon.common.runtime.SdkBuildTimeConfig)1 SyncClientType (io.quarkus.amazon.common.runtime.SyncHttpClientBuildTimeConfig.SyncClientType)1