io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem Java Examples
The following examples show how to use
io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem.
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 File: ConfigBuildSteps.java From quarkus with Apache License 2.0 | 6 votes |
@BuildStep void nativeServiceProviders( final BuildProducer<ServiceProviderBuildItem> providerProducer) throws IOException { providerProducer.produce(new ServiceProviderBuildItem(ConfigProviderResolver.class.getName(), SmallRyeConfigProviderResolver.class.getName())); final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); classLoader.getResources(SERVICES_PREFIX + ConfigSourceProvider.class.getName()); for (Class<?> serviceClass : Arrays.asList( ConfigSource.class, ConfigSourceProvider.class, Converter.class)) { final String serviceName = serviceClass.getName(); final Set<String> names = ServiceUtil.classNamesNamedIn(classLoader, SERVICES_PREFIX + serviceName); final List<String> list = names.stream() // todo: see https://github.com/quarkusio/quarkus/issues/5492 .filter(s -> !s.startsWith("org.jboss.resteasy.microprofile.config.")).collect(Collectors.toList()); if (!list.isEmpty()) { providerProducer.produce(new ServiceProviderBuildItem(serviceName, list)); } } }
Example #2
Source File: DeploymentProcessor.java From camel-k-runtime with Apache License 2.0 | 6 votes |
@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 #3
Source File: VertxHttpProcessor.java From quarkus with Apache License 2.0 | 5 votes |
/** * Register the {@link ExchangeAttributeBuilder} services for native image consumption * * @param exchangeAttributeBuilderService * @throws BuildException */ @BuildStep void registerExchangeAttributeBuilders(final BuildProducer<ServiceProviderBuildItem> exchangeAttributeBuilderService) throws BuildException { // get hold of the META-INF/services/io.quarkus.vertx.http.runtime.attribute.ExchangeAttributeBuilder // from within the jar containing the ExchangeAttributeBuilder class final CodeSource codeSource = ExchangeAttributeBuilder.class.getProtectionDomain().getCodeSource(); if (codeSource == null) { logger.debug("Skipping registration of service providers for " + ExchangeAttributeBuilder.class); return; } try (final FileSystem jarFileSystem = ZipUtils.newFileSystem(codeSource.getLocation().toURI(), Collections.emptyMap())) { final Path serviceDescriptorFilePath = jarFileSystem.getPath("META-INF", "services", "io.quarkus.vertx.http.runtime.attribute.ExchangeAttributeBuilder"); if (!Files.exists(serviceDescriptorFilePath)) { logger.debug("Skipping registration of service providers for " + ExchangeAttributeBuilder.class + " since no service descriptor file found"); return; } // we register all the listed providers since the access log configuration is a runtime construct // and we won't know at build time which attributes the user application will choose final ServiceProviderBuildItem serviceProviderBuildItem; serviceProviderBuildItem = ServiceProviderBuildItem.allProviders(ExchangeAttributeBuilder.class.getName(), serviceDescriptorFilePath); exchangeAttributeBuilderService.produce(serviceProviderBuildItem); } catch (IOException | URISyntaxException e) { throw new BuildException(e, Collections.emptyList()); } }
Example #4
Source File: LoggingResourceProcessor.java From quarkus with Apache License 2.0 | 5 votes |
@BuildStep void miscSetup( Consumer<RuntimeInitializedClassBuildItem> runtimeInit, Consumer<NativeImageSystemPropertyBuildItem> systemProp, Consumer<ServiceProviderBuildItem> provider) { runtimeInit.accept(new RuntimeInitializedClassBuildItem("org.jboss.logmanager.formatters.TrueColorHolder")); systemProp .accept(new NativeImageSystemPropertyBuildItem("java.util.logging.manager", "org.jboss.logmanager.LogManager")); provider.accept( new ServiceProviderBuildItem(EmbeddedConfigurator.class.getName(), InitialConfigurator.class.getName())); }
Example #5
Source File: SmallRyeReactiveStreamsOperatorsProcessor.java From quarkus with Apache License 2.0 | 5 votes |
@BuildStep public void build(BuildProducer<ServiceProviderBuildItem> serviceProvider, BuildProducer<FeatureBuildItem> feature) { feature.produce(new FeatureBuildItem(Feature.SMALLRYE_REACTIVE_STREAMS_OPERATORS)); serviceProvider.produce(new ServiceProviderBuildItem(ReactiveStreamsEngine.class.getName(), Engine.class.getName())); serviceProvider.produce(new ServiceProviderBuildItem(ReactiveStreamsFactory.class.getName(), ReactiveStreamsFactoryImpl.class.getName())); }
Example #6
Source File: MutinyReactiveStreamsOperatorsProcessor.java From quarkus with Apache License 2.0 | 5 votes |
@BuildStep public void build(BuildProducer<ServiceProviderBuildItem> serviceProvider) { serviceProvider .produce(new ServiceProviderBuildItem(ReactiveStreamsEngine.class.getName(), Engine.class.getName())); serviceProvider.produce(new ServiceProviderBuildItem(ReactiveStreamsFactory.class.getName(), ReactiveStreamsFactoryImpl.class.getName())); }
Example #7
Source File: SmallRyeReactiveTypeConvertersProcessor.java From quarkus with Apache License 2.0 | 5 votes |
@BuildStep public void build(BuildProducer<ServiceProviderBuildItem> serviceProvider, BuildProducer<FeatureBuildItem> feature, CombinedIndexBuildItem indexBuildItem) { feature.produce(new FeatureBuildItem(Feature.SMALLRYE_REACTIVE_TYPE_CONVERTERS)); Collection<ClassInfo> implementors = indexBuildItem.getIndex().getAllKnownImplementors(REACTIVE_TYPE_CONVERTER); implementors.forEach(info -> serviceProvider .produce(new ServiceProviderBuildItem(REACTIVE_TYPE_CONVERTER.toString(), info.toString()))); }
Example #8
Source File: TikaProcessor.java From quarkus with Apache License 2.0 | 5 votes |
@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); }
Example #9
Source File: PahoProcessor.java From camel-quarkus with Apache License 2.0 | 5 votes |
@BuildStep ServiceProviderBuildItem registerServiceProviders() { return new ServiceProviderBuildItem( NetworkModuleFactory.class.getName(), org.eclipse.paho.client.mqttv3.internal.TCPNetworkModuleFactory.class.getName(), org.eclipse.paho.client.mqttv3.internal.SSLNetworkModuleFactory.class.getName(), org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketNetworkModuleFactory.class.getName(), org.eclipse.paho.client.mqttv3.internal.websocket.WebSocketSecureNetworkModuleFactory.class.getName()); }
Example #10
Source File: JaxbProcessor.java From quarkus with Apache License 2.0 | 5 votes |
@BuildStep void registerClasses( BuildProducer<NativeImageSystemPropertyBuildItem> nativeImageProps, BuildProducer<ServiceProviderBuildItem> providerItem) { addReflectiveClass(false, false, "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"); addReflectiveClass(false, false, "com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl"); addReflectiveClass(false, false, "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"); addReflectiveClass(false, false, "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"); addReflectiveClass(true, false, "com.sun.xml.bind.v2.ContextFactory"); addReflectiveClass(true, false, "com.sun.xml.internal.bind.v2.ContextFactory"); addReflectiveClass(true, false, "com.sun.xml.internal.stream.XMLInputFactoryImpl"); addReflectiveClass(true, false, "com.sun.xml.internal.stream.XMLOutputFactoryImpl"); addReflectiveClass(true, false, "com.sun.org.apache.xpath.internal.functions.FuncNot"); addReflectiveClass(true, false, "com.sun.org.apache.xerces.internal.impl.dv.xs.SchemaDVFactoryImpl"); addResourceBundle("javax.xml.bind.Messages"); addResourceBundle("javax.xml.bind.helpers.Messages"); addResourceBundle("com.sun.org.apache.xml.internal.serializer.utils.SerializerMessages"); addResourceBundle("com.sun.org.apache.xml.internal.res.XMLErrorResources"); addResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLMessages"); addResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages"); addResourceBundle("com.sun.org.apache.xerces.internal.impl.xpath.regex.message"); nativeImageProps .produce(new NativeImageSystemPropertyBuildItem("com.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize", "true")); JAXB_REFLECTIVE_CLASSES.stream() .map(Class::getName) .forEach(className -> addReflectiveClass(true, false, className)); JAXB_SERIALIZERS.stream() .map(s -> "com/sun/org/apache/xml/internal/serializer/output_" + s + ".properties") .forEach(this::addResource); providerItem .produce(new ServiceProviderBuildItem(JAXBContext.class.getName(), "com.sun.xml.bind.v2.ContextFactory")); }
Example #11
Source File: SmallRyeGraphQLProcessor.java From quarkus with Apache License 2.0 | 5 votes |
@BuildStep void registerNativeImageResources(BuildProducer<ServiceProviderBuildItem> serviceProvider) throws IOException { // Lookup Service (We use the one from the CDI Module) String lookupService = SPI_PATH + LookupService.class.getName(); Set<String> lookupImplementations = ServiceUtil.classNamesNamedIn(Thread.currentThread().getContextClassLoader(), lookupService); serviceProvider.produce( new ServiceProviderBuildItem(LookupService.class.getName(), lookupImplementations.toArray(new String[0]))); }
Example #12
Source File: KeycloakReflectionBuildStep.java From quarkus with Apache License 2.0 | 5 votes |
@BuildStep public void registerServiceProviders(BuildProducer<ServiceProviderBuildItem> serviceProvider) { serviceProvider.produce(new ServiceProviderBuildItem(ClientCredentialsProvider.class.getName(), ClientIdAndSecretCredentialsProvider.class.getName(), JWTClientCredentialsProvider.class.getName(), JWTClientSecretCredentialsProvider.class.getName())); serviceProvider.produce(new ServiceProviderBuildItem(ClaimInformationPointProviderFactory.class.getName(), HttpClaimInformationPointProviderFactory.class.getName(), ClaimsInformationPointProviderFactory.class.getName())); }
Example #13
Source File: JsonbProcessor.java From quarkus with Apache License 2.0 | 5 votes |
@BuildStep void build(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, BuildProducer<NativeImageResourceBundleBuildItem> resourceBundle, BuildProducer<ServiceProviderBuildItem> serviceProvider, BuildProducer<AdditionalBeanBuildItem> additionalBeans, CombinedIndexBuildItem combinedIndexBuildItem) { reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, JsonBindingProvider.class.getName())); resourceBundle.produce(new NativeImageResourceBundleBuildItem("yasson-messages")); serviceProvider.produce(new ServiceProviderBuildItem(JsonbComponentInstanceCreator.class.getName(), QuarkusJsonbComponentInstanceCreator.class.getName())); // this needs to be registered manually since the runtime module is not indexed by Jandex additionalBeans.produce(new AdditionalBeanBuildItem(JsonbProducer.class)); IndexView index = combinedIndexBuildItem.getIndex(); // handle the various @JsonSerialize cases for (AnnotationInstance serializeInstance : index.getAnnotations(JSONB_TYPE_SERIALIZER)) { registerInstance(reflectiveClass, serializeInstance); } // handle the various @JsonDeserialize cases for (AnnotationInstance deserializeInstance : index.getAnnotations(JSONB_TYPE_DESERIALIZER)) { registerInstance(reflectiveClass, deserializeInstance); } }
Example #14
Source File: AwsCommonsProcessor.java From camel-quarkus with Apache License 2.0 | 5 votes |
@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 #15
Source File: JaxbProcessor.java From quarkus with Apache License 2.0 | 4 votes |
@BuildStep void processAnnotationsAndIndexFiles( BuildProducer<NativeImageSystemPropertyBuildItem> nativeImageProps, BuildProducer<ServiceProviderBuildItem> providerItem, BuildProducer<NativeImageProxyDefinitionBuildItem> proxyDefinitions, CombinedIndexBuildItem combinedIndexBuildItem, List<JaxbFileRootBuildItem> fileRoots) { IndexView index = combinedIndexBuildItem.getIndex(); // Register classes for reflection based on JAXB annotations boolean jaxbRootAnnotationsDetected = false; for (DotName jaxbRootAnnotation : JAXB_ROOT_ANNOTATIONS) { for (AnnotationInstance jaxbRootAnnotationInstance : index .getAnnotations(jaxbRootAnnotation)) { if (jaxbRootAnnotationInstance.target().kind() == Kind.CLASS) { addReflectiveClass(true, true, jaxbRootAnnotationInstance.target().asClass().name().toString()); jaxbRootAnnotationsDetected = true; } } } if (!jaxbRootAnnotationsDetected && fileRoots.isEmpty()) { return; } // Register package-infos for reflection for (AnnotationInstance xmlSchemaInstance : index.getAnnotations(XML_SCHEMA)) { if (xmlSchemaInstance.target().kind() == Kind.CLASS) { reflectiveClass.produce( new ReflectiveClassBuildItem(false, false, xmlSchemaInstance.target().asClass().name().toString())); } } // Register XML Java type adapters for reflection for (AnnotationInstance xmlJavaTypeAdapterInstance : index.getAnnotations(XML_JAVA_TYPE_ADAPTER)) { reflectiveClass.produce( new ReflectiveClassBuildItem(true, true, xmlJavaTypeAdapterInstance.value().asClass().name().toString())); } if (!index.getAnnotations(XML_ANY_ELEMENT).isEmpty()) { addReflectiveClass(false, false, "javax.xml.bind.annotation.W3CDomHandler"); } JAXB_ANNOTATIONS.stream() .map(Class::getName) .forEach(className -> { proxyDefinitions.produce(new NativeImageProxyDefinitionBuildItem(className, Locatable.class.getName())); addReflectiveClass(true, false, className); }); for (JaxbFileRootBuildItem i : fileRoots) { try (Stream<Path> stream = iterateResources(i.getFileRoot())) { stream.filter(p -> p.getFileName().toString().equals("jaxb.index")) .forEach(this::handleJaxbFile); } } }
Example #16
Source File: UndertowWebsocketProcessor.java From quarkus with Apache License 2.0 | 4 votes |
@BuildStep ServiceProviderBuildItem registerConfiguratorServiceProvider() { return new ServiceProviderBuildItem(ServerEndpointConfig.Configurator.class.getName(), DefaultContainerConfigurator.class.getName()); }
Example #17
Source File: UndertowWebsocketProcessor.java From quarkus with Apache License 2.0 | 4 votes |
@BuildStep ServiceProviderBuildItem registerContainerProviderService() { return new ServiceProviderBuildItem(ContainerProvider.class.getName(), UndertowContainerProvider.class.getName()); }
Example #18
Source File: AmazonServicesClientsProcessor.java From quarkus with Apache License 2.0 | 4 votes |
@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(interceptorClass -> { if (!knownInterceptorImpls.contains(interceptorClass.getName())) { throw new ConfigurationError( 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 only clients that are used if (syncTransportNeeded) { if (amazonClients.stream().filter(isSyncApache).findAny().isPresent()) { checkClasspath(APACHE_HTTP_SERVICE, "apache-client"); //Register Apache client as sync client proxyDefinition .produce(new NativeImageProxyDefinitionBuildItem("org.apache.http.conn.HttpClientConnectionManager", "org.apache.http.pool.ConnPoolControl", "software.amazon.awssdk.http.apache.internal.conn.Wrapped")); serviceProvider.produce( new ServiceProviderBuildItem(SdkHttpService.class.getName(), APACHE_HTTP_SERVICE)); } else { checkClasspath(URL_HTTP_SERVICE, "url-connection-client"); serviceProvider.produce(new ServiceProviderBuildItem(SdkHttpService.class.getName(), URL_HTTP_SERVICE)); } } if (asyncTransportNeeded) { checkClasspath(NETTY_HTTP_SERVICE, "netty-nio-client"); //Register netty as async client serviceProvider.produce( new ServiceProviderBuildItem(SdkAsyncHttpService.class.getName(), NETTY_HTTP_SERVICE)); } }
Example #19
Source File: QuteProcessor.java From quarkus with Apache License 2.0 | 4 votes |
@BuildStep ServiceProviderBuildItem registerPublisherFactory() { return new ServiceProviderBuildItem(PublisherFactory.class.getName(), MutinyPublisherFactory.class.getName()); }