Author: cziegeler
Date: Sat Jul 26 11:13:35 2008
New Revision: 680025

URL: http://svn.apache.org/viewvc?rev=680025&view=rev
Log:
FELIX-645 : Only apply global property if it hasn't been defined by the 
component itself.

Modified:
    
felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
    
felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java

Modified: 
felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java?rev=680025&r1=680024&r2=680025&view=diff
==============================================================================
--- 
felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
 (original)
+++ 
felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/PropertyHandler.java
 Sat Jul 26 11:13:35 2008
@@ -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 {

Modified: 
felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java?rev=680025&r1=680024&r2=680025&view=diff
==============================================================================
--- 
felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
 (original)
+++ 
felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
 Sat Jul 26 11:13:35 2008
@@ -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();


Reply via email to