Commits

Anonymous committed b9ebffd

small tweak to not assume a resource is the same class that we asked the object factory for. this is needed if the factory is using proxies, for example

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@228e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (1)

src/java/com/opensymphony/xwork/interceptor/component/DefaultComponentManager.java

 package com.opensymphony.xwork.interceptor.component;
 
 import com.opensymphony.xwork.ObjectFactory;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import java.io.Serializable;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 
 /**
- *
- *
  * @author joew@thoughtworks.com
  * @author $Author$
  * @version $Revision$
     }
 
     public void initializeObject(Object obj) {
-        loadResource(obj, this);
+        loadResource(obj, obj.getClass(), this);
 
         // is this even needed now?
         //        if (fallback != null) {
         addAllInterfaces(clazz.getSuperclass(), allInterfaces);
     }
 
-    private Class loadResource(Object resource, DefaultComponentManager dcm) {
+    private Class loadResource(Object resource, Class clazz, DefaultComponentManager dcm) {
         boolean resourceNotLoaded = !dcm.loadOrder.contains(resource);
 
         if (resourceNotLoaded) {
-            Map resources = getResourceDependencies(resource.getClass());
+            Map resources = getResourceDependencies(clazz);
 
             for (Iterator iterator = resources.entrySet().iterator();
-                    iterator.hasNext();) {
+                 iterator.hasNext();) {
                 Map.Entry mapEntry = (Map.Entry) iterator.next();
                 Class depResource = (Class) mapEntry.getKey();
                 DefaultComponentManager newDcm = (DefaultComponentManager) mapEntry.getValue();
                         newResource = ObjectFactory.getObjectFactory().buildBean(depResource);
                     }
 
-                    Class enabler = loadResource(newResource, newDcm);
+                    Class enabler = loadResource(newResource, depResource, newDcm);
                     setupResource(resource, enabler, newResource);
                 } catch (Exception e) {
                     e.printStackTrace();
                 }
             }
 
-            dcm.alreadyLoaded.add(resource.getClass());
+            dcm.alreadyLoaded.add(clazz);
 
             if (resource instanceof Initializable) {
                 Initializable initializable = (Initializable) resource;
                 initializable.init();
             }
 
-            dcm.resourceInstances.put(resource.getClass(), resource);
+            dcm.resourceInstances.put(clazz, resource);
             dcm.loadOrder.add(resource);
         }
 
         // now return this class's enabler
-        Class enabler = (Class) dcm.enablers2.get(resource.getClass());
+        Class enabler = (Class) dcm.enablers2.get(clazz);
 
         return enabler;
     }
         }
 
         try {
-            enabler.getMethods()[0].invoke(resource, new Object[] {newResource});
+            enabler.getMethods()[0].invoke(resource, new Object[]{newResource});
         } catch (Exception e) {
             e.printStackTrace();
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.