Turbine provides a number of annotations to inject dependencies into your actions,
screens and layouts. All Assemblers
that is, all modules of type
Action
, Screen
, Layout
, Page
,
Navigation
and ScheduledJob
as well as all
Valves
in the pipeline support the injection of services,
configurations and loaders. This relieves you from the burden of looking
them up at runtime and thus simplifies and accelerates the code.
@TurbineService
gets injected an instance of this service at the time the instance
of the class is created. The field should have the type of the service
interface like in the following two examples:
This is the equivalent of
As you an see, the annotation supports an optional parameter, the
name of the service in the Turbine service repository. If this
parameter is not present, the annotation processor will look
for the field SERVICE_NAME
and then ROLE
in the type class of the field to retrieve the service name. If none
of them can be found, the fully qualified class name of the
service interface is used to look up the service.
Configuration
is annotated
with @TurbineConfiguration
, Turbine will inject an instance
of the Turbine configuration object at the time the instance of the class
is created.
This is the equivalent of
The annotation supports an optional parameter, the
prefix of the configuration subset to retrieve.
@TurbineConfiguration
, Turbine will inject the corresponding
configuration value. In this case, the annotation parameter defines the
configuration key and is required. Strings, Lists and most simple types
are supported. The value will only be set if the key is found in the
configuration, so that the field can be initialized with a default value.
This is the equivalent of
@TurbineLoader
gets injected an instance of the specified Loader
at
the time the instance of the class is created. The field should have
the type of the loader.
This is the equivalent of
The annotation parameter is required and defines the type of module
that is to be loaded.
@TurbineActionEvent
is associated to a named action event. The annotation parameter
is required and defines the name of the event. See the
Action Events Howto
for usage and examples.
module.cache
to true
in
TurbineResources.properties
.