Results 1 to 5 of 5

Thread: DB messages and bean definitions

  1. #1
    Join Date
    Sep 2004
    Location
    Israel
    Posts
    6

    Default DB messages and bean definitions

    Is there currently any support for loading messages from a DB?
    It is easier to enable administrators to change messages on the fly for a running application.
    On the same subject, are there any plans to enable bean configuration through DB tables instead of XML? It would be great to be able to configure application context through DB tables and then force a reload of the context to enable dynamic bean additions and reconfigurations.

    Slavik.

  2. #2
    Join Date
    Aug 2004
    Location
    Toulouse, France
    Posts
    148

    Default

    So far, there is none afaik
    But it is easy to provide an implementation of MessageSource via the AbstractMessageSource in which you resolve message request by reading a value in database.
    I'll have a look at it this afternoon to provide a patch if you're interested.

    Olivier

  3. #3
    Join Date
    Sep 2004
    Location
    Israel
    Posts
    6

    Default

    I was thinking of a more complete solution enabling both messages and bean definitions to be specified in DB tables.
    Some things to consider:
    1. Locale sensitive messages
    2. Caching - enabling invalidates
    3. Dirty table to mark changes in DB tables
    4. Reload on demand hooks
    5. Probably more stuff...

    If there are more users interested in such a solution, perhaps this can be designed and added to Spring officially.

    Slavik.

  4. #4
    Join Date
    Aug 2004
    Location
    Toulouse, France
    Posts
    148

    Default

    A basic solution isn't that bad :
    1. MessageSource are locale sensitive
    the table could be message VARCHAR(xx), locale VARCHAR(xx)
    hence the sql code uses either the code and the locale to grab a message. If not found, we could revert to query where the locale IS NULL.
    2. It can be useful indeed, but isn't it as expensive as the real query ? Caching is only useful if the checking of caching is significantely faster than the real job in itself. So, regarding point 3, a dirty table is likely to be useless as a SELECT dirty FROM dirty_table WHERE code=? AND locale=? is as expensive as the real SELECT message FROM message_source_...
    Eventually, a timed cache can be used. For instance, for one minute, if the code has been resolved, it would trigger an sql query.
    4. easy and useful method, right, just like the ReloadableRessourceBundleMessageSource implementation
    5. I don't see much thing there, eventually whether a missing message for the given code and locale should try with locale IS NULL or directly return a missing message.

  5. #5
    Join Date
    Nov 2004
    Location
    Netherlands
    Posts
    1

    Default

    What about extending the messages?

    For a portal application I would like the messages to have a priority, start/enddate and to which site the message applies because a message could apply to only one site in the portal and not to others.

    I'm thinking about either extending the MessageSource to provide a Message object which also holds info about priority so you can for example change the color in the display depending on priority. This would also need a new tag to retrieve this Message.
    Or I'm thinking about adding the site and priority to the message key. But this has the disadvantage that you would need to query for all priotities.

Similar Threads

  1. Replies: 4
    Last Post: Oct 5th, 2005, 11:04 AM
  2. sessionFactory bean created twice by hibernateDao
    By dthompson in forum Security
    Replies: 2
    Last Post: Aug 24th, 2005, 07:45 AM
  3. Velocity OutOfMemoryError during UnitTests
    By camach in forum Container
    Replies: 2
    Last Post: May 26th, 2005, 05:28 PM
  4. DefaultAdvisorAutoProxyCreator skipping beans
    By youngm in forum Container
    Replies: 6
    Last Post: Apr 12th, 2005, 04:29 PM
  5. Replies: 1
    Last Post: Apr 8th, 2005, 07:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •