You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2009/11/13 03:48:58 UTC
svn commit: r835712 [8/19] - in
/myfaces/extensions/validator/branches/branch_for_jsf_2_0: ./ assembly/
assembly/src/ assembly/src/main/ assembly/src/main/assembly/
assembly/src/main/resources/ component-support/
component-support/generic-support/ comp...
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultGroupStorage.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/storage/DefaultGroupStorage.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultGroupStorage.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultGroupStorage.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage;
+
+import org.apache.myfaces.extensions.validator.util.GroupUtils;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import static org.apache.myfaces.extensions.validator.internal.UsageCategory.INTERNAL;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.ArrayList;
+
+/**
+ * default storage implementation for groups
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(INTERNAL)
+public class DefaultGroupStorage implements GroupStorage
+{
+ protected final Log logger = LogFactory.getLog(getClass());
+
+ private Map<String, List<Class>> addedGroups = new HashMap<String, List<Class>>();
+
+ private Map<String, List<Class>> restrictedGroups = new HashMap<String, List<Class>>();
+
+ public void addGroup(Class groupClass, String viewId, String clientId)
+ {
+ addGroupToGroupStorage(groupClass, viewId, clientId, this.addedGroups);
+ }
+
+ public void restrictGroup(Class groupClass, String viewId, String clientId)
+ {
+ addGroupToGroupStorage(groupClass, viewId, clientId, this.restrictedGroups);
+ }
+
+ public Class[] getGroups(String viewId, String clientId)
+ {
+ if(this.addedGroups.size() < 1)
+ {
+ return null;
+ }
+
+ //add found groups
+ String key = GroupUtils.getGroupKey(viewId, null);
+ List<Class> resultListForPage = buildGroupList(key, this.addedGroups);
+
+ key = GroupUtils.getGroupKey(viewId, clientId);
+ List<Class> resultListForComponent = buildGroupList(key, this.addedGroups);
+
+ //remove restricted groups
+ Class[] resultsForPage =
+ filterGroupList(GroupUtils.getGroupKey(viewId, null), resultListForPage);
+ Class[] resultsForComponent =
+ filterGroupList(GroupUtils.getGroupKey(viewId, clientId), resultListForComponent);
+
+ if(resultsForPage.length == 0)
+ {
+ if(resultsForComponent.length == 0)
+ {
+ if(this.logger.isDebugEnabled())
+ {
+ this.logger.debug("no groups for group-validation available." +
+ "maybe you restricted all groups or you aren't using groups." +
+ "bean validation will use the default group for validation");
+ }
+ }
+ return resultsForComponent;
+ }
+ else if(resultsForComponent.length == 0)
+ {
+ return resultsForPage;
+ }
+
+ return mergeResults(resultsForPage, resultsForComponent);
+ }
+
+ private void addGroupToGroupStorage(Class groupClass, String viewId, String clientId,
+ Map<String, List<Class>> groupStorage)
+ {
+ List<Class> groupList = groupStorage.get(GroupUtils.getGroupKey(viewId, clientId));
+
+ if(groupList == null)
+ {
+ groupList = new ArrayList<Class>();
+ groupStorage.put(GroupUtils.getGroupKey(viewId, clientId), groupList);
+ }
+
+ if(!groupList.contains(groupClass))
+ {
+ groupList.add(groupClass);
+ }
+ }
+
+ private List<Class> buildGroupList(String key, Map<String, List<Class>> groupStorage)
+ {
+ List<Class> list = groupStorage.get(key);
+ return (list != null) ? list : new ArrayList<Class>();
+ }
+
+ private Class[] filterGroupList(String key, List<Class> addedGroups)
+ {
+ List<Class> restrictedGroups = buildGroupList(key, this.restrictedGroups);
+ List<Class> results = new ArrayList<Class>();
+
+ for(Class currentGroup : addedGroups)
+ {
+ if(!restrictedGroups.contains(currentGroup))
+ {
+ results.add(currentGroup);
+ }
+ }
+
+ return results.toArray(new Class[results.size()]);
+ }
+
+ private Class[] mergeResults(Class[] resultsForPage, Class[] resultsForComponent)
+ {
+ Class[] mergedResult = new Class[resultsForPage.length + resultsForComponent.length];
+
+ System.arraycopy(resultsForPage, 0, mergedResult, 0, resultsForPage.length);
+ System.arraycopy(resultsForComponent, 0, mergedResult, resultsForPage.length, resultsForComponent.length);
+
+ return mergedResult;
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultGroupStorageManager.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/storage/DefaultGroupStorageManager.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultGroupStorageManager.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultGroupStorageManager.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import static org.apache.myfaces.extensions.validator.internal.UsageCategory.INTERNAL;
+
+/**
+ * default storage-manager for groups
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(INTERNAL)
+class DefaultGroupStorageManager extends AbstractRequestScopeAwareStorageManager<GroupStorage>
+{
+ public String getStorageManagerKey()
+ {
+ return StorageManager.class.getName() + "_FOR_GROUPS:KEY";
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/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_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMetaDataStorage.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMetaDataStorage.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMetaDataStorage.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.ToDo;
+import org.apache.myfaces.extensions.validator.internal.Priority;
+import static org.apache.myfaces.extensions.validator.internal.UsageCategory.INTERNAL;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
+import org.apache.myfaces.extensions.validator.core.property.PropertyDetails;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformationKeys;
+import org.apache.myfaces.extensions.validator.core.property.DefaultPropertyInformation;
+import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
+import org.apache.myfaces.extensions.validator.core.WebXmlParameter;
+import org.apache.myfaces.extensions.validator.core.CustomInformation;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.util.ClassUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(INTERNAL)
+public class DefaultMetaDataStorage implements MetaDataStorage
+{
+ protected final Log logger = LogFactory.getLog(getClass());
+
+ private Map<String, PropertyInformation> cachedPropertyInformation = new HashMap<String, PropertyInformation>();
+
+ private List<MetaDataStorageFilter> metaDataStorageFilters = new ArrayList<MetaDataStorageFilter>();
+ private List<Class<? extends MetaDataStorageFilter>> deniedMetaDataFilters =
+ new ArrayList<Class<? extends MetaDataStorageFilter>>();
+
+ public DefaultMetaDataStorage()
+ {
+ initFilters();
+ }
+
+ private void initFilters()
+ {
+ List<String> metaDataStorageFilterClassNames = new ArrayList<String>();
+
+ metaDataStorageFilterClassNames
+ .add(WebXmlParameter.CUSTOM_META_DATA_STORAGE_FILTER);
+ metaDataStorageFilterClassNames
+ .add(ExtValContext.getContext().getInformationProviderBean().get(
+ CustomInformation.META_DATA_STORAGE_FILTER));
+
+ MetaDataStorageFilter metaDataStorageFilter;
+ for (String validationExceptionInterceptorName : metaDataStorageFilterClassNames)
+ {
+ metaDataStorageFilter =
+ (MetaDataStorageFilter)ClassUtils.tryToInstantiateClassForName(validationExceptionInterceptorName);
+
+ if (metaDataStorageFilter != null)
+ {
+ this.metaDataStorageFilters.add(metaDataStorageFilter);
+
+ logAddedFilter(metaDataStorageFilter.getClass());
+ }
+ }
+ }
+
+ public void storeMetaDataOf(PropertyInformation propertyInformation)
+ {
+ invokeFilters(propertyInformation);
+
+ PropertyInformation propertyInformationToStore = new DefaultPropertyInformation();
+
+ PropertyDetails propertyDetails = propertyInformation
+ .getInformation(PropertyInformationKeys.PROPERTY_DETAILS, PropertyDetails.class);
+
+ copyMetaData(propertyInformation, propertyInformationToStore);
+
+ this.cachedPropertyInformation.put(
+ createKey(propertyDetails.getBaseObject().getClass(), propertyDetails.getProperty()),
+ propertyInformationToStore);
+ }
+
+ private void invokeFilters(PropertyInformation propertyInformation)
+ {
+ for(MetaDataStorageFilter filter : this.metaDataStorageFilters)
+ {
+ filter.filter(propertyInformation);
+ }
+ }
+
+ public MetaDataEntry[] getMetaData(Class targetClass, String targetProperty)
+ {
+ PropertyInformation propertyInformation = this.cachedPropertyInformation
+ .get(createKey(targetClass, targetProperty));
+
+ PropertyInformation clonedPropertyInformation = new DefaultPropertyInformation();
+ copyMetaData(propertyInformation, clonedPropertyInformation);
+
+ return clonedPropertyInformation.getMetaDataEntries();
+ }
+
+ public boolean containsMetaDataFor(Class targetClass, String targetProperty)
+ {
+ return this.cachedPropertyInformation.containsKey(createKey(targetClass, targetProperty));
+ }
+
+ public void registerFilter(MetaDataStorageFilter storageFilter)
+ {
+ synchronized (this)
+ {
+ if(!isFilterDenied(storageFilter) && !isFilterAlreadyRegistered(storageFilter))
+ {
+ this.metaDataStorageFilters.add(storageFilter);
+ logAddedFilter(storageFilter.getClass());
+ }
+ }
+ }
+
+ private boolean isFilterDenied(MetaDataStorageFilter storageFilter)
+ {
+ return this.deniedMetaDataFilters.contains(storageFilter.getClass());
+ }
+
+ private boolean isFilterAlreadyRegistered(MetaDataStorageFilter storageFilter)
+ {
+ for(MetaDataStorageFilter filter : this.metaDataStorageFilters)
+ {
+ if(filter.getClass().equals(storageFilter.getClass()))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void deregisterFilter(Class<? extends MetaDataStorageFilter> filterClass)
+ {
+ MetaDataStorageFilter storageFilter = ClassUtils.tryToInstantiateClass(filterClass);
+
+ synchronized (this)
+ {
+ this.metaDataStorageFilters.remove(storageFilter);
+ }
+
+ logRemovedFilter(storageFilter.getClass());
+ }
+
+ public void denyFilter(Class<? extends MetaDataStorageFilter> filterClass)
+ {
+ synchronized (this)
+ {
+ for(Class<? extends MetaDataStorageFilter> filterId : this.deniedMetaDataFilters)
+ {
+ if(filterId.equals(filterClass))
+ {
+ return;
+ }
+ }
+ this.deniedMetaDataFilters.add(filterClass);
+ }
+
+ deregisterFilter(filterClass);
+ }
+
+ private String createKey(Class targetClass, String targetProperty)
+ {
+ return targetClass.getName() + "#" + targetProperty;
+ }
+
+ @ToDo(Priority.MEDIUM)
+ private void copyMetaData(PropertyInformation source, PropertyInformation target)
+ {
+ MetaDataEntry newMetaDataEntry;
+ for(MetaDataEntry metaDataEntry : source.getMetaDataEntries())
+ {
+ newMetaDataEntry = new MetaDataEntry();
+ newMetaDataEntry.setKey(metaDataEntry.getKey());
+ newMetaDataEntry.setValue(metaDataEntry.getValue());
+
+ target.addMetaDataEntry(newMetaDataEntry);
+ }
+ }
+
+ private void logAddedFilter(Class<? extends MetaDataStorageFilter> filterClass)
+ {
+ if(this.logger.isInfoEnabled())
+ {
+ this.logger.info(filterClass.getName() + " added");
+ }
+ }
+
+ private void logRemovedFilter(Class<? extends MetaDataStorageFilter> filterClass)
+ {
+ if(this.logger.isInfoEnabled())
+ {
+ this.logger.info(filterClass.getName() + " removed");
+ }
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMetaDataStorageManager.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/storage/DefaultMetaDataStorageManager.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMetaDataStorageManager.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultMetaDataStorageManager.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage;
+
+import org.apache.myfaces.extensions.validator.core.storage.mapper.DefaultMetaDataStorageNameMapper;
+
+/**
+ * default storage-manager for property information entries
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+class DefaultMetaDataStorageManager extends AbstractApplicationScopeAwareStorageManager<MetaDataStorage>
+{
+ DefaultMetaDataStorageManager()
+ {
+ register(new DefaultMetaDataStorageNameMapper());
+ }
+
+ public String getStorageManagerKey()
+ {
+ return StorageManager.class.getName() + "_FOR_META_DATA_CACHE:KEY";
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultRendererProxyStorage.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/storage/DefaultRendererProxyStorage.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultRendererProxyStorage.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultRendererProxyStorage.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import static org.apache.myfaces.extensions.validator.internal.UsageCategory.INTERNAL;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * default storage implementation for groups
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(INTERNAL)
+public class DefaultRendererProxyStorage implements RendererProxyStorage
+{
+ Map<String, Map<String, RendererProxyStorageEntry>> proxyStorage =
+ new HashMap<String, Map<String, RendererProxyStorageEntry>>();
+
+ public void setEntry(String rendererKey, String clientId, RendererProxyStorageEntry entry)
+ {
+ getRendererStorage(rendererKey).put(clientId, entry);
+ }
+
+ public boolean containsEntry(String rendererKey, String clientId)
+ {
+ return getRendererStorage(rendererKey).containsKey(clientId);
+ }
+
+ public RendererProxyStorageEntry getEntry(String rendererKey, String clientId)
+ {
+ return getRendererStorage(rendererKey).get(clientId);
+ }
+
+ private Map<String, RendererProxyStorageEntry> getRendererStorage(String rendererKey)
+ {
+ if(!proxyStorage.containsKey(rendererKey))
+ {
+ proxyStorage.put(rendererKey, new HashMap<String, RendererProxyStorageEntry>());
+ }
+
+ return proxyStorage.get(rendererKey);
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultRendererProxyStorageManager.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/storage/DefaultRendererProxyStorageManager.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultRendererProxyStorageManager.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultRendererProxyStorageManager.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage;
+
+import org.apache.myfaces.extensions.validator.core.renderkit.ExtValRendererProxy;
+import org.apache.myfaces.extensions.validator.core.storage.mapper.DefaultRendererProxyStorageNameMapper;
+
+/**
+ * default storage-manager for renderer proxy entries
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+class DefaultRendererProxyStorageManager
+ extends AbstractRequestScopeAwareStorageManager<RendererProxyStorage>
+{
+ DefaultRendererProxyStorageManager()
+ {
+ register(new DefaultRendererProxyStorageNameMapper());
+ }
+
+ public String getStorageManagerKey()
+ {
+ //for better backward compatibility
+ return ExtValRendererProxy.class.getName() + ":STORAGE";
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultStorageManagerFactory.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/storage/DefaultStorageManagerFactory.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultStorageManagerFactory.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultStorageManagerFactory.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage;
+
+import org.apache.myfaces.extensions.validator.core.factory.ClassMappingFactory;
+import org.apache.myfaces.extensions.validator.core.factory.AbstractNameMapperAwareFactory;
+import org.apache.myfaces.extensions.validator.core.mapper.NameMapper;
+import org.apache.myfaces.extensions.validator.core.initializer.configuration.StaticConfigurationNames;
+import org.apache.myfaces.extensions.validator.core.initializer.configuration.StaticConfiguration;
+import org.apache.myfaces.extensions.validator.core.initializer.configuration.StaticConfigurationEntry;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.util.ClassUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import static org.apache.myfaces.extensions.validator.internal.UsageCategory.INTERNAL;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * default implementation for storage-manager creation and caching
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(INTERNAL)
+public class DefaultStorageManagerFactory extends AbstractNameMapperAwareFactory<Class>
+ implements ClassMappingFactory<Class, StorageManager>, StorageManagerHolder
+{
+ protected final Log logger = LogFactory.getLog(getClass());
+
+ private boolean lazyStaticMappingApplied = false;
+ private List<NameMapper<Class>> nameMapperList = new ArrayList<NameMapper<Class>>();
+ private Map<Class, StorageManager> storageTypeToStorageManagerMap = new HashMap<Class, StorageManager>();
+
+ public DefaultStorageManagerFactory()
+ {
+ if(logger.isDebugEnabled())
+ {
+ logger.debug(getClass().getName() + " instantiated");
+ }
+
+ setStorageManager(RendererProxyStorage.class, new DefaultRendererProxyStorageManager(), false);
+ setStorageManager(GroupStorage.class, new DefaultGroupStorageManager(), false);
+ setStorageManager(MetaDataStorage.class, new DefaultMetaDataStorageManager(), false);
+ setStorageManager(FacesMessageStorage.class, new DefaultFacesMessageStorageManager(), false);
+
+ setStorageManager(
+ FacesInformationStorage.class, new DefaultFacesInformationStorageManager(), false);
+ }
+
+ public StorageManager create(Class storageType)
+ {
+ if (!this.lazyStaticMappingApplied)
+ {
+ initStaticMappings();
+ }
+
+ StorageManager storageManager;
+ String storageManagerName;
+ //null -> use name mappers
+ for (NameMapper<Class> nameMapper : this.nameMapperList)
+ {
+ storageManagerName = nameMapper.createName(storageType);
+
+ if (storageManagerName == null)
+ {
+ continue;
+ }
+
+ storageManager = (StorageManager)ClassUtils.tryToInstantiateClassForName(storageManagerName);
+
+ if (storageManager != null)
+ {
+ addMapping(storageType, storageManager);
+ return storageManager;
+ }
+ }
+ return getStorageManager(storageType);
+ }
+
+ private synchronized void addMapping(Class storageType, StorageManager storageManager)
+ {
+ boolean isValidEntry = true;
+ if(storageType == null)
+ {
+ isValidEntry = false;
+ if(this.logger.isErrorEnabled())
+ {
+ this.logger.error("you tried to add an invalid storage type");
+ }
+ }
+
+ if(storageManager == null)
+ {
+ isValidEntry = false;
+ if(this.logger.isErrorEnabled())
+ {
+ this.logger.error("you tried to add an invalid storage manager");
+ }
+ }
+
+ if(!isValidEntry)
+ {
+ return;
+ }
+
+ setStorageManager(storageType, storageManager, true);
+ }
+
+ private void initStaticMappings()
+ {
+ this.lazyStaticMappingApplied = true;
+
+ //setup internal static mappings
+ for (StaticConfiguration<String, String> staticConfig :
+ ExtValContext.getContext().getStaticConfiguration(
+ StaticConfigurationNames.STORAGE_TYPE_TO_STORAGE_MANAGER_CONFIG))
+ {
+ setupStrategyMappings(staticConfig.getMapping());
+ }
+ }
+
+ private void setupStrategyMappings(List<StaticConfigurationEntry<String, String>> mappings)
+ {
+ for(StaticConfigurationEntry<String, String> mapping : mappings)
+ {
+ addMapping(ClassUtils.tryToLoadClassForName(mapping.getSource()),
+ (StorageManager)ClassUtils.tryToInstantiateClassForName(mapping.getTarget()));
+ }
+ }
+
+ protected List<NameMapper<Class>> getNameMapperList()
+ {
+ return this.nameMapperList;
+ }
+
+ public void setStorageManager(Class storageType, StorageManager storageManager, boolean override)
+ {
+ if(!this.storageTypeToStorageManagerMap.containsKey(storageType) ||
+ (this.storageTypeToStorageManagerMap.containsKey(storageType) && override))
+ {
+
+ if(logger.isTraceEnabled())
+ {
+ logger.trace("adding type to storage-manager mapping: "
+ + storageType.getName() + " -> " + storageManager.getClass().getName());
+ }
+
+ this.storageTypeToStorageManagerMap.put(storageType, storageManager);
+ }
+ }
+
+ public StorageManager getStorageManager(Class type)
+ {
+ return this.storageTypeToStorageManagerMap.get(type);
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/FacesInformationStorage.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/storage/FacesInformationStorage.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/FacesInformationStorage.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/FacesInformationStorage.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import javax.faces.event.PhaseId;
+
+/**
+ * storage for additional information about the current faces request
+ * for now it just contains information about the current phase of the lifecycle
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(UsageCategory.API)
+public interface FacesInformationStorage
+{
+ void setCurrentPhaseId(PhaseId phaseId);
+
+ PhaseId getCurrentPhaseId();
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/FacesMessageStorage.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/storage/FacesMessageStorage.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/FacesMessageStorage.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/FacesMessageStorage.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.core.validation.message.FacesMessageHolder;
+
+import javax.faces.application.FacesMessage;
+import java.util.List;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(UsageCategory.API)
+public interface FacesMessageStorage
+{
+ void addFacesMessage(String clientId, FacesMessage facesMessage);
+
+ List<FacesMessageHolder> getFacesMessages();
+
+ void addAll();
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/GroupStorage.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/storage/GroupStorage.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/GroupStorage.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/GroupStorage.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+/**
+ * suggested interface for a group storage
+ * used by the bvi module and add-ons
+ * <p/>
+ * it allows to manage groups for the current request
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(UsageCategory.API)
+public interface GroupStorage
+{
+ void addGroup(Class groupClass, String viewId, String clientId);
+
+ void restrictGroup(Class groupClass, String viewId, String clientId);
+
+ Class[] getGroups(String viewId, String clientId);
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/MetaDataStorage.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/storage/MetaDataStorage.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/MetaDataStorage.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/MetaDataStorage.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
+import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(UsageCategory.API)
+public interface MetaDataStorage
+{
+ void storeMetaDataOf(PropertyInformation propertyInformation);
+
+ MetaDataEntry[] getMetaData(Class targetClass, String targetProperty);
+
+ boolean containsMetaDataFor(Class targetClass, String targetProperty);
+
+ void registerFilter(MetaDataStorageFilter storageFilter);
+
+ void deregisterFilter(Class<? extends MetaDataStorageFilter> filterClass);
+
+ void denyFilter(Class<? extends MetaDataStorageFilter> filterClass);
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/MetaDataStorageFilter.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/storage/MetaDataStorageFilter.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/MetaDataStorageFilter.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/MetaDataStorageFilter.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.core.property.PropertyInformation;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(UsageCategory.API)
+public interface MetaDataStorageFilter
+{
+ void filter(PropertyInformation propertyInformation);
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/RendererProxyStorage.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/storage/RendererProxyStorage.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/RendererProxyStorage.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/RendererProxyStorage.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import static org.apache.myfaces.extensions.validator.internal.UsageCategory.INTERNAL;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(INTERNAL)
+public interface RendererProxyStorage
+{
+ void setEntry(String rendererKey, String clientId, RendererProxyStorageEntry entry);
+
+ boolean containsEntry(String rendererKey, String clientId);
+
+ RendererProxyStorageEntry getEntry(String rendererKey, String clientId);
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/RendererProxyStorageEntry.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/storage/RendererProxyStorageEntry.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/RendererProxyStorageEntry.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/RendererProxyStorageEntry.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class RendererProxyStorageEntry
+{
+ private boolean decodeCalled = false;
+ private boolean encodeBeginCalled = false;
+ private boolean encodeChildrenCalled = false;
+ private boolean encodeEndCalled = false;
+
+ private Object convertedValue = null;
+
+ public boolean isDecodeCalled()
+ {
+ return decodeCalled;
+ }
+
+ public void setDecodeCalled(boolean decodeCalled)
+ {
+ this.decodeCalled = decodeCalled;
+ }
+
+ public boolean isEncodeBeginCalled()
+ {
+ return encodeBeginCalled;
+ }
+
+ public void setEncodeBeginCalled(boolean encodeBeginCalled)
+ {
+ this.encodeBeginCalled = encodeBeginCalled;
+ }
+
+ public boolean isEncodeChildrenCalled()
+ {
+ return encodeChildrenCalled;
+ }
+
+ public void setEncodeChildrenCalled(boolean encodeChildrenCalled)
+ {
+ this.encodeChildrenCalled = encodeChildrenCalled;
+ }
+
+ public boolean isEncodeEndCalled()
+ {
+ return encodeEndCalled;
+ }
+
+ public void setEncodeEndCalled(boolean encodeEndCalled)
+ {
+ this.encodeEndCalled = encodeEndCalled;
+ }
+
+ public Object getConvertedValue()
+ {
+ return convertedValue;
+ }
+
+ public void setConvertedValue(Object convertedValue)
+ {
+ this.convertedValue = convertedValue;
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/StorageManager.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/storage/StorageManager.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/StorageManager.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/StorageManager.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import static org.apache.myfaces.extensions.validator.internal.UsageCategory.API;
+
+/**
+ * manager to create and reset specific storage implementations
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(API)
+public interface StorageManager<T>
+{
+ T create(String key);
+ void reset(String key);
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/StorageManagerHolder.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/storage/StorageManagerHolder.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/StorageManagerHolder.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/StorageManagerHolder.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import static org.apache.myfaces.extensions.validator.internal.UsageCategory.API;
+
+/**
+ * interface to manage storage-manager instances
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(API)
+public interface StorageManagerHolder
+{
+ void setStorageManager(Class type, StorageManager storageManager, boolean override);
+ StorageManager getStorageManager(Class type);
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/ValidationResult.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/storage/ValidationResult.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/ValidationResult.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/ValidationResult.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.ToDo;
+import org.apache.myfaces.extensions.validator.internal.Priority;
+import org.apache.myfaces.extensions.validator.core.validation.message.FacesMessageHolder;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@ToDo(value = Priority.LOW, description = "refactor it")
+@UsageInformation(UsageCategory.INTERNAL)
+class ValidationResult
+{
+ private List<FacesMessageHolder> facesMessageHolderList = new ArrayList<FacesMessageHolder>();
+
+ public void addFacesMessageHolder(FacesMessageHolder facesMessageHolder)
+ {
+ this.facesMessageHolderList.add(facesMessageHolder);
+ }
+
+ public List<FacesMessageHolder> getFacesMessageHolderList()
+ {
+ return facesMessageHolderList;
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/mapper/DefaultFacesInformationStorageNameMapper.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/storage/mapper/DefaultFacesInformationStorageNameMapper.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/mapper/DefaultFacesInformationStorageNameMapper.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/mapper/DefaultFacesInformationStorageNameMapper.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage.mapper;
+
+import org.apache.myfaces.extensions.validator.core.mapper.NameMapper;
+import org.apache.myfaces.extensions.validator.core.storage.FacesInformationStorage;
+import org.apache.myfaces.extensions.validator.core.storage.DefaultFacesInformationStorage;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+
+/**
+ * use a public class to allow optional deregistration
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@InvocationOrder(100)
+public class DefaultFacesInformationStorageNameMapper implements NameMapper<String>
+{
+ public String createName(String source)
+ {
+ return (FacesInformationStorage.class.getName().equals(source)) ?
+ DefaultFacesInformationStorage.class.getName() : null;
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/mapper/DefaultFacesMessageStorageNameMapper.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/storage/mapper/DefaultFacesMessageStorageNameMapper.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/mapper/DefaultFacesMessageStorageNameMapper.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/mapper/DefaultFacesMessageStorageNameMapper.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage.mapper;
+
+import org.apache.myfaces.extensions.validator.core.mapper.NameMapper;
+import org.apache.myfaces.extensions.validator.core.storage.DefaultFacesMessageStorage;
+import org.apache.myfaces.extensions.validator.core.storage.FacesMessageStorage;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+
+/**
+ * use a public class to allow optional deregistration
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@InvocationOrder(100)
+public class DefaultFacesMessageStorageNameMapper implements NameMapper<String>
+{
+ public String createName(String source)
+ {
+ return (FacesMessageStorage.class.getName().equals(source)) ?
+ DefaultFacesMessageStorage.class.getName() : null;
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/mapper/DefaultMetaDataStorageNameMapper.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/storage/mapper/DefaultMetaDataStorageNameMapper.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/mapper/DefaultMetaDataStorageNameMapper.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/mapper/DefaultMetaDataStorageNameMapper.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage.mapper;
+
+import org.apache.myfaces.extensions.validator.core.mapper.NameMapper;
+import org.apache.myfaces.extensions.validator.core.storage.MetaDataStorage;
+import org.apache.myfaces.extensions.validator.core.storage.DefaultMetaDataStorage;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+
+/**
+ * use a public class to allow optional deregistration
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@InvocationOrder(100)
+public class DefaultMetaDataStorageNameMapper implements NameMapper<String>
+{
+ public String createName(String source)
+ {
+ return (MetaDataStorage.class.getName().equals(source)) ?
+ DefaultMetaDataStorage.class.getName() : null;
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/mapper/DefaultRendererProxyStorageNameMapper.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/storage/mapper/DefaultRendererProxyStorageNameMapper.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/mapper/DefaultRendererProxyStorageNameMapper.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/mapper/DefaultRendererProxyStorageNameMapper.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.storage.mapper;
+
+import org.apache.myfaces.extensions.validator.core.mapper.NameMapper;
+import org.apache.myfaces.extensions.validator.core.storage.DefaultRendererProxyStorage;
+import org.apache.myfaces.extensions.validator.core.storage.RendererProxyStorage;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+
+/**
+ * use a public class to allow optional deregistration
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@InvocationOrder(100)
+public class DefaultRendererProxyStorageNameMapper implements NameMapper<String>
+{
+
+ public String createName(String source)
+ {
+ return (RendererProxyStorage.class.getName().equals(source)) ?
+ DefaultRendererProxyStorage.class.getName() : null;
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/SkipValidationEvaluator.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/validation/SkipValidationEvaluator.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/SkipValidationEvaluator.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/SkipValidationEvaluator.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.validation;
+
+import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
+import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(UsageCategory.API)
+public interface SkipValidationEvaluator
+{
+ boolean skipValidation(FacesContext facesContext, UIComponent uiComponent,
+ ValidationStrategy validationStrategy, MetaDataEntry entry);
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/exception/RequiredValidatorException.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/validation/exception/RequiredValidatorException.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/exception/RequiredValidatorException.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/exception/RequiredValidatorException.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.validation.exception;
+
+import javax.faces.validator.ValidatorException;
+import javax.faces.application.FacesMessage;
+
+/**
+ * to handle special cases in ValidationExceptionInterceptors
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+public class RequiredValidatorException extends ValidatorException
+{
+ private static final long serialVersionUID = -4646331736428495884L;
+
+ public RequiredValidatorException(FacesMessage facesMessage)
+ {
+ super(facesMessage);
+ }
+
+ public RequiredValidatorException(FacesMessage facesMessage, Throwable throwable)
+ {
+ super(facesMessage, throwable);
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/message/DefaultFacesMessageFactory.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/validation/message/DefaultFacesMessageFactory.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/message/DefaultFacesMessageFactory.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/message/DefaultFacesMessageFactory.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.validation.message;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.core.factory.FacesMessageFactory;
+
+import javax.faces.application.FacesMessage;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.2
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class DefaultFacesMessageFactory implements FacesMessageFactory
+{
+ public FacesMessage convert(FacesMessage facesMessage)
+ {
+ if(isLabeledFacesMessage(facesMessage))
+ {
+ return facesMessage;
+ }
+ return create(facesMessage.getSeverity(), facesMessage.getSummary(), facesMessage.getDetail());
+ }
+
+ public FacesMessage create(FacesMessage.Severity severity, String summary, String detail)
+ {
+ return new ViolationMessage(severity, summary, detail);
+ }
+
+ protected boolean isLabeledFacesMessage(FacesMessage facesMessage)
+ {
+ //don't use the interface here
+ return facesMessage instanceof ViolationMessage;
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/message/FacesMessageHolder.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/validation/message/FacesMessageHolder.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/message/FacesMessageHolder.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/message/FacesMessageHolder.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.validation.message;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import javax.faces.application.FacesMessage;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class FacesMessageHolder
+{
+ private FacesMessage facesMessage;
+ private String clientId;
+
+ public FacesMessageHolder(FacesMessage facesMessage)
+ {
+ this.facesMessage = facesMessage;
+ }
+
+ public FacesMessageHolder(FacesMessage facesMessage, String clientId)
+ {
+ this.facesMessage = facesMessage;
+ setClientId(clientId);
+ }
+
+ public FacesMessage getFacesMessage()
+ {
+ return facesMessage;
+ }
+
+ public String getClientId()
+ {
+ return clientId;
+ }
+
+ public void setClientId(String clientId)
+ {
+ if(!"*".equals(clientId))
+ {
+ this.clientId = clientId;
+ }
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/message/LabeledMessage.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/validation/message/LabeledMessage.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/message/LabeledMessage.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/message/LabeledMessage.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.validation.message;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+/**
+ * don't remove *Text - it would lead to an overlap with trinidad
+ *
+ * @author Gerhard Petracek
+ * @since 1.x.2
+ */
+@UsageInformation(UsageCategory.API)
+public interface LabeledMessage
+{
+ String getLabelText();
+ void setLabelText(String label);
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/message/ViolationMessage.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/validation/message/ViolationMessage.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/message/ViolationMessage.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/core/src/main/java/org/apache/myfaces/extensions/validator/core/validation/message/ViolationMessage.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.core.validation.message;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import javax.faces.application.FacesMessage;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.2
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+class ViolationMessage extends FacesMessage implements LabeledMessage
+{
+ private static final long serialVersionUID = 6903958942987711231L;
+ private String label;
+ private boolean summaryLabelReplaced = false;
+ private boolean detailLabelReplaced = false;
+
+ public ViolationMessage(String summary, String detail)
+ {
+ this(SEVERITY_ERROR, summary, detail);
+ }
+
+ public ViolationMessage(Severity severity, String summary, String detail)
+ {
+ setSeverity(severity);
+ setSummary(summary);
+ setDetail(detail);
+ }
+
+ public String getLabelText()
+ {
+ return label;
+ }
+
+ public void setLabelText(String label)
+ {
+ this.label = label;
+ }
+
+ @Override
+ public String getSummary()
+ {
+ if(label != null && !this.summaryLabelReplaced)
+ {
+ setSummary(getLabeledMesssage(super.getSummary(), getLabelText()));
+ this.summaryLabelReplaced = true;
+ }
+ return super.getSummary();
+ }
+
+ @Override
+ public String getDetail()
+ {
+ if(label != null && !this.detailLabelReplaced)
+ {
+ setDetail(getLabeledMesssage(super.getDetail(), getLabelText()));
+ this.detailLabelReplaced = true;
+ }
+ return super.getDetail();
+ }
+
+ private String getLabeledMesssage(String message, String label)
+ {
+ for(int i = 0; i < 3; i++)
+ {
+ if(message != null && message.contains("{" + i + "}"))
+ {
+ message = message.replace("{" + i + "}", label);
+ }
+ }
+
+ return message;
+ }
+
+ @Override
+ public void setSummary(String s)
+ {
+ super.setSummary(s);
+ this.summaryLabelReplaced = false;
+ }
+
+ @Override
+ public void setDetail(String s)
+ {
+ super.setDetail(s);
+ this.detailLabelReplaced = false;
+ }
+}