当前位置: 首页>>代码示例>>Java>>正文


Java HttpSessionListener类代码示例

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


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

示例1: onApplicationEvent

import javax.servlet.http.HttpSessionListener; //导入依赖的package包/类
public void onApplicationEvent(AbstractSessionEvent event) {
	if (this.listeners.isEmpty()) {
		return;
	}

	HttpSessionEvent httpSessionEvent = createHttpSessionEvent(event);

	for (HttpSessionListener listener : this.listeners) {
		if (event instanceof SessionDestroyedEvent) {
			listener.sessionDestroyed(httpSessionEvent);
		}
		else if (event instanceof SessionCreatedEvent) {
			listener.sessionCreated(httpSessionEvent);
		}
	}
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:17,代码来源:SessionEventHttpSessionListenerAdapter.java

示例2: getListeners

import javax.servlet.http.HttpSessionListener; //导入依赖的package包/类
@SuppressWarnings("nls")
private synchronized List<HttpSessionListener> getListeners()
{
	if( listenerTracker == null )
	{
		PluginService pluginService = AbstractPluginService.get();
		if( pluginService == null )
		{
			// We're not initialised yet, probably because Tomcat is trying
			// to tell us about a bunch of existing sessions from other
			// cluster nodes while we're still starting up.
			return Collections.emptyList();
		}

		listenerTracker = new PluginTracker<HttpSessionListener>(pluginService, "com.tle.web.core",
			"webSessionListener", null, new PluginTracker.ExtensionParamComparator("order")).setBeanKey("bean");
	}
	return listenerTracker.getBeanList();
}
 
开发者ID:equella,项目名称:Equella,代码行数:20,代码来源:UserSessionDestructionListener.java

示例3: onAddListener

import javax.servlet.http.HttpSessionListener; //导入依赖的package包/类
/**
 * This method is used by injected code to register listeners for
 * {@link ServletContext}. If object argument is a {@link ServletContext} and
 * listener argument contains {@link HttpSessionListener} or
 * {@link HttpSessionAttributeListener}, the method will add them to list of
 * known listeners associated to {@link ServletContext}
 *
 * @param servletContext
 *          the active servlet context
 * @param listener
 *          the listener to use
 */
public void onAddListener(ServletContext servletContext, Object listener) {
  String contextPath = servletContext.getContextPath();
  ServletContextDescriptor scd = getDescriptor(servletContext);
  logger.debug("Registering listener {} for context {}", listener, contextPath);
  // As theoretically one class can implement many listener interfaces we
  // check if it implements each of supported ones
  if (listener instanceof HttpSessionListener) {
    scd.addHttpSessionListener((HttpSessionListener)listener);
  }
  if (listener instanceof HttpSessionAttributeListener) {
    scd.addHttpSessionAttributeListener((HttpSessionAttributeListener)listener);
  }
  if (ServletLevel.isServlet31) {
    // Guard the code inside block to avoid use of classes
    // that are not available in versions before Servlet 3.1
    if (listener instanceof HttpSessionIdListener) { // NOSONAR
      scd.addHttpSessionIdListener((HttpSessionIdListener)listener);
    }
  }
}
 
开发者ID:AmadeusITGroup,项目名称:HttpSessionReplacer,代码行数:33,代码来源:SessionHelpers.java

示例4: addListener

import javax.servlet.http.HttpSessionListener; //导入依赖的package包/类
private void addListener(String name, String classname) {
    LOG.debug("Adding listener: " + name + "=" + classname);
    
    Object listenerObject = GlobalResourceLoader.getResourceLoader().getObject(new ObjectDefinition(classname));
    
    if (listenerObject == null) {
        LOG.error("Listener '" + name + "' class not found: " + classname);
        return;

    }
    if (!(listenerObject instanceof HttpSessionListener)) {
        LOG.error("Class '" + listenerObject.getClass() + "' does not implement servlet javax.servlet.http.HttpSessionListener");
        return;
    }
    
    HttpSessionListener listener = (HttpSessionListener) listenerObject;
    listeners.put(name, listener);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:BootstrapListener.java

示例5: removeSession

import javax.servlet.http.HttpSessionListener; //导入依赖的package包/类
@Override
public final void removeSession(final AbstractSession session, boolean invalidate) {
    final String clusterId = getClusterId(session);
    final boolean removed = removeSession(clusterId);
    if (removed) {
        _sessionsStats.decrement();
        _sessionTimeStats.set(Math.round((System.currentTimeMillis() - session.getCreationTime()) / 1000.0));
        _sessionIdManager.removeSession(session);
        if (invalidate) {
            _sessionIdManager.invalidateAll(session.getClusterId());
        }

        if (invalidate && _sessionListeners != null) {
            final HttpSessionEvent event = new HttpSessionEvent(session);
            for (int i = LazyList.size(_sessionListeners); i-- > 0;) {
                ((HttpSessionListener) LazyList.get(_sessionListeners, i)).sessionDestroyed(event);
            }
        }

        if (!invalidate) {
            session.willPassivate();
        }
    }
}
 
开发者ID:nano-projects,项目名称:nano-framework,代码行数:25,代码来源:AbstractSessionManager.java

示例6: init

import javax.servlet.http.HttpSessionListener; //导入依赖的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

示例7: onApplicationEvent

import javax.servlet.http.HttpSessionListener; //导入依赖的package包/类
@Override
public void onApplicationEvent(AbstractSessionEvent event) {
	if (this.listeners.isEmpty()) {
		return;
	}

	HttpSessionEvent httpSessionEvent = createHttpSessionEvent(event);

	for (HttpSessionListener listener : this.listeners) {
		if (event instanceof SessionDestroyedEvent) {
			listener.sessionDestroyed(httpSessionEvent);
		}
		else if (event instanceof SessionCreatedEvent) {
			listener.sessionCreated(httpSessionEvent);
		}
	}
}
 
开发者ID:spring-projects,项目名称:spring-session,代码行数:18,代码来源:SessionEventHttpSessionListenerAdapter.java

示例8: sessionCreated

import javax.servlet.http.HttpSessionListener; //导入依赖的package包/类
@Override
public void sessionCreated(HttpSessionEvent event) {
    HttpSession session = event.getSession();
    synchronized (session) {
        session.setAttribute(Constants.SESSION_RESET_ATTR, "#");
        HANDLER.instantiateAuthBean(session);

        if (CONFIG.getContent().getSessionTimeout() > 0) {
            session.setMaxInactiveInterval(CONFIG.getContent().getSessionTimeout() * 60);
        }

        for (HttpSessionListener sessionListener : HANDLER.sessionListeners) {
            HANDLER.executeInjection(sessionListener);
            sessionListener.sessionCreated(event);
        }
    }
}
 
开发者ID:jefalbino,项目名称:jsmart-web,代码行数:18,代码来源:SessionControl.java

示例9: setListeners

import javax.servlet.http.HttpSessionListener; //导入依赖的package包/类
public synchronized void setListeners(List l) {
    if (listeners == null) {
	listeners = l;
	if (listeners != null) {
	    HttpSessionEvent event = new HttpSessionEvent(this);
	    for (int i = 0; i < listeners.size(); i++)
		try {
		    ((HttpSessionListener) listeners.get(i)).sessionCreated(event);
		} catch (ClassCastException cce) {
			//servletContext. log("Wrong session listener type."+cce);
		} catch (NullPointerException npe) {
			//servletContext. log("Null session listener.");
		}
	}
    }
}
 
开发者ID:couchbase,项目名称:couchbase-lite-java-listener,代码行数:17,代码来源:Serve.java

示例10: isWeb

import javax.servlet.http.HttpSessionListener; //导入依赖的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

示例11: tellNew

import javax.servlet.http.HttpSessionListener; //导入依赖的package包/类
/**
 * Inform the listeners about the new session.
 *
 */
public void tellNew() {

    // Notify interested session event listeners
    fireSessionEvent(Session.SESSION_CREATED_EVENT, null);

    // Notify interested application event listeners
    Context context = (Context) manager.getContainer();
    Object listeners[] = context.getApplicationLifecycleListeners();
    if (listeners != null) {
        HttpSessionEvent event =
            new HttpSessionEvent(getSession());
        for (int i = 0; i < listeners.length; i++) {
            if (!(listeners[i] instanceof HttpSessionListener))
                continue;
            HttpSessionListener listener =
                (HttpSessionListener) listeners[i];
            try {
                context.fireContainerEvent("beforeSessionCreated",
                        listener);
                listener.sessionCreated(event);
                context.fireContainerEvent("afterSessionCreated", listener);
            } catch (Throwable t) {
                ExceptionUtils.handleThrowable(t);
                try {
                    context.fireContainerEvent("afterSessionCreated",
                            listener);
                } catch (Exception e) {
                    // Ignore
                }
                manager.getContainer().getLogger().error
                    (sm.getString("standardSession.sessionEvent"), t);
            }
        }
    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:41,代码来源:StandardSession.java

示例12: addListener

import javax.servlet.http.HttpSessionListener; //导入依赖的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

示例13: sessionCreated

import javax.servlet.http.HttpSessionListener; //导入依赖的package包/类
public void sessionCreated(HttpSessionEvent se) {
    if (ctx == null) {
        logger.warn("cannot find applicationContext");

        return;
    }

    Collection<HttpSessionListener> httpSessionListeners = ctx
            .getBeansOfType(HttpSessionListener.class).values();

    for (HttpSessionListener httpSessionListener : httpSessionListeners) {
        httpSessionListener.sessionCreated(se);
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:15,代码来源:ProxyServletListener.java

示例14: sessionDestroyed

import javax.servlet.http.HttpSessionListener; //导入依赖的package包/类
public void sessionDestroyed(HttpSessionEvent se) {
    if (ctx == null) {
        logger.warn("cannot find applicationContext");

        return;
    }

    Collection<HttpSessionListener> httpSessionListeners = ctx
            .getBeansOfType(HttpSessionListener.class).values();

    for (HttpSessionListener httpSessionListener : httpSessionListeners) {
        httpSessionListener.sessionDestroyed(se);
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:15,代码来源:ProxyServletListener.java

示例15: sessionCreated

import javax.servlet.http.HttpSessionListener; //导入依赖的package包/类
@Override
public void sessionCreated(HttpSessionEvent event)
{
	for( HttpSessionListener listener : getListeners() )
	{
		listener.sessionCreated(event);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:9,代码来源:UserSessionDestructionListener.java


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