001    /**
002     * Copyright 2005-2012 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     */
016    package org.kuali.rice.krms.framework.engine;
017    
018    import java.util.Map;
019    
020    import org.kuali.rice.krms.api.engine.ExecutionOptions;
021    import org.kuali.rice.krms.api.engine.SelectionCriteria;
022    import org.kuali.rice.krms.api.engine.Term;
023    
024    /**
025     * Loads a {@link Context} for the given set of criteria.  Applications who
026     * want to provide their own means for creating a context and supplying it to
027     * the KRMS engine can do so by implementing a custom ContextProvider. 
028     * 
029     * @see Context
030     * 
031     * @author Kuali Rice Team (rice.collab@kuali.org)
032     *
033     */
034    public interface ContextProvider {
035    
036            /**
037             * Loads the context for the given selection criteria, facts, and execution
038             * options.  If no context can be located based on the given criteria, then
039             * this method should return null.
040             * 
041             * <p>In the case where multiple Contexts could potentially be identified
042             * from the same set of selection criteria, it is up to the implementer
043             * of the ContextProvider to ensure that the most appropriate Context is
044             * returned.  Or alternatively, an exception could be thrown indicating
045             * context ambiguity.
046             * 
047             * <p>The sectionCriteria, facts, and executionOptions which are passed to
048             * this method should never be null.  However, they might be empty.
049             * 
050             * @param selectionCriteria the criteria to use during the selection phase of engine operation
051             * @param facts the set of facts that are supplied to the engine at execution time
052             * @param executionOptions a collection of options that can be used to customize engine execution behavior
053             * 
054             * @return the context which matches the given criteria, or null if no context matches
055             */
056            public Context loadContext(SelectionCriteria selectionCriteria, Map<Term, Object> facts, ExecutionOptions executionOptions);
057            
058    }