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