Package org.drools.core.impl
Class KnowledgeBaseImpl
- java.lang.Object
-
- org.drools.core.impl.KnowledgeBaseImpl
-
- All Implemented Interfaces:
Externalizable
,Serializable
,InternalKnowledgeBase
,org.kie.api.event.kiebase.KieBaseEventManager
,org.kie.api.KieBase
public class KnowledgeBaseImpl extends Object implements InternalKnowledgeBase, Externalizable
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
KnowledgeBaseImpl.ClassRegister
-
Field Summary
Fields Modifier and Type Field Description List<List<String>>
jaxbClasses
Set<org.kie.api.event.kiebase.KieBaseEventListener>
kieBaseListeners
protected static org.slf4j.Logger
logger
protected Map<String,InternalKnowledgePackage>
pkgs
-
Constructor Summary
Constructors Constructor Description KnowledgeBaseImpl()
KnowledgeBaseImpl(String id, RuleBaseConfiguration config)
-
Method Summary
-
-
-
Constructor Detail
-
KnowledgeBaseImpl
public KnowledgeBaseImpl()
-
KnowledgeBaseImpl
public KnowledgeBaseImpl(String id, RuleBaseConfiguration config)
-
-
Method Detail
-
initMBeans
public void initMBeans()
- Specified by:
initMBeans
in interfaceInternalKnowledgeBase
-
nextWorkingMemoryCounter
public int nextWorkingMemoryCounter()
- Specified by:
nextWorkingMemoryCounter
in interfaceInternalKnowledgeBase
-
getWorkingMemoryCounter
public int getWorkingMemoryCounter()
- Specified by:
getWorkingMemoryCounter
in interfaceInternalKnowledgeBase
-
addEventListener
public void addEventListener(org.kie.api.event.kiebase.KieBaseEventListener listener)
- Specified by:
addEventListener
in interfaceorg.kie.api.event.kiebase.KieBaseEventManager
-
removeEventListener
public void removeEventListener(org.kie.api.event.kiebase.KieBaseEventListener listener)
- Specified by:
removeEventListener
in interfaceorg.kie.api.event.kiebase.KieBaseEventManager
-
getKieBaseEventListeners
public Collection<org.kie.api.event.kiebase.KieBaseEventListener> getKieBaseEventListeners()
- Specified by:
getKieBaseEventListeners
in interfaceorg.kie.api.event.kiebase.KieBaseEventManager
-
getSessionConfiguration
public SessionConfiguration getSessionConfiguration()
- Specified by:
getSessionConfiguration
in interfaceInternalKnowledgeBase
-
removeKiePackage
public void removeKiePackage(String packageName)
- Specified by:
removeKiePackage
in interfaceorg.kie.api.KieBase
-
getRule
public org.kie.api.definition.rule.Rule getRule(String packageName, String ruleName)
- Specified by:
getRule
in interfaceorg.kie.api.KieBase
-
getQuery
public org.kie.api.definition.rule.Query getQuery(String packageName, String queryName)
- Specified by:
getQuery
in interfaceorg.kie.api.KieBase
-
newKieSessionsPool
public org.kie.api.runtime.KieSessionsPool newKieSessionsPool(int initialSize)
- Specified by:
newKieSessionsPool
in interfaceorg.kie.api.KieBase
-
newKieSession
public org.kie.api.runtime.KieSession newKieSession()
- Specified by:
newKieSession
in interfaceorg.kie.api.KieBase
-
newKieSession
public org.kie.api.runtime.KieSession newKieSession(org.kie.api.runtime.KieSessionConfiguration conf, org.kie.api.runtime.Environment environment)
- Specified by:
newKieSession
in interfaceorg.kie.api.KieBase
-
createSession
public StatefulKnowledgeSessionImpl createSession(long id, FactHandleFactory handleFactory, long propagationContext, SessionConfiguration config, InternalAgenda agenda, org.kie.api.runtime.Environment environment)
- Specified by:
createSession
in interfaceInternalKnowledgeBase
-
internalCreateStatefulKnowledgeSession
public StatefulKnowledgeSessionImpl internalCreateStatefulKnowledgeSession(org.kie.api.runtime.Environment environment, SessionConfiguration sessionConfig, boolean fromPool)
-
getKieSessions
public Collection<? extends org.kie.api.runtime.KieSession> getKieSessions()
- Specified by:
getKieSessions
in interfaceorg.kie.api.KieBase
-
newStatelessKieSession
public org.kie.api.runtime.StatelessKieSession newStatelessKieSession(org.kie.api.runtime.KieSessionConfiguration conf)
- Specified by:
newStatelessKieSession
in interfaceorg.kie.api.KieBase
-
newStatelessKieSession
public org.kie.api.runtime.StatelessKieSession newStatelessKieSession()
- Specified by:
newStatelessKieSession
in interfaceorg.kie.api.KieBase
-
getKiePackages
public Collection<org.kie.api.definition.KiePackage> getKiePackages()
- Specified by:
getKiePackages
in interfaceorg.kie.api.KieBase
-
getKiePackage
public org.kie.api.definition.KiePackage getKiePackage(String packageName)
- Specified by:
getKiePackage
in interfaceorg.kie.api.KieBase
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
Handles the read serialization of the Package. Patterns in Rules may reference generated data which cannot be serialized by default methods. The Package uses PackageCompilationData to hold a reference to the generated bytecode; which must be restored before any Rules. A custom ObjectInputStream, able to resolve classes against the bytecode in the PackageCompilationData, is used to restore the Rules.- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
Handles the write serialization of the Package. Patterns in Rules may reference generated data which cannot be serialized by default methods. The Package uses PackageCompilationData to hold a reference to the generated bytecode. The generated bytecode must be restored before any Rules.- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
getId
public String getId()
- Specified by:
getId
in interfaceInternalKnowledgeBase
- Returns:
- the id
-
disposeStatefulSession
public void disposeStatefulSession(StatefulKnowledgeSessionImpl statefulSession)
- Specified by:
disposeStatefulSession
in interfaceInternalKnowledgeBase
-
newFactHandleFactory
public FactHandleFactory newFactHandleFactory()
- Specified by:
newFactHandleFactory
in interfaceInternalKnowledgeBase
-
newFactHandleFactory
public FactHandleFactory newFactHandleFactory(long id, long counter)
- Specified by:
newFactHandleFactory
in interfaceInternalKnowledgeBase
-
getProcesses
public Collection<org.kie.api.definition.process.Process> getProcesses()
- Specified by:
getProcesses
in interfaceorg.kie.api.KieBase
-
getPackages
public InternalKnowledgePackage[] getPackages()
-
getPackagesMap
public Map<String,InternalKnowledgePackage> getPackagesMap()
- Specified by:
getPackagesMap
in interfaceInternalKnowledgeBase
-
getGlobals
public Map<String,Class<?>> getGlobals()
- Specified by:
getGlobals
in interfaceInternalKnowledgeBase
-
readLock
public void readLock()
- Specified by:
readLock
in interfaceInternalKnowledgeBase
-
readUnlock
public void readUnlock()
- Specified by:
readUnlock
in interfaceInternalKnowledgeBase
-
addPackages
public void addPackages(Collection<? extends org.kie.api.definition.KiePackage> newPkgs)
Add aPackage
to the network. Iterates through thePackage
adding Each individualRule
to the network. Before update network each referencedWorkingMemory
is locked.- Specified by:
addPackages
in interfaceInternalKnowledgeBase
- Parameters:
newPkgs
- The package to add.
-
addPackage
public Future<org.kie.api.definition.KiePackage> addPackage(org.kie.api.definition.KiePackage newPkg)
- Specified by:
addPackage
in interfaceInternalKnowledgeBase
-
enqueueModification
public void enqueueModification(Runnable modification)
- Specified by:
enqueueModification
in interfaceInternalKnowledgeBase
-
flushModifications
public boolean flushModifications()
- Specified by:
flushModifications
in interfaceInternalKnowledgeBase
-
processAllTypesDeclaration
public void processAllTypesDeclaration(Collection<InternalKnowledgePackage> pkgs)
- Specified by:
processAllTypesDeclaration
in interfaceInternalKnowledgeBase
-
hasMultipleAgendaGroups
public boolean hasMultipleAgendaGroups()
- Specified by:
hasMultipleAgendaGroups
in interfaceInternalKnowledgeBase
-
registerFunctionClassAndInnerClasses
public static void registerFunctionClassAndInnerClasses(String functionClassName, JavaDialectRuntimeData runtime, KnowledgeBaseImpl.ClassRegister consumer) throws ClassNotFoundException
- Throws:
ClassNotFoundException
-
registerTypeDeclaration
public void registerTypeDeclaration(TypeDeclaration newDecl, InternalKnowledgePackage newPkg)
- Specified by:
registerTypeDeclaration
in interfaceInternalKnowledgeBase
-
processTypeDeclaration
protected void processTypeDeclaration(TypeDeclaration newDecl, InternalKnowledgePackage newPkg)
-
registerAndLoadTypeDefinition
public Class<?> registerAndLoadTypeDefinition(String className, byte[] def) throws ClassNotFoundException
- Specified by:
registerAndLoadTypeDefinition
in interfaceInternalKnowledgeBase
- Throws:
ClassNotFoundException
-
addGlobal
public void addGlobal(String identifier, Class clazz)
- Specified by:
addGlobal
in interfaceInternalKnowledgeBase
-
removeGlobal
public void removeGlobal(String identifier)
- Specified by:
removeGlobal
in interfaceInternalKnowledgeBase
-
setupRete
protected void setupRete()
-
registerAddedEntryNodeCache
public void registerAddedEntryNodeCache(EntryPointNode node)
- Specified by:
registerAddedEntryNodeCache
in interfaceInternalKnowledgeBase
-
getAddedEntryNodeCache
public Set<EntryPointNode> getAddedEntryNodeCache()
- Specified by:
getAddedEntryNodeCache
in interfaceInternalKnowledgeBase
-
registeRremovedEntryNodeCache
public void registeRremovedEntryNodeCache(EntryPointNode node)
- Specified by:
registeRremovedEntryNodeCache
in interfaceInternalKnowledgeBase
-
getRemovedEntryNodeCache
public Set<EntryPointNode> getRemovedEntryNodeCache()
- Specified by:
getRemovedEntryNodeCache
in interfaceInternalKnowledgeBase
-
getRete
public Rete getRete()
Retrieve the Rete-OO network for thisRuleBase
.- Specified by:
getRete
in interfaceInternalKnowledgeBase
- Returns:
- The RETE-OO network.
-
getReteooBuilder
public ReteooBuilder getReteooBuilder()
- Specified by:
getReteooBuilder
in interfaceInternalKnowledgeBase
-
getNodeCount
public int getNodeCount()
- Specified by:
getNodeCount
in interfaceInternalKnowledgeBase
-
getMemoryCount
public int getMemoryCount(String topic)
- Specified by:
getMemoryCount
in interfaceInternalKnowledgeBase
-
registerSegmentPrototype
public void registerSegmentPrototype(LeftTupleSource tupleSource, SegmentMemory smem)
-
hasSegmentPrototypes
public boolean hasSegmentPrototypes()
- Specified by:
hasSegmentPrototypes
in interfaceInternalKnowledgeBase
-
invalidateSegmentPrototype
public void invalidateSegmentPrototype(LeftTupleNode rootNode)
- Specified by:
invalidateSegmentPrototype
in interfaceInternalKnowledgeBase
-
createSegmentFromPrototype
public SegmentMemory createSegmentFromPrototype(InternalWorkingMemory wm, LeftTupleSource tupleSource)
- Specified by:
createSegmentFromPrototype
in interfaceInternalKnowledgeBase
-
getSegmentPrototype
public SegmentMemory.Prototype getSegmentPrototype(SegmentMemory segment)
- Specified by:
getSegmentPrototype
in interfaceInternalKnowledgeBase
-
getExactTypeDeclaration
public TypeDeclaration getExactTypeDeclaration(Class<?> clazz)
- Specified by:
getExactTypeDeclaration
in interfaceInternalKnowledgeBase
-
getOrCreateExactTypeDeclaration
public TypeDeclaration getOrCreateExactTypeDeclaration(Class<?> clazz)
- Specified by:
getOrCreateExactTypeDeclaration
in interfaceInternalKnowledgeBase
-
getTypeDeclaration
public TypeDeclaration getTypeDeclaration(Class<?> clazz)
- Specified by:
getTypeDeclaration
in interfaceInternalKnowledgeBase
-
getTypeDeclarations
public Collection<TypeDeclaration> getTypeDeclarations()
- Specified by:
getTypeDeclarations
in interfaceInternalKnowledgeBase
-
beforeIncrementalUpdate
public void beforeIncrementalUpdate(KieBaseUpdate kieBaseUpdate)
- Specified by:
beforeIncrementalUpdate
in interfaceInternalKnowledgeBase
-
afterIncrementalUpdate
public void afterIncrementalUpdate(KieBaseUpdate kieBaseUpdate)
- Specified by:
afterIncrementalUpdate
in interfaceInternalKnowledgeBase
-
addRules
public void addRules(Collection<RuleImpl> rules) throws InvalidPatternException
- Specified by:
addRules
in interfaceInternalKnowledgeBase
- Throws:
InvalidPatternException
-
removeQuery
public void removeQuery(String packageName, String ruleName)
- Specified by:
removeQuery
in interfaceorg.kie.api.KieBase
-
removeRule
public void removeRule(String packageName, String ruleName)
- Specified by:
removeRule
in interfaceorg.kie.api.KieBase
-
removeRules
public void removeRules(Collection<RuleImpl> rules)
- Specified by:
removeRules
in interfaceInternalKnowledgeBase
-
removeFunction
public void removeFunction(String packageName, String functionName)
- Specified by:
removeFunction
in interfaceorg.kie.api.KieBase
-
addProcess
public void addProcess(org.kie.api.definition.process.Process process)
- Specified by:
addProcess
in interfaceInternalKnowledgeBase
-
removeProcess
public void removeProcess(String id)
- Specified by:
removeProcess
in interfaceInternalKnowledgeBase
- Specified by:
removeProcess
in interfaceorg.kie.api.KieBase
-
getProcess
public org.kie.api.definition.process.Process getProcess(String id)
- Specified by:
getProcess
in interfaceorg.kie.api.KieBase
-
addStatefulSession
public void addStatefulSession(StatefulKnowledgeSessionImpl wm)
-
getPackage
public InternalKnowledgePackage getPackage(String name)
- Specified by:
getPackage
in interfaceInternalKnowledgeBase
-
getWorkingMemories
public Collection<InternalWorkingMemory> getWorkingMemories()
- Specified by:
getWorkingMemories
in interfaceInternalKnowledgeBase
-
getConfiguration
public RuleBaseConfiguration getConfiguration()
- Specified by:
getConfiguration
in interfaceInternalKnowledgeBase
-
getRootClassLoader
public ClassLoader getRootClassLoader()
- Specified by:
getRootClassLoader
in interfaceInternalKnowledgeBase
-
executeQueuedActions
public void executeQueuedActions()
- Specified by:
executeQueuedActions
in interfaceInternalKnowledgeBase
-
createNewPartitionId
public RuleBasePartitionId createNewPartitionId()
- Specified by:
createNewPartitionId
in interfaceInternalKnowledgeBase
-
getFactType
public org.kie.api.definition.type.FactType getFactType(String packageName, String typeName)
- Specified by:
getFactType
in interfaceorg.kie.api.KieBase
-
getClassFieldAccessorCache
public ClassFieldAccessorCache getClassFieldAccessorCache()
- Specified by:
getClassFieldAccessorCache
in interfaceInternalKnowledgeBase
-
getEntryPointIds
public Set<String> getEntryPointIds()
- Specified by:
getEntryPointIds
in interfaceorg.kie.api.KieBase
-
getTripleStore
public TripleStore getTripleStore()
- Specified by:
getTripleStore
in interfaceInternalKnowledgeBase
-
getTraitRegistry
public TraitRegistry getTraitRegistry()
- Specified by:
getTraitRegistry
in interfaceInternalKnowledgeBase
-
removeObjectsGeneratedFromResource
public boolean removeObjectsGeneratedFromResource(org.kie.api.io.Resource resource)
- Specified by:
removeObjectsGeneratedFromResource
in interfaceInternalKnowledgeBase
-
getResolvedReleaseId
public org.kie.api.builder.ReleaseId getResolvedReleaseId()
- Specified by:
getResolvedReleaseId
in interfaceInternalKnowledgeBase
-
setResolvedReleaseId
public void setResolvedReleaseId(org.kie.api.builder.ReleaseId currentReleaseId)
- Specified by:
setResolvedReleaseId
in interfaceInternalKnowledgeBase
-
getContainerId
public String getContainerId()
- Specified by:
getContainerId
in interfaceInternalKnowledgeBase
-
setContainerId
public void setContainerId(String containerId)
- Specified by:
setContainerId
in interfaceInternalKnowledgeBase
-
setKieContainer
public void setKieContainer(InternalKieContainer kieContainer)
- Specified by:
setKieContainer
in interfaceInternalKnowledgeBase
-
getKieContainer
public InternalKieContainer getKieContainer()
-
getRuleUnitDescriptionRegistry
public RuleUnitDescriptionRegistry getRuleUnitDescriptionRegistry()
- Specified by:
getRuleUnitDescriptionRegistry
in interfaceInternalKnowledgeBase
-
hasUnits
public boolean hasUnits()
- Specified by:
hasUnits
in interfaceInternalKnowledgeBase
-
getReceiveNodes
public List<AsyncReceiveNode> getReceiveNodes()
- Specified by:
getReceiveNodes
in interfaceInternalKnowledgeBase
-
addReceiveNode
public void addReceiveNode(AsyncReceiveNode node)
- Specified by:
addReceiveNode
in interfaceInternalKnowledgeBase
-
-