List of usage examples for javax.servlet ServletRequestAttributeEvent ServletRequestAttributeEvent
public ServletRequestAttributeEvent(ServletContext sc, ServletRequest request, String name, Object value)
From source file:org.apache.coyote.tomcat5.CoyoteRequest.java
/** * Remove the specified request attribute if it exists. * * @param name Name of the request attribute to remove *//*from www.j a va2 s. co m*/ public void removeAttribute(String name) { Object value = null; boolean found = false; // Remove the specified attribute // Check for read only attribute // requests are per thread so synchronization unnecessary if (readOnlyAttributes.containsKey(name)) { return; } found = attributes.containsKey(name); if (found) { value = attributes.get(name); attributes.remove(name); } else { return; } // Notify interested application event listeners Object listeners[] = context.getApplicationEventListeners(); if ((listeners == null) || (listeners.length == 0)) return; ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(context.getServletContext(), getRequest(), name, value); for (int i = 0; i < listeners.length; i++) { if (!(listeners[i] instanceof ServletRequestAttributeListener)) continue; ServletRequestAttributeListener listener = (ServletRequestAttributeListener) listeners[i]; try { listener.attributeRemoved(event); } catch (Throwable t) { log(sm.getString("coyoteRequest.attributeEvent"), t); // Error valve will pick this execption up and display it to user attributes.put(Globals.EXCEPTION_ATTR, t); } } }
From source file:org.apache.coyote.tomcat5.CoyoteRequest.java
/** * Set the specified request attribute to the specified value. * * @param name Name of the request attribute to set * @param value The associated value/* w w w . ja v a 2 s . c o m*/ */ public void setAttribute(String name, Object value) { // Name cannot be null if (name == null) throw new IllegalArgumentException(sm.getString("coyoteRequest.setAttribute.namenull")); // Null value is the same as removeAttribute() if (value == null) { removeAttribute(name); return; } if (name.equals(Globals.DISPATCHER_TYPE_ATTR)) { dispatcherType = value; return; } else if (name.equals(Globals.DISPATCHER_REQUEST_PATH_ATTR)) { requestDispatcherPath = value; return; } Object oldValue = null; boolean replaced = false; // Add or replace the specified attribute // Check for read only attribute // requests are per thread so synchronization unnecessary if (readOnlyAttributes.containsKey(name)) { return; } oldValue = attributes.put(name, value); if (oldValue != null) { replaced = true; } // Notify interested application event listeners Object listeners[] = context.getApplicationEventListeners(); if ((listeners == null) || (listeners.length == 0)) return; ServletRequestAttributeEvent event = null; if (replaced) event = new ServletRequestAttributeEvent(context.getServletContext(), getRequest(), name, oldValue); else event = new ServletRequestAttributeEvent(context.getServletContext(), getRequest(), name, value); for (int i = 0; i < listeners.length; i++) { if (!(listeners[i] instanceof ServletRequestAttributeListener)) continue; ServletRequestAttributeListener listener = (ServletRequestAttributeListener) listeners[i]; try { if (replaced) { listener.attributeReplaced(event); } else { listener.attributeAdded(event); } } catch (Throwable t) { log(sm.getString("coyoteRequest.attributeEvent"), t); // Error valve will pick this execption up and display it to user attributes.put(Globals.EXCEPTION_ATTR, t); } } }
From source file:org.ireland.jnetty.http.HttpServletRequestImpl.java
/** * Notify interested ServletRequestAttributeListeners that attribute has been assigned a value. * /*from w w w . j a v a 2 s .co m*/ * ? * */ private void notifyAttributeAdded(String name, Object value) { if (_requestAttributeListeners != null && !_requestAttributeListeners.isEmpty()) { final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(servletContext, this, name, value); for (ServletRequestAttributeListener listener : _requestAttributeListeners) { listener.attributeAdded(event); } } }
From source file:org.ireland.jnetty.http.HttpServletRequestImpl.java
/** * Notify interested ServletRequestAttributeListeners that attribute has been Replaced. * /*from w ww.j a v a 2 s . c o m*/ * ?? */ private void notifyAttributeReplaced(String name, Object oldValue) { if (_requestAttributeListeners != null && !_requestAttributeListeners.isEmpty()) { final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(servletContext, this, name, oldValue); for (ServletRequestAttributeListener listener : _requestAttributeListeners) { listener.attributeReplaced(event); } } }
From source file:org.ireland.jnetty.http.HttpServletRequestImpl.java
/** * Notify interested listeners that attribute has been removed. ? *//*from www . j a v a 2s. c o m*/ private void notifyAttributeRemoved(String name, Object value) { if (_requestAttributeListeners != null && !_requestAttributeListeners.isEmpty()) { final ServletRequestAttributeEvent event = new ServletRequestAttributeEvent(servletContext, this, name, value); for (ServletRequestAttributeListener listener : _requestAttributeListeners) { listener.attributeRemoved(event); } } }