Mercurial Hosting > luan
comparison src/org/eclipse/jetty/server/Request.java @ 989:900e5b8ccd19
remove useless listeners
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 17 Oct 2016 05:39:54 -0600 |
parents | 13beba0c127f |
children | 83cc6e05a58f |
comparison
equal
deleted
inserted
replaced
988:13beba0c127f | 989:900e5b8ccd19 |
---|---|
155 private String _queryString; | 155 private String _queryString; |
156 private BufferedReader _reader; | 156 private BufferedReader _reader; |
157 private String _readerEncoding; | 157 private String _readerEncoding; |
158 private String _remoteAddr; | 158 private String _remoteAddr; |
159 private String _remoteHost; | 159 private String _remoteHost; |
160 private Object _requestAttributeListeners; | |
161 private String _requestURI; | 160 private String _requestURI; |
162 private String _scheme = URIUtil.HTTP; | 161 private String _scheme = URIUtil.HTTP; |
163 private String _serverName; | 162 private String _serverName; |
164 private String _servletPath; | 163 private String _servletPath; |
165 private long _timeStamp; | 164 private long _timeStamp; |
175 | 174 |
176 /* ------------------------------------------------------------ */ | 175 /* ------------------------------------------------------------ */ |
177 public Request(AbstractHttpConnection connection) | 176 public Request(AbstractHttpConnection connection) |
178 { | 177 { |
179 setConnection(connection); | 178 setConnection(connection); |
180 } | |
181 | |
182 /* ------------------------------------------------------------ */ | |
183 public void addEventListener(final EventListener listener) | |
184 { | |
185 if (listener instanceof ServletRequestAttributeListener) | |
186 _requestAttributeListeners = LazyList.add(_requestAttributeListeners,listener); | |
187 if (listener instanceof AsyncListener) | |
188 throw new IllegalArgumentException(listener.getClass().toString()); | |
189 } | 179 } |
190 | 180 |
191 /* ------------------------------------------------------------ */ | 181 /* ------------------------------------------------------------ */ |
192 /** | 182 /** |
193 * Extract Parameters from query string and/or form _content. | 183 * Extract Parameters from query string and/or form _content. |
1293 /* | 1283 /* |
1294 * @see javax.servlet.ServletRequest#removeAttribute(java.lang.String) | 1284 * @see javax.servlet.ServletRequest#removeAttribute(java.lang.String) |
1295 */ | 1285 */ |
1296 public void removeAttribute(String name) | 1286 public void removeAttribute(String name) |
1297 { | 1287 { |
1298 Object old_value = _attributes == null?null:_attributes.getAttribute(name); | |
1299 | |
1300 if (_attributes != null) | 1288 if (_attributes != null) |
1301 _attributes.removeAttribute(name); | 1289 _attributes.removeAttribute(name); |
1302 | |
1303 if (old_value != null) | |
1304 { | |
1305 if (_requestAttributeListeners != null) | |
1306 { | |
1307 final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(_context,this,name,old_value); | |
1308 final int size = LazyList.size(_requestAttributeListeners); | |
1309 for (int i = 0; i < size; i++) | |
1310 { | |
1311 final EventListener listener = (ServletRequestAttributeListener)LazyList.get(_requestAttributeListeners,i); | |
1312 if (listener instanceof ServletRequestAttributeListener) | |
1313 { | |
1314 final ServletRequestAttributeListener l = (ServletRequestAttributeListener)listener; | |
1315 l.attributeRemoved(event); | |
1316 } | |
1317 } | |
1318 } | |
1319 } | |
1320 } | |
1321 | |
1322 /* ------------------------------------------------------------ */ | |
1323 public void removeEventListener(final EventListener listener) | |
1324 { | |
1325 _requestAttributeListeners = LazyList.remove(_requestAttributeListeners,listener); | |
1326 } | 1290 } |
1327 | 1291 |
1328 /* ------------------------------------------------------------ */ | 1292 /* ------------------------------------------------------------ */ |
1329 /* | 1293 /* |
1330 * Set a request attribute. if the attribute name is "org.eclipse.jetty.server.server.Request.queryEncoding" then the value is also passed in a call to | 1294 * Set a request attribute. if the attribute name is "org.eclipse.jetty.server.server.Request.queryEncoding" then the value is also passed in a call to |
1383 } | 1347 } |
1384 | 1348 |
1385 if (_attributes == null) | 1349 if (_attributes == null) |
1386 _attributes = new AttributesMap(); | 1350 _attributes = new AttributesMap(); |
1387 _attributes.setAttribute(name,value); | 1351 _attributes.setAttribute(name,value); |
1388 | |
1389 if (_requestAttributeListeners != null) | |
1390 { | |
1391 final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(_context,this,name,old_value == null?value:old_value); | |
1392 final int size = LazyList.size(_requestAttributeListeners); | |
1393 for (int i = 0; i < size; i++) | |
1394 { | |
1395 final EventListener listener = (ServletRequestAttributeListener)LazyList.get(_requestAttributeListeners,i); | |
1396 if (listener instanceof ServletRequestAttributeListener) | |
1397 { | |
1398 final ServletRequestAttributeListener l = (ServletRequestAttributeListener)listener; | |
1399 | |
1400 if (old_value == null) | |
1401 l.attributeAdded(event); | |
1402 else if (value == null) | |
1403 l.attributeRemoved(event); | |
1404 else | |
1405 l.attributeReplaced(event); | |
1406 } | |
1407 } | |
1408 } | |
1409 } | 1352 } |
1410 | 1353 |
1411 /* ------------------------------------------------------------ */ | 1354 /* ------------------------------------------------------------ */ |
1412 /* | 1355 /* |
1413 */ | 1356 */ |