private static void doTestServingLayer(Config config) throws IOException { try (ServingLayer servingLayer = new ServingLayer(config)) { servingLayer.start(); Context context = servingLayer.getContext(); assertNotNull(context.findErrorPage(500)); assertEquals(0, context.getApplicationLifecycleListeners().length); assertNotNull(context.findParameter(ConfigUtils.class.getName() + ".serialized")); assertNotNull(context.getName()); assertGreaterOrEqual(Double.parseDouble(context.getWebappVersion()), 3.1); } }
/** * {@inheritDoc} * @see org.jboss.modcluster.SessionManager#removeSessionListener(javax.servlet.http.HttpSessionListener) */ public void removeSessionListener(HttpSessionListener listener) { synchronized (this.context) { this.context.setApplicationLifecycleListeners(this.removeListener(listener, this.context.getApplicationLifecycleListeners())); } }
@Override public void addSessionListener(HttpSessionListener listener) { synchronized (this.context) { this.context.setApplicationLifecycleListeners(this.addListener(listener, this.context.getApplicationLifecycleListeners())); } }
/** * {@inheritDoc} * @see org.jboss.modcluster.SessionManager#addSessionListener(javax.servlet.http.HttpSessionListener) */ public void addSessionListener(HttpSessionListener listener) { synchronized (this.context) { this.context.setApplicationLifecycleListeners(this.addListener(listener, this.context.getApplicationLifecycleListeners())); } }
@Override public void removeSessionListener(HttpSessionListener listener) { synchronized (this.context) { this.context.setApplicationLifecycleListeners(this.removeListener(listener, this.context.getApplicationLifecycleListeners())); } }
@Test public void removeSessionListener() { HttpSessionListener listener = mock(HttpSessionListener.class); ArgumentCaptor<Object[]> capturedListeners = ArgumentCaptor.forClass(Object[].class); Object otherListener = new Object(); when(this.context.getApplicationLifecycleListeners()).thenReturn(new Object[] { otherListener, listener }); this.catalinaContext.removeSessionListener(listener); verify(this.context).setApplicationLifecycleListeners(capturedListeners.capture()); Object[] listeners = capturedListeners.getValue(); assertEquals(1, listeners.length); assertSame(otherListener, listeners[0]); }
@Test public void addSessionListener() { HttpSessionListener listener = mock(HttpSessionListener.class); ArgumentCaptor<Object[]> capturedListeners = ArgumentCaptor.forClass(Object[].class); Object otherListener = new Object(); when(this.context.getApplicationLifecycleListeners()).thenReturn(new Object[] { otherListener }); this.catalinaContext.addSessionListener(listener); verify(this.context).setApplicationLifecycleListeners(capturedListeners.capture()); Object[] listeners = capturedListeners.getValue(); assertEquals(2, listeners.length); assertSame(listener, listeners[0]); assertSame(otherListener, listeners[1]); }
Object listeners[] = context.getApplicationLifecycleListeners(); if (listeners != null) { HttpSessionEvent event =
private void sessionCreatedEvent(RedisSessionCreatedEvent sessionCreatedEvent) { Context context = manager.getContext(); Object listeners[] = context.getApplicationLifecycleListeners(); if (listeners != null) { RedisHttpSession session = new RedisHttpSession(sessionCreatedEvent.getId(), manager); HttpSessionEvent event = new HttpSessionEvent(session); //noinspection ForLoopReplaceableByForEach 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) { handleThrowable(t); try { fireContainerEvent(context, "afterSessionCreated", listener); } catch (Exception e) { // Ignore } manager.getContext().getLogger().error(sm.getString("standardSession.sessionEvent"), t); } } } }
private void sessionDestroyedEvent(RedisSessionDestroyedEvent sessionDestroyedEvent) { Context context = manager.getContext(); Object listeners[] = context.getApplicationLifecycleListeners(); if (listeners != null) { RedisHttpSession session = new RedisHttpSession(sessionDestroyedEvent.getId(), manager); HttpSessionEvent event = new HttpSessionEvent(session); for (int i = 0; i < listeners.length; i++) { int j = (listeners.length - 1) - i; if (!(listeners[j] instanceof HttpSessionListener)) { continue; } HttpSessionListener listener = (HttpSessionListener) listeners[j]; try { fireContainerEvent(context, "beforeSessionDestroyed", listener); listener.sessionDestroyed(event); fireContainerEvent(context, "afterSessionDestroyed", listener); } catch (Throwable t) { handleThrowable(t); try { fireContainerEvent(context, "afterSessionDestroyed", listener); } catch (Exception e) { // Ignore } manager.getContext().getLogger().error(sm.getString("standardSession.sessionEvent"), t); } } } }
private void sessionCreatedEvent(RedisSessionCreatedEvent sessionCreatedEvent) { Context context = (Context) manager.getContainer(); Object listeners[] = context.getApplicationLifecycleListeners(); if (listeners != null) { RedisHttpSession session = new RedisHttpSession(sessionCreatedEvent.getId(), manager); HttpSessionEvent event = new HttpSessionEvent(session); //noinspection ForLoopReplaceableByForEach 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) { ExceptionUtils.handleThrowable(t); try { fireContainerEvent(context, "afterSessionCreated", listener); } catch (Exception e) { // Ignore } manager.getContainer().getLogger().error(sm.getString("standardSession.sessionEvent"), t); } } } }
private void sessionDestroyedEvent(RedisSessionDestroyedEvent sessionDestroyedEvent) { Context context = (Context) manager.getContainer(); Object listeners[] = context.getApplicationLifecycleListeners(); if (listeners != null) { RedisHttpSession session = new RedisHttpSession(sessionDestroyedEvent.getId(), manager); HttpSessionEvent event = new HttpSessionEvent(session); for (int i = 0; i < listeners.length; i++) { int j = (listeners.length - 1) - i; if (!(listeners[j] instanceof HttpSessionListener)) { continue; } HttpSessionListener listener = (HttpSessionListener) listeners[j]; try { fireContainerEvent(context, "beforeSessionDestroyed", listener); listener.sessionDestroyed(event); fireContainerEvent(context, "afterSessionDestroyed", listener); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); try { fireContainerEvent(context, "afterSessionDestroyed", listener); } catch (Exception e) { // Ignore } manager.getContainer().getLogger().error(sm.getString("standardSession.sessionEvent"), t); } } } }
Object listeners[] = context.getApplicationLifecycleListeners(); if (listeners != null && listeners.length > 0) { HttpSessionEvent event =
Object listeners[] = context.getApplicationLifecycleListeners(); if (listeners != null && listeners.length > 0) { HttpSessionEvent event =
Object listeners[] = context.getApplicationLifecycleListeners(); if (listeners != null) { HttpSessionEvent event =
Object listeners[] = context.getApplicationLifecycleListeners(); if (listeners != null) { HttpSessionEvent event =
Object listeners[] = context.getApplicationLifecycleListeners(); if (listeners != null) { HttpSessionEvent event =
Object listeners[] = context.getApplicationLifecycleListeners(); if (listeners != null && listeners.length > 0) { HttpSessionEvent event =
Object listeners[] = context.getApplicationLifecycleListeners(); if (listeners != null) { HttpSessionEvent event =
Object listeners[] = context.getApplicationLifecycleListeners(); if (listeners != null) { HttpSessionEvent event =