java.lang.Object
io.jstach.opt.spring.SpringJStachioExtension
- All Implemented Interfaces:
JStachioExtension,JStachioExtensionProvider
JStachio services based on Spring notably the config and
template finding.
- Author:
- agentgt
- API Note
- Although this is an extension it is not designed to be loaded by the
ServiceLoader.
-
Constructor Summary
ConstructorsConstructorDescriptionSpringJStachioExtension(JStachioConfig config, JStachioTemplateFinder templateFinder) Constructor for injectionSpringJStachioExtension(Environment environment, List<Template<?>> templates) Constructor for injection -
Method Summary
Modifier and TypeMethodDescriptionstatic JStachioConfigconfig(PropertyResolver propertyResolver) Creates a JStachio config from a property resolver (usuallyEnvironment).Provide a config or not.Provide a template finder or not.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.jstach.jstachio.spi.JStachioExtensionProvider
init, provideFilter
-
Constructor Details
-
SpringJStachioExtension
Constructor for injection- Parameters:
config- jstachio config seeconfig(PropertyResolver)templateFinder- template finder to use
-
SpringJStachioExtension
Constructor for injection- Parameters:
environment- springs environment to be used forJStachioConfigtemplates- templates found via spring
-
-
Method Details
-
config
Creates a JStachio config from a property resolver (usuallyEnvironment).- Parameters:
propertyResolver- wrapper property resolver- Returns:
- config
-
provideConfig
Provide a config or not. The final config is a composite of all the found configs.Specifically if multiple instances of
JStachioExtensionare 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 foundJStachioExtensionsinstance will use the default config which usesSystem.getProperties(). The config comes from SpringEnvironmentabstraction.- Specified by:
provideConfigin interfaceJStachioExtensionProvider- Returns:
- config if this service provides one or
null
-
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. The provided template finder instead of using reflection delegates to the templates wired in via spring.
- Specified by:
provideTemplateFinderin interfaceJStachioExtensionProvider- Returns:
- template finder or not
-