1 64 65 package com.jcorporate.expresso.core.controller; 66 67 import com.jcorporate.expresso.core.ExpressoConstants; 68 import com.jcorporate.expresso.core.jsdkapi.GenericSession; 69 import org.apache.struts.config.ForwardConfig; 70 71 import javax.servlet.ServletException ; 72 import javax.servlet.http.HttpServletRequest ; 73 import java.io.Serializable ; 74 import java.util.HashMap ; 75 import java.util.Map ; 76 77 84 85 public class DynamicForwarder implements Serializable { 86 88 91 Map sessionForwards = new HashMap (); 92 93 96 private static final Object objectLock = new Object (); 97 98 101 protected DynamicForwarder() { 102 103 } 104 105 113 public static void addConfig(String pageStyle, 114 HttpServletRequest servletRequest, 115 ForwardConfig forwardConfig) throws ServletException { 116 synchronized (objectLock) { 117 DynamicForwarder forwarder = (DynamicForwarder) GenericSession 118 .getAttribute(servletRequest, ExpressoConstants 119 .PROCESSOR_FORWARD_KEY); 120 if (forwarder == null) { 121 122 forwarder = new DynamicForwarder(); 123 GenericSession.setAttribute(servletRequest, 124 ExpressoConstants.PROCESSOR_FORWARD_KEY 125 , forwarder); 126 } 127 128 forwarder.sessionForwards.put(pageStyle 129 , forwardConfig); 130 } 131 } 132 133 142 public static synchronized ForwardConfig redeemConfig(String pageStyle, 143 HttpServletRequest servletRequest) throws ServletException { 144 synchronized (objectLock) { 145 DynamicForwarder forwarder = (DynamicForwarder) GenericSession 146 .getAttribute(servletRequest, ExpressoConstants 147 .PROCESSOR_FORWARD_KEY); 148 if (forwarder == null) { 149 return null; 150 } 151 152 ForwardConfig fc; 153 fc = (ForwardConfig) forwarder.sessionForwards.get(pageStyle); 154 if (fc != null) { 155 forwarder.sessionForwards.remove(pageStyle); 156 } 157 return fc; 158 } 159 } 160 } | Popular Tags |