deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject git commit: DELTASPIKE-487 moved navigation logic to own NavigationHandler
Date Sun, 02 Mar 2014 11:10:54 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 140afd31c -> cc19e43ed


DELTASPIKE-487 moved navigation logic to own NavigationHandler

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

Branch: refs/heads/master
Commit: cc19e43ed38802e7fd462041712d8b868cc5f62d
Parents: 140afd3
Author: tandraschko <tandraschko@apache.org>
Authored: Sun Mar 2 12:10:43 2014 +0100
Committer: tandraschko <tandraschko@apache.org>
Committed: Sun Mar 2 12:10:43 2014 +0100

----------------------------------------------------------------------
 .../navigation/DeltaSpikeNavigationHandler.java | 41 +---------
 .../ViewAccessScopedAwareNavigationHandler.java | 86 ++++++++++++++++++++
 2 files changed, 88 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/cc19e43e/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DeltaSpikeNavigationHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DeltaSpikeNavigationHandler.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DeltaSpikeNavigationHandler.java
index 8ddaa29..c035417 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DeltaSpikeNavigationHandler.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DeltaSpikeNavigationHandler.java
@@ -39,9 +39,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArraySet;
-import org.apache.deltaspike.core.api.provider.BeanProvider;
-import org.apache.deltaspike.core.impl.scope.DeltaSpikeContextExtension;
-import org.apache.deltaspike.core.impl.scope.viewaccess.ViewAccessContext;
+import org.apache.deltaspike.jsf.impl.scope.viewaccess.ViewAccessScopedAwareNavigationHandler;
 
 public class DeltaSpikeNavigationHandler extends ConfigurableNavigationHandler implements
Deactivatable
 {
@@ -53,10 +51,6 @@ public class DeltaSpikeNavigationHandler extends ConfigurableNavigationHandler
i
     private final NavigationHandler wrapped;
     private final boolean activated;
 
-    private volatile Boolean initialized;
-    
-    private DeltaSpikeContextExtension contextExtension;
-    
     /**
      * Constructor for wrapping the given {@link NavigationHandler}
      *
@@ -71,17 +65,6 @@ public class DeltaSpikeNavigationHandler extends ConfigurableNavigationHandler
i
     @Override
     public void handleNavigation(FacesContext context, String fromAction, String outcome)
     {
-        lazyInit();
-        
-        if (context.getViewRoot() != null && context.getViewRoot().getViewId() !=
null)
-        {
-            ViewAccessContext viewAccessContext = contextExtension.getViewAccessScopedContext();
-            if (viewAccessContext != null)
-            {
-                viewAccessContext.onProcessingViewFinished(context.getViewRoot().getViewId());
-            }
-        }
-        
         if (!this.activated || isUnhandledExceptionQueued(context))
         {
             this.wrapped.handleNavigation(context, fromAction, outcome);
@@ -104,8 +87,7 @@ public class DeltaSpikeNavigationHandler extends ConfigurableNavigationHandler
i
         ViewConfigAwareNavigationHandler viewConfigAwareNavigationHandler =
                 new ViewConfigAwareNavigationHandler(this.wrapped);
 
-        //TODO add AccessScopeAwareNavigationHandler
-        return viewConfigAwareNavigationHandler;
+        return new ViewAccessScopedAwareNavigationHandler(viewConfigAwareNavigationHandler);
     }
 
     @Override
@@ -188,23 +170,4 @@ public class DeltaSpikeNavigationHandler extends ConfigurableNavigationHandler
i
 
         return new NavigationCaseMapWrapper(result, this.wrapped);
     }
-    
-    private void lazyInit()
-    {
-        if (this.initialized == null)
-        {
-            init();
-        }
-    }
-
-    private synchronized void init()
-    {
-        // switch into paranoia mode
-        if (this.initialized == null)
-        {
-            contextExtension = BeanProvider.getContextualReference(DeltaSpikeContextExtension.class,
true);
-            
-            this.initialized = true;
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/cc19e43e/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/viewaccess/ViewAccessScopedAwareNavigationHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/viewaccess/ViewAccessScopedAwareNavigationHandler.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/viewaccess/ViewAccessScopedAwareNavigationHandler.java
new file mode 100644
index 0000000..1e5349d
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/viewaccess/ViewAccessScopedAwareNavigationHandler.java
@@ -0,0 +1,86 @@
+/*
+ * 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.scope.viewaccess;
+
+import javax.faces.application.NavigationHandler;
+import javax.faces.context.FacesContext;
+import org.apache.deltaspike.core.api.provider.BeanProvider;
+import org.apache.deltaspike.core.impl.scope.DeltaSpikeContextExtension;
+import org.apache.deltaspike.core.impl.scope.viewaccess.ViewAccessContext;
+import org.apache.deltaspike.core.spi.activation.Deactivatable;
+import org.apache.deltaspike.core.util.ClassDeactivationUtils;
+
+public class ViewAccessScopedAwareNavigationHandler extends NavigationHandler implements
Deactivatable
+{
+    private final NavigationHandler navigationHandler;
+    private final boolean activated;
+
+    private volatile Boolean initialized;
+    
+    private DeltaSpikeContextExtension contextExtension;
+    
+    public ViewAccessScopedAwareNavigationHandler(NavigationHandler navigationHandler)
+    {
+        this.navigationHandler = navigationHandler;
+        this.activated = ClassDeactivationUtils.isActivated(getClass());
+    }
+
+    @Override
+    public void handleNavigation(FacesContext context, String fromAction, String outcome)
+    {
+        // remember viewId before navigation
+        String viewId = null;
+        if (this.activated && context.getViewRoot() != null)
+        {
+            viewId = context.getViewRoot().getViewId();
+        }
+
+        this.navigationHandler.handleNavigation(context, fromAction, outcome);
+        
+        if (this.activated && viewId != null)
+        {
+            lazyInit();
+
+            ViewAccessContext viewAccessContext = contextExtension.getViewAccessScopedContext();
+            if (viewAccessContext != null)
+            {
+                viewAccessContext.onProcessingViewFinished(viewId);
+            }
+        }
+    }
+
+    private void lazyInit()
+    {
+        if (this.initialized == null)
+        {
+            init();
+        }
+    }
+
+    private synchronized void init()
+    {
+        // switch into paranoia mode
+        if (this.initialized == null)
+        {
+            contextExtension = BeanProvider.getContextualReference(DeltaSpikeContextExtension.class,
true);
+            
+            this.initialized = true;
+        }
+    }
+}


Mime
View raw message