deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject git commit: DELTASPIKE-535 DeltaSpikeViewHandler construction issue in non EE
Date Tue, 04 Mar 2014 19:41:18 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master f24f10b3f -> fa1fc9fcc


DELTASPIKE-535 DeltaSpikeViewHandler construction issue in non EE

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

Branch: refs/heads/master
Commit: fa1fc9fcc4b7f470fd27249cabc427e1af3e0e93
Parents: f24f10b
Author: tandraschko <tandraschko@apache.org>
Authored: Tue Mar 4 20:41:09 2014 +0100
Committer: tandraschko <tandraschko@apache.org>
Committed: Tue Mar 4 20:41:09 2014 +0100

----------------------------------------------------------------------
 .../jsf/impl/view/DeltaSpikeViewHandler.java    | 50 +++++++++++++++-----
 1 file changed, 37 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/fa1fc9fc/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/view/DeltaSpikeViewHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/view/DeltaSpikeViewHandler.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/view/DeltaSpikeViewHandler.java
index 1c0ebaa..ae2cff0 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/view/DeltaSpikeViewHandler.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/view/DeltaSpikeViewHandler.java
@@ -37,8 +37,10 @@ public class DeltaSpikeViewHandler extends ViewHandlerWrapper implements
Deactiv
 {
     protected final ViewHandler wrapped;
 
-    private final ViewHandler securityAwareViewHandler;
-    private final ClientWindow clientWindow;
+    private volatile Boolean initialized;
+    
+    private ViewHandler securityAwareViewHandler;
+    private ClientWindow clientWindow;
 
     /**
      * Constructor for wrapping the given {@link ViewHandler}
@@ -48,17 +50,6 @@ public class DeltaSpikeViewHandler extends ViewHandlerWrapper implements
Deactiv
     public DeltaSpikeViewHandler(ViewHandler wrapped)
     {
         this.wrapped = wrapped;
-        if (ClassDeactivationUtils.isActivated(getClass()))
-        {
-            this.securityAwareViewHandler = createSecurityAwareViewHandler();
-            //TODO add ViewHandler for handling the WindowContext
-        }
-        else
-        {
-            this.securityAwareViewHandler = null;
-        }
-
-        this.clientWindow = BeanProvider.getContextualReference(ClientWindow.class, true);
     }
 
     //allows custom implementations to override the SecurityAwareViewHandler
@@ -70,6 +61,8 @@ public class DeltaSpikeViewHandler extends ViewHandlerWrapper implements
Deactiv
     @Override
     public UIViewRoot createView(FacesContext facesContext, String viewId)
     {
+        lazyInit();
+        
         if (this.securityAwareViewHandler == null)
         {
             return this.wrapped.createView(facesContext, viewId);
@@ -80,6 +73,8 @@ public class DeltaSpikeViewHandler extends ViewHandlerWrapper implements
Deactiv
     @Override
     public String getActionURL(FacesContext context, String viewId)
     {
+        lazyInit();
+        
         String actionURL = this.wrapped.getActionURL(context, viewId);
         return ClientWindowHelper.appendWindowId(context, actionURL, clientWindow);
     }
@@ -89,4 +84,33 @@ public class DeltaSpikeViewHandler extends ViewHandlerWrapper implements
Deactiv
     {
         return this.wrapped;
     }
+    
+    private void lazyInit()
+    {
+        if (this.initialized == null)
+        {
+            init();
+        }
+    }
+
+    private synchronized void init()
+    {
+        // switch into paranoia mode
+        if (this.initialized == null)
+        {
+            if (ClassDeactivationUtils.isActivated(getClass()))
+            {
+                this.securityAwareViewHandler = createSecurityAwareViewHandler();
+                //TODO add ViewHandler for handling the WindowContext
+            }
+            else
+            {
+                this.securityAwareViewHandler = null;
+            }
+
+            this.clientWindow = BeanProvider.getContextualReference(ClientWindow.class, true);
+            
+            this.initialized = true;
+        }
+    }
 }


Mime
View raw message