Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-1411

Lifecycle phase executions repetitions

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1.4
    • 1.1.5
    • JSR-127
    • None

    Description

      Every phase in LifecycleImpl looks like:

      private boolean applyRequestValues(FacesContext facesContext, PhaseListenerManager phaseListenerMgr)
      throws FacesException
      {
      boolean skipFurtherProcessing = false;
      if (log.isTraceEnabled()) log.trace("entering applyRequestValues in " + LifecycleImpl.class.getName());

      try {
      phaseListenerMgr.informPhaseListenersBefore(PhaseId.APPLY_REQUEST_VALUES);

      if(isResponseComplete(facesContext, "applyRequestValues", true))

      { // have to return right away return true; }

      if(shouldRenderResponse(facesContext, "applyRequestValues", true))

      { skipFurtherProcessing = true; }

      facesContext.getViewRoot().processDecodes(facesContext);
      } finally

      { phaseListenerMgr.informPhaseListenersAfter(PhaseId.APPLY_REQUEST_VALUES); }

      if (isResponseComplete(facesContext, "applyRequestValues", false)

      shouldRenderResponse(facesContext, "applyRequestValues", false)) { // since this phase is completed we don't need to return right away even if the response is completed skipFurtherProcessing = true; }

      if (!skipFurtherProcessing && log.isTraceEnabled())
      log.trace("exiting applyRequestValues in "
      + LifecycleImpl.class.getName());
      return skipFurtherProcessing;
      }

      And that is repeated as many times as phases are. The fix will be to extract the common behavior in a method, that receives one additional parameter - PhaseExecutor and delegate to it the real execution.

      Attachments

        1. ApplyRequestValuesExecutor.java
          0.4 kB
          Nikolay Petrov
        2. InvokeApplicationExecutor.java
          0.4 kB
          Nikolay Petrov
        3. LifecycleImpl.java
          7 kB
          Nikolay Petrov
        4. PhaseExecutor.java
          0.2 kB
          Nikolay Petrov
        5. ProcessValidationsExecutor.java
          0.4 kB
          Nikolay Petrov
        6. RenderResponseExecutor.java
          0.8 kB
          Nikolay Petrov
        7. RestoreViewExecutor.java
          4 kB
          Nikolay Petrov
        8. UpdateModelValuesExecutor.java
          0.4 kB
          Nikolay Petrov

        Activity

          People

            mmarinschek Martin Marinschek
            ingon Nikolay Petrov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: