Class SokletProcessor

All Implemented Interfaces:
Processor

Soklet's standard annotation processor. It generates lookup tables for Resource Method definitions, generated public-API-only MCP endpoint adapters and their classpath index, and reports usage errors detectable by static analysis.

Compile each Java module in its own compiler invocation. A single javac --module-source-path invocation spanning multiple modules is not supported because generated discovery indexes require one class-output root. Ordinary Maven and Gradle builds that compile modules separately are supported.

This Annotation Processor ensures Resource Methods annotated with SseEventSource are declared as returning an instance of SseHandshakeResult. It validates HTTP/SSE path syntax using ResourcePathDeclaration, reporting malformed, partial-component, duplicate-name and non-final varargs placeholders on the annotated method before generating its route entry. HTTP/SSE parameters may declare only one Soklet binding annotation. Optional value bindings require reference types; path bindings cannot use Optional, and varargs path bindings require String. Application qualifiers and custom converter types remain eligible.

Your build system should ensure this Annotation Processor is available at compile time. Follow the instructions below to make your application conformant:

Using javac directly:

javac -parameters -processor com.soklet.SokletProcessor ...[rest of javac command elided]
Using Maven:
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>...</version>
    <configuration>
        <release>...</release>
        <compilerArgs>
            <!-- Rest of args elided -->
            <arg>-parameters</arg>
            <arg>-processor</arg>
            <arg>com.soklet.SokletProcessor</arg>
        </compilerArgs>
    </configuration>
</plugin>
Using Gradle:
def sokletVersion = "4.0.0" // (use your actual version)

dependencies {
  // Soklet used by your code at compile/run time
  implementation "com.soklet:soklet:${sokletVersion}"

  // Same artifact also provides the annotation processor
  annotationProcessor "com.soklet:soklet:${sokletVersion}"

  // If tests also need processing (optional)
  testAnnotationProcessor "com.soklet:soklet:${sokletVersion}"
}

Incremental/IDE ("IntelliJ-safe") behavior

  • Merges the current compilation into one prior HTTP/SSE snapshot: CLASS_OUTPUT first, then the enabled sidecar and persistent caches as fallbacks. An empty current snapshot is authoritative.
  • Replaces entries for touched top-level types and removes retained HTTP/SSE owners absent from the compiler's sources/classpath. Untouched visible types, nested types and dependency JAR owners remain eligible.
  • A selected HTTP/SSE snapshot that cannot be read completely or contains malformed rows causes a compiler diagnostic and is not overwritten with partial metadata.
  • Declares wildcard annotation support, while claiming no annotations, so a compiler still invokes it when a touched type removes its final Soklet annotation.
  • Skips publishing HTTP/SSE and MCP indexes when an annotation-processing diagnostic is already known. Later javac errors, including errors in method bodies, are outside this processing-phase guarantee; use a clean build after a failed compilation.
  • Writes with originating elements (best-effort) so incremental build tools can track dependencies.

Processor options

  • -Asoklet.cacheMode=none|sidecar|persistent (default: sidecar)
  • -Asoklet.cacheDir=/path (used only when cacheMode=persistent; required to enable persistent)
  • -Asoklet.pruneDeleted=true|false (default: false; generally not IDE-safe)
  • -Asoklet.debug=true|false (default: false)

For incremental HTTP/SSE and annotated MCP compilation, untouched owners must remain visible on the compiler's source path or classpath. A deleted source whose old classfile is still visible remains a resolvable type; remove that old output or perform a clean build. The optional soklet.pruneDeleted setting additionally checks classfile presence in CLASS_OUTPUT and is stricter than normal compiler-visibility cleanup. If a cache cannot be updated or invalidated, compilation fails rather than leaving a usable stale fallback. That diagnostic can follow publication of a CLASS_OUTPUT index; discard failed compiler output and use a clean build before packaging it.

Important: This processor will never create a project-root .soklet directory by default. Persistent caching is only enabled when cacheMode=persistent and soklet.cacheDir is set. Persistent cache keys and generated MCP provider names use SHA-256. When upgrading from a processor that used SHA-1 cache keys, perform a clean, complete compilation to rebuild all route and endpoint metadata; an older persistent snapshot alone cannot supply unchanged owners during a partial compilation.

Author:
Mark Allen