Uploaded image for project: 'Seam International'
  1. Seam International
  2. SEAMINTL-15

DB-based messages and other external sources

    Details

    • Type: Feature Request
    • Status: Pull Request Sent (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 3.2.0.Alpha1
    • Component/s: Messages
    • Labels:
      None

      Description

      (hope this is not an obsolute one)

      Refactor the producing of the messages so that you could e.g. specialize a producer method if you want to produce messages from a DB. Currently the only way is to write an extension that loads the stuff and explicitly places the messages in the appscoped component.

        Gliffy Diagrams

          Activity

          Hide
          nickarls Nicklas Karlsson added a comment -

          One way of doing this would perhaps to @Inject an Instance of something into Bundles and then have a @PostConstruct or @Inject constructor check if there is something injected that would then be assimilated. This something could perhaps be a Map<String, ResourceBundle> that would be passed along to putAll. Users could then write producers for resource bundles they'd like automatically made available.

          Show
          nickarls Nicklas Karlsson added a comment - One way of doing this would perhaps to @Inject an Instance of something into Bundles and then have a @PostConstruct or @Inject constructor check if there is something injected that would then be assimilated. This something could perhaps be a Map<String, ResourceBundle> that would be passed along to putAll. Users could then write producers for resource bundles they'd like automatically made available.
          Show
          kenfinni Ken Finnigan added a comment - Copied from SEAMINTL-7 , comments from Dan on how this could be achieved: I think we draw from a proposal Pete once put together: http://in.relation.to/Bloggers/StoringYourMessagesInADatabase And another for CDI by a couple different people: http://in.relation.to/Bloggers/AnotherNicePortableExtension https://github.com/softwaremill/softwaremill-common/blob/master/softwaremill-cdi/src/main/java/pl/softwaremill/common/cdi/config/ConfigExtension.java http://www.andygibson.net/blog/article/injecting-string-resource-services-with-cdi/
          Hide
          nickarls Nicklas Karlsson added a comment - - edited

          It could be done quite cheap with a

          public interface BundleLoader
          {
          	public ResourceBundle loadBundle(Locale locale, String key);
          }
          

          And in ApplicationBundles

          @Inject
          BundleLoader loader;
          

              public ResourceBundle get(final Locale locale, final Object key) {
                  containsLocaleMap(locale);
                  if (!bundles.get(locale).containsKey(key)) {
                      ResourceBundle bundle = loader.loadBundle(locale, key.toString());
                      put(locale, key.toString(), bundle);
                  }
                  return bundles.get(locale).get(key);
              }
          

          with the default implementation being the ResouceBundle.load(...) and people could then @Specialize this and have DB-based bundles, lazy loading etc...

          Show
          nickarls Nicklas Karlsson added a comment - - edited It could be done quite cheap with a public interface BundleLoader { public ResourceBundle loadBundle(Locale locale, String key); } And in ApplicationBundles @Inject BundleLoader loader; public ResourceBundle get(final Locale locale, final Object key) { containsLocaleMap(locale); if (!bundles.get(locale).containsKey(key)) { ResourceBundle bundle = loader.loadBundle(locale, key.toString()); put(locale, key.toString(), bundle); } return bundles.get(locale).get(key); } with the default implementation being the ResouceBundle.load(...) and people could then @Specialize this and have DB-based bundles, lazy loading etc...
          Hide
          nickarls Nicklas Karlsson added a comment -

          Perhaps the BundleLoader should be a Instance<BundleLoader> that would be used if the user has provided one and then the fallback would be the ResourceBundle.loadBundle()

          Show
          nickarls Nicklas Karlsson added a comment - Perhaps the BundleLoader should be a Instance<BundleLoader> that would be used if the user has provided one and then the fallback would be the ResourceBundle.loadBundle()
          Hide
          spinner José Freitas added a comment - - edited

          I like the first solution (the one with a class responsible only for loading bundles. 'loader.loadBundle'). It's quite simple and it will help a lot on extending the way we could load data for our resourcebundle.

          Show
          spinner José Freitas added a comment - - edited I like the first solution (the one with a class responsible only for loading bundles. 'loader.loadBundle'). It's quite simple and it will help a lot on extending the way we could load data for our resourcebundle.
          Hide
          spinner José Freitas added a comment -

          I took the liberty to assign the issue to Nicklars, since he's already involved with the solution. I hope you don't mind ken.

          Show
          spinner José Freitas added a comment - I took the liberty to assign the issue to Nicklars, since he's already involved with the solution. I hope you don't mind ken.
          Hide
          kenfinni Ken Finnigan added a comment -

          That's fine

          Nicklas, are you putting together a pull request for this JIRA?

          Show
          kenfinni Ken Finnigan added a comment - That's fine Nicklas, are you putting together a pull request for this JIRA?

            People

            • Assignee:
              nickarls Nicklas Karlsson
              Reporter:
              nickarls Nicklas Karlsson
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:

                Development