WW-4144 Defines new extension point to build Results and adjusts ObjectFactory to use it

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1506865 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Lukasz Lenart
2013-07-25 09:42:16 +00:00
parent e366ae8510
commit b370886797
2 changed files with 26 additions and 0 deletions
@@ -20,6 +20,7 @@ import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.config.entities.InterceptorConfig;
import com.opensymphony.xwork2.config.entities.ResultConfig;
import com.opensymphony.xwork2.conversion.TypeConverter;
import com.opensymphony.xwork2.factory.ResultBuilder;
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.interceptor.Interceptor;
@@ -53,6 +54,8 @@ public class ObjectFactory implements Serializable {
private Container container;
protected ReflectionProvider reflectionProvider;
private ResultBuilder resultBuilder;
@Inject(value="objectFactory.classloader", required=false)
public void setClassLoader(ClassLoader cl) {
this.ccl = cl;
@@ -75,6 +78,11 @@ public class ObjectFactory implements Serializable {
this.container = container;
}
@Inject(required = false)
public void setResultBuilder(ResultBuilder resultBuilder) {
this.resultBuilder = resultBuilder;
}
/**
* @deprecated Since 2.1
*/
@@ -221,6 +229,9 @@ public class ObjectFactory implements Serializable {
* @param extraContext a Map of extra context which uses the same keys as the {@link com.opensymphony.xwork2.ActionContext}
*/
public Result buildResult(ResultConfig resultConfig, Map<String, Object> extraContext) throws Exception {
if (resultBuilder != null) {
return resultBuilder.buildResult(resultConfig, extraContext);
}
String resultClassName = resultConfig.getClassName();
Result result = null;
@@ -0,0 +1,15 @@
package com.opensymphony.xwork2.factory;
import com.opensymphony.xwork2.Result;
import com.opensymphony.xwork2.config.entities.ResultConfig;
import java.util.Map;
/**
* Used by {@link com.opensymphony.xwork2.ObjectFactory} to build {@link com.opensymphony.xwork2.Result}
*/
public interface ResultBuilder {
Result buildResult(ResultConfig resultConfig, Map<String, Object> extraContext) throws Exception;
}