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 2008/10/01 19:10:11 UTC
svn commit: r700842 [2/6] - in
/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger: ./
core/ core/src/ core/src/main/ core/src/main/config/ core/src/main/java/
core/src/main/java/org/ core/src/main/java/org/apache/ core/src/main/jav...
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/DefaultFactoryFinder.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/DefaultFactoryFinder.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/DefaultFactoryFinder.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/DefaultFactoryFinder.java Wed Oct 1 10:10:07 2008
@@ -0,0 +1,230 @@
+/*
+ * 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.factory;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.core.annotation.extractor.DefaultComponentAnnotationExtractorFactory;
+import org.apache.myfaces.extensions.validator.core.WebXmlParameter;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.logging.DefaultLoggerFactory;
+import org.apache.myfaces.extensions.validator.core.renderkit.DefaultRenderKitWrapperFactory;
+import org.apache.myfaces.extensions.validator.core.initializer.component.DefaultComponentInitializerFactory;
+import org.apache.myfaces.extensions.validator.core.metadata.extractor.DefaultMetaDataExtractorFactory;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.DefaultValidationStrategyFactory;
+import org.apache.myfaces.extensions.validator.core.validation.message.resolver.DefaultMessageResolverFactory;
+import org.apache.myfaces.extensions.validator.util.ClassUtils;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+//dynamic approach to create the factories during the first request, when a faces-context is available
+@UsageInformation(UsageCategory.INTERNAL)
+public class DefaultFactoryFinder implements FactoryFinder
+{
+ protected Map<FactoryNames, Object> factoryMap = new HashMap<FactoryNames, Object>();
+
+ public final <T> T getFactory(FactoryNames factoryName, Class<T> targetClass)
+ {
+ if(!(factoryMap.containsKey(factoryName)))
+ {
+ initFactory(factoryName);
+ }
+
+ return (T)factoryMap.get(factoryName);
+ }
+
+ private void initFactory(FactoryNames factoryName)
+ {
+ Object factory = null;
+ switch (factoryName)
+ {
+ case COMPONENT_ANNOTATION_EXTRACTOR_FACTORY:
+ factory = createComponentAnnotationExtractorFactory();
+ break;
+
+ case VALIDATION_STRATEGY_FACTORY:
+ factory = createValidationStrategyFactory();
+ break;
+
+ case MESSAGE_RESOLVER_FACTORY:
+ factory = createMessageResolverFactory();
+ break;
+
+ case META_DATA_EXTRACTOR_FACTORY:
+ factory = createMetaDataExtractorFactory();
+ break;
+
+ case COMPONENT_INITIALIZER_FACTORY:
+ factory = createComponentInitializerFactory();
+ break;
+
+ case RENDERKIT_WRAPPER_FACTORY:
+ factory = createRenderKitWrapperFactory();
+ break;
+
+ case LOGGER_FACTORY:
+ factory = createLoggerFactory();
+ break;
+
+ default: //required by checkstyle
+ }
+
+ if(factory == null)
+ {
+ throw new IllegalStateException("not possible to create factory " + factoryName);
+ }
+
+ factoryMap.put(factoryName, factory);
+ }
+
+ protected Object createComponentAnnotationExtractorFactory()
+ {
+ Object factory = null;
+
+ List<String> annotationExtractorFactoryClassNames = new ArrayList<String>();
+
+ annotationExtractorFactoryClassNames.add(WebXmlParameter.CUSTOM_COMPONENT_ANNOTATION_EXTRACTOR_FACTORY);
+ annotationExtractorFactoryClassNames
+ .add(ExtValContext.getContext().getInformationProviderBean()
+ .getCustomComponentAnnotationExtractorFactory());
+ annotationExtractorFactoryClassNames.add(DefaultComponentAnnotationExtractorFactory.class.getName());
+
+ for (String className : annotationExtractorFactoryClassNames)
+ {
+ factory = ClassUtils.tryToInstantiateClassForName(className);
+
+ if (factory != null)
+ {
+ break;
+ }
+ }
+ return factory;
+ }
+
+ protected Object createValidationStrategyFactory()
+ {
+ Object factory = null;
+
+ List<String> validationStrategyFactoryClassNames = new ArrayList<String>();
+
+ validationStrategyFactoryClassNames.add(WebXmlParameter.CUSTOM_VALIDATION_STRATEGY_FACTORY);
+ validationStrategyFactoryClassNames
+ .add(ExtValContext.getContext().getInformationProviderBean().getCustomValidationStrategyFactory());
+ validationStrategyFactoryClassNames.add(DefaultValidationStrategyFactory.class.getName());
+
+ for (String className : validationStrategyFactoryClassNames)
+ {
+ factory = ClassUtils.tryToInstantiateClassForName(className);
+
+ if (factory != null)
+ {
+ break;
+ }
+ }
+
+ return factory;
+ }
+
+ protected Object createMessageResolverFactory()
+ {
+ Object factory = null;
+ List<String> messageResolverFactoryClassNames = new ArrayList<String>();
+
+ messageResolverFactoryClassNames.add(WebXmlParameter.CUSTOM_MESSAGE_RESOLVER_FACTORY);
+ messageResolverFactoryClassNames
+ .add(ExtValContext.getContext().getInformationProviderBean().getCustomMessageResolverFactory());
+ messageResolverFactoryClassNames
+ .add(DefaultMessageResolverFactory.class.getName());
+
+ for (String className : messageResolverFactoryClassNames)
+ {
+ factory = ClassUtils.tryToInstantiateClassForName(className);
+
+ if (factory != null)
+ {
+ break;
+ }
+ }
+
+ return factory;
+ }
+
+ protected Object createMetaDataExtractorFactory()
+ {
+ Object factory = null;
+ List<String> metaDataExtractorFactoryClassNames = new ArrayList<String>();
+
+ metaDataExtractorFactoryClassNames.add(WebXmlParameter.CUSTOM_META_DATA_EXTRACTOR_FACTORY);
+ metaDataExtractorFactoryClassNames
+ .add(ExtValContext.getContext().getInformationProviderBean().getCustomMetaDataExtractorFactory());
+ metaDataExtractorFactoryClassNames.add(DefaultMetaDataExtractorFactory.class.getName());
+
+ for (String className : metaDataExtractorFactoryClassNames)
+ {
+ factory = ClassUtils.tryToInstantiateClassForName(className);
+
+ if (factory != null)
+ {
+ break;
+ }
+ }
+
+ return factory;
+ }
+
+ protected Object createComponentInitializerFactory()
+ {
+ Object factory = null;
+ List<String> componentInitializerFactoryClassNames = new ArrayList<String>();
+
+ componentInitializerFactoryClassNames.add(WebXmlParameter.CUSTOM_COMPONENT_INITIALIZER_FACTORY);
+ componentInitializerFactoryClassNames
+ .add(ExtValContext.getContext().getInformationProviderBean().getCustomComponentInitializerFactory());
+ componentInitializerFactoryClassNames.add(DefaultComponentInitializerFactory.class.getName());
+
+ for (String className : componentInitializerFactoryClassNames)
+ {
+ factory = ClassUtils.tryToInstantiateClassForName(className);
+
+ if (factory != null)
+ {
+ break;
+ }
+ }
+
+ return factory;
+ }
+
+ protected Object createRenderKitWrapperFactory()
+ {
+ return new DefaultRenderKitWrapperFactory();
+ }
+
+ private Object createLoggerFactory()
+ {
+ return new DefaultLoggerFactory();
+ }
+}
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/FactoryFinder.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/FactoryFinder.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/FactoryFinder.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/FactoryFinder.java Wed Oct 1 10:10:07 2008
@@ -0,0 +1,32 @@
+/*
+ * 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.factory;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.API)
+public interface FactoryFinder
+{
+ <T> T getFactory(FactoryNames factoryName, Class<T> targetClass);
+}
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/FactoryNames.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/FactoryNames.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/FactoryNames.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/factory/FactoryNames.java Wed Oct 1 10:10:07 2008
@@ -0,0 +1,34 @@
+/*
+ * 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.factory;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+public enum FactoryNames
+{
+ COMPONENT_ANNOTATION_EXTRACTOR_FACTORY,
+ VALIDATION_STRATEGY_FACTORY,
+ MESSAGE_RESOLVER_FACTORY,
+ META_DATA_EXTRACTOR_FACTORY,
+ COMPONENT_INITIALIZER_FACTORY,
+ RENDERKIT_WRAPPER_FACTORY,
+ LOGGER_FACTORY
+}
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/ComponentInitializer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/ComponentInitializer.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/ComponentInitializer.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/ComponentInitializer.java Wed Oct 1 10:10:07 2008
@@ -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.initializer.component;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import java.util.Map;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.API)
+public interface ComponentInitializer
+{
+ void configureComponent(FacesContext facesContext, UIComponent uiComponent, Map<String, Object> metaData);
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/DefaultComponentInitializer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/DefaultComponentInitializer.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/DefaultComponentInitializer.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/DefaultComponentInitializer.java Wed Oct 1 10:10:07 2008
@@ -0,0 +1,57 @@
+/*
+ * 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.initializer.component;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.util.LogUtils;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class DefaultComponentInitializer implements ComponentInitializer
+{
+ private static List<ComponentInitializer> componentInitializers = new ArrayList<ComponentInitializer>();
+
+ public void configureComponent(FacesContext facesContext, UIComponent uiComponent, Map<String, Object> metaData)
+ {
+ for(ComponentInitializer componentInitializer : componentInitializers)
+ {
+ componentInitializer.configureComponent(facesContext, uiComponent, metaData);
+ LogUtils.trace("configureComponent of " + componentInitializer.getClass().getName() + " called",getClass());
+ }
+ }
+
+ @UsageInformation(UsageCategory.INTERNAL)
+ public static void addComponentInitializer(ComponentInitializer componentInitializer)
+ {
+ synchronized (DefaultComponentInitializer.class)
+ {
+ componentInitializers.add(componentInitializer);
+ }
+ }
+}
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/DefaultComponentInitializerFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/DefaultComponentInitializerFactory.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/DefaultComponentInitializerFactory.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/initializer/component/DefaultComponentInitializerFactory.java Wed Oct 1 10:10:07 2008
@@ -0,0 +1,85 @@
+/*
+ * 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.initializer.component;
+
+import org.apache.myfaces.extensions.validator.core.mapper.ClassMappingFactory;
+import org.apache.myfaces.extensions.validator.core.WebXmlParameter;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.util.ClassUtils;
+import org.apache.myfaces.extensions.validator.util.LogUtils;
+
+import javax.faces.component.UIComponent;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation({UsageCategory.INTERNAL, UsageCategory.CUSTOMIZABLE})
+public class DefaultComponentInitializerFactory implements
+ ClassMappingFactory<UIComponent, ComponentInitializer>
+{
+ private static Map<String, ComponentInitializer> componentToComponentInitializerMapping
+ = new HashMap<String, ComponentInitializer>();
+ private static List<String> componentInitializerClassNames = new ArrayList<String>();
+
+ static
+ {
+ componentInitializerClassNames
+ .add(WebXmlParameter.CUSTOM_COMPONENT_INITIALIZER);
+ componentInitializerClassNames
+ .add(ExtValContext.getContext().getInformationProviderBean().getCustomComponentInitializer());
+ componentInitializerClassNames
+ .add(DefaultComponentInitializer.class.getName());
+ }
+
+ public ComponentInitializer create(UIComponent uiComponent)
+ {
+ String componentKey = uiComponent.getClass().getName();
+
+ if (componentToComponentInitializerMapping.containsKey(componentKey))
+ {
+ return componentToComponentInitializerMapping.get(componentKey);
+ }
+
+ ComponentInitializer componentInitializer;
+
+ for (String componentInitializerName : componentInitializerClassNames)
+ {
+ componentInitializer =
+ (ComponentInitializer) ClassUtils.tryToInstantiateClassForName(componentInitializerName);
+
+ if (componentInitializer != null)
+ {
+ componentToComponentInitializerMapping.put(componentKey, componentInitializer);
+
+ LogUtils.trace(componentInitializer.getClass().getName() + " used for " + componentKey, getClass());
+
+ return componentInitializer;
+ }
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/AbstractRendererInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/AbstractRendererInterceptor.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/AbstractRendererInterceptor.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/AbstractRendererInterceptor.java Wed Oct 1 10:10:07 2008
@@ -0,0 +1,95 @@
+/*
+ * 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.interceptor;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+import javax.faces.convert.ConverterException;
+import javax.faces.render.Renderer;
+import java.io.IOException;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public abstract class AbstractRendererInterceptor implements RendererInterceptor
+{
+ public final String getInterceptorId()
+ {
+ return getClass().getName();
+ }
+
+ /*
+ * before
+ */
+ public void beforeDecode(FacesContext facesContext, UIComponent uiComponent, Renderer wrapped)
+ {
+ }
+
+ public void beforeEncodeBegin(FacesContext facesContext, UIComponent uiComponent, Renderer wrapped)
+ throws IOException
+ {
+ }
+
+ public void beforeEncodeChildren(FacesContext facesContext, UIComponent uiComponent, Renderer wrapped)
+ throws IOException
+ {
+ }
+
+ public void beforeEncodeEnd(FacesContext facesContext, UIComponent uiComponent, Renderer wrapped)
+ throws IOException
+ {
+ }
+
+ public void beforeGetConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object o, Renderer wrapped)
+ throws ConverterException
+ {
+ }
+
+ /*
+ * after
+ */
+ public void afterDecode(FacesContext facesContext, UIComponent uiComponent, Renderer wrapped)
+ {
+ }
+
+ public void afterEncodeBegin(FacesContext facesContext, UIComponent uiComponent, Renderer wrapped)
+ throws IOException
+ {
+ }
+
+ public void afterEncodeChildren(FacesContext facesContext, UIComponent uiComponent, Renderer wrapped)
+ throws IOException
+ {
+ }
+
+ public void afterEncodeEnd(FacesContext facesContext, UIComponent uiComponent, Renderer wrapped)
+ throws IOException
+ {
+ }
+
+ public void afterGetConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object o, Renderer wrapped)
+ throws ConverterException
+ {
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/RendererInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/RendererInterceptor.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/RendererInterceptor.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/RendererInterceptor.java Wed Oct 1 10:10:07 2008
@@ -0,0 +1,71 @@
+/*
+ * 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.interceptor;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+import javax.faces.convert.ConverterException;
+import javax.faces.render.Renderer;
+import java.io.IOException;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.API)
+public interface RendererInterceptor
+{
+ String getInterceptorId();
+ /*
+ * before
+ */
+ void beforeDecode(FacesContext facesContext, UIComponent uiComponent, Renderer renderer);
+
+ void beforeEncodeBegin(FacesContext facesContext, UIComponent uiComponent, Renderer renderer)
+ throws IOException;
+
+ void beforeEncodeChildren(FacesContext facesContext, UIComponent uiComponent, Renderer renderer)
+ throws IOException;
+
+ void beforeEncodeEnd(FacesContext facesContext, UIComponent uiComponent, Renderer renderer)
+ throws IOException;
+
+ void beforeGetConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object o, Renderer renderer)
+ throws ConverterException;
+
+ /*
+ * after
+ */
+ void afterDecode(FacesContext facesContext, UIComponent uiComponent, Renderer renderer);
+
+ void afterEncodeBegin(FacesContext facesContext, UIComponent uiComponent, Renderer renderer)
+ throws IOException;
+
+ void afterEncodeChildren(FacesContext facesContext, UIComponent uiComponent, Renderer renderer)
+ throws IOException;
+
+ void afterEncodeEnd(FacesContext facesContext, UIComponent uiComponent, Renderer renderer)
+ throws IOException;
+
+ void afterGetConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object o, Renderer renderer)
+ throws ConverterException;
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/ValidationInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/ValidationInterceptor.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/ValidationInterceptor.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/interceptor/ValidationInterceptor.java Wed Oct 1 10:10:07 2008
@@ -0,0 +1,153 @@
+/*
+ * 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.interceptor;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
+import org.apache.myfaces.extensions.validator.core.metadata.extractor.MetaDataExtractor;
+import org.apache.myfaces.extensions.validator.core.annotation.extractor.AnnotationExtractor;
+import org.apache.myfaces.extensions.validator.core.annotation.extractor.AnnotationExtractorFactory;
+import org.apache.myfaces.extensions.validator.core.annotation.AnnotationEntry;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.factory.FactoryNames;
+import org.apache.myfaces.extensions.validator.core.recorder.ProcessedInformationRecorder;
+import org.apache.myfaces.extensions.validator.util.LogUtils;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.convert.ConverterException;
+import javax.faces.render.Renderer;
+import java.io.IOException;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class ValidationInterceptor extends AbstractRendererInterceptor
+{
+ @Override
+ public void beforeEncodeBegin(FacesContext facesContext, UIComponent uiComponent, Renderer wrapped)
+ throws IOException
+ {
+ initComponent(facesContext, uiComponent);
+ }
+
+ protected void initComponent(FacesContext facesContext, UIComponent uiComponent)
+ {
+ if(!(uiComponent instanceof EditableValueHolder))
+ {
+ return;
+ }
+
+ LogUtils.trace("start to init component " + uiComponent.getClass().getName(), getClass());
+
+ ValidationStrategy validationStrategy;
+ MetaDataExtractor metaDataExtractor;
+
+ AnnotationExtractor annotationExtractor = ExtValContext.getContext().getFactoryFinder().getFactory(
+ FactoryNames.COMPONENT_ANNOTATION_EXTRACTOR_FACTORY, AnnotationExtractorFactory.class).create();
+
+ Map<String, Object> metaData;
+ for (AnnotationEntry entry : annotationExtractor.extractAnnotations(facesContext, uiComponent))
+ {
+
+ validationStrategy = ExtValUtils.getValidationStrategyForAnnotation(entry.getAnnotation());
+
+ if (validationStrategy != null)
+ {
+ metaDataExtractor = ExtValUtils.getMetaDataExtractorForValidationStrategy(validationStrategy);
+
+ if(metaDataExtractor != null)
+ {
+ metaData = metaDataExtractor.extractMetaData(entry.getAnnotation());
+ }
+ else
+ {
+ metaData = null;
+ }
+
+ if(metaData == null)
+ {
+ metaData = new HashMap<String, Object>();
+ }
+
+ //get component initializer for the current component and configure it
+ ExtValUtils.configureComponentWithMetaData(facesContext, uiComponent, metaData);
+ }
+ }
+
+ LogUtils.trace("init component of " + uiComponent.getClass().getName() + " finished", getClass());
+ }
+
+ @Override
+ public void beforeGetConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object o, Renderer wrapped)
+ throws ConverterException
+ {
+ Object convertedObject = wrapped.getConvertedValue(facesContext, uiComponent, o);
+
+ //recorde user input e.g. for cross-component validation
+ for(ProcessedInformationRecorder recorder : ExtValContext.getContext().getProcessedInformationRecorders())
+ {
+ recorder.recordUserInput(uiComponent, convertedObject);
+
+ LogUtils.trace(recorder.getClass().getName() + " called", getClass());
+ }
+
+ processValidation(facesContext, uiComponent, convertedObject);
+ }
+
+ protected void processValidation(FacesContext facesContext, UIComponent uiComponent, Object convertedObject)
+ {
+ if (!(uiComponent instanceof EditableValueHolder))
+ {
+ return;
+ }
+ LogUtils.trace("start validation", getClass());
+
+ ValidationStrategy validationStrategy;
+
+ AnnotationExtractor annotationExtractor = ExtValUtils.getAnnotationExtractor();
+
+ for (AnnotationEntry entry : annotationExtractor.extractAnnotations(facesContext, uiComponent))
+ {
+ validationStrategy = ExtValUtils.getValidationStrategyForAnnotation(entry.getAnnotation());
+
+ if (validationStrategy != null)
+ {
+ LogUtils.trace("validate " + entry.getAnnotation().getClass().getName() + " with " +
+ validationStrategy.getClass().getName(), getClass());
+
+ validationStrategy.validate(facesContext, uiComponent, entry, convertedObject);
+ }
+ else
+ {
+ LogUtils.trace("no validation strategy found for " + entry.getAnnotation().annotationType().getName(),
+ getClass());
+ }
+ }
+
+ LogUtils.trace("validation finished", getClass());
+ }
+}
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/AbstractLoggerFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/AbstractLoggerFactory.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/AbstractLoggerFactory.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/AbstractLoggerFactory.java Wed Oct 1 10:10:07 2008
@@ -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.logging;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.core.mapper.ClassMappingFactory;
+
+/**
+ * to inject a custom logger factory use:
+ * ExtValContext.getContext().getFactoryFinder()
+ * .getFactory(FactoryNames.LOGGER_FACTORY, AbstractLoggerFactory.class)
+ * .setCustomLoggerFactory(new CustomLoggerFactory());
+ * e.g. via a startup-listener - see AbstractStartupListener
+ *
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.API)
+public abstract class AbstractLoggerFactory implements ClassMappingFactory<Class, Logger>
+{
+ protected AbstractLoggerFactory customLoggerFactory;
+
+ public void setCustomLoggerFactory(AbstractLoggerFactory loggerFactory)
+ {
+ this.customLoggerFactory = loggerFactory;
+ }
+
+ public final Logger create(Class targetClass)
+ {
+ Logger result = null;
+
+ if(this.customLoggerFactory != null)
+ {
+ result = this.customLoggerFactory.createLogger(targetClass);
+ }
+
+ if(result == null)
+ {
+ return createLogger(targetClass);
+ }
+
+ return result;
+ }
+
+ protected abstract Logger createLogger(Class targetClass);
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/DefaultLoggerFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/DefaultLoggerFactory.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/DefaultLoggerFactory.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/DefaultLoggerFactory.java Wed Oct 1 10:10:07 2008
@@ -0,0 +1,54 @@
+/*
+ * 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.logging;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.util.ELUtils;
+
+import javax.faces.context.FacesContext;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class DefaultLoggerFactory extends AbstractLoggerFactory
+{
+ private Map<Class, Logger> classToLoggerMapping = new HashMap<Class, Logger>();
+
+ protected Logger createLogger(Class targetClass)
+ {
+ Logger customLogger = null;
+
+ if(FacesContext.getCurrentInstance() != null)
+ {
+ customLogger = (Logger) ELUtils.getValueOfExpression(FacesContext.getCurrentInstance(),
+ "#{customExtValLoggerAdapter}");
+ }
+
+ if(!this.classToLoggerMapping.containsKey(targetClass))
+ {
+ this.classToLoggerMapping.put(targetClass, customLogger);
+ }
+ return new LoggerWrapper(customLogger);
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/Level.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/Level.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/Level.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/Level.java Wed Oct 1 10:10:07 2008
@@ -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.logging;
+
+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.API)
+public enum Level
+{
+ TRACE,
+ DEBUG,
+ INFO,
+ WARN,
+ ERROR,
+ FATAL
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/Logger.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/Logger.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/Logger.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/Logger.java Wed Oct 1 10:10:07 2008
@@ -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.logging;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.API)
+public interface Logger
+{
+ void log(Level level, String message);
+ void log(Level level, String message, Throwable throwable);
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/LoggerWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/LoggerWrapper.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/LoggerWrapper.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/logging/LoggerWrapper.java Wed Oct 1 10:10:07 2008
@@ -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.logging;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class LoggerWrapper implements Logger
+{
+ private Logger logger;
+ private static java.util.logging.Logger jdkLogger;
+
+ public LoggerWrapper(Logger logger)
+ {
+ this.logger = logger;
+
+ if(jdkLogger == null)
+ {
+ jdkLogger = java.util.logging.Logger.getLogger(LoggerWrapper.class.getName());
+
+ //log this warning just once
+ if(this.logger == null)
+ {
+ jdkLogger.logp(java.util.logging.Level.WARNING, LoggerWrapper.class.getName(), "LoggerWrapper()",
+ "no logger attached - e.g.: for commons logging please use the commons-logging-support module");
+ }
+ }
+ }
+
+ public void log(Level level, String message)
+ {
+ log(level, message, null);
+ }
+
+ public void log(Level level, String message, Throwable throwable)
+ {
+ if(this.logger != null)
+ {
+ this.logger.log(level, message, throwable);
+ }
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/mapper/AbstractCustomNameMapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/mapper/AbstractCustomNameMapper.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/mapper/AbstractCustomNameMapper.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/mapper/AbstractCustomNameMapper.java Wed Oct 1 10:10:07 2008
@@ -0,0 +1,54 @@
+/*
+ * 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.mapper;
+
+import org.apache.myfaces.extensions.validator.util.ClassUtils;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+/**
+ * A generic implementation. Subclasses just have to now the fully qualified name of the name mapper.
+ *
+ * NameMappers are stateless.
+ *
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.REUSE)
+public abstract class AbstractCustomNameMapper<T> implements NameMapper<T>
+{
+ private NameMapper<T> customNameMapper;
+
+ public String createName(T source)
+ {
+ if (customNameMapper == null)
+ {
+ String className = getCustomNameMapperClassName();
+
+ if (className != null)
+ {
+ customNameMapper = (NameMapper<T>) ClassUtils.tryToInstantiateClassForName(className);
+ }
+ }
+
+ return (customNameMapper != null) ? customNameMapper.createName(source) : null;
+ }
+
+ protected abstract String getCustomNameMapperClassName();
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/mapper/ClassMappingFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/mapper/ClassMappingFactory.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/mapper/ClassMappingFactory.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/mapper/ClassMappingFactory.java Wed Oct 1 10:10:07 2008
@@ -0,0 +1,32 @@
+/*
+ * 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.mapper;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.API)
+public interface ClassMappingFactory<P, R>
+{
+ R create(P source);
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/mapper/NameMapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/mapper/NameMapper.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/mapper/NameMapper.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/mapper/NameMapper.java Wed Oct 1 10:10:07 2008
@@ -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.mapper;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+
+/**
+ * Interface for name mappers.
+ * A name mapper calculates a name for a given source object.
+ * e.g. Annotation -> ValidationStrategy
+ *
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.API)
+public interface NameMapper<T>
+{
+ String createName(T source);
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/CommonMetaDataKeys.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/CommonMetaDataKeys.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/CommonMetaDataKeys.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/CommonMetaDataKeys.java Wed Oct 1 10:10:07 2008
@@ -0,0 +1,45 @@
+/*
+ * 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.metadata;
+
+/**
+ * helper for frequent meta-data keys
+ *
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+/*
+ * placed in core to avoid duplicated information in multiple modules (validation module and component-support module)
+ */
+public interface CommonMetaDataKeys
+{
+ static final String REQUIRED = "required";
+
+ static final String MIN_LENGTH = "min_length";
+ static final String MAX_LENGTH = "max_length";
+
+ static final String RANGE_MIN = "range_min";
+ static final String RANGE_MAX = "range_max";
+
+ static final String PATTERN = "pattern";
+ static final String PATTERN_VALIDATION_ERROR_MESSAGE = "pattern_validation_error_message";
+ static final String EMAIL = "email";
+
+ static final String CUSTOM = "custom";
+}
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/BeanMetaDataExtractorAdapter.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/BeanMetaDataExtractorAdapter.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/BeanMetaDataExtractorAdapter.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/BeanMetaDataExtractorAdapter.java Wed Oct 1 10:10:07 2008
@@ -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.metadata.extractor;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+
+/**
+ * it's just a helper for proxies - you just need it, if you define the equivalent validation strategy as bean and
+ * e.g. spring creates a proxy for it.
+ *
+ * if there is also a proxy for the extractor you can use the className property to manually repeat the
+ * full qualified class name.
+ *
+ * @see org.apache.myfaces.extensions.validator.core.validation.strategy.BeanValidationStrategyAdapter
+ *
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation({UsageCategory.REUSE})
+public interface BeanMetaDataExtractorAdapter extends MetaDataExtractor
+{
+ String getMetaDataExtractorClassName();
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/BeanMetaDataExtractorAdapterImpl.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/BeanMetaDataExtractorAdapterImpl.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/BeanMetaDataExtractorAdapterImpl.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/BeanMetaDataExtractorAdapterImpl.java Wed Oct 1 10:10:07 2008
@@ -0,0 +1,81 @@
+/*
+ * 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.metadata.extractor;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+
+import java.util.Map;
+import java.lang.annotation.Annotation;
+
+/**
+ * it's just a helper for proxies - you just need it, if you define the equivalent validation strategy as bean and
+ * e.g. spring creates a proxy for it.
+ *
+ * if there is also a proxy for the extractor you can use the className property to manually repeat the
+ * full qualified class name.
+ *
+ * @see org.apache.myfaces.extensions.validator.core.validation.strategy.BeanValidationStrategyAdapter
+ *
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation({UsageCategory.REUSE})
+public class BeanMetaDataExtractorAdapterImpl implements BeanMetaDataExtractorAdapter
+{
+ private MetaDataExtractor metaDataExtractor;
+ private String metaDataExtractorClassName;
+
+ public Map<String, Object> extractMetaData(Annotation annotation)
+ {
+ return this.metaDataExtractor.extractMetaData(annotation);
+ }
+
+ public String getMetaDataExtractorClassName()
+ {
+ if(metaDataExtractorClassName != null)
+ {
+ return metaDataExtractorClassName;
+ }
+ if(metaDataExtractor.getClass().getPackage() != null)
+ {
+ metaDataExtractor.getClass();
+ }
+
+ return null;
+ }
+
+ /*
+ * generated
+ */
+ public void setMetaDataExtractorClassName(String metaDataExtractorClassName)
+ {
+ this.metaDataExtractorClassName = metaDataExtractorClassName;
+ }
+
+ public MetaDataExtractor getMetaDataExtractor()
+ {
+ return metaDataExtractor;
+ }
+
+ public void setMetaDataExtractor(MetaDataExtractor metaDataExtractor)
+ {
+ this.metaDataExtractor = metaDataExtractor;
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/DefaultMetaDataExtractorFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/DefaultMetaDataExtractorFactory.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/DefaultMetaDataExtractorFactory.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/DefaultMetaDataExtractorFactory.java Wed Oct 1 10:10:07 2008
@@ -0,0 +1,128 @@
+/*
+ * 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.metadata.extractor;
+
+import org.apache.myfaces.extensions.validator.core.mapper.ClassMappingFactory;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.BeanValidationStrategyAdapter;
+import org.apache.myfaces.extensions.validator.core.metadata.extractor.mapper
+ .CustomConfiguredValidationStrategyToMetaDataExtractorNameMapper;
+import org.apache.myfaces.extensions.validator.core.metadata.extractor.mapper
+ .CustomConventionValidationStrategyToMetaDataExtractorNameMapper;
+import org.apache.myfaces.extensions.validator.core.metadata.extractor.mapper
+ .DefaultValidationStrategyToMetaDataExtractorNameMapper;
+import org.apache.myfaces.extensions.validator.core.metadata.extractor.mapper
+ .SimpleValidationStrategyToMetaDataExtractorNameMapper;
+import org.apache.myfaces.extensions.validator.core.metadata.extractor.mapper
+ .BeanValidationStrategyToMetaDataExtractorNameMapper;
+import org.apache.myfaces.extensions.validator.core.mapper.NameMapper;
+import org.apache.myfaces.extensions.validator.util.ClassUtils;
+import org.apache.myfaces.extensions.validator.util.LogUtils;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * Factory which creates the MetaDataExtractor for a given ValidationStrategy
+ *
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+/*
+ * ValidationStrategy -> MetaDataExtractor instead of Annotation -> MetaDataExtractor
+ * to avoid a second static mapping e.g. for jpa annotations
+ */
+@UsageInformation({UsageCategory.INTERNAL, UsageCategory.CUSTOMIZABLE})
+public class DefaultMetaDataExtractorFactory implements
+ ClassMappingFactory<ValidationStrategy, MetaDataExtractor>
+{
+ private static Map<String, String> validationStrategyToMetaDataExtractorMapping = new HashMap<String, String>();
+ private static List<NameMapper<ValidationStrategy>> nameMapperList
+ = new ArrayList<NameMapper<ValidationStrategy>>();
+
+ static
+ {
+ nameMapperList
+ .add(new CustomConfiguredValidationStrategyToMetaDataExtractorNameMapper());
+ nameMapperList
+ .add(new CustomConventionValidationStrategyToMetaDataExtractorNameMapper());
+ nameMapperList
+ .add(new DefaultValidationStrategyToMetaDataExtractorNameMapper());
+ nameMapperList
+ .add(new SimpleValidationStrategyToMetaDataExtractorNameMapper());
+ nameMapperList
+ .add(new BeanValidationStrategyToMetaDataExtractorNameMapper());
+ }
+
+ public MetaDataExtractor create(ValidationStrategy validationStrategy)
+ {
+ String validationStrategyName = null;
+
+ //proxy check
+ if(validationStrategy.getClass().getPackage() != null)
+ {
+ validationStrategyName = validationStrategy.getClass().getName();
+ }
+ //in case of a proxy and the usage of a BeanValidationStrategyAdapter
+ else if (validationStrategy instanceof BeanValidationStrategyAdapter)
+ {
+ validationStrategyName = ((BeanValidationStrategyAdapter)validationStrategy)
+ .getValidationStrategyClassName();
+ }
+
+ if (validationStrategyToMetaDataExtractorMapping.containsKey(validationStrategyName))
+ {
+ return (MetaDataExtractor)ClassUtils.tryToInstantiateClassForName(
+ validationStrategyToMetaDataExtractorMapping.get(validationStrategyName));
+ }
+
+ MetaDataExtractor metaDataExtractor;
+ String extractorName;
+ //null -> use name mappers
+ for (NameMapper<ValidationStrategy> nameMapper : nameMapperList)
+ {
+ extractorName = nameMapper.createName(validationStrategy);
+
+ if (extractorName == null)
+ {
+ continue;
+ }
+
+ metaDataExtractor = (MetaDataExtractor)ClassUtils.tryToInstantiateClassForName(extractorName);
+
+ if (metaDataExtractor != null)
+ {
+ if(validationStrategyName != null)
+ {
+ validationStrategyToMetaDataExtractorMapping.put(validationStrategyName, extractorName);
+
+ LogUtils.trace(extractorName + " used for " + validationStrategyName , getClass());
+ }
+ return metaDataExtractor;
+ }
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/MetaDataExtractor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/MetaDataExtractor.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/MetaDataExtractor.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/MetaDataExtractor.java Wed Oct 1 10:10:07 2008
@@ -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.metadata.extractor;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.API)
+public interface MetaDataExtractor
+{
+ Map<String, Object> extractMetaData(Annotation annotation);
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/mapper/BeanValidationStrategyToMetaDataExtractorNameMapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/mapper/BeanValidationStrategyToMetaDataExtractorNameMapper.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/mapper/BeanValidationStrategyToMetaDataExtractorNameMapper.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/mapper/BeanValidationStrategyToMetaDataExtractorNameMapper.java Wed Oct 1 10:10:07 2008
@@ -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.metadata.extractor.mapper;
+
+import org.apache.myfaces.extensions.validator.core.mapper.NameMapper;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.BeanValidationStrategyAdapter;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+/**
+ * It's an alternative Mapper - if there is a proxy around the validation strategy.
+ *
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation({UsageCategory.INTERNAL, UsageCategory.ALTERNATIVE})
+public class BeanValidationStrategyToMetaDataExtractorNameMapper implements NameMapper<ValidationStrategy>
+{
+ public String createName(ValidationStrategy validationStrategy)
+ {
+ if(validationStrategy instanceof BeanValidationStrategyAdapter)
+ {
+ return ((BeanValidationStrategyAdapter)validationStrategy).getMetaDataExtractorClassName();
+ }
+ return null;
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/mapper/CustomConfiguredValidationStrategyToMetaDataExtractorNameMapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/mapper/CustomConfiguredValidationStrategyToMetaDataExtractorNameMapper.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/mapper/CustomConfiguredValidationStrategyToMetaDataExtractorNameMapper.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/mapper/CustomConfiguredValidationStrategyToMetaDataExtractorNameMapper.java Wed Oct 1 10:10:07 2008
@@ -0,0 +1,42 @@
+/*
+ * 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.metadata.extractor.mapper;
+
+import org.apache.myfaces.extensions.validator.core.WebXmlParameter;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
+import org.apache.myfaces.extensions.validator.core.mapper.AbstractCustomNameMapper;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+/**
+ * To provide a custom NameMapper to map ValidationStrategies to MetaDataExtractors.
+ * (configured via web.xml)
+ *
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation({UsageCategory.INTERNAL, UsageCategory.CUSTOMIZABLE})
+public class CustomConfiguredValidationStrategyToMetaDataExtractorNameMapper extends
+ AbstractCustomNameMapper<ValidationStrategy>
+{
+ protected String getCustomNameMapperClassName()
+ {
+ return WebXmlParameter.CUSTOM_VALIDATION_STRATEGY_TO_META_DATA_EXTRACTOR_NAME_MAPPER;
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/mapper/CustomConventionValidationStrategyToMetaDataExtractorNameMapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/mapper/CustomConventionValidationStrategyToMetaDataExtractorNameMapper.java?rev=700842&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/mapper/CustomConventionValidationStrategyToMetaDataExtractorNameMapper.java (added)
+++ myfaces/extensions/validator/branches/trunk_core_with_pluggable_logger/core/src/main/java/org/apache/myfaces/extensions/validator/core/metadata/extractor/mapper/CustomConventionValidationStrategyToMetaDataExtractorNameMapper.java Wed Oct 1 10:10:07 2008
@@ -0,0 +1,45 @@
+/*
+ * 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.metadata.extractor.mapper;
+
+import org.apache.myfaces.extensions.validator.core.mapper.AbstractCustomNameMapper;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+/**
+ * To provide a custom NameMapper to map ValidationStrategies to MetaDataExtractors.
+ * (configured via information provider bean)
+ * The bean provides the default name (convention).
+ * It's possible to provide a custom full qualified name. (= customizable convention)
+ *
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation({UsageCategory.INTERNAL, UsageCategory.CUSTOMIZABLE})
+public class CustomConventionValidationStrategyToMetaDataExtractorNameMapper extends
+ AbstractCustomNameMapper<ValidationStrategy>
+{
+ protected String getCustomNameMapperClassName()
+ {
+ return ExtValContext.getContext().getInformationProviderBean()
+ .getCustomValidationStrategyToMetaDataExtractorNameMapper();
+ }
+}
\ No newline at end of file