liveBook · Manning

Recorder

As explained in Quarkus in Action

A Quarkus recorder is an extension class whose methods define runtime logic that can be recorded as bytecode during the build.

A recorder bridges the build-time and runtime halves of a Quarkus extension. Its runtime-module methods contain application logic, but calls made during a processor build step record the method’s bytecode instead of executing it immediately. section 12.2.2 section 12.6

A recorder participates in extension processing as follows:

  • Place the recorder in the runtime module and annotate the class with @Recorder. section 12.2.2 section 12.3.4
  • Accept build-time values as method arguments; constructed objects and their creation steps are serialized into the packaged application. section 12.2.2
  • Call the recorder from a processor build step, which receives a proxy representing the recorded runtime value. section 12.2.2 section 12.3.5
  • Choose STATIC_INIT or RUNTIME_INIT; STATIC_INIT can run during native image construction and improve native startup when the operation permits it. section 12.3.5 section 12.6

Metadata handler recorder

MetadataExtensionRecorder.createHandler(String data) returns a new MetadataHandler(data). The processor computes metadata JSON during the build, passes it to the recorder, and packages the handler-construction steps so the data is inlined rather than recomputed during application startup. section 12.3.4 section 12.3.5

Listing 12.8 The recorder for the Metadata extension
package org.acme.metadata.extension.runtime;

import io.quarkus.runtime.annotations.Recorder;
import io.vertx.core.Handler;
import io.vertx.ext.web.RoutingContext;

@Recorder
public class MetadataExtensionRecorder {
    public Handler<RoutingContext> createHandler(String data) {
        return new MetadataHandler(data);
    }
}

The recorder listing shows the minimal runtime-module class, annotation, method signature, and recorded handler construction. section 12.3.4

How Quarkus in Action covers it

How deep it goes
Defines module placement, bytecode serialization, proxy values, and initialization phases, while deferring direct generation to Gizmo.
Examples
Uses MetadataExtensionRecorder to inline JSON data while constructing a MetadataHandler for an HTTP route.
What you can do after
Build it from scratch by annotating a runtime class and invoking it from a recorded processor build step.
How it connects
Connects processors, build steps, build items, runtime modules, native images, and JVM application startup.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quarkus in Action. The section links point to the parts of the book it draws on.