mvc support - wip preparing for release

This commit is contained in:
Keith Donald
2007-10-28 18:24:50 +00:00
parent e59408ffb3
commit cc0f5dedd0
66 changed files with 2410 additions and 85 deletions

View File

@@ -26,32 +26,32 @@
<dependency org="xerces" name="xercesImpl" rev="2.8.0"/>
<dependency org="xml-apis" name="xml-apis" rev="1.3.03"/>
-->
<dependency org="org.springframework" name="spring-beans" rev="2.1-m4" />
<dependency org="org.springframework" name="spring-beans" rev="2.5-rc1" />
<dependency org="org.springframework" name="spring-binding" rev="latest.integration" />
<dependency org="org.springframework" name="spring-core" rev="2.1-m4" />
<dependency org="org.springframework" name="spring-context" rev="2.1-m4" />
<dependency org="org.springframework" name="spring-web" rev="2.1-m4" />
<dependency org="org.springframework" name="spring-core" rev="2.5-rc1" />
<dependency org="org.springframework" name="spring-context" rev="2.5-rc1" />
<dependency org="org.springframework" name="spring-web" rev="2.5-rc1" />
<!-- testing support only dependencies -->
<dependency org="junit" name="junit" rev="3.8.2" conf="buildtime, testing->default" />
<!-- spring mvc only dependencies -->
<dependency org="org.springframework" name="spring-webmvc" rev="2.1-m4" conf="buildtime, mvc->default" />
<dependency org="org.springframework" name="spring-webmvc" rev="2.5-rc1" conf="buildtime, mvc->default" />
<!-- spring portlet mvc only dependencies -->
<dependency org="org.springframework" name="spring-webmvc-portlet" rev="2.1-m4" conf="buildtime, portlet->default" />
<dependency org="org.springframework" name="spring-webmvc-portlet" rev="2.5-rc1" conf="buildtime, portlet->default" />
<!-- struts only dependencies -->
<dependency org="struts" name="struts" rev="1.2.9" conf="buildtime, struts->default" />
<dependency org="org.springframework" name="spring-webmvc-struts" rev="2.1-m4" conf="buildtime, struts->default" />
<dependency org="org.springframework" name="spring-webmvc-struts" rev="2.5-rc1" conf="buildtime, struts->default" />
<!-- build time only dependencies -->
<dependency org="javax.servlet" name="servlet-api" rev="2.4" conf="buildtime->default" />
<dependency org="javax.portlet" name="portlet-api" rev="1.0" conf="buildtime->default" />
<dependency org="javax.el" name="el-api" rev="1.0" conf="buildtime->default" />
<dependency org="org.hibernate" name="hibernate" rev="3.2.4.ga" conf="buildtime->default" />
<dependency org="org.springframework" name="spring-orm" rev="2.1-m4" conf="buildtime->default" />
<dependency org="org.springframework" name="spring-tx" rev="2.1-m4" conf="buildtime->default" />
<dependency org="org.springframework" name="spring-orm" rev="2.5-rc1" conf="buildtime->default" />
<dependency org="org.springframework" name="spring-tx" rev="2.5-rc1" conf="buildtime->default" />
<dependency org="javax.persistence" name="persistence-api" rev="1.0b" conf="buildtime->default" />
<dependency org="concurrent" name="concurrent" rev="1.3.4" conf="buildtime->default" />
@@ -60,8 +60,8 @@
<dependency org="log4j" name="log4j" rev="1.2.14" conf="test->default" />
<dependency org="org.easymock" name="easymock" rev="2.2" conf="test->default" />
<dependency org="com.cenqua.clover" name="clover" rev="1.3.12" conf="test->default" />
<dependency org="org.springframework" name="spring-jdbc" rev="2.1-m4" conf="test->default" />
<dependency org="org.springframework" name="spring-test" rev="2.1-m4" conf="test->default" />
<dependency org="org.springframework" name="spring-jdbc" rev="2.5-rc1" conf="test->default" />
<dependency org="org.springframework" name="spring-test" rev="2.5-rc1" conf="test->default" />
<dependency org="org.hibernate" name="hibernate" rev="3.2.4.ga" conf="test->default" />
<dependency org="org.hibernate" name="hibernate-entitymanager" rev="3.3.1.ga" conf="test->default" />
<dependency org="org.hibernate" name="hibernate-commons-annotations" rev="3.3.0.ga" conf="test->default" />

View File

@@ -90,11 +90,7 @@ public class ServletExternalContext implements ExternalContext {
*/
private SharedAttributeMap applicationMap;
private String flowId;
private String flowExecutionKey;
private RequestPath requestPath;
private FlowRequestInfo flowRequestInfo;
private String encodingScheme = DEFAULT_ENCODING_SCHEME;
@@ -128,25 +124,51 @@ public class ServletExternalContext implements ExternalContext {
this.requestMap = new LocalAttributeMap(new HttpServletRequestMap(this.request));
this.sessionMap = new LocalSharedAttributeMap(new HttpSessionMap(this.request));
this.applicationMap = new LocalSharedAttributeMap(new HttpServletContextMap(context));
parseRequestPathInfo();
this.flowRequestInfo = parseFlowRequestInfo(this.request);
}
public static class FlowRequestInfo {
private String flowId;
private String flowExecutionKey;
private RequestPath requestPath;
public FlowRequestInfo(String flowId, String flowExecutionKey, RequestPath requestPath) {
this.flowId = flowId;
this.flowExecutionKey = flowExecutionKey;
this.requestPath = requestPath;
}
public String getFlowId() {
return flowId;
}
public String getFlowExecutionKey() {
return flowExecutionKey;
}
public RequestPath getRequestPath() {
return requestPath;
}
}
public String getFlowId() {
return flowId;
return flowRequestInfo.getFlowId();
}
public String getFlowExecutionKey() {
return flowExecutionKey;
return flowRequestInfo.getFlowExecutionKey();
}
public RequestPath getRequestPath() {
return flowRequestInfo.getRequestPath();
}
public String getRequestMethod() {
return request.getMethod();
}
public RequestPath getRequestPath() {
return requestPath;
}
public ParameterMap getRequestParameterMap() {
return requestParameterMap;
}
@@ -183,8 +205,6 @@ public class ServletExternalContext implements ExternalContext {
return flowExecutionRedirector != null || flowDefinitionRedirector != null || resourceUri != null;
}
// response requesters
public PrintWriter getResponseWriter() {
try {
return response.getWriter();
@@ -194,6 +214,30 @@ public class ServletExternalContext implements ExternalContext {
}
}
public String encode(String string) {
try {
return URLEncoder.encode(string, encodingScheme);
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("Unsupported encoding errors should never happen", e);
}
}
public String buildFlowDefinitionUrl(FlowDefinitionRequestInfo requestInfo) {
return getFlowExecutorPath() + "/" + requestInfo.getFlowDefinitionId() + requestPath(requestInfo)
+ requestParameters(requestInfo) + fragment(requestInfo);
}
public String buildFlowExecutionUrl(FlowExecutionRequestInfo requestInfo, boolean contextRelative) {
String contextRelativeUrl = getFlowExecutionsPath() + requestInfo.getFlowDefinitionId() + "/"
+ requestInfo.getFlowExecutionKey() + requestPath(requestInfo) + requestParameters(requestInfo)
+ fragment(requestInfo);
if (contextRelative) {
return contextRelativeUrl;
} else {
return request.getScheme() + request.getServerName() + contextRelativeUrl;
}
}
public void sendFlowExecutionRedirect(FlowExecutionRequestInfo request) {
flowExecutionRedirector = new FlowExecutionRedirector(request);
}
@@ -206,32 +250,6 @@ public class ServletExternalContext implements ExternalContext {
this.resourceUri = resourceUri;
}
// helpers
public String encode(String string) {
try {
return URLEncoder.encode(string, encodingScheme);
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("Unsupported encoding errors should never happen", e);
}
}
public String buildFlowDefinitionUrl(FlowDefinitionRequestInfo requestInfo) {
return request.getContextPath() + request.getServletPath() + "/" + requestInfo.getFlowDefinitionId()
+ requestPath(requestInfo) + requestParameters(requestInfo) + fragment(requestInfo);
}
public String buildFlowExecutionUrl(FlowExecutionRequestInfo requestInfo, boolean contextRelative) {
String contextRelativeUrl = request.getContextPath() + request.getServletPath() + "/executions/"
+ requestInfo.getFlowDefinitionId() + "/" + requestInfo.getFlowExecutionKey()
+ requestPath(requestInfo) + requestParameters(requestInfo) + fragment(requestInfo);
if (contextRelative) {
return contextRelativeUrl;
} else {
return request.getScheme() + request.getServerName() + contextRelativeUrl;
}
}
// execution processing result setters
public void setPausedResult(String flowExecutionKey) {
@@ -247,7 +265,7 @@ public class ServletExternalContext implements ExternalContext {
public void setExceptionResult(FlowException e) {
result = 2;
exception = e;
processedFlowExecutionKey = flowExecutionKey;
processedFlowExecutionKey = flowRequestInfo.getFlowExecutionKey();
}
/**
@@ -293,29 +311,45 @@ public class ServletExternalContext implements ExternalContext {
}
}
private void parseRequestPathInfo() {
// hooks subclasses may override
protected FlowRequestInfo parseFlowRequestInfo(HttpServletRequest request) {
String pathInfo = request.getPathInfo();
if (pathInfo == null) {
throw new IllegalArgumentException(
"The requestPathInfo is null: unable to extract flow definition id or flow execution key");
}
String flowId;
String flowExecutionKey;
RequestPath path = new RequestPath(pathInfo);
if (path.getElement(0).equals("executions")) {
flowId = path.getElement(1);
flowExecutionKey = path.getElement(2);
if (path.getElementCount() > 3) {
requestPath = path.pop(3);
path = path.pop(3);
} else {
requestPath = null;
path = null;
}
} else {
flowId = path.getElement(0);
flowExecutionKey = null;
if (path.getElementCount() > 1) {
requestPath = path.pop(1);
path = path.pop(1);
} else {
requestPath = null;
path = null;
}
}
return new FlowRequestInfo(flowId, flowExecutionKey, path);
}
// private helpers
private String getFlowExecutorPath() {
return request.getContextPath() + request.getServletPath();
}
private String getFlowExecutionsPath() {
return getFlowExecutorPath() + "/executions/";
}
private boolean isPausedResult() {
@@ -411,9 +445,7 @@ public class ServletExternalContext implements ExternalContext {
public void issueRedirect() throws IOException {
FlowExecutionRequestInfo requestInfo = (FlowExecutionRequestInfo) getRequestInfo();
String targetUrl = request.getContextPath() + request.getServletPath() + "/executions/"
+ requestInfo.getFlowDefinitionId() + "/" + requestInfo.getFlowExecutionKey()
+ requestPath(getRequestInfo()) + requestParameters(getRequestInfo()) + fragment(getRequestInfo());
String targetUrl = buildFlowExecutionUrl(requestInfo, true);
response.sendRedirect(response.encodeRedirectURL(targetUrl));
}
}
@@ -424,10 +456,8 @@ public class ServletExternalContext implements ExternalContext {
}
public void issueRedirect() throws IOException {
FlowDefinitionRequestInfo redirect = (FlowDefinitionRequestInfo) getRequestInfo();
String targetUrl = request.getContextPath() + request.getServletPath() + "/"
+ redirect.getFlowDefinitionId() + requestPath(getRequestInfo())
+ requestParameters(getRequestInfo()) + fragment(getRequestInfo());
FlowDefinitionRequestInfo requestInfo = (FlowDefinitionRequestInfo) getRequestInfo();
String targetUrl = buildFlowDefinitionUrl(requestInfo);
response.sendRedirect(response.encodeRedirectURL(targetUrl));
}
}

View File

@@ -1,13 +1,14 @@
package org.springframework.webflow.engine.builder;
import org.springframework.binding.expression.Expression;
import org.springframework.core.io.ResourceLoader;
import org.springframework.webflow.execution.Action;
import org.springframework.webflow.execution.ViewFactory;
public interface ViewFactoryCreator {
public ViewFactory createViewFactory(Expression viewId);
public ViewFactory createViewFactory(Expression viewId, ResourceLoader viewResourceLoader);
public Action createFinalResponseAction(Expression viewId);
public Action createFinalResponseAction(Expression viewId, ResourceLoader viewResourceLoader);
}