-
Notifications
You must be signed in to change notification settings - Fork 0
/
HelloResource.java
35 lines (29 loc) · 946 Bytes
/
HelloResource.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.example.payara.hello;
import jakarta.inject.Inject;
import jakarta.validation.ValidationException;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
@Path("/hello-world")
public class HelloResource {
@Inject
HelloService helloService;
@GET
@Produces("text/plain")
public String hello() {
return helloService.hello();
}
@GET
@Path("hello-throw-ejb-wrapped-validation-exception")
@Produces("application/json")
public String helloThrowWrapped() throws ValidationException {
return helloService.helloThrowEJBWrappedValidationException();
}
@GET
@Path("hello-throw-not-ejb-wrapped-validation-exception")
@Produces("application/json")
public String helloThrowNotWrapped() {
throw new ValidationException("This is handled correctly by the ValidationExceptionMapper, and 400 is " +
"returned");
}
}