Class CommonExtensionI18nAutoConfiguration.CommonExtensionMessageSourceCreator
java.lang.Object
com.broadleafcommerce.common.extension.i18n.autoconfigure.CommonExtensionI18nAutoConfiguration.CommonExtensionMessageSourceCreator
- Enclosing class:
- CommonExtensionI18nAutoConfiguration
@Configuration
@EnableConfigurationProperties
public static class CommonExtensionI18nAutoConfiguration.CommonExtensionMessageSourceCreator
extends Object
In the event that a user wants to define their own custom bundle, we want to allow
them to name it
messages.properties
for their convenience. As a result, we
will give our default bundle a different basename rather than calling it
messages.properties
.
We also append our default bundle using a MessagesDefaultBasenameAddingPostProcessor
,
so that it is added even if the user assigns their own custom basenames.
However, MessageSourceAutoConfiguration
will only register a MessageSource
if
the classpath has a messages.properties
, or one of the sources listed in
MessageSourceProperties.basename
. Since we append our default basename after
initialization, both of these conditions could not be met.
As a result, we will manually create a MessageSource
if it is not already present.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.context.MessageSource
messageSource
(org.springframework.boot.autoconfigure.context.MessageSourceProperties properties) If there is not a message source, I need to define one for the default messages.org.springframework.boot.autoconfigure.context.MessageSourceProperties
-
Constructor Details
-
CommonExtensionMessageSourceCreator
public CommonExtensionMessageSourceCreator()
-
-
Method Details
-
messageSourceProperties
@Bean @ConditionalOnMissingBean(value=org.springframework.context.MessageSource.class, search=CURRENT) @ConfigurationProperties(prefix="spring.messages") public org.springframework.boot.autoconfigure.context.MessageSourceProperties messageSourceProperties() -
messageSource
@Bean("messageSource") @ConditionalOnMissingBean(value=org.springframework.context.MessageSource.class, search=CURRENT) public org.springframework.context.MessageSource messageSource(org.springframework.boot.autoconfigure.context.MessageSourceProperties properties) If there is not a message source, I need to define one for the default messages. This comes _directly_ fromMessageSourceAutoConfiguration#messageSource()
-