Skip to content

Annotations

weftkit's vocabulary is a handful of annotations plus the Loader interface. The processor validates how you use them during compilation.

@Registry

Marks the single class that anchors the wiring, usually your plugin main. The component registry is generated into its package, and the class itself is injectable as an ambient dependency along with any of its constructor parameters.

@Wired

Marks a class as created through the loader. Its constructor is the injection point, and the processor validates every parameter against the graph. A @Wired class must be a concrete, public, top-level or static nested class with exactly one public constructor.

@Singleton

Marks a @Wired component as created once and injected by type from then on. A plain @Wired component is created fresh for every injection instead. With lazy = true the singleton is created on its first injection instead of during load, and it cannot implement Loader or carry @Provides, @Initializes, or @Requires.

@Provides

Marks a public no-argument getter on a @Wired singleton. Its return value becomes an injectable dependency once the owner has loaded.

@Qualified

Distinguishes multiple dependencies of the same type. On a @Wired class or a @Provides getter it tags what is offered, and on a constructor parameter it selects the implementation or product carrying that tag.

@Initializes

Declares the static holders a @Wired singleton initializes during load. Components that require those holders load after it.

@Requires

Declares the static holders a component reads, ordering it after the singleton that initializes them.

Loader

Implement Loader to hook the lifecycle. load runs when the singleton is created, and returning false aborts startup. unload runs on shutdown in reverse load order. Only singletons may implement Loader, since a per-injection component would never have its load called.