The runtime library
Generated code runs on elasticore-springboot3 (Spring Boot 3) or elasticore-springboot4
(Spring Boot 4). Both use the Java package io.elasticore.springboot3, so generated imports do
not change between Boot versions. Upgrade it together with the generator - the same version:
generated code uses runtime classes that older runtimes do not have.
Who is asking
| Class or field | What |
|---|---|
security.CurrentUser - currentUser.id(), signedIn(), hasRole("ADMIN") | who is asking, as the generated services see it; the default is SessionCurrentUser, a bean of yours replaces it (Spring Security) |
CurrentUser.runAsSystem(() -> ...) | the application itself: every @access check passes inside it - start-up data, a nightly job |
ACCESS.require(currentUser, "report") | fields of the generated service: the entity's @access for an operation of your own - 401 for a visitor, 403 for who may not; an operation the line does not name is the administrator's |
security.SessionCurrentUser.signIn(request, id, role), signOut(request) | the session the generated sign-in uses - for a flow of your own (sign up and sign in at once) |
security.AccessPolicy, security.PasswordHasher | beans you may replace (PBKDF2 is the default hasher) |
// the application itself creating an administrator at start-up
CurrentUser.runAsSystem(() -> customers.save(admin));
Value types
| Class | What |
|---|---|
domain.Money | the type of a money field. Money.of("10.00"), Money.of(bigDecimal) (null for null), plus, minus, times(long), times(Quantity), times(BigDecimal), rounded(2) (half-up), toBigDecimal(), isNegative(), compareTo. plus(null) / minus(null) return the same amount. Immutable; 10 and 10.00 are equal |
domain.Quantity | the type of a quantity field: never negative; minus below zero answers 422 not enough; plus, covers |
A 5.5 % VAT: net.times(new java.math.BigDecimal("0.055")).rounded(2).
Refusals
Exception (io.elasticore.springboot3.) | Answer |
|---|---|
validation.BadRequestException | 400 |
security.NotSignedInException | 401 |
security.ForbiddenException | 403 |
validation.NotFoundException (or jakarta.persistence.EntityNotFoundException) | 404 |
validation.ConflictException | 409 |
validation.InvariantViolationException | state. codes 409, reference. 404, others 422 |
http.PortCallException | 502 |
Each takes (code, message, args...) to be translated; see
API and error answers.
Plumbing you may meet
| Class | What |
|---|---|
EnableElastiCore | registers the port proxies (HTTP runtime mode, DBMS) |
validation.RequestShapeErrors | the problem+json answers before a controller - imported by the generated XxxApiErrors |
validation.ErrorMessages, BeanValidation | the message lookup in the request's language, service-side validation |
util.IdUtils.newId(n) | the @genid id generator |
entity.PersistentModel | the marker for mapping: xml domain classes (Kotlin all-open / no-arg) |
domain.Lookup | what derive(lookup) reads referenced rows with |