pequenino
Visionary Software Solutions Rooter @Pequenino registration annotations: the user-facing (service, implementation) annotations, split out so adopters can depend on just the annotations without the processor.
@Pequenino is the user-facing registration annotation for the piggies service-provider-registry mechanism — a single (service, implementation) pair, placed on a module-info or package-info, that the human processor picks up at compile time.
Rationale
Why. Bloch's Service Provider Framework (Effective Java, Item 1) needs a registry per service. The piggies mechanism collapses them into one annotation (@Pequenino), one provider processor (human), and one aggregation processor (rooter). This module carries only the annotations, so a module that declares registrations depends on pequenino alone, without the processor.
Both annotations carry @Retention(RUNTIME), yet a processor consumes them during compilation, so a module wearing them runs without this one on its path.
The human processor reads each @Pequenino and writes one service\timplementation line to META-INF/rooter/registrations in the provider's jar. The rooter processor later reads every such resource across the processor classpath (via getResources) and generates one <Service>MotherTree per service: an enum implementing Registry<Class<? extends S>, Supplier<? extends S>> and Iterable<Supplier<? extends S>>.
The wire-format types (Registrations, Registration, RegistrationSerializationStrategy) live in registrations.
Place @Pequenino on a module-info (module-wide) or a package-info (package-wide). The annotation is @Repeatable, not an array: each @Pequenino names exactly one pair, keeping every registration self-contained and independently readable.
This module contains no processor logic, so declaring a registration costs no processor closure. human validates registrations at build time; misconfiguration fails the build rather than surfacing at runtime.
Key Concepts
Pequenino
Role. Registers an implementation() of a service() into that service's generated MotherTree registry: names one (service, implementation) pair. @Repeatable, so multiple registrations can stack on one target.
Pattern. Annotation
Pequeninos
Role. The @Repeatable container; authored implicitly by the compiler when more than one @Pequenino appears.
Pattern. Container annotation
Lane
Purpose. Declaring a service implementation on a module or package, for a compile-time registry to be generated from.
Alternative. A provides ... with clause in module-info, when java.util.ServiceLoader finding providers at run time is enough.
Usage
Usage
// module-info.java — compile-only; the annotation is not needed at runtime
requires static software.visionary.piggies.pequenino;Placement: several registrations stack on one module
// provider-module/src/main/java/module-info.java
@Pequenino(service = Codec.class, implementation = Json.class)
@Pequenino(service = Codec.class, implementation = Yaml.class)
module example.codecs {
requires static software.visionary.piggies.pequenino;
}Caveats
- The
implementationmust be a concrete class with a public no-arg constructor, a class singleton reached through a public staticINSTANCEorgetInstance(), or an enum singleton. Thehumanprocessor validates this at build time and fails the build loudly for anything else.
Views
Drawn from the release. A link in a view opens its source at the release tag.