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); } } }
@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(); }
/** * 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); } } }
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); }
@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(); } } }
/** * 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)); }
@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); } } }
@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); } } }
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."); } } } }
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; }
/** * 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); } } } }
@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())); } }
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); } }
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); } }
@Override public void sessionCreated(HttpSessionEvent event) { for( HttpSessionListener listener : getListeners() ) { listener.sessionCreated(event); } }
@Override public void sessionDestroyed(HttpSessionEvent event) { for( HttpSessionListener listener : getListeners() ) { listener.sessionDestroyed(event); } }
/** * 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 { fireContainerEvent(context, "beforeSessionCreated", listener); listener.sessionCreated(event); fireContainerEvent(context, "afterSessionCreated", listener); } catch (Throwable t) { try { fireContainerEvent(context, "afterSessionCreated", listener); } catch (Exception e) { ; } manager.getContainer().getLogger().error (sm.getString("standardSession.sessionEvent"), t); } } } }
public void sessionDestroyed(final HttpSession session) { final HttpSessionEvent sre = new HttpSessionEvent(session); for (int i = httpSessionListeners.length - 1; i >= 0; --i) { ManagedListener listener = httpSessionListeners[i]; this.<HttpSessionListener>get(listener).sessionDestroyed(sre); } }
/** * 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); } } } }
@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())); } }
@Override public void sessionCreated(RepositoryBackedSession session) { if (session instanceof HttpSession) { HttpSessionEvent event = new HttpSessionEvent((HttpSession)session); for (HttpSessionListener listener : descriptor.getHttpSessionListeners()) { listener.sessionCreated(event); } } }
@Test public void testOnAddListener() { ServletContextDescriptor scd = new ServletContextDescriptor(servletContext); when(servletContext.getAttribute(Attributes.SERVLET_CONTEXT_DESCRIPTOR)).thenReturn(scd); sessionHelpers.onAddListener(servletContext, "Dummy"); assertTrue(scd.getHttpSessionListeners().isEmpty()); assertTrue(scd.getHttpSessionIdListeners().isEmpty()); assertTrue(scd.getHttpSessionAttributeListeners().isEmpty()); HttpSessionListener listener = mock(HttpSessionListener.class); HttpSessionIdListener idListener = mock(HttpSessionIdListener.class); HttpSessionAttributeListener attributeListener = mock(HttpSessionAttributeListener.class); HttpSessionListener multiListener = mock(HttpSessionListener.class, withSettings().extraInterfaces(HttpSessionAttributeListener.class)); HttpSessionAttributeListener attributeMultiListener = (HttpSessionAttributeListener)multiListener; sessionHelpers.onAddListener(servletContext, listener); assertThat(scd.getHttpSessionListeners(), hasItem(listener)); assertTrue(scd.getHttpSessionIdListeners().isEmpty()); assertTrue(scd.getHttpSessionAttributeListeners().isEmpty()); sessionHelpers.onAddListener(servletContext, idListener); assertThat(scd.getHttpSessionListeners(), hasItem(listener)); assertThat(scd.getHttpSessionIdListeners(), hasItem(idListener)); assertTrue(scd.getHttpSessionAttributeListeners().isEmpty()); sessionHelpers.onAddListener(servletContext, attributeListener); assertThat(scd.getHttpSessionListeners(), hasItem(listener)); assertThat(scd.getHttpSessionIdListeners(), hasItem(idListener)); assertThat(scd.getHttpSessionAttributeListeners(), hasItem(attributeListener)); sessionHelpers.onAddListener(servletContext, multiListener); assertThat(scd.getHttpSessionListeners(), hasItem(listener)); assertThat(scd.getHttpSessionListeners(), hasItem(multiListener)); assertThat(scd.getHttpSessionIdListeners(), hasItem(idListener)); assertThat(scd.getHttpSessionAttributeListeners(), hasItem(attributeListener)); assertThat(scd.getHttpSessionAttributeListeners(), hasItem(attributeMultiListener)); }
@Test public void testSessionCreated() { HttpSessionListener listener = mock(HttpSessionListener.class); descriptor.addHttpSessionListener(listener); notifier.sessionCreated(session); verify(listener).sessionCreated(any(HttpSessionEvent.class)); HttpSessionListener listener2 = mock(HttpSessionListener.class); descriptor.addHttpSessionListener(listener2); notifier.sessionCreated(session); verify(listener, times(2)).sessionCreated(any(HttpSessionEvent.class)); verify(listener2).sessionCreated(any(HttpSessionEvent.class)); }
@Test public void testSessionDestroyed() { HttpSessionListener listener = mock(HttpSessionListener.class); descriptor.addHttpSessionListener(listener); notifier.sessionDestroyed(session, false); verify(listener).sessionDestroyed(any(HttpSessionEvent.class)); HttpSessionListener listener2 = mock(HttpSessionListener.class); descriptor.addHttpSessionListener(listener2); notifier.sessionDestroyed(session, false); verify(listener, times(2)).sessionDestroyed(any(HttpSessionEvent.class)); verify(listener2).sessionDestroyed(any(HttpSessionEvent.class)); }
@Test public void testShutdown() { HttpSessionListener listener = mock(HttpSessionListener.class); descriptor.addHttpSessionListener(listener); notifier.sessionDestroyed(session, true); verify(listener).sessionDestroyed(any(HttpSessionEvent.class)); HttpSessionListener listener2 = mock(HttpSessionListener.class); descriptor.addHttpSessionListener(listener2); notifier.sessionDestroyed(session, true); verify(listener, times(2)).sessionDestroyed(any(HttpSessionEvent.class)); verify(listener2).sessionDestroyed(any(HttpSessionEvent.class)); }
public void sessionCreated(HttpSessionEvent se) { for (EventListener listener: PluginWebInstanceRepository.getListeners()) { if (listener instanceof HttpSessionListener) { ((HttpSessionListener) listener).sessionCreated(se); } } }
public void sessionDestroyed(HttpSessionEvent se) { for (EventListener listener: PluginWebInstanceRepository.getListeners()) { if (listener instanceof HttpSessionListener) { ((HttpSessionListener) listener).sessionDestroyed(se); } } }
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 + "'"); } } }
public WebAppSessionWrapper(HttpSession delegate, ServletContext context, HttpSessionListener sessionListener, HttpSessionAttributeListener sessionAttributeListener) { super(delegate); this.context = context; this.sessionListener = sessionListener; this.sessionAttributeListener = sessionAttributeListener; fireSessionCreated(); }
@Test public void testContributeListeners_SessionListener() throws Exception { // TODO: test session destroy event... doAnswer(i -> { HttpServletRequest request = (HttpServletRequest) i.getArgumentAt(0, ServletRequest.class); request.getSession(true); return null; }).when(mockServlet1).service(any(ServletRequest.class), any(ServletResponse.class)); HttpSessionListener sessionListener = mock(HttpSessionListener.class); startApp(b -> JettyModule.extend(b) .addServlet(mockServlet1, "s1", "/a/*", "/b/*") .addListener(sessionListener)); verify(sessionListener, times(0)).sessionCreated(any()); verify(sessionListener, times(0)).sessionDestroyed(any()); WebTarget base = ClientBuilder.newClient().target("http://localhost:8080"); base.path("/a").request().get(); Thread.sleep(100); verify(sessionListener, times(1)).sessionCreated(any()); verify(sessionListener, times(0)).sessionDestroyed(any()); base.path("/b").request().get(); Thread.sleep(100); verify(sessionListener, times(2)).sessionCreated(any()); verify(sessionListener, times(0)).sessionDestroyed(any()); // not_found request base.path("/c").request().get(); Thread.sleep(100); verify(sessionListener, times(2)).sessionCreated(any()); verify(sessionListener, times(0)).sessionDestroyed(any()); }
@Test public void testContributeListeners_SessionListener_SessionsDisabled() throws Exception { doAnswer(i -> { HttpServletRequest request = (HttpServletRequest) i.getArgumentAt(0, ServletRequest.class); try { request.getSession(true); } catch (IllegalStateException e) { // expected, ignoring... } return null; }).when(mockServlet1).service(any(ServletRequest.class), any(ServletResponse.class)); HttpSessionListener sessionListener = mock(HttpSessionListener.class); startApp(b -> { JettyModule.extend(b) .addServlet(mockServlet1, "s1", "/a/*", "/b/*") .addListener(sessionListener); BQCoreModule.extend(b).setProperty("bq.jetty.sessions", "false"); }); verify(sessionListener, times(0)).sessionCreated(any()); verify(sessionListener, times(0)).sessionDestroyed(any()); WebTarget base = ClientBuilder.newClient().target("http://localhost:8080"); base.path("/a").request().get(); Thread.sleep(100); verify(sessionListener, times(0)).sessionCreated(any()); verify(sessionListener, times(0)).sessionDestroyed(any()); }
/** * {@inheritDoc} * @see javax.servlet.http.HttpSessionListener#sessionCreated(javax.servlet.http.HttpSessionEvent) */ public void sessionCreated(final HttpSessionEvent event) { LOG.debug("Begin BootstrapListener session created..."); init(); for (HttpSessionListener listener : listeners.values()) { listener.sessionCreated(event); } LOG.debug("...end BootstrapListener session created."); }
/** * {@inheritDoc} * @see javax.servlet.http.HttpSessionListener#sessionDestroyed(javax.servlet.http.HttpSessionEvent) */ public void sessionDestroyed(final HttpSessionEvent event) { LOG.debug("Begin BootstrapListener session destroyed..."); init(); for (HttpSessionListener listener : listeners.values()) { listener.sessionDestroyed(event); } LOG.debug("...end BootstrapListener session destroyed."); }
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); } }
public static void initializeHttpSessionListener() { BundleContext bundleContext = FrameworkUtil.getBundle(HttpServiceServlet.class).getBundleContext(); Hashtable<String, Object> properties = new Hashtable<String, Object>(); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, Boolean.TRUE.toString()); properties.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=*)"); bundleContext.registerService(new String[] { HttpSessionListener.class.getName() }, SERVICE_LISTENER, properties); }
private void fireSessionCreatedEvent(HttpSession session){ for (EventListener listener : listeners){ if(listener instanceof HttpSessionListener){ ((HttpSessionListener) listener).sessionCreated(new HttpSessionEvent(session)); } } }