• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ServletRequestAttributeListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.servlet.ServletRequestAttributeListener的典型用法代码示例。如果您正苦于以下问题:Java ServletRequestAttributeListener类的具体用法?Java ServletRequestAttributeListener怎么用?Java ServletRequestAttributeListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ServletRequestAttributeListener类属于javax.servlet包,在下文中一共展示了ServletRequestAttributeListener类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: notifyAttributeRemoved

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:28,代码来源:Request.java


示例2: notifyAttributeRemoved

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
/**
 * 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);
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:27,代码来源:Request.java


示例3: init

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
/**
 * Init method called by the main servlet when the wrapping servlet is initialized. This means that the context is
 * taken into service by the system.
 *
 * @param parent The parent servlet context. Just for some delegation actions
 */
void init(ServletContext parent) {
    // Set up the tracking of event listeners.
    BundleContext bc = getOwner().getBundleContext();
    delegate = parent;
    Collection<Class<? extends EventListener>> toTrack = Arrays.asList(HttpSessionListener.class,
            ServletRequestListener.class, HttpSessionAttributeListener.class, ServletRequestAttributeListener.class,
            ServletContextListener.class);
    Collection<String> objectFilters = toTrack.stream().
            map((c) -> "(" + Constants.OBJECTCLASS + "=" + c.getName() + ")").collect(Collectors.toList());
    String filterString = "|" + String.join("", objectFilters);
    eventListenerTracker = startTracking(filterString,
            new Tracker<EventListener, EventListener>(bc, getContextPath(), (e) -> e, (e) -> { /* No destruct */}));
    // Initialize the servlets.
    ServletContextEvent event = new ServletContextEvent(this);
    call(ServletContextListener.class, (l) -> l.contextInitialized(event));
    servlets.values().forEach((s) -> init(s));
    // And the filters.
    filters.values().forEach((f) -> init(f));
    // Set up the tracking of servlets and filters.
    servletTracker = startTracking(Constants.OBJECTCLASS + "=" + Servlet.class.getName(),
            new Tracker<Servlet, String>(bc, getContextPath(), this::addServlet, this::removeServlet));
    filterTracker = startTracking(Constants.OBJECTCLASS + "=" + Filter.class.getName(),
            new Tracker<Filter, String>(bc, getContextPath(), this::addFilter, this::removeFilter));
}
 
开发者ID:arievanwi,项目名称:osgi.ee,代码行数:31,代码来源:OurServletContext.java


示例4: isWeb

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
private static boolean isWeb(final Class<?> beanClass) {
    if (Servlet.class.isAssignableFrom(beanClass)
        || Filter.class.isAssignableFrom(beanClass)) {
        return true;
    }
    if (EventListener.class.isAssignableFrom(beanClass)) {
        return HttpSessionAttributeListener.class.isAssignableFrom(beanClass)
               || ServletContextListener.class.isAssignableFrom(beanClass)
               || ServletRequestListener.class.isAssignableFrom(beanClass)
               || ServletContextAttributeListener.class.isAssignableFrom(beanClass)
               || HttpSessionListener.class.isAssignableFrom(beanClass)
               || HttpSessionBindingListener.class.isAssignableFrom(beanClass)
               || HttpSessionActivationListener.class.isAssignableFrom(beanClass)
               || HttpSessionIdListener.class.isAssignableFrom(beanClass)
               || ServletRequestAttributeListener.class.isAssignableFrom(beanClass);
    }

    return false;
}
 
开发者ID:apache,项目名称:tomee,代码行数:20,代码来源:WebContext.java


示例5: addListener

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
@Override
public <T extends EventListener> void addListener(T t) {
    if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
        throw new IllegalStateException(
                sm.getString("applicationContext.addListener.ise",
                        getContextPath()));
    }

    boolean match = false;
    if (t instanceof ServletContextAttributeListener ||
            t instanceof ServletRequestListener ||
            t instanceof ServletRequestAttributeListener ||
            t instanceof HttpSessionAttributeListener) {
        context.addApplicationEventListener(t);
        match = true;
    }

    if (t instanceof HttpSessionListener
            || (t instanceof ServletContextListener &&
                    newServletContextListenerAllowed)) {
        // Add listener directly to the list of instances rather than to
        // the list of class names.
        context.addApplicationLifecycleListener(t);
        match = true;
    }

    if (match) return;

    if (t instanceof ServletContextListener) {
        throw new IllegalArgumentException(sm.getString(
                "applicationContext.addListener.iae.sclNotAllowed",
                t.getClass().getName()));
    } else {
        throw new IllegalArgumentException(sm.getString(
                "applicationContext.addListener.iae.wrongType",
                t.getClass().getName()));
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:39,代码来源:ApplicationContext.java


示例6: addListener

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
@Override
public <T extends EventListener> void addListener(T t) {
	if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
		throw new IllegalStateException(sm.getString("applicationContext.addListener.ise", getContextPath()));
	}

	boolean match = false;
	if (t instanceof ServletContextAttributeListener || t instanceof ServletRequestListener
			|| t instanceof ServletRequestAttributeListener || t instanceof HttpSessionAttributeListener) {
		context.addApplicationEventListener(t);
		match = true;
	}

	if (t instanceof HttpSessionListener
			|| (t instanceof ServletContextListener && newServletContextListenerAllowed)) {
		// Add listener directly to the list of instances rather than to
		// the list of class names.
		context.addApplicationLifecycleListener(t);
		match = true;
	}

	if (match)
		return;

	if (t instanceof ServletContextListener) {
		throw new IllegalArgumentException(
				sm.getString("applicationContext.addListener.iae.sclNotAllowed", t.getClass().getName()));
	} else {
		throw new IllegalArgumentException(
				sm.getString("applicationContext.addListener.iae.wrongType", t.getClass().getName()));
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:33,代码来源:ApplicationContext.java


示例7: loadListeners

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
private void loadListeners(WebAppConfiguration wac)
    throws ClassNotFoundException, IllegalAccessException,
    InstantiationException, WebAppConfigurationException {
  for (WebAppListener listener : wac.getListeners()) {
    String className = listener.getListenerClass();
    Class<?> clazz = classLoader.loadClass(className);
    Object obj = clazz.newInstance();
    boolean used = false;
    if (obj instanceof ServletContextAttributeListener) {
      scaListeners.add((ServletContextAttributeListener) obj);
      used = true;
    }
    if (obj instanceof ServletContextListener) {
      scListeners.add((ServletContextListener) obj);
      used = true;
    }
    if (obj instanceof ServletRequestListener) {
      srListeners.add((ServletRequestListener) obj);
      used = true;
    }
    if (obj instanceof ServletRequestAttributeListener) {
      sraListeners.add((ServletRequestAttributeListener) obj);
      used = true;
    }
    if (obj instanceof HttpSessionAttributeListener) {
      sessionAttributeListeners.add((HttpSessionAttributeListener) obj);
      used = true;
    }
    if (obj instanceof HttpSessionListener) {
      sessionListeners.add((HttpSessionListener) obj);
      used = true;
    }
    if (!used) {
      throw new WebAppConfigurationException("Don't know what to do with '"
          + className + "'");
    }
  }
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:39,代码来源:WebAppImpl.java


示例8: ServletRequestAttributeListenerWrapper

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
public ServletRequestAttributeListenerWrapper(
    ServletRequest request,
    ServletContext context,
    ServletRequestAttributeListener listener) {
  super(request);
  this.context = context;
  this.listener = listener;
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:9,代码来源:ServletRequestAttributeListenerWrapper.java


示例9: addListenerInstance

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
private void addListenerInstance(final Object listenerInstance,
        final List<ServletContextAttributeListener> contextAttributeListeners,
        final List<ServletContextListener> contextListeners,
        final List<ServletRequestAttributeListener> requestAttributeListeners,
        final List<ServletRequestListener> requestListeners, final List<HttpSessionActivationListener> sessionActivationListeners,
        final List<HttpSessionAttributeListener> sessionAttributeListeners, final List<HttpSessionListener> sessionListeners) {
    if (listenerInstance instanceof ServletContextAttributeListener) {
        contextAttributeListeners.add((ServletContextAttributeListener) listenerInstance);
    }
    if (listenerInstance instanceof ServletContextListener) {
        contextListeners.add((ServletContextListener) listenerInstance);
    }
    if (listenerInstance instanceof ServletRequestAttributeListener) {
        requestAttributeListeners.add((ServletRequestAttributeListener) listenerInstance);
    }
    if (listenerInstance instanceof ServletRequestListener) {
        requestListeners.add((ServletRequestListener) listenerInstance);
    }
    if (listenerInstance instanceof HttpSessionActivationListener) {
        sessionActivationListeners.add((HttpSessionActivationListener) listenerInstance);
    }
    if (listenerInstance instanceof HttpSessionAttributeListener) {
        sessionAttributeListeners.add((HttpSessionAttributeListener) listenerInstance);
    }
    if (listenerInstance instanceof HttpSessionListener) {
        sessionListeners.add((HttpSessionListener) listenerInstance);
    }
}
 
开发者ID:geronimo-iia,项目名称:winstone,代码行数:29,代码来源:WebAppConfiguration.java


示例10: attributeAdded

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
public void attributeAdded(final ServletRequestAttributeEvent srae)
{
    final Iterator<ServletRequestAttributeListener> listeners = getContextListeners();
    while (listeners.hasNext())
    {
        listeners.next().attributeAdded(srae);
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:9,代码来源:ServletRequestAttributeListenerManager.java


示例11: attributeRemoved

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
public void attributeRemoved(final ServletRequestAttributeEvent srae)
{
    final Iterator<ServletRequestAttributeListener> listeners = getContextListeners();
    while (listeners.hasNext())
    {
        listeners.next().attributeRemoved(srae);
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:9,代码来源:ServletRequestAttributeListenerManager.java


示例12: attributeReplaced

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
public void attributeReplaced(final ServletRequestAttributeEvent srae)
{
    final Iterator<ServletRequestAttributeListener> listeners = getContextListeners();
    while (listeners.hasNext())
    {
        listeners.next().attributeReplaced(srae);
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:9,代码来源:ServletRequestAttributeListenerManager.java


示例13: removeAttribute

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
/**
 * Remove the specified request attribute if it exists.
 *
 * @param name Name of the request attribute to remove
 */
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;
    }

    // Pass special attributes to the native layer
    if (name.startsWith("org.apache.tomcat.")) {
        coyoteRequest.getAttributes().remove(name);
    }

    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) {
            context.getLogger().error(sm.getString("coyoteRequest.attributeEvent"), t);
            // Error valve will pick this execption up and display it to user
            attributes.put( Globals.EXCEPTION_ATTR, t );
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:51,代码来源:Request.java


示例14: servletRequestAttributeAdded

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
public void servletRequestAttributeAdded(final HttpServletRequest request, final String name, final Object value) {
    final ServletRequestAttributeEvent sre = new ServletRequestAttributeEvent(servletContext, request, name, value);
    for (int i = 0; i < servletRequestAttributeListeners.length; ++i) {
        this.<ServletRequestAttributeListener>get(servletRequestAttributeListeners[i]).attributeAdded(sre);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:ApplicationListeners.java


示例15: servletRequestAttributeRemoved

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
public void servletRequestAttributeRemoved(final HttpServletRequest request, final String name, final Object value) {
    final ServletRequestAttributeEvent sre = new ServletRequestAttributeEvent(servletContext, request, name, value);
    for (int i = 0; i < servletRequestAttributeListeners.length; ++i) {
        this.<ServletRequestAttributeListener>get(servletRequestAttributeListeners[i]).attributeRemoved(sre);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:ApplicationListeners.java


示例16: servletRequestAttributeReplaced

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
public void servletRequestAttributeReplaced(final HttpServletRequest request, final String name, final Object value) {
    final ServletRequestAttributeEvent sre = new ServletRequestAttributeEvent(servletContext, request, name, value);
    for (int i = 0; i < servletRequestAttributeListeners.length; ++i) {
        this.<ServletRequestAttributeListener>get(servletRequestAttributeListeners[i]).attributeReplaced(sre);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:ApplicationListeners.java


示例17: ServletRequestAttributeListenerList

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
public ServletRequestAttributeListenerList() {
  listeners = new ArrayList<ServletRequestAttributeListener>();
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:4,代码来源:ServletRequestAttributeListenerList.java


示例18: add

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
public void add(ServletRequestAttributeListener listener) {
  listeners.add(listener);
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:4,代码来源:ServletRequestAttributeListenerList.java


示例19: attributeAdded

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
public void attributeAdded(ServletRequestAttributeEvent srae) {
  for (ServletRequestAttributeListener listener : listeners) {
    listener.attributeAdded(srae);
  }
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:6,代码来源:ServletRequestAttributeListenerList.java


示例20: attributeRemoved

import javax.servlet.ServletRequestAttributeListener; //导入依赖的package包/类
public void attributeRemoved(ServletRequestAttributeEvent srae) {
  for (ServletRequestAttributeListener listener : listeners) {
    listener.attributeRemoved(srae);
  }
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:6,代码来源:ServletRequestAttributeListenerList.java



注:本文中的javax.servlet.ServletRequestAttributeListener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InstructionList类代码示例发布时间:2022-05-21
下一篇:
Java InjectionPoint类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap