-
Notifications
You must be signed in to change notification settings - Fork 88
guide component facade
devonfw-core edited this page Nov 21, 2022
·
9 revisions
Table of Contents
Warning
|
Hey there! Seems like you are still using the documentation of our legacy Java repository. Since it won’t be maintained anymore, we recommend you to checkout the new Java page here. |
Note
|
Our recommended approach for implementing the logic layer is use-cases |
For each component of the application, the logic layer defines a component facade.
This is an interface defining all business operations of the component.
It carries the name of the component («Component»
) and has an implementation named «Component»Impl
(see implementation).
Warning
|
Hey there! Seems like you are still using the documentation of our legacy Java repository. Since it won’t be maintained anymore, we recommend you to checkout the new Java page here.
The component facade interface defines the logic API of the component and has to be business oriented.
This means that all parameters and return types of all methods from this API have to be business transfer-objects, datatypes (String , Integer , MyCustomerNumber , etc.), or collections of these.
The API may also only access objects of other business components listed in the (transitive) dependencies of the business-architecture.
|
Here is an example how such an API may look like:
public interface Bookingmanagement {
BookingEto findBooking(Long id);
BookingCto findBookingCto(Long id);
Page<BookingEto> findBookingEtos(BookingSearchCriteriaTo criteria);
void approveBooking(BookingEto booking);
}
Warning
|
Hey there! Seems like you are still using the documentation of our legacy Java repository. Since it won’t be maintained anymore, we recommend you to checkout the new Java page here.
The implementation of an interface from the logic layer (a component facade or a use-case) carries the name of that interface with the suffix Impl and is annotated with @Named .
An implementation typically needs access to the persistent data.
This is done by injecting the corresponding repository (or DAO).
According to data-sovereignty, only repositories of the same business component may be accessed directly.
For accessing data from other components the implementation has to use the corresponding API of the logic layer (the component facade). Further, it shall not expose persistent entities from the domain layer and has to map them to transfer objects using the bean-mapper.
|
@Named
@Transactional
public class BookingmanagementImpl extends AbstractComponentFacade implements Bookingmanagement {
@Inject
private BookingRepository bookingRepository;
@Override
public BookingEto findBooking(Long id) {
LOG.debug("Get Booking with id {} from database.", id);
BookingEntity entity = this.bookingRepository.findOne(id);
return getBeanMapper().map(entity, BookingEto.class));
}
}
As you can see, entities (BookingEntity
) are mapped to corresponding ETOs (BookingEto
).
Further details about this can be found in bean-mapping.
This documentation is licensed under the Creative Commons License (Attribution-NoDerivatives 4.0 International).