[seam-commits] Seam SVN: r12341 - in modules/servlet/trunk: src/main/java/org/jboss/seam/servlet and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Wed Mar 31 08:11:16 EDT 2010


Author: nickarls
Date: 2010-03-31 08:11:15 -0400 (Wed, 31 Mar 2010)
New Revision: 12341

Modified:
   modules/servlet/trunk/pom.xml
   modules/servlet/trunk/src/main/java/org/jboss/seam/servlet/HttpManager.java
Log:
Don't listen on servlet context attrs, too soon

Modified: modules/servlet/trunk/pom.xml
===================================================================
--- modules/servlet/trunk/pom.xml	2010-03-31 11:59:42 UTC (rev 12340)
+++ modules/servlet/trunk/pom.xml	2010-03-31 12:11:15 UTC (rev 12341)
@@ -77,6 +77,7 @@
 			<groupId>org.jboss.weld</groupId>
 			<artifactId>weld-extensions</artifactId>
 			<version>1.0.0.Alpha1</version>
+			<scope>provided</scope>
 		</dependency>		
 		<dependency>
 			<groupId>org.jboss.weld</groupId>

Modified: modules/servlet/trunk/src/main/java/org/jboss/seam/servlet/HttpManager.java
===================================================================
--- modules/servlet/trunk/src/main/java/org/jboss/seam/servlet/HttpManager.java	2010-03-31 11:59:42 UTC (rev 12340)
+++ modules/servlet/trunk/src/main/java/org/jboss/seam/servlet/HttpManager.java	2010-03-31 12:11:15 UTC (rev 12341)
@@ -1,20 +1,18 @@
 package org.jboss.seam.servlet;
 
-import javax.enterprise.context.RequestScoped;
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.inject.Inject;
-import javax.servlet.ServletContextAttributeEvent;
 import javax.servlet.ServletRequestEvent;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 import javax.servlet.http.HttpSessionEvent;
 
-import org.jboss.seam.servlet.event.qualifier.AttributeAdded;
-import org.jboss.seam.servlet.event.qualifier.AttributeRemoved;
-import org.jboss.seam.servlet.event.qualifier.AttributeReplaced;
 import org.jboss.seam.servlet.event.qualifier.Created;
 import org.jboss.seam.servlet.event.qualifier.Destroyed;
 import org.jboss.seam.servlet.event.qualifier.Initialized;
@@ -26,8 +24,8 @@
  * @author Nicklas Karlsson
  * 
  */
- at RequestScoped
-public class HttpManager
+ at SessionScoped
+public class HttpManager implements Serializable
 {
    private static final long serialVersionUID = 5191073522575178427L;
    
@@ -50,43 +48,18 @@
       request = null;
    }
 
-   protected void servletContextAttributeAdded(@Observes @AttributeAdded ServletContextAttributeEvent e)
-   {
-      if (BeanManager.class.getName().equals(e.getName()))
-      {
-         log.trace("Bean manager set in servlet context with event #0", e);
-         beanManager = (BeanManager) e.getValue();
-      }
-   }
-
-   protected void servletContextAttributeReplaced(@Observes @AttributeReplaced ServletContextAttributeEvent e)
-   {
-      if (BeanManager.class.getName().equals(e.getName()))
-      {
-         log.trace("Bean manager replaced in servlet context with event #0", e);
-         beanManager = (BeanManager) e.getValue();
-      }
-   }
-
-   protected void servletContextAttributeRemoved(@Observes @AttributeRemoved ServletContextAttributeEvent e)
-   {
-      if (BeanManager.class.getName().equals(e.getName()))
-      {
-         log.trace("Bean manager removed from servlet context with event #0", e);
-         beanManager = null;
-      }
-   }
-
    protected void sessionInitialized(@Observes @Created HttpSessionEvent e)
    {
       log.trace("HTTP session initalized with event #0", e);
       session = e.getSession();
+      beanManager = (BeanManager) session.getServletContext().getAttribute(BeanManager.class.getName());
    }
 
    protected void sessionDestroyed(@Observes @Destroyed HttpSessionEvent e)
    {
       log.trace("HTTP session destroyed with event #0", e);
       session = null;
+      beanManager = null;
    }
 
    /**



More information about the seam-commits mailing list