-
Notifications
You must be signed in to change notification settings - Fork 0
/
HelloService.java
38 lines (30 loc) · 1.05 KB
/
HelloService.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
36
37
38
package com.example.payara.hello;
import com.example.payara.hello.entity.Hello;
import jakarta.annotation.PostConstruct;
import jakarta.ejb.ConcurrencyManagement;
import jakarta.ejb.ConcurrencyManagementType;
import jakarta.ejb.Singleton;
import jakarta.ejb.Startup;
import jakarta.inject.Inject;
import jakarta.validation.ValidationException;
@Singleton
@Startup
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
public class HelloService {
@Inject
HelloStorage helloStorage;
String id;
@PostConstruct
public void init() {
var hello = new Hello();
hello.setMessage("Hello, World!");
id = helloStorage.merge(hello).getId();
}
public String hello() {
return helloStorage.read(id).getMessage();
}
public String helloThrowEJBWrappedValidationException() throws ValidationException {
throw new ValidationException("This exception should become a 400 after the ValidationExceptionMapper handles " +
"it when called by the EJBExceptionMapper after unwrapping it");
}
}