extval 1.2 r04m03
git-svn-id: https://svn.apache.org/repos/asf/myfaces/extensions/validator/tags/extval_1.2.4M3@960479 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/initializer/component/TrinidadComponentInitializer.java b/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/initializer/component/TrinidadComponentInitializer.java
index 4860ab5..9b09e0f 100644
--- a/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/initializer/component/TrinidadComponentInitializer.java
+++ b/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/initializer/component/TrinidadComponentInitializer.java
@@ -64,22 +64,19 @@
public final void configureComponent(FacesContext facesContext, UIComponent uiComponent,
Map<String, Object> metaData)
{
+ TrinidadClientValidatorStorage storage = ExtValUtils
+ .getStorage(TrinidadClientValidatorStorage.class, TrinidadClientValidatorStorage.class.getName());
+
for(TrinidadComponentInitializer componentInitializer : componentInitializers)
{
if(componentInitializer.configureTrinidadComponent(facesContext, uiComponent, metaData))
{
- addComponentToStorage(uiComponent);
+ storage.addComponent(uiComponent);
updateComponent(facesContext, uiComponent);
}
}
}
- private void addComponentToStorage(UIComponent uiComponent)
- {
- ExtValUtils.getStorage(TrinidadClientValidatorStorage.class, TrinidadClientValidatorStorage.class.getName())
- .addComponent(uiComponent);
- }
-
protected boolean configureTrinidadComponent(FacesContext facesContext, UIComponent uiComponent,
Map<String, Object> metaData)
{
diff --git a/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/DefaultClientValidatorStorageManager.java b/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/DefaultClientValidatorStorageManager.java
index c401dc5..4ade20b 100644
--- a/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/DefaultClientValidatorStorageManager.java
+++ b/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/DefaultClientValidatorStorageManager.java
@@ -34,6 +34,8 @@
public class DefaultClientValidatorStorageManager
extends AbstractRequestScopeAwareStorageManager<TrinidadClientValidatorStorage>
{
+ private final String key = StorageManager.class.getName() + "_FOR_TRINIDAD_CLIENT_VALIDATOR:KEY";
+
public DefaultClientValidatorStorageManager()
{
register(new DefaultClientValidatorStorageNameMapper());
@@ -41,6 +43,6 @@
public String getStorageManagerKey()
{
- return StorageManager.class.getName() + "_FOR_TRINIDAD_CLIENT_VALIDATOR:KEY";
+ return key;
}
}
diff --git a/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/DefaultComponentMetaDataExtractor.java b/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/DefaultComponentMetaDataExtractor.java
index fba8efb..0577e47 100644
--- a/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/DefaultComponentMetaDataExtractor.java
+++ b/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/DefaultComponentMetaDataExtractor.java
@@ -86,12 +86,14 @@
*/
Class entityClass = ProxyUtils.getUnproxiedClass(propertyDetails.getBaseObject().getClass());
- if (isCached(entityClass, propertyDetails.getProperty()))
+ MetaDataStorage storage = getMetaDataStorage();
+
+ if (isCached(storage, entityClass, propertyDetails.getProperty()))
{
//create
propertyInformation.setInformation(PropertyInformationKeys.PROPERTY_DETAILS, propertyDetails);
- for (MetaDataEntry metaDataEntry : getCachedMetaData(entityClass, propertyDetails.getProperty()))
+ for (MetaDataEntry metaDataEntry : getCachedMetaData(storage, entityClass, propertyDetails.getProperty()))
{
propertyInformation.addMetaDataEntry(metaDataEntry);
}
@@ -99,7 +101,7 @@
else
{
propertyInformation = ExtValAnnotationUtils.extractAnnotations(entityClass, propertyDetails);
- cacheMetaData(propertyInformation);
+ cacheMetaData(storage, propertyInformation);
}
logger.finest("extract finished");
@@ -107,19 +109,19 @@
return propertyInformation;
}
- protected boolean isCached(Class entityClass, String property)
+ protected boolean isCached(MetaDataStorage storage, Class entityClass, String property)
{
- return getMetaDataStorage().containsMetaDataFor(entityClass, property);
+ return storage.containsMetaDataFor(entityClass, property);
}
- protected void cacheMetaData(PropertyInformation propertyInformation)
+ protected void cacheMetaData(MetaDataStorage storage, PropertyInformation propertyInformation)
{
- getMetaDataStorage().storeMetaDataOf(propertyInformation);
+ storage.storeMetaDataOf(propertyInformation);
}
- protected MetaDataEntry[] getCachedMetaData(Class entityClass, String property)
+ protected MetaDataEntry[] getCachedMetaData(MetaDataStorage storage, Class entityClass, String property)
{
- return getMetaDataStorage().getMetaData(entityClass, property);
+ return storage.getMetaData(entityClass, property);
}
protected MetaDataStorage getMetaDataStorage()
diff --git a/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRendererProxy.java b/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRendererProxy.java
index 59ab4cc..771971a 100644
--- a/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRendererProxy.java
+++ b/core/src/main/java/org/apache/myfaces/extensions/validator/core/renderkit/ExtValRendererProxy.java
@@ -251,11 +251,13 @@
key += getOptionalKey(facesContext, uiComponent);
- if (!getRendererStorage().containsEntry(getRendererKey(), key))
+ RendererProxyStorage rendererProxyStorage = getRendererStorage();
+
+ if (!rendererProxyStorage.containsEntry(getRendererKey(), key))
{
- getRendererStorage().setEntry(getRendererKey(), key, new RendererProxyStorageEntry());
+ rendererProxyStorage.setEntry(getRendererKey(), key, new RendererProxyStorageEntry());
}
- return getRendererStorage().getEntry(getRendererKey(), key);
+ return rendererProxyStorage.getEntry(getRendererKey(), key);
}
protected String getOptionalKey(FacesContext facesContext, UIComponent uiComponent)
diff --git a/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultFacesInformationStorageManager.java b/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultFacesInformationStorageManager.java
index da13bdf..f02ec4b 100644
--- a/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultFacesInformationStorageManager.java
+++ b/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultFacesInformationStorageManager.java
@@ -32,6 +32,8 @@
class DefaultFacesInformationStorageManager extends
AbstractRequestScopeAwareStorageManager<FacesInformationStorage>
{
+ private final String key = StorageManager.class.getName() + "_FOR_FACES_INFORMATION_STORAGE:KEY";
+
DefaultFacesInformationStorageManager()
{
register(new DefaultFacesInformationStorageNameMapper());
@@ -39,6 +41,6 @@
public String getStorageManagerKey()
{
- return StorageManager.class.getName() + "_FOR_FACES_INFORMATION_STORAGE:KEY";
+ return key;
}
}
diff --git a/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultFacesMessageStorageManager.java b/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultFacesMessageStorageManager.java
index 312326f..d548917 100644
--- a/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultFacesMessageStorageManager.java
+++ b/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultFacesMessageStorageManager.java
@@ -31,6 +31,8 @@
@UsageInformation(INTERNAL)
class DefaultFacesMessageStorageManager extends AbstractRequestScopeAwareStorageManager<FacesMessageStorage>
{
+ private static final String KEY = StorageManager.class.getName() + "_FOR_FACES_MESSAGES:KEY";
+
DefaultFacesMessageStorageManager()
{
register(new DefaultFacesMessageStorageNameMapper());
@@ -38,6 +40,6 @@
public String getStorageManagerKey()
{
- return StorageManager.class.getName() + "_FOR_FACES_MESSAGES:KEY";
+ return KEY;
}
}
diff --git a/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultGroupStorageManager.java b/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultGroupStorageManager.java
index 916b5bc..eeccb9f 100644
--- a/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultGroupStorageManager.java
+++ b/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultGroupStorageManager.java
@@ -30,8 +30,10 @@
@UsageInformation(INTERNAL)
class DefaultGroupStorageManager extends AbstractRequestScopeAwareStorageManager<GroupStorage>
{
+ private final String key = StorageManager.class.getName() + "_FOR_GROUPS:KEY";
+
public String getStorageManagerKey()
{
- return StorageManager.class.getName() + "_FOR_GROUPS:KEY";
+ return key;
}
}
diff --git a/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMappedConstraintSourceStorageManager.java b/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMappedConstraintSourceStorageManager.java
index 38f53e8..931726a 100644
--- a/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMappedConstraintSourceStorageManager.java
+++ b/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMappedConstraintSourceStorageManager.java
@@ -31,6 +31,8 @@
@UsageInformation(INTERNAL)
class DefaultMappedConstraintSourceStorageManager extends AbstractApplicationScopeAwareStorageManager<PropertyStorage>
{
+ private final String key = StorageManager.class.getName() + "_FOR_MAPPED_CONSTRAINT_SOURCE:KEY";
+
DefaultMappedConstraintSourceStorageManager()
{
register(new DefaultMappedConstraintSourceStorageNameMapper());
@@ -38,6 +40,6 @@
public String getStorageManagerKey()
{
- return StorageManager.class.getName() + "_FOR_MAPPED_CONSTRAINT_SOURCE:KEY";
+ return key;
}
}
diff --git a/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMetaDataStorageManager.java b/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMetaDataStorageManager.java
index ecc69be..c118cf8 100644
--- a/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMetaDataStorageManager.java
+++ b/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMetaDataStorageManager.java
@@ -31,6 +31,8 @@
@UsageInformation(UsageCategory.INTERNAL)
class DefaultMetaDataStorageManager extends AbstractApplicationScopeAwareStorageManager<MetaDataStorage>
{
+ private final String key = StorageManager.class.getName() + "_FOR_META_DATA_CACHE:KEY";
+
DefaultMetaDataStorageManager()
{
register(new DefaultMetaDataStorageNameMapper());
@@ -38,6 +40,6 @@
public String getStorageManagerKey()
{
- return StorageManager.class.getName() + "_FOR_META_DATA_CACHE:KEY";
+ return key;
}
}
diff --git a/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultPropertyStorageManager.java b/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultPropertyStorageManager.java
index fc5a104..c91ec52 100644
--- a/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultPropertyStorageManager.java
+++ b/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultPropertyStorageManager.java
@@ -31,6 +31,8 @@
@UsageInformation(INTERNAL)
class DefaultPropertyStorageManager extends AbstractApplicationScopeAwareStorageManager<PropertyStorage>
{
+ private final String key = StorageManager.class.getName() + "_FOR_PROPERTY:KEY";
+
DefaultPropertyStorageManager()
{
register(new DefaultPropertyStorageNameMapper());
@@ -38,6 +40,6 @@
public String getStorageManagerKey()
{
- return StorageManager.class.getName() + "_FOR_PROPERTY:KEY";
+ return key;
}
}
\ No newline at end of file
diff --git a/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultRendererInterceptorPropertyStorageManager.java b/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultRendererInterceptorPropertyStorageManager.java
index 565bc30..f4dfbb8 100644
--- a/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultRendererInterceptorPropertyStorageManager.java
+++ b/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultRendererInterceptorPropertyStorageManager.java
@@ -32,6 +32,8 @@
class DefaultRendererInterceptorPropertyStorageManager
extends AbstractRequestScopeAwareStorageManager<RendererInterceptorPropertyStorage>
{
+ private final String key = StorageManager.class.getName() + "_FOR_RENDERER_INTERCEPTOR_PROPERTY:KEY";
+
DefaultRendererInterceptorPropertyStorageManager()
{
register(new DefaultRendererInterceptorPropertyStorageNameMapper());
@@ -39,6 +41,6 @@
public String getStorageManagerKey()
{
- return StorageManager.class.getName() + "_FOR_RENDERER_INTERCEPTOR_PROPERTY:KEY";
+ return key;
}
}
\ No newline at end of file
diff --git a/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultRendererProxyStorageManager.java b/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultRendererProxyStorageManager.java
index c3d3acd..f145ebd 100644
--- a/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultRendererProxyStorageManager.java
+++ b/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultRendererProxyStorageManager.java
@@ -33,6 +33,8 @@
class DefaultRendererProxyStorageManager
extends AbstractRequestScopeAwareStorageManager<RendererProxyStorage>
{
+ private final String key = ExtValRendererProxy.class.getName() + ":STORAGE";
+
DefaultRendererProxyStorageManager()
{
register(new DefaultRendererProxyStorageNameMapper());
@@ -41,6 +43,6 @@
public String getStorageManagerKey()
{
//for better backward compatibility
- return ExtValRendererProxy.class.getName() + ":STORAGE";
+ return key;
}
}
\ No newline at end of file
diff --git a/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultViolationSeverityInterpreterStorageManager.java b/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultViolationSeverityInterpreterStorageManager.java
index 2df77fd..bdc1958 100644
--- a/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultViolationSeverityInterpreterStorageManager.java
+++ b/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultViolationSeverityInterpreterStorageManager.java
@@ -32,6 +32,8 @@
class DefaultViolationSeverityInterpreterStorageManager extends
AbstractRequestScopeAwareStorageManager<ViolationSeverityInterpreterStorage>
{
+ private final String key = StorageManager.class.getName() + "_FOR_VIOLATIONSEVERITY_INTERPRETER:KEY";
+
DefaultViolationSeverityInterpreterStorageManager()
{
register(new DefaultViolationSeverityInterpreterStorageNameMapper());
@@ -39,6 +41,6 @@
public String getStorageManagerKey()
{
- return StorageManager.class.getName() + "_FOR_VIOLATIONSEVERITY_INTERPRETER:KEY";
+ return key;
}
}
\ No newline at end of file
diff --git a/core/src/main/java/org/apache/myfaces/extensions/validator/util/ConstraintSourceUtils.java b/core/src/main/java/org/apache/myfaces/extensions/validator/util/ConstraintSourceUtils.java
index 65f5bcc..a7aca49 100644
--- a/core/src/main/java/org/apache/myfaces/extensions/validator/util/ConstraintSourceUtils.java
+++ b/core/src/main/java/org/apache/myfaces/extensions/validator/util/ConstraintSourceUtils.java
@@ -26,6 +26,7 @@
import org.apache.myfaces.extensions.validator.core.ExtValContext;
import org.apache.myfaces.extensions.validator.core.property.PropertyDetails;
import org.apache.myfaces.extensions.validator.core.storage.MappedConstraintSourceStorage;
+import org.apache.myfaces.extensions.validator.core.storage.PropertyStorage;
import org.apache.myfaces.extensions.validator.core.validation.ConstraintSource;
import org.apache.myfaces.extensions.validator.core.validation.IgnoreConstraintSource;
import org.apache.myfaces.extensions.validator.core.validation.TargetProperty;
@@ -50,44 +51,53 @@
Class originalClass,
String originalProperty)
{
- if (isMappedConstraintSourceCached(originalClass, originalProperty))
+ MappedConstraintSourceStorage mappedConstraintSourceStorage = getConstraintSourceStorage();
+
+ if (isMappedConstraintSourceCached(mappedConstraintSourceStorage, originalClass, originalProperty))
{
- return getMappedConstraintSource(originalClass, originalProperty);
+ return getMappedConstraintSource(mappedConstraintSourceStorage, originalClass, originalProperty);
}
originalClass = ProxyUtils.getUnproxiedClass(originalClass);
- Class newClass = findMappedClass(originalClass, originalProperty);
+ PropertyStorage propertyStorage = ReflectionUtils.getPropertyStorage();
+ Class newClass = findMappedClass(propertyStorage, originalClass, originalProperty);
//mapped source is ignored via @IgnoreConstraintSource or there is just no mapping annotation at the target
if (newClass == null)
{
- tryToCacheMappedConstraintSourceMetaData(originalClass, originalProperty, null);
+ tryToCacheMappedConstraintSourceMetaData(
+ mappedConstraintSourceStorage, originalClass, originalProperty, null);
+
return null;
}
- String newProperty = findMappedProperty(originalClass, newClass, originalProperty);
+ String newProperty = findMappedProperty(propertyStorage, originalClass, newClass, originalProperty);
PropertyDetails result = new PropertyDetails(originalKey, newClass, newProperty);
- tryToCacheMappedConstraintSourceMetaData(originalClass, originalProperty, result);
+ tryToCacheMappedConstraintSourceMetaData(
+ mappedConstraintSourceStorage, originalClass, originalProperty, result);
+
return result;
}
- private static boolean isMappedConstraintSourceCached(Class baseBeanClass, String property)
+ private static boolean isMappedConstraintSourceCached(
+ MappedConstraintSourceStorage storage, Class baseBeanClass, String property)
{
- return getConstraintSourceStorage().containsMapping(baseBeanClass, property);
+ return storage.containsMapping(baseBeanClass, property);
}
- private static PropertyDetails getMappedConstraintSource(Class baseBeanClass, String property)
+ private static PropertyDetails getMappedConstraintSource(
+ MappedConstraintSourceStorage storage, Class baseBeanClass, String property)
{
- return getConstraintSourceStorage().getMappedConstraintSource(baseBeanClass, property);
+ return storage.getMappedConstraintSource(baseBeanClass, property);
}
private static void tryToCacheMappedConstraintSourceMetaData(
- Class originalClass, String originalProperty, PropertyDetails result)
+ MappedConstraintSourceStorage storage, Class originalClass, String originalProperty, PropertyDetails result)
{
- getConstraintSourceStorage().storeMapping(originalClass, originalProperty, result);
+ storage.storeMapping(originalClass, originalProperty, result);
}
private static MappedConstraintSourceStorage getConstraintSourceStorage()
@@ -96,18 +106,18 @@
.getStorage(MappedConstraintSourceStorage.class, MappedConstraintSourceStorage.class.getName());
}
- private static Class findMappedClass(Class baseBeanClass, String property)
+ private static Class findMappedClass(PropertyStorage storage, Class baseBeanClass, String property)
{
Class<? extends Annotation> constraintSourceAnnotationImplementation = (Class) ExtValContext.getContext()
.getGlobalProperty(ConstraintSource.class.getName());
Annotation foundConstraintSourceAnnotation = tryToGetAnnotationFromProperty(
- baseBeanClass, property, constraintSourceAnnotationImplementation);
+ storage, baseBeanClass, property, constraintSourceAnnotationImplementation);
if (foundConstraintSourceAnnotation == null)
{
foundConstraintSourceAnnotation = tryToGetAnnotationFromField(
- baseBeanClass, property, constraintSourceAnnotationImplementation);
+ storage, baseBeanClass, property, constraintSourceAnnotationImplementation);
}
if (foundConstraintSourceAnnotation == null && !isMappedConstraintSourceIgnored(baseBeanClass, property))
@@ -124,9 +134,10 @@
return null;
}
- private static String findMappedProperty(Class baseBeanClass, Class newBaseBeanClass, String originalProperty)
+ private static String findMappedProperty(
+ PropertyStorage storage, Class baseBeanClass, Class newBaseBeanClass, String originalProperty)
{
- Annotation targetPropertyAnnotation = getTargetPropertyMetaData(baseBeanClass, originalProperty);
+ Annotation targetPropertyAnnotation = getTargetPropertyMetaData(storage, baseBeanClass, originalProperty);
if (targetPropertyAnnotation != null)
{
return extractNewPropertyName(newBaseBeanClass, targetPropertyAnnotation);
@@ -135,16 +146,19 @@
return originalProperty;
}
- private static Annotation getTargetPropertyMetaData(Class baseBeanClass, String originalProperty)
+ private static Annotation getTargetPropertyMetaData(
+ PropertyStorage storage, Class baseBeanClass, String originalProperty)
{
Class<? extends Annotation> targetPropertyAnnotation = getTargetPropertyAnnotationImplementation();
Class<? extends Annotation> targetPropertyIdAnnotation = getTargetPropertyIdAnnotationImplementation();
- Annotation result = findTargetPropertyIdAnnotation(baseBeanClass, originalProperty, targetPropertyIdAnnotation);
+ Annotation result = findTargetPropertyIdAnnotation(
+ storage, baseBeanClass, originalProperty, targetPropertyIdAnnotation);
if (result == null)
{
- result = findTargetPropertyAnnotation(baseBeanClass, originalProperty, targetPropertyAnnotation);
+ result = findTargetPropertyAnnotation(
+ storage, baseBeanClass, originalProperty, targetPropertyAnnotation);
}
return result;
@@ -225,29 +239,32 @@
return name;
}
- private static Annotation findTargetPropertyIdAnnotation(Class baseBeanClass,
+ private static Annotation findTargetPropertyIdAnnotation(PropertyStorage storage,
+ Class baseBeanClass,
String property,
Class<? extends Annotation> targetPropertyIdAnnotation)
{
- Annotation result = tryToGetAnnotationFromProperty(baseBeanClass, property, targetPropertyIdAnnotation);
+ Annotation result = tryToGetAnnotationFromProperty(
+ storage, baseBeanClass, property, targetPropertyIdAnnotation);
if (result == null)
{
- result = tryToGetAnnotationFromField(baseBeanClass, property, targetPropertyIdAnnotation);
+ result = tryToGetAnnotationFromField(storage, baseBeanClass, property, targetPropertyIdAnnotation);
}
return result;
}
- private static Annotation findTargetPropertyAnnotation(Class baseBeanClass,
+ private static Annotation findTargetPropertyAnnotation(PropertyStorage storage,
+ Class baseBeanClass,
String property,
Class<? extends Annotation> targetPropertyAnnotation)
{
- Annotation result = tryToGetAnnotationFromProperty(baseBeanClass, property, targetPropertyAnnotation);
+ Annotation result = tryToGetAnnotationFromProperty(storage, baseBeanClass, property, targetPropertyAnnotation);
if (result == null)
{
- result = tryToGetAnnotationFromField(baseBeanClass, property, targetPropertyAnnotation);
+ result = tryToGetAnnotationFromField(storage, baseBeanClass, property, targetPropertyAnnotation);
}
return result;
@@ -255,14 +272,15 @@
private static boolean isMappedConstraintSourceIgnored(Class baseBeanClass, String property)
{
- Method method = ReflectionUtils.tryToGetMethodOfProperty(baseBeanClass, property);
+ PropertyStorage storage = ReflectionUtils.getPropertyStorage();
+ Method method = ReflectionUtils.tryToGetMethodOfProperty(storage, baseBeanClass, property);
if (method != null && method.isAnnotationPresent(getIgnoreConstraintSourceAnnotationImplementation()))
{
return true;
}
- Field field = ReflectionUtils.tryToGetFieldOfProperty(baseBeanClass, property);
+ Field field = ReflectionUtils.tryToGetFieldOfProperty(storage, baseBeanClass, property);
if (field != null && field.isAnnotationPresent(getIgnoreConstraintSourceAnnotationImplementation()))
{
@@ -288,9 +306,9 @@
}
private static Annotation tryToGetAnnotationFromField(
- Class baseBeanClass, String property, Class<? extends Annotation> annotationClass)
+ PropertyStorage storage, Class baseBeanClass, String property, Class<? extends Annotation> annotationClass)
{
- Field field = ReflectionUtils.tryToGetFieldOfProperty(baseBeanClass, property);
+ Field field = ReflectionUtils.tryToGetFieldOfProperty(storage, baseBeanClass, property);
if (field != null && field.isAnnotationPresent(annotationClass))
{
@@ -299,11 +317,12 @@
return null;
}
- private static Annotation tryToGetAnnotationFromProperty(Class baseBeanClass,
+ private static Annotation tryToGetAnnotationFromProperty(PropertyStorage storage,
+ Class baseBeanClass,
String property,
Class<? extends Annotation> annotationClass)
{
- Method method = ReflectionUtils.tryToGetMethodOfProperty(baseBeanClass, property);
+ Method method = ReflectionUtils.tryToGetMethodOfProperty(storage, baseBeanClass, property);
if (method != null && method.isAnnotationPresent(annotationClass))
{
diff --git a/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValAnnotationUtils.java b/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValAnnotationUtils.java
index 30d5d3e..0ea030c 100644
--- a/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValAnnotationUtils.java
+++ b/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValAnnotationUtils.java
@@ -30,6 +30,7 @@
import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
import org.apache.myfaces.extensions.validator.core.property.DefaultPropertyInformation;
import org.apache.myfaces.extensions.validator.core.property.PropertyInformationKeys;
+import org.apache.myfaces.extensions.validator.core.storage.PropertyStorage;
import org.apache.myfaces.extensions.validator.internal.UsageCategory;
import org.apache.myfaces.extensions.validator.internal.UsageInformation;
import org.apache.myfaces.extensions.validator.internal.ToDo;
@@ -51,12 +52,14 @@
PropertyInformation propertyInformation = new DefaultPropertyInformation();
propertyInformation.setInformation(PropertyInformationKeys.PROPERTY_DETAILS, propertyDetails);
+ PropertyStorage storage = ReflectionUtils.getPropertyStorage();
+
while (!Object.class.getName().equals(entityClass.getName()))
{
- addPropertyAccessAnnotations(entityClass, propertyDetails.getProperty(), propertyInformation);
- addFieldAccessAnnotations(entityClass, propertyDetails.getProperty(), propertyInformation);
+ addPropertyAccessAnnotations(storage, entityClass, propertyDetails.getProperty(), propertyInformation);
+ addFieldAccessAnnotations(storage, entityClass, propertyDetails.getProperty(), propertyInformation);
- processInterfaces(entityClass, propertyDetails, propertyInformation);
+ processInterfaces(storage, entityClass, propertyDetails, propertyInformation);
entityClass = entityClass.getSuperclass();
}
@@ -65,11 +68,11 @@
}
@ToDo(value = Priority.HIGH, description = "add cache")
- public static void addPropertyAccessAnnotations(Class entity,
+ public static void addPropertyAccessAnnotations(PropertyStorage storage, Class entity,
String property,
PropertyInformation propertyInformation)
{
- Method method = ReflectionUtils.tryToGetMethodOfProperty(entity, property);
+ Method method = ReflectionUtils.tryToGetMethodOfProperty(storage, entity, property);
if(method != null)
{
@@ -78,11 +81,11 @@
}
@ToDo(value = Priority.HIGH, description = "add cache")
- public static void addFieldAccessAnnotations(Class entity,
+ public static void addFieldAccessAnnotations(PropertyStorage storage, Class entity,
String property,
PropertyInformation propertyInformation)
{
- Field field = ReflectionUtils.tryToGetFieldOfProperty(entity, property);
+ Field field = ReflectionUtils.tryToGetFieldOfProperty(storage, entity, property);
if(field != null)
{
@@ -90,15 +93,15 @@
}
}
- private static void processInterfaces(Class currentClass,
+ private static void processInterfaces(PropertyStorage storage, Class currentClass,
PropertyDetails propertyDetails,
PropertyInformation propertyInformation)
{
for (Class currentInterface : currentClass.getInterfaces())
{
- addPropertyAccessAnnotations(currentInterface, propertyDetails.getProperty(), propertyInformation);
+ addPropertyAccessAnnotations(storage, currentInterface, propertyDetails.getProperty(), propertyInformation);
- processInterfaces(currentInterface, propertyDetails, propertyInformation);
+ processInterfaces(storage, currentInterface, propertyDetails, propertyInformation);
}
}
diff --git a/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java b/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
index 58687ae..6e1bf73 100644
--- a/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
+++ b/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
@@ -645,14 +645,59 @@
public static <T> T getStorage(Class<T> storageType, String storageName)
{
- return (T) getStorageManagerFactory().create(storageType).create(storageName);
+ T storage = getCachedStorage(storageType, storageName);
+
+ if(storage != null)
+ {
+ return storage;
+ }
+ storage = (T) getStorageManagerFactory().create(storageType).create(storageName);
+
+ cacheStorageForRequest(storageType, storageName, storage);
+
+ return storage;
+ }
+
+ private static <T> T getCachedStorage(Class<T> storageType, String storageName)
+ {
+ Map requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
+
+ String key = createStorageKey(storageType.getName(), storageName);
+ return (T)requestMap.get(key);
+ }
+
+ private static <T> void cacheStorageForRequest(Class<T> storageType, String storageName, T storage)
+ {
+ Map requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
+
+ String key = createStorageKey(storageType.getName(), storageName);
+ requestMap.put(key, storage);
+ }
+
+ private static String createStorageKey(String storageType, String storageName)
+ {
+ StringBuilder key = new StringBuilder("cachedStorage:");
+ key.append(storageType);
+ key.append(":");
+ key.append(storageName);
+ return key.toString();
}
public static void resetStorage(Class storageType, String storageName)
{
+ resetCachedStorage(storageType.getName(), storageName);
+
getStorageManagerFactory().create(storageType).reset(storageName);
}
+ private static void resetCachedStorage(String storageType, String storageName)
+ {
+ String key = createStorageKey(storageType, storageName);
+
+ Map requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
+ requestMap.put(key, null);
+ }
+
private static ClassMappingFactory<Class, StorageManager> getStorageManagerFactory()
{
return (ExtValContext.getContext()
diff --git a/core/src/main/java/org/apache/myfaces/extensions/validator/util/NullValueAwareConcurrentHashMap.java b/core/src/main/java/org/apache/myfaces/extensions/validator/util/NullValueAwareConcurrentHashMap.java
index 146163d..bcd5493 100644
--- a/core/src/main/java/org/apache/myfaces/extensions/validator/util/NullValueAwareConcurrentHashMap.java
+++ b/core/src/main/java/org/apache/myfaces/extensions/validator/util/NullValueAwareConcurrentHashMap.java
@@ -19,7 +19,6 @@
package org.apache.myfaces.extensions.validator.util;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.Map;
/**
* in some cases we have to store null values to avoid re-evaluation
@@ -32,26 +31,6 @@
private V nullMarkerValue;
- protected NullValueAwareConcurrentHashMap(int initialCapacity, float loadFactor, int concurrencyLevel)
- {
- super(initialCapacity, loadFactor, concurrencyLevel);
- }
-
- protected NullValueAwareConcurrentHashMap(int initialCapacity, float loadFactor)
- {
- super(initialCapacity, loadFactor);
- }
-
- protected NullValueAwareConcurrentHashMap(int initialCapacity)
- {
- super(initialCapacity);
- }
-
- protected NullValueAwareConcurrentHashMap(Map<? extends K, ? extends V> m)
- {
- super(m);
- }
-
public NullValueAwareConcurrentHashMap(V nullMarkerValue)
{
this.nullMarkerValue = nullMarkerValue;
diff --git a/core/src/main/java/org/apache/myfaces/extensions/validator/util/ReflectionUtils.java b/core/src/main/java/org/apache/myfaces/extensions/validator/util/ReflectionUtils.java
index 609156b..063f78c 100644
--- a/core/src/main/java/org/apache/myfaces/extensions/validator/util/ReflectionUtils.java
+++ b/core/src/main/java/org/apache/myfaces/extensions/validator/util/ReflectionUtils.java
@@ -209,25 +209,37 @@
return ExtValUtils.getStorage(PropertyStorage.class, PropertyStorage.class.getName());
}
+ @Deprecated
public static Method tryToGetMethodOfProperty(Class entity, String property)
{
- if (isCachedMethod(entity, property))
+ return tryToGetMethodOfProperty(getPropertyStorage(), entity, property);
+ }
+
+ public static Method tryToGetMethodOfProperty(PropertyStorage storage, Class entity, String property)
+ {
+ if (isCachedMethod(storage, entity, property))
{
- return getCachedMethod(entity, property);
+ return getCachedMethod(storage, entity, property);
}
Method method = tryToGetReadMethod(entity, property);
- tryToCacheMethod(entity, property, method);
+ tryToCacheMethod(storage, entity, property, method);
return method;
}
+ @Deprecated
public static Field tryToGetFieldOfProperty(Class entity, String property)
{
- if (isCachedField(entity, property))
+ return tryToGetFieldOfProperty(getPropertyStorage(), entity, property);
+ }
+
+ public static Field tryToGetFieldOfProperty(PropertyStorage storage, Class entity, String property)
+ {
+ if (isCachedField(storage, entity, property))
{
- return getCachedField(entity, property);
+ return getCachedField(storage, entity, property);
}
Field field = null;
@@ -265,23 +277,22 @@
}
}
- tryToCacheField(entity, property, field);
+ tryToCacheField(storage, entity, property, field);
return field;
}
- private static void tryToCacheField(Class entity, String property, Field field)
+ private static void tryToCacheField(PropertyStorage storage, Class entity, String property, Field field)
{
- PropertyStorage propertyStorage = getPropertyStorage();
- if (!propertyStorage.containsField(entity, property))
+ if (!storage.containsField(entity, property))
{
- propertyStorage.storeField(entity, property, field);
+ storage.storeField(entity, property, field);
}
}
- private static boolean isCachedField(Class entity, String property)
+ private static boolean isCachedField(PropertyStorage storage, Class entity, String property)
{
- return getPropertyStorage().containsField(entity, property);
+ return storage.containsField(entity, property);
}
private static Method tryToGetReadMethod(Class baseBeanClass, String property)
@@ -350,27 +361,26 @@
}
}
- private static Field getCachedField(Class entity, String property)
+ private static Field getCachedField(PropertyStorage storage, Class entity, String property)
{
- return getPropertyStorage().getField(entity, property);
+ return storage.getField(entity, property);
}
- private static boolean isCachedMethod(Class entity, String property)
+ private static boolean isCachedMethod(PropertyStorage storage, Class entity, String property)
{
- return getPropertyStorage().containsMethod(entity, property);
+ return storage.containsMethod(entity, property);
}
- private static void tryToCacheMethod(Class entity, String property, Method method)
+ private static void tryToCacheMethod(PropertyStorage storage, Class entity, String property, Method method)
{
- PropertyStorage propertyStorage = getPropertyStorage();
- if (!propertyStorage.containsMethod(entity, property))
+ if (!storage.containsMethod(entity, property))
{
- propertyStorage.storeMethod(entity, property, method);
+ storage.storeMethod(entity, property, method);
}
}
- private static Method getCachedMethod(Class entity, String property)
+ private static Method getCachedMethod(PropertyStorage storage, Class entity, String property)
{
- return getPropertyStorage().getMethod(entity, property);
+ return storage.getMethod(entity, property);
}
}
diff --git a/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/ExtValBeanValidationContext.java b/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/ExtValBeanValidationContext.java
index fc4eeae..cd14680 100644
--- a/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/ExtValBeanValidationContext.java
+++ b/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/ExtValBeanValidationContext.java
@@ -30,6 +30,7 @@
import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
import org.apache.myfaces.extensions.validator.core.storage.GroupStorage;
import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.JsfProjectStage;
import org.apache.myfaces.extensions.validator.util.ExtValUtils;
import org.apache.myfaces.extensions.validator.internal.UsageInformation;
import org.apache.myfaces.extensions.validator.internal.UsageCategory;
@@ -60,6 +61,8 @@
protected ModelValidationStorage modelValidationStorage;
+ protected boolean developmentMode = false;
+
protected ExtValBeanValidationContext()
{
initGroupStorage();
@@ -67,6 +70,11 @@
initMessageResolver();
initMessageInterpolator();
+
+ if (JsfProjectStage.is(JsfProjectStage.Development))
+ {
+ this.developmentMode = true;
+ }
}
@SuppressWarnings({"unchecked"})
@@ -96,7 +104,10 @@
return (ValidatorFactory)validatorFactory;
}
- this.logger.warning("fallback to the default bv validator factory");
+ if(this.developmentMode)
+ {
+ this.logger.warning("fallback to the default bv validator factory");
+ }
return BeanValidationUtils.getDefaultValidatorFactory();
}
diff --git a/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/storage/DefaultModelValidationStorageManager.java b/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/storage/DefaultModelValidationStorageManager.java
index 1831012..1ca166e 100644
--- a/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/storage/DefaultModelValidationStorageManager.java
+++ b/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/storage/DefaultModelValidationStorageManager.java
@@ -33,8 +33,10 @@
public class DefaultModelValidationStorageManager
extends AbstractRequestScopeAwareStorageManager<ModelValidationStorage>
{
+ private final String key = StorageManager.class.getName() + "_FOR_MODEL_VALIDATION:KEY";
+
public String getStorageManagerKey()
{
- return StorageManager.class.getName() + "_FOR_MODEL_VALIDATION:KEY";
+ return key;
}
}
\ No newline at end of file
diff --git a/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/BeanValidationUtils.java b/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/BeanValidationUtils.java
index 831887b..247af27 100644
--- a/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/BeanValidationUtils.java
+++ b/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/BeanValidationUtils.java
@@ -118,6 +118,8 @@
List<ModelValidationEntry> modelValidationEntryList = new ArrayList<ModelValidationEntry>();
List<Class> restrictedGroupsForModelValidation = new ArrayList<Class>();
+ String activeViewId = FacesContext.getCurrentInstance().getViewRoot().getViewId();
+
bvmi.extractExtValBeanValidationMetaData(propertyDetails,
processModelValidation,
key,
@@ -125,14 +127,16 @@
foundGroupsForPropertyValidation,
restrictedGroupsForPropertyValidation,
modelValidationEntryList,
- restrictedGroupsForModelValidation);
+ restrictedGroupsForModelValidation,
+ activeViewId);
bvmi.processExtValBeanValidationMetaData(component,
propertyDetails,
foundGroupsForPropertyValidation,
restrictedGroupsForPropertyValidation,
modelValidationEntryList,
- restrictedGroupsForModelValidation);
+ restrictedGroupsForModelValidation,
+ activeViewId);
}
public static void processConstraintViolations(FacesContext facesContext,
diff --git a/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java b/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
index 3abb7c6..d5c6120 100644
--- a/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
+++ b/validation-modules/bean-validation/src/main/java/org/apache/myfaces/extensions/validator/beanval/util/ExtValBeanValidationMetaDataInternals.java
@@ -72,14 +72,16 @@
List<Class> foundGroupsForPropertyValidation,
List<Class> restrictedGroupsForPropertyValidation,
List<ModelValidationEntry> modelValidationEntryList,
- List<Class> restrictedGroupsForModelValidation)
+ List<Class> restrictedGroupsForModelValidation,
+ String activeViewId)
{
inspectFirstBean(processModelValidation,
firstBean,
foundGroupsForPropertyValidation,
restrictedGroupsForPropertyValidation,
modelValidationEntryList,
- restrictedGroupsForModelValidation);
+ restrictedGroupsForModelValidation,
+ activeViewId);
inspectFirstProperty(processModelValidation,
key,
@@ -88,6 +90,7 @@
restrictedGroupsForPropertyValidation,
modelValidationEntryList,
restrictedGroupsForModelValidation,
+ activeViewId,
key.length == 2);
inspectBaseOfProperty(propertyDetails,
@@ -95,14 +98,16 @@
foundGroupsForPropertyValidation,
restrictedGroupsForPropertyValidation,
modelValidationEntryList,
- restrictedGroupsForModelValidation);
+ restrictedGroupsForModelValidation,
+ activeViewId);
inspectLastProperty(propertyDetails,
processModelValidation,
foundGroupsForPropertyValidation,
restrictedGroupsForPropertyValidation,
modelValidationEntryList,
- restrictedGroupsForModelValidation);
+ restrictedGroupsForModelValidation,
+ activeViewId);
}
void processExtValBeanValidationMetaData(UIComponent component,
@@ -110,17 +115,17 @@
List<Class> foundGroupsForPropertyValidation,
List<Class> restrictedGroupsForPropertyValidation,
List<ModelValidationEntry> modelValidationEntryList,
- List<Class> restrictedGroupsForModelValidation)
+ List<Class> restrictedGroupsForModelValidation,
+ String activeViewId)
{
ExtValBeanValidationContext extValBeanValidationContext = ExtValBeanValidationContext.getCurrentInstance();
- String currentViewId = FacesContext.getCurrentInstance().getViewRoot().getViewId();
String clientId = component.getClientId(FacesContext.getCurrentInstance());
- processFoundGroups(extValBeanValidationContext, currentViewId, clientId,
+ processFoundGroups(extValBeanValidationContext, activeViewId, clientId,
foundGroupsForPropertyValidation);
- processRestrictedGroups(extValBeanValidationContext, currentViewId, clientId,
+ processRestrictedGroups(extValBeanValidationContext, activeViewId, clientId,
restrictedGroupsForPropertyValidation);
initModelValidation(extValBeanValidationContext, component, propertyDetails,
@@ -132,13 +137,15 @@
List<Class> foundGroupsForPropertyValidation,
List<Class> restrictedGroupsForPropertyValidation,
List<ModelValidationEntry> modelValidationEntryList,
- List<Class> restrictedGroupsForModelValidation)
+ List<Class> restrictedGroupsForModelValidation,
+ String activeViewId)
{
processClass(firstBean,
foundGroupsForPropertyValidation,
restrictedGroupsForPropertyValidation,
modelValidationEntryList,
restrictedGroupsForModelValidation,
+ activeViewId,
processModelValidation);
}
@@ -149,6 +156,7 @@
List<Class> restrictedGroupsForPropertyValidation,
List<ModelValidationEntry> modelValidationEntryList,
List<Class> restrictedGroupsForModelValidation,
+ String activeViewId,
boolean isLastProperty)
{
processFieldsAndProperties(key[0] + "." + key[1],
@@ -158,6 +166,7 @@
restrictedGroupsForPropertyValidation,
modelValidationEntryList,
restrictedGroupsForModelValidation,
+ activeViewId,
processModelValidation,
isLastProperty);
}
@@ -167,13 +176,15 @@
List<Class> foundGroupsForPropertyValidation,
List<Class> restrictedGroupsForPropertyValidation,
List<ModelValidationEntry> modelValidationEntryList,
- List<Class> restrictedGroupsForModelValidation)
+ List<Class> restrictedGroupsForModelValidation,
+ String activeViewId)
{
processClass(propertyDetails.getBaseObject(),
foundGroupsForPropertyValidation,
restrictedGroupsForPropertyValidation,
modelValidationEntryList,
restrictedGroupsForModelValidation,
+ activeViewId,
processModelValidation);
}
@@ -182,7 +193,8 @@
List<Class> foundGroupsForPropertyValidation,
List<Class> restrictedGroupsForPropertyValidation,
List<ModelValidationEntry> modelValidationEntryList,
- List<Class> restrictedGroupsForModelValidation)
+ List<Class> restrictedGroupsForModelValidation,
+ String activeViewId)
{
processFieldsAndProperties(
propertyDetails.getKey(),
@@ -192,6 +204,7 @@
restrictedGroupsForPropertyValidation,
modelValidationEntryList,
restrictedGroupsForModelValidation,
+ activeViewId,
processModelValidation,
true);
}
@@ -201,6 +214,7 @@
List<Class> restrictedGroupsForPropertyValidation,
List<ModelValidationEntry> modelValidationEntryList,
List<Class> restrictedGroupsForModelValidation,
+ String activeViewId,
boolean processModelValidation)
{
Class classToInspect = ProxyUtils.getUnproxiedClass(objectToInspect.getClass());
@@ -212,6 +226,7 @@
restrictedGroupsForPropertyValidation,
modelValidationEntryList,
restrictedGroupsForModelValidation,
+ activeViewId,
processModelValidation);
processInterfaces(objectToInspect.getClass(), objectToInspect,
@@ -219,6 +234,7 @@
restrictedGroupsForPropertyValidation,
modelValidationEntryList,
restrictedGroupsForModelValidation,
+ activeViewId,
processModelValidation);
classToInspect = classToInspect.getSuperclass();
@@ -232,6 +248,7 @@
List<Class> restrictedGroupsForPropertyValidation,
List<ModelValidationEntry> modelValidationEntryList,
List<Class> restrictedGroupsForModelValidation,
+ String activeViewId,
boolean processModelValidation,
boolean isLastProperty)
{
@@ -248,6 +265,7 @@
restrictedGroupsForPropertyValidation,
modelValidationEntryList,
restrictedGroupsForModelValidation,
+ activeViewId,
processModelValidation);
}
else if (metaDataEntry.getValue() instanceof BeanValidation.List)
@@ -260,6 +278,7 @@
restrictedGroupsForPropertyValidation,
modelValidationEntryList,
restrictedGroupsForModelValidation,
+ activeViewId,
processModelValidation);
}
}
@@ -367,6 +386,7 @@
List<Class> restrictedGroupsForPropertyValidation,
List<ModelValidationEntry> modelValidationEntryList,
List<Class> restrictedGroupsForModelValidation,
+ String activeViewId,
boolean processModelValidation)
{
if (objectToInspect.getClass().isAnnotationPresent(BeanValidation.class))
@@ -377,6 +397,7 @@
restrictedGroupsForPropertyValidation,
modelValidationEntryList,
restrictedGroupsForModelValidation,
+ activeViewId,
processModelValidation);
}
else if (objectToInspect.getClass().isAnnotationPresent(BeanValidation.List.class))
@@ -390,6 +411,7 @@
restrictedGroupsForPropertyValidation,
modelValidationEntryList,
restrictedGroupsForModelValidation,
+ activeViewId,
processModelValidation);
}
}
@@ -401,6 +423,7 @@
List<Class> restrictedGroupsForPropertyValidation,
List<ModelValidationEntry> modelValidationEntryList,
List<Class> restrictedGroupsForModelValidation,
+ String activeViewId,
boolean processModelValidation)
{
for (Class currentInterface : currentClass.getInterfaces())
@@ -410,6 +433,7 @@
restrictedGroupsForPropertyValidation,
modelValidationEntryList,
restrictedGroupsForModelValidation,
+ activeViewId,
processModelValidation);
processInterfaces(currentInterface, metaDataSourceObject,
@@ -417,6 +441,7 @@
restrictedGroupsForPropertyValidation,
modelValidationEntryList,
restrictedGroupsForModelValidation,
+ activeViewId,
processModelValidation);
}
}
@@ -427,11 +452,12 @@
List<Class> restrictedGroupsForPropertyValidation,
List<ModelValidationEntry> modelValidationEntryList,
List<Class> restrictedGroupsForModelValidation,
+ String activeViewId,
boolean processModelValidation)
{
for (String currentViewId : beanValidation.viewIds())
{
- if (useMetaDataForViewId(beanValidation, currentViewId))
+ if (useMetaDataForViewId(beanValidation, currentViewId, activeViewId))
{
processMetaData(beanValidation,
metaDataSourceObject,
@@ -445,10 +471,10 @@
}
}
- private boolean useMetaDataForViewId(BeanValidation beanValidation, String currentViewId)
+ private boolean useMetaDataForViewId(BeanValidation beanValidation, String viewId, String activeViewId)
{
- return (currentViewId.equals(FacesContext.getCurrentInstance().getViewRoot().getViewId()) ||
- currentViewId.equals("*")) && isValidationPermitted(beanValidation);
+ return (viewId.equals(activeViewId) ||
+ viewId.equals("*")) && isValidationPermitted(beanValidation);
}
private void processMetaData(BeanValidation beanValidation,
diff --git a/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/JoinValidationMetaDataStorageFilter.java b/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/JoinValidationMetaDataStorageFilter.java
index cc8f3a6..dc56d2c 100644
--- a/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/JoinValidationMetaDataStorageFilter.java
+++ b/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/JoinValidationMetaDataStorageFilter.java
@@ -26,9 +26,11 @@
import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
import org.apache.myfaces.extensions.validator.core.property.PropertyInformationKeys;
import org.apache.myfaces.extensions.validator.core.storage.MetaDataStorageFilter;
+import org.apache.myfaces.extensions.validator.core.storage.PropertyStorage;
import org.apache.myfaces.extensions.validator.util.ClassUtils;
import org.apache.myfaces.extensions.validator.util.ExtValUtils;
import org.apache.myfaces.extensions.validator.util.ProxyUtils;
+import org.apache.myfaces.extensions.validator.util.ReflectionUtils;
import static org.apache.myfaces.extensions.validator.util.ExtValAnnotationUtils.addPropertyAccessAnnotations;
import static org.apache.myfaces.extensions.validator.util.ExtValAnnotationUtils.addFieldAccessAnnotations;
import org.apache.myfaces.extensions.validator.internal.UsageInformation;
@@ -191,8 +193,9 @@
{
PropertyInformation propertyInformation = new DefaultPropertyInformation();
- addPropertyAccessAnnotations(targetClass, targetProperty, propertyInformation);
- addFieldAccessAnnotations(targetClass, targetProperty, propertyInformation);
+ PropertyStorage storage = ReflectionUtils.getPropertyStorage();
+ addPropertyAccessAnnotations(storage, targetClass, targetProperty, propertyInformation);
+ addFieldAccessAnnotations(storage, targetClass, targetProperty, propertyInformation);
return propertyInformation;
}
diff --git a/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/annotation/extractor/DefaultPropertyScanningMetaDataExtractor.java b/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/annotation/extractor/DefaultPropertyScanningMetaDataExtractor.java
index 16b130c..bda5358 100644
--- a/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/annotation/extractor/DefaultPropertyScanningMetaDataExtractor.java
+++ b/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/baseval/annotation/extractor/DefaultPropertyScanningMetaDataExtractor.java
@@ -24,12 +24,14 @@
import org.apache.myfaces.extensions.validator.core.property.PropertyDetails;
import org.apache.myfaces.extensions.validator.core.metadata.extractor.DefaultComponentMetaDataExtractor;
import org.apache.myfaces.extensions.validator.core.metadata.extractor.MetaDataExtractor;
+import org.apache.myfaces.extensions.validator.core.storage.PropertyStorage;
import org.apache.myfaces.extensions.validator.internal.ToDo;
import org.apache.myfaces.extensions.validator.internal.Priority;
import org.apache.myfaces.extensions.validator.internal.UsageInformation;
import org.apache.myfaces.extensions.validator.internal.UsageCategory;
import org.apache.myfaces.extensions.validator.util.ExtValUtils;
import org.apache.myfaces.extensions.validator.util.ProxyUtils;
+import org.apache.myfaces.extensions.validator.util.ReflectionUtils;
import static org.apache.myfaces.extensions.validator.util.ExtValAnnotationUtils.addFieldAccessAnnotations;
import static org.apache.myfaces.extensions.validator.util.ExtValAnnotationUtils.addPropertyAccessAnnotations;
import org.apache.myfaces.extensions.validator.PropertyValidationModuleKey;
@@ -76,8 +78,10 @@
/*
* find and add annotations
*/
- addPropertyAccessAnnotations(entityClass, propertyDetails.getProperty(), propertyInformation);
- addFieldAccessAnnotations(entityClass, propertyDetails.getProperty(), propertyInformation);
+ PropertyStorage storage = ReflectionUtils.getPropertyStorage();
+
+ addPropertyAccessAnnotations(storage, entityClass, propertyDetails.getProperty(), propertyInformation);
+ addFieldAccessAnnotations(storage, entityClass, propertyDetails.getProperty(), propertyInformation);
return propertyInformation;
}
diff --git a/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultCrossValidationStorageManager.java b/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultCrossValidationStorageManager.java
index e041c95d..dd4a5fd 100644
--- a/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultCrossValidationStorageManager.java
+++ b/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultCrossValidationStorageManager.java
@@ -32,9 +32,11 @@
public class DefaultCrossValidationStorageManager
extends AbstractRequestScopeAwareStorageManager<CrossValidationStorage>
{
+ private final String key = CrossValidationStorage.class.getName();
+
public String getStorageManagerKey()
{
//for better backward compatibility
- return CrossValidationStorage.class.getName();
+ return key;
}
}
diff --git a/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultProcessedInformationStorageManager.java b/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultProcessedInformationStorageManager.java
index 66182c8..9e9fb51 100644
--- a/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultProcessedInformationStorageManager.java
+++ b/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultProcessedInformationStorageManager.java
@@ -33,9 +33,11 @@
public class DefaultProcessedInformationStorageManager
extends AbstractRequestScopeAwareStorageManager<CrossValidationStorage>
{
+ private final String key = CrossValidationUtils.class.getName();
+
public String getStorageManagerKey()
{
//for better backward compatibility
- return CrossValidationUtils.class.getName();
+ return key;
}
}
\ No newline at end of file