开发者

Dynamic Spring Message Source

开发者 https://www.devze.com 2023-02-16 05:46 出处:网络
I\'m about to extend org.springframework.context.support.AbstractMessageSource that will allow me to dynamically add and edit messages in Spring. I\'m planning on storing these values in a database. I

I'm about to extend org.springframework.context.support.AbstractMessageSource that will allow me to dynamically add and edit messages in Spring. I'm planning on storing these values in a database. Is there something out there that does this already? Is there a different approach I should think of?

Here are the requirements:

  • I have to be able to add messages
  • 开发者_JAVA百科
  • I have to be able to edit messages
  • These adds and edits should take place immediately


Sure.

Develop custom MessageSource and set it as parent to existing (for example based on property files).

    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basenames">
        <list>
            <value>message/messages</value>
        </list>
    </property>

    <property name="parentMessageSource">
        <bean class=com.example.DatabaseMessageSource"/>
    </property>
</bean>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号