diff --git a/architecture/README.md b/architecture/README.md deleted file mode 100644 index be093f25ed..0000000000 --- a/architecture/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant articles - -- [A Quick and Practical Example of Hexagonal Architecture in Java](https://www.baeldung.com/a-quick-and-practical-example-of-hexagonal-architecture-in-java-3/) diff --git a/architecture/pom.xml b/architecture/pom.xml deleted file mode 100644 index 4ad104293e..0000000000 --- a/architecture/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - 4.0.0 - com.baeldung.architecture - architecture - 0.0.1-SNAPSHOT - architecture - jar - A Quick and Practical Example of Hexagonal Architecture in Java - - - parent-boot-2 - com.baeldung - 0.0.1-SNAPSHOT - ../parent-boot-2 - - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - com.h2database - h2 - runtime - - - org.springframework.boot - spring-boot-starter-web - - - diff --git a/architecture/src/main/java/com/baeldung/architecture/HexagonalArchitectureTaskApplication.java b/architecture/src/main/java/com/baeldung/architecture/HexagonalArchitectureTaskApplication.java deleted file mode 100644 index 69c6f4b276..0000000000 --- a/architecture/src/main/java/com/baeldung/architecture/HexagonalArchitectureTaskApplication.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.baeldung.architecture; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class HexagonalArchitectureTaskApplication { - public static void main(String[] args) { - SpringApplication.run(HexagonalArchitectureTaskApplication.class, args); - } - -} diff --git a/architecture/src/main/java/com/baeldung/architecture/application/task/AddNewDailyTask.java b/architecture/src/main/java/com/baeldung/architecture/application/task/AddNewDailyTask.java deleted file mode 100644 index f9ee97542c..0000000000 --- a/architecture/src/main/java/com/baeldung/architecture/application/task/AddNewDailyTask.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baeldung.architecture.application.task; - -import java.time.Instant; -import java.time.temporal.ChronoUnit; - -import com.baeldung.architecture.commands.task.CreateTask; -import com.baeldung.architecture.domain.task.Task; - -import org.springframework.stereotype.Component; - -@Component -public class AddNewDailyTask implements CreateTask { - - private AddNewTask addNewTask; - - public AddNewDailyTask(AddNewTask addNewTask) { - this.addNewTask = addNewTask; - } - - @Override - public void create(Task newTask) { - Instant initialDueDate = newTask.getDueDate(); - String description = newTask.getDescription(); - for (int i = 1; i <= 5; i++) { - Task task = new Task(initialDueDate.plus(i, ChronoUnit.DAYS), description); - addNewTask.create(task); - } - } -} diff --git a/architecture/src/main/java/com/baeldung/architecture/application/task/AddNewTask.java b/architecture/src/main/java/com/baeldung/architecture/application/task/AddNewTask.java deleted file mode 100644 index 70638378f9..0000000000 --- a/architecture/src/main/java/com/baeldung/architecture/application/task/AddNewTask.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.architecture.application.task; - -import com.baeldung.architecture.domain.task.Task; -import com.baeldung.architecture.domain.task.TaskService; -import com.baeldung.architecture.commands.task.*; - -import org.springframework.stereotype.Component; - -@Component -public class AddNewTask implements CreateTask { - - private TaskService taskService; - - public AddNewTask(TaskService taskService) { - this.taskService = taskService; - } - - @Override - public void create(Task newTask) { - taskService.createTask(newTask); - } -} diff --git a/architecture/src/main/java/com/baeldung/architecture/application/task/GetTasks.java b/architecture/src/main/java/com/baeldung/architecture/application/task/GetTasks.java deleted file mode 100644 index c876f7de85..0000000000 --- a/architecture/src/main/java/com/baeldung/architecture/application/task/GetTasks.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.architecture.application.task; - -import com.baeldung.architecture.domain.task.Task; -import com.baeldung.architecture.domain.task.TaskService; -import com.baeldung.architecture.commands.task.*; - -import org.springframework.stereotype.Component; - -@Component -public class GetTasks implements GetAllTasks { - - private TaskService taskService; - - public GetTasks(TaskService taskService) { - this.taskService = taskService; - } - - @Override - public Iterable getAll() { - return taskService.getAllTasks(); - } -} diff --git a/architecture/src/main/java/com/baeldung/architecture/commands/task/CreateTask.java b/architecture/src/main/java/com/baeldung/architecture/commands/task/CreateTask.java deleted file mode 100644 index ec60868a22..0000000000 --- a/architecture/src/main/java/com/baeldung/architecture/commands/task/CreateTask.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.baeldung.architecture.commands.task; - -import com.baeldung.architecture.domain.task.Task; - -public interface CreateTask { - public void create(Task newTask); -} diff --git a/architecture/src/main/java/com/baeldung/architecture/commands/task/GetAllTasks.java b/architecture/src/main/java/com/baeldung/architecture/commands/task/GetAllTasks.java deleted file mode 100644 index c9aa1be5f8..0000000000 --- a/architecture/src/main/java/com/baeldung/architecture/commands/task/GetAllTasks.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.baeldung.architecture.commands.task; - -import com.baeldung.architecture.domain.task.Task; - -public interface GetAllTasks { - public Iterable getAll(); -} diff --git a/architecture/src/main/java/com/baeldung/architecture/domain/task/Task.java b/architecture/src/main/java/com/baeldung/architecture/domain/task/Task.java deleted file mode 100644 index 240dc33571..0000000000 --- a/architecture/src/main/java/com/baeldung/architecture/domain/task/Task.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.baeldung.architecture.domain.task; - -import java.time.Instant; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - -@Entity -public class Task { - @Id - @GeneratedValue(strategy=GenerationType.AUTO) - private Long id; - private Instant dueDate = Instant.now(); - private String description; - - public Task() {} - - public Task(Instant dueDate, String description) { - this.dueDate = dueDate; - this.description = description; - } - - public Task(Long id, Instant dueDate, String description) { - this(dueDate, description); - this.id = id; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Instant getDueDate() { - return dueDate; - } - - public void setDueDate(Instant dueDate) { - this.dueDate = dueDate; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } -} diff --git a/architecture/src/main/java/com/baeldung/architecture/domain/task/TaskRepository.java b/architecture/src/main/java/com/baeldung/architecture/domain/task/TaskRepository.java deleted file mode 100644 index d896212714..0000000000 --- a/architecture/src/main/java/com/baeldung/architecture/domain/task/TaskRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.baeldung.architecture.domain.task; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface TaskRepository extends CrudRepository {}; diff --git a/architecture/src/main/java/com/baeldung/architecture/domain/task/TaskService.java b/architecture/src/main/java/com/baeldung/architecture/domain/task/TaskService.java deleted file mode 100644 index 11ef0f3e19..0000000000 --- a/architecture/src/main/java/com/baeldung/architecture/domain/task/TaskService.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.architecture.domain.task; - -import org.springframework.stereotype.Service; - -@Service -public class TaskService { - - private TaskRepository taskRepository; - - public TaskService(TaskRepository taskRepository) { - this.taskRepository = taskRepository; - } - - public void createTask(Task task) { - taskRepository.save(task); - } - - public Iterable getAllTasks() { - return taskRepository.findAll(); - } - -} diff --git a/architecture/src/main/java/com/baeldung/architecture/framework/cli/StartupRunner.java b/architecture/src/main/java/com/baeldung/architecture/framework/cli/StartupRunner.java deleted file mode 100644 index 449bc9386e..0000000000 --- a/architecture/src/main/java/com/baeldung/architecture/framework/cli/StartupRunner.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.architecture.framework.cli; - -import com.baeldung.architecture.application.task.AddNewDailyTask; -import com.baeldung.architecture.domain.task.Task; - -import org.springframework.boot.ApplicationArguments; -import org.springframework.boot.ApplicationRunner; -import org.springframework.stereotype.Component; - -@Component -public class StartupRunner implements ApplicationRunner { - - AddNewDailyTask addNewDailyTask; - - public StartupRunner(AddNewDailyTask addNewDailyTask) { - this.addNewDailyTask = addNewDailyTask; - } - @Override - public void run(ApplicationArguments args) throws Exception { - Task task = new Task(); - task.setDescription("Startup Task"); - addNewDailyTask.create(task); - } -} diff --git a/architecture/src/main/java/com/baeldung/architecture/framework/http/task/TaskApiController.java b/architecture/src/main/java/com/baeldung/architecture/framework/http/task/TaskApiController.java deleted file mode 100644 index 87a8f5fe4b..0000000000 --- a/architecture/src/main/java/com/baeldung/architecture/framework/http/task/TaskApiController.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.baeldung.architecture.framework.http.task; - -import java.time.Instant; - -import com.baeldung.architecture.application.task.AddNewTask; -import com.baeldung.architecture.application.task.GetTasks; -import com.baeldung.architecture.domain.task.Task; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("task") -public class TaskApiController { - - private AddNewTask addNewTask; - private GetTasks getTasks; - - public TaskApiController( - AddNewTask addNewTask, - GetTasks getTasks - ) { - this.addNewTask = addNewTask; - this.getTasks = getTasks; - } - - @GetMapping - Iterable listTasks() { - return getTasks.getAll(); - } - - @PostMapping(consumes = "application/json", produces = "application/json") - void createTask(@RequestBody TaskRequest taskRequest) { - Task task = new Task(); - task.setDescription(taskRequest.getDescription()); - task.setDueDate(Instant.parse(taskRequest.getDueDate())); - addNewTask.create(task); - } -} diff --git a/architecture/src/main/java/com/baeldung/architecture/framework/http/task/TaskRequest.java b/architecture/src/main/java/com/baeldung/architecture/framework/http/task/TaskRequest.java deleted file mode 100644 index 70b98a32f9..0000000000 --- a/architecture/src/main/java/com/baeldung/architecture/framework/http/task/TaskRequest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.architecture.framework.http.task; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -public class TaskRequest { - @JsonInclude(Include.NON_NULL) - private String description; - - @JsonInclude(Include.NON_NULL) - private String dueDate; - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getDueDate() { - return dueDate; - } - - public void setDueDate(String dueDate) { - this.dueDate = dueDate; - } -}