myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r1051870 - in /myfaces/extensions/cdi/trunk: core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ jee-modules/jsf-module/...
Date Wed, 22 Dec 2010 12:23:52 GMT
Author: gpetracek
Date: Wed Dec 22 12:23:52 2010
New Revision: 1051870

URL: http://svn.apache.org/viewvc?rev=1051870&view=rev
Log:
EXTCDI-89 cleanup

Modified:
    myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/SecurityUtils.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigDefinitionEntry.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigEntry.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/spi/ViewConfigEntry.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/security/SecurityInterceptor.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/ViewConfigTest.java

Modified: myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/SecurityUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/SecurityUtils.java?rev=1051870&r1=1051869&r2=1051870&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/SecurityUtils.java
(original)
+++ myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/SecurityUtils.java
Wed Dec 22 12:23:52 2010
@@ -26,6 +26,7 @@ import static org.apache.myfaces.extensi
 
 import javax.interceptor.InvocationContext;
 import javax.enterprise.inject.spi.BeanManager;
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -35,7 +36,7 @@ public class SecurityUtils
 {
     public static void invokeVoters(InvocationContext invocationContext,
                                     BeanManager beanManager,
-                                    Class<? extends AccessDecisionVoter>[] accessDecisionVoters,
+                                    List<Class<? extends AccessDecisionVoter>>
accessDecisionVoters,
                                     Class<? extends ViewConfig> errorView)
     {
         if(accessDecisionVoters == null)

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigDefinitionEntry.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigDefinitionEntry.java?rev=1051870&r1=1051869&r2=1051870&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigDefinitionEntry.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigDefinitionEntry.java
Wed Dec 22 12:23:52 2010
@@ -258,10 +258,9 @@ class DefaultViewConfigDefinitionEntry i
         return result.substring(0, result.length() - 1);
     }
 
-    public Class<? extends AccessDecisionVoter>[] getAccessDecisionVoters()
+    public List<Class<? extends AccessDecisionVoter>> getAccessDecisionVoters()
     {
-        //noinspection unchecked
-        return this.foundVoters.toArray(new Class[this.foundVoters.size()]);
+        return Collections.unmodifiableList(this.foundVoters);
     }
 
     public void addPageBean(Class pageBeanClass)

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigEntry.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigEntry.java?rev=1051870&r1=1051869&r2=1051870&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigEntry.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigEntry.java
Wed Dec 22 12:23:52 2010
@@ -50,7 +50,7 @@ public class DefaultViewConfigEntry impl
     private List<PageBeanConfigEntry> beanDefinition;
 
     //security
-    private final Class<? extends AccessDecisionVoter>[] accessDecisionVoters;
+    private final List<Class<? extends AccessDecisionVoter>> accessDecisionVoters;
     private final Class<? extends ViewConfig> customErrorView;
 
     private Page.ViewParameter viewParameter;
@@ -65,7 +65,7 @@ public class DefaultViewConfigEntry impl
                            Class<? extends ViewConfig> viewDefinitionClass,
                            Page.NavigationMode navigationMode,
                            Page.ViewParameter viewParameter,
-                           Class<? extends AccessDecisionVoter>[] accessDecisionVoters,
+                           List<Class<? extends AccessDecisionVoter>> accessDecisionVoters,
                            Class<? extends ViewConfig> errorView,
                            List<Annotation> metaDataList)
     {
@@ -182,9 +182,9 @@ public class DefaultViewConfigEntry impl
         }
     }
 
-    public Class<? extends AccessDecisionVoter>[] getAccessDecisionVoters()
+    public List<Class<? extends AccessDecisionVoter>> getAccessDecisionVoters()
     {
-        return accessDecisionVoters;
+        return Collections.unmodifiableList(this.accessDecisionVoters);
     }
 
     public Class<? extends ViewConfig> getErrorView()

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/spi/ViewConfigEntry.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/spi/ViewConfigEntry.java?rev=1051870&r1=1051869&r2=1051870&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/spi/ViewConfigEntry.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/spi/ViewConfigEntry.java
Wed Dec 22 12:23:52 2010
@@ -42,7 +42,7 @@ public interface ViewConfigEntry
 
     List<Annotation> getMetaData();
 
-    Class<? extends AccessDecisionVoter>[] getAccessDecisionVoters();
+    List<Class<? extends AccessDecisionVoter>> getAccessDecisionVoters();
 
     void addPageBean(Class pageBeanClass);
 

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/security/SecurityInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/security/SecurityInterceptor.java?rev=1051870&r1=1051869&r2=1051870&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/security/SecurityInterceptor.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/security/SecurityInterceptor.java
Wed Dec 22 12:23:52 2010
@@ -29,6 +29,7 @@ import javax.inject.Inject;
 import javax.enterprise.inject.spi.BeanManager;
 import java.lang.reflect.Method;
 import java.io.Serializable;
+import java.util.Arrays;
 
 /**
  * @author Gerhard Petracek
@@ -53,7 +54,7 @@ public class SecurityInterceptor impleme
 
         Class<? extends AccessDecisionVoter>[] voterClasses = secured.value();
 
-        invokeVoters(invocationContext, this.beanManager, voterClasses, secured.errorView());
+        invokeVoters(invocationContext, this.beanManager, Arrays.asList(voterClasses), secured.errorView());
 
         return invocationContext.proceed();
     }

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/ViewConfigTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/ViewConfigTest.java?rev=1051870&r1=1051869&r2=1051870&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/ViewConfigTest.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/jsf/test/impl/config/view/ViewConfigTest.java
Wed Dec 22 12:23:52 2010
@@ -18,6 +18,7 @@
  */
 package org.apache.myfaces.extensions.cdi.jsf.test.impl.config.view;
 
+import org.apache.myfaces.extensions.cdi.core.api.security.AccessDecisionVoter;
 import org.apache.myfaces.extensions.cdi.jsf.api.config.view.Page;
 import org.apache.myfaces.extensions.cdi.jsf.impl.config.view.spi.PageBeanConfigEntry;
 import org.apache.myfaces.extensions.cdi.jsf.impl.config.view.spi.ViewConfigEntry;
@@ -138,9 +139,9 @@ public class ViewConfigTest
         assertEquals(registrationConfigEntry.getNavigationMode(), Page.NavigationMode.DEFAULT);
         assertEquals(orderConfigEntry.getNavigationMode(), Page.NavigationMode.REDIRECT);
 
-        assertTrue(registrationConfigEntry.getAccessDecisionVoters().length == 0);
-        assertEquals(orderConfigEntry.getAccessDecisionVoters().length, 1);
-        assertEquals(orderConfigEntry.getAccessDecisionVoters()[0], TestAccessDecisionVoter1.class);
+        assertTrue(registrationConfigEntry.getAccessDecisionVoters().size() == 0);
+        assertEquals(orderConfigEntry.getAccessDecisionVoters().size(), 1);
+        assertEquals(orderConfigEntry.getAccessDecisionVoters().iterator().next(), TestAccessDecisionVoter1.class);
     }
 
     @Test
@@ -190,13 +191,25 @@ public class ViewConfigTest
         ViewConfigEntry viewConfigEntry = ViewConfigCache.getViewDefinition(
                 ViewConfigWithAccessDecisionVoters.Page1.class);
 
-        assertEquals(viewConfigEntry.getAccessDecisionVoters().length, 1);
+        assertEquals(viewConfigEntry.getAccessDecisionVoters().size(), 1);
 
         viewConfigEntry = ViewConfigCache.getViewDefinition(ViewConfigWithAccessDecisionVoters.Page2.class);
 
-        assertEquals(viewConfigEntry.getAccessDecisionVoters().length, 2);
-        assertTrue(viewConfigEntry.getAccessDecisionVoters()[0].equals(TestAccessDecisionVoter2.class));
-        assertTrue(viewConfigEntry.getAccessDecisionVoters()[1].equals(TestAccessDecisionVoter1.class));
+        assertEquals(viewConfigEntry.getAccessDecisionVoters().size(), 2);
+
+        boolean voter2 = false;
+        for(Class<? extends AccessDecisionVoter> accessDecisionVoter : viewConfigEntry.getAccessDecisionVoters())
+        {
+            if(!voter2)
+            {
+                assertTrue(accessDecisionVoter.equals(TestAccessDecisionVoter2.class));
+                voter2 = true;
+            }
+            else
+            {
+                assertTrue(accessDecisionVoter.equals(TestAccessDecisionVoter1.class));
+            }
+        }
     }
 
     @Test



Mime
View raw message