Package io.jstach.opt.spring.boot.webmvc
Class JStachioConfiguration
java.lang.Object
io.jstach.opt.spring.boot.webmvc.JStachioConfiguration
@Configuration
@EnableConfigurationProperties(JStachioProperties.class)
public class JStachioConfiguration
extends Object
Configures JStachio Spring style.
Templates are loaded from the ServiceLoader and are then registered in the ApplicationContext. Extensions that are wired by Spring will also be discovered as well as ServiceLoader based extensions that are not already wired as beans.
- Author:
- agentgt, dsyer
- API Note
- while this class and methods on this class are public for Spring reflection it is not intended to be true public API.
-
Constructor Summary
ConstructorDescriptionJStachioConfiguration
(ConfigurableListableBeanFactory beanFactory) Do nothing constructor to placate jdk 18 javadoc -
Method Summary
Modifier and TypeMethodDescriptionconfig
(Environment environment) Resolve config from spring environmentjstachio
(List<JStachioExtension> extensions) Creates jstachio from found pluginsmessageConverter
(JStachio jstachio, JStachioProperties properties) Creates a message converter from Spring JStachiospringJStachioExtension
(JStachioConfig config, JStachioTemplateFinder templateFinder) Creates a services based on spring objects.The default template config is empty and will let each template resolve its own config.templateFinder
(JStachioConfig config, TemplateConfig templateConfig) Resolve template finder configstemplatesByServiceLoader
(TemplateConfig templateConfig) Templates found with the service loader
-
Constructor Details
-
JStachioConfiguration
Do nothing constructor to placate jdk 18 javadoc- Parameters:
beanFactory
- used to register the serviceloader found templates
-
-
Method Details
-
templatesByServiceLoader
Templates found with the service loader- Parameters:
templateConfig
- used to create singleton templates- Returns:
- templates
- See Also:
-
config
@Bean @ConditionalOnMissingBean(JStachioConfig.class) public JStachioConfig config(Environment environment) Resolve config from spring environment- Parameters:
environment
- for properties- Returns:
- config
-
templateFinder
@Bean @ConditionalOnMissingBean(JStachioTemplateFinder.class) public JStachioTemplateFinder templateFinder(JStachioConfig config, TemplateConfig templateConfig) Resolve template finder configs- Parameters:
config
- jstachio configtemplateConfig
- the template config- Returns:
- spring powered template finder
-
templateConfig
The default template config is empty and will let each template resolve its own config. The template config contains an optional formatter (nullable) and optional escaper (nullable). If a template config is provided as a bean somewhere else it will replace this default. The only time this could be of use is if you needed a formatter or escaper with custom wiring.- Returns:
- empty template config.
- See Also:
-
springJStachioExtension
@Bean public SpringJStachioExtension springJStachioExtension(JStachioConfig config, JStachioTemplateFinder templateFinder) Creates a services based on spring objects.- Parameters:
config
- used for configtemplateFinder
- used to find templates- Returns:
- spring powered jstatchio extension provider
- See Also:
-
jstachio
@Bean @ConditionalOnMissingBean(JStachio.class) public SpringJStachio jstachio(List<JStachioExtension> extensions) Creates jstachio from found plugins- Parameters:
extensions
- plugins- Returns:
- spring version fo jstachio
-
messageConverter
@Bean @ConditionalOnMissingBean(JStachioHttpMessageConverter.class) public JStachioHttpMessageConverter messageConverter(JStachio jstachio, JStachioProperties properties) Creates a message converter from Spring JStachio- Parameters:
jstachio
- jstachio instanceproperties
- spring boot powered properties- Returns:
- jstachio message converter
-