felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r1349496 - /felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
Date Tue, 12 Jun 2012 19:48:06 GMT
Author: clement
Date: Tue Jun 12 19:48:06 2012
New Revision: 1349496

URL: http://svn.apache.org/viewvc?rev=1349496&view=rev
Log:
Fixed FELIX-3500

Improve the implementation of the method id computation.

Modified:
    felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java

Modified: felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java?rev=1349496&r1=1349495&r2=1349496&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
(original)
+++ felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
Tue Jun 12 19:48:06 2012
@@ -23,12 +23,7 @@ import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 import org.apache.felix.ipojo.architecture.InstanceDescription;
 import org.apache.felix.ipojo.metadata.Element;
@@ -152,7 +147,7 @@ public class InstanceManager implements 
      * The Map storing the Method objects by ids.
      * [id=>{@link Method}].
      */
-    private Map m_methods = new HashMap();
+    private Map m_methods = new Hashtable();
 
 
     /**
@@ -1155,15 +1150,13 @@ public class InstanceManager implements 
      * @return the method object or <code>null</code> if the method cannot be
found.
      */
     private Member getMethodById(String methodId) {
-        // Not necessary synchronized as recomputing the methodID will give the same Method
twice.
+        // Used a synchronized map.
         Member member = (Member) m_methods.get(methodId);
         if (member == null  && m_clazz != null) {
-
             // First try on methods.
             Method[] mets = m_clazz.getDeclaredMethods();
             for (int i = 0; i < mets.length; i++) {
-                // Check if the method was not already computed. If not, compute the Id and
check.
-                if (!m_methods.containsValue(mets[i]) && (MethodMetadata.computeMethodId(mets[i]).equals(methodId)))
{
+                if (MethodMetadata.computeMethodId(mets[i]).equals(methodId)) {
                     // Store the new methodId
                     m_methods.put(methodId, mets[i]);
                     return mets[i];
@@ -1175,7 +1168,7 @@ public class InstanceManager implements 
                 Constructor[] constructors = m_clazz.getDeclaredConstructors();
                 for (int i = 0; i < constructors.length; i++) {
                     // Check if the constructor was not already computed. If not, compute
the Id and check.
-                    if (!m_methods.containsValue(constructors[i]) && (MethodMetadata.computeMethodId(constructors[i]).equals(methodId)))
{
+                    if (MethodMetadata.computeMethodId(constructors[i]).equals(methodId))
{
                         // Store the new methodId
                         m_methods.put(methodId, constructors[i]);
                         return constructors[i];
@@ -1183,7 +1176,7 @@ public class InstanceManager implements 
                 }
             }
 
-            // Cannot happen
+            // Should not happen
             m_logger.log(Logger.INFO, "A methodID cannot be associated with a method from
the POJO class: " + methodId);
             return null;
         } else {



Mime
View raw message