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
DELETErequests. - DianaApplication
- Marks the application entrypoint class.
-
Constrains a
Stringfield 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
GETrequests. - GlobalMiddleware
-
Registers a
Middlewareimplementation globally, applied to every route. - GrpcService
-
Registers a class extending a protoc-generated
XServiceBase(package:grpc'sService) as a gRPC service. - Header
- 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/toJsonfor this class — no boilerplate needed. - JsonField
-
Customizes the JSON key of a field inside a
@Jsonclass. - 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
Stringfield to contain at least one non-whitespace character. - NotEmpty
-
Constrains a
String,ListorMapfield to be non-empty. - NotNull
-
Constrains a field to be non-null. All other constraints skip
nullvalues, so combine them with NotNull (or a non-nullable type) when the field is required. - Patch
-
Maps a method to
PATCHrequests. - PathParam
- Binds a route-method parameter to a path parameter.
- Pattern
-
Constrains a
Stringfield to fully match a regular expression. - Post
-
Maps a method to
POSTrequests. - 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
Acceptheader allows (server preference order); nothing acceptable → 406. Method-level replaces controller-level; without the annotation, JSON. - Put
-
Maps a method to
PUTrequests. - 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
voidreturns). - 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
@MessageMappingmethod'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,ListorMapfield. - Table
-
Maps a
@Jsonentity class to a database table for Diana query repositories (DianaRepositoryin thediana_datapackage). - 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
Middlewareimplementations 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
Listof DTOs). - Value
-
Injects a configuration value (from
application.yaml, overridable via environment variables) into a constructor parameter. - WebSocketController
-
Registers a class implementing Diana's
WebSocketHandlerinterface as a WebSocket endpoint at path (Spring: aWebSocketHandlerregistered throughWebSocketConfigurer).
Enums
- Scope
- Lifecycle scope of an injectable class.