struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Musachy Barroso (JIRA)" <j...@apache.org>
Subject [jira] Commented: (WW-1821) Provide mechanism to avoid instantiating Spring managed actions at startup
Date Mon, 01 Dec 2008 21:30:37 GMT

    [ https://issues.apache.org/struts/browse/WW-1821?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45078#action_45078
] 

Musachy Barroso commented on WW-1821:
-------------------------------------

Looking at this code:

try {
            Class clazz = objectFactory.getClassInstance(className);
            if (objectFactory.isNoArgConstructorRequired()) {
                if (!Modifier.isPublic(clazz.getModifiers())) {
                    throw new ConfigurationException("Action class [" + className + "] is
not public", loc);
                }
                clazz.getConstructor(new Class[]{});
            }
        } 

if the line that creates the the class, is moved inside the if statement (which it should).
Then you could create your own ObjectFactory that return false in isNoArgConstructorRequired(),
which would solve this problem.

> Provide mechanism to avoid instantiating Spring managed actions at startup
> --------------------------------------------------------------------------
>
>                 Key: WW-1821
>                 URL: https://issues.apache.org/struts/browse/WW-1821
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>    Affects Versions: 2.0.6
>            Reporter: marco ocana
>            Priority: Minor
>             Fix For: 2.2.x
>
>
> When Spring is used as the object factory for actions, Struts 2 will instantiate at application
load time  each of the action beans defined in struts.xml.  
> It would be very useful to to have a way to avoid this behavior, particularly during
development.  Because of dependencies defined in Spring, instantiating the action objects
can also mean instantiating expensive resources such as datasources that might not be immediately
needed. 
> This feature can make the difference between restarting the application in 10 seconds
versus multiple minutes. Would be a big development productivity boost.
> It appears that the instantiation of actions occurs in the process of verifying struts.xml.
Specifically, it checks that the classes that implement the actions have no-arg constructors
that are public.
> In the case of the default ObjectFactory, the class defined in the configuration is loaded
and evaluated using the reflection API. When the SpringObjectFactory is used however, the
action implementation class is obtained by requesting the action bean from Spring and then
getting its class. 
> Ideally, we would examine metadata and determine the validity of the action definition
without actually creating the action object. 
> If it turns out that the verification cannot avoid instantiating actions, then I propose
that a configuration option be provided that would short-circuit checking the action classes,
presumably in struts.properties . 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message