deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject deltaspike git commit: DELTASPIKE-1126 also suport evaluateVariables in @ConfigProperty
Date Tue, 12 Apr 2016 09:31:19 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 373771829 -> 2a6058c56


DELTASPIKE-1126 also suport evaluateVariables in @ConfigProperty


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/2a6058c5
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/2a6058c5
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/2a6058c5

Branch: refs/heads/master
Commit: 2a6058c56b4511f62e195da8c235b0b280fe441e
Parents: 3737718
Author: Mark Struberg <struberg@apache.org>
Authored: Tue Apr 12 11:25:08 2016 +0200
Committer: Mark Struberg <struberg@apache.org>
Committed: Tue Apr 12 11:25:08 2016 +0200

----------------------------------------------------------------------
 .../apache/deltaspike/core/api/config/ConfigProperty.java   | 8 ++++++++
 .../core/spi/config/BaseConfigPropertyProducer.java         | 2 ++
 .../api/config/injectable/InjectableConfigPropertyTest.java | 2 ++
 .../test/core/api/config/injectable/SettingsBean.java       | 9 +++++++++
 .../test/resources/META-INF/apache-deltaspike.properties    | 2 ++
 5 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/2a6058c5/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigProperty.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigProperty.java
b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigProperty.java
index 40172a9..260eaa2 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigProperty.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigProperty.java
@@ -136,4 +136,12 @@ public @interface ConfigProperty
 
     @Nonbinding
     String parameterizedBy() default NULL;
+
+    /**
+     * Whether to resolve 'variables' in configured values.
+     *
+     * @see org.apache.deltaspike.core.api.config.ConfigResolver.TypedResolver#evaluateVariables(boolean)
+     */
+    @Nonbinding
+    boolean evaluateVariables() default true;
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/2a6058c5/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/config/BaseConfigPropertyProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/config/BaseConfigPropertyProducer.java
b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/config/BaseConfigPropertyProducer.java
index e325aff..dec87f7 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/config/BaseConfigPropertyProducer.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/config/BaseConfigPropertyProducer.java
@@ -133,6 +133,8 @@ public abstract class BaseConfigPropertyProducer
             resolver.parameterizedBy(parameterizedBy);
         }
 
+        resolver.evaluateVariables(configProperty.evaluateVariables());
+
         return resolver.getValue();
     }
 

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/2a6058c5/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/InjectableConfigPropertyTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/InjectableConfigPropertyTest.java
b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/InjectableConfigPropertyTest.java
index 4e67f78..568d26e 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/InjectableConfigPropertyTest.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/InjectableConfigPropertyTest.java
@@ -76,6 +76,8 @@ public class InjectableConfigPropertyTest
         Assert.assertEquals("14", settingsBean.getProperty3Filled());
         Assert.assertEquals("myDefaultValue", settingsBean.getProperty3Defaulted());
         Assert.assertEquals(42, settingsBean.getProperty4Defaulted());
+
+        Assert.assertEquals("some setting for prodDB", settingsBean.getDbConfig());
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/2a6058c5/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/SettingsBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/SettingsBean.java
b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/SettingsBean.java
index 3dcbd2f..d180aca 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/SettingsBean.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/SettingsBean.java
@@ -88,6 +88,10 @@ public class SettingsBean
     @ConfigProperty(name = "configPropertyTrue8")
     private Boolean booleanPropertyTrue8;
 
+    @Inject
+    @ConfigProperty(name = "testDbConfig")
+    private String dbConfig;
+
     protected SettingsBean()
     {
     }
@@ -184,4 +188,9 @@ public class SettingsBean
     {
         return booleanPropertyTrue8;
     }
+
+    public String getDbConfig()
+    {
+        return dbConfig;
+    }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/2a6058c5/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties
b/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties
index 58b0c65..d8fee1c 100644
--- a/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties
+++ b/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties
@@ -22,6 +22,8 @@ org.apache.deltaspike.core.spi.activation.ClassDeactivator=org.apache.deltaspike
 testProperty02=test_value_02
 db=prodDB
 
+testDbConfig=some setting for ${db}
+
 globalAlternatives.org.apache.deltaspike.test.core.api.alternative.global.BaseBean1=org.apache.deltaspike.test.core.api.alternative.global.SubBaseBean2
 globalAlternatives.org.apache.deltaspike.test.core.api.alternative.global.BaseInterface1=org.apache.deltaspike.test.core.api.alternative.global.BaseInterface1AlternativeImplementation
 


Mime
View raw message