Author: nickarls
Date: 2010-04-25 17:11:37 -0400 (Sun, 25 Apr 2010)
New Revision: 12634
Added:
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/BeanManagerServletContextListener.java
modules/faces/trunk/impl/src/main/resources/META-INF/web-fragment.xml
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/SystemEventBridge.java
Log:
own ServletContextListener for sticking the BeanManager into the ServletContext attribute
of the BM class name
Added:
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
(rev 0)
+++
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/BeanManagerServletContextListener.java 2010-04-25
21:11:37 UTC (rev 12634)
@@ -0,0 +1,23 @@
+package org.jboss.seam.faces.event;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+public class BeanManagerServletContextListener implements ServletContextListener
+{
+ @Inject
+ private BeanManager beanManager;
+
+ public void contextDestroyed(ServletContextEvent sce)
+ {
+ }
+
+ public void contextInitialized(ServletContextEvent sce)
+ {
+ sce.getServletContext().setAttribute(BeanManager.class.getName(), 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:20 UTC (rev 12633)
+++
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/PhaseEventBridge.java 2010-04-25
21:11:37 UTC (rev 12634)
@@ -25,6 +25,7 @@
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.util.AnnotationLiteral;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
@@ -39,7 +40,6 @@
import org.jboss.seam.faces.event.qualifier.RenderResponse;
import org.jboss.seam.faces.event.qualifier.RestoreView;
import org.jboss.seam.faces.event.qualifier.UpdateModelValues;
-import org.jboss.weld.extensions.beanManager.BeanManagerAware;
import org.slf4j.Logger;
/**
@@ -63,13 +63,15 @@
* @author <a href="mailto:lincolnbaxter@gmail.com>Lincoln Baxter,
III</a>
*
*/
-@ApplicationScoped
-public class PhaseEventBridge extends BeanManagerAware implements PhaseListener
+public class PhaseEventBridge implements PhaseListener
{
private static final long serialVersionUID = -6181019551463318453L;
@Inject
private Logger log;
+
+ @Inject
+ private BeanManager beanManager;
/**
* @param whenQualifier When this event occurred (e.g.:
@@ -115,7 +117,7 @@
*/
Annotation[] qualifiers = new Annotation[] { whenQualifier, phaseQualifier };
log.debug("Fired event #0 with qualifiers #1", event, qualifiers);
- getBeanManager().fireEvent(event, qualifiers);
+ beanManager.fireEvent(event, qualifiers);
}
public void afterPhase(final PhaseEvent e)
Modified:
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/SystemEventBridge.java
===================================================================
---
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/SystemEventBridge.java 2010-04-25
21:11:20 UTC (rev 12633)
+++
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/SystemEventBridge.java 2010-04-25
21:11:37 UTC (rev 12634)
@@ -23,8 +23,8 @@
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;
import javax.faces.component.UIViewRoot;
import javax.faces.event.AbortProcessingException;
@@ -35,10 +35,10 @@
import javax.faces.event.PreRenderViewEvent;
import javax.faces.event.SystemEvent;
import javax.faces.event.SystemEventListener;
+import javax.inject.Inject;
import org.jboss.seam.faces.event.qualifier.Component;
import org.jboss.seam.faces.event.qualifier.View;
-import org.jboss.weld.extensions.beanManager.BeanManagerAware;
/**
* A SystemEventListener used to bridge JSF system events to the CDI event
@@ -63,9 +63,10 @@
*
* @author Nicklas Karlsson
*/
-@ApplicationScoped
-public class SystemEventBridge extends BeanManagerAware implements SystemEventListener
+public class SystemEventBridge implements SystemEventListener
{
+ @Inject
+ BeanManager beanManager;
public boolean isListenerForSource(final Object source)
{
@@ -76,7 +77,7 @@
{
Object payload = e.getClass().cast(e);
Annotation[] qualifiers = getQualifiers(e);
- getBeanManager().fireEvent(payload, qualifiers);
+ beanManager.fireEvent(payload, qualifiers);
}
private Annotation[] getQualifiers(SystemEvent e)
Added: modules/faces/trunk/impl/src/main/resources/META-INF/web-fragment.xml
===================================================================
--- modules/faces/trunk/impl/src/main/resources/META-INF/web-fragment.xml
(rev 0)
+++ modules/faces/trunk/impl/src/main/resources/META-INF/web-fragment.xml 2010-04-25
21:11:37 UTC (rev 12634)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-fragment version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd">
+ <name>seamfaces</name>
+
+ <listener>
+ <listener-class>org.jboss.seam.faces.event.BeanManagerServletContextListener</listener-class>
+ </listener>
+
+</web-fragment>
\ No newline at end of file