From 1a486e584b6184ac7e8e933dafb6b8696a806856 Mon Sep 17 00:00:00 2001 From: Ray Krueger Date: Mon, 20 Nov 2006 19:35:11 +0000 Subject: [PATCH] HttpSessionEventPublisher need not implement ServletContextListener any longer --- .../ui/session/HttpSessionEventPublisher.java | 21 +------------------ .../HttpSessionEventPublisherTests.java | 21 ++----------------- 2 files changed, 3 insertions(+), 39 deletions(-) diff --git a/core/src/main/java/org/acegisecurity/ui/session/HttpSessionEventPublisher.java b/core/src/main/java/org/acegisecurity/ui/session/HttpSessionEventPublisher.java index bb73d513aa..62dc01f69e 100644 --- a/core/src/main/java/org/acegisecurity/ui/session/HttpSessionEventPublisher.java +++ b/core/src/main/java/org/acegisecurity/ui/session/HttpSessionEventPublisher.java @@ -38,7 +38,7 @@ import javax.servlet.http.HttpSessionListener; * * @author Ray Krueger */ -public class HttpSessionEventPublisher implements HttpSessionListener, ServletContextListener { +public class HttpSessionEventPublisher implements HttpSessionListener { //~ Static fields/initializers ===================================================================================== private static final Log log = LogFactory.getLog(HttpSessionEventPublisher.class); @@ -47,25 +47,6 @@ public class HttpSessionEventPublisher implements HttpSessionListener, ServletCo //~ Methods ======================================================================================================== - /** - * Not implemented - * - * @param event - */ - public void contextDestroyed(ServletContextEvent event) {} - - /** - * Handled internally by a call to {@link WebApplicationContextUtils#getWebApplicationContext(javax.servlet.ServletContext)}. - * - * @param event the ServletContextEvent passed in by the container, event.getServletContext() will be used to get - * the WebApplicationContext - */ - public void contextInitialized(ServletContextEvent event) { - if (log.isDebugEnabled()) { - log.debug("Received ServletContextEvent: " + event); - } - } - ApplicationContext getContext(ServletContext servletContext) { return WebApplicationContextUtils.getWebApplicationContext(servletContext); } diff --git a/core/src/test/java/org/acegisecurity/ui/session/HttpSessionEventPublisherTests.java b/core/src/test/java/org/acegisecurity/ui/session/HttpSessionEventPublisherTests.java index e349d97e30..72a0adac79 100644 --- a/core/src/test/java/org/acegisecurity/ui/session/HttpSessionEventPublisherTests.java +++ b/core/src/test/java/org/acegisecurity/ui/session/HttpSessionEventPublisherTests.java @@ -16,13 +16,10 @@ package org.acegisecurity.ui.session; import junit.framework.TestCase; - import org.springframework.mock.web.MockHttpSession; import org.springframework.mock.web.MockServletContext; - import org.springframework.web.context.support.StaticWebApplicationContext; -import javax.servlet.ServletContextEvent; import javax.servlet.http.HttpSessionEvent; @@ -35,18 +32,7 @@ import javax.servlet.http.HttpSessionEvent; public class HttpSessionEventPublisherTests extends TestCase { //~ Methods ======================================================================================================== - public void testDelayedContextInitializationSucceeds() { - HttpSessionEventPublisher publisher = new HttpSessionEventPublisher(); - MockServletContext servletContext = new MockServletContext(); - - // shouldn't fail, even with null context - publisher.contextInitialized(new ServletContextEvent(servletContext)); - - StaticWebApplicationContext context = new StaticWebApplicationContext(); - context.setServletContext(servletContext); - } - - /** + /** * It's not that complicated so we'll just run it straight through here. */ public void testPublisher() { @@ -61,13 +47,11 @@ public class HttpSessionEventPublisherTests extends TestCase { context.registerSingleton("listener", TestListener.class, null); context.refresh(); - publisher.contextInitialized(new ServletContextEvent(servletContext)); - MockHttpSession session = new MockHttpSession(servletContext); TestListener listener = (TestListener) context.getBean("listener"); HttpSessionEvent event = new HttpSessionEvent(session); - + publisher.sessionCreated(event); assertNotNull(listener.getCreatedEvent()); @@ -82,6 +66,5 @@ public class HttpSessionEventPublisherTests extends TestCase { assertNull(listener.getCreatedEvent()); assertEquals(session, listener.getDestroyedEvent().getSession()); - publisher.contextDestroyed(new ServletContextEvent(servletContext)); } }