1 package org.apache.beehive.controls.runtime.servlet; 2 19 20 import javax.servlet.ServletRequest ; 21 import javax.servlet.ServletRequestWrapper ; 22 23 import org.apache.beehive.controls.api.context.ControlContainerContext; 24 import org.apache.beehive.controls.api.context.ControlThreadContext; 25 26 33 class ServletRequestService implements ServletRequest 34 { 35 40 private static class Wrapper extends ServletRequestWrapper 41 { 42 Wrapper(ServletRequestService requestService) 43 { 44 super(requestService); 45 _requestService = requestService; 46 } 47 48 54 public ServletRequest getRequest() 55 { 56 return _requestService.getServletRequest(); 57 } 58 59 ServletRequestService _requestService; 60 } 61 62 ServletRequestService(ServletBeanContext beanContext) 63 { 64 _beanContext = beanContext; 65 } 66 67 72 final protected ServletBeanContext getServletBeanContext() 73 { 74 if (_beanContext == null) 75 { 76 ControlContainerContext ccc = ControlThreadContext.getContext(); 77 if (! (ccc instanceof ServletBeanContext)) 78 throw new IllegalStateException ("No ServletBeanContext available"); 79 80 _beanContext = (ServletBeanContext)ccc; 81 } 82 return _beanContext; 83 } 84 85 90 ServletRequestWrapper getRequestWrapper() 91 { 92 return new Wrapper (this); 93 } 94 95 final protected ServletRequest getServletRequest() 96 { 97 ServletRequest servletRequest = getServletBeanContext().getServletRequest(); 98 if (servletRequest == null) 99 throw new IllegalStateException ("No access to ServletRequest outside request processing"); 100 return servletRequest; 101 } 102 103 public java.lang.Object getAttribute(java.lang.String name) 104 { 105 return getServletRequest().getAttribute(name); 106 } 107 108 public java.util.Enumeration getAttributeNames() 109 { 110 return getServletRequest().getAttributeNames(); 111 } 112 113 public java.lang.String getCharacterEncoding() 114 { 115 return getServletRequest().getCharacterEncoding(); 116 } 117 118 public void setCharacterEncoding(java.lang.String env) 119 throws java.io.UnsupportedEncodingException 120 { 121 getServletRequest().setCharacterEncoding(env); 122 } 123 124 public int getContentLength() 125 { 126 return getServletRequest().getContentLength(); 127 } 128 129 public java.lang.String getContentType() 130 { 131 return getServletRequest().getContentType(); 132 } 133 134 public javax.servlet.ServletInputStream getInputStream() throws java.io.IOException 135 { 136 return getServletRequest().getInputStream(); 137 } 138 139 public java.lang.String getParameter(java.lang.String name) 140 { 141 return getServletRequest().getParameter(name); 142 } 143 144 public java.util.Enumeration getParameterNames() 145 { 146 return getServletRequest().getParameterNames(); 147 } 148 149 public java.lang.String [] getParameterValues(java.lang.String name) 150 { 151 return getServletRequest().getParameterValues(name); 152 } 153 154 public java.util.Map getParameterMap() 155 { 156 return getServletRequest().getParameterMap(); 157 } 158 159 public java.lang.String getProtocol() 160 { 161 return getServletRequest().getProtocol(); 162 } 163 164 public java.lang.String getScheme() 165 { 166 return getServletRequest().getScheme(); 167 } 168 169 public java.lang.String getServerName() 170 { 171 return getServletRequest().getServerName(); 172 } 173 174 public int getServerPort() 175 { 176 return getServletRequest().getServerPort(); 177 } 178 179 public int getLocalPort() 180 { 181 return getServletRequest().getLocalPort(); 182 } 183 184 public java.lang.String getLocalAddr() 185 { 186 return getServletRequest().getLocalAddr(); 187 } 188 189 public java.lang.String getLocalName() 190 { 191 return getServletRequest().getLocalName(); 192 } 193 194 195 public java.io.BufferedReader getReader() throws java.io.IOException 196 { 197 return getServletRequest().getReader(); 198 } 199 200 public java.lang.String getRemoteAddr() 201 { 202 return getServletRequest().getRemoteAddr(); 203 } 204 205 public java.lang.String getRemoteHost() 206 { 207 return getServletRequest().getRemoteHost(); 208 } 209 210 public int getRemotePort() 211 { 212 return getServletRequest().getRemotePort(); 213 } 214 215 public void setAttribute(java.lang.String name, java.lang.Object o) 216 { 217 getServletRequest().setAttribute(name, o); 218 } 219 220 public void removeAttribute(java.lang.String name) 221 { 222 getServletRequest().removeAttribute(name); 223 } 224 225 public java.util.Locale getLocale() 226 { 227 return getServletRequest().getLocale(); 228 } 229 230 public java.util.Enumeration getLocales() 231 { 232 return getServletRequest().getLocales(); 233 } 234 235 public boolean isSecure() 236 { 237 return getServletRequest().isSecure(); 238 } 239 240 public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path) 241 { 242 return getServletRequest().getRequestDispatcher(path); 243 } 244 245 public java.lang.String getRealPath(java.lang.String path) 246 { 247 return getServletRequest().getRealPath(path); 248 } 249 250 transient private ServletBeanContext _beanContext; } 252 | Popular Tags |