- All Superinterfaces:
JStachioExtension
- All Known Implementing Classes:
JMustacheRenderer
,SpringJStachioExtension
An extension that is a factory that provides other extensions.
All methods are optional (default) so that implementations can decide what particularly
plugins/services they want to provide.
This is extension is useful if there is configuration logic that needs to happen before
creation. See
init(JStachioConfig)
and provideConfig()
.- Author:
- agentgt
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
init
(JStachioConfig config) Called before the extensions are used but afterprovideConfig()
.static JStachioExtensionProvider
of
(JStachioExtension extension) Creates a provider from an extension.default @Nullable JStachioConfig
Provide a config or not.default @Nullable JStachioFilter
Provide a filter or not.default @Nullable JStachioTemplateFinder
Provide a template finder or not.
-
Method Details
-
provideFilter
Provide a filter or not. The final filter is a composite and becomes a filter chain.- Returns:
- filter if this service provider provies one or
null
-
provideConfig
Provide a config or not. The final config is a composite of all the found configs.Specifically if multiple instances of
JStachioExtension
are found that return a nonnull they will be combined by looping through all of them to find a nonnull value forJStachioConfig.getProperty(String)
. If no configs are provided or no services foundJStachioExtensions
instance will use the default config which usesSystem.getProperties()
.- Returns:
- config if this service provides one or
null
- API Note
- This method is called before
init(JStachioConfig)
-
provideTemplateFinder
Provide a template finder or not. The final template finder is a composite of all the other ones found. SeeJStachioTemplateFinder.order()
for ordering details.If no template finders are provided then the default template finder that uses reflection and the ServiceLoader is used.
- Returns:
- template finder or not
-
init
Called before the extensions are used but afterprovideConfig()
. SeeprovideConfig()
on how the config is consolidated to a single config.- Parameters:
config
- the composite config never null
-
of
Creates a provider from an extension. If the extension is a provider than it is returned without wrapping. If the extension represent multiple types of extensions the returned provider will provide all of them.- Parameters:
extension
- the extension to be wrapped.- Returns:
- provider that will provide the extension
-