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 interfaceKnowledgeBaseImpl.ClassRegister
-
Field Summary
Fields Modifier and Type Field Description List<List<String>>jaxbClassesSet<org.kie.api.event.kiebase.KieBaseEventListener>kieBaseListenersprotected static org.slf4j.Loggerloggerprotected 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:
initMBeansin interfaceInternalKnowledgeBase
-
nextWorkingMemoryCounter
public int nextWorkingMemoryCounter()
- Specified by:
nextWorkingMemoryCounterin interfaceInternalKnowledgeBase
-
getWorkingMemoryCounter
public int getWorkingMemoryCounter()
- Specified by:
getWorkingMemoryCounterin interfaceInternalKnowledgeBase
-
addEventListener
public void addEventListener(org.kie.api.event.kiebase.KieBaseEventListener listener)
- Specified by:
addEventListenerin interfaceorg.kie.api.event.kiebase.KieBaseEventManager
-
removeEventListener
public void removeEventListener(org.kie.api.event.kiebase.KieBaseEventListener listener)
- Specified by:
removeEventListenerin interfaceorg.kie.api.event.kiebase.KieBaseEventManager
-
getKieBaseEventListeners
public Collection<org.kie.api.event.kiebase.KieBaseEventListener> getKieBaseEventListeners()
- Specified by:
getKieBaseEventListenersin interfaceorg.kie.api.event.kiebase.KieBaseEventManager
-
getSessionConfiguration
public SessionConfiguration getSessionConfiguration()
- Specified by:
getSessionConfigurationin interfaceInternalKnowledgeBase
-
removeKiePackage
public void removeKiePackage(String packageName)
- Specified by:
removeKiePackagein interfaceorg.kie.api.KieBase
-
getRule
public org.kie.api.definition.rule.Rule getRule(String packageName, String ruleName)
- Specified by:
getRulein interfaceorg.kie.api.KieBase
-
getQuery
public org.kie.api.definition.rule.Query getQuery(String packageName, String queryName)
- Specified by:
getQueryin interfaceorg.kie.api.KieBase
-
newKieSessionsPool
public org.kie.api.runtime.KieSessionsPool newKieSessionsPool(int initialSize)
- Specified by:
newKieSessionsPoolin interfaceorg.kie.api.KieBase
-
newKieSession
public org.kie.api.runtime.KieSession newKieSession()
- Specified by:
newKieSessionin 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:
newKieSessionin 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:
createSessionin 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:
getKieSessionsin interfaceorg.kie.api.KieBase
-
newStatelessKieSession
public org.kie.api.runtime.StatelessKieSession newStatelessKieSession(org.kie.api.runtime.KieSessionConfiguration conf)
- Specified by:
newStatelessKieSessionin interfaceorg.kie.api.KieBase
-
newStatelessKieSession
public org.kie.api.runtime.StatelessKieSession newStatelessKieSession()
- Specified by:
newStatelessKieSessionin interfaceorg.kie.api.KieBase
-
getKiePackages
public Collection<org.kie.api.definition.KiePackage> getKiePackages()
- Specified by:
getKiePackagesin interfaceorg.kie.api.KieBase
-
getKiePackage
public org.kie.api.definition.KiePackage getKiePackage(String packageName)
- Specified by:
getKiePackagein 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:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
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:
writeExternalin interfaceExternalizable- Throws:
IOException
-
getId
public String getId()
- Specified by:
getIdin interfaceInternalKnowledgeBase- Returns:
- the id
-
disposeStatefulSession
public void disposeStatefulSession(StatefulKnowledgeSessionImpl statefulSession)
- Specified by:
disposeStatefulSessionin interfaceInternalKnowledgeBase
-
newFactHandleFactory
public FactHandleFactory newFactHandleFactory()
- Specified by:
newFactHandleFactoryin interfaceInternalKnowledgeBase
-
newFactHandleFactory
public FactHandleFactory newFactHandleFactory(long id, long counter)
- Specified by:
newFactHandleFactoryin interfaceInternalKnowledgeBase
-
getProcesses
public Collection<org.kie.api.definition.process.Process> getProcesses()
- Specified by:
getProcessesin interfaceorg.kie.api.KieBase
-
getPackages
public InternalKnowledgePackage[] getPackages()
-
getPackagesMap
public Map<String,InternalKnowledgePackage> getPackagesMap()
- Specified by:
getPackagesMapin interfaceInternalKnowledgeBase
-
getGlobals
public Map<String,Class<?>> getGlobals()
- Specified by:
getGlobalsin interfaceInternalKnowledgeBase
-
readLock
public void readLock()
- Specified by:
readLockin interfaceInternalKnowledgeBase
-
readUnlock
public void readUnlock()
- Specified by:
readUnlockin interfaceInternalKnowledgeBase
-
addPackages
public void addPackages(Collection<? extends org.kie.api.definition.KiePackage> newPkgs)
Add aPackageto the network. Iterates through thePackageadding Each individualRuleto the network. Before update network each referencedWorkingMemoryis locked.- Specified by:
addPackagesin interfaceInternalKnowledgeBase- Parameters:
newPkgs- The package to add.
-
addPackage
public Future<org.kie.api.definition.KiePackage> addPackage(org.kie.api.definition.KiePackage newPkg)
- Specified by:
addPackagein interfaceInternalKnowledgeBase
-
enqueueModification
public void enqueueModification(Runnable modification)
- Specified by:
enqueueModificationin interfaceInternalKnowledgeBase
-
flushModifications
public boolean flushModifications()
- Specified by:
flushModificationsin interfaceInternalKnowledgeBase
-
processAllTypesDeclaration
public void processAllTypesDeclaration(Collection<InternalKnowledgePackage> pkgs)
- Specified by:
processAllTypesDeclarationin interfaceInternalKnowledgeBase
-
hasMultipleAgendaGroups
public boolean hasMultipleAgendaGroups()
- Specified by:
hasMultipleAgendaGroupsin 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:
registerTypeDeclarationin interfaceInternalKnowledgeBase
-
processTypeDeclaration
protected void processTypeDeclaration(TypeDeclaration newDecl, InternalKnowledgePackage newPkg)
-
registerAndLoadTypeDefinition
public Class<?> registerAndLoadTypeDefinition(String className, byte[] def) throws ClassNotFoundException
- Specified by:
registerAndLoadTypeDefinitionin interfaceInternalKnowledgeBase- Throws:
ClassNotFoundException
-
addGlobal
public void addGlobal(String identifier, Class clazz)
- Specified by:
addGlobalin interfaceInternalKnowledgeBase
-
removeGlobal
public void removeGlobal(String identifier)
- Specified by:
removeGlobalin interfaceInternalKnowledgeBase
-
setupRete
protected void setupRete()
-
registerAddedEntryNodeCache
public void registerAddedEntryNodeCache(EntryPointNode node)
- Specified by:
registerAddedEntryNodeCachein interfaceInternalKnowledgeBase
-
getAddedEntryNodeCache
public Set<EntryPointNode> getAddedEntryNodeCache()
- Specified by:
getAddedEntryNodeCachein interfaceInternalKnowledgeBase
-
registeRremovedEntryNodeCache
public void registeRremovedEntryNodeCache(EntryPointNode node)
- Specified by:
registeRremovedEntryNodeCachein interfaceInternalKnowledgeBase
-
getRemovedEntryNodeCache
public Set<EntryPointNode> getRemovedEntryNodeCache()
- Specified by:
getRemovedEntryNodeCachein interfaceInternalKnowledgeBase
-
getRete
public Rete getRete()
Retrieve the Rete-OO network for thisRuleBase.- Specified by:
getRetein interfaceInternalKnowledgeBase- Returns:
- The RETE-OO network.
-
getReteooBuilder
public ReteooBuilder getReteooBuilder()
- Specified by:
getReteooBuilderin interfaceInternalKnowledgeBase
-
getNodeCount
public int getNodeCount()
- Specified by:
getNodeCountin interfaceInternalKnowledgeBase
-
getMemoryCount
public int getMemoryCount(String topic)
- Specified by:
getMemoryCountin interfaceInternalKnowledgeBase
-
registerSegmentPrototype
public void registerSegmentPrototype(LeftTupleSource tupleSource, SegmentMemory smem)
-
hasSegmentPrototypes
public boolean hasSegmentPrototypes()
- Specified by:
hasSegmentPrototypesin interfaceInternalKnowledgeBase
-
invalidateSegmentPrototype
public void invalidateSegmentPrototype(LeftTupleNode rootNode)
- Specified by:
invalidateSegmentPrototypein interfaceInternalKnowledgeBase
-
createSegmentFromPrototype
public SegmentMemory createSegmentFromPrototype(InternalWorkingMemory wm, LeftTupleSource tupleSource)
- Specified by:
createSegmentFromPrototypein interfaceInternalKnowledgeBase
-
getSegmentPrototype
public SegmentMemory.Prototype getSegmentPrototype(SegmentMemory segment)
- Specified by:
getSegmentPrototypein interfaceInternalKnowledgeBase
-
getExactTypeDeclaration
public TypeDeclaration getExactTypeDeclaration(Class<?> clazz)
- Specified by:
getExactTypeDeclarationin interfaceInternalKnowledgeBase
-
getOrCreateExactTypeDeclaration
public TypeDeclaration getOrCreateExactTypeDeclaration(Class<?> clazz)
- Specified by:
getOrCreateExactTypeDeclarationin interfaceInternalKnowledgeBase
-
getTypeDeclaration
public TypeDeclaration getTypeDeclaration(Class<?> clazz)
- Specified by:
getTypeDeclarationin interfaceInternalKnowledgeBase
-
getTypeDeclarations
public Collection<TypeDeclaration> getTypeDeclarations()
- Specified by:
getTypeDeclarationsin interfaceInternalKnowledgeBase
-
beforeIncrementalUpdate
public void beforeIncrementalUpdate(KieBaseUpdate kieBaseUpdate)
- Specified by:
beforeIncrementalUpdatein interfaceInternalKnowledgeBase
-
afterIncrementalUpdate
public void afterIncrementalUpdate(KieBaseUpdate kieBaseUpdate)
- Specified by:
afterIncrementalUpdatein interfaceInternalKnowledgeBase
-
addRules
public void addRules(Collection<RuleImpl> rules) throws InvalidPatternException
- Specified by:
addRulesin interfaceInternalKnowledgeBase- Throws:
InvalidPatternException
-
removeQuery
public void removeQuery(String packageName, String ruleName)
- Specified by:
removeQueryin interfaceorg.kie.api.KieBase
-
removeRule
public void removeRule(String packageName, String ruleName)
- Specified by:
removeRulein interfaceorg.kie.api.KieBase
-
removeRules
public void removeRules(Collection<RuleImpl> rules)
- Specified by:
removeRulesin interfaceInternalKnowledgeBase
-
removeFunction
public void removeFunction(String packageName, String functionName)
- Specified by:
removeFunctionin interfaceorg.kie.api.KieBase
-
addProcess
public void addProcess(org.kie.api.definition.process.Process process)
- Specified by:
addProcessin interfaceInternalKnowledgeBase
-
removeProcess
public void removeProcess(String id)
- Specified by:
removeProcessin interfaceInternalKnowledgeBase- Specified by:
removeProcessin interfaceorg.kie.api.KieBase
-
getProcess
public org.kie.api.definition.process.Process getProcess(String id)
- Specified by:
getProcessin interfaceorg.kie.api.KieBase
-
addStatefulSession
public void addStatefulSession(StatefulKnowledgeSessionImpl wm)
-
getPackage
public InternalKnowledgePackage getPackage(String name)
- Specified by:
getPackagein interfaceInternalKnowledgeBase
-
getWorkingMemories
public Collection<InternalWorkingMemory> getWorkingMemories()
- Specified by:
getWorkingMemoriesin interfaceInternalKnowledgeBase
-
getConfiguration
public RuleBaseConfiguration getConfiguration()
- Specified by:
getConfigurationin interfaceInternalKnowledgeBase
-
getRootClassLoader
public ClassLoader getRootClassLoader()
- Specified by:
getRootClassLoaderin interfaceInternalKnowledgeBase
-
executeQueuedActions
public void executeQueuedActions()
- Specified by:
executeQueuedActionsin interfaceInternalKnowledgeBase
-
createNewPartitionId
public RuleBasePartitionId createNewPartitionId()
- Specified by:
createNewPartitionIdin interfaceInternalKnowledgeBase
-
getFactType
public org.kie.api.definition.type.FactType getFactType(String packageName, String typeName)
- Specified by:
getFactTypein interfaceorg.kie.api.KieBase
-
getClassFieldAccessorCache
public ClassFieldAccessorCache getClassFieldAccessorCache()
- Specified by:
getClassFieldAccessorCachein interfaceInternalKnowledgeBase
-
getEntryPointIds
public Set<String> getEntryPointIds()
- Specified by:
getEntryPointIdsin interfaceorg.kie.api.KieBase
-
getTripleStore
public TripleStore getTripleStore()
- Specified by:
getTripleStorein interfaceInternalKnowledgeBase
-
getTraitRegistry
public TraitRegistry getTraitRegistry()
- Specified by:
getTraitRegistryin interfaceInternalKnowledgeBase
-
removeObjectsGeneratedFromResource
public boolean removeObjectsGeneratedFromResource(org.kie.api.io.Resource resource)
- Specified by:
removeObjectsGeneratedFromResourcein interfaceInternalKnowledgeBase
-
getResolvedReleaseId
public org.kie.api.builder.ReleaseId getResolvedReleaseId()
- Specified by:
getResolvedReleaseIdin interfaceInternalKnowledgeBase
-
setResolvedReleaseId
public void setResolvedReleaseId(org.kie.api.builder.ReleaseId currentReleaseId)
- Specified by:
setResolvedReleaseIdin interfaceInternalKnowledgeBase
-
getContainerId
public String getContainerId()
- Specified by:
getContainerIdin interfaceInternalKnowledgeBase
-
setContainerId
public void setContainerId(String containerId)
- Specified by:
setContainerIdin interfaceInternalKnowledgeBase
-
setKieContainer
public void setKieContainer(InternalKieContainer kieContainer)
- Specified by:
setKieContainerin interfaceInternalKnowledgeBase
-
getKieContainer
public InternalKieContainer getKieContainer()
-
getRuleUnitDescriptionRegistry
public RuleUnitDescriptionRegistry getRuleUnitDescriptionRegistry()
- Specified by:
getRuleUnitDescriptionRegistryin interfaceInternalKnowledgeBase
-
hasUnits
public boolean hasUnits()
- Specified by:
hasUnitsin interfaceInternalKnowledgeBase
-
getReceiveNodes
public List<AsyncReceiveNode> getReceiveNodes()
- Specified by:
getReceiveNodesin interfaceInternalKnowledgeBase
-
addReceiveNode
public void addReceiveNode(AsyncReceiveNode node)
- Specified by:
addReceiveNodein interfaceInternalKnowledgeBase
-
-