FELIX-2953 Made the cache size configurable via a system property.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1104138 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyManager.java b/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyManager.java
index 4918877..9567714 100644
--- a/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyManager.java
+++ b/dependencymanager/core/src/main/java/org/apache/felix/dm/DependencyManager.java
@@ -58,6 +58,7 @@
 public class DependencyManager {
     public static final String ASPECT = "org.apache.felix.dependencymanager.aspect";
     public static final String SERVICEREGISTRY_CACHE_INDICES = "dm.index"; // TODO rename
+    public static final String METHOD_CACHE_SIZE = "org.apache.felix.dependencymanager.methodcache";
     private final BundleContext m_context;
     private final Logger m_logger;
     private List m_components = Collections.synchronizedList(new ArrayList());
diff --git a/dependencymanager/core/src/main/java/org/apache/felix/dm/InvocationUtil.java b/dependencymanager/core/src/main/java/org/apache/felix/dm/InvocationUtil.java
index c32e8a4..f59d01c 100644
--- a/dependencymanager/core/src/main/java/org/apache/felix/dm/InvocationUtil.java
+++ b/dependencymanager/core/src/main/java/org/apache/felix/dm/InvocationUtil.java
@@ -30,8 +30,18 @@
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
 public class InvocationUtil {
-    public static final int CACHE_SIZE = 2048;
-    private static final Map /* <Key, Method> */ m_methodCache = new LRUMap(CACHE_SIZE);
+    private static final Map /* <Key, Method> */ m_methodCache;
+    static {
+        int size = 2048;
+        try {
+            String value = System.getProperty(DependencyManager.METHOD_CACHE_SIZE);
+            if (value != null) {
+                size = Integer.parseInt(value);
+            }
+        }
+        catch (Exception e) {}
+        m_methodCache = new LRUMap(Math.max(size, 64));
+    }
     
     public static Object invokeCallbackMethod(Object instance, String methodName, Class[][] signatures, Object[][] parameters) throws NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
         Class currentClazz = instance.getClass();