1 7 package com.inversoft.verge.mvc.controller.actionflow; 8 9 10 import java.util.HashMap ; 11 import java.util.Map ; 12 13 import javax.servlet.http.HttpServletRequest ; 14 15 import com.inversoft.verge.mvc.controller.actionflow.config.Namespace; 16 import com.inversoft.verge.mvc.controller.actionflow.config.Node; 17 18 19 28 public class ActionFlowState { 29 30 33 public static final String SESSION_KEY = "actionFlowState"; 34 35 private HttpServletRequest request; 36 37 38 41 public ActionFlowState(HttpServletRequest request) { 42 this.request = request; 43 } 44 45 46 52 public Node getCurrentNodeForNamespace(Namespace namespace) { 53 Map state = (Map ) request.getSession().getAttribute(SESSION_KEY); 54 if (state == null) { 55 state = new HashMap (); 56 request.getSession().setAttribute(SESSION_KEY, state); 57 } 58 59 return (Node) state.get(namespace.getName()); 60 } 61 62 68 public Node getCurrentNodeForNamespace(String namespace) { 69 Map state = (Map ) request.getSession().getAttribute(SESSION_KEY); 70 if (state == null) { 71 state = new HashMap (); 72 request.getSession().setAttribute(SESSION_KEY, state); 73 } 74 75 return (Node) state.get(namespace); 76 } 77 78 85 void setCurrentNodeForNamespace(Namespace namespace, Node node) { 86 Map state = (Map ) request.getSession().getAttribute(SESSION_KEY); 87 if (state == null) { 88 state = new HashMap (); 89 request.getSession().setAttribute(SESSION_KEY, state); 90 } 91 92 state.put(namespace.getName(), node); 93 } 94 } | Popular Tags |