Helion


Szczegóły ebooka

Designing Hexagonal Architecture with Java

Designing Hexagonal Architecture with Java


Hexagonal architecture enhances developers' productivity by decoupling business code from technology code, making the software more change-tolerant, and allowing it to evolve and incorporate new technologies without the need for significant refactoring. By adhering to hexagonal principles, you can structure your software in a way that reduces the effort required to understand and maintain the code.

This book starts with an in-depth analysis of hexagonal architecture's building blocks, such as entities, use cases, ports, and adapters. You'll learn how to assemble business code in the Domain hexagon, create features by using ports and use cases in the Application hexagon, and make your software compatible with different technologies by employing adapters in the Framework hexagon. Moving on, you'll get your hands dirty developing a system based on a real-world scenario applying all the hexagonal architecture's building blocks. By creating a hexagonal system, you'll also understand how you can use Java modules to reinforce dependency inversion and ensure the isolation of each hexagon in the architecture. Finally, you'll get to grips with using Quarkus to turn your hexagonal application into a cloud-native system.

By the end of this hexagonal architecture book, you'll be able to bring order and sanity to the development of complex and long-lasting applications.

  • Designing Hexagonal Architecture with Java
  • Contributors
  • About the author
  • About the reviewer
  • Preface
    • Who this book is for
    • What this book covers
    • To get the most out of this book
    • Download the example code files
    • Download the color images
    • Conventions used
    • Get in touch
    • Share Your Thoughts
  • Section 1: Architecture Fundamentals
  • Chapter 1: Why Hexagonal Architecture?
    • Technical requirements
    • Reviewing software architecture
      • The invisible things
      • Vicious cycle
      • Its not for everyone
      • Monolithic or distributed
      • Making decisions
    • Understanding the hexagonal architecture
      • Domain hexagon
      • Application hexagon
      • Framework hexagon
      • Advantages of the hexagonal approach
    • Summary
    • Questions
    • Further reading
  • Chapter 2: Wrapping Business Rules inside Domain Hexagon
    • Technical requirements
    • Modeling a problem domain with entities
      • The purity of domain entities
      • Relevant entities
      • Using UUIDs to define identity
    • Enhancing descriptiveness with value objects
    • Assuring consistency with aggregates
    • Working with domain services
    • Using policy and specification to deal with business rules
    • Defining business rules as POJOs
    • Summary
    • Questions
    • Further reading
  • Chapter 3: Handling Behavior with Ports and Use Cases
    • Technical requirements
    • Expressing software behavior with use cases
      • How to create a use case
    • Implementing use cases with input ports
    • Using output ports to deal with external data
      • It's not only about repositories
      • Where to use output ports
    • Automating behavior with the Application hexagon
    • Summary
    • Questions
    • Further reading
  • Chapter 4: Creating Adapters to Interact with the Outside World
    • Technical requirements
    • Understanding adapters
    • Using input adapters to allow driving operations
      • Creating input adapters
    • Using output adapters to speak with different data sources
      • Creating output adapters
    • Summary
    • Questions
    • Further reading
  • Chapter 5: Exploring the Nature of Driving and Driven Operations
    • Technical requirements
    • Reaching the hexagonal application with driving operations
      • Integrating web applications with the hexagonal system
      • Running test agents
      • Calling the hexagonal system from other applications
    • Handling external resources with driven operations
      • Data persistence
      • Messaging and events
      • Mock servers
    • Summary
    • Questions
  • Section 2: Using Hexagons to Create a Solid Foundation
  • Chapter 6: Building the Domain Hexagon
    • Technical requirements
    • Bootstrapping the Domain hexagon
    • Understanding the problem domain
    • Defining value objects
    • Defining entities and specifications
      • The Equipment and Router abstract entities
      • Core router entity and its specifications
      • Edge router entity and its specifications
      • Switch entity and its specifications
    • Defining domain services
      • Router service
      • Switch service
      • Network service
    • Testing the Domain hexagon
    • Summary
    • Questions
  • Chapter 7: Building the Application Hexagon
    • Technical requirements
    • Bootstrapping the Application hexagon
    • Defining use cases
      • Creating written descriptions for router management use cases
      • Defining the use case interface for router management
      • Creating written descriptions for switch management use cases
      • Defining the use case interface for switch management
      • Creating written descriptions for network management use cases
      • Defining the use case interface for network management
    • Implementing use cases with input ports
      • Testing the Application hexagon
    • Summary
    • Questions
  • Chapter 8: Building the Framework Hexagon
    • Technical requirements
    • Bootstrapping the Framework hexagon
    • Implementing output adapters
      • Router management output adapter
      • Switch management output adapter
    • Implementing input adapters
      • Router management input adapter
      • Switch management input adapter
      • Network management input adapter
    • Testing the Framework hexagon
    • Summary
      • Questions
  • Chapter 9: Applying Dependency Inversion with Java Modules
    • Technical requirements
    • Introducing JPMS
    • Inverting dependencies on a hexagonal application
      • Providing services with use cases and input ports
      • Providing services with output ports and output adapters
      • Making the input adapters dependent on abstractions
    • Using the Java platform's ServiceLoader class to retrieve JPMS provider implementations
      • Initializing RouterManagementGenericAdapter
      • Initializing SwitchManagementGenericAdapter
      • Initializing NetworkManagementGenericAdapter
    • Summary
    • Questions
    • Further reading
  • Section 3: Becoming Cloud-Native
  • Chapter 10: Adding Quarkus to a Modularized Hexagonal Application
    • Technical requirements
    • Revisiting the JVM
      • Speeding up runtime performance with JIT compilation
      • Improving startup time with AOT compilation
    • Introducing Quarkus
      • Creating REST endpoints with JAX-RS
      • Employing dependency injection with Quarkus DI
      • Validating objects
      • Configuring a data source and using Hibernate ORM
    • Adding Quarkus to a modularized hexagonal application
    • Summary
    • Questions
  • Chapter 11: Leveraging CDI Beans to Manage Ports and Use Cases
    • Technical requirements
    • Learning about Quarkus DI
      • Working with beans
    • Transforming ports, use cases, and adapters into CDI beans
      • Implementing CDI for router management objects
      • Implementing CDI for switch management objects
      • Implementing CDI for network management classes and interfaces
    • Testing use cases with Quarkus and Cucumber
    • Summary
    • Questions
    • Answers
  • Chapter 12: Using RESTEasy Reactive to Implement Input Adapters
    • Technical requirements
    • Exploring the approaches to handling server's requests
      • Imperative
      • Reactive
    • Implementing input adapters with RESTEasy Reactive
      • Implementing the Reactive input adapter for router management
      • Implementing the Reactive input adapter for switch management
      • Implementing the Reactive input adapter for network management
    • Adding OpenAPI and Swagger UI
    • Testing Reactive input adapters
    • Summary
    • Questions
  • Chapter 13: Persisting Data with Output Adapters and Hibernate Reactive
    • Technical requirements
    • Introducing Hibernate Reactive and Panache
      • Hibernate Reactive features
      • Panache features
    • Enabling reactive behavior on output adapters
      • Configuring reactive data sources
      • Configuring entities
      • Implementing reactive repository classes
      • Implementing reactive output adapters
      • Reactive router management of the MySQL output adapter
      • Reactive switch management of the MySQL output adapter
    • Testing the reactive output adapters
    • Summary
    • Questions
  • Chapter 14: Setting Up Dockerfile and Kubernetes Objects for Cloud Deployment
    • Technical requirements
    • Preparing the Docker image
      • Creating a Docker image with an Uber .jar artifact
      • Creating a Docker image with a native executable
    • Creating Kubernetes objects
      • Reviewing Kubernetes main objects
      • Configuring Kubernetes objects for the hexagonal system
    • Deploying on Minikube
    • Summary
    • Questions
  • Chapter 15: Good Design Practices for Your Hexagonal Application
    • Technical requirements
    • Using Domain Driven Design to shape the Domain hexagon
      • Understanding the business we are in
      • Promoting collaboration to increase knowledge
      • Applying DDD techniques to build the Domain hexagon
      • Implementing bounded contexts and subdomains in a hexagonal system
    • The need to create ports and use cases
    • Dealing with multiple adapter categories
    • Conclusion the hexagonal journey
    • Summary
    • Questions
  • Assessments
    • Chapter 1, Why Hexagonal Architecture?
    • Question 1
    • Answer
    • Question 2
    • Answer
    • Question 3
    • Answer
    • Question 4
    • Answer
    • Question 5
    • Answer
    • Chapter 2, Wrapping Business Rules inside Domain Hexagon
    • Question 1
    • Answer
    • Question 2
    • Answer
    • Question 3
    • Answer
    • Question 4
    • Answer
    • Question 5
    • Answer
    • Question 6
    • Answer
    • Chapter 3, Handling Behavior with Ports and Use Cases
    • Question 1
    • Answer
    • Question 2
    • Answer
    • Question 3
    • Answer
    • Question 4
    • Answer
    • Chapter 4, Creating Adapters to Interact with the Outside World
    • Question 1
    • Answer
    • Question 2
    • Answer
    • Question 3
    • Answer
    • Question 4
    • Answer
    • Chapter 5, Exploring the Nature of Driving and Driven Operations
    • Question 1
    • Answer
    • Question 2
    • Answer
    • Question 3
    • Answer
    • Question 4
    • Answer
    • Chapter 6, Building the Domain Hexagon
    • Question 1
    • Answer
    • Question 2
    • Answer
    • Question 3
    • Answer
    • Question 4
    • Answer
    • Chapter 7, Building the Application Hexagon
    • Question 1
    • Answer
    • Question 2
    • Answer
    • Question 3
    • Answer
    • Chapter 8, Building the Framework Hexagon
    • Question 1
    • Answer
    • Question 2
    • Answer
    • Question 3
    • Answer
    • Question 4
    • Answer
    • Chapter 9, Applying Dependency Inversion with Java Modules
    • Question 1
    • Answer
    • Question 2
    • Answer
    • Question 3
    • Answer
    • Question 4
    • Answer
    • Chapter 10, Adding Quarkus to a Modularized Hexagonal Application
    • Question 1
    • Answer
    • Question 2
    • Answer
    • Question 3
    • Answer
    • Question 4
    • Answer
    • Chapter 11, Leveraging CDI Beans to Manage Ports and Use Cases
    • Question 1
    • Answer
    • Question 2
    • Answer
    • Question 3
    • Answer
    • Question 4
    • Answer
    • Chapter 12, Using RESTEasy Reactive to Implement Input Adapters
    • Question 1
    • Answer
    • Question 2
    • Answer
    • Question 3
    • Answer
    • Question 4
    • Answer
    • Chapter 13, Persisting Data with Output Adapters and Hibernate Reactive
    • Question 1
    • Answer
    • Question 2
    • Answer
    • Question 3
    • Answer
    • Question 4
    • Answer
    • Chapter 14, Setting up Dockerfile and Kubernetes Objects for Cloud Deployment
    • Question 1
    • Answer
    • Question 2
    • Answer
    • Question 3
    • Answer
    • Chapter 15, Good Design Practices for Your Hexagonal Application
    • Question 1
    • Answer
    • Question 2
    • Answer
    • Question 3
    • Answer
    • Question 4
    • Answer
    • Why subscribe?
  • Other Books You May Enjoy
    • Packt is searching for authors like you
    • Share Your Thoughts

  • Tytuły: Designing Hexagonal Architecture with Java
  • Autor: Davi Vieira
  • Tytuł oryginału: Designing Hexagonal Architecture with Java
  • ISBN Ebooka: 9781801810296, 9781801810296
  • Data wydania: 2022-01-07
  • Identyfikator pozycji: e_2t2z
  • Kategorie:
  • Wydawca: Packt Publishing