[
https://issues.apache.org/struts/browse/WW-1821?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
marco ocana updated WW-1821:
----------------------------
Description:
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 .
was:
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 avoid this behavior if possible, 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 server in 10
seconds versus multiple minutes. Would be a big productivity boost.
In looking through the code, it appears that the instantiation of actions
occurs in the process of verifying that the struts.xml configuration is valid.
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. Don't know how difficult
Spring makes this.
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 . During
development, the risk of having an action blow up is acceptable.
> 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: Actions
> Affects Versions: 2.0.6
> Reporter: marco ocana
> Priority: Minor
>
> 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.