1
2
3
4
5 package net.sf.wfnm;
6
7 import org.apache.commons.logging.Log;
8 import org.apache.commons.logging.LogFactory;
9
10 import java.util.Enumeration;
11 import java.util.HashSet;
12 import java.util.Set;
13 import java.util.Stack;
14
15
16 /***
17 * A log helper that display debug information about the internal status of the framework and that display which
18 * objects the framework automatically removes.
19 *
20 * @author <a href="mailto:malbari@users.sourceforge.net">Maurizio Albari</a>
21 * @version 1.0.6
22 */
23 public class LogHelper {
24 /***
25 * The log.
26 */
27 private static Log log = LogFactory.getLog(LogHelper.class);
28
29 /***
30 * Log the webflow stack.
31 *
32 * @param container the attribute container
33 */
34 public static void logWebflowStack(AttributeContainer container) {
35 if (log.isDebugEnabled() && NavigationManagerFactory.existsInstance(container)) {
36 NavigationManager navigationManager = NavigationManagerFactory.getInstance(container);
37
38 Set sessionSet = new HashSet();
39
40 for (Enumeration e = container.getAttributeNames(); e.hasMoreElements();) {
41 String attName = (String) e.nextElement();
42 sessionSet.add(attName);
43 }
44
45 Stack webflowStack = navigationManager.getWebflowStack();
46
47 log.debug("***** Webflow stack: START *****");
48
49 for (int i = 0; i < webflowStack.size(); i++) {
50 Webflow webflow = (Webflow) webflowStack.elementAt(i);
51 log.debug("Webflow " + webflow.getName() + " owns " + webflow.getOwnedObjectSet());
52 sessionSet.removeAll(webflow.getOwnedObjectSet());
53
54 Stack pageStack = webflow.getPageStack();
55
56 for (int j = 0; j < pageStack.size(); j++) {
57 Page page = (Page) pageStack.get(j);
58 log.debug("\tpage " + page.getUrl() + " owns " + page.getOwnedObjectSet());
59 sessionSet.removeAll(page.getOwnedObjectSet());
60 }
61 }
62
63 log.debug("Attribute container owns " + sessionSet);
64
65 log.debug("***** Webflow stack: END *****");
66 }
67 }
68 }