myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdebussc...@apache.org
Subject svn commit: r1077844 - in /myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core: factory/ mapper/ metadata/transformer/ metadata/transformer/mapper/
Date Fri, 04 Mar 2011 08:15:57 GMT
Author: rdebusscher
Date: Fri Mar  4 08:15:56 2011
New Revision: 1077844

URL: http://svn.apache.org/viewvc?rev=1077844&view=rev
Log:
EXTVAL-128

Modified:
    myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/AbstractNameMapperAwareFactory.java
    myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/mapper/SubMapperAwareNameMapper.java
    myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/transformer/DefaultMetaDataTransformerFactory.java
    myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/transformer/mapper/ValidationStrategyToMetaDataTransformerSubMapperAwareNameMapper.java

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/AbstractNameMapperAwareFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/AbstractNameMapperAwareFactory.java?rev=1077844&r1=1077843&r2=1077844&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/AbstractNameMapperAwareFactory.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/AbstractNameMapperAwareFactory.java
Fri Mar  4 08:15:56 2011
@@ -18,6 +18,8 @@
  */
 package org.apache.myfaces.extensions.validator.core.factory;
 
+import org.apache.myfaces.extensions.validator.core.Nested;
+import org.apache.myfaces.extensions.validator.core.mapper.SubMapperAwareNameMapper;
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
 import org.apache.myfaces.extensions.validator.core.mapper.NameMapper;
@@ -70,14 +72,32 @@ public abstract class AbstractNameMapper
 
     public synchronized void deregister(Class<? extends NameMapper> classToDeregister)
     {
+        boolean subNameMapper = false;
+
+        if (classToDeregister != null && classToDeregister.isAnnotationPresent(Nested.class))
+        {
+            subNameMapper = true;
+        }
+
         Iterator<NameMapper<T>> nameMapperIterator = getNameMapperList().iterator();
-        while(nameMapperIterator.hasNext())
+
+        while (nameMapperIterator.hasNext())
         {
-            if(nameMapperIterator.next().getClass().getName().equals(classToDeregister.getName()))
+            if (subNameMapper)
+            {
+                NameMapper<T> nameMapper = nameMapperIterator.next();
+                if (nameMapper instanceof SubMapperAwareNameMapper)
+                {
+                    ((SubMapperAwareNameMapper) nameMapper).removeNameMapper(classToDeregister);
+                }
+            } else
             {
-                nameMapperIterator.remove();
-                //don't break - e.g. to deregister all wrappers...
-                //break;
+                if (nameMapperIterator.next().getClass().getName().equals(classToDeregister.getName()))
+                {
+                    nameMapperIterator.remove();
+                    //don't break - e.g. to deregister all wrappers...
+                    //break;
+                }
             }
         }
     }

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/mapper/SubMapperAwareNameMapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/mapper/SubMapperAwareNameMapper.java?rev=1077844&r1=1077843&r2=1077844&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/mapper/SubMapperAwareNameMapper.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/mapper/SubMapperAwareNameMapper.java
Fri Mar  4 08:15:56 2011
@@ -35,4 +35,10 @@ public interface SubMapperAwareNameMappe
      * @param nameMapper sub-nameMapper to add
      */
     void addNameMapper(NameMapper<T> nameMapper);
+
+    /**
+     * Deregisters all (sub-)name mappers of the given type
+     * @param nameMapperClass type of the (sub-)name mappers which have to be deregistered
+     */
+    void removeNameMapper(Class<? extends NameMapper> nameMapperClass);
 }
\ No newline at end of file

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/transformer/DefaultMetaDataTransformerFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/transformer/DefaultMetaDataTransformerFactory.java?rev=1077844&r1=1077843&r2=1077844&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/transformer/DefaultMetaDataTransformerFactory.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/transformer/DefaultMetaDataTransformerFactory.java
Fri Mar  4 08:15:56 2011
@@ -38,6 +38,7 @@ import org.apache.myfaces.extensions.val
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.CopyOnWriteArrayList;
@@ -232,6 +233,22 @@ public class DefaultMetaDataTransformerF
         super.register(validationStrategyNameMapper);
     }
 
+    @Override
+    public void deregister(Class<? extends NameMapper> classToDeregister)
+    {
+        super.deregister(classToDeregister);
+        for (NameMapper<ValidationStrategy> nameMapper
+                : new ArrayList<NameMapper<ValidationStrategy>>(subNameMapperList))
+        {
+
+            if (nameMapper.getClass().equals(classToDeregister))
+            {
+                subNameMapperList.remove(nameMapper);
+            }
+        }
+
+    }
+
     /**
      * it's a very special case due to the missing order in the execution of startup-listeners
(phase listeners)
      * packaged in faces-config.xml files of jars
@@ -257,4 +274,11 @@ public class DefaultMetaDataTransformerF
             }
         }
     }
+
+    //just for testing
+    protected List<NameMapper<ValidationStrategy>> getSubNameMapperList()
+    {
+        return this.subNameMapperList;
+    }
 }
+

Modified: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/transformer/mapper/ValidationStrategyToMetaDataTransformerSubMapperAwareNameMapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/transformer/mapper/ValidationStrategyToMetaDataTransformerSubMapperAwareNameMapper.java?rev=1077844&r1=1077843&r2=1077844&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/transformer/mapper/ValidationStrategyToMetaDataTransformerSubMapperAwareNameMapper.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/transformer/mapper/ValidationStrategyToMetaDataTransformerSubMapperAwareNameMapper.java
Fri Mar  4 08:15:56 2011
@@ -54,6 +54,28 @@ public class ValidationStrategyToMetaDat
         }
     }
 
+    public void removeNameMapper(Class<? extends NameMapper> nameMapperClass)
+    {
+        List<NameMapper<ValidationStrategy>> nameMappersToRemove =
+                new ArrayList<NameMapper<ValidationStrategy>>(this.subNameMappers.size());
+
+        for(NameMapper<ValidationStrategy> currentSubNameMapper : this.subNameMappers)
+        {
+            if(currentSubNameMapper.getClass().getName().equals(nameMapperClass.getName()))
+            {
+                nameMappersToRemove.add(currentSubNameMapper);
+                //don't break - e.g. to deregister all wrappers...
+                //break;
+            }
+        }
+
+        //do it manually due to the CopyOnWriteArrayList
+        for(NameMapper<ValidationStrategy> currentSubNameMapper : nameMappersToRemove)
+        {
+            this.subNameMappers.remove(currentSubNameMapper);
+        }
+    }
+
     private void sortSubNameMappers()
     {
         List<NameMapper<ValidationStrategy>> sortableList =



Mime
View raw message