Class ViewLifecyclePhaseBase

java.lang.Object
org.kuali.rice.krad.uif.lifecycle.ViewLifecyclePhaseBase
All Implemented Interfaces:
Runnable, LifecycleElementState, ViewLifecyclePhase
Direct Known Subclasses:
ApplyModelComponentPhase, FinalizeComponentPhase, InitializeComponentPhase, PreProcessElementPhase, RenderComponentPhase

public abstract class ViewLifecyclePhaseBase extends Object implements ViewLifecyclePhase
Base abstract implementation for a lifecycle phase.
Author:
Kuali Rice Team (rice.collab@kuali.org)
  • Constructor Details

    • ViewLifecyclePhaseBase

      public ViewLifecyclePhaseBase()
  • Method Details

    • recycle

      public void recycle()
      Resets this phase for recycling.
      Specified by:
      recycle in interface ViewLifecyclePhase
    • prepare

      public void prepare(LifecycleElement element, Component parent, String parentPath, List<String> refreshPaths)
      Prepares a phase for use after being recycled (state cleared).
      Specified by:
      prepare in interface ViewLifecyclePhase
      Parameters:
      element - lifecycle element to prepare
      parent - parent component
      parentPath - path of the element related to its parent (in other words the property of the parent that holds this element)
      refreshPaths - during a component refresh request, the list of view paths that should be processed by the phase (this includes a subset of the entire view tree)
    • run

      public final void run()
      Executes the lifecycle phase.

      Performs state validation and updates component view status.

      Specified by:
      run in interface Runnable
      See Also:
    • shouldSkipLifecycle

      protected boolean shouldSkipLifecycle()
      Indicates whether the lifecycle should be skipped for the current component.

      Elements are always processed in the pre process phase, or in the case of the element or one of its childs being refreshed. If these conditions are false, the element method LifecycleElement.skipLifecycle() is invoked to determine if the lifecycle can be skipped.

      Returns:
      boolean true if the lifecycle should be skipped, false if not
      See Also:
    • validateBeforeProcessing

      protected void validateBeforeProcessing()
      Validates this phase and thread state before processing and logs activity.
      See Also:
    • processSuccessors

      protected void processSuccessors(Queue<ViewLifecyclePhase> successors)
      Adds phases added as successors to the processor, or if there are no pending successors invokes the complete notification step.
      Parameters:
      successors - phases to process
    • setNextPhase

      public void setNextPhase(ViewLifecyclePhase nextPhase)
      Sets the next phase, to queue for processing after this phase is completed.
      Specified by:
      setNextPhase in interface ViewLifecyclePhase
      Parameters:
      nextPhase - next phase
    • setTasks

      public void setTasks(List<ViewLifecycleTask<?>> tasks)
      Sets the tasks to process at this phase.
      Parameters:
      tasks - list of tasks
    • setSkipLifecycleTasks

      public void setSkipLifecycleTasks(List<ViewLifecycleTask<?>> skipLifecycleTasks)
      Sets the tasks to process at this phase when the lifecycle is skipped.
      Parameters:
      skipLifecycleTasks - list of tasks
    • initializeSuccessors

      protected void initializeSuccessors(Queue<ViewLifecyclePhase> successors)
      Initializes queue of successor phases.

      This method will be called while processing this phase after all tasks have been performed, to determine phases to queue for successor processing. This phase will not be considered complete until all successors queued by this method, and all subsequent successor phases, have completed processing.

      Parameters:
      successors - The queue of successor phases
    • setRefreshPaths

      public void setRefreshPaths(List<String> refreshPaths)
      Sets the refresh paths for this phase.
      Specified by:
      setRefreshPaths in interface ViewLifecyclePhase
      Parameters:
      refreshPaths - list of refresh paths.
    • getRefreshPaths

      public List<String> getRefreshPaths()
      Description copied from interface: ViewLifecyclePhase
      During a component refresh, returns the list of view paths the lifecycle phase will be processed on.
      Specified by:
      getRefreshPaths in interface ViewLifecyclePhase
      Returns:
      list of view paths
    • initializeRefreshPathSuccessors

      protected void initializeRefreshPathSuccessors(Queue<ViewLifecyclePhase> successors)
      Initializes only the lifecycle successors referenced by paths within getRefreshPaths().
      Parameters:
      successors - the successor queue
    • getNestedPropertiesForRefreshPath

      protected List<String> getNestedPropertiesForRefreshPath()
      Determines the list of child properties for the current phase component that are in the refresh paths and should be processed next.
      Returns:
      list of property names relative to the component the phase is currently processing
    • initializeAllLifecycleSuccessors

      protected void initializeAllLifecycleSuccessors(Queue<ViewLifecyclePhase> successors)
      Initializes all lifecycle phase successors.
      Parameters:
      successors - The successor queue.
    • verifyCompleted

      protected void verifyCompleted()
      May be overridden in order to check for illegal state based on more concrete assumptions than can be made here.
      Throws:
      IllegalStateException - If the conditions for completing the lifecycle phase have not been met
    • initializeSuccessor

      protected ViewLifecyclePhase initializeSuccessor(LifecycleElement nestedElement, String nestedPath, Component nestedParent)
      Initializes a successor of this phase for a given nested element.
      Parameters:
      nestedElement - The lifecycle element
      nestedPath - The path, relative to the parent element
      nestedParent - The parent component of the nested element refresh)
      Returns:
      successor phase
    • notifyCompleted

      public final void notifyCompleted()
      Notifies predecessors that this task has completed.
      Specified by:
      notifyCompleted in interface ViewLifecyclePhase
    • getElement

      public final LifecycleElement getElement()
      Gets the element this lifecycle phase is responsible for processing.
      Specified by:
      getElement in interface LifecycleElementState
      Returns:
      element this lifecycle phase is responsible for processing
    • getParent

      public final Component getParent()
      Retrieves the component that is a parent to the element being processed in the view three.
      Specified by:
      getParent in interface ViewLifecyclePhase
      Returns:
      parent component
    • getParentPath

      public String getParentPath()
      Gets the path relative the predecessor phase's component.
      Specified by:
      getParentPath in interface LifecycleElementState
      Returns:
      path relative the predecessor phase's component
    • getViewPath

      public String getViewPath()
      Gets the path relative to the view.
      Specified by:
      getViewPath in interface LifecycleElementState
      Returns:
      path relative the the view
    • setViewPath

      public void setViewPath(String viewPath)
      Parameters:
      viewPath - the viewPath to set
    • getDepth

      public int getDepth()
      Gets the depth of the element in the lifecycle tree.
      Specified by:
      getDepth in interface LifecycleElementState
      Returns:
      The depth of the element in the lifecycle tree.
    • isProcessed

      public final boolean isProcessed()
      Determines if this lifecycle phase has completed processing.

      This method will return true when this phase's tasks have been processed, but does not necessarily indicate that successor phases have been completed. Use ViewLifecyclePhase.isComplete() to determine if the lifecycle has been fully completed for this phase.

      Specified by:
      isProcessed in interface ViewLifecyclePhase
      Returns:
      true if this phase has been processed, false if not
    • isComplete

      public final boolean isComplete()
      Determines if this lifecycle phase and all successor phases, have completed processing.
      Specified by:
      isComplete in interface ViewLifecyclePhase
      Returns:
      true if this phase and all successor phases have been processed, false if not
      See Also:
    • getPredecessor

      public ViewLifecyclePhase getPredecessor()
      Gets the lifecycle phase that directly precedes this phase.
      Specified by:
      getPredecessor in interface ViewLifecyclePhase
      Returns:
      lifecycle phase that directly precedes this phase
    • setPredecessor

      public void setPredecessor(ViewLifecyclePhase phase)
      Sets the predecessor, for notification during processing.
      Specified by:
      setPredecessor in interface ViewLifecyclePhase
      Parameters:
      phase - predecessor phase
    • getCurrentTask

      public ViewLifecycleTask<?> getCurrentTask()
      Gets the task currently running.
      Specified by:
      getCurrentTask in interface ViewLifecyclePhase
      Returns:
      the task currently running, null if this phase is not active.
    • hasPendingSuccessors

      public boolean hasPendingSuccessors()
      Determines of there are any pending successors of this phase.
      Specified by:
      hasPendingSuccessors in interface ViewLifecyclePhase
      Returns:
      True if there are pending successors, false if no successors are pending.
    • removePendingSuccessor

      public void removePendingSuccessor(String parentPath)
      Remove a pending successor by path.
      Specified by:
      removePendingSuccessor in interface ViewLifecyclePhase
      Parameters:
      parentPath - path
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • trace

      protected void trace(String step)
      Logs a trace message related to processing this lifecycle, when tracing is active and debugging is enabled.
      Parameters:
      step - The step in processing the phase that has been reached.
      See Also: