felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r440838 - /incubator/felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentMetadata.java
Date Wed, 06 Sep 2006 19:12:24 GMT
Author: rickhall
Date: Wed Sep  6 12:12:23 2006
New Revision: 440838

URL: http://svn.apache.org/viewvc?view=rev&rev=440838
Log:
Applied patch (FELIX-109) to fix a class cast exception.

Modified:
    incubator/felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentMetadata.java

Modified: incubator/felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentMetadata.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentMetadata.java?view=diff&rev=440838&r1=440837&r2=440838
==============================================================================
--- incubator/felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentMetadata.java (original)
+++ incubator/felix/trunk/scr/src/main/java/org/apache/felix/scr/ComponentMetadata.java Wed
Sep  6 12:12:23 2006
@@ -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) {



Mime
View raw message