You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2011/10/02 11:09:10 UTC

svn commit: r1178159 - in /felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo: handlers/configuration/ConfigurationHandler.java util/DependencyModel.java util/Property.java

Author: clement
Date: Sun Oct  2 09:09:09 2011
New Revision: 1178159

URL: http://svn.apache.org/viewvc?rev=1178159&view=rev
Log:
Fixed Felix-2981
Applied the patch from Robert Lillack

Modified:
    felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java
    felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
    felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Property.java

Modified: felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java?rev=1178159&r1=1178158&r2=1178159&view=diff
==============================================================================
--- felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java (original)
+++ felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java Sun Oct  2 09:09:09 2011
@@ -435,6 +435,14 @@ public class ConfigurationHandler extend
             }
         }
 
+        // Every removed configurable propery gets reset to its default value
+        for (int i = 0; i < m_configurableProperties.size(); i++) {
+            Property prop = (Property) m_configurableProperties.get(i);
+            if (configuration.get(prop.getName()) == null) {
+                reconfigureProperty(prop, prop.getDefaultValue());
+            }
+        }
+
         return toPropagate;
 
     }

Modified: felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java?rev=1178159&r1=1178158&r2=1178159&view=diff
==============================================================================
--- felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java (original)
+++ felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java Sun Oct  2 09:09:09 2011
@@ -431,7 +431,7 @@ public abstract class DependencyModel im
      * @param obj the service object if the service was get
      */
     private void manageDeparture(ServiceReference ref, Object obj) {
-    	// Unget the service reference
+        // Unget the service reference
         ungetService(ref);
 
         // If we already get this service and the binding policy is static, the dependency becomes broken

Modified: felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Property.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Property.java?rev=1178159&r1=1178158&r2=1178159&view=diff
==============================================================================
--- felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Property.java (original)
+++ felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Property.java Sun Oct  2 09:09:09 2011
@@ -75,6 +75,11 @@ public class Property implements FieldIn
     private Object m_value = NO_VALUE;
 
     /**
+     * The default value of the property.
+     */
+    private Object m_defaultValue = NO_VALUE;
+
+    /**
      * Flag tracking is the method was
      * already called for the current value.
      */
@@ -126,6 +131,7 @@ public class Property implements FieldIn
         m_type = computeType(type, manager.getGlobalContext());
         if (value != null) {
             m_value = create(m_type, value);
+            m_defaultValue = m_value;
         }
 
         if (method != null) {
@@ -136,9 +142,9 @@ public class Property implements FieldIn
     }
 
     public Property(String name, String field, String method, int index,
-    		String value, String type, InstanceManager manager, Handler handler) throws ConfigurationException {
-    	this(name, field, method, value, type, manager, handler);
-    	m_index = index;
+            String value, String type, InstanceManager manager, Handler handler) throws ConfigurationException {
+        this(name, field, method, value, type, manager, handler);
+        m_index = index;
     }
 
     /**
@@ -277,7 +283,7 @@ public class Property implements FieldIn
      * parameter.
      */
     public int getParameterIndex() {
-    	return m_index;
+        return m_index;
     }
 
     /**
@@ -292,6 +298,17 @@ public class Property implements FieldIn
         return m_value;
     }
 
+    /**
+     * Gets the initial value of the property.
+     * @return the default value.
+     */
+    public Object getDefaultValue() {
+        if (m_defaultValue == NO_VALUE) {
+            return getNoValue(m_type);
+        }
+
+        return m_defaultValue;
+    }
 
     /**
      * Gets the NO VALUE Object.
@@ -523,7 +540,7 @@ public class Property implements FieldIn
      * it will be invoked another times.
      */
     public synchronized void reset() {
-    	m_invoked = false;
+        m_invoked = false;
     }
 
     /**
@@ -596,30 +613,30 @@ public class Property implements FieldIn
      * @see org.apache.felix.ipojo.ConstructorInjector#getConstructorParameter(int)
      */
     public Object getConstructorParameter(int index) {
-    	if (m_index != index) {
-    		return null;
-    	}
+        if (m_index != index) {
+            return null;
+        }
 
-    	if (m_value  == NO_VALUE) {
+        if (m_value  == NO_VALUE) {
            return getNoValue(m_type);
         }
         return m_value;
-	}
+    }
 
-	/**
-	 * Gets the type of the constructor parameter to inject.
-	 * @param index the parameter index
-	 * @return the Class of the property.
-	 * @see org.apache.felix.ipojo.ConstructorInjector#getConstructorParameterType(int)
-	 */
-	public Class getConstructorParameterType(int index) {
-		if (m_index != index) {
-    		return null;
-    	}
-		return m_type;
-	}
+    /**
+     * Gets the type of the constructor parameter to inject.
+     * @param index the parameter index
+     * @return the Class of the property.
+     * @see org.apache.felix.ipojo.ConstructorInjector#getConstructorParameterType(int)
+     */
+    public Class getConstructorParameterType(int index) {
+        if (m_index != index) {
+            return null;
+        }
+        return m_type;
+    }
 
-	/**
+    /**
      * Gets the handler managing the property.
      * @return the configuration handler.
      */