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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.