Class BoundedDomain<R extends Realm,B,P extends Port<R>>

java.lang.Object
net.tangly.core.domain.BoundedDomain<R,B,P>
Type Parameters:
R - realm handles all entities and values objects of the domain model
B - business logic provides complex domain business logic functions
P - port empowers the business domain to communicate with outer layers or external systems. The communication is generally asynchronous
All Implemented Interfaces:
DomainAudit, HasName

public class BoundedDomain<R extends Realm,B,P extends Port<R>> extends Object implements HasName, DomainAudit
A bounded domain as defined in the DDD approach has a domain-specific model and a set of adapters. A bounded domain is a cohesive and decoupled unit of functionality that is relevant to the business. It has a unique name.

The lifecycle of a bounded domain is:

  1. Bounded domain creation. The creation sets the realm, logic, ports, tenant directory are set.
  2. Define codes and tags into the domain type registry. The port interface provides a method Port.importConfiguration(DomainAudit, TypeRegistry)
  3. Startup of the domain after construction
  4. Shutdown of the domain after startup

The tenant directory provides access to tenant configuration information.

The type registry is the source of codes and tags. These concepts support dynamic extension points into the domain. Each tenant can defines code values and tags.

  • Constructor Details

    • BoundedDomain

      public BoundedDomain(@NotNull @NotNull String name, @NotNull R realm, @NotNull B logic, @NotNull P port, TenantDirectory directory)
      Constructor of the bounded domain.
      Parameters:
      name - human-readable name of the domain
      realm - realm handles all entities and values objects of the domain model
      logic - logic provides complex domain business logic functions
      port - port empowers the business domain to communicate with external systems
      directory - directory of the tenant to support inter-domain communication
  • Method Details

    • addTagCounts

      protected static <I extends HasOid & HasMutableTags> void addTagCounts(@NotNull @NotNull TypeRegistry registry, @NotNull @NotNull Provider<I> provider, Map<TagType<?>,Integer> counts)
    • addTagCounts

      protected static <I extends HasTags> void addTagCounts(@NotNull @NotNull TypeRegistry registry, @NotNull @NotNull List<I> entities, Map<TagType<?>,Integer> counts)
    • subscribe

      public void subscribe(@NotNull @NotNull BoundedDomain.EventListener listener)
      Subscribes to the public event channel of the domain.
      Parameters:
      listener - event listener
    • subscribeInternally

      public void subscribeInternally(@NotNull @NotNull BoundedDomain.EventListener listener)
      Subscribes to the internal event channel of the domain.
      Parameters:
      listener - event listener
    • countTags

      public Map<TagType<?>,Integer> countTags(@NotNull @NotNull Map<TagType<?>,Integer> counts)
    • name

      public String name()
      Description copied from interface: DomainAudit
      Returns the name of the domain audit. It should be the name of the bounded domain.
      Specified by:
      name in interface DomainAudit
      Specified by:
      name in interface HasName
      Returns:
      name of the domain audit
    • realm

      public R realm()
    • logic

      public B logic()
    • port

      public P port()
    • registry

      public TypeRegistry registry()
    • directory

      public TenantDirectory directory()
    • entities

      public List<DomainEntity<?>> entities()
    • auditEvents

      public List<net.tangly.commons.logger.EventData> auditEvents()
    • enabled

      public boolean enabled()
    • log

      public void log(@NotNull @NotNull net.tangly.commons.logger.EventData auditEvent)
      Specified by:
      log in interface DomainAudit
    • entityImported

      public void entityImported(@NotNull @NotNull String entityName)
      Description copied from interface: DomainAudit
      Instances were added, deleted or modified in the domain programmatically and not through the user interface.
      Specified by:
      entityImported in interface DomainAudit
      Parameters:
      entityName - name of the entity
    • submitInterally

      public void submitInterally(@NotNull @NotNull Object event)
      Description copied from interface: DomainAudit
      Submit an event to the internal event channel of the domain. The channel is used to publish events within the domain.
      Specified by:
      submitInterally in interface DomainAudit
      Parameters:
      event - event to submit
    • submit

      public void submit(@NotNull @NotNull Object event)
      Description copied from interface: DomainAudit
      Submit an event to the external public event channel of the domain. The channel is used to publish events to other domains.
      Specified by:
      submit in interface DomainAudit
      Parameters:
      event - event to submit
    • channel

      public SubmissionPublisher<Object> channel()
    • internalChannel

      public SubmissionPublisher<Object> internalChannel()
    • startup

      public void startup()
    • shutdown

      public void shutdown()