001/**
002 * Copyright 2005-2018 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.krad.uif.lifecycle;
017
018import org.kuali.rice.krad.uif.freemarker.LifecycleRenderingContext;
019import org.kuali.rice.krad.uif.view.ExpressionEvaluator;
020
021/**
022 * Interface for controlling the execution of the view lifecycle.
023 * 
024 * @author Kuali Rice Team (rice.collab@kuali.org)
025 */
026public interface ViewLifecycleProcessor {
027
028    /**
029     * Performs a lifecycle phase according to this processor's semantics, blocking until the phase
030     * has been completely processed. Once the initial phase has been completely processed, this
031     * method will return.
032     * 
033     * @param initialPhase The initial lifecycle phase
034     */
035    void performPhase(ViewLifecyclePhase initialPhase);
036
037    /**
038     * Pushes lifecycle phases to be processed within the lifecycle associated with this processor.
039     * 
040     * <p>A phase submitted using this method will be added to the front of the queue, to be processed
041     * by the next available processor.</p>
042     * 
043     * @param phase The phase to be processed within the lifecycle associated with this processor.
044     */
045    void pushPendingPhase(ViewLifecyclePhase phase);
046
047    /**
048     * Queues a lifecycle phase to be processed within the lifecycle associated with this processor.
049     * 
050     * <p>A phase submitted using this method will be added to the end of the queue, to be processed
051     * after all other phases currently in the queue have been submitted.</p>
052     * 
053     * @param phase The phase to be processed within the lifecycle associated with this processor.
054     */
055    void offerPendingPhase(ViewLifecyclePhase phase);
056
057    /**
058     * Gets the phase actively being processing on the current thread.
059     *
060     * @return lifecycle phase active on the current thread
061     */
062    ViewLifecyclePhase getActivePhase();
063
064    /**
065     * Gets the lifecycle associated with this processor.
066     *
067     * @return lifecycle associated with this processor
068     */
069    ViewLifecycle getLifecycle();
070
071    /**
072     * Gets a thread-local rending context for invoking FreeMarker operations on the current thread.
073     *
074     * @return rending context for invoking FreeMarker operations on the current thread
075     */
076    LifecycleRenderingContext getRenderingContext();
077
078    /**
079     * Returns an instance of {@link org.kuali.rice.krad.uif.view.ExpressionEvaluator} that can be
080     * used for evaluating expressions contained on the view.
081     * 
082     * <p>A ExpressionEvaluator must be initialized with a model for expression evaluation. One
083     * instance is constructed for the view lifecycle and made available to all components/helpers
084     * through this method</p>
085     * 
086     * @return instance of ExpressionEvaluator
087     */
088    ExpressionEvaluator getExpressionEvaluator();
089
090}