- All Known Implementing Classes:
DSLClassProvider,DSLJarProvider,DSLSourceProvider
RuntimeContext.importRules(String, Object) method.
Implementations are expected to create a new RuleSetBuilder from the provided RuntimeContext,
append new rules, and finally invoke the RuleSetBuilder.build() method.
If an implementation requires or relies on specific configuration options, the authors of the implementation
should read them via the RuntimeContext.get(String) method. The configuration options should be documented
so that developers can set those options via the corresponding RuntimeContext.set(String, Object) method
prior to importing the rules.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <C extends RuntimeContext<C>>
voidappendTo(RuntimeContext<C> context, Object source) Appends the provided rule source to the specifiedRuleSetBuilderinstance.default Knowledgecreate(KnowledgeService service, File... files) Deprecated.default Knowledgecreate(KnowledgeService service, InputStream... streams) Deprecated.Use theappendTo(RuntimeContext, Object)method instead.default Knowledgecreate(KnowledgeService service, Reader... streams) Deprecated.Use theappendTo(RuntimeContext, Object)method instead.default Knowledgecreate(KnowledgeService service, URL... resources) Deprecated.Use theappendTo(RuntimeContext, Object)method instead.default Knowledgecreate(KnowledgeService service, TypeResolver resolver, File... files) Deprecated.Use theappendTo(RuntimeContext, Object)method instead.default Knowledgecreate(KnowledgeService service, TypeResolver typeResolver, InputStream... streams) Deprecated.Use theappendTo(RuntimeContext, Object)method instead.default Knowledgecreate(KnowledgeService service, TypeResolver typeResolver, Reader... streams) Deprecated.Use theappendTo(RuntimeContext, Object)method instead.default Knowledgecreate(KnowledgeService service, TypeResolver typeResolver, URL... resources) Deprecated.Use theappendTo(RuntimeContext, Object)method instead.getName()Returns the name of the DSL knowledge provider.static DSLKnowledgeProviderload(Class<? extends DSLKnowledgeProvider> dsl) Attempts to load and instantiate aDSLKnowledgeProviderimplementation.static DSLKnowledgeProviderLoads a specific DSL (Domain-Specific Language) knowledge provider based on the provided identifier.
-
Method Details
-
getName
String getName()Returns the name of the DSL knowledge provider.- Returns:
- the name of the provider
-
appendTo
default <C extends RuntimeContext<C>> void appendTo(RuntimeContext<C> context, Object source) throws IOException Appends the provided rule source to the specifiedRuleSetBuilderinstance.If the implementation requires or relies on specific configuration entries, they should be set via the
FluentEnvironment.set(String, Object)method.This method is the preferred approach for integrating external rule sources. Unlike the deprecated
create(KnowledgeService, TypeResolver, URL...)method and its variants, this method enables appending sources directly to bothKnowledgeandRuleSessionrule set instances.- Type Parameters:
C- The type of the context for the builder.- Parameters:
context- TheRuntimeContextinstance to which the rule source(s) will be appended.source- The rule source to be appended to the target builder. The source can be in various formats, depending on the implementation (e.g., a String representing rule definitions, a File with rule definitions, a URL, etc.).- Throws:
IOException- If an I/O error occurs while processing the source.IllegalArgumentException- If the source format is unrecognized or cannot be processed.
-
create
Deprecated.Use theappendTo(RuntimeContext, Object)method instead.Creates a newKnowledgefrom the provided resources. This method has been deprecated since version 4.0.0 in favor of using the newappendTo(RuntimeContext, Object)method for applying external resources. To ensure backward compatibility, this method (and other similar pre-4.0.0 methods) now attempts to automatically adopt the new approach. However, depending on the implementation, compatibility might not be fully guaranteed.- Parameters:
service- the Knowledge service.resources- the remote or local resources to apply.- Returns:
- a new Knowledge instance.
- Throws:
IOException- if an error occurs while reading the data sources.
-
create
@Deprecated default Knowledge create(KnowledgeService service, TypeResolver typeResolver, URL... resources) throws IOException Deprecated.Use theappendTo(RuntimeContext, Object)method instead.Creates a newKnowledgefrom the provided resources. This method has been deprecated since version 4.0.0 in favor of using the newappendTo(RuntimeContext, Object)method for applying external resources. To ensure backward compatibility, this method (and other similar pre-4.0.0 methods) now attempts to automatically adopt the new approach. However, depending on the implementation, compatibility might not be fully guaranteed.- Parameters:
resources- remote or local resources to applytypeResolver- TypeResolver to use.service- Knowledge service.- Returns:
- new Knowledge instance
- Throws:
IOException- if an error occurs when reading the data sources.
-
create
@Deprecated default Knowledge create(KnowledgeService service, InputStream... streams) throws IOException Deprecated.Use theappendTo(RuntimeContext, Object)method instead.Creates a newKnowledgefrom the provided resources. This method has been deprecated since version 4.0.0 in favor of using the newappendTo(RuntimeContext, Object)method for applying external resources. To ensure backward compatibility, this method (and other similar pre-4.0.0 methods) now attempts to automatically adopt the new approach. However, depending on the implementation, compatibility might not be fully guaranteed.- Parameters:
streams- remote or local resources to applyservice- Knowledge service.- Returns:
- new Knowledge instance
- Throws:
IOException- if an error occurs when reading the data sources.- See Also:
-
create
@Deprecated default Knowledge create(KnowledgeService service, TypeResolver resolver, File... files) throws IOException Deprecated.Use theappendTo(RuntimeContext, Object)method instead.Creates a newKnowledgefrom the provided resources. This method has been deprecated since version 4.0.0 in favor of using the newappendTo(RuntimeContext, Object)method for applying external resources. To ensure backward compatibility, this method (and other similar pre-4.0.0 methods) now attempts to automatically adopt the new approach. However, depending on the implementation, compatibility might not be fully guaranteed.- Parameters:
files- file resourcesservice- Knowledge service.resolver- Type resolver- Returns:
- new Knowledge instance
- Throws:
IOException- if an error occurs when reading the data sources.
-
create
Deprecated.Use theappendTo(RuntimeContext, Object)method instead.Creates a newKnowledgefrom the provided resources. This method has been deprecated since version 4.0.0 in favor of using the newappendTo(RuntimeContext, Object)method for applying external resources. To ensure backward compatibility, this method (and other similar pre-4.0.0 methods) now attempts to automatically adopt the new approach. However, depending on the implementation, compatibility might not be fully guaranteed.- Parameters:
files- file resourcesservice- Knowledge service.- Returns:
- new Knowledge instance
- Throws:
IOException- if an error occurs when reading the data sources.
-
create
@Deprecated default Knowledge create(KnowledgeService service, TypeResolver typeResolver, InputStream... streams) throws IOException Deprecated.Use theappendTo(RuntimeContext, Object)method instead.Creates a newKnowledgefrom the provided resources. This method has been deprecated since version 4.0.0 in favor of using the newappendTo(RuntimeContext, Object)method for applying external resources. To ensure backward compatibility, this method (and other similar pre-4.0.0 methods) now attempts to automatically adopt the new approach. However, depending on the implementation, compatibility might not be fully guaranteed.- Parameters:
streams- remote or local resources to applyservice- Knowledge service.typeResolver- TypeResolver to use.- Returns:
- new Knowledge instance
- Throws:
IOException- if an error occurs when reading the data sources.
-
create
@Deprecated default Knowledge create(KnowledgeService service, Reader... streams) throws IOException Deprecated.Use theappendTo(RuntimeContext, Object)method instead.Creates a newKnowledgefrom the provided resources. This method has been deprecated since version 4.0.0 in favor of using the newappendTo(RuntimeContext, Object)method for applying external resources. To ensure backward compatibility, this method (and other similar pre-4.0.0 methods) now attempts to automatically adopt the new approach. However, depending on the implementation, compatibility might not be fully guaranteed.- Parameters:
streams- remote or local resources to applyservice- Knowledge service.- Returns:
- new Knowledge instance
- Throws:
IOException- if resources can not be readUnsupportedOperationException- if this method is not supported by the implementation- See Also:
-
create
@Deprecated default Knowledge create(KnowledgeService service, TypeResolver typeResolver, Reader... streams) throws IOException Deprecated.Use theappendTo(RuntimeContext, Object)method instead.Creates a newKnowledgefrom the provided resources. This method has been deprecated since version 4.0.0 in favor of using the newappendTo(RuntimeContext, Object)method for applying external resources. To ensure backward compatibility, this method (and other similar pre-4.0.0 methods) now attempts to automatically adopt the new approach. However, depending on the implementation, compatibility might not be fully guaranteed.- Parameters:
streams- The remote or local resources to apply.service- The Knowledge service.typeResolver- The TypeResolver to use.- Returns:
- A new instance of Knowledge.
- Throws:
IOException- If the resources cannot be read.UnsupportedOperationException- If this method is not supported by the implementation.
-
load
Loads a specific DSL (Domain-Specific Language) knowledge provider based on the provided identifier.- Parameters:
dsl- The identifier for the DSL provider to load.- Returns:
- The DSLKnowledgeProvider implementation matching the given identifier.
- Throws:
NullPointerException- if the dsl argument is null.IllegalStateException- if no or multiple providers were found for the specified DSL identifier.
-
load
Attempts to load and instantiate aDSLKnowledgeProviderimplementation.- Parameters:
dsl- TheClassobject corresponding to the DSL implementation class. This class must implement theDSLKnowledgeProviderinterface and have a public no-argument constructor. Must not benull.- Returns:
- An instance of the specified
DSLKnowledgeProviderimplementation. - Throws:
IllegalStateException- If the instantiation of the DSL class instance fails for any reason, including if the input parameter isnull.
-
appendTo(RuntimeContext, Object)method instead.