code polish

This commit is contained in:
Keith Donald
2008-10-17 14:26:29 +00:00
parent 8fb8d3437c
commit 375c8dbffb
8 changed files with 44 additions and 15 deletions

View File

@@ -92,7 +92,8 @@ public class FlowDefinitionRegistryImpl implements FlowDefinitionRegistry {
public void registerFlowDefinition(FlowDefinitionHolder definitionHolder) {
Assert.notNull(definitionHolder, "The holder of the flow definition to register is required");
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);
}
@@ -115,6 +116,6 @@ public class FlowDefinitionRegistryImpl implements FlowDefinitionRegistry {
}
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();
}
}

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.webflow.definition.registry;
import org.springframework.core.style.ToStringCreator;
import org.springframework.webflow.definition.FlowDefinition;
/**
@@ -60,4 +61,8 @@ class StaticFlowDefinitionHolder implements FlowDefinitionHolder {
return flowDefinition.hashCode();
}
public String toString() {
return new ToStringCreator(this).append("flowDefinition", flowDefinition).toString();
}
}

View File

@@ -17,6 +17,8 @@ package org.springframework.webflow.engine.builder;
import org.apache.commons.logging.Log;
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.registry.FlowDefinitionConstructionException;
import org.springframework.webflow.definition.registry.FlowDefinitionHolder;
@@ -60,6 +62,7 @@ public class DefaultFlowHolder implements FlowDefinitionHolder {
* @param assembler the flow assembler to use
*/
public DefaultFlowHolder(FlowAssembler assembler) {
Assert.notNull(assembler, "The FlowAssembler is required");
this.assembler = assembler;
}
@@ -106,7 +109,7 @@ public class DefaultFlowHolder implements FlowDefinitionHolder {
}
public String toString() {
return "'" + getFlowDefinitionId() + "'";
return new ToStringCreator(this).append("flowBuilder", assembler.getFlowBuilder()).toString();
}
}

View File

@@ -41,6 +41,7 @@ import org.springframework.context.support.GenericApplicationContext;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.core.JdkVersion;
import org.springframework.core.io.Resource;
import org.springframework.core.style.ToStringCreator;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
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();
}
}

View File

@@ -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
* class is closely coupled with package-private <code>FlowSessionImpl</code> and
* <code>RequestControlContextImpl</code>. The three classes work together to form a complete flow execution
* implementation based on a finite state machine.
* class is closely coupled with package-private <code>FlowSessionImpl</code> and <code>RequestControlContextImpl</code>
* . The three classes work together to form a complete flow execution implementation based on a finite state machine.
* <p>
* 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
@@ -211,7 +210,7 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable {
IllegalStateException {
Assert.state(!started, "This flow has already been started; you cannot call 'start()' more than once");
if (logger.isDebugEnabled()) {
logger.debug("Starting execution in " + externalContext);
logger.debug("Starting in " + externalContext + " with input " + input);
}
started = true;
MessageContext messageContext = createMessageContext(null);
@@ -230,13 +229,13 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable {
try {
listeners.firePaused(requestContext);
} catch (Throwable e) {
logger.error("Flow execution listener threw exception", e);
logger.error("FlowExecutionListener threw exception", e);
}
}
try {
listeners.fireRequestProcessed(requestContext);
} catch (Throwable e) {
logger.error("Flow execution listener threw exception", e);
logger.error("FlowExecutionListener threw exception", e);
}
RequestContextHolder.setRequestContext(null);
}
@@ -251,7 +250,7 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable {
}
}
if (logger.isDebugEnabled()) {
logger.debug("Resuming execution in " + externalContext);
logger.debug("Resuming in " + externalContext);
}
Flow activeFlow = getActiveSessionInternal().getFlow();
MessageContext messageContext = createMessageContext(activeFlow.getApplicationContext());
@@ -271,13 +270,13 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable {
try {
listeners.firePaused(requestContext);
} catch (Throwable e) {
logger.error("Flow execution listener threw exception", e);
logger.error("FlowExecutionListener threw exception", e);
}
}
try {
listeners.fireRequestProcessed(requestContext);
} catch (Throwable e) {
logger.error("Flow execution listener threw exception", e);
logger.error("FlowExecutionListener threw exception", e);
}
RequestContextHolder.setRequestContext(null);
}
@@ -539,8 +538,8 @@ public class FlowExecutionImpl implements FlowExecution, Externalizable {
// internal helpers
/**
* Activate a new <code>FlowSession</code> for the flow definition. Creates the new flow session and pushes it
* onto the stack.
* Activate a new <code>FlowSession</code> for the flow definition. Creates the new flow session and pushes it onto
* the stack.
* @param flow the flow definition
* @return the new flow session
*/

View File

@@ -15,6 +15,8 @@
*/
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.webflow.context.ExternalContext;
import org.springframework.webflow.context.ExternalContextHolder;
@@ -72,6 +74,8 @@ import org.springframework.webflow.execution.repository.FlowExecutionRepository;
*/
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.
*/
@@ -127,6 +131,9 @@ public class FlowExecutorImpl implements FlowExecutor {
public FlowExecutionResult launchExecution(String flowId, MutableAttributeMap input, ExternalContext context)
throws FlowException {
try {
if (logger.isDebugEnabled()) {
logger.debug("Launching new execution of flow '" + flowId + "' with input " + input);
}
ExternalContextHolder.setExternalContext(context);
FlowDefinition flowDefinition = definitionLocator.getFlowDefinition(flowId);
FlowExecution flowExecution = executionFactory.createFlowExecution(flowDefinition);
@@ -144,6 +151,9 @@ public class FlowExecutorImpl implements FlowExecutor {
public FlowExecutionResult resumeExecution(String flowExecutionKey, ExternalContext context) throws FlowException {
try {
if (logger.isDebugEnabled()) {
logger.debug("Resuming flow execution with key '" + flowExecutionKey);
}
ExternalContextHolder.setExternalContext(context);
FlowExecutionKey key = executionRepository.parseFlowExecutionKey(flowExecutionKey);
FlowExecutionLock lock = executionRepository.getLock(key);

View File

@@ -49,7 +49,7 @@ public class AbstractFlowHandler implements FlowHandler {
}
public String toString() {
return new ToStringCreator(this).append("flowId", getFlowId()).toString();
return new ToStringCreator(this).toString();
}
}

View File

@@ -20,6 +20,7 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.style.ToStringCreator;
import org.springframework.util.Assert;
import org.springframework.web.servlet.handler.AbstractHandlerMapping;
import org.springframework.webflow.context.servlet.DefaultFlowUrlHandler;
@@ -113,7 +114,12 @@ public class FlowHandlerMapping extends AbstractHandlerMapping {
return null;
}
public String toString() {
return new ToStringCreator(this).append("flowRegistry", flowRegistry).toString();
}
private static class DefaultFlowHandler extends AbstractFlowHandler {
private String flowId;
public DefaultFlowHandler(String flowId) {