This page is served by Spring Boot. The source is in src/main/resources/public/index.html.
This page is served by Quarkus. The source is in src/main/resources/META-INF/resources/index.html.
This page is served by Spring Boot. The source is in src/main/resources/public/index.html.
This page is served by Quarkus. The source is in src/main/resources/META-INF/resources/index.html.
null value is also valid.
54 | * @return {@literal true} if the string is a valid UUID.
55 | */
56 | public static boolean isValid(final String value) {
57 | if (value == null) {
58 | return true;
59 | }
60 | return AggregateRootUuid.isValid(value);
61 | }
62 |
63 | /**
64 | * Parses a given string and returns a new instance of PersonId.
65 | *
66 | * @param value String with valid UUID to convert. A null value returns null.
67 | * @return Converted value.
68 | */
69 | public static PersonId valueOf(final String value) {
70 | if (value == null) {
71 | return null;
72 | }
73 | AggregateRootUuid.requireArgValid("value", value);
74 | return new PersonId(UUID.fromString(value));
75 | }
76 |
77 | }
--------------------------------------------------------------------------------
/spring-boot/query/src/main/java/org/fuin/cqrs4j/example/spring/query/app/QryApplication.java:
--------------------------------------------------------------------------------
1 | package org.fuin.cqrs4j.example.spring.query.app;
2 |
3 | import org.fuin.cqrs4j.springboot.base.EventstoreConfig;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.boot.autoconfigure.domain.EntityScan;
7 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
8 | import org.springframework.context.annotation.Bean;
9 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
10 | import org.springframework.scheduling.TaskScheduler;
11 | import org.springframework.scheduling.annotation.EnableAsync;
12 | import org.springframework.scheduling.annotation.EnableScheduling;
13 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
14 | import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
15 | import org.springframework.scheduling.config.ScheduledTaskRegistrar;
16 |
17 | import java.util.concurrent.Executor;
18 |
19 | @SpringBootApplication(scanBasePackages = {
20 | "org.fuin.cqrs4j.springboot.view",
21 | "org.fuin.cqrs4j.example.spring.shared",
22 | "org.fuin.cqrs4j.example.spring.query.app",
23 | "org.fuin.cqrs4j.example.spring.query.views"
24 | })
25 | @EnableConfigurationProperties(EventstoreConfig.class)
26 | @EnableJpaRepositories("org.fuin.cqrs4j.")
27 | @EntityScan({
28 | "org.fuin.cqrs4j.springboot.view",
29 | "org.fuin.cqrs4j.example.spring.query.views"
30 | })
31 | @EnableScheduling
32 | @EnableAsync
33 | public class QryApplication {
34 |
35 | @Bean("projectorExecutor")
36 | public Executor taskExecutor() {
37 | final ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
38 | executor.setCorePoolSize(1);
39 | executor.setMaxPoolSize(5);
40 | executor.setQueueCapacity(500);
41 | executor.setThreadNamePrefix("qry-app-");
42 | executor.initialize();
43 | return executor;
44 | }
45 |
46 | @Bean
47 | public ScheduledTaskRegistrar scheduledTaskRegistrar(TaskScheduler taskScheduler) {
48 | final ScheduledTaskRegistrar scheduledTaskRegistrar = new ScheduledTaskRegistrar();
49 | scheduledTaskRegistrar.setScheduler(taskScheduler);
50 | return scheduledTaskRegistrar;
51 | }
52 |
53 | @Bean
54 | public TaskScheduler threadPoolTaskScheduler() {
55 | final ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
56 | scheduler.setPoolSize(20);
57 | return scheduler;
58 | }
59 |
60 | public static void main(String[] args) {
61 | SpringApplication.run(QryApplication.class, args);
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/spring-boot/query/src/main/java/org/fuin/cqrs4j/example/spring/query/views/personlist/PersonListEntry.java:
--------------------------------------------------------------------------------
1 | package org.fuin.cqrs4j.example.spring.query.views.personlist;
2 |
3 | import jakarta.persistence.*;
4 | import jakarta.validation.constraints.NotNull;
5 | import org.fuin.cqrs4j.example.spring.shared.PersonId;
6 | import org.fuin.cqrs4j.example.spring.shared.PersonName;
7 | import org.fuin.objects4j.common.Contract;
8 |
9 | /**
10 | * Represents a person that will be stored in the database.
11 | */
12 | @Entity
13 | @NamedQuery(name = PersonListEntry.FIND_ALL, query = "SELECT p FROM PersonListEntry p")
14 | @Table(name = "SPRING_PERSON_LIST")
15 | public class PersonListEntry {
16 |
17 | public static final String FIND_ALL = "PersonListEntry.findAll";
18 |
19 | @Id
20 | @Column(name = "ID", nullable = false, length = 36, updatable = false)
21 | @NotNull
22 | private String id;
23 |
24 | @Column(name = "NAME", nullable = false, length = PersonName.MAX_LENGTH, updatable = true)
25 | @NotNull
26 | private String name;
27 |
28 | /**
29 | * Deserialization constructor.
30 | */
31 | protected PersonListEntry() {
32 | super();
33 | }
34 |
35 | /**
36 | * Constructor with all data.
37 | *
38 | * @param id
39 | * Unique aggregate identifier.
40 | * @param name
41 | * Name of the created person
42 | */
43 | public PersonListEntry(@NotNull final PersonId id, @NotNull final PersonName name) {
44 | super();
45 | Contract.requireArgNotNull("id", id);
46 | Contract.requireArgNotNull("name", name);
47 | this.id = id.asString();
48 | this.name = name.asString();
49 | }
50 |
51 | /**
52 | * Returns the person as "DTO" instance.
53 | *
54 | * @return Person record.
55 | */
56 | public Person toDto() {
57 | return new Person(id, name);
58 | }
59 |
60 | /**
61 | * Returns the unique person identifier.
62 | *
63 | * @return Aggregate ID.
64 | */
65 | @NotNull
66 | public PersonId getId() {
67 | return PersonId.valueOf(id);
68 | }
69 |
70 | /**
71 | * Returns the name of the person to create.
72 | *
73 | * @return the Person name
74 | */
75 | @NotNull
76 | public PersonName getName() {
77 | return new PersonName(name);
78 | }
79 |
80 | /**
81 | * Sets the name of the person.
82 | *
83 | * @param name
84 | * Name to set.
85 | */
86 | public void setName(@NotNull final PersonName name) {
87 | Contract.requireArgNotNull("name", name);
88 | this.name = name.asString();
89 | }
90 |
91 | @Override
92 | public String toString() {
93 | return "PersonListEntry [id=" + id + ", name=" + name + "]";
94 | }
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/spring-boot/query/src/main/java/org/fuin/cqrs4j/example/spring/query/views/personlist/PersonListController.java:
--------------------------------------------------------------------------------
1 | package org.fuin.cqrs4j.example.spring.query.views.personlist;
2 |
3 | import jakarta.persistence.EntityManager;
4 | import org.fuin.cqrs4j.example.spring.shared.PersonId;
5 | import org.fuin.ddd4j.core.AggregateNotFoundException;
6 | import org.fuin.objects4j.core.UUIDStr;
7 | import org.slf4j.Logger;
8 | import org.slf4j.LoggerFactory;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.http.MediaType;
11 | import org.springframework.http.ResponseEntity;
12 | import org.springframework.transaction.annotation.Transactional;
13 | import org.springframework.web.bind.annotation.GetMapping;
14 | import org.springframework.web.bind.annotation.PathVariable;
15 | import org.springframework.web.bind.annotation.RequestMapping;
16 | import org.springframework.web.bind.annotation.RestController;
17 |
18 | import java.util.List;
19 | import java.util.UUID;
20 | import java.util.stream.Collectors;
21 |
22 | /**
23 | * REST controller providing the persons.
24 | */
25 | @RestController
26 | @RequestMapping("/persons")
27 | @Transactional(readOnly = true)
28 | public class PersonListController {
29 |
30 | private static final Logger LOG = LoggerFactory.getLogger(PersonListController.class);
31 |
32 | @Autowired
33 | private EntityManager em;
34 |
35 | /**
36 | * Get all persons list.
37 | *
38 | * @return the list
39 | */
40 | @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
41 | public Listnull value is also valid.
55 | * @return {@literal true} if the string is a valid UUID.
56 | */
57 | public static boolean isValid(final String value) {
58 | if (value == null) {
59 | return true;
60 | }
61 | return AggregateRootUuid.isValid(value);
62 | }
63 |
64 | /**
65 | * Parses a given string and returns a new instance of PersonId.
66 | *
67 | * @param value String with valid UUID to convert. A null value returns null.
68 | * @return Converted value.
69 | */
70 | public static PersonId valueOf(final String value) {
71 | if (value == null) {
72 | return null;
73 | }
74 | AggregateRootUuid.requireArgValid("value", value);
75 | return new PersonId(UUID.fromString(value));
76 | }
77 |
78 | /**
79 | * Converts the value object from/to UUID.
80 | */
81 | public static final class Converter implements JsonbAdapter