public final class BoundedContextBuilder
extends java.lang.Object
implements io.spine.logging.Logging
BoundedContext
instances.Modifier and Type | Method and Description |
---|---|
<I,E extends Entity<I,?>> |
add(java.lang.Class<E> entityClass)
Adds the default repository for the passed entity class to
the repository registration list.
|
BoundedContextBuilder |
add(Repository<?,?> repository)
Adds the passed repository to the registration list which will be processed after
the Bounded Context is created.
|
BoundedContextBuilder |
addCommandDispatcher(CommandDispatcher commandDispatcher)
Adds the passed command dispatcher to the dispatcher registration list which will be
processed after the Bounded Context is created.
|
BoundedContextBuilder |
addCommandFilter(BusFilter<CommandEnvelope> filter)
Adds a filter for commands.
|
BoundedContextBuilder |
addCommandListener(Listener<CommandEnvelope> listener)
Adds a listener for commands posted to the
CommandBus of the context being built. |
BoundedContextBuilder |
addEventDispatcher(EventDispatcher eventDispatcher)
Adds the passed event dispatcher to the dispatcher registration list which will be processed
after the Bounded Context is created.
|
BoundedContextBuilder |
addEventFilter(BusFilter<EventEnvelope> filter)
Adds a filter for events.
|
BoundedContextBuilder |
addEventListener(Listener<EventEnvelope> listener)
Adds a listener of the events posted to the
EventBus of the context being built. |
BoundedContext |
build()
Creates a new instance of
BoundedContext with the set configurations. |
com.google.common.collect.ImmutableList<CommandDispatcher> |
commandDispatchers()
Obtains the list of command dispatchers added to the builder by the time of the call.
|
BoundedContextBuilder |
enrichEventsUsing(EventEnricher enricher)
Sets a custom
Enricher for events posted to
the EventBus of the context being built. |
com.google.common.collect.ImmutableList<EventDispatcher> |
eventDispatchers()
Obtains the list of event dispatchers added to the builder by the time of the call.
|
java.util.Optional<EventEnricher> |
eventEnricher()
Obtains
EventEnricher assigned to the context to be built, or
empty Optional if no enricher was assigned prior to this call. |
boolean |
isMultitenant() |
io.spine.core.BoundedContextName |
name()
Returns the name of the resulting context.
|
<I,E extends Entity<I,?>> |
remove(java.lang.Class<E> entityClass)
Removes the repository from the registration list by the passed entity class.
|
BoundedContextBuilder |
remove(Repository<?,?> repository)
Removes the passed repository from the registration list.
|
BoundedContextBuilder |
removeCommandDispatcher(CommandDispatcher commandDispatcher)
Removes the passed command dispatcher from the corresponding registration list.
|
BoundedContextBuilder |
removeEventDispatcher(EventDispatcher eventDispatcher)
Removes the passed event dispatcher from the corresponding registration list.
|
com.google.common.collect.ImmutableList<Repository<?,?>> |
repositories()
Obtains the list of repositories added to the builder by the time of the call.
|
BoundedContextBuilder |
setAggregateRootDirectory(java.util.function.Supplier<AggregateRootDirectory> directory)
Sets the supplier of
AggregateRootDirectory -s to use in the built context. |
BoundedContextBuilder |
setTenantIndex(TenantIndex tenantIndex) |
ContextSpec |
spec()
Obtains the context spec.
|
SystemSettings |
systemSettings()
Obtains the configuration of the System context.
|
java.util.Optional<? extends TenantIndex> |
tenantIndex()
Obtains
TenantIndex implementation associated with the Bounded Context. |
public ContextSpec spec()
public io.spine.core.BoundedContextName name()
public boolean isMultitenant()
public java.util.Optional<? extends TenantIndex> tenantIndex()
TenantIndex
implementation associated with the Bounded Context.@CanIgnoreReturnValue public BoundedContextBuilder enrichEventsUsing(EventEnricher enricher)
Enricher
for events posted to
the EventBus
of the context being built.
If the Enricher
is not set, the enrichments
will NOT be supported in this context.
enricher
- the Enricher
for events or null
if enrichment is not supportedpublic java.util.Optional<EventEnricher> eventEnricher()
EventEnricher
assigned to the context to be built, or
empty Optional
if no enricher was assigned prior to this call.@CanIgnoreReturnValue public BoundedContextBuilder setTenantIndex(TenantIndex tenantIndex)
@CanIgnoreReturnValue public BoundedContextBuilder addCommandDispatcher(CommandDispatcher commandDispatcher)
CommandDispatcher
, but the BoundedContextBuilder.add(Repository)
method
should be preferred for this purpose.@CanIgnoreReturnValue public BoundedContextBuilder addCommandFilter(BusFilter<CommandEnvelope> filter)
The order of appending the filters to the builder is the order of the filters in
the CommandBus
.
public BoundedContextBuilder addCommandListener(Listener<CommandEnvelope> listener)
CommandBus
of the context being built.@CanIgnoreReturnValue public BoundedContextBuilder addEventDispatcher(EventDispatcher eventDispatcher)
EventDispatcher
, but the BoundedContextBuilder.add(Repository)
method
should be preferred for this purpose.@CanIgnoreReturnValue public BoundedContextBuilder addEventFilter(BusFilter<EventEnvelope> filter)
The order of appending the filters to the builder is the order of the filters in
the EventBus
.
filter
- the filter to addpublic BoundedContextBuilder addEventListener(Listener<EventEnvelope> listener)
EventBus
of the context being built.@CanIgnoreReturnValue public <I,E extends Entity<I,?>> BoundedContextBuilder add(java.lang.Class<E> entityClass)
@CanIgnoreReturnValue public BoundedContextBuilder add(Repository<?,?> repository)
@CanIgnoreReturnValue public BoundedContextBuilder removeCommandDispatcher(CommandDispatcher commandDispatcher)
@CanIgnoreReturnValue public BoundedContextBuilder removeEventDispatcher(EventDispatcher eventDispatcher)
@CanIgnoreReturnValue public <I,E extends Entity<I,?>> BoundedContextBuilder remove(java.lang.Class<E> entityClass)
@CanIgnoreReturnValue public BoundedContextBuilder remove(Repository<?,?> repository)
public com.google.common.collect.ImmutableList<Repository<?,?>> repositories()
Adding repositories to the builder after this method returns will not update the returned list.
public com.google.common.collect.ImmutableList<CommandDispatcher> commandDispatchers()
Adding dispatchers to the builder after this method returns will not update the returned list.
public com.google.common.collect.ImmutableList<EventDispatcher> eventDispatchers()
Adding dispatchers to the builder after this method returns will not update the returned list.
@CanIgnoreReturnValue public BoundedContextBuilder setAggregateRootDirectory(java.util.function.Supplier<AggregateRootDirectory> directory)
AggregateRootDirectory
-s to use in the built context.
By default, an in-mem implementation is used.
directory
- the supplier of aggregate root directoriespublic SystemSettings systemSettings()
With it, users are able to change the behavior of the system context.
public BoundedContext build()
BoundedContext
with the set configurations.
The resulting domain-specific Bounded Context has as internal System Bounded Context. The entities of the System domain describe the entities of the resulting Bounded Context.
The System Bounded Context shares some configuration with the Domain Bounded Context, such as:
All the other configuration is NOT shared.
The name of the System Bounded Context is derived from the name of the Domain Bounded Context.
BoundedContext