1 package org.apache.beehive.controls.runtime.servlet; 2 19 20 import javax.servlet.ServletResponse ; 21 import javax.servlet.ServletResponseWrapper ; 22 23 import org.apache.beehive.controls.api.context.ControlContainerContext; 24 import org.apache.beehive.controls.api.context.ControlThreadContext; 25 26 33 class ServletResponseService implements ServletResponse 34 { 35 40 private static class Wrapper extends ServletResponseWrapper 41 { 42 Wrapper(ServletResponseService responseService) 43 { 44 super(responseService); 45 _responseService = responseService; 46 } 47 48 54 public ServletResponse getResponse() 55 { 56 return _responseService.getServletResponse(); 57 } 58 59 ServletResponseService _responseService; 60 } 61 62 ServletResponseService(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 final protected ServletResponse getServletResponse() 86 { 87 ServletResponse servletResponse = getServletBeanContext().getServletResponse(); 88 if (servletResponse == null) 89 throw new IllegalStateException ("No access to ServletResponse outside request processing"); 90 return servletResponse; 91 } 92 93 98 ServletResponseWrapper getResponseWrapper() 99 { 100 return new Wrapper (this); 101 } 102 103 public java.lang.String getCharacterEncoding() 104 { 105 return getServletResponse().getCharacterEncoding(); 106 } 107 108 public java.lang.String getContentType() 109 { 110 return getServletResponse().getContentType(); 111 } 112 113 public javax.servlet.ServletOutputStream getOutputStream() throws java.io.IOException 114 { 115 return getServletResponse().getOutputStream(); 116 } 117 118 public java.io.PrintWriter getWriter() throws java.io.IOException 119 { 120 return getServletResponse().getWriter(); 121 } 122 123 public void setCharacterEncoding(java.lang.String charset) 124 { 125 getServletResponse().setCharacterEncoding(charset); 126 } 127 128 public void setContentLength(int len) 129 { 130 getServletResponse().setContentLength(len); 131 } 132 133 public void setContentType(java.lang.String type) 134 { 135 getServletResponse().setContentType(type); 136 } 137 138 public void setBufferSize(int size) 139 { 140 getServletResponse().setBufferSize(size); 141 } 142 143 public int getBufferSize() 144 { 145 return getServletResponse().getBufferSize(); 146 } 147 148 public void flushBuffer() throws java.io.IOException 149 { 150 getServletResponse().flushBuffer(); 151 } 152 153 public void resetBuffer() 154 { 155 getServletResponse().resetBuffer(); 156 } 157 158 public boolean isCommitted() 159 { 160 return getServletResponse().isCommitted(); 161 } 162 163 public void reset() 164 { 165 getServletResponse().reset(); 166 } 167 168 public void setLocale(java.util.Locale loc) 169 { 170 getServletResponse().setLocale(loc); 171 } 172 173 public java.util.Locale getLocale() 174 { 175 return getServletResponse().getLocale(); 176 } 177 178 transient private ServletBeanContext _beanContext; } 180 | Popular Tags |