1 /**
2 * Copyright 2005-2011 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.krms.api.engine;
17
18 import java.util.Map;
19 import java.util.Set;
20
21 /**
22 * The ExecutionEnvironment manages contextual information which is made available to
23 * different components of the rules engine during execution. Facts can be retrieved
24 * from and published to the environment. It also provides a reference to the
25 * {@link EngineResults} or tracking engine activity and returning values back to
26 * the client of the rules engine.
27 *
28 * @author Kuali Rice Team (rice.collab@kuali.org)
29 *
30 */
31 public interface ExecutionEnvironment {
32
33 /**
34 * Returns the selection criteria that was used to initialize the environment.
35 *
36 * @return the selection criteria for this environment
37 */
38 public SelectionCriteria getSelectionCriteria();
39
40 /**
41 * Returns an immutable Map of facts available within this environment.
42 *
43 * @return the facts in this environment
44 */
45 public Map<Term, Object> getFacts();
46
47 /**
48 * Publishes a new fact
49 *
50 * @param factName name of the fact to publish
51 * @param factValue value of the fact to publish
52 * // TODO: we don't support updating facts, refactor this method
53 * @return true if an existing fact was updated, false if this was a new fact
54 */
55 public boolean publishFact(Term factName, Object factValue);
56
57 public void addTermResolver(TermResolver<?> termResolver);
58
59 public <T> T resolveTerm(Term term, Object caller) throws TermResolutionException;
60
61 public Set<Term> getTermsForCaller(Object caller);
62
63 public ExecutionOptions getExecutionOptions();
64
65 public EngineResults getEngineResults();
66
67 }