Skip to content

Latest commit

 

History

History
77 lines (51 loc) · 2.8 KB

3-logic.asciidoc

File metadata and controls

77 lines (51 loc) · 2.8 KB

Order Service - Logic Layer

In this chapter we are going to create business logic layer for already implemented database entities, repositories, and queries. We are going to prepare transfer-objects and use-cases together with facades and proper component tests.

ATTENTION: When you are new to devonfw, it might be a little tricky to get the packaging right and to understand what should go into api and what should go into core. Therefore, please consult the architecture-mapping of the devon4j documentation.

Transfer objects

In the dataaccess exercise you have created the Entity infrastructure. Now, we create transfer-objects.

ATTENTION: We create ETOs in the api module (not in core)

For each entity we create an ETO:

  • OrderEto for OrderEntity

  • ItemEto for ItemEntity

Add all properties from Entity to Eto except for relations.

TOs

Use-Cases

Now that we have created ETOs we create use-cases for CRUD functionality on our business-objects:

  • UcFindItem[Impl]

  • UcFindOrder[Impl]

  • UcManageItem[Impl]

  • UcManageOrder[Impl]

UCs

Each of use-case implementation shall be annotated as following:

@Named
@Transactional

Component-Facade (optional)

If you have completed the use-cases and still have some time left, you can create the facade for the ordermanagement component. Otherwise you can skip here and simply inject the use-cases directly in the next exercises. The component facade simplifies such injection as you always just inject the component facade via its interface and can find any use-case method via content assist (tab auto-completion).

If other components or the service-layer want to use these use-cases, we can compose them as component-facade: Ordermanagement[Impl]

  • The interface simply extends all use-case interfaces

  • The implementation gets all use-cases injected and delegates to them in the method implementations.

Example:

  @Inject
  private UcFindOrder ucFindOrder;

  ...

  @Override
  public OrderEto findOrder(IdRef<Order> id) {

    return this.ucFindOrder.findOrder(id);
  }
Facade