Adding new setting to force spring object factory to use configured

autowire strategy
WW-2479


git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@668645 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Donald J. Brown
2008-06-17 13:09:09 +00:00
parent 7dc0031e33
commit d24822fb69
2 changed files with 26 additions and 1 deletions
@@ -118,9 +118,15 @@ public final class StrutsConstants {
*/
public static final String STRUTS_MULTIPART_PARSER = "struts.multipart.parser";
/** Whether Spring should autoWire or not */
/** How Spring should autowire. Valid values are 'name', 'type', 'auto', and 'constructor' */
public static final String STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE = "struts.objectFactory.spring.autoWire";
/** Whether the autowire strategy chosen by STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE is always respected. Defaults
* to false, which is the legacy behavior that tries to determine the best strategy for the situation.
* @since 2.1.3
*/
public static final String STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE_ALWAYS_RESPECT = "struts.objectFactory.spring.autoWire.alwaysRespect";
/** Whether Spring should use its class cache or not */
public static final String STRUTS_OBJECTFACTORY_SPRING_USE_CLASS_CACHE = "struts.objectFactory.spring.useClassCache";
@@ -50,6 +50,23 @@ public class StrutsSpringObjectFactory extends SpringObjectFactory {
@Inject(value=StrutsConstants.STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE,required=false) String autoWire,
@Inject(value=StrutsConstants.STRUTS_OBJECTFACTORY_SPRING_USE_CLASS_CACHE,required=false) String useClassCacheStr,
@Inject ServletContext servletContext) {
this(autoWire, "false", useClassCacheStr, servletContext);
}
/**
* Constructs the spring object factory
* @param autoWire The type of autowiring to use
* @param alwaysAutoWire Whether to always respect the autowiring or not
* @param useClassCacheStr Whether to use the class cache or not
* @param servletContext The servlet context
* @since 2.1.3
*/
@Inject
public StrutsSpringObjectFactory(
@Inject(value=StrutsConstants.STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE,required=false) String autoWire,
@Inject(value=StrutsConstants.STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE_ALWAYS_RESPECT,required=false) String alwaysAutoWire,
@Inject(value=StrutsConstants.STRUTS_OBJECTFACTORY_SPRING_USE_CLASS_CACHE,required=false) String useClassCacheStr,
@Inject ServletContext servletContext) {
super();
boolean useClassCache = "true".equals(useClassCacheStr);
@@ -85,6 +102,8 @@ public class StrutsSpringObjectFactory extends SpringObjectFactory {
this.setUseClassCache(useClassCache);
this.setAlwaysRespectAutowireStrategy("true".equalsIgnoreCase(alwaysAutoWire));
LOG.info("... initialized Struts-Spring integration successfully");
}
}