Search in sources :

Example 1 with ResteasyJaxrsProviderBuildItem

use of io.quarkus.resteasy.common.spi.ResteasyJaxrsProviderBuildItem in project quarkus by quarkusio.

the class SpringDataRestProcessor method registerRestDataPanacheExceptionMapper.

@BuildStep
void registerRestDataPanacheExceptionMapper(BuildProducer<ResteasyJaxrsProviderBuildItem> resteasyJaxrsProviderBuildItemBuildProducer, BuildProducer<ExceptionMapperBuildItem> exceptionMapperBuildItemBuildProducer) {
    resteasyJaxrsProviderBuildItemBuildProducer.produce(new ResteasyJaxrsProviderBuildItem(RestDataPanacheExceptionMapper.class.getName()));
    exceptionMapperBuildItemBuildProducer.produce(new ExceptionMapperBuildItem(RestDataPanacheExceptionMapper.class.getName(), RestDataPanacheException.class.getName(), Priorities.USER + 100, false));
}
Also used : ExceptionMapperBuildItem(io.quarkus.resteasy.reactive.spi.ExceptionMapperBuildItem) ResteasyJaxrsProviderBuildItem(io.quarkus.resteasy.common.spi.ResteasyJaxrsProviderBuildItem) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 2 with ResteasyJaxrsProviderBuildItem

use of io.quarkus.resteasy.common.spi.ResteasyJaxrsProviderBuildItem in project quarkus by quarkusio.

the class SpringWebResteasyClassicProcessor method registerProviders.

@BuildStep
public void registerProviders(BeanArchiveIndexBuildItem beanArchiveIndexBuildItem, BuildProducer<ResteasyJaxrsProviderBuildItem> providersProducer) throws IOException {
    // TODO only read this information once since it is exactly the same in ResteasyCommonProcessor#setupProviders
    final Set<String> availableProviders = ServiceUtil.classNamesNamedIn(getClass().getClassLoader(), "META-INF/services/" + Providers.class.getName());
    final MediaTypeMap<String> categorizedReaders = new MediaTypeMap<>();
    final MediaTypeMap<String> categorizedWriters = new MediaTypeMap<>();
    final MediaTypeMap<String> categorizedContextResolvers = new MediaTypeMap<>();
    final Set<String> otherProviders = new HashSet<>();
    ResteasyCommonProcessor.categorizeProviders(availableProviders, categorizedReaders, categorizedWriters, categorizedContextResolvers, otherProviders);
    boolean useAllAvailable = false;
    Set<String> providersToRegister = new HashSet<>();
    OUTER: for (DotName mappingClass : MAPPING_ANNOTATIONS) {
        final Collection<AnnotationInstance> instances = beanArchiveIndexBuildItem.getIndex().getAnnotations(mappingClass);
        for (AnnotationInstance instance : instances) {
            if (collectProviders(providersToRegister, categorizedWriters, instance, "produces")) {
                useAllAvailable = true;
                break OUTER;
            }
            if (collectProviders(providersToRegister, categorizedContextResolvers, instance, "produces")) {
                useAllAvailable = true;
                break OUTER;
            }
            if (collectProviders(providersToRegister, categorizedReaders, instance, "consumes")) {
                useAllAvailable = true;
                break OUTER;
            }
        }
    }
    if (useAllAvailable) {
        providersToRegister = availableProviders;
    } else {
        // for Spring Web we register all the json providers by default because using "produces" in @RequestMapping
        // and friends is optional
        providersToRegister.addAll(categorizedWriters.getPossible(MediaType.APPLICATION_JSON_TYPE));
        // we also need to register the custom Spring related providers
        providersToRegister.add(ResponseEntityFeature.class.getName());
        providersToRegister.add(ResponseStatusFeature.class.getName());
    }
    for (String provider : providersToRegister) {
        providersProducer.produce(new ResteasyJaxrsProviderBuildItem(provider));
    }
}
Also used : MediaTypeMap(org.jboss.resteasy.core.MediaTypeMap) ResteasyJaxrsProviderBuildItem(io.quarkus.resteasy.common.spi.ResteasyJaxrsProviderBuildItem) Collection(java.util.Collection) DotName(org.jboss.jandex.DotName) AnnotationInstance(org.jboss.jandex.AnnotationInstance) ResponseEntityFeature(org.jboss.resteasy.spring.web.ResponseEntityFeature) HashSet(java.util.HashSet) ResponseStatusFeature(org.jboss.resteasy.spring.web.ResponseStatusFeature) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 3 with ResteasyJaxrsProviderBuildItem

use of io.quarkus.resteasy.common.spi.ResteasyJaxrsProviderBuildItem in project quarkus by quarkusio.

the class SpringWebProcessor method generateMappersForResponseStatusOnException.

private void generateMappersForResponseStatusOnException(BuildProducer<ResteasyJaxrsProviderBuildItem> providersProducer, BuildProducer<ExceptionMapperBuildItem> exceptionMapperProducer, IndexView index, ClassOutput classOutput, TypesUtil typesUtil, boolean isResteasyClassic) {
    Collection<AnnotationInstance> responseStatusInstances = index.getAnnotations(RESPONSE_STATUS);
    if (responseStatusInstances.isEmpty()) {
        return;
    }
    for (AnnotationInstance instance : responseStatusInstances) {
        if (AnnotationTarget.Kind.CLASS != instance.target().kind()) {
            continue;
        }
        DotName dotName = instance.target().asClass().name();
        if (!typesUtil.isAssignable(Exception.class, dotName)) {
            continue;
        }
        String name = new ResponseStatusOnExceptionGenerator(instance.target().asClass(), classOutput, isResteasyClassic).generate();
        providersProducer.produce(new ResteasyJaxrsProviderBuildItem(name));
        exceptionMapperProducer.produce(new ExceptionMapperBuildItem(name, dotName.toString(), Priorities.USER, false));
    }
}
Also used : ExceptionMapperBuildItem(io.quarkus.resteasy.reactive.spi.ExceptionMapperBuildItem) ResteasyJaxrsProviderBuildItem(io.quarkus.resteasy.common.spi.ResteasyJaxrsProviderBuildItem) DotName(org.jboss.jandex.DotName) AnnotationInstance(org.jboss.jandex.AnnotationInstance)

Example 4 with ResteasyJaxrsProviderBuildItem

use of io.quarkus.resteasy.common.spi.ResteasyJaxrsProviderBuildItem in project quarkus by quarkusio.

the class SmallRyeOpenTracingProcessor method setupFilter.

@BuildStep
void setupFilter(BuildProducer<AdditionalBeanBuildItem> additionalBeans, BuildProducer<ResteasyJaxrsProviderBuildItem> providers, BuildProducer<FilterBuildItem> filterProducer, BuildProducer<FeatureBuildItem> feature, BuildProducer<CustomContainerResponseFilterBuildItem> customResponseFilters, BuildProducer<DynamicFeatureBuildItem> dynamicFeatures, BuildProducer<WriterInterceptorBuildItem> writerInterceptors, Capabilities capabilities) {
    feature.produce(new FeatureBuildItem(Feature.SMALLRYE_OPENTRACING));
    additionalBeans.produce(new AdditionalBeanBuildItem(QuarkusSmallRyeTracingDynamicFeature.class));
    providers.produce(new ResteasyJaxrsProviderBuildItem(QuarkusSmallRyeTracingDynamicFeature.class.getName()));
    if (capabilities.isPresent(Capability.SERVLET)) {
        FilterBuildItem filterInfo = FilterBuildItem.builder("tracingFilter", SpanFinishingFilter.class.getName()).setAsyncSupported(true).addFilterUrlMapping("*", DispatcherType.FORWARD).addFilterUrlMapping("*", DispatcherType.INCLUDE).addFilterUrlMapping("*", DispatcherType.REQUEST).addFilterUrlMapping("*", DispatcherType.ASYNC).addFilterUrlMapping("*", DispatcherType.ERROR).build();
        filterProducer.produce(filterInfo);
    } else if (capabilities.isPresent(Capability.RESTEASY)) {
        providers.produce(new ResteasyJaxrsProviderBuildItem(QuarkusSmallRyeTracingStandaloneVertxDynamicFeature.class.getName()));
    } else if (capabilities.isPresent(Capability.RESTEASY_REACTIVE)) {
        customResponseFilters.produce(new CustomContainerResponseFilterBuildItem(QuarkusSmallRyeTracingStandaloneContainerResponseFilter.class.getName()));
        dynamicFeatures.produce(new DynamicFeatureBuildItem(QuarkusSmallRyeTracingDynamicFeature.class.getName()));
        writerInterceptors.produce(new WriterInterceptorBuildItem.Builder(QuarkusSmallRyeTracingStandaloneContainerResponseFilter.class.getName()).build());
    }
}
Also used : DynamicFeatureBuildItem(io.quarkus.resteasy.reactive.spi.DynamicFeatureBuildItem) FeatureBuildItem(io.quarkus.deployment.builditem.FeatureBuildItem) AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) QuarkusSmallRyeTracingStandaloneVertxDynamicFeature(io.quarkus.smallrye.opentracing.runtime.QuarkusSmallRyeTracingStandaloneVertxDynamicFeature) DynamicFeatureBuildItem(io.quarkus.resteasy.reactive.spi.DynamicFeatureBuildItem) ResteasyJaxrsProviderBuildItem(io.quarkus.resteasy.common.spi.ResteasyJaxrsProviderBuildItem) QuarkusSmallRyeTracingDynamicFeature(io.quarkus.smallrye.opentracing.runtime.QuarkusSmallRyeTracingDynamicFeature) FilterBuildItem(io.quarkus.undertow.deployment.FilterBuildItem) CustomContainerResponseFilterBuildItem(io.quarkus.resteasy.reactive.spi.CustomContainerResponseFilterBuildItem) QuarkusSmallRyeTracingStandaloneContainerResponseFilter(io.quarkus.smallrye.opentracing.runtime.QuarkusSmallRyeTracingStandaloneContainerResponseFilter) CustomContainerResponseFilterBuildItem(io.quarkus.resteasy.reactive.spi.CustomContainerResponseFilterBuildItem) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 5 with ResteasyJaxrsProviderBuildItem

use of io.quarkus.resteasy.common.spi.ResteasyJaxrsProviderBuildItem in project quarkus by quarkusio.

the class OidcTokenPropagationBuildStep method registerProvider.

@BuildStep(onlyIf = IsEnabled.class)
void registerProvider(BuildProducer<AdditionalBeanBuildItem> additionalBeans, BuildProducer<ReflectiveClassBuildItem> reflectiveClass, BuildProducer<ResteasyJaxrsProviderBuildItem> jaxrsProviders, BuildProducer<RestClientAnnotationProviderBuildItem> restAnnotationProvider) {
    additionalBeans.produce(AdditionalBeanBuildItem.unremovableOf(AccessTokenRequestFilter.class));
    additionalBeans.produce(AdditionalBeanBuildItem.unremovableOf(JsonWebTokenRequestFilter.class));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, AccessTokenRequestFilter.class));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, JsonWebTokenRequestFilter.class));
    if (config.registerFilter) {
        Class<?> filterClass = config.jsonWebToken ? JsonWebTokenRequestFilter.class : AccessTokenRequestFilter.class;
        jaxrsProviders.produce(new ResteasyJaxrsProviderBuildItem(filterClass.getName()));
    } else {
        restAnnotationProvider.produce(new RestClientAnnotationProviderBuildItem(ACCESS_TOKEN_CREDENTIAL, AccessTokenRequestFilter.class));
        restAnnotationProvider.produce(new RestClientAnnotationProviderBuildItem(JWT_ACCESS_TOKEN_CREDENTIAL, JsonWebTokenRequestFilter.class));
    }
}
Also used : AccessTokenRequestFilter(io.quarkus.oidc.token.propagation.AccessTokenRequestFilter) ResteasyJaxrsProviderBuildItem(io.quarkus.resteasy.common.spi.ResteasyJaxrsProviderBuildItem) JsonWebTokenRequestFilter(io.quarkus.oidc.token.propagation.JsonWebTokenRequestFilter) RestClientAnnotationProviderBuildItem(io.quarkus.restclient.deployment.RestClientAnnotationProviderBuildItem) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Aggregations

ResteasyJaxrsProviderBuildItem (io.quarkus.resteasy.common.spi.ResteasyJaxrsProviderBuildItem)19 BuildStep (io.quarkus.deployment.annotations.BuildStep)16 ExceptionMapperBuildItem (io.quarkus.resteasy.reactive.spi.ExceptionMapperBuildItem)5 ReflectiveClassBuildItem (io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem)4 AnnotationInstance (org.jboss.jandex.AnnotationInstance)4 DotName (org.jboss.jandex.DotName)4 AdditionalBeanBuildItem (io.quarkus.arc.deployment.AdditionalBeanBuildItem)2 UnremovableBeanBuildItem (io.quarkus.arc.deployment.UnremovableBeanBuildItem)2 Record (io.quarkus.deployment.annotations.Record)2 RestClientAnnotationProviderBuildItem (io.quarkus.restclient.deployment.RestClientAnnotationProviderBuildItem)2 CustomContainerResponseFilterBuildItem (io.quarkus.resteasy.reactive.spi.CustomContainerResponseFilterBuildItem)2 IndexView (org.jboss.jandex.IndexView)2 MethodInfo (org.jboss.jandex.MethodInfo)2 Type (org.jboss.jandex.Type)2 BeanArchiveIndexBuildItem (io.quarkus.arc.deployment.BeanArchiveIndexBuildItem)1 BeanContainerBuildItem (io.quarkus.arc.deployment.BeanContainerBuildItem)1 DotNames (io.quarkus.arc.processor.DotNames)1 Capabilities (io.quarkus.deployment.Capabilities)1 Capability (io.quarkus.deployment.Capability)1 BuildProducer (io.quarkus.deployment.annotations.BuildProducer)1