Author: nickarls
Date: 2010-04-25 17:41:10 -0400 (Sun, 25 Apr 2010)
New Revision: 12635
Modified:
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/beanManager/FacesServletContextBeanManagerProvider.java
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/BeanManagerServletContextListener.java
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/PhaseEventBridge.java
Log:
Other name for BM key in context listener
Multiple key search in FSCBMP
Modified:
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/beanManager/FacesServletContextBeanManagerProvider.java
===================================================================
---
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/beanManager/FacesServletContextBeanManagerProvider.java 2010-04-25
21:11:37 UTC (rev 12634)
+++
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/beanManager/FacesServletContextBeanManagerProvider.java 2010-04-25
21:41:10 UTC (rev 12635)
@@ -21,10 +21,14 @@
*/
package org.jboss.seam.faces.beanManager;
+import java.util.ArrayList;
+import java.util.List;
+
import javax.enterprise.inject.spi.BeanManager;
import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;
+import org.jboss.seam.faces.event.BeanManagerServletContextListener;
import org.jboss.weld.extensions.beanManager.BeanManagerProvider;
/**
@@ -38,6 +42,15 @@
{
public static final FacesServletContextBeanManagerProvider DEFAULT = new
FacesServletContextBeanManagerProvider();
+ private static final List<String> SERVLET_CONTEXT_KEYS = new
ArrayList<String>()
+ {
+ private static final long serialVersionUID = 1L;
+ {
+ add(BeanManager.class.getName());
+ add(BeanManagerServletContextListener.BEANMANAGER_SERVLETCONTEXT_KEY);
+ }
+ };
+
public BeanManager getBeanManager()
{
FacesContext facesContext = FacesContext.getCurrentInstance();
@@ -46,9 +59,23 @@
return null;
}
ServletContext servletContext = (ServletContext)
facesContext.getExternalContext().getContext();
- return (BeanManager) servletContext.getAttribute(BeanManager.class.getName());
+ return getBeanManager(servletContext);
}
+ private BeanManager getBeanManager(ServletContext servletContext)
+ {
+ BeanManager beanManager = null;
+ for (String key : SERVLET_CONTEXT_KEYS)
+ {
+ beanManager = (BeanManager) servletContext.getAttribute(key);
+ if (beanManager != null)
+ {
+ break;
+ }
+ }
+ return beanManager;
+ }
+
public int getPrecedence()
{
return 20;
Modified:
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/BeanManagerServletContextListener.java
===================================================================
---
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/BeanManagerServletContextListener.java 2010-04-25
21:11:37 UTC (rev 12634)
+++
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/BeanManagerServletContextListener.java 2010-04-25
21:41:10 UTC (rev 12635)
@@ -1,3 +1,24 @@
+/*
+ * 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.faces.event;
import javax.enterprise.inject.spi.BeanManager;
@@ -5,8 +26,16 @@
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
+/**
+ * A Servlet Context Listener that places the BeanManager under a known attribute key
+ *
+ * @author Nicklas Karlsson
+ *
+ */
public class BeanManagerServletContextListener implements ServletContextListener
{
+ public static final String BEANMANAGER_SERVLETCONTEXT_KEY =
"org.jboss.seam.faces.javax.enterprise.spi.BeanManager";
+
@Inject
private BeanManager beanManager;
@@ -16,7 +45,7 @@
public void contextInitialized(ServletContextEvent sce)
{
- sce.getServletContext().setAttribute(BeanManager.class.getName(), beanManager);
+ sce.getServletContext().setAttribute(BEANMANAGER_SERVLETCONTEXT_KEY, beanManager);
}
Modified:
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/PhaseEventBridge.java
===================================================================
---
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/PhaseEventBridge.java 2010-04-25
21:11:37 UTC (rev 12634)
+++
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/PhaseEventBridge.java 2010-04-25
21:41:10 UTC (rev 12635)
@@ -23,7 +23,6 @@
import java.lang.annotation.Annotation;
-import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.util.AnnotationLiteral;