use of io.quarkus.resteasy.reactive.spi.GeneratedJaxRsResourceGizmoAdaptor in project quarkus by quarkusio.
the class RestDataProcessor method implementResources.
@BuildStep
void implementResources(CombinedIndexBuildItem index, List<RestDataResourceBuildItem> resourceBuildItems, List<ResourcePropertiesBuildItem> resourcePropertiesBuildItems, Capabilities capabilities, BuildProducer<GeneratedBeanBuildItem> resteasyClassicImplementationsProducer, BuildProducer<GeneratedJaxRsResourceBuildItem> resteasyReactiveImplementationsProducer) {
boolean isReactivePanache = capabilities.isPresent(Capability.HIBERNATE_REACTIVE);
boolean isResteasyClassic = capabilities.isPresent(Capability.RESTEASY);
if (isReactivePanache && isResteasyClassic) {
throw new IllegalStateException("Reactive REST Data Panache does not work with 'quarkus-resteasy'. Only 'quarkus-resteasy-reactive' extensions are supported");
}
ClassOutput classOutput = isResteasyClassic ? new GeneratedBeanGizmoAdaptor(resteasyClassicImplementationsProducer) : new GeneratedJaxRsResourceGizmoAdaptor(resteasyReactiveImplementationsProducer);
JaxRsResourceImplementor jaxRsResourceImplementor = new JaxRsResourceImplementor(hasValidatorCapability(capabilities), isResteasyClassic, isReactivePanache);
ResourcePropertiesProvider resourcePropertiesProvider = new ResourcePropertiesProvider(index.getIndex());
for (RestDataResourceBuildItem resourceBuildItem : resourceBuildItems) {
ResourceMetadata resourceMetadata = resourceBuildItem.getResourceMetadata();
ResourceProperties resourceProperties = getResourceProperties(resourcePropertiesProvider, resourceMetadata, resourcePropertiesBuildItems);
if (resourceProperties.isHal() && !hasHalCapability(capabilities)) {
throw new IllegalStateException("Cannot generate HAL endpoints without a RESTEasy JSON-B or Jackson capability");
}
if (resourceProperties.isExposed()) {
jaxRsResourceImplementor.implement(classOutput, resourceMetadata, resourceProperties);
}
}
}
use of io.quarkus.resteasy.reactive.spi.GeneratedJaxRsResourceGizmoAdaptor in project quarkus by quarkusio.
the class GeneratedJaxRsResourceTest method buildCustomizer.
protected static Consumer<BuildChainBuilder> buildCustomizer() {
return new Consumer<>() {
/**
* This represents the extension that generates a JAX-RS resource like:
*
* <pre>
* {@code
* @Path("/test')
* public class TestResource {
*
* @GET
* public String test() {
* return "test";
* }
* }
* }
* </pre>
*/
@Override
public void accept(BuildChainBuilder builder) {
builder.addBuildStep(context -> {
BuildProducer<GeneratedJaxRsResourceBuildItem> producer = context::produce;
ClassOutput classOutput = new GeneratedJaxRsResourceGizmoAdaptor(producer);
try (ClassCreator classCreator = ClassCreator.builder().classOutput(classOutput).className("com.example.TestResource").build()) {
classCreator.addAnnotation(Path.class).addValue("value", "test");
MethodCreator methodCreator = classCreator.getMethodCreator("test", String.class);
methodCreator.addAnnotation(GET.class);
methodCreator.returnValue(methodCreator.load("test"));
}
}).produces(GeneratedJaxRsResourceBuildItem.class).build();
}
};
}
Aggregations