diana_annotation library

Annotations for the Diana backend framework.

This package contains only const annotation classes and has no runtime behaviour. It is re-exported by package:diana/diana.dart; application code normally imports that instead.

Classes

Body
Binds a route-method parameter to the JSON request body.
Cacheable
Caches the method's result per argument list, in memory, per isolate (Spring's @Cacheable).
CircuitBreaker
Fails fast when the method keeps failing (spring-retry's @CircuitBreaker).
Component
A generic Injectable component (semantic alias).
ConfigurationProperties
Binds a whole configuration section to a class, which becomes injectable.
Consumes
Restricts the request content types a route (or every route of a controller) accepts. The body is decoded with the matching registered BodyCodec; other content types get a 415. Method-level replaces controller-level entirely; without the annotation, JSON is used.
ControllerAdvice
Marks a class as a global exception-handling component.
CrossOrigin
Enables CORS for a controller (all routes) or a single route, replacing the global server.cors.* policy entirely (route wins over controller, controller over global — no field merging).
Delete
Maps a method to DELETE requests.
DianaApplication
Marks the application entrypoint class.
Email
Constrains a String field to look like an email address.
EventListener
Marks a method as an application-event listener (Spring: @EventListener).
ExceptionHandler
Handles exceptions of type exception (and its subtypes) thrown by any route.
Get
Maps a method to GET requests.
GlobalMiddleware
Registers a Middleware implementation globally, applied to every route.
GrpcService
Registers a class extending a protoc-generated XServiceBase (package:grpc's Service) as a gRPC service.
Binds a route-method parameter to an HTTP request header.
HttpRoute
Base class for HTTP route annotations. Prefer the Get/Post/Put/ Delete/Patch shorthands.
Injectable
Marks a class as a provider in the dependency injection graph.
Json
Generates fromJson/toJson for this class — no boilerplate needed.
JsonField
Customizes the JSON key of a field inside a @Json class.
Max
Constrains a numeric field to be <= value.
MessageMapping
Handles STOMP messages sent to a destination under the app prefix (stomp.appPrefix, default /app) — Spring's @MessageMapping.
Min
Constrains a numeric field to be >= value.
Named
Selects a qualified provider for a constructor parameter.
NotBlank
Constrains a String field to contain at least one non-whitespace character.
NotEmpty
Constrains a String, List or Map field to be non-empty.
NotNull
Constrains a field to be non-null. All other constraints skip null values, so combine them with NotNull (or a non-nullable type) when the field is required.
Patch
Maps a method to PATCH requests.
PathParam
Binds a route-method parameter to a path parameter.
Pattern
Constrains a String field to fully match a regular expression.
Post
Maps a method to POST requests.
PostConstruct
Marks a method to run after the provider is constructed, during application initialization (Spring: @PostConstruct).
PreDestroy
Marks a method to run during graceful shutdown (Spring: @PreDestroy).
Principal
Binds the authenticated principal to a route-method parameter (Spring: @AuthenticationPrincipal).
Produces
Declares the response content types a route (or controller) can produce. The response is encoded with the first type the request's Accept header allows (server preference order); nothing acceptable → 406. Method-level replaces controller-level; without the annotation, JSON.
Put
Maps a method to PUT requests.
QueryParam
Binds a route-method parameter to a query-string parameter.
Repository
An Injectable that encapsulates data access (semantic alias).
ResponseStatus
Overrides the success status code of a route (default 200, or 204 for void returns).
RestController
Marks a class as an HTTP controller whose routes are mounted under path.
Retryable
Retries the method with a fixed backoff when it throws (spring-retry's @Retryable).
RolesAllowed
Requires an authenticated principal holding any of roles (JSR-250 semantics). Implies Secured: anonymous → 401, authenticated but missing every role → 403.
Scheduled
Runs a method on a fixed schedule (Spring: @Scheduled), started after application initialization and stopped during graceful shutdown.
Secured
Requires an authenticated principal to access the route(s).
SendTo
Publishes a @MessageMapping method's return value to a broker destination (Spring's @SendTo).
Service
An Injectable that expresses business logic (semantic alias).
Size
Constrains the length of a String, List or Map field.
Table
Maps a @Json entity class to a database table for Diana query repositories (DianaRepository in the diana_data package).
Timed
Records the method's invocation duration and outcome as metrics (and a trace span) via the app's observability provider (Micrometer's @Timed).
Transactional
Runs the method inside a database transaction (Spring: @Transactional).
UseMiddleware
Applies Middleware implementations to a controller (all its routes) or to a single route method, in the listed order.
Valid
Cascades validation into a nested DTO field (or a List of DTOs).
Value
Injects a configuration value (from application.yaml, overridable via environment variables) into a constructor parameter.
WebSocketController
Registers a class implementing Diana's WebSocketHandler interface as a WebSocket endpoint at path (Spring: a WebSocketHandler registered through WebSocketConfigurer).

Enums

Scope
Lifecycle scope of an injectable class.