Index: DefaultDynObjectManager.java
===================================================================
--- DefaultDynObjectManager.java	(revision 1404)
+++ DefaultDynObjectManager.java	(revision 1405)
@@ -41,6 +41,7 @@
 import java.util.Set;
 
 import org.gvsig.tools.ToolsLocator;
+import org.gvsig.tools.dataTypes.DataTypes;
 import org.gvsig.tools.dynobject.DelegatedDynObject;
 import org.gvsig.tools.dynobject.DynClass;
 import org.gvsig.tools.dynobject.DynClassName;
@@ -331,7 +332,7 @@
     private Map anonymousClasses;
     private ClassesNamespaces classes;
     private Map methodsMap;
-    private MethodInfo[] methods;
+    private List<MethodInfo> methods;
 
     public static DefaultDynObjectManager getManager() {
         if (manager == null) {
@@ -347,7 +348,11 @@
 
     static String getKey(Class theClass, DynClass dynClass, String methodName) {
         if (dynClass == null) {
-            return theClass.getName() + ":" + methodName;
+            if( theClass == null ) {
+                return "__anonymous__:" + methodName;
+            } else {
+                return theClass.getName() + ":" + methodName;
+            }
         } else {
             return dynClass.getName() + ":" + methodName;
         }
@@ -505,6 +510,10 @@
         return registerDynMethod(theClass, null, dynMethod);
     }
 
+    public int registerDynMethod(DynMethod dynMethod) {
+        return registerDynMethod(null, null, dynMethod);
+    }
+
     int registerDynMethod(Class theClass, DynClass dynClass, DynMethod dynMethod) {
         MethodInfo info = new MethodInfo(theClass, dynClass, dynMethod, 0);
         MethodInfo oldInfo = (MethodInfo) methodsMap.get(info.getKey());
@@ -515,15 +524,10 @@
             return oldInfo.code;
         }
         if (methods == null) {
-            methods = new MethodInfo[1];
-            info.code = 0;
-        } else {
-            MethodInfo[] temp1 = new MethodInfo[methods.length + 1];
-            System.arraycopy(methods, 0, temp1, 0, methods.length);
-            info.code = temp1.length - 1;
-            methods = temp1;
+            methods = new ArrayList<MethodInfo>();
         }
-        methods[info.code] = info;
+        info.code = methods.size();
+        methods.add(info);
         methodsMap.put(info.getKey(), info);
 
         return info.code;
@@ -540,7 +544,7 @@
              * Asi evitamos codigo de comprobacion para los casos que valla bien
              * que deberian ser la mayoria.
              */
-            return methods[code].dynMethod.invoke(self, context);
+            return methods.get(code).dynMethod.invoke((DynObject)self, new Object[] {context});
         } catch (RuntimeException e) {
             getDynMethod(self, code);
             throw e;
@@ -574,14 +578,24 @@
     }
 
     public DynMethod getDynMethod(int code) throws DynMethodException {
-        if (code >= methods.length) {
+        if (code >= methods.size()) {
             throw new DynMethodNotSupportedException(code, "{null}");
         }
-        MethodInfo info = methods[code];
+        MethodInfo info = methods.get(code);
         info.check((Class) null, code);
         return info.dynMethod;
     }
-
+    
+    @Override
+    public DynMethod getDynMethod(String methodName) throws DynMethodException {
+        String key = DefaultDynObjectManager.getKey(null, null, methodName);
+        MethodInfo info = (MethodInfo) methodsMap.get(key);
+        if (info == null) {
+            throw new IllegalDynMethodException(methodName);
+        }
+        return info.dynMethod;
+    }
+    
     public DynMethod getDynMethod(Object obj, int code)
         throws DynMethodException {
         return getDynMethod(obj.getClass(), code);
@@ -589,20 +603,20 @@
 
     public DynMethod getDynMethod(Class theClass, int code)
         throws DynMethodException {
-        if (code >= methods.length) {
+        if (code >= methods.size()) {
             throw new DynMethodNotSupportedException(code, theClass.getName());
         }
-        MethodInfo info = methods[code];
+        MethodInfo info = methods.get(code);
         info.check(theClass, code);
         return info.dynMethod;
     }
 
     public DynMethod getDynMethod(DynClass dynClass, int code)
         throws DynMethodException {
-        if (code >= methods.length) {
+        if (code >= methods.size()) {
             throw new DynMethodNotSupportedException(code, dynClass.getName());
         }
-        MethodInfo info = methods[code];
+        MethodInfo info = methods.get(code);
         info.check(dynClass, code);
         return info.dynMethod;
     }
@@ -766,4 +780,11 @@
             }
         }        
     }
+
+    @Override
+    public DynField createDynField(String name) {
+        return new DefaultDynField(name, DataTypes.STRING);
+    }
+    
+    
 }
