Annotation Interface Injected
Marks a transient, non-final instance field of a reference type to be populated from the local
environment when an injection driver claims the object (deserialised by the communication layer
or, in the future, created by the registry). A static field is refused: populating one would
write state of the class, shared across every instance and outliving what the driver claimed; a
primitive field is refused as well, since no binding yields a primitive. Which instances a driver
claims is the driver's rule, not the annotation's: for the deserialisation driver it is being
InjectionAware, and on an instance no driver claims the annotation is inert. Population
and InjectionAware.afterInjection() run before the received session is validated and must
stay free of side effects beyond the object itself.
Resolution is by the effective type – type() if given, else the declared
field type – plus the optional qualifier: never by the field name and never by anything
from the byte stream. The effective type also selects the binding kind: an object the registry
provides itself, a service of the registry, a logger or an executor. Not every kind is served
yet. A service needs the instance using it – a registry resolves one for an
instance, never in the abstract – and the lookup taking that instance does not exist yet,
so a declaration of the service kind stays unavailable: a tolerant field keeps what it has, a
required one fails the claim.
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionAn optional qualifier: the hierarchical instance name of a service (/<componentType>/<instance>), the name of a thread pool (mandatory for executors) or the logger name (default: the declaring class); empty = resolve by type (and, for loggers, declaring class) only.booleanWhether the driver's processing fails if the binding is not available.Class<?>The type to resolve the binding by, e. g.Class<?>[]The type arguments of the effective type, in pre-order: each class is followed by the arguments of its own type parameters.
-
Element Details
-
name
String nameAn optional qualifier: the hierarchical instance name of a service (/<componentType>/<instance>), the name of a thread pool (mandatory for executors) or the logger name (default: the declaring class); empty = resolve by type (and, for loggers, declaring class) only. In every kind it is the name in the form its namespace uses: pool and logger namespaces are flat, the service namespace is hierarchical.- Returns:
- The qualifier selecting the instance among those of the effective type or the empty string to resolve by type only.
- Default:
- ""
-
type
Class<?> typeThe type to resolve the binding by, e. g. the specific type a component is registered with when the field is declared with a supertype only. Must be assignable to the field type.void.class(the default) resolves by the declared field type; a field cannot bevoid, so the sentinel never collides with a real binding type.- Returns:
- The type to resolve the binding by or
void.classto use the declared field type.
- Default:
- void.class
-
typeArgs
Class<?>[] typeArgsThe type arguments of the effective type, in pre-order: each class is followed by the arguments of its own type parameters. Empty (the default) takes the arguments from the field's generic signature; needed only where the signature cannot pin them, that is together withtype()or for a declaration using a type variable.- Returns:
- The type arguments of the effective type in pre-order or an empty array to take them from the generic signature of the field.
- Default:
- {}
-
required
boolean requiredWhether the driver's processing fails if the binding is not available. Tolerant fields staynulland the class must behave sensibly with that. This governs availability only: a declaration the environment cannot honour at all – a type not matching the binding – fails the processing whatever this says.- Returns:
- Whether the driver's processing fails if the binding is not available.
- Default:
- false
-