javax.servlet.ServletRequestAttributeEvent源码实例Demo

类javax.servlet.ServletRequestAttributeEvent源码实例Demo

下面列出了javax.servlet.ServletRequestAttributeEvent 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Tomcat8-Source-Read   文件: Request.java
/**
 * 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);
        }
    }
}
 
源代码2 项目: Tomcat7.0.67   文件: Request.java
/**
 * 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);
        }
    }
}
 
源代码3 项目: tomcatsrc   文件: Request.java
/**
 * 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);
        }
    }
}
 
源代码4 项目: quarkus-http   文件: ApplicationListeners.java
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);
    }
}
 
源代码5 项目: quarkus-http   文件: ApplicationListeners.java
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);
    }
}
 
源代码6 项目: quarkus-http   文件: ApplicationListeners.java
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);
    }
}
 
/**
 * Handle attribute added event.
 *
 * @param event the event.
 */
@Override
public void attributeAdded(ServletRequestAttributeEvent event) {
    if (event.getName().equals("attributeAdded")) {
        event.getServletContext().setAttribute("attributeAdded", true);
    }
}
 
/**
 * Handle attribute removed event.
 *
 * @param event the event.
 */
@Override
public void attributeRemoved(ServletRequestAttributeEvent event) {
    if (event.getName().equals("attributeRemoved")) {
        event.getServletContext().setAttribute("attributeRemoved", true);
    }
}
 
/**
 * Handle attribute replaced event.
 *
 * @param event the event.
 */
@Override
public void attributeReplaced(ServletRequestAttributeEvent event) {
    if (event.getName().equals("attributeReplaced")) {
        event.getServletContext().setAttribute("attributeReplaced", true);
    }
}
 
源代码10 项目: lams   文件: ApplicationListeners.java
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);
    }
}
 
源代码11 项目: lams   文件: ApplicationListeners.java
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);
    }
}
 
源代码12 项目: lams   文件: ApplicationListeners.java
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);
    }
}
 
源代码13 项目: quarkus-http   文件: ServletContextTestListener.java
@Override
public void attributeAdded(final ServletRequestAttributeEvent srae) {
    servletRequestAttributeEvent = srae;
}
 
源代码14 项目: quarkus-http   文件: ServletContextTestListener.java
@Override
public void attributeRemoved(final ServletRequestAttributeEvent srae) {
    servletRequestAttributeEvent = srae;
}
 
源代码15 项目: quarkus-http   文件: ServletContextTestListener.java
@Override
public void attributeReplaced(final ServletRequestAttributeEvent srae) {
    servletRequestAttributeEvent = srae;
}
 
源代码16 项目: piranha   文件: DefaultHttpRequestManager.java
@Override
public void attributeAdded(HttpServletRequest request, String name, Object value) {
    attributeListeners.stream().forEach((listener) -> {
        listener.attributeAdded(new ServletRequestAttributeEvent(request.getServletContext(), request, name, value));
    });
}
 
源代码17 项目: piranha   文件: DefaultHttpRequestManager.java
@Override
public void attributeRemoved(HttpServletRequest request, String name) {
    attributeListeners.stream().forEach((listener) -> {
        listener.attributeRemoved(new ServletRequestAttributeEvent(request.getServletContext(), request, name, null));
    });
}
 
源代码18 项目: piranha   文件: DefaultHttpRequestManager.java
@Override
public void attributeReplaced(HttpServletRequest request, String name, Object value) {
    attributeListeners.stream().forEach((listener) -> {
        listener.attributeReplaced(new ServletRequestAttributeEvent(request.getServletContext(), request, name, value));
    });
}
 
@Override
public void attributeAdded(ServletRequestAttributeEvent srae) {
	logger.debug("ServletRequest域对象中添加了属性:{},属性值是:{}", srae.getName(), srae.getValue());
}
 
@Override
public void attributeRemoved(ServletRequestAttributeEvent srae) {
	logger.debug("ServletRequest域对象中删除了属性:{},属性值是:{}", srae.getName(), srae.getValue());
}
 
@Override
public void attributeReplaced(ServletRequestAttributeEvent srae) {
	logger.debug("ServletRequest域对象中替换了属性:{},原值是:{}, 现值是:{}", srae.getName(), srae.getSource(), srae.getValue());
}
 
源代码评论
动弹
沙发等你来抢
 类所在包
 类方法
 同包方法