Applied patch (FELIX-109) to fix a class cast exception.
git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@440838 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/ComponentMetadata.java b/scr/src/main/java/org/apache/felix/scr/ComponentMetadata.java
index e8c010b..8fe037e 100644
--- a/scr/src/main/java/org/apache/felix/scr/ComponentMetadata.java
+++ b/scr/src/main/java/org/apache/felix/scr/ComponentMetadata.java
@@ -16,10 +16,7 @@
*/
package org.apache.felix.scr;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.List;
-import java.util.ArrayList;
+import java.util.*;
import org.osgi.service.component.ComponentException;
@@ -43,7 +40,13 @@
private String m_implementationClassName = null;
// Associated properties (0..*)
- private Properties m_properties = new Properties();
+ private Dictionary m_properties = new Hashtable();
+
+ // List of Property metadata - used while building the meta data
+ // while validating the properties contained in the PropertyMetadata
+ // instances are copied to the m_properties Dictionary while this
+ // list will be cleared
+ private List m_propertyMetaData = new ArrayList();
// Provided services (0..1)
private ServiceMetadata m_service = null;
@@ -128,9 +131,7 @@
if(newProperty == null) {
throw new IllegalArgumentException ("Cannot add a null property");
}
- String key = newProperty.getName();
- Object value = newProperty.getValue();
- m_properties.put(key,value);
+ m_propertyMetaData.add(newProperty);
}
/**
@@ -215,11 +216,11 @@
}
/**
- * Returns the property descriptors
+ * Returns the properties.
*
- * @return the property descriptors as a Collection
+ * @return the properties as a Dictionary
*/
- public Properties getProperties() {
+ public Dictionary getProperties() {
return m_properties;
}
@@ -246,11 +247,14 @@
*/
void validate() {
- // First check if the properties are valid
- Iterator propertyIterator = m_properties.keySet().iterator();
+ // First check if the properties are valid (and extract property values)
+ Iterator propertyIterator = m_propertyMetaData.iterator();
while ( propertyIterator.hasNext() ) {
- ((PropertyMetadata)propertyIterator.next()).validate();
- }
+ PropertyMetadata propMeta = (PropertyMetadata) propertyIterator.next();
+ propMeta.validate();
+ m_properties.put(propMeta.getName(), propMeta.getValue());
+ }
+ m_propertyMetaData.clear();
// Check that the provided services are valid too
if(m_service != null) {