Domain Service Java SDK

Introduction

The service project SDK provides numerous components to help with the implementation of a Domain Service Project based on the project's design model. That means, whatever you modelled in the design phase will be reflected by pre-generated code.

Tip:

The generated SDK is dependent on the extensions that are currently enabled in the project. Please check the related pages for Java Spring Boot Implementation in the chapter Extensions to find out more about the generated SDK and how it can be used.

Structure

SDK consists of some main packages under src/main/generated source folder:

  • api: which holds all API Namespace's schema models, controllers and delegate classes.
  • domain: which holds classes for all entities, services, commands, events and agents that have been modelled in Domain Namespaces.
  • integration: which contains classes and providers that allows for easy integration with dependent API(s) that have been added in Integration Namespaces.

Solution engineers can use these generated classes to implement logic and interact with different modelled components.

Below are the main SDK components that can be used by solution engineers to help to implement project generated implementation files logic.

Warning:

Some components are grouped under the namespace that they are modelled.

For example:

// Import Owner entity that was modelled in a namespace with the prefix: cc
import de.cards.sdk.domain.cc.entity.Owner;

Distributed tracing

  • To provide distributed tracing among your different service projects, Spring cloud sleuth is already a dependency of your service project.

  • All incoming and outgoing requests are tracked by default.

  • To create extra spans of your incoming request flow, you can easily use @NewSpan annotation to annotate your methods where you want a tracing span to be created.

  • By default all generated services base classes are annotated with @NewSpan.

Logging

Logging can be using slf4j logger factory to create a logger instance.

slf4j provides the info,warn,debug,trace log levels.

// Add imports for slf4j
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

// Create logger instance
private static Logger log = LoggerFactory.getLogger(CardRECommand.class);

// logging examples
log.info("Saved a new Credit Card Root Entity with Id {}", cardRootEntity.getId());