Fix Felix-1114.
Provides a 'updated' attribute in 'Properties' specifying a method called when a reconfiguration is completed:
<properties updated="afterReconfiguration">
<property ...>
</properties>
The specified method receives a Dictionary containing the <key,value> pairs
Provides the associated annotation:
@Updated
public void afterReconfiguration(Dictionary conf) {
...
}
Extend the API to support the 'updated' attribute (setUpdatedMethod(String method))
Add test checking the 'updated' attribute behavior on simple properties, ManagedService reconfiguration and ManagedServiceFactory reconfiguration.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@770759 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java
index 8bccc28..a9f5827 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java
@@ -67,6 +67,9 @@
if (arg0.equals("Lorg/apache/felix/ipojo/annotations/Invalidate;")) {
return processInvalidate();
}
+ if (arg0.equals("Lorg/apache/felix/ipojo/annotations/Updated;")) {
+ return processUpdated();
+ }
if (arg0.equals("Lorg/apache/felix/ipojo/annotations/Bind;")) {
return processBind("bind");
}
@@ -84,6 +87,25 @@
}
/**
+ * Process @Updated annotation.
+ * @return null.
+ */
+ private AnnotationVisitor processUpdated() {
+ Element parent = null;
+ if (! m_collector.getIds().containsKey("properties")) {
+ parent = new Element("Properties", "");
+ m_collector.getIds().put("properties", parent);
+ m_collector.getElements().put(parent, null);
+ } else {
+ parent = (Element) m_collector.getIds().get("properties");
+ }
+
+ parent.addAttribute(new Attribute("updated", m_name));
+
+ return null;
+ }
+
+ /**
* Process @bind & @unbind.
* @param type : bind or unbind
* @return the visitor parsing @bind & @unbind annotations.
diff --git a/ipojo/manipulator/src/main/resources/core.xsd b/ipojo/manipulator/src/main/resources/core.xsd
index 4731b49..ac2850c 100644
--- a/ipojo/manipulator/src/main/resources/core.xsd
+++ b/ipojo/manipulator/src/main/resources/core.xsd
@@ -397,7 +397,7 @@
<xs:element name="properties" type="PropertiesType" id="properties"></xs:element>
<xs:complexType name="PropertiesType">
<xs:annotation>
- <xs:documentation>List of component, instance or service properties. This field will receive the property value.</xs:documentation>
+ <xs:documentation>List configuration properties. This field will receive the property value.</xs:documentation>
</xs:annotation>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="property" type="PropertyType">
@@ -413,6 +413,10 @@
<xs:annotation>
<xs:documentation>Unique identifier used to reconfigure components properties (via Managed Services) with the Configuration Admin.</xs:documentation>
</xs:annotation></xs:attribute>
+ <xs:attribute name="updated" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation>Updated method called when a reconfiguration is done</xs:documentation>
+ </xs:annotation></xs:attribute>
</xs:complexType>
<xs:complexType name="ServiceDependencyType">