You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by gp...@apache.org on 2013/02/15 22:04:33 UTC

[2/7] git commit: DELTASPIKE-288 org.apache.deltaspike.jsf.api.navigation.PageParameterContext -> NavigationParameterContext

DELTASPIKE-288 org.apache.deltaspike.jsf.api.navigation.PageParameterContext -> NavigationParameterContext


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

Branch: refs/heads/master
Commit: 3255ce40be4027d94026757d60b2dcfc1f015ae2
Parents: f97031f
Author: gpetracek <gp...@apache.org>
Authored: Fri Feb 15 20:44:27 2013 +0100
Committer: gpetracek <gp...@apache.org>
Committed: Fri Feb 15 20:44:27 2013 +0100

----------------------------------------------------------------------
 .../jsf/api/config/view/NavigationParameter.java   |    2 +-
 .../api/navigation/NavigationParameterContext.java |   31 +++++++
 .../jsf/api/navigation/PageParameterContext.java   |   31 -------
 .../DefaultNavigationParameterContext.java         |   66 +++++++++++++++
 .../navigation/DefaultPageParameterContext.java    |   66 ---------------
 .../ViewConfigAwareNavigationHandler.java          |   12 ++--
 .../apache/deltaspike/jsf/impl/util/JsfUtils.java  |    7 +-
 .../navigation/parameter/uc004/PageBean004.java    |    6 +-
 8 files changed, 111 insertions(+), 110 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3255ce40/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/config/view/NavigationParameter.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/config/view/NavigationParameter.java b/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/config/view/NavigationParameter.java
index 1f0da13..65e1faa 100644
--- a/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/config/view/NavigationParameter.java
+++ b/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/config/view/NavigationParameter.java
@@ -32,7 +32,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
 /**
  * This annotation can be used as interceptor for JSF action methods as an alternative for
- * {@link org.apache.deltaspike.jsf.api.navigation.PageParameterContext}.
+ * {@link org.apache.deltaspike.jsf.api.navigation.NavigationParameterContext}.
  */
 @Target({ METHOD, TYPE })
 @Retention(RUNTIME)

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3255ce40/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/navigation/NavigationParameterContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/navigation/NavigationParameterContext.java b/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/navigation/NavigationParameterContext.java
new file mode 100644
index 0000000..98ce8b5
--- /dev/null
+++ b/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/navigation/NavigationParameterContext.java
@@ -0,0 +1,31 @@
+/*
+ * 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.api.navigation;
+
+import java.util.Map;
+
+/**
+ * Can be used to add parameters dynamically to the final navigation string
+ */
+public interface NavigationParameterContext
+{
+    void addPageParameter(String key, Object value);
+
+    Map<String, String> getPageParameters();
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3255ce40/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/navigation/PageParameterContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/navigation/PageParameterContext.java b/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/navigation/PageParameterContext.java
deleted file mode 100644
index 75f0f3c..0000000
--- a/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/navigation/PageParameterContext.java
+++ /dev/null
@@ -1,31 +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.api.navigation;
-
-import java.util.Map;
-
-/**
- * Can be used to add parameters dynamically to the final navigation string
- */
-public interface PageParameterContext
-{
-    void addPageParameter(String key, Object value);
-
-    Map<String, String> getPageParameters();
-}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3255ce40/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DefaultNavigationParameterContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DefaultNavigationParameterContext.java b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DefaultNavigationParameterContext.java
new file mode 100644
index 0000000..050a826
--- /dev/null
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DefaultNavigationParameterContext.java
@@ -0,0 +1,66 @@
+/*
+ * 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 org.apache.deltaspike.jsf.api.navigation.NavigationParameterContext;
+import org.apache.deltaspike.jsf.impl.util.JsfUtils;
+
+import javax.enterprise.context.RequestScoped;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Request scoped storage for page-parameters.
+ * Can be used to add parameters dynamically to the final navigation string
+ */
+@RequestScoped
+public class DefaultNavigationParameterContext implements NavigationParameterContext
+{
+    private Map<String, String> parameters = new HashMap<String, String>();
+
+    protected DefaultNavigationParameterContext()
+    {
+    }
+
+    public Map<String, String> getPageParameters()
+    {
+        return Collections.unmodifiableMap(this.parameters);
+    }
+
+    public void addPageParameter(String key, Object param)
+    {
+        if (param == null)
+        {
+            this.parameters.remove(key);
+            return;
+        }
+
+        String value = param.toString().trim();
+
+        if (value.startsWith("#{") && value.endsWith("}"))
+        {
+            value = JsfUtils.getValueOfExpressionAsString(value);
+        }
+
+        //simple version - we could add multi-ref support, if we really need it
+        //but this method might be called multiple times for the same parameter/s
+        this.parameters.put(key, value);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3255ce40/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DefaultPageParameterContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DefaultPageParameterContext.java b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DefaultPageParameterContext.java
deleted file mode 100644
index fee02bf..0000000
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/DefaultPageParameterContext.java
+++ /dev/null
@@ -1,66 +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 org.apache.deltaspike.jsf.api.navigation.PageParameterContext;
-import org.apache.deltaspike.jsf.impl.util.JsfUtils;
-
-import javax.enterprise.context.RequestScoped;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Request scoped storage for page-parameters.
- * Can be used to add parameters dynamically to the final navigation string
- */
-@RequestScoped
-public class DefaultPageParameterContext implements PageParameterContext
-{
-    private Map<String, String> parameters = new HashMap<String, String>();
-
-    protected DefaultPageParameterContext()
-    {
-    }
-
-    public Map<String, String> getPageParameters()
-    {
-        return Collections.unmodifiableMap(this.parameters);
-    }
-
-    public void addPageParameter(String key, Object param)
-    {
-        if (param == null)
-        {
-            this.parameters.remove(key);
-            return;
-        }
-
-        String value = param.toString().trim();
-
-        if (value.startsWith("#{") && value.endsWith("}"))
-        {
-            value = JsfUtils.getValueOfExpressionAsString(value);
-        }
-
-        //simple version - we could add multi-ref support, if we really need it
-        //but this method might be called multiple times for the same parameter/s
-        this.parameters.put(key, value);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3255ce40/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/ViewConfigAwareNavigationHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/ViewConfigAwareNavigationHandler.java b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/ViewConfigAwareNavigationHandler.java
index 119e99f..afc8a89 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/ViewConfigAwareNavigationHandler.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/navigation/ViewConfigAwareNavigationHandler.java
@@ -28,7 +28,7 @@ import org.apache.deltaspike.core.util.ClassUtils;
 import org.apache.deltaspike.jsf.api.config.view.NavigationParameter;
 import org.apache.deltaspike.jsf.api.config.view.Page;
 import org.apache.deltaspike.jsf.api.config.view.event.PreViewConfigNavigateEvent;
-import org.apache.deltaspike.jsf.api.navigation.PageParameterContext;
+import org.apache.deltaspike.jsf.api.navigation.NavigationParameterContext;
 import org.apache.deltaspike.jsf.impl.util.JsfUtils;
 
 import javax.enterprise.inject.spi.BeanManager;
@@ -49,7 +49,7 @@ class ViewConfigAwareNavigationHandler extends NavigationHandler
 
     private BeanManager beanManager;
 
-    private PageParameterContext pageParameterContext;
+    private NavigationParameterContext navigationParameterContext;
 
     /**
      * Constructor which allows to use the given {@link NavigationHandler}
@@ -144,7 +144,7 @@ class ViewConfigAwareNavigationHandler extends NavigationHandler
 
     private void addConfiguredViewParameters(Class<?> viewConfigClass)
     {
-        if (this.pageParameterContext != null)
+        if (this.navigationParameterContext != null)
         {
             NavigationParameter navigationParameter = viewConfigClass.getAnnotation(NavigationParameter.class);
 
@@ -170,7 +170,7 @@ class ViewConfigAwareNavigationHandler extends NavigationHandler
 
     private void addConfiguredPageParameter(NavigationParameter viewParameter)
     {
-        this.pageParameterContext.addPageParameter(viewParameter.key(), viewParameter.value());
+        this.navigationParameterContext.addPageParameter(viewParameter.key(), viewParameter.value());
     }
 
     private String convertEntryToOutcome(ExternalContext externalContext, ViewConfigDescriptor entry)
@@ -248,8 +248,8 @@ class ViewConfigAwareNavigationHandler extends NavigationHandler
         if (this.beanManager == null)
         {
             this.beanManager = BeanManagerProvider.getInstance().getBeanManager();
-            this.pageParameterContext =
-                    BeanProvider.getContextualReference(PageParameterContext.class);
+            this.navigationParameterContext =
+                    BeanProvider.getContextualReference(NavigationParameterContext.class);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3255ce40/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/JsfUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/JsfUtils.java b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/JsfUtils.java
index 05a2abb..26fa481 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/JsfUtils.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/util/JsfUtils.java
@@ -20,7 +20,7 @@ package org.apache.deltaspike.jsf.impl.util;
 
 import org.apache.deltaspike.core.api.config.view.metadata.ViewConfigResolver;
 import org.apache.deltaspike.core.api.provider.BeanProvider;
-import org.apache.deltaspike.jsf.api.navigation.PageParameterContext;
+import org.apache.deltaspike.jsf.api.navigation.NavigationParameterContext;
 
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
@@ -57,9 +57,10 @@ public abstract class JsfUtils
             return result;
         }
 
-        PageParameterContext pageParameterContext = BeanProvider.getContextualReference(PageParameterContext.class);
+        NavigationParameterContext navigationParameterContext =
+                BeanProvider.getContextualReference(NavigationParameterContext.class);
 
-        for (Map.Entry<String, String> entry : pageParameterContext.getPageParameters().entrySet())
+        for (Map.Entry<String, String> entry : navigationParameterContext.getPageParameters().entrySet())
         {
             //TODO add multi-value support
             result.add(new RequestParameter(entry.getKey(), new String[]{entry.getValue()}));

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/3255ce40/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc004/PageBean004.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc004/PageBean004.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc004/PageBean004.java
index 0cd48c1..34a1476 100644
--- a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc004/PageBean004.java
+++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/navigation/parameter/uc004/PageBean004.java
@@ -19,7 +19,7 @@
 package org.apache.deltaspike.test.jsf.impl.config.view.navigation.parameter.uc004;
 
 import org.apache.deltaspike.core.api.config.view.ViewConfig;
-import org.apache.deltaspike.jsf.api.navigation.PageParameterContext;
+import org.apache.deltaspike.jsf.api.navigation.NavigationParameterContext;
 
 import javax.enterprise.context.SessionScoped;
 import javax.inject.Inject;
@@ -32,7 +32,7 @@ public class PageBean004
     private int currentValue = -100;
 
     @Inject
-    private PageParameterContext pageParameterContext;
+    private NavigationParameterContext navigationParameterContext;
 
     //TODO add test
 
@@ -42,7 +42,7 @@ public class PageBean004
 
         if (currentValue >= 0)
         {
-            this.pageParameterContext.addPageParameter("cv", this.currentValue++);
+            this.navigationParameterContext.addPageParameter("cv", this.currentValue++);
         }
         return SimplePageConfig.class;
     }