javax.servlet.ServletRequestAttributeEvent Java Examples

The following examples show how to use javax.servlet.ServletRequestAttributeEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Request.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Notify interested listeners that attribute has been removed.
 */
private void notifyAttributeRemoved(String name, Object value) {
    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) {
            ExceptionUtils.handleThrowable(t);
            context.getLogger().error(sm.getString("coyoteRequest.attributeEvent"), t);
            // Error valve will pick this exception up and display it to user
            attributes.put(RequestDispatcher.ERROR_EXCEPTION, t);
        }
    }
}
 
Example #2
Source File: Request.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Notify interested listeners that attribute has been removed.
 */
private void notifyAttributeRemoved(String name, Object value) {
    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) {
            ExceptionUtils.handleThrowable(t);
            context.getLogger().error(sm.getString("coyoteRequest.attributeEvent"), t);
            // Error valve will pick this exception up and display it to user
            attributes.put(RequestDispatcher.ERROR_EXCEPTION, t);
        }
    }
}
 
Example #3
Source File: Request.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Notify interested listeners that attribute has been removed.
 *
 * @param name Attribute name
 * @param value Attribute value
 */
private void notifyAttributeRemoved(String name, Object value) {
    Context context = getContext();
    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) {
            ExceptionUtils.handleThrowable(t);
            // Error valve will pick this exception up and display it to user
            attributes.put(RequestDispatcher.ERROR_EXCEPTION, t);
            context.getLogger().error(sm.getString("coyoteRequest.attributeEvent"), t);
        }
    }
}
 
Example #4
Source File: ServletRequestAttributeListenerTest.java    From piranha with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Handle attribute added event.
 *
 * @param event the event.
 */
@Override
public void attributeAdded(ServletRequestAttributeEvent event) {
    if (event.getName().equals("attributeAdded")) {
        event.getServletContext().setAttribute("attributeAdded", true);
    }
}
 
Example #5
Source File: ApplicationListeners.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void servletRequestAttributeReplaced(final HttpServletRequest request, final String name, final Object value) {
    if(!started) {
        return;
    }
    final ServletRequestAttributeEvent sre = new ServletRequestAttributeEvent(servletContext, request, name, value);
    for (int i = 0; i < servletRequestAttributeListeners.length; ++i) {
        this.<ServletRequestAttributeListener>get(servletRequestAttributeListeners[i]).attributeReplaced(sre);
    }
}
 
Example #6
Source File: ApplicationListeners.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void servletRequestAttributeRemoved(final HttpServletRequest request, final String name, final Object value) {
    if(!started) {
        return;
    }
    final ServletRequestAttributeEvent sre = new ServletRequestAttributeEvent(servletContext, request, name, value);
    for (int i = 0; i < servletRequestAttributeListeners.length; ++i) {
        this.<ServletRequestAttributeListener>get(servletRequestAttributeListeners[i]).attributeRemoved(sre);
    }
}
 
Example #7
Source File: ApplicationListeners.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public void servletRequestAttributeAdded(final HttpServletRequest request, final String name, final Object value) {
    if(!started) {
        return;
    }
    final ServletRequestAttributeEvent sre = new ServletRequestAttributeEvent(servletContext, request, name, value);
    for (int i = 0; i < servletRequestAttributeListeners.length; ++i) {
        this.<ServletRequestAttributeListener>get(servletRequestAttributeListeners[i]).attributeAdded(sre);
    }
}
 
Example #8
Source File: ServletRequestAttributeListenerTest.java    From piranha with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Handle attribute replaced event.
 *
 * @param event the event.
 */
@Override
public void attributeReplaced(ServletRequestAttributeEvent event) {
    if (event.getName().equals("attributeReplaced")) {
        event.getServletContext().setAttribute("attributeReplaced", true);
    }
}
 
Example #9
Source File: ServletRequestAttributeListenerTest.java    From piranha with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Handle attribute removed event.
 *
 * @param event the event.
 */
@Override
public void attributeRemoved(ServletRequestAttributeEvent event) {
    if (event.getName().equals("attributeRemoved")) {
        event.getServletContext().setAttribute("attributeRemoved", true);
    }
}
 
Example #10
Source File: ApplicationListeners.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public void servletRequestAttributeReplaced(final HttpServletRequest request, final String name, final Object value) {
    if(!started || servletContextAttributeListeners.length == 0) {
        return;
    }
    final ServletRequestAttributeEvent sre = new ServletRequestAttributeEvent(servletContext, request, name, value);
    for (int i = 0; i < servletRequestAttributeListeners.length; ++i) {
        this.<ServletRequestAttributeListener>get(servletRequestAttributeListeners[i]).attributeReplaced(sre);
    }
}
 
Example #11
Source File: ApplicationListeners.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public void servletRequestAttributeRemoved(final HttpServletRequest request, final String name, final Object value) {
    if(!started || servletContextAttributeListeners.length == 0) {
        return;
    }
    final ServletRequestAttributeEvent sre = new ServletRequestAttributeEvent(servletContext, request, name, value);
    for (int i = 0; i < servletRequestAttributeListeners.length; ++i) {
        this.<ServletRequestAttributeListener>get(servletRequestAttributeListeners[i]).attributeRemoved(sre);
    }
}
 
Example #12
Source File: ApplicationListeners.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public void servletRequestAttributeAdded(final HttpServletRequest request, final String name, final Object value) {
    if(!started || servletContextAttributeListeners.length == 0) {
        return;
    }
    final ServletRequestAttributeEvent sre = new ServletRequestAttributeEvent(servletContext, request, name, value);
    for (int i = 0; i < servletRequestAttributeListeners.length; ++i) {
        this.<ServletRequestAttributeListener>get(servletRequestAttributeListeners[i]).attributeAdded(sre);
    }
}
 
Example #13
Source File: DefaultHttpRequestManager.java    From piranha with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void attributeReplaced(HttpServletRequest request, String name, Object value) {
    attributeListeners.stream().forEach((listener) -> {
        listener.attributeReplaced(new ServletRequestAttributeEvent(request.getServletContext(), request, name, value));
    });
}
 
Example #14
Source File: DefaultHttpRequestManager.java    From piranha with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void attributeRemoved(HttpServletRequest request, String name) {
    attributeListeners.stream().forEach((listener) -> {
        listener.attributeRemoved(new ServletRequestAttributeEvent(request.getServletContext(), request, name, null));
    });
}
 
Example #15
Source File: DefaultHttpRequestManager.java    From piranha with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void attributeAdded(HttpServletRequest request, String name, Object value) {
    attributeListeners.stream().forEach((listener) -> {
        listener.attributeAdded(new ServletRequestAttributeEvent(request.getServletContext(), request, name, value));
    });
}
 
Example #16
Source File: ServletContextTestListener.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
@Override
public void attributeReplaced(final ServletRequestAttributeEvent srae) {
    servletRequestAttributeEvent = srae;
}
 
Example #17
Source File: ServletContextTestListener.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
@Override
public void attributeRemoved(final ServletRequestAttributeEvent srae) {
    servletRequestAttributeEvent = srae;
}
 
Example #18
Source File: ServletContextTestListener.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
@Override
public void attributeAdded(final ServletRequestAttributeEvent srae) {
    servletRequestAttributeEvent = srae;
}
 
Example #19
Source File: MyServletRequestAttributeListener.java    From java-tutorial with Creative Commons Attribution Share Alike 4.0 International 4 votes vote down vote up
@Override
public void attributeAdded(ServletRequestAttributeEvent srae) {
	logger.debug("ServletRequest域对象中添加了属性:{},属性值是:{}", srae.getName(), srae.getValue());
}
 
Example #20
Source File: MyServletRequestAttributeListener.java    From java-tutorial with Creative Commons Attribution Share Alike 4.0 International 4 votes vote down vote up
@Override
public void attributeRemoved(ServletRequestAttributeEvent srae) {
	logger.debug("ServletRequest域对象中删除了属性:{},属性值是:{}", srae.getName(), srae.getValue());
}
 
Example #21
Source File: MyServletRequestAttributeListener.java    From java-tutorial with Creative Commons Attribution Share Alike 4.0 International 4 votes vote down vote up
@Override
public void attributeReplaced(ServletRequestAttributeEvent srae) {
	logger.debug("ServletRequest域对象中替换了属性:{},原值是:{}, 现值是:{}", srae.getName(), srae.getSource(), srae.getValue());
}