1 16 package org.springframework.webflow.context.servlet; 17 18 import javax.servlet.ServletContext ; 19 import javax.servlet.http.HttpServletRequest ; 20 import javax.servlet.http.HttpServletResponse ; 21 22 import org.springframework.core.style.ToStringCreator; 23 import org.springframework.webflow.context.ExternalContext; 24 import org.springframework.webflow.core.collection.LocalAttributeMap; 25 import org.springframework.webflow.core.collection.LocalParameterMap; 26 import org.springframework.webflow.core.collection.LocalSharedAttributeMap; 27 import org.springframework.webflow.core.collection.MutableAttributeMap; 28 import org.springframework.webflow.core.collection.ParameterMap; 29 import org.springframework.webflow.core.collection.SharedAttributeMap; 30 31 38 public class ServletExternalContext implements ExternalContext { 39 40 43 private ServletContext context; 44 45 48 private HttpServletRequest request; 49 50 53 private HttpServletResponse response; 54 55 62 public ServletExternalContext(ServletContext context, HttpServletRequest request, HttpServletResponse response) { 63 this.context = context; 64 this.request = request; 65 this.response = response; 66 } 67 68 public String getContextPath() { 69 return request.getContextPath(); 70 } 71 72 public String getDispatcherPath() { 73 return request.getServletPath(); 74 } 75 76 public String getRequestPathInfo() { 77 return request.getPathInfo(); 78 } 79 80 public ParameterMap getRequestParameterMap() { 81 return new LocalParameterMap(new HttpServletRequestParameterMap(request)); 82 } 83 84 public MutableAttributeMap getRequestMap() { 85 return new LocalAttributeMap(new HttpServletRequestMap(request)); 86 } 87 88 public SharedAttributeMap getSessionMap() { 89 return new LocalSharedAttributeMap(new HttpSessionMap(request)); 90 } 91 92 public SharedAttributeMap getGlobalSessionMap() { 93 return getSessionMap(); 94 } 95 96 public SharedAttributeMap getApplicationMap() { 97 return new LocalSharedAttributeMap(new HttpServletContextMap(context)); 98 } 99 100 103 public ServletContext getContext() { 104 return context; 105 } 106 107 110 public HttpServletRequest getRequest() { 111 return request; 112 } 113 114 117 public HttpServletResponse getResponse() { 118 return response; 119 } 120 121 public String toString() { 122 return new ToStringCreator(this).append("requestParameterMap", getRequestParameterMap()).toString(); 123 } 124 } | Popular Tags |