Nature of Service

The nature() element indicates the intent of the actions defined within the domain service:

  • VIEW

    The default; the service’s actions appear on menu bars, can be contributed, appear in the REST API

  • REST

    The service’s actions are intended only to be listed in the REST API exposed by the RestfulObjects viewer.

The actual class name of the domain service is only rendered for the VIEW natures.

For example:

@DomainService
@RequiredArgsConstructor(onConstructor_ = {@Inject} )
public class Loans {                                    (1)

    private final LoanRepository loanRepository;        (2)

    @Action(semantics=SemanticsOf.SAFE)
    public List<Loan> findOverdueLoans() {
        // ...
    }
}
1 name is intended to be rendered in the UI
2 it’s common for domain-layer domain services to be injected into presentation layer services.

For services that do not need to appear in the UI and do not need to be invoked using WrapperFactory (in other words, do not need to be part of the metamodel), you can declare the service using Spring’s @Service, @Repository or @Component annotations.

For example:

@Repository
public class LoanRepository {
    public List<Loan> findLoansFor(Borrower borrower) {
        // ...
    }
}