Home » JAX-RS

Tag Archives: JAX-RS

For gourmets and practioners: pick your flavour of the reactive stack with JAX-RS and Apache CXF

java-interview-questions-answers

When JAX-RS 2.1 specification was released back in 2017, one of its true novelties was the introduction of the reactive API extensions. The industry has acknowledged the importance of the modern programming paradigms and specification essentially mandated the first-class support of the asynchronous and reactive programming for the Client API. But what about the server side? It was not left ...

Read More »

Converting JAX-RS parameters with ParamConverters

java-interview-questions-answers

If you want JAX-RS to automatically convert parameters such as query params, path params, or others, you need to create a ParamConverter. Primitive types, strings, and types who define certain conversion methods, such as a valueOf(String) method, are automatically converted. Here’s how to define a converter for LocalDates. One gotcha I ran into a few times — besides the fact ...

Read More »

RESTful services with HATEOAS: REST APIs and Hypermedia on JVM

java-interview-questions-answers

1. Introduction So far we have spent a fair amount of time talking about the role of the hypermedia and HATEOAS in the RESTful web services and APIs, glancing over different specifications and usability aspects. It sounded like supporting hypermedia and HATEOAS is not that difficult, just pick you favorites and you are good to go! As you may guess, ...

Read More »

Quickly creating URIs with UriBuilder

java-interview-questions-answers

If you have access to the JAX-RS API and an implementation in your projects (many do), then you can use JAX-RS’ UriBuilder to conveniently create URIs via builder pattern using resolvable placeholder. Have a look at the following example: 1 2 3 4 5 6 7 String host = System.getProperty("host", "localhost"); String port = System.getProperty("port", "8080");   URI uri = ...

Read More »

The Hypermedia APIs support in JAX-RS and OpenAPI: a long way to go

Sooner or later, most of the developers who actively work on REST(ful) web services and APIs stumble upon this truly extraterrestrial thing called HATEOAS: Hypertext As The Engine Of Application State. The curiosity of what HATEOAS is and how it relates to REST would eventually lead to discovery of the Richardson Maturity Model which demystifies the industry definitions of REST ...

Read More »

A configurable JAX-RS ExceptionMapper with MicroProfile Config

java-interview-questions-answers

When you create REST services with JAX-RS, you typically either return nothing (so HTTP 201/2/4 etc) or some data, potentially in JSON format (so HTTP 200), or some Exception / Error (so HTTP 4xx or 5xx). We usually translate a Runtime Exception into some HTTP 5xx and a Checked Exception into some 4xx. Because we want to keep our boundary ...

Read More »

Speed Up Services With Reactive API in Java EE 8

java-interview-questions-answers

Services can often be optimized with asynchronous processing even without changing their behavior towards the outside world. The reason why some services aren’t efficient is that they need to wait for other services to provide a result to continue further. Let’s look how to call external REST services without waiting for them and also do multiple parallel calls independently and ...

Read More »

Java EE MVC: Handling form validation

java-interview-questions-answers

In this post we will have a look on form validation in Java EE MVC. Java EE MVC integrates with the Java Bean Validation API (JSR 303) which makes adding validation constraints pretty easy. Validation using the JAX-RS way Assume we have a small html form that can be used to send contact messages. To represent the form data we ...

Read More »