001: package org.drools.spi;
002:
003: /*
004: * Copyright 2005 JBoss Inc
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: import java.io.Serializable;
020:
021: import org.drools.FactException;
022: import org.drools.FactHandle;
023: import org.drools.WorkingMemory;
024: import org.drools.rule.Declaration;
025: import org.drools.rule.Rule;
026:
027: /**
028: * KnowledgeHelper implementation types are injected into consequenses
029: * instrumented at compile time and instances passed at runtime. It provides
030: * convenience methods for users to interact with the WorkingMemory.
031: * <p>
032: * Of particular interest is the update method as it allows an object to
033: * be modified without having to specify the facthandle, because they are not
034: * passed to the consequence at runtime. To achieve this the implementation will
035: * need to lookup the fact handle of the object form the WorkingMemory.
036: *
037: * @author <a href="mailto:bob@werken.com">bob mcwhirter </a>
038: * @author <a href="mailto:mproctor@codehaus.org">mark proctor</a>
039: */
040: public interface KnowledgeHelper extends Serializable {
041:
042: public void setActivation(final Activation agendaItem);
043:
044: /**
045: * Asserts an object, notice that it does not return the FactHandle
046: *
047: * @param object -
048: * the object to be asserted
049: * @throws FactException -
050: * Exceptions can be thrown by conditions which are wrapped and
051: * returned as a FactException
052: */
053: void insert(Object object) throws FactException;
054:
055: /**
056: * Asserts an object specifying that it implement the onPropertyChange
057: * listener, notice that it does not return the FactHandle.
058: *
059: * @param object -
060: * the object to be asserted
061: * @param dynamic -
062: * specifies the object implements onPropertyChangeListener
063: * @throws FactException -
064: * Exceptions can be thrown by conditions which are wrapped and
065: * returned as a FactException
066: */
067: void insert(Object object, boolean dynamic) throws FactException;
068:
069: public void insertLogical(Object object) throws FactException;
070:
071: public void insertLogical(Object object, boolean dynamic)
072: throws FactException;
073:
074: void update(FactHandle handle, Object newObject)
075: throws FactException;
076:
077: void update(Object newObject) throws FactException;
078:
079: void retract(FactHandle handle) throws FactException;
080:
081: void retract(Object object) throws FactException;
082:
083: public void modifyRetract(final Object object);
084:
085: public void modifyRetract(final FactHandle factHandle);
086:
087: public void modifyInsert(final Object object);
088:
089: public void modifyInsert(final FactHandle factHandle,
090: final Object object);
091:
092: public Object get(Declaration declaration);
093:
094: /**
095: * @return - The rule name
096: */
097: Rule getRule();
098:
099: Tuple getTuple();
100:
101: Activation getActivation();
102:
103: WorkingMemory getWorkingMemory();
104:
105: // /** @return - A List of the objects in the WorkingMemory */
106: // List getObjects();
107: //
108: // /**
109: // * Retruns a List of Objects that match the given Class in the paremeter.
110: // *
111: // * @param objectClass -
112: // * The Class to filter by
113: // * @return - All the Objects in the WorkingMemory that match the given Class
114: // * filter
115: // */
116: // List getObjects(Class objectClass);
117: //
118: // QueryResults getQueryResults(String query);
119: //
120: // /**
121: // * Clears the agenda causing all existing Activations to fire
122: // * ActivationCancelled events. <br>
123: // */
124: // void clearAgenda();
125: //
126: // void clearAgendaGroup(String group);
127: //
128: // public AgendaGroup getFocus();
129: //
130: void setFocus(String focus);
131:
132: //
133: // void setFocus(AgendaGroup focus);
134:
135: public Declaration getDeclaration(String identifier);
136:
137: public void halt();
138:
139: }
|