aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1765406 - in /aries/trunk/blueprint: blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/api/config/ blueprint-maven-plugin/ blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/ blueprint-mav...
Date Tue, 18 Oct 2016 09:32:40 GMT
Author: cschneider
Date: Tue Oct 18 09:32:40 2016
New Revision: 1765406

URL: http://svn.apache.org/viewvc?rev=1765406&view=rev
Log:
[ARIES-1628] Add support default properties, prefixes and suffixes

Added:
    aries/trunk/blueprint/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/api/config/Property.java
Modified:
    aries/trunk/blueprint/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/api/config/Config.java
    aries/trunk/blueprint/blueprint-maven-plugin/pom.xml
    aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/ConfigWriter.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java
    aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/BeanWithConfig.java

Modified: aries/trunk/blueprint/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/api/config/Config.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/api/config/Config.java?rev=1765406&r1=1765405&r2=1765406&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/api/config/Config.java
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/api/config/Config.java
Tue Oct 18 09:32:40 2016
@@ -14,4 +14,7 @@ import java.lang.annotation.Target;
 public @interface Config {
     String pid();
     String updatePolicy() default "reload"; 
+    String placeholderPrefix() default "${";
+    String placeholderSuffix() default "}";
+    Property[] defaults() default {};
 }

Added: aries/trunk/blueprint/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/api/config/Property.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/api/config/Property.java?rev=1765406&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/api/config/Property.java
(added)
+++ aries/trunk/blueprint/blueprint-maven-plugin-annotation/src/main/java/org/apache/aries/blueprint/api/config/Property.java
Tue Oct 18 09:32:40 2016
@@ -0,0 +1,6 @@
+package org.apache.aries.blueprint.api.config;
+
+public @interface Property {
+    String key();
+    String value();
+}

Modified: aries/trunk/blueprint/blueprint-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/pom.xml?rev=1765406&r1=1765405&r2=1765406&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/pom.xml (original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/pom.xml Tue Oct 18 09:32:40 2016
@@ -154,6 +154,12 @@
             <version>0.8.0</version>
         </dependency>
         <dependency>
+        	<groupId>org.osgi</groupId>
+        	<artifactId>osgi.cmpn</artifactId>
+        	<version>6.0.0</version>
+        </dependency>
+
+        <dependency>
         	<groupId>org.apache.aries.blueprint</groupId>
         	<artifactId>blueprint-maven-plugin-annotation</artifactId>
         	<version>1.0.0-SNAPSHOT</version>

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/ConfigWriter.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/ConfigWriter.java?rev=1765406&r1=1765405&r2=1765406&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/ConfigWriter.java
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/main/java/org/apache/aries/blueprint/plugin/javax/ConfigWriter.java
Tue Oct 18 09:32:40 2016
@@ -22,6 +22,7 @@ import javax.xml.stream.XMLStreamExcepti
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.aries.blueprint.api.config.Config;
+import org.apache.aries.blueprint.api.config.Property;
 import org.apache.aries.blueprint.plugin.spi.XmlWriter;
 
 public class ConfigWriter implements XmlWriter {
@@ -38,8 +39,28 @@ public class ConfigWriter implements Xml
         writer.writeStartElement("property-placeholder");
         writer.writeDefaultNamespace(CONFIG_NS);
         writer.writeAttribute("persistent-id", config.pid());
+        if (!"${".equals(config.placeholderPrefix())) {
+            writer.writeAttribute("placeholder-prefix", config.updatePolicy());
+        }
+        if (!"}".equals(config.placeholderSuffix())) {
+            writer.writeAttribute("placeholder-suffix", config.updatePolicy());
+        }
         writer.writeAttribute("update-strategy", config.updatePolicy());
         writer.writeCharacters("\n");
+        
+        Property[] defaults = config.defaults();
+        if (defaults.length > 0) {
+            writer.writeStartElement("default-properties");
+            writer.writeCharacters("\n");
+            for (Property defaultProp : defaults) {
+                writer.writeEmptyElement("property");
+                writer.writeAttribute("name", defaultProp.key());
+                writer.writeAttribute("value", defaultProp.value());
+                writer.writeCharacters("\n");
+            }
+            writer.writeEndElement();
+            writer.writeCharacters("\n");
+        }
         writer.writeEndElement();
     }
 

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java?rev=1765406&r1=1765405&r2=1765406&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BeanTest.java
Tue Oct 18 09:32:40 2016
@@ -208,6 +208,6 @@ public class BeanTest {
         assertEquals("There should be a property", 1, bean.properties.size());
         Property prop = bean.properties.iterator().next();
         assertEquals("title", prop.name);
-        assertEquals("${title}", prop.value);
+        assertEquals("$[title]", prop.value);
     }
 }

Modified: aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/BeanWithConfig.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/BeanWithConfig.java?rev=1765406&r1=1765405&r2=1765406&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/BeanWithConfig.java
(original)
+++ aries/trunk/blueprint/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/test/BeanWithConfig.java
Tue Oct 18 09:32:40 2016
@@ -4,10 +4,19 @@ import javax.inject.Singleton;
 
 import org.apache.aries.blueprint.api.config.Config;
 import org.apache.aries.blueprint.api.config.ConfigProperty;
+import org.apache.aries.blueprint.api.config.Property;
 
-@Config(pid="org.apache.aries.my")
+@Config//
+( //
+    pid = "org.apache.aries.my", //
+    placeholderPrefix = "$[", //
+    placeholderSuffix = "]", //
+    defaults = { 
+                @Property(key="title", value="My Title")
+    }
+)
 @Singleton
 public class BeanWithConfig {
-    @ConfigProperty("${title}")
+    @ConfigProperty("$[title]")
     String title;
 }



Mime
View raw message