code polish
This commit is contained in:
@@ -92,7 +92,8 @@ public class FlowDefinitionRegistryImpl implements FlowDefinitionRegistry {
|
|||||||
public void registerFlowDefinition(FlowDefinitionHolder definitionHolder) {
|
public void registerFlowDefinition(FlowDefinitionHolder definitionHolder) {
|
||||||
Assert.notNull(definitionHolder, "The holder of the flow definition to register is required");
|
Assert.notNull(definitionHolder, "The holder of the flow definition to register is required");
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Registering flow definition held by " + definitionHolder);
|
logger.debug("Registering flow definition held by " + definitionHolder + " under id '"
|
||||||
|
+ definitionHolder.getFlowDefinitionId() + "'");
|
||||||
}
|
}
|
||||||
flowDefinitions.put(definitionHolder.getFlowDefinitionId(), definitionHolder);
|
flowDefinitions.put(definitionHolder.getFlowDefinitionId(), definitionHolder);
|
||||||
}
|
}
|
||||||
@@ -115,6 +116,6 @@ public class FlowDefinitionRegistryImpl implements FlowDefinitionRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringCreator(this).append("flowDefinitions", flowDefinitions).append("parent", parent).toString();
|
return new ToStringCreator(this).append("flowIds", getFlowDefinitionIds()).append("parent", parent).toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.webflow.definition.registry;
|
package org.springframework.webflow.definition.registry;
|
||||||
|
|
||||||
|
import org.springframework.core.style.ToStringCreator;
|
||||||
import org.springframework.webflow.definition.FlowDefinition;
|
import org.springframework.webflow.definition.FlowDefinition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,4 +61,8 @@ class StaticFlowDefinitionHolder implements FlowDefinitionHolder {
|
|||||||
return flowDefinition.hashCode();
|
return flowDefinition.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringCreator(this).append("flowDefinition", flowDefinition).toString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,8 @@ package org.springframework.webflow.engine.builder;
|
|||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.core.style.ToStringCreator;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.webflow.definition.FlowDefinition;
|
import org.springframework.webflow.definition.FlowDefinition;
|
||||||
import org.springframework.webflow.definition.registry.FlowDefinitionConstructionException;
|
import org.springframework.webflow.definition.registry.FlowDefinitionConstructionException;
|
||||||
import org.springframework.webflow.definition.registry.FlowDefinitionHolder;
|
import org.springframework.webflow.definition.registry.FlowDefinitionHolder;
|
||||||
@@ -60,6 +62,7 @@ public class DefaultFlowHolder implements FlowDefinitionHolder {
|
|||||||
* @param assembler the flow assembler to use
|
* @param assembler the flow assembler to use
|
||||||
*/
|
*/
|
||||||
public DefaultFlowHolder(FlowAssembler assembler) {
|
public DefaultFlowHolder(FlowAssembler assembler) {
|
||||||
|
Assert.notNull(assembler, "The FlowAssembler is required");
|
||||||
this.assembler = assembler;
|
this.assembler = assembler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +109,7 @@ public class DefaultFlowHolder implements FlowDefinitionHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "'" + getFlowDefinitionId() + "'";
|
return new ToStringCreator(this).append("flowBuilder", assembler.getFlowBuilder()).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -41,6 +41,7 @@ import org.springframework.context.support.GenericApplicationContext;
|
|||||||
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
|
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
|
||||||
import org.springframework.core.JdkVersion;
|
import org.springframework.core.JdkVersion;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.core.style.ToStringCreator;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
@@ -964,4 +965,8 @@ public class FlowModelFlowBuilder extends AbstractFlowBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringCreator(this).append("resource", flowModelHolder.getFlowModelResource()).toString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,9 +57,8 @@ import org.springframework.webflow.execution.View;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Default implementation of FlowExecution that uses a stack-based data structure to manage spawned flow sessions. This
|
* Default implementation of FlowExecution that uses a stack-based data structure to manage spawned flow sessions. This
|
||||||
* class is closely coupled with package-private <code>FlowSessionImpl</code> and
|
* class is closely coupled with package-private <code>FlowSessionImpl</code> and <code>RequestControlContextImpl</code>
|
||||||
* <code>RequestControlContextImpl</code>. The three classes work together to form a complete flow execution
|
* . The three classes work together to form a complete flow execution implementation based on a finite state machine.
|
||||||
* implementation based on a finite state machine.
|
|
||||||
* <p>
|
* <p>
|
||||||
* This implementation of FlowExecution is serializable so it can be safely stored in an HTTP session or other
|
* This implementation of FlowExecution is serializable so it can be safely stored in an HTTP session or other
|
||||||
* persistent store such as a file, database, or client-side form field. Once deserialized, the
|
* persistent store such as a file, database, or client-side form field. Once deserialized, the
|
||||||
@@ -211,7 +210,7 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable {
|
|||||||
IllegalStateException {
|
IllegalStateException {
|
||||||
Assert.state(!started, "This flow has already been started; you cannot call 'start()' more than once");
|
Assert.state(!started, "This flow has already been started; you cannot call 'start()' more than once");
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Starting execution in " + externalContext);
|
logger.debug("Starting in " + externalContext + " with input " + input);
|
||||||
}
|
}
|
||||||
started = true;
|
started = true;
|
||||||
MessageContext messageContext = createMessageContext(null);
|
MessageContext messageContext = createMessageContext(null);
|
||||||
@@ -230,13 +229,13 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable {
|
|||||||
try {
|
try {
|
||||||
listeners.firePaused(requestContext);
|
listeners.firePaused(requestContext);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.error("Flow execution listener threw exception", e);
|
logger.error("FlowExecutionListener threw exception", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
listeners.fireRequestProcessed(requestContext);
|
listeners.fireRequestProcessed(requestContext);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.error("Flow execution listener threw exception", e);
|
logger.error("FlowExecutionListener threw exception", e);
|
||||||
}
|
}
|
||||||
RequestContextHolder.setRequestContext(null);
|
RequestContextHolder.setRequestContext(null);
|
||||||
}
|
}
|
||||||
@@ -251,7 +250,7 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Resuming execution in " + externalContext);
|
logger.debug("Resuming in " + externalContext);
|
||||||
}
|
}
|
||||||
Flow activeFlow = getActiveSessionInternal().getFlow();
|
Flow activeFlow = getActiveSessionInternal().getFlow();
|
||||||
MessageContext messageContext = createMessageContext(activeFlow.getApplicationContext());
|
MessageContext messageContext = createMessageContext(activeFlow.getApplicationContext());
|
||||||
@@ -271,13 +270,13 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable {
|
|||||||
try {
|
try {
|
||||||
listeners.firePaused(requestContext);
|
listeners.firePaused(requestContext);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.error("Flow execution listener threw exception", e);
|
logger.error("FlowExecutionListener threw exception", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
listeners.fireRequestProcessed(requestContext);
|
listeners.fireRequestProcessed(requestContext);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.error("Flow execution listener threw exception", e);
|
logger.error("FlowExecutionListener threw exception", e);
|
||||||
}
|
}
|
||||||
RequestContextHolder.setRequestContext(null);
|
RequestContextHolder.setRequestContext(null);
|
||||||
}
|
}
|
||||||
@@ -539,8 +538,8 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable {
|
|||||||
// internal helpers
|
// internal helpers
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activate a new <code>FlowSession</code> for the flow definition. Creates the new flow session and pushes it
|
* Activate a new <code>FlowSession</code> for the flow definition. Creates the new flow session and pushes it onto
|
||||||
* onto the stack.
|
* the stack.
|
||||||
* @param flow the flow definition
|
* @param flow the flow definition
|
||||||
* @return the new flow session
|
* @return the new flow session
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.webflow.executor;
|
package org.springframework.webflow.executor;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.webflow.context.ExternalContext;
|
import org.springframework.webflow.context.ExternalContext;
|
||||||
import org.springframework.webflow.context.ExternalContextHolder;
|
import org.springframework.webflow.context.ExternalContextHolder;
|
||||||
@@ -72,6 +74,8 @@ import org.springframework.webflow.execution.repository.FlowExecutionRepository;
|
|||||||
*/
|
*/
|
||||||
public class FlowExecutorImpl implements FlowExecutor {
|
public class FlowExecutorImpl implements FlowExecutor {
|
||||||
|
|
||||||
|
private static final Log logger = LogFactory.getLog(FlowExecutorImpl.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The locator to access flow definitions registered in a central registry.
|
* The locator to access flow definitions registered in a central registry.
|
||||||
*/
|
*/
|
||||||
@@ -127,6 +131,9 @@ public class FlowExecutorImpl implements FlowExecutor {
|
|||||||
public FlowExecutionResult launchExecution(String flowId, MutableAttributeMap input, ExternalContext context)
|
public FlowExecutionResult launchExecution(String flowId, MutableAttributeMap input, ExternalContext context)
|
||||||
throws FlowException {
|
throws FlowException {
|
||||||
try {
|
try {
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("Launching new execution of flow '" + flowId + "' with input " + input);
|
||||||
|
}
|
||||||
ExternalContextHolder.setExternalContext(context);
|
ExternalContextHolder.setExternalContext(context);
|
||||||
FlowDefinition flowDefinition = definitionLocator.getFlowDefinition(flowId);
|
FlowDefinition flowDefinition = definitionLocator.getFlowDefinition(flowId);
|
||||||
FlowExecution flowExecution = executionFactory.createFlowExecution(flowDefinition);
|
FlowExecution flowExecution = executionFactory.createFlowExecution(flowDefinition);
|
||||||
@@ -144,6 +151,9 @@ public class FlowExecutorImpl implements FlowExecutor {
|
|||||||
|
|
||||||
public FlowExecutionResult resumeExecution(String flowExecutionKey, ExternalContext context) throws FlowException {
|
public FlowExecutionResult resumeExecution(String flowExecutionKey, ExternalContext context) throws FlowException {
|
||||||
try {
|
try {
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("Resuming flow execution with key '" + flowExecutionKey);
|
||||||
|
}
|
||||||
ExternalContextHolder.setExternalContext(context);
|
ExternalContextHolder.setExternalContext(context);
|
||||||
FlowExecutionKey key = executionRepository.parseFlowExecutionKey(flowExecutionKey);
|
FlowExecutionKey key = executionRepository.parseFlowExecutionKey(flowExecutionKey);
|
||||||
FlowExecutionLock lock = executionRepository.getLock(key);
|
FlowExecutionLock lock = executionRepository.getLock(key);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class AbstractFlowHandler implements FlowHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringCreator(this).append("flowId", getFlowId()).toString();
|
return new ToStringCreator(this).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.core.style.ToStringCreator;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.web.servlet.handler.AbstractHandlerMapping;
|
import org.springframework.web.servlet.handler.AbstractHandlerMapping;
|
||||||
import org.springframework.webflow.context.servlet.DefaultFlowUrlHandler;
|
import org.springframework.webflow.context.servlet.DefaultFlowUrlHandler;
|
||||||
@@ -113,7 +114,12 @@ public class FlowHandlerMapping extends AbstractHandlerMapping {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringCreator(this).append("flowRegistry", flowRegistry).toString();
|
||||||
|
}
|
||||||
|
|
||||||
private static class DefaultFlowHandler extends AbstractFlowHandler {
|
private static class DefaultFlowHandler extends AbstractFlowHandler {
|
||||||
|
|
||||||
private String flowId;
|
private String flowId;
|
||||||
|
|
||||||
public DefaultFlowHandler(String flowId) {
|
public DefaultFlowHandler(String flowId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user