Uploaded image for project: 'DeltaSpike'
  1. DeltaSpike
  2. DELTASPIKE-223

Add convention for @MessageResource annotated types.

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.2-incubating
    • 0.3-incubating
    • I18n-Module
    • None

    Description

      Add the possibility to use convention for @MessageResource annotated types.
      If there is no @MessageTemplate given for a defined method then the method itself shall provide the information for the property key.

      Example:

      @MessageResource
      class MyMessages() {

      String getErrorMessage();

      String getGetError();

      @MessageTemplate("MESSGAE_WARN")
      String getWarnMessage();
      }

      The convention would be:
      1. If method name starts with 'get' remove it.
      2. Split the method name at the upper case characters and seperate the parts with underscore.

      getErrorMessage() ->

      {Error, Message}

      -> ERROR_MESSAGE.
      getGetError() ->

      {Get, Error}

      -> GET_ERROR. (not pretty i know, just an example)
      getWarnMessage() is already defined

      Maybe the missing annotation could be added at the method of the type at deployment time.
      So there would be no need to provide property key name for every method, because if someone like me has a lot of messages and kept to the convention i described, it would be easier to switch to delta-spike i18n and also less work to do.

      So the existing implementation could be used as it is now. And during runtime, the interface would be as i18n needs it.

      Attachments

        There are no Sub-Tasks for this issue.

        Activity

          People

            gpetracek Gerhard Petracek
            cchet Thomas Herzog
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: