public class RequestContext {
    private static final ScopedValue<String> REQUEST_ID = ScopedValue.newInstance();

    private static void record(String action) {
        System.out.println(REQUEST_ID.get() + ": " + action);
    }

    private static void prepareResponse() {
        record("catalog consulted");
    }

    public static void main(String[] args) {
        System.out.println("Before: " + REQUEST_ID.isBound());
        ScopedValue.where(REQUEST_ID, "P-17").run(RequestContext::prepareResponse);
        System.out.println("After: " + REQUEST_ID.isBound());
    }
}
