deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject deltaspike git commit: DELTASPIKE-1029 refactored
Date Wed, 25 Nov 2015 21:05:34 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 70165b048 -> d778adaef


DELTASPIKE-1029 refactored

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

Branch: refs/heads/master
Commit: d778adaef916f5185fa63dcaad89576cc639e79a
Parents: 70165b0
Author: Thomas Andraschko <tandraschko@apache.org>
Authored: Wed Nov 25 22:05:21 2015 +0100
Committer: Thomas Andraschko <tandraschko@apache.org>
Committed: Wed Nov 25 22:05:21 2015 +0100

----------------------------------------------------------------------
 .../DeltaSpikeExternalContextWrapper.java       |  7 +-
 .../request/DeltaSpikeFacesContextWrapper.java  |  9 ---
 .../DeltaSpikePartialResponseWriter.java        | 71 --------------------
 .../DeltaSpikePartialViewContext.java           | 53 ---------------
 .../strategy/AbstractClientWindowStrategy.java  |  7 +-
 .../strategy/ClientSideWindowStrategy.java      |  9 +--
 6 files changed, 13 insertions(+), 143 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d778adae/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeExternalContextWrapper.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeExternalContextWrapper.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeExternalContextWrapper.java
index 6b741e8..a5dccc5 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeExternalContextWrapper.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeExternalContextWrapper.java
@@ -51,9 +51,12 @@ public class DeltaSpikeExternalContextWrapper extends ExternalContextWrapper
imp
             JsfUtils.saveFacesMessages(this.wrapped);
         }
 
-        String targetURL = ClientWindowHelper.appendWindowId(facesContext, url, this.clientWindow);
+        if (clientWindow != null)
+        {
+            url = clientWindow.interceptRedirect(facesContext, url);
+        }
 
-        this.wrapped.redirect(targetURL);
+        this.wrapped.redirect(url);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d778adae/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeFacesContextWrapper.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeFacesContextWrapper.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeFacesContextWrapper.java
index e2301cc..18578ab 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeFacesContextWrapper.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/listener/request/DeltaSpikeFacesContextWrapper.java
@@ -38,10 +38,8 @@ import javax.faces.context.FacesContextWrapper;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.CopyOnWriteArrayList;
-import javax.faces.context.PartialViewContext;
 import org.apache.deltaspike.core.util.metadata.AnnotationInstanceProvider;
 import org.apache.deltaspike.jsf.impl.exception.control.BridgeExceptionHandlerWrapper;
-import org.apache.deltaspike.jsf.impl.navigation.DeltaSpikePartialViewContext;
 
 import org.apache.deltaspike.jsf.impl.navigation.NavigationHandlerAwareApplication;
 import org.apache.deltaspike.jsf.impl.security.SecurityAwareViewHandler;
@@ -100,13 +98,6 @@ class DeltaSpikeFacesContextWrapper extends FacesContextWrapper
 
         wrappedFacesContext.release();
     }
-
-    @Override
-    public PartialViewContext getPartialViewContext()
-    {
-        PartialViewContext partialViewContext = getWrapped().getPartialViewContext();
-        return new DeltaSpikePartialViewContext(partialViewContext);
-    }
     
     @Override
     public ExceptionHandler getExceptionHandler()

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d778adae/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DeltaSpikePartialResponseWriter.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DeltaSpikePartialResponseWriter.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DeltaSpikePartialResponseWriter.java
deleted file mode 100644
index 0c2e27c..0000000
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DeltaSpikePartialResponseWriter.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.navigation;
-
-import java.io.IOException;
-import javax.faces.context.FacesContext;
-import javax.faces.context.PartialResponseWriter;
-import org.apache.deltaspike.core.api.provider.BeanProvider;
-import org.apache.deltaspike.jsf.spi.scope.window.ClientWindow;
-
-public class DeltaSpikePartialResponseWriter extends PartialResponseWriter
-{
-    private ClientWindow clientWindow;
-
-    private volatile Boolean initialized;
-
-    public DeltaSpikePartialResponseWriter(PartialResponseWriter wrapped)
-    {
-        super(wrapped);
-    }
-    
-    @Override
-    public void redirect(String url) throws IOException
-    {
-        lazyInit();
-
-        if (clientWindow == null)
-        {
-            super.redirect(url);
-        }
-        else
-        {
-            super.redirect(clientWindow.interceptRedirect(FacesContext.getCurrentInstance(),
url));
-        }
-    }
-    
-    private void lazyInit()
-    {
-        if (this.initialized == null)
-        {
-            init();
-        }
-    }
-
-    private synchronized void init()
-    {
-        // switch into paranoia mode
-        if (this.initialized == null)
-        {
-            clientWindow = BeanProvider.getContextualReference(ClientWindow.class, true);
-
-            this.initialized = true;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d778adae/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DeltaSpikePartialViewContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DeltaSpikePartialViewContext.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DeltaSpikePartialViewContext.java
deleted file mode 100644
index 8fc04aa..0000000
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DeltaSpikePartialViewContext.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.navigation;
-
-import javax.faces.context.PartialResponseWriter;
-import javax.faces.context.PartialViewContext;
-import javax.faces.context.PartialViewContextWrapper;
-
-public class DeltaSpikePartialViewContext extends PartialViewContextWrapper
-{
-    private final PartialViewContext wrapped;
-    private PartialResponseWriter writer = null;
-
-    public DeltaSpikePartialViewContext(PartialViewContext wrapped)
-    {
-        this.wrapped = wrapped;
-    }
-
-    @Override
-    public PartialResponseWriter getPartialResponseWriter()
-    {
-        if (writer == null)
-        {
-            PartialResponseWriter parentWriter = getWrapped().getPartialResponseWriter();
-            writer = new DeltaSpikePartialResponseWriter(parentWriter);
-        }
-
-        return writer;
-    }
-
-    
-    @Override
-    public PartialViewContext getWrapped()
-    {
-        return this.wrapped;
-    }
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d778adae/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/AbstractClientWindowStrategy.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/AbstractClientWindowStrategy.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/AbstractClientWindowStrategy.java
index 97aca91..111f85b 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/AbstractClientWindowStrategy.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/AbstractClientWindowStrategy.java
@@ -104,6 +104,11 @@ public abstract class AbstractClientWindowStrategy implements ClientWindow
         return "" + (new Random()).nextInt() % 10000;
     }
 
+    protected String generateNewRequestToken()
+    {
+        return "" + ((int) Math.floor(Math.random() * 999));
+    }
+    
     protected boolean isPost(FacesContext facesContext)
     {
         if (facesContext.isPostback())
@@ -214,6 +219,6 @@ public abstract class AbstractClientWindowStrategy implements ClientWindow
     @Override
     public String interceptRedirect(FacesContext facesContext, String url)
     {
-        return url;
+        return ClientWindowHelper.appendWindowId(facesContext, url, this);
     }
 }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d778adae/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/ClientSideWindowStrategy.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/ClientSideWindowStrategy.java
b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/ClientSideWindowStrategy.java
index 3b48e2a..1ca586b 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/ClientSideWindowStrategy.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/scope/window/strategy/ClientSideWindowStrategy.java
@@ -196,13 +196,13 @@ public class ClientSideWindowStrategy extends AbstractClientWindowStrategy
 
         return "";
     }
-    
+
     @Override
     public String interceptRedirect(FacesContext facesContext, String url)
     {
         if (facesContext.getPartialViewContext().isAjaxRequest())
         {
-            String requestToken = newRequestToken();
+            String requestToken = generateNewRequestToken();
             String windowId = getWindowId(facesContext);
             
             ClientWindowHelper.addRequestWindowIdCookie(facesContext,
@@ -225,9 +225,4 @@ public class ClientSideWindowStrategy extends AbstractClientWindowStrategy
         
         return url;
     }
-    
-    protected String newRequestToken()
-    {
-        return "" + ((int) Math.floor(Math.random() * 999));
-    }
 }


Mime
View raw message