myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdebussc...@apache.org
Subject svn commit: r1055780 - in /myfaces/extensions/validator/trunk/core/src/main: java/org/apache/myfaces/extensions/validator/core/startup/ resources/META-INF/
Date Thu, 06 Jan 2011 08:01:10 GMT
Author: rdebusscher
Date: Thu Jan  6 08:01:09 2011
New Revision: 1055780

URL: http://svn.apache.org/viewvc?rev=1055780&view=rev
Log:
EXTVAL-123

Added:
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValLifecycleFactoryWrapper.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValLifecycleWrapper.java
Modified:
    myfaces/extensions/validator/trunk/core/src/main/resources/META-INF/faces-config.xml

Added: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValLifecycleFactoryWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValLifecycleFactoryWrapper.java?rev=1055780&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValLifecycleFactoryWrapper.java
(added)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValLifecycleFactoryWrapper.java
Thu Jan  6 08:01:09 2011
@@ -0,0 +1,68 @@
+/*
+ * 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.startup;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.lifecycle.LifecycleFactory;
+import java.util.Iterator;
+
+/**
+ * Lifecycle factory that wraps the LifeCycle implementation so that we can guarantee that
the
+ * ExtVal PhaseListeners are 'executed' (initialised) before any code of the JSF implementation
is executed.
+ * Solution for the issue EXTVAL-123.
+ *
+ * @author Rudy De Busscher
+ * @author Gerard Petracek
+ * @since x.x.5
+ */
+@UsageInformation(value = UsageCategory.INTERNAL)
+public class ExtValLifecycleFactoryWrapper extends LifecycleFactory
+{
+
+    private final LifecycleFactory wrapped;
+
+    /**
+     * Constructs The wrapper around the factory specified as parameter.
+     * @param wrapped Factory instance we will wrap.
+     */
+    public ExtValLifecycleFactoryWrapper(LifecycleFactory wrapped)
+    {
+        this.wrapped = wrapped;
+    }
+
+    public void addLifecycle(String s, Lifecycle lifecycle)
+    {
+        wrapped.addLifecycle(s, lifecycle);
+    }
+
+    public Lifecycle getLifecycle(String s)
+    {
+        Lifecycle result = this.wrapped.getLifecycle(s);
+
+        return new ExtValLifecycleWrapper(result);
+    }
+
+    public Iterator<String> getLifecycleIds()
+    {
+        return wrapped.getLifecycleIds();
+    }
+}

Added: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValLifecycleWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValLifecycleWrapper.java?rev=1055780&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValLifecycleWrapper.java
(added)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValLifecycleWrapper.java
Thu Jan  6 08:01:09 2011
@@ -0,0 +1,90 @@
+/*
+ * 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.startup;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseListener;
+import javax.faces.lifecycle.Lifecycle;
+
+/**
+ * Wrapper around a Lifecycle that initialise the ExtVal PhaseListeners before an execution
of any
+ * phase (except the render view). Solution for the issue EXTVAL-123.
+ * @author Rudy De Busscher
+ * @author Gerard Petracek
+ * @since x.x.5
+ */
+@UsageInformation(value = UsageCategory.INTERNAL)
+class ExtValLifecycleWrapper extends Lifecycle
+{
+    private Lifecycle wrapped;
+
+    ExtValLifecycleWrapper(Lifecycle wrapped)
+    {
+        this.wrapped = wrapped;
+
+    }
+
+    public void addPhaseListener(PhaseListener phaseListener)
+    {
+        wrapped.addPhaseListener(phaseListener);
+    }
+
+    public void execute(FacesContext facesContext)
+            throws FacesException
+    {
+        initializeExtVal();
+        wrapped.execute(facesContext);
+    }
+
+    public PhaseListener[] getPhaseListeners()
+    {
+        return wrapped.getPhaseListeners();
+    }
+
+    public void removePhaseListener(PhaseListener phaseListener)
+    {
+        wrapped.removePhaseListener(phaseListener);
+    }
+
+    public void render(FacesContext facesContext)
+            throws FacesException
+    {
+        // Don't need to initialize ExtVal here because this phase is never the very first
one in a system (restore
+        // view is always the first)
+        wrapped.render(facesContext);
+    }
+
+
+    private void initializeExtVal()
+    {
+
+        for (PhaseListener currentPhaseListener : getPhaseListeners())
+        {
+            if (currentPhaseListener instanceof AbstractStartupListener)
+            {
+                currentPhaseListener.beforePhase(null);
+            }
+        }
+    }
+
+}

Modified: myfaces/extensions/validator/trunk/core/src/main/resources/META-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/resources/META-INF/faces-config.xml?rev=1055780&r1=1055779&r2=1055780&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/resources/META-INF/faces-config.xml (original)
+++ myfaces/extensions/validator/trunk/core/src/main/resources/META-INF/faces-config.xml Thu
Jan  6 08:01:09 2011
@@ -22,6 +22,7 @@
               xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
               version="1.2">
     <factory>
+        <lifecycle-factory>org.apache.myfaces.extensions.validator.core.startup.ExtValLifecycleFactoryWrapper</lifecycle-factory>
         <render-kit-factory>org.apache.myfaces.extensions.validator.core.renderkit.ExtValRenderKitFactory</render-kit-factory>
     </factory>
 



Mime
View raw message