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 2010/01/04 12:35:05 UTC

svn commit: r895602 - in /myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core: ./ storage/ storage/mapper/

Author: gpetracek
Date: Mon Jan  4 11:35:05 2010
New Revision: 895602

URL: http://svn.apache.org/viewvc?rev=895602&view=rev
Log:
EXTVAL-44 minor improvements

Added:
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultViolationSeverityInterpreterStorage.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultViolationSeverityInterpreterStorageManager.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/ViolationSeverityInterpreterStorage.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/mapper/DefaultViolationSeverityInterpreterStorageNameMapper.java
Modified:
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContext.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContextInternals.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultStorageManagerFactory.java

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContext.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContext.java?rev=895602&r1=895601&r2=895602&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContext.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContext.java Mon Jan  4 11:35:05 2010
@@ -124,6 +124,14 @@
 
     public ViolationSeverityInterpreter getViolationSeverityInterpreter()
     {
+        ViolationSeverityInterpreter requestScopedInterpreter = this.contextHelper
+                .getRequestScopedViolationSeverityInterpreter();
+
+        if(requestScopedInterpreter != null)
+        {
+            return requestScopedInterpreter;
+        }
+
         return this.violationSeverityInterpreter;
     }
 

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContextInternals.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContextInternals.java?rev=895602&r1=895601&r2=895602&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContextInternals.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValContextInternals.java Mon Jan  4 11:35:05 2010
@@ -18,6 +18,8 @@
  */
 package org.apache.myfaces.extensions.validator.core;
 
+import org.apache.myfaces.extensions.validator.core.storage.ViolationSeverityInterpreterStorage;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ViolationSeverityInterpreter;
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 import org.apache.myfaces.extensions.validator.util.ClassUtils;
@@ -92,4 +94,11 @@
         }
         return bean;
     }
+
+    ViolationSeverityInterpreter getRequestScopedViolationSeverityInterpreter()
+    {
+        return ExtValUtils.getStorage(
+                ViolationSeverityInterpreterStorage.class, ViolationSeverityInterpreterStorage.class.getName())
+                .getViolationSeverityInterpreter();
+    }
 }
\ No newline at end of file

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultStorageManagerFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultStorageManagerFactory.java?rev=895602&r1=895601&r2=895602&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultStorageManagerFactory.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultStorageManagerFactory.java Mon Jan  4 11:35:05 2010
@@ -71,6 +71,8 @@
                 new DefaultPropertyStorageManager(), false);
         setStorageManager(RendererInterceptorPropertyStorage.class,
                 new DefaultRendererInterceptorPropertyStorageManager(), false);
+        setStorageManager(ViolationSeverityInterpreterStorage.class,
+                new DefaultViolationSeverityInterpreterStorageManager(), false);
 
         setStorageManager(
                 FacesInformationStorage.class, new DefaultFacesInformationStorageManager(), false);

Added: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultViolationSeverityInterpreterStorage.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultViolationSeverityInterpreterStorage.java?rev=895602&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultViolationSeverityInterpreterStorage.java (added)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultViolationSeverityInterpreterStorage.java Mon Jan  4 11:35:05 2010
@@ -0,0 +1,47 @@
+/*
+ * 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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.extensions.validator.core.validation.parameter.ViolationSeverityInterpreter;
+import static org.apache.myfaces.extensions.validator.internal.UsageCategory.INTERNAL;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(INTERNAL)
+public class DefaultViolationSeverityInterpreterStorage implements ViolationSeverityInterpreterStorage
+{
+    protected final Log logger = LogFactory.getLog(getClass());
+
+    private ViolationSeverityInterpreter violationSeverityInterpreter;
+
+    public void setViolationSeverityInterpreter(ViolationSeverityInterpreter violationSeverityInterpreter)
+    {
+        this.violationSeverityInterpreter = violationSeverityInterpreter;
+    }
+
+    public ViolationSeverityInterpreter getViolationSeverityInterpreter()
+    {
+        return this.violationSeverityInterpreter;
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultViolationSeverityInterpreterStorageManager.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultViolationSeverityInterpreterStorageManager.java?rev=895602&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultViolationSeverityInterpreterStorageManager.java (added)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/DefaultViolationSeverityInterpreterStorageManager.java Mon Jan  4 11:35:05 2010
@@ -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.core.storage.mapper.DefaultViolationSeverityInterpreterStorageNameMapper;
+
+/**
+ * default storage-manager for a custom ViolationSeverityInterpreter
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+class DefaultViolationSeverityInterpreterStorageManager extends
+        AbstractRequestScopeAwareStorageManager<ViolationSeverityInterpreterStorage>
+{
+    DefaultViolationSeverityInterpreterStorageManager()
+    {
+        register(new DefaultViolationSeverityInterpreterStorageNameMapper());
+    }
+
+    public String getStorageManagerKey()
+    {
+        return StorageManager.class.getName() + "_FOR_VIOLATIONSEVERITY_INTERPRETER:KEY";
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/ViolationSeverityInterpreterStorage.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/ViolationSeverityInterpreterStorage.java?rev=895602&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/ViolationSeverityInterpreterStorage.java (added)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/ViolationSeverityInterpreterStorage.java Mon Jan  4 11:35:05 2010
@@ -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.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.parameter.ViolationSeverityInterpreter;
+
+/**
+ * suggested interface for a violation-severity-interpreter storage
+ * used by add-ons to change the interpreter for the current request
+ * 
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(UsageCategory.API)
+public interface ViolationSeverityInterpreterStorage
+{
+    void setViolationSeverityInterpreter(ViolationSeverityInterpreter violationSeverityInterpreter);
+
+    ViolationSeverityInterpreter getViolationSeverityInterpreter();
+}
\ No newline at end of file

Added: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/mapper/DefaultViolationSeverityInterpreterStorageNameMapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/mapper/DefaultViolationSeverityInterpreterStorageNameMapper.java?rev=895602&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/mapper/DefaultViolationSeverityInterpreterStorageNameMapper.java (added)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/storage/mapper/DefaultViolationSeverityInterpreterStorageNameMapper.java Mon Jan  4 11:35:05 2010
@@ -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.InvocationOrder;
+import org.apache.myfaces.extensions.validator.core.mapper.NameMapper;
+import org.apache.myfaces.extensions.validator.core.storage.DefaultViolationSeverityInterpreterStorage;
+import org.apache.myfaces.extensions.validator.core.storage.ViolationSeverityInterpreterStorage;
+
+/**
+ * use a public class to allow optional deregistration
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@InvocationOrder(100)
+public class DefaultViolationSeverityInterpreterStorageNameMapper implements NameMapper<String>
+{
+    public String createName(String source)
+    {
+        return (ViolationSeverityInterpreterStorage.class.getName().equals(source)) ?
+                DefaultViolationSeverityInterpreterStorage.class.getName() : null;
+    }
+}
\ No newline at end of file