All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkiverse.cxf.deployment.WsApiProcessor Maven / Gradle / Ivy

package io.quarkiverse.cxf.deployment;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Set;
import java.util.stream.Stream;

import org.jboss.jandex.DotName;
import org.jboss.jandex.IndexView;

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
import io.quarkus.deployment.util.ServiceUtil;

/**
 * {@link BuildStep}s related to {@code jakarta.xml.ws:jakarta.xml.ws-api}
 */
class WsApiProcessor {

    @BuildStep
    void indexDependencies(BuildProducer indexDependencies) {
        Stream.of(
                "jakarta.xml.ws:jakarta.xml.ws-api")
                .forEach(ga -> {
                    String[] coords = ga.split(":");
                    indexDependencies.produce(new IndexDependencyBuildItem(coords[0], coords[1]));
                });
    }

    @BuildStep
    void registerForReflection(BuildProducer reflectiveClass, CombinedIndexBuildItem combinedIndex) {

        final IndexView index = combinedIndex.getIndex();
        Stream.of(
                "jakarta.xml.ws.handler.Handler")
                .map(DotName::createSimple)
                .flatMap(dotName -> index.getAllKnownImplementors(dotName).stream())
                .map(classInfo -> classInfo.name().toString())
                .map(className -> ReflectiveClassBuildItem.builder(className).build())
                .forEach(reflectiveClass::produce);
    }

    @BuildStep
    void registerServices(BuildProducer serviceProvider) {
        Stream.of(
                "jakarta.xml.ws.spi.Provider")
                .forEach(serviceName -> {
                    try {
                        final Set names = ServiceUtil.classNamesNamedIn(Thread.currentThread().getContextClassLoader(),
                                ServiceProviderBuildItem.SPI_ROOT + serviceName);
                        serviceProvider.produce(new ServiceProviderBuildItem(serviceName, new ArrayList<>(names)));
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                });
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy