Annotation Interface Provision
Provisions are components that implement the functionality of the
features (Spring beans, Guice bindings, "services"). By default,
provisions are unscoped, i.e. a new instance will be created every time
the provision is requested. By declaring
@Provision(singleton=true), a single, lazily initialized instance
will be returned every time the provision is requested. Provision methods
cannot be final, as they will be extended in Configurations. They may be
abstract, in which case they'll be forwarded to an implementation found
in the Configuration.
According to the Java specification, annotations on methods are not
inherited. To comply to the constraints set by Java, the annotation
must be repeated on all overriding classes. The annotation processor
will report an error otherwise. Additionally, if a provision is
declared as singleton, this declaration must be repeated in overriding
methods, because otherwise, it would fall back to the default, i.e.
false. The annotation processor checks that a provision isn't
accidentally "downgraded" from singleton to unscoped, it's an error to
override a singleton provision with @Provision(singleton=false)
or just @Provision. It is possible to "downgrade" a singleton
provision to unscoped by additionally specifying the override attribute:
@Provision(singleton=false, override=true).
-
Optional Element Summary
Optional Elements
-
Element Details
-
singleton
boolean singleton- Default:
false
-
override
boolean override- Default:
false
-