REST endpoint framework implementing Jakarta REST and more for Quarkus applications.
npx @tessl/cli install tessl/maven-io-quarkus--quarkus-resteasy@3.23.0RESTEasy Classic extension for Quarkus that provides Jakarta REST (JAX-RS) support with integration to Quarkus's reactive architecture through Vert.x HTTP. This extension enables developers to build REST endpoints with minimal configuration while maintaining fast startup times and low memory footprint optimized for cloud-native applications.
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>Standard Jakarta REST annotations and Quarkus integration classes:
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.*;
import jakarta.ws.rs.ext.*;
import jakarta.servlet.http.*;
import io.quarkus.resteasy.runtime.*;
import io.quarkus.resteasy.runtime.standalone.*;
import io.quarkus.resteasy.runtime.vertx.*;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.ext.web.RoutingContext;
import org.jboss.resteasy.spi.AsyncMessageBodyWriter;
import org.jboss.resteasy.spi.AsyncOutputStream;Create a simple REST endpoint using Jakarta REST annotations:
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
@Path("/hello")
public class HelloResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "Hello, World!";
}
@GET
@Path("/{name}")
@Produces(MediaType.TEXT_PLAIN)
public String helloName(@PathParam("name") String name) {
return "Hello, " + name + "!";
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createEntity(String jsonData) {
// Process JSON data
return Response.status(201).entity("Created").build();
}
}Using Vert.x integration for JSON handling:
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
@Path("/api")
public class ApiResource {
@POST
@Path("/data")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public JsonObject processData(JsonObject input) {
// Direct Vert.x JsonObject usage
return new JsonObject()
.put("status", "processed")
.put("input", input);
}
@GET
@Path("/items")
@Produces(MediaType.APPLICATION_JSON)
public JsonArray getItems() {
return new JsonArray()
.add("item1")
.add("item2")
.add("item3");
}
}The extension integrates RESTEasy with Quarkus's reactive architecture:
Key components include security filters, exception mappers, JSON message body readers/writers, and configuration interfaces that work together to provide a complete REST framework.
Configure RESTEasy Vert.x integration settings.
@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED)
@ConfigMapping(prefix = "quarkus.resteasy.vertx")
public interface ResteasyVertxConfig {
@WithDefault("8191")
int responseBufferSize();
}Configuration properties:
quarkus.resteasy.vertx.response-buffer-size: Output stream response buffer size (default: 8191)Annotation for REST path template interception and processing.
@Inherited
@InterceptorBinding
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface QuarkusRestPathTemplate {
@Nonbinding String value() default "";
}Used with interceptor for metrics and observability:
@QuarkusRestPathTemplate
@Interceptor
@Priority(Interceptor.Priority.LIBRARY_BEFORE)
public class QuarkusRestPathTemplateInterceptor {
// Processes path templates for monitoring integration
}JAX-RS permission checker for endpoint security.
@ApplicationScoped
public class JaxRsPermissionChecker {
public boolean shouldRunPermissionChecks();
public boolean applyPermissionChecks(MethodDescription method);
public MethodDescription getMethodSecuredWithAuthZPolicy(
MethodDescription method, MethodDescription fallback);
}Security filters for request processing:
@Provider
@Priority(Priorities.AUTHENTICATION)
public class EagerSecurityFilter implements ContainerRequestFilter {
// Performs security checks early in request processing
}
@Provider
@Priority(Priorities.AUTHENTICATION + 1)
public class SecurityContextFilter implements ContainerRequestFilter {
// Manages security context during request processing
}Security interceptor for method-level checks:
@Interceptor
@Priority(Interceptor.Priority.PLATFORM_BEFORE + 1)
public class StandardSecurityCheckInterceptor {
// Applies standard security checks to JAX-RS methods
}Built-in exception mappers for common security scenarios.
@Provider
public class AuthenticationRedirectExceptionMapper
implements ExceptionMapper<AuthenticationRedirectException> {
public Response toResponse(AuthenticationRedirectException exception);
}
@Provider
public class AuthenticationFailedExceptionMapper
implements ExceptionMapper<AuthenticationFailedException> {
public Response toResponse(AuthenticationFailedException exception);
}
@Provider
public class AuthenticationCompletionExceptionMapper
implements ExceptionMapper<AuthenticationCompletionException> {
public Response toResponse(AuthenticationCompletionException exception);
}
@Provider
public class ForbiddenExceptionMapper
implements ExceptionMapper<ForbiddenException> {
public Response toResponse(ForbiddenException exception);
}
@Provider
public class UnauthorizedExceptionMapper
implements ExceptionMapper<UnauthorizedException> {
public Response toResponse(UnauthorizedException exception);
}Message body readers and writers for Vert.x JSON types.
@Provider
@Produces(MediaType.APPLICATION_JSON)
public class JsonObjectReader implements MessageBodyReader<JsonObject> {
public boolean isReadable(Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType);
public JsonObject readFrom(Class<JsonObject> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, String> httpHeaders,
InputStream entityStream) throws IOException, WebApplicationException;
}
@Provider
@Consumes(MediaType.APPLICATION_JSON)
public class JsonObjectWriter implements AsyncMessageBodyWriter<JsonObject> {
public boolean isWriteable(Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType);
public void writeTo(JsonObject jsonObject, Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputStream entityStream) throws IOException, WebApplicationException;
public CompletionStage<Void> asyncWriteTo(JsonObject jsonObject, Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
AsyncOutputStream entityStream);
}
@Provider
@Produces(MediaType.APPLICATION_JSON)
public class JsonArrayReader implements MessageBodyReader<JsonArray> {
public boolean isReadable(Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType);
public JsonArray readFrom(Class<JsonArray> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, String> httpHeaders,
InputStream entityStream) throws IOException, WebApplicationException;
}
@Provider
@Consumes(MediaType.APPLICATION_JSON)
public class JsonArrayWriter implements AsyncMessageBodyWriter<JsonArray> {
public boolean isWriteable(Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType);
public void writeTo(JsonArray jsonArray, Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputStream entityStream) throws IOException, WebApplicationException;
public CompletionStage<Void> asyncWriteTo(JsonArray jsonArray, Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
AsyncOutputStream entityStream);
}Utility for pushing context objects from virtual HTTP plugins.
public class ContextUtil {
public static void pushContext(RoutingContext routingContext);
}Used by AWS Lambda, Azure Functions, and similar virtual HTTP plugins to integrate with RESTEasy context management.
RESTEasy servlet and filter implementations for traditional servlet environments.
public class ResteasyServlet extends HttpServlet30Dispatcher {
/**
* Service method for handling HTTP requests in servlet environments
*/
public void service(String httpMethod, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException;
}
public class ResteasyFilter extends Filter30Dispatcher {
/**
* Filter method for intercepting requests in servlet filter chains
*/
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
FilterChain filterChain) throws IOException, ServletException;
}Additional exception mapper for composite exception handling.
@Provider
public class CompositeExceptionMapper implements ExceptionMapper<CompositeException> {
public Response toResponse(CompositeException exception);
}Complete security interceptor implementations for RBAC and authentication.
public abstract class StandardSecurityCheckInterceptor {
@Interceptor
@RolesAllowed("")
@Priority(Interceptor.Priority.LIBRARY_BEFORE)
public static class RolesAllowedInterceptor {
@AroundInvoke
public Object intercept(InvocationContext invocationContext) throws Exception;
}
@Interceptor
@PermissionsAllowed("")
@Priority(Interceptor.Priority.LIBRARY_BEFORE)
public static class PermissionsAllowedInterceptor {
@AroundInvoke
public Object intercept(InvocationContext invocationContext) throws Exception;
}
@Interceptor
@PermitAll
@Priority(Interceptor.Priority.LIBRARY_BEFORE)
public static class PermitAllInterceptor {
@AroundInvoke
public Object intercept(InvocationContext invocationContext) throws Exception;
}
@Interceptor
@Authenticated
@Priority(Interceptor.Priority.LIBRARY_BEFORE)
public static class AuthenticatedInterceptor {
@AroundInvoke
public Object intercept(InvocationContext invocationContext) throws Exception;
}
}Core components for standalone (non-servlet) RESTEasy deployment.
@Recorder
public class ResteasyStandaloneRecorder {
public RuntimeValue<Deployment> staticInit(ResteasyDeployment dep, String path);
public void start(ShutdownContext shutdown, boolean isVirtual);
public Handler<RoutingContext> vertxRequestHandler(RuntimeValue<Deployment> deployment,
String rootPath);
public Handler<FailureRoutingContext> vertxFailureHandler(RuntimeValue<Deployment> deployment,
String rootPath);
public Handler<RoutingContext> defaultAuthFailureHandler();
}
public class VertxRequestHandler implements Handler<RoutingContext> {
public void handle(RoutingContext request);
}
public class VertxHttpRequest extends BaseHttpRequest {
// HTTP request abstraction for Vert.x integration
}
public class VertxHttpResponse implements HttpResponse {
// HTTP response implementation for Vert.x integration
}Utilities for efficient streaming and buffer management in Vert.x integration.
public interface BufferAllocator {
ByteBuf allocateBuffer();
ByteBuf allocateBuffer(boolean direct);
ByteBuf allocateBuffer(int bufferSize);
ByteBuf allocateBuffer(boolean direct, int bufferSize);
int getBufferSize();
}
public interface VertxOutput {
void write(ByteBuf data, boolean last) throws IOException;
CompletableFuture<Void> writeNonBlocking(ByteBuf data, boolean last);
}
public class VertxBlockingOutput implements VertxOutput {
public void write(ByteBuf data, boolean last) throws IOException;
public CompletableFuture<Void> writeNonBlocking(ByteBuf data, boolean last);
}
public class VertxOutputStream extends AsyncOutputStream {
// Standard OutputStream methods plus async variants for Vert.x integration
}Additional utility classes for RESTEasy integration.
public class NonJaxRsClassMappings {
public String getBasePath();
public void setBasePath(String basePath);
public Map<String, String> getMethodNameToPath();
public void setMethodNameToPath(Map<String, String> methodNameToPath);
}
public class VertxUtil {
public static UriInfo extractUriInfo(HttpServerRequest req, String contextPath);
public static HttpHeaders extractHttpHeaders(HttpServerRequest request);
public static List<MediaType> extractAccepts(MultivaluedMap<String, String> requestHeaders);
public static List<Locale> extractLanguages(MultivaluedMap<String, String> requestHeaders);
public static MultivaluedMap<String, String> extractRequestHeaders(HttpServerRequest request);
}
public class RequestDispatcher {
public SynchronousDispatcher getDispatcher();
public String getDomain();
public ResteasyProviderFactory getProviderFactory();
public void service(Context context, HttpServerRequest req, HttpServerResponse resp,
HttpRequest vertxReq, HttpResponse vertxResp, boolean handleNotFound,
Throwable throwable);
}Security context implementation for RESTEasy integration.
public class QuarkusResteasySecurityContext implements SecurityContext {
public Principal getUserPrincipal();
public boolean isUserInRole(String role);
public boolean isSecure();
public String getAuthenticationScheme();
}Bridge between MicroProfile Config and RESTEasy configuration.
public class ResteasyConfigurationMPConfig implements ResteasyConfiguration {
public String getParameter(String name);
public Enumeration<String> getParameterNames();
public String getInitParameter(String name);
public Enumeration<String> getInitParameterNames();
}Essential interfaces used throughout the extension.
public interface AsyncMessageBodyWriter<T> extends MessageBodyWriter<T> {
CompletionStage<Void> asyncWriteTo(T t, Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
AsyncOutputStream entityStream);
}The extension provides these Quarkus capabilities:
io.quarkus.rest: General REST capabilityio.quarkus.resteasy: RESTEasy-specific capabilityConfiguration prefix: quarkus.resteasy.*
Extension metadata:
Core dependencies provided by the extension:
The extension supports standard JAX-RS extension mechanisms:
ExceptionMapper implementationsContainerRequestFilter and ContainerResponseFilter implementationsMessageBodyReader and MessageBodyWriter implementations@Interceptor and @InterceptorBindingCreate standard Jakarta REST resources using familiar annotations:
@Path - Define resource paths@GET, @POST, @PUT, @DELETE - HTTP methods@Produces, @Consumes - Media types@PathParam, @QueryParam, @FormParam - Parameter bindingLeverage Quarkus Security for declarative security:
@RolesAllowed, @PermitAll, @DenyAll - Role-based access control@Authenticated - Require authenticationquarkus.http.auth.* configurationUse Vert.x types directly in JAX-RS methods for reactive processing:
JsonObject and JsonArray for JSON handlingThis extension serves as the foundation for building REST APIs in Quarkus applications, providing seamless integration between RESTEasy and Quarkus's reactive, cloud-native architecture.