You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2010/03/14 11:50:19 UTC

svn commit: r922811 - /struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java

Author: lukaszlenart
Date: Sun Mar 14 10:50:19 2010
New Revision: 922811

URL: http://svn.apache.org/viewvc?rev=922811&view=rev
Log:
Resolved WW-3407 - added flag to turn off eager loading of actioon classess

Modified:
    struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java

Modified: struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java?rev=922811&r1=922810&r2=922811&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java (original)
+++ struts/struts2/trunk/plugins/convention/src/main/java/org/apache/struts2/convention/PackageBasedActionConfigBuilder.java Sun Mar 14 10:50:19 2010
@@ -105,6 +105,7 @@ public class PackageBasedActionConfigBui
     private boolean slashesInActionNames;
 
     private static final String DEFAULT_METHOD = "execute";
+    private boolean eagerLoading = false;
 
     /**
      * Constructs actions based on a list of packages.
@@ -281,6 +282,15 @@ public class PackageBasedActionConfigBui
         this.mapAllMatches = "true".equals(mapAllMatches);
     }
 
+    /**
+     * @param eagerLoading (Optional) If set, found action classes will be instantiated by the ObjectFactory to accelerate future use
+     *                      setting it up can clash with Spring managed beans
+     */
+    @Inject(value = "struts.convention.action.eagerLoading", required = false)
+    public void setEagerLoading(String eagerLoading) {
+        this.eagerLoading = "true".equals(eagerLoading);
+    }
+
     protected void initReloadClassLoader() {
         //when the configuration is reloaded, a new classloader will be setup
         if (isReloadEnabled() && reloadingClassLoader == null)
@@ -567,13 +577,15 @@ public class PackageBasedActionConfigBui
                 continue;
             }
 
-            // Tell the ObjectFactory about this class
-            try {
-                objectFactory.getClassInstance(actionClass.getName());
-            } catch (ClassNotFoundException e) {
-                if (LOG.isErrorEnabled())
-                    LOG.error("Object Factory was unable to load class [#0]", e, actionClass.getName());
-                throw new StrutsException("Object Factory was unable to load class " + actionClass.getName(), e);
+            if (eagerLoading) {
+                // Tell the ObjectFactory about this class
+                try {
+                    objectFactory.getClassInstance(actionClass.getName());
+                } catch (ClassNotFoundException e) {
+                    if (LOG.isErrorEnabled())
+                        LOG.error("Object Factory was unable to load class [#0]", e, actionClass.getName());
+                    throw new StrutsException("Object Factory was unable to load class " + actionClass.getName(), e);
+                }
             }
 
             // Determine the action package