/*
* WebFlow Navigation Manager: webflow definiton, server side navigation history and automatic session cleaning.
* Distributed under LGPL license at web site http://wfnm.sourceforge.net .
*/
package net.sf.wfnm;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
import java.util.Stack;
/**
* A log helper that display debug information about the internal status of the framework and that display which
* objects the framework automatically removes.
*
* @author <a href="mailto:malbari@users.sourceforge.net">Maurizio Albari</a>
* @version 1.0.6
*/
public class LogHelper {
/**
* The log.
*/
private static Log log = LogFactory.getLog(LogHelper.class);
/**
* Log the webflow stack.
*
* @param container the attribute container
*/
public static void logWebflowStack(AttributeContainer container) {
if (log.isDebugEnabled() && NavigationManagerFactory.existsInstance(container)) {
NavigationManager navigationManager = NavigationManagerFactory.getInstance(container);
Set sessionSet = new HashSet();
for (Enumeration e = container.getAttributeNames(); e.hasMoreElements();) {
String attName = (String) e.nextElement();
sessionSet.add(attName);
}
Stack webflowStack = navigationManager.getWebflowStack();
log.debug("***** Webflow stack: START *****");
for (int i = 0; i < webflowStack.size(); i++) {
Webflow webflow = (Webflow) webflowStack.elementAt(i);
log.debug("Webflow " + webflow.getName() + " owns " + webflow.getOwnedObjectSet());
sessionSet.removeAll(webflow.getOwnedObjectSet());
Stack pageStack = webflow.getPageStack();
for (int j = 0; j < pageStack.size(); j++) {
Page page = (Page) pageStack.get(j);
log.debug("\tpage " + page.getUrl() + " owns " + page.getOwnedObjectSet());
sessionSet.removeAll(page.getOwnedObjectSet());
}
}
log.debug("Attribute container owns " + sessionSet);
log.debug("***** Webflow stack: END *****");
}
}
}