Class KnowledgeService
- java.lang.Object
-
- org.evrete.KnowledgeService
-
public class KnowledgeService extends Object
KnowledgeService is a root element of every Evrete-based application. It holds initial
Configuration, security settings, references to all required SPI implementations, and an instance of Java ExecutorService.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKnowledgeService.Builder
-
Constructor Summary
Constructors Constructor Description KnowledgeService()KnowledgeService(Configuration conf)
-
Method Summary
-
-
-
Constructor Detail
-
KnowledgeService
public KnowledgeService(Configuration conf)
-
KnowledgeService
public KnowledgeService()
-
-
Method Detail
-
builder
public static KnowledgeService.Builder builder()
-
builder
public static KnowledgeService.Builder builder(Configuration configuration)
-
getClassLoader
public ClassLoader getClassLoader()
-
setClassLoader
public void setClassLoader(ClassLoader classLoader)
-
newKnowledge
public Knowledge newKnowledge(TypeResolver typeResolver)
- Returns:
- an empty
Knowledgeinstance
-
newTypeResolver
public TypeResolver newTypeResolver()
-
getDSL
public DSLKnowledgeProvider getDSL(String dsl)
A convenience method to load specific DSL implementation;
- Parameters:
dsl- DSL name- Returns:
- new instance of DSL provider
- Throws:
IllegalStateException- if no implementation found by the given name
-
getDSL
public DSLKnowledgeProvider getDSL(Class<? extends DSLKnowledgeProvider> dsl)
A convenience method to load specific DSL implementation;
- Parameters:
dsl- DSL implementation class- Returns:
- new instance of DSL provider
- Throws:
IllegalStateException- if implementation could not be instantiated
-
newKnowledge
public Knowledge newKnowledge(String dsl, URL... resources) throws IOException
- Parameters:
dsl- DSL nameresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(Class<? extends DSLKnowledgeProvider> dsl, URL... resources) throws IOException
- Parameters:
dsl- DSL classresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(String dsl, File... resources) throws IOException
- Parameters:
dsl- DSL nameresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(Class<? extends DSLKnowledgeProvider> dsl, File... resources) throws IOException
- Parameters:
dsl- DSL classresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(Class<? extends DSLKnowledgeProvider> dsl, TypeResolver resolver, File... resources) throws IOException
- Parameters:
dsl- DSL classresolver- TypeResolver to useresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(String dsl, TypeResolver resolver, File... resources) throws IOException
- Parameters:
dsl- DSL classresolver- TypeResolver to useresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(String dsl, TypeResolver typeResolver, URL... resources) throws IOException
- Parameters:
dsl- DSL nametypeResolver- TypeResolver to useresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(Class<? extends DSLKnowledgeProvider> dsl, TypeResolver typeResolver, URL... resources) throws IOException
- Parameters:
dsl- DSL classtypeResolver- TypeResolver to useresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(String dsl, Reader... resources) throws IOException
- Parameters:
dsl- DSL nameresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(Class<? extends DSLKnowledgeProvider> dsl, Reader... resources) throws IOException
- Parameters:
dsl- DSL classresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(String dsl, TypeResolver typeResolver, Reader... resources) throws IOException
- Parameters:
dsl- DSL nametypeResolver- TypeResolver to useresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(Class<? extends DSLKnowledgeProvider> dsl, TypeResolver typeResolver, Reader... resources) throws IOException
- Parameters:
dsl- DSL classtypeResolver- TypeResolver to useresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(String dsl, InputStream... resources) throws IOException
- Parameters:
dsl- DSL nameresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(Class<? extends DSLKnowledgeProvider> dsl, InputStream... resources) throws IOException
- Parameters:
dsl- DSL classresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(String dsl, TypeResolver typeResolver, InputStream... resources) throws IOException
- Parameters:
dsl- DSL nametypeResolver- TypeResolver to useresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(Class<? extends DSLKnowledgeProvider> dsl, TypeResolver typeResolver, InputStream... resources) throws IOException
- Parameters:
dsl- DSL classtypeResolver- TypeResolver to useresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(String dsl, Class<?>... resources) throws IOException
This is a convenience method. The implementation gets URLs of each class and calls
newKnowledge(String, URL...)- Parameters:
dsl- DSL nameresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
shutdown
public void shutdown()
Shuts down the service and releases its internal resources. Once a service is shutdown, it can not be reused in the future.
-
getExecutor
public org.evrete.runtime.async.ForkJoinExecutor getExecutor()
-
getConfiguration
public Configuration getConfiguration()
-
getMemoryFactoryProvider
public MemoryFactoryProvider getMemoryFactoryProvider()
-
getExpressionResolverProvider
public ExpressionResolverProvider getExpressionResolverProvider()
-
getLiteralSourceCompiler
public LiteralSourceCompiler getLiteralSourceCompiler()
-
getTypeResolverProvider
public TypeResolverProvider getTypeResolverProvider()
-
newKnowledge
public Knowledge newKnowledge(Class<? extends DSLKnowledgeProvider> dsl, Class<?>... resources) throws IOException
This is a convenience method. The implementation gets URLs of each class and calls
newKnowledge(String, URL...)- Parameters:
dsl- DSL classresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(String dsl, TypeResolver typeResolver, Class<?>... resources) throws IOException
This is a convenience method. The implementation gets URLs of each class and calls
newKnowledge(String, TypeResolver, URL...)- Parameters:
dsl- DSL nametypeResolver- TypeResolver to useresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(Class<? extends DSLKnowledgeProvider> dsl, TypeResolver typeResolver, Class<?>... resources) throws IOException
This is a convenience method. The implementation gets URLs of each class and calls
newKnowledge(String, TypeResolver, URL...)- Parameters:
dsl- DSL classtypeResolver- TypeResolver to useresources- DSL resources- Returns:
- a
Knowledgeinstance built by DSL provider from given resources. - Throws:
IOException
-
newStatefulSession
public StatefulSession newStatefulSession()
This method is a shorthand for
newKnowledge().newStatefulSession()which returns an empty session instance.- Returns:
- an empty
StatefulSession
-
newStatelessSession
public StatelessSession newStatelessSession()
This method is a shorthand for
newKnowledge().newStatelessSession()which returns an empty session instance.- Returns:
- an empty
StatelessSession
-
newKnowledge
public Knowledge newKnowledge(String dsl, String... resources) throws IOException
- Throws:
IOException
-
newKnowledge
public Knowledge newKnowledge(Class<? extends DSLKnowledgeProvider> dsl, String... resources) throws IOException
- Throws:
IOException
-
-