FELIX-645 : Only apply global property if it hasn't been defined by the component itself.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@680025 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
index 466dc8e..eda9709 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
@@ -332,7 +332,7 @@
      * Process all found properties for the component.
      * @throws MojoExecutionException
      */
-    public void processProperties()
+    public void processProperties(final Map globalProperties)
     throws MojoExecutionException {
         final Iterator propIter = properties.entrySet().iterator();
         while ( propIter.hasNext() ) {
@@ -341,6 +341,27 @@
             final PropertyDescription desc = (PropertyDescription)entry.getValue();
             this.processProperty(desc.propertyTag, propName, desc.field);
         }
+        // apply pre configured global properties
+        if ( globalProperties != null ) {
+            final Iterator globalPropIter = globalProperties.entrySet().iterator();
+            while ( globalPropIter.hasNext() ) {
+                final Map.Entry entry = (Map.Entry)globalPropIter.next();
+                final String name = entry.getKey().toString();
+
+                // check if the service already provides this property
+                if ( !properties.containsKey(name) ) {
+                    final String value = entry.getValue().toString();
+
+                    final Property p = new Property();
+                    p.setName(name);
+                    p.setValue(value);
+                    p.setType("String");
+                    p.setPrivate(true);
+                    component.addProperty(p);
+
+                }
+            }
+        }
     }
 
     protected static final class PropertyDescription {
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
index 46cb241..e21915f 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
@@ -252,18 +252,6 @@
         // Utility handler for propertie
         final PropertyHandler propertyHandler = new PropertyHandler(component, ocd);
 
-        // pre configured properties
-        final Iterator globalPropIter = this.properties.entrySet().iterator();
-        while ( globalPropIter.hasNext() ) {
-            final Map.Entry entry = (Map.Entry)globalPropIter.next();
-            final Property p = new Property();
-            p.setName(entry.getKey().toString());
-            p.setValue(entry.getValue().toString());
-            p.setType("String");
-            p.setPrivate(true);
-            component.addProperty(p);
-        }
-
         JavaClassDescription currentDescription = description;
         do {
             // properties
@@ -293,7 +281,7 @@
         } while (inherited && currentDescription != null);
 
         // process properties
-        propertyHandler.processProperties();
+        propertyHandler.processProperties(this.properties);
 
         // process references
         final Iterator refIter = references.entrySet().iterator();