You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by rd...@apache.org on 2011/01/10 09:49:43 UTC

svn commit: r1057123 - /myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValLifecycleWrapper.java

Author: rdebusscher
Date: Mon Jan 10 08:49:43 2011
New Revision: 1057123

URL: http://svn.apache.org/viewvc?rev=1057123&view=rev
Log:
EXTVAL-123: Improve performance (remarked by Gerhard)

Modified:
    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/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=1057123&r1=1057122&r2=1057123&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValLifecycleWrapper.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/startup/ExtValLifecycleWrapper.java Mon Jan 10 08:49:43 2011
@@ -29,6 +29,7 @@ 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
@@ -38,10 +39,11 @@ class ExtValLifecycleWrapper extends Lif
 {
     private Lifecycle wrapped;
 
+    private boolean initialized = false;
+
     ExtValLifecycleWrapper(Lifecycle wrapped)
     {
         this.wrapped = wrapped;
-
     }
 
     public void addPhaseListener(PhaseListener phaseListener)
@@ -52,7 +54,10 @@ class ExtValLifecycleWrapper extends Lif
     public void execute(FacesContext facesContext)
             throws FacesException
     {
-        initializeExtVal();
+        if(!this.initialized)
+        {
+            initializeExtVal();
+        }
         wrapped.execute(facesContext);
     }
 
@@ -75,9 +80,9 @@ class ExtValLifecycleWrapper extends Lif
     }
 
 
-    private void initializeExtVal()
+    private synchronized void initializeExtVal()
     {
-
+        //we don't need further checks - startup listeners are deregistered after the invocation.
         for (PhaseListener currentPhaseListener : getPhaseListeners())
         {
             if (currentPhaseListener instanceof AbstractStartupListener)
@@ -85,6 +90,6 @@ class ExtValLifecycleWrapper extends Lif
                 currentPhaseListener.beforePhase(null);
             }
         }
+        this.initialized = true;
     }
-
 }