AggregateRoute

annotation class AggregateRoute(val resourceName: String = "", val enabled: Boolean = true, val owner: AggregateRoute.Owner = Owner.NEVER)

Configures routing and ownership behavior for aggregate operations.

This annotation defines how aggregate instances are accessed and managed in terms of:

  • Resource naming for API endpoints

  • Ownership policies for multi-tenant scenarios

  • Route generation for REST APIs

The routing configuration affects how commands are dispatched and how API endpoints are generated for the aggregate.

Example usage:

@AggregateRoot
@AggregateRoute(
resourceName = "orders",
owner = AggregateRoute.Owner.AGGREGATE_ID
)
class OrderAggregate(
@AggregateId
val orderId: String,

@OwnerId
val customerId: String
)

This generates routes like: POST /orders/{orderId}/create

Parameters

resourceName

Custom name for the resource in API routes. If empty, the aggregate class name (lowercased) will be used. This affects URL generation.

enabled

Whether routing is enabled for this aggregate. When false, no routes will be generated. Defaults to true.

owner

Ownership policy determining tenant isolation. Controls whether operations require owner context and how ownership is determined.

See also

for available ownership policies

for marking aggregate root classes

Types

Link copied to clipboard

Defines ownership policies for aggregate operations in multi-tenant scenarios.

Properties

Link copied to clipboard
val enabled: Boolean = true
Link copied to clipboard
Link copied to clipboard