Author: nickarls
Date: 2010-04-24 17:53:03 -0400 (Sat, 24 Apr 2010)
New Revision: 12629
Removed:
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/ServletContextHelper.java
Modified:
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/beanManager/ServletContextBeanManagerProvider.java
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/ServletContextProducer.java
Log:
BeanManagerAware for faces module
Fixed precedence
Lazy loading of providers
Weld-specific provider (Pete, can we have this in weld-extensions?)
Modified:
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/beanManager/ServletContextBeanManagerProvider.java
===================================================================
---
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/beanManager/ServletContextBeanManagerProvider.java 2010-04-24
02:42:24 UTC (rev 12628)
+++
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/beanManager/ServletContextBeanManagerProvider.java 2010-04-24
21:53:03 UTC (rev 12629)
@@ -22,8 +22,8 @@
package org.jboss.seam.servlet.beanManager;
import javax.enterprise.inject.spi.BeanManager;
+import javax.servlet.ServletContext;
-import org.jboss.seam.servlet.http.ServletContextHelper;
import org.jboss.weld.extensions.beanManager.BeanManagerProvider;
/**
@@ -35,9 +35,22 @@
*/
public class ServletContextBeanManagerProvider implements BeanManagerProvider
{
+ private static ThreadLocal<ServletContext> servletContext = new
ThreadLocal<ServletContext>()
+ {
+ protected ServletContext initialValue()
+ {
+ return null;
+ }
+ };
+
+ public static void setServletContext(ServletContext sc)
+ {
+ servletContext.set(sc);
+ }
+
public BeanManager getBeanManager()
{
- return (BeanManager)
ServletContextHelper.getCurrentInstance().getAttribute(BeanManager.class.getName());
+ return (BeanManager)
servletContext.get().getAttribute(BeanManager.class.getName());
}
public int getPrecedence()
Deleted:
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/ServletContextHelper.java
===================================================================
---
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/ServletContextHelper.java 2010-04-24
02:42:24 UTC (rev 12628)
+++
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/ServletContextHelper.java 2010-04-24
21:53:03 UTC (rev 12629)
@@ -1,63 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.seam.servlet.http;
-
-import javax.servlet.ServletContext;
-
-/**
- * A ThreadLocal storage for the ServletContext. The current instance is set in
- * ServletContextProducer and used in the ServletContextBeanManagerProvider.
- *
- * @author Nicklas Karlsson
- *
- */
-public class ServletContextHelper
-{
- private static ThreadLocal<ServletContext> servletContext = new
ThreadLocal<ServletContext>()
- {
- protected ServletContext initialValue()
- {
- return null;
- }
- };
-
- /**
- * Returns the current instance of the ServletContext, if any
- *
- * @return The servet context or null if none is currently set
- */
- public static ServletContext getCurrentInstance()
- {
- return (servletContext.get());
- }
-
-
- /**
- * Sets the current instance of the ServletContext
- *
- * @param sc The Servlet Context
- */
- public static void setCurrentInstance(ServletContext sc)
- {
- servletContext.set(sc);
- }
-}
Modified:
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/ServletContextProducer.java
===================================================================
---
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/ServletContextProducer.java 2010-04-24
02:42:24 UTC (rev 12628)
+++
modules/servlet/trunk/impl/src/main/java/org/jboss/seam/servlet/http/ServletContextProducer.java 2010-04-24
21:53:03 UTC (rev 12629)
@@ -29,6 +29,7 @@
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
+import org.jboss.seam.servlet.beanManager.ServletContextBeanManagerProvider;
import org.jboss.seam.servlet.event.qualifier.Destroyed;
import org.jboss.seam.servlet.event.qualifier.Initialized;
import org.slf4j.Logger;
@@ -57,7 +58,7 @@
log.debug("Servlet context initialized with event #0", e);
servletContext = e.getServletContext();
servletContext.setAttribute(BeanManager.class.getName(), beanManager);
- ServletContextHelper.setCurrentInstance(servletContext);
+ ServletContextBeanManagerProvider.setServletContext(servletContext);
}
protected void contextDestroyed(@Observes @Destroyed ServletContextEvent e)