Interface EntryPoint
- All Known Subinterfaces:
KieRuntime,KieSession,RuleRuntime
An entry-point is an abstract channel through where facts are inserted into the engine.
KIE 6 supports multiple entry-points into a single KieBase: the
default, anonymous entry-point, as well as as many user declared entry points the application
requires.
To get a reference to an entry point, just request the session:
KieSession session = kbase.newStatelessKieSession();
...
WorkingMemoryEntryPoint entrypoint = session.getEntryPoint("my entry point");
Once a reference to an entry point is acquired, the application can insert, update and retract facts to/from that entry-point as usual:
... FactHandle factHandle = entrypoint.insert( fact ); ... entrypoint.update( factHandle, newFact ); ... entrypoint.retract( factHandle ); ...
-
Method Summary
Modifier and TypeMethodDescriptionvoiddelete(FactHandle handle) Retracts the fact for which the given FactHandle was assigned regardless if it has been explicitly or logically inserted.voiddelete(FactHandle handle, FactHandle.State fhState) Retracts the fact for which the given FactHandle was assigned.longgetFactHandle(Object object) Returns the fact handle associated with the given object.<T extends FactHandle>
Collection<T><T extends FactHandle>
Collection<T>getFactHandles(ObjectFilter filter) default <T> Collection<T>getInstancesOf(Class<T> clazz) Returns a Collection of objects in this entry-point that are instances of the given class.getObject(FactHandle factHandle) Collection<? extends Object>This class is not a general-purpose Collection implementation! While this class implements the Collection interface, it intentionally violates Collection general contract, which mandates the use of the equals method when comparing objects.Collection<? extends Object>getObjects(ObjectFilter filter) default <T> TgetSingleInstanceOf(Class<T> clazz) Returns the only object in this entry-point that is an instance of the given class.Inserts a new fact into this entry pointvoidretract(FactHandle handle) Deprecated.voidupdate(FactHandle handle, Object object) Updates the fact for which the given FactHandle was assigned with the new fact set as the second parameter in this method.voidupdate(FactHandle handle, Object object, String... modifiedProperties) Updates the fact for which the given FactHandle was assigned with the new fact set as the second parameter in this method, also specifying the set of properties that have been modified.
-
Method Details
-
getEntryPointId
String getEntryPointId()- Returns:
- the String Id of this entry point
-
insert
Inserts a new fact into this entry point- Parameters:
object- the fact to be inserted- Returns:
- the fact handle created for the given fact
-
retract
Deprecated.Retracts the fact for which the given FactHandle was assigned.- Parameters:
handle- the handle whose fact is to be retracted.
-
delete
Retracts the fact for which the given FactHandle was assigned regardless if it has been explicitly or logically inserted.- Parameters:
handle- the handle whose fact is to be retracted.
-
delete
Retracts the fact for which the given FactHandle was assigned.- Parameters:
handle- the handle whose fact is to be retracted.fhState- defines how the handle has to be retracted: as an explicitly inserted fact (STATED), from the Truth Maintenance System (LOGICAL), or both (ALL)
-
update
Updates the fact for which the given FactHandle was assigned with the new fact set as the second parameter in this method.- Parameters:
handle- the FactHandle for the fact to be updated.object- the new value for the fact being updated.
-
update
Updates the fact for which the given FactHandle was assigned with the new fact set as the second parameter in this method, also specifying the set of properties that have been modified.- Parameters:
handle- the FactHandle for the fact to be updated.object- the new value for the fact being updated.modifiedProperties- the list of the names of the object's properties modified by this update.
-
getFactHandle
Returns the fact handle associated with the given object. It is important to note that this method behaves in accordance with the configured assert behaviour for thisKieBase(either IDENTITY or EQUALITY).- Parameters:
object- the fact for which the fact handle will be returned.- Returns:
- the fact handle for the given object, or null in case no fact handle was found for the given object.
- See Also:
-
getObject
- Returns:
- the object associated with the given FactHandle.
-
getObjects
Collection<? extends Object> getObjects()This class is not a general-purpose Collection implementation! While this class implements the Collection interface, it intentionally violates Collection general contract, which mandates the use of the equals method when comparing objects.
Instead the approach used when comparing objects with the contains(Object) method is dependent on the WorkingMemory configuration, where it can be configured for Identity or for Equality.
- Returns:
- all facts from the current session as a Collection.
-
getObjects
- Parameters:
filter- the filter to be applied to the returned collection of facts.- Returns:
- all facts from the current session that are accepted by the given
ObjectFilter.
-
getInstancesOf
Returns a Collection of objects in this entry-point that are instances of the given class.- Parameters:
clazz- the class of objects to be retrieved- Returns:
- all facts from this entry-point that are instance of the given class.
-
getSingleInstanceOf
Returns the only object in this entry-point that is an instance of the given class.- Parameters:
clazz- the class of object to be retrieved- Returns:
- the only object from this entry-point that is an instance of the given class.
- Throws:
NoSuchElementException- if there isn't any object of the given class in this entry-pointIllegalStateException- if there is more than one object of the given class in this entry-point
-
getFactHandles
- Returns:
- all
FactHandles from the current session.
-
getFactHandles
- Parameters:
filter- the filter to be applied to the returned collection ofFactHandles.- Returns:
- all
FactHandles from the current session for which the facts are accepted by the given filter.
-
getFactCount
long getFactCount()- Returns:
- the total number of facts currently in this entry point
-
delete(FactHandle)