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

ProjectStage-aware and Property-aware configuration

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.4
    • 0.5
    • Configuration
    • None

    Description

      In many situations one likes to use different configurations depending on the ProjectStage.

      E.g. to take the JPA configuration for the local database from a properties file which contains the credentials and JDBC driver class for the local test setup in ProjectStage Development and UnitTest, but use a JNDI provided DataSource for ProjectStage Production.

      Same goes with using various kind of configuration depending on a configured property like e.g. 'dbvendor'. Using some Oracle specific flags if dbvendor is set to 'oracle' vs other flags for 'mysql'.

      To not come into chicken/egg issues, I propose that the whole change only affects our ConfigResolver and the producers for @ConfigProperty

      I suggest to add 2 new methods to ConfigResolver:

      #getProjectStageAwarePropertyValue(String key)

      This would basically first do a lookup of key + projectStage, e.g. someKey.Production and if it doesn't find anything, then looks up the configured value without the ProjectStage.

      #getPropertyAwarePropertyValue(String key, String propertyName);

      The lookup pack for key= 'someconfig', ProjectStage = Production and propertyName = 'dbvendor' would be:

      • lookup dbvendor.Production, then if not found do a fallback to dbvendor. Let's say we found the value 'mysql' that way.
      • lookup someconfig.mysql.Production
      • fallback: lookup someconfig.mysql
      • fallback: lookup someconfig.Production
      • fallback: lookup someconfig

      Attachments

        Activity

          People

            struberg Mark Struberg
            struberg Mark Struberg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: