Does Spring-WebFlow provide a way of getting to know the number of flows currently executing ?
I could work around it with a global bean, but maybe WebFlow provides a solution out-of-the-box.
Edit: As requested, here the so called "Global Bean" solution based on a FlowExecutionListenerAdapter
package your.package;
import org.apache.log4j.Logger;
import org.springframework.webflow.core.collection.AttributeMap;
import org.springframework.webflow.definition.StateDefinition;
import org.springframework.webflow.definition.TransitionDefinition;
import org.springframework.webflow.execution.FlowExecutionListenerAdapter;
import org.springframework.webflow.execution.FlowSession;
import org.springframework.webflow.execution.RequestContext;
public class FlowExecutionListener extends FlowExecutionListenerAdapter {
private static Logger logger = Logger.getLogger(FlowExecutionListener.class);
private int sessionCount = 0;
@Override
public void sessionStarted(final RequestContext context, final FlowSession session) {
super.sessionStarted(context, session);
sessionCount++;
logger.debug("sessionStarted, state: " + session.getState().getId() + ", count: " + sessionCount);
}
@Override
public void sessionEnded(final RequestContext context, final FlowSession session, final String outcome, final AttributeMap output) {
super.sessionEnded(context, session, outcome, output);
sessionCount--;
logger.debug("sessionEnded, state: " + session.getState().getId() + ", count: " + sessionCount);
}
}
The bean must be registered at Spring-level:
<bean id="flowExecutionListener" class="your.package.FlowExecutionListener" />
Edit2:
If you have more than one WebFlow in your application, this would count all the active flows. In case you want to account them separately, you can get the flow's ID with session.getDefinition().getId().