Properties can use method from parent class to be setted :
In :
<property method="updateFoo" name="foo" type="java.lang.String"/>
The updateFoo method can be in the parent class. However, if the type of the property cannot be discovered (i.e. linked with a field), the type attribute must be set to describe the property type.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@578694 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java
index b0aade4..758127b 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java
@@ -112,6 +112,7 @@
value = new String(strValue);
m_type = java.lang.String.class;
}
+
if (type.equals("boolean")) {
value = new Boolean(strValue);
m_type = Boolean.TYPE;
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java
index 0dc93df..81f3e01 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java
@@ -175,11 +175,7 @@
ff.add(fm);
} else {
MethodMetadata[] mm = manipulation.getMethods(methodName);
- if (mm.length == 0) {
- m_manager.getFactory().getLogger().log(Logger.ERROR,
- "[" + m_manager.getClassName() + "] The method " + methodName + " does not exist in the implementation");
- return;
- } else {
+ if (mm.length != 0) {
if (mm[0].getMethodArguments().length != 1) {
m_manager.getFactory().getLogger().log(Logger.ERROR,
"[" + m_manager.getClassName() + "] The method " + methodName + " does not have one argument");
@@ -191,7 +187,15 @@
return;
}
type = mm[0].getMethodArguments()[0];
- }
+ } else {
+ // Else, the method is in a super class, look for the type attribute to get the type (if not already discovered)
+ if (type == null && configurables[i].containsAttribute("type")) {
+ type = configurables[i].getAttribute("type");
+ } else {
+ m_manager.getFactory().getLogger().log(Logger.ERROR, "The type of the property cannot be discovered, please add a 'type' attribute");
+ return;
+ }
+ }
}
ConfigurableProperty cp = new ConfigurableProperty(name, fieldName, methodName, value, type, this);
@@ -224,10 +228,10 @@
}
/**
- * Stop method.
- * Do nothing.
- * @see org.apache.felix.ipojo.Handler#stop()
- */
+ * Stop method.
+ * Do nothing.
+ * @see org.apache.felix.ipojo.Handler#stop()
+ */
public void stop() {
}