Home / Modules / yoja-core

yoja-core

The runtime foundation. Application lifecycle, worker thread pools, task scheduling, async helpers, and the HTTP primitive value objects shared by every other module — all built on Vert.x.

Installation

implementation 'com.easygoingapi:yoja-core:VERSION'

yoja-core is pulled transitively by every other Yoja module, so you rarely need to declare it explicitly.

YojaApp: Application Lifecycle

YojaApp owns the shared Vert.x instance every module dials through. One start() per JVM.

import com.easygoingapi.yoja.core.YojaApp;

public class Main {
    public static void main(String[] args) {
        YojaApp.start();
        // ... build your router / server / clients here
    }
}

YojaApp class

Process-wide bootstrap. Starts and exposes the singleton Vert.x runtime.

Lifecycle
SignatureReturnsDescription
static start()voidInitialise the runtime with defaults; no-op if already started
static builder()BuilderFluent builder for custom VertxOptions, default timeouts, etc.
static restart()Future<Void>Close and re-initialise the runtime
static logVertxConfig()voidDump effective Vert.x options to the log
Accessors
SignatureReturnsDescription
static vertx()VertxThe shared Vert.x instance used by every module
static isStarted()booleantrue once start() has been called
static defaultTimeout()DurationProcess-wide default timeout for futures

Worker: Background Thread Execution

Worker provides two named thread pools whose work never runs on the event loop. singleThread serialises work by key (one-at-a-time semantics); parallelThread runs work concurrently up to the pool size.

Worker class

Two public, statically initialised pools. Neither pool runs work on the Vert.x event loop.

Worker.singleThread — serialises by key
SignatureReturnsDescription
once(key, runnable)voidRun at most one task per key concurrently; additional triggers dedupe or queue
schedule(key, supplier)FutureVariants accepting Future / Supplier
close()voidGraceful shutdown
Worker.parallelThread — concurrent pool
SignatureReturnsDescription
execute(runnable)voidFire-and-forget execution
submit(callable)FutureReturns a Future for the result
close()voidGraceful shutdown

Timer: Task Scheduling

A small scheduler covering one-shot delays, recurring periods, fixed-rate runs, calendar dates, and worker-pinned execution.

Timer.schedule("stats", t -> taskService.logStats())
     .period(Duration.ofSeconds(30))
     .build();

Timer class

Fluent task scheduler built on Vert.x' periodic / timer primitives.

Factory
SignatureReturnsDescription
static schedule(String id, Consumer<Task> action)BuilderNamed task
static schedule(Consumer<Task> action)BuilderAuto-sequenced task (no explicit id)
static cancelAll()voidCancel every active scheduled task
Builder
SignatureReturnsDescription
delay(Duration)BuilderInitial delay before the first fire
period(Duration)BuilderRecurring fire interval
fixedRate(Duration)BuilderDrift-compensating recurring fire
at(Instant)BuilderFirst fire at a specific absolute date/time
on(Worker)BuilderPin execution to a worker pool instead of the event loop
build()TaskMaterialise and start the scheduled task

FutureUtil: Async Helpers

Synchronous helpers for tests and CLI entry points. Never call await from a Vert.x event-loop thread.

FutureUtil class

Static helpers that bridge the async world with blocking call sites. Never call from a Vert.x event-loop thread.

SignatureReturnsDescription
static await(Future<?>)voidBlock until the future completes
static <V> awaitValue(Future<V>)VBlock and return the resolved value
static await(List<Future<?>>)voidBlock until every future in the list completes
static sleep(long millis)voidWorker-thread-safe sleep; does not block the event loop

HTTP primitives

Value objects shared by every HTTP-related module (server, client, reverse-proxy). They model URLs, parameters, headers, cookies, and encoding helpers without depending on Vert.x in their public API.

HttpUrl class

Immutable URL value object: protocol, host, port, path, query, fragment. Built through a fluent builder.

Builder
SignatureReturnsDescription
static builder(String host)BuilderStart a new URL for the given host
protocol(HttpProtocole)Builder
port(int)Builder
path(String)Builder
parameterQuery(String)BuilderRaw query string
fragment(String)Builder
build()HttpUrlMaterialise the value
Accessors
SignatureReturnsDescription
url(Format)StringFull URL string, encoded or decoded
pathAndQuery(Format)StringPath + query portion only
host()String
port()int
path()String
parameterQuery(Format)StringRaw query string, encoded or decoded
fragment(Format)String

HttpParameter class

Multimap for HTTP query parameters. Preserves duplicate names. Parsed from raw text or built from named entries.

Factory & mutation
SignatureReturnsDescription
static parse(String raw)HttpParameterURL-decode and parse a raw query string
addEntry(name) · addEntry(name, value) · addEntries(name, List)voidAppend entries (keeps duplicates)
putEntry(name) · putEntry(name, value) · putEntries(name, List)voidReplace all entries with the same name
Accessors
SignatureReturnsDescription
entries()List<Entry>Full ordered entry list
values(name)List<String>All values for the given name
firstValue(name)StringFirst value, or null
hasName(name)boolean
names()Set<String>Distinct parameter names
parameterQuery(Format)StringRender as a raw query string

HttpHeader class

Name → single-value header map. Case-aware on insertion; case-insensitive on lookup.

SignatureReturnsDescription
put(name, value)voidSet or replace a header
get(name)StringValue or null (case-insensitive lookup)
has(name)boolean
remove(name)void
values()Map<String,String>All headers as a map
names()Set<String>
size()int
isEmpty()boolean

HttpCookie class

Full Set-Cookie value object. Comparable; usable in sorted sets.

Builder
SignatureReturnsDescription
static builder(String name, String value)Builder
domain(String) · path(String) · maxAge(long)Builder
httpOnly(boolean) · secure(boolean) · sameSite(CookieSameSite)Builder
build()HttpCookie
Accessors
SignatureReturnsDescription
getName() · getValue()String
getDomain() · getPath()String
getMaxAge()longMax age in seconds; -1 = session cookie
isHttpOnly() · isSecure()boolean
getSameSite()CookieSameSite

HttpEncoding class

URL-encoding helpers and the Format enum used throughout the HTTP primitives.

SignatureReturnsDescription
enum Format { encoded, decoded }Controls how URL components are rendered throughout the API
static urlEncode(String)StringPercent-encode a string
static urlDecode(String)StringDecode a percent-encoded string

HttpMethod · HttpProtocole · HttpCertificate · ContentType enums

Small enums shared across all HTTP modules.

TypeValuesDescription
HttpMethodGET, POST, PUT, DELETE, PATCH, …Standard HTTP verbs
HttpProtocolehttp, https, ws, wssProtocol scheme
HttpCertificateNONE, SSL, SELF_SIGNEDTLS strategy for servers
ContentTypejsonObject, jsonArray, text, …Pre-baked MIME constants; key() = "Content-Type", value() = MIME string

Certificatable interface

Implemented by every server that supports hot TLS rotation.

SignatureReturnsDescription
keyPath()PathPath to the currently active private key
certificatePath()PathPath to the currently active certificate
updateCertificate(Path keyPath, Path certPath)Future<Boolean>Hot-swap TLS material without restarting the server

Other utilities

Smaller helpers used across the framework.

StringUtil · TimeUtil · PathUtil · ResourceUtil · ProcessUtil · JavaReflectUtil utility classes

ClassKey methodsDescription
StringUtilNull-safe trim/blank checks, splitting, padding
TimeUtilprettyPrint(Duration)Human-readable duration; instant ↔ epoch helpers
PathUtilForward-slash normalisation, prefix stripping
ResourceUtilread(String classpathPath)Read a jar-bundled text resource as a String
ProcessUtilCurrent-process introspection helpers
JavaReflectUtilInternal reflection accessor used by the framework (not for application use)

YojaAppException

YojaAppException runtime exception

Common base of every framework-thrown unchecked exception. Catch this to handle "anything Yoja threw".

SignatureDescription
YojaAppException(String message)Message-only form
YojaAppException(String message, Throwable cause)Wrapping form

For the full code-level reference, see the module's README on GitHub and the Javadoc-annotated source under yoja-core/src/main/java/.