Class AddMethodImplementor
- java.lang.Object
-
- io.quarkus.rest.data.panache.deployment.methods.StandardMethodImplementor
-
- io.quarkus.rest.data.panache.deployment.methods.AddMethodImplementor
-
- All Implemented Interfaces:
MethodImplementor
public final class AddMethodImplementor extends StandardMethodImplementor
-
-
Field Summary
-
Fields inherited from class io.quarkus.rest.data.panache.deployment.methods.StandardMethodImplementor
responseImplementor
-
Fields inherited from interface io.quarkus.rest.data.panache.deployment.methods.MethodImplementor
APPLICATION_HAL_JSON, APPLICATION_JSON
-
-
Constructor Summary
Constructors Constructor Description AddMethodImplementor(boolean withValidation, boolean isResteasyClassic, boolean isReactivePanache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringgetResourceMethodName()Get a name of a method which this controller uses to access data.protected voidimplementInternal(io.quarkus.gizmo.ClassCreator classCreator, ResourceMetadata resourceMetadata, ResourceProperties resourceProperties, io.quarkus.gizmo.FieldDescriptor resourceField)Generate JAX-RS POST method.-
Methods inherited from class io.quarkus.rest.data.panache.deployment.methods.StandardMethodImplementor
addConsumesAnnotation, addContextAnnotation, addDefaultValueAnnotation, addDeleteAnnotation, addGetAnnotation, addLinksAnnotation, addPathAnnotation, addPathParamAnnotation, addPostAnnotation, addProducesAnnotation, addProducesJsonAnnotation, addPutAnnotation, addQueryParamAnnotation, addSortQueryParamValidatorAnnotation, appendToPath, implement, implementTryBlock, isNotReactivePanache, isResteasyClassic
-
-
-
-
Method Detail
-
implementInternal
protected void implementInternal(io.quarkus.gizmo.ClassCreator classCreator, ResourceMetadata resourceMetadata, ResourceProperties resourceProperties, io.quarkus.gizmo.FieldDescriptor resourceField)Generate JAX-RS POST method. The RESTEasy Classic version exposesRestDataResource.add(Object). Generated code looks more or less like this:
The RESTEasy Reactive version exposes@POST @Path("") @Consumes({"application/json"}) @Produces({"application/json"}) @LinkResource( rel = "add", entityClassName = "com.example.Entity" ) public Response add(Entity entityToSave) { try { Entity entity = restDataResource.add(entityToSave); String location = new ResourceLinksProvider().getSelfLink(entity); if (location != null) { ResponseBuilder responseBuilder = Response.status(201); responseBuilder.entity(entity); responseBuilder.location(URI.create(location)); return responseBuilder.build(); } else { throw new RuntimeException("Could not extract a new entity URL") } } catch (Throwable t) { throw new RestDataPanacheException(t); } }ReactiveRestDataResource.add(Object)and the generated code looks more or less like this:@POST @Path("") @Consumes({"application/json"}) @Produces({"application/json"}) @LinkResource( rel = "add", entityClassName = "com.example.Entity" ) public Uni<Response> add(Entity entityToSave) { return restDataResource.add(entityToSave).map(entity -> { String location = new ResourceLinksProvider().getSelfLink(entity); if (location != null) { ResponseBuilder responseBuilder = Response.status(201); responseBuilder.entity(entity); responseBuilder.location(URI.create(location)); return responseBuilder.build(); } else { throw new RuntimeException("Could not extract a new entity URL") } }).onFailure().invoke(t -> throw new RestDataPanacheException(t)); }- Specified by:
implementInternalin classStandardMethodImplementor
-
getResourceMethodName
protected String getResourceMethodName()
Description copied from class:StandardMethodImplementorGet a name of a method which this controller uses to access data.- Specified by:
getResourceMethodNamein classStandardMethodImplementor
-
-