Class AbstractSessionWrapper<S extends RuleSession<S>>
- Type Parameters:
S- the type of theRuleSessiondelegate object
- All Implemented Interfaces:
Environment,EventBus,FluentEnvironment<S>,FluentImports<S>,MemoryStreaming,Named,RuleSession<S>,RuleSet<RuntimeRule>,RuleSetContext<S,,RuntimeRule> RuntimeContext<S>,SessionOps
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds an import statement using its string representation.A convenience method that returns an instance ofCollectorfor inserting streams of facts.builder(ClassLoader classLoader) Returns an instance ofRuleSetBuilderfor building and appending rules to the current context.configureTypes(Consumer<TypeResolver> action) Configures theTypeResolverby applying the given action.voiddelete(FactHandle handle) Deletes a fact from the working memory.<T> TRetrieves the value of a property by its name.Retrieves the activation manager associated with this session.Class<? extends ActivationManager>Returns the Activation Manager factory class for this RuntimeContext.Retrieves the ClassLoader used by the current context.Retrieves the Configuration object associated with this RuntimeContext.Return the condition manager associated with this context.<T> TgetFact(FactHandle handle) Returns fact by its handle.Retrieves the current set of import statements.getName()Returns the name of the object.Retrieves the parent context of this session instance.Retrieves a collection of all property names in the environment.<E extends ContextEvent>
Events.Publisher<E>getPublisher(Class<E> eventClass) Returns a publisher for a specific event class type.final RuntimeRuleRetrieves a rule based on its name.Retrieves the comparator used for ordering rules.final List<RuntimeRule>getRules()Method returns a list of rules created so far.Returns theKnowledgeServiceinstance.Retrieves the TypeResolver instance associated with this RuntimeContext.Inserts a fact in working memory and returns a serializable fact handle.Inserts a fact and explicitly specifies itsTypename.protected Sself()Sets the specified property to the given value.setActivationManager(ActivationManager activationManager) Sets the activation manager for the session.<A extends ActivationManager>
voidsetActivationManagerFactory(Class<A> managerClass) Sets the Activation Manager factory class for this RuntimeContext.voidsetActivationManagerFactory(String managerClass) Sets the Activation Manager factory class name for this RuntimeContext.setActivationMode(ActivationMode activationMode) Sets the activation mode for the session.voidsetRuleComparator(Comparator<Rule> comparator) Sets the comparator used for ordering rules.<T> Stream<Map.Entry<FactHandle,T>> streamFactEntries(Class<T> type) <T> Stream<Map.Entry<FactHandle,T>> streamFactEntries(String type) voidupdate(FactHandle handle, Object newValue) Updates a fact that already exists in the working memoryMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.evrete.api.Environment
get, get, getPropertyNamesMethods inherited from interface org.evrete.api.events.EventBus
getPublisher, subscribe, subscribe, subscribeAsyncMethods inherited from interface org.evrete.api.FluentEnvironment
setMethods inherited from interface org.evrete.api.FluentImports
addImport, addImport, getImports, getJavaImportsMethods inherited from interface org.evrete.api.MemoryStreaming
streamFacts, streamFacts, streamFactsMethods inherited from interface org.evrete.api.RuleSession
addEventListener, fire, insert, insert, insertAs, insertAs, removeEventListenerMethods inherited from interface org.evrete.api.RuleSet
getRule, getRule, getRules, ruleExistsMethods inherited from interface org.evrete.api.RuntimeContext
builder, builder, configureTypes, getActivationManagerFactory, getClassLoader, getConfiguration, getEvaluatorsContext, getRuleComparator, getService, getTypeResolver, importRules, importRules, setActivationManagerFactory, setActivationManagerFactory, setActivationMode, setRuleComparatorMethods inherited from interface org.evrete.api.SessionOps
insert, insertAs
-
Field Details
-
delegate
-
-
Constructor Details
-
AbstractSessionWrapper
-
-
Method Details
-
getActivationManager
Description copied from interface:RuleSessionRetrieves the activation manager associated with this session.- Specified by:
getActivationManagerin interfaceRuleSession<S extends RuleSession<S>>- Returns:
- the activation manager for this session
-
asCollector
Description copied from interface:RuleSessionA convenience method that returns an instance ofCollectorfor inserting streams of facts.- Specified by:
asCollectorin interfaceRuleSession<S extends RuleSession<S>>- Type Parameters:
T- the type of input elements to the reduction operation- Returns:
- collector
-
setActivationManager
Description copied from interface:RuleSessionSets the activation manager for the session.- Specified by:
setActivationManagerin interfaceRuleSession<S extends RuleSession<S>>- Parameters:
activationManager- the activation manager to set- Returns:
- the current session instance
-
getParentContext
Description copied from interface:RuleSessionRetrieves the parent context of this session instance.- Specified by:
getParentContextin interfaceRuleSession<S extends RuleSession<S>>- Returns:
- the parent context of this Knowledge instance
-
insert0
Description copied from interface:SessionOpsInserts a fact in working memory and returns a serializable fact handle. When
resolveCollectionsis set to true, and the fact is anIterableor an Array, the engine will instead insert its components and return a nullFactHandle. The engine will derive logical type of the fact(s) from their Java class names.Together with the
SessionOps.insert0(String, Object, boolean)method, this operation constitutes the core insert operations that are actually implemented by the engine. The other insert methods are just convenience wrappers of the two.- Specified by:
insert0in interfaceSessionOps- Parameters:
fact- object to insertresolveCollections- collection/array inspection flag- Returns:
- fact handle assigned to the fact, or
nullif multiple facts were inserted - See Also:
-
insert0
Description copied from interface:SessionOpsInserts a fact and explicitly specifies its
Typename. WhenresolveCollectionsis set to true, and the fact is anIterableor an Array, the engine will instead insert its components, and return a nullFactHandle.Together with the
SessionOps.insert0(Object, boolean)method, this operation constitutes the core insert operations that are actually implemented by the engine. The other insert methods are just convenience wrappers of the two.- Specified by:
insert0in interfaceSessionOps- Parameters:
type- explicit logical type of the inserted fact(s)fact- object to insertresolveCollections- collection/array inspection flag- Returns:
- fact handle assigned to the fact, or
nullif multiple facts were inserted - See Also:
-
streamFactEntries
Description copied from interface:MemoryStreaming- Specified by:
streamFactEntriesin interfaceMemoryStreaming- Returns:
- a stream of all fact entries and their fact handles
-
streamFactEntries
Description copied from interface:MemoryStreaming- Specified by:
streamFactEntriesin interfaceMemoryStreaming- Type Parameters:
T- the type of facts to stream- Parameters:
type- the logical type of the facts- Returns:
- a stream of fact entries of the specified logical type
- See Also:
-
streamFactEntries
Description copied from interface:MemoryStreaming- Specified by:
streamFactEntriesin interfaceMemoryStreaming- Type Parameters:
T- the type of facts to stream- Parameters:
type- the Java type of the facts- Returns:
- a stream of fact entries of the specified logical type
-
getFact
Description copied from interface:RuleSessionReturns fact by its handle.- Specified by:
getFactin interfaceRuleSession<S extends RuleSession<S>>- Type Parameters:
T- type of the fact (useObjector wildcard if type is unknown)- Parameters:
handle- fact handle- Returns:
- fact or
nullif fact is not found
-
delete
Description copied from interface:SessionOpsDeletes a fact from the working memory.- Specified by:
deletein interfaceSessionOps- Parameters:
handle- The FactHandle associated with the fact to be deleted.
-
update
Description copied from interface:SessionOpsUpdates a fact that already exists in the working memory- Specified by:
updatein interfaceSessionOps- Parameters:
handle- fact handle, previously assigned to original factnewValue- an updated version of the fact
-
get
Description copied from interface:EnvironmentRetrieves the value of a property by its name.- Specified by:
getin interfaceEnvironment- Type Parameters:
T- The expected type of the property value.- Parameters:
property- The name of the property to retrieve.- Returns:
- The value of the property as type T, or
nullif it does not exist.
-
getPropertyNames
Description copied from interface:EnvironmentRetrieves a collection of all property names in the environment.- Specified by:
getPropertyNamesin interfaceEnvironment- Returns:
- A collection of strings representing all property names in the environment.
-
getName
Description copied from interface:NamedReturns the name of the object. -
getRule
Description copied from interface:RuleSetRetrieves a rule based on its name.- Specified by:
getRulein interfaceRuleSet<D extends RuleSetContext<C,R>> - Parameters:
name- the name of the rule to retrieve- Returns:
- the rule with the specified name, or null if no rule with that name exists
-
set
Description copied from interface:FluentEnvironmentSets the specified property to the given value.- Specified by:
setin interfaceEnvironment- Specified by:
setin interfaceFluentEnvironment<D extends RuleSetContext<C,R>> - Parameters:
property- the name of the property to set; should not benull.value- the new value for the property; the actual type is determined by the implementation and the property being set.- Returns:
- the current instance of
Xto allow for method chaining.
-
getPublisher
Description copied from interface:EventBusReturns a publisher for a specific event class type.- Specified by:
getPublisherin interfaceEventBus- Type Parameters:
E- the type of the event to publish- Parameters:
eventClass- the class object of the event type- Returns:
- an
Events.Publisherfor the specified event class type - See Also:
-
configureTypes
Description copied from interface:RuntimeContextConfigures theTypeResolverby applying the given action.- Specified by:
configureTypesin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Parameters:
action- the action to configure the TypeResolver- Returns:
- this context
-
self
-
addImport
Description copied from interface:FluentImportsAdds an import statement using its string representation.- Specified by:
addImportin interfaceFluentImports<D extends RuleSetContext<C,R>> - Parameters:
imp- the full canonical name of the class or package to be imported- Returns:
- this instance to allow for method chaining
-
getRules
Description copied from interface:RuleSetMethod returns a list of rules created so far.
- Specified by:
getRulesin interfaceRuleSet<D extends RuleSetContext<C,R>> - Returns:
- list of currently known rules
-
getImports
Description copied from interface:FluentImportsRetrieves the current set of import statements.- Specified by:
getImportsin interfaceFluentImports<D extends RuleSetContext<C,R>> - Returns:
- an
Importsobject containing the current set of import statements
-
getRuleComparator
Description copied from interface:RuntimeContextRetrieves the comparator used for ordering rules.- Specified by:
getRuleComparatorin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Returns:
- the comparator for Rule objects.
-
setRuleComparator
Description copied from interface:RuntimeContextSets the comparator used for ordering rules.- Specified by:
setRuleComparatorin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Parameters:
comparator- the comparator for Rule objects.
-
builder
Description copied from interface:RuntimeContextReturns an instance of
RuleSetBuilderfor building and appending rules to the current context.Builder MUST be terminated with the
RuleSetBuilder.build()call for changes to take effect.Usage BEFORE 3.1.00:
Usage AFTER 3.1.00:service .newKnowledge() .newRule() .forEach("$a", A.class) .where("$a.active") .execute();service .newKnowledge() .builder() // !! important .newRule() .forEach("$a", A.class) .where("$a.active") .execute() .build(); // !! important- Specified by:
builderin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Parameters:
classLoader- the classloader to use.- Returns:
- new instance of RuleSetBuilder.
-
setActivationMode
Description copied from interface:RuntimeContextSets the activation mode for the session.- Specified by:
setActivationModein interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Parameters:
activationMode- the activation mode to set- Returns:
- the updated instance of the class
-
getEvaluatorsContext
Description copied from interface:RuntimeContextReturn the condition manager associated with this context.- Specified by:
getEvaluatorsContextin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Returns:
- the evaluator context
-
getClassLoader
Description copied from interface:RuntimeContextRetrieves the ClassLoader used by the current context.- Specified by:
getClassLoaderin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Returns:
- the ClassLoader used by the object.
-
getService
Description copied from interface:RuntimeContextReturns theKnowledgeServiceinstance.- Specified by:
getServicein interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Returns:
- the
KnowledgeServiceinstance
-
getActivationManagerFactory
Description copied from interface:RuntimeContextReturns the Activation Manager factory class for this RuntimeContext.- Specified by:
getActivationManagerFactoryin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Returns:
- the Activation Manager factory class
-
setActivationManagerFactory
Description copied from interface:RuntimeContextSets the Activation Manager factory class for this RuntimeContext.- Specified by:
setActivationManagerFactoryin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Type Parameters:
A- the type of Activation Manager- Parameters:
managerClass- the Activation Manager factory class
-
setActivationManagerFactory
Description copied from interface:RuntimeContextSets the Activation Manager factory class name for this RuntimeContext.- Specified by:
setActivationManagerFactoryin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Parameters:
managerClass- the Activation Manager factory class name
-
getTypeResolver
Description copied from interface:RuntimeContextRetrieves the TypeResolver instance associated with this RuntimeContext.- Specified by:
getTypeResolverin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Returns:
- the TypeResolver instance
-
getConfiguration
Description copied from interface:RuntimeContextRetrieves the Configuration object associated with this RuntimeContext.- Specified by:
getConfigurationin interfaceRuntimeContext<D extends RuleSetContext<C,R>> - Returns:
- the Configuration object
-