myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r920516 - in /myfaces/extensions/validator/branches/branch_for_jsf_1_1: core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/ core/src/main/java/org/apache/myfaces/extensions/validator/util/ validation-modules/bean-valida...
Date Mon, 08 Mar 2010 21:18:36 GMT
Author: gpetracek
Date: Mon Mar  8 21:18:35 2010
New Revision: 920516

URL: http://svn.apache.org/viewvc?rev=920516&view=rev
Log:
[review-result] minor improvements

Modified:
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMetaDataStorage.java
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultPropertyStorage.java
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/core/src/main/java/org/apache/myfaces/extensions/validator/util/ClassUtils.java
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleValidationInterceptorInternals.java
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/ModelValidationPhaseListener.java
    myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationPhaseListener.java

Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMetaDataStorage.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMetaDataStorage.java?rev=920516&r1=920515&r2=920516&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMetaDataStorage.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMetaDataStorage.java
Mon Mar  8 21:18:35 2010
@@ -48,7 +48,8 @@
 {
     protected final Log logger = LogFactory.getLog(getClass());
 
-    private Map<String, PropertyInformation> cachedPropertyInformation = new HashMap<String,
PropertyInformation>();
+    private Map<String, Map<String, PropertyInformation>> cachedPropertyInformation
=
+            new HashMap<String, Map<String, PropertyInformation>>();
 
     private List<MetaDataStorageFilter> metaDataStorageFilters = new ArrayList<MetaDataStorageFilter>();
     private List<Class<? extends MetaDataStorageFilter>> deniedMetaDataFilters
=
@@ -95,9 +96,8 @@
 
         copyMetaData(propertyInformation, propertyInformationToStore);
 
-        this.cachedPropertyInformation.put(
-                createKey(propertyDetails.getBaseObject().getClass(), propertyDetails.getProperty()),
-                propertyInformationToStore);
+        getMapForClass(propertyDetails.getBaseObject().getClass())
+                .put(propertyDetails.getProperty(), propertyInformationToStore);
     }
 
     private void invokeFilters(PropertyInformation propertyInformation)
@@ -110,8 +110,7 @@
 
     public MetaDataEntry[] getMetaData(Class targetClass, String targetProperty)
     {
-        PropertyInformation propertyInformation = this.cachedPropertyInformation
-                .get(createKey(targetClass, targetProperty));
+        PropertyInformation propertyInformation = getMapForClass(targetClass).get(targetProperty);
 
         PropertyInformation clonedPropertyInformation = new DefaultPropertyInformation();
         copyMetaData(propertyInformation, clonedPropertyInformation);
@@ -121,7 +120,7 @@
 
     public boolean containsMetaDataFor(Class targetClass, String targetProperty)
     {
-        return this.cachedPropertyInformation.containsKey(createKey(targetClass, targetProperty));
+        return getMapForClass(targetClass).containsKey(targetProperty);
     }
 
     public void registerFilter(MetaDataStorageFilter storageFilter)
@@ -182,22 +181,6 @@
         deregisterFilter(filterClass);
     }
 
-    private String createKey(Class targetClass, String targetProperty)
-    {
-        String targetClassName = getTargetClassName(targetClass);
-        return targetClassName + "#" + targetProperty;
-    }
-
-    private String getTargetClassName(Class currentClass)
-    {
-        if (currentClass.getName().contains("$$EnhancerByCGLIB$$")
-            || currentClass.getName().contains("$$FastClassByCGLIB$$"))
-        {
-            return currentClass.getName().substring(0, currentClass.getName().indexOf("$"));
-        }
-        return currentClass.getName();
-    }
-
     @ToDo(Priority.MEDIUM)
     private void copyMetaData(PropertyInformation source, PropertyInformation target)
     {
@@ -227,4 +210,14 @@
             this.logger.info(filterClass.getName() + " removed");
         }
     }
+
+    private Map<String, PropertyInformation> getMapForClass(Class target)
+    {
+        String key = ClassUtils.getClassName(target);
+        if(!this.cachedPropertyInformation.containsKey(key))
+        {
+            this.cachedPropertyInformation.put(key, new HashMap<String, PropertyInformation>());
+        }
+        return this.cachedPropertyInformation.get(key);
+    }
 }

Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultPropertyStorage.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultPropertyStorage.java?rev=920516&r1=920515&r2=920516&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultPropertyStorage.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultPropertyStorage.java
Mon Mar  8 21:18:35 2010
@@ -18,15 +18,16 @@
  */
 package org.apache.myfaces.extensions.validator.core.storage;
 
-import static org.apache.myfaces.extensions.validator.internal.UsageCategory.INTERNAL;
-import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import static org.apache.myfaces.extensions.validator.internal.UsageCategory.INTERNAL;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.util.ClassUtils;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
-import java.util.Map;
 import java.util.HashMap;
+import java.util.Map;
 
 /**
  * @author Gerhard Petracek
@@ -37,41 +38,56 @@
 {
     protected final Log logger = LogFactory.getLog(getClass());
 
-    private Map<String, Field> fieldMap = new HashMap<String, Field>();
-    private Map<String, Method> methodMap = new HashMap<String, Method>();
+    private Map<String, Map<String, Field>> fieldMap = new HashMap<String,
Map<String, Field>>();
+    private Map<String, Map<String, Method>> methodMap = new HashMap<String,
Map<String, Method>>();
 
     public void storeField(Class targetClass, String property, Field field)
     {
-        this.fieldMap.put(createKey(targetClass, property), field);
+        getFieldMapForClass(targetClass).put(property, field);
     }
 
     public void storeMethod(Class targetClass, String property, Method method)
     {
-        this.methodMap.put(createKey(targetClass, property), method);
+        getMethodMapForClass(targetClass).put(property,  method);
     }
 
     public Field getField(Class targetClass, String property)
     {
-        return this.fieldMap.get(createKey(targetClass, property));
+        return getFieldMapForClass(targetClass).get(property);
     }
 
     public Method getMethod(Class targetClass, String property)
     {
-        return this.methodMap.get(createKey(targetClass, property));
+        return getMethodMapForClass(targetClass).get(property);
     }
 
     public boolean containsField(Class targetClass, String property)
     {
-        return this.fieldMap.containsKey(createKey(targetClass, property));
+        return getFieldMapForClass(targetClass).containsKey(property);
     }
 
     public boolean containsMethod(Class targetClass, String property)
     {
-        return this.methodMap.containsKey(createKey(targetClass, property));
+        return getMethodMapForClass(targetClass).containsKey(property);
+    }
+
+    private Map<String, Field> getFieldMapForClass(Class target)
+    {
+        String key = ClassUtils.getClassName(target);
+        if (!this.fieldMap.containsKey(key))
+        {
+            this.fieldMap.put(key, new HashMap<String, Field>());
+        }
+        return this.fieldMap.get(key);
     }
 
-    private String createKey(Class targetClass, String property)
+    private Map<String, Method> getMethodMapForClass(Class target)
     {
-        return targetClass + "#" + property;
+        String key = ClassUtils.getClassName(target);
+        if (!this.methodMap.containsKey(key))
+        {
+            this.methodMap.put(key, new HashMap<String, Method>());
+        }
+        return this.methodMap.get(key);
     }
-}
+}
\ No newline at end of file

Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/core/src/main/java/org/apache/myfaces/extensions/validator/util/ClassUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/core/src/main/java/org/apache/myfaces/extensions/validator/util/ClassUtils.java?rev=920516&r1=920515&r2=920516&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/core/src/main/java/org/apache/myfaces/extensions/validator/util/ClassUtils.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/core/src/main/java/org/apache/myfaces/extensions/validator/util/ClassUtils.java
Mon Mar  8 21:18:35 2010
@@ -120,4 +120,19 @@
             return null;
         }
     }
+
+    public static String getClassName(Class currentClass)
+    {
+        if (isProxiedClass(currentClass))
+        {
+            return currentClass.getName().substring(0, currentClass.getName().indexOf("$"));
+        }
+        return currentClass.getName();
+    }
+
+    public static boolean isProxiedClass(Class currentClass)
+    {
+        return currentClass.getName().contains("$$EnhancerByCGLIB$$")
+            || currentClass.getName().contains("$$FastClassByCGLIB$$");
+    }
 }

Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleValidationInterceptorInternals.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleValidationInterceptorInternals.java?rev=920516&r1=920515&r2=920516&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleValidationInterceptorInternals.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/BeanValidationModuleValidationInterceptorInternals.java
Mon Mar  8 21:18:35 2010
@@ -31,6 +31,7 @@
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+import org.apache.myfaces.extensions.validator.util.ClassUtils;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
@@ -220,7 +221,13 @@
 
     Class getBaseClassType(PropertyInformation propertyInformation)
     {
-        return ExtValUtils.getPropertyDetails(propertyInformation).getBaseObject().getClass();
+        Class result = ExtValUtils.getPropertyDetails(propertyInformation).getBaseObject().getClass();
+
+        if(ClassUtils.isProxiedClass(result))
+        {
+            result = ClassUtils.tryToLoadClassForName(ClassUtils.getClassName(result));
+        }
+        return result;
     }
 
     String getPropertyToValidate(PropertyInformation propertyInformation)

Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java?rev=920516&r1=920515&r2=920516&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
Mon Mar  8 21:18:35 2010
@@ -35,6 +35,7 @@
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 import org.apache.myfaces.extensions.validator.util.ExtValUtils;
 import org.apache.myfaces.extensions.validator.util.ReflectionUtils;
+import org.apache.myfaces.extensions.validator.util.ClassUtils;
 
 import javax.faces.application.FacesMessage;
 import javax.faces.component.UIComponent;
@@ -201,6 +202,12 @@
                               boolean processModelValidation)
     {
         Class classToInspect = objectToInspect.getClass();
+
+        if(ClassUtils.isProxiedClass(classToInspect))
+        {
+            classToInspect = ClassUtils.tryToLoadClassForName(ClassUtils.getClassName(classToInspect));
+        }
+
         while (!Object.class.getName().equals(classToInspect.getName()))
         {
             transferGroupValidationInformationToFoundGroups(objectToInspect,

Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/ModelValidationPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/ModelValidationPhaseListener.java?rev=920516&r1=920515&r2=920516&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/ModelValidationPhaseListener.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/validation/ModelValidationPhaseListener.java
Mon Mar  8 21:18:35 2010
@@ -452,4 +452,28 @@
     {
         return PhaseId.UPDATE_MODEL_VALUES;
     }
+
+    /*
+     * generated
+     */
+    @Override
+    public boolean equals(Object o)
+    {
+        if (this == o)
+        {
+            return true;
+        }
+        if (!(o instanceof ModelValidationPhaseListener))
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return super.hashCode();
+    }
 }

Modified: myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationPhaseListener.java?rev=920516&r1=920515&r2=920516&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationPhaseListener.java
(original)
+++ myfaces/extensions/validator/branches/branch_for_jsf_1_1/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationPhaseListener.java
Mon Mar  8 21:18:35 2010
@@ -165,4 +165,25 @@
     {
         return PhaseId.ANY_PHASE;
     }
+
+    @Override
+    public boolean equals(Object o)
+    {
+        if (this == o)
+        {
+            return true;
+        }
+        if (!(o instanceof CrossValidationPhaseListener))
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return super.hashCode();
+    }
 }



Mime
View raw message