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);
}
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");
}
}
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));
}
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);
}
});
}
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);
}
});
}
Aggregations