deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject git commit: DELTASPIKE-452 JsfToCdiSystemEventBroadcaster
Date Mon, 09 Dec 2013 09:01:03 GMT
Updated Branches:
  refs/heads/master 249ab699f -> a6b53a71d


DELTASPIKE-452 JsfToCdiSystemEventBroadcaster

 thx to Thomas Andraschko


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/a6b53a71
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/a6b53a71
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/a6b53a71

Branch: refs/heads/master
Commit: a6b53a71d55d1671d10715591e7c4b7b82a4b5a4
Parents: 249ab69
Author: gpetracek <gpetracek@apache.org>
Authored: Mon Dec 9 09:56:52 2013 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Mon Dec 9 09:56:52 2013 +0100

----------------------------------------------------------------------
 .../system/JsfToCdiSystemEventBroadcaster.java  | 58 ++++++++++++++++++++
 .../main/resources/META-INF/faces-config.xml    | 13 +++++
 2 files changed, 71 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/a6b53a71/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/system/JsfToCdiSystemEventBroadcaster.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/system/JsfToCdiSystemEventBroadcaster.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/system/JsfToCdiSystemEventBroadcaster.java
new file mode 100644
index 0000000..d8c56d0
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/system/JsfToCdiSystemEventBroadcaster.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.jsf.impl.listener.system;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.SystemEvent;
+import javax.faces.event.SystemEventListener;
+import org.apache.deltaspike.core.api.provider.BeanManagerProvider;
+import org.apache.deltaspike.core.spi.activation.Deactivatable;
+import org.apache.deltaspike.core.util.ClassDeactivationUtils;
+
+/**
+ * Broadcasts JSF events to CDI observers.
+ */
+public class JsfToCdiSystemEventBroadcaster implements SystemEventListener, Deactivatable
+{
+    private boolean isActivated = true;
+
+    public JsfToCdiSystemEventBroadcaster()
+    {
+        this.isActivated = ClassDeactivationUtils.isActivated(getClass());
+    }
+
+    @Override
+    public boolean isListenerForSource(Object source)
+    {
+        return true;
+    }
+
+    @Override
+    public void processEvent(SystemEvent e) throws AbortProcessingException
+    {
+        if (!this.isActivated)
+        {
+            return;
+        }
+
+        BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager();
+        beanManager.fireEvent(e);
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/a6b53a71/deltaspike/modules/jsf/impl/src/main/resources/META-INF/faces-config.xml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/resources/META-INF/faces-config.xml b/deltaspike/modules/jsf/impl/src/main/resources/META-INF/faces-config.xml
index de8ef13..3c8d349 100644
--- a/deltaspike/modules/jsf/impl/src/main/resources/META-INF/faces-config.xml
+++ b/deltaspike/modules/jsf/impl/src/main/resources/META-INF/faces-config.xml
@@ -32,6 +32,19 @@
         <view-handler>org.apache.deltaspike.jsf.impl.view.DeltaSpikeViewHandler</view-handler>
         <navigation-handler>org.apache.deltaspike.jsf.impl.navigation.DeltaSpikeNavigationHandler</navigation-handler>
         <action-listener>org.apache.deltaspike.jsf.impl.listener.action.DeltaSpikeActionListener</action-listener>
+
+        <system-event-listener>
+            <system-event-listener-class>org.apache.deltaspike.jsf.impl.listener.system.JsfToCdiSystemEventBroadcaster</system-event-listener-class>
+            <system-event-class>javax.faces.event.ExceptionQueuedEvent</system-event-class>
+        </system-event-listener>
+        <system-event-listener>
+            <system-event-listener-class>org.apache.deltaspike.jsf.impl.listener.system.JsfToCdiSystemEventBroadcaster</system-event-listener-class>
+            <system-event-class>javax.faces.event.PostConstructApplicationEvent</system-event-class>
+        </system-event-listener>
+        <system-event-listener>
+            <system-event-listener-class>org.apache.deltaspike.jsf.impl.listener.system.JsfToCdiSystemEventBroadcaster</system-event-listener-class>
+            <system-event-class>javax.faces.event.PreDestroyApplicationEvent</system-event-class>
+        </system-event-listener>
     </application>
 
     <factory>


Mime
View raw message