Service implementation

Using the preceding approach, you could divide the abstraction of the domain service into two parts—the main service abstraction and a read-only service abstraction:

public abstract class ReadOnlyBaseService<TE, T> { 
    private final Repository<TE, T> repository; 
    ReadOnlyBaseService(ReadOnlyRepository<TE, T> repository) { 
        this.repository = repository; 

The following diagram contains the OTRS services and their relationships:

Domain services

Now, we could use this ReadOnlyBaseService to create BaseService. Here, we are using the dependency injection pattern via a constructor to map concrete objects with abstraction: ...

Get Mastering Microservices with Java - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.