Package org.drools.base.definitions.impl
Class KnowledgePackageImpl
java.lang.Object
org.drools.base.definitions.impl.KnowledgePackageImpl
- All Implemented Interfaces:
Externalizable,Serializable,InternalKnowledgePackage,KiePackage
public class KnowledgePackageImpl
extends Object
implements InternalKnowledgePackage, Externalizable
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<String,AccumulateFunction> protected DialectRuntimeRegistryprotected Map<String,ImportDeclaration> protected StringName of the pkg.protected booleanprotected ResourceTypePackageRegistrySet of all rule-names in thisPackage.protected Map<String,TypeDeclaration> protected booleanThis is to indicate the the package has no errors during the compilation/building phaseprotected Map<String,WindowDeclaration> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAccumulateFunction(String name, AccumulateFunction function) voidaddCloningResource(String key, Object resource) voidvoidaddFunction(Function function) voidvoidaddImport(ImportDeclaration importDecl) voidaddProcess(Process process) Add a rule flow to this package.voidaddPrototype(Prototype prototype) voidAdd aRuleto thisPackage.voidaddStaticImport(String functionImport) voidaddTypeDeclaration(TypeDeclaration typeDecl) voidvoidThis will throw an exception if the package is not validvoidclear()deepCloneIfAlreadyInUse(ClassLoader classLoader) booleanThis will return the error summary (if any) if the package is invalid.getExactTypeDeclaration(Class<?> clazz) getFactType(String typeName) getFunction(String name) protected String[]getName()Retrieve the name of thisPackage.getPrototype(String name) Retrieve aRuleby name.Get the rule flows for this package.getRules()getRulesGeneratedFromResource(Resource resource) getTypeDeclaration(Class<?> clazz) getTypeDeclaration(String type) inthashCode()booleanisValid()voidmergeTraitRegistry(RuleBase knowledgeBase) booleanvoidreadExternal(ObjectInput stream) Handles the read serialization of the Package.booleanvoidremoveFunction(String functionName) voidremoveFunctionImport(String functionImport) removeFunctionsGeneratedFromResource(Resource resource) voidremoveGlobal(String identifier) booleanremoveObjectsGeneratedFromResource(Resource resource) removeProcessesGeneratedFromResource(Resource resource) voidremoveRule(RuleImpl rule) voidremoveRuleFlow(String id) Rule flows can be removed by ID.removeRulesGeneratedFromResource(Resource resource) voidremoveTypeDeclaration(String type) protected voidremoveTypesGeneratedFromResource(Resource resource) voidOnce this is called, the package will be marked as invalidvoidsetClassLoader(ClassLoader classLoader) voidOnce this is called, the package will be marked as invalidvoidtoString()voidvoidwriteExternal(ObjectOutput stream) Handles the write serialization of the Package.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.drools.base.definitions.InternalKnowledgePackage
buildFieldAccessors, getFieldExtractor, getFieldType, getReader, getWiringResults, mergeStore, removeClass, setClassFieldAccessorCache, wireObjectType, wireStore
-
Field Details
-
name
Name of the pkg. -
rules
Set of all rule-names in thisPackage. -
imports
-
functions
-
accumulateFunctions
-
staticImports
-
globals
-
prototypes
-
dialectRuntimeRegistry
-
typeDeclarations
-
entryPointsIds
-
windowDeclarations
-
resourceTypePackages
-
cloningResources
-
valid
protected boolean validThis is to indicate the the package has no errors during the compilation/building phase -
needStreamMode
protected boolean needStreamMode
-
-
Constructor Details
-
KnowledgePackageImpl
public KnowledgePackageImpl() -
KnowledgePackageImpl
Construct.- Parameters:
name- The name of thisPackage.
-
-
Method Details
-
getResourceTypePackages
- Specified by:
getResourceTypePackagesin interfaceInternalKnowledgePackage
-
getRules
- Specified by:
getRulesin interfaceKiePackage
-
getFunction
-
getProcesses
- Specified by:
getProcessesin interfaceKiePackage
-
getFactTypes
- Specified by:
getFactTypesin interfaceKiePackage
-
getQueries
- Specified by:
getQueriesin interfaceKiePackage
-
getFunctionNames
- Specified by:
getFunctionNamesin interfaceKiePackage
-
getGlobalVariables
- Specified by:
getGlobalVariablesin interfaceKiePackage
-
writeExternal
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- Parameters:
stream- out the stream to write the object to; should be an instance of DroolsObjectOutputStream or OutputStream- Throws:
IOException
-
readExternal
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- Parameters:
stream- , the stream to read data from in order to restore the object; should be an instance of DroolsObjectInputStream or InputStream- Throws:
IOExceptionClassNotFoundException
-
getName
Retrieve the name of thisPackage.- Specified by:
getNamein interfaceKiePackage- Returns:
- The name of this
Package.
-
getPackageClassLoader
- Specified by:
getPackageClassLoaderin interfaceInternalKnowledgePackage
-
getDialectRuntimeRegistry
- Specified by:
getDialectRuntimeRegistryin interfaceInternalKnowledgePackage
-
addImport
- Specified by:
addImportin interfaceInternalKnowledgePackage
-
getImports
- Specified by:
getImportsin interfaceInternalKnowledgePackage
-
addTypeDeclaration
- Specified by:
addTypeDeclarationin interfaceInternalKnowledgePackage
-
removeTypeDeclaration
- Specified by:
removeTypeDeclarationin interfaceInternalKnowledgePackage
-
getTypeDeclarations
- Specified by:
getTypeDeclarationsin interfaceInternalKnowledgePackage
-
getTypeDeclaration
- Specified by:
getTypeDeclarationin interfaceInternalKnowledgePackage
-
getExactTypeDeclaration
-
getTypeDeclaration
- Specified by:
getTypeDeclarationin interfaceInternalKnowledgePackage
-
addStaticImport
- Specified by:
addStaticImportin interfaceInternalKnowledgePackage
-
addFunction
- Specified by:
addFunctionin interfaceInternalKnowledgePackage
-
getFunctions
- Specified by:
getFunctionsin interfaceInternalKnowledgePackage
-
addAccumulateFunction
- Specified by:
addAccumulateFunctionin interfaceInternalKnowledgePackage
-
getAccumulateFunctions
- Specified by:
getAccumulateFunctionsin interfaceInternalKnowledgePackage
-
removeFunctionImport
-
getStaticImports
- Specified by:
getStaticImportsin interfaceInternalKnowledgePackage
-
addGlobal
- Specified by:
addGlobalin interfaceInternalKnowledgePackage
-
removeGlobal
- Specified by:
removeGlobalin interfaceInternalKnowledgePackage
-
getGlobals
- Specified by:
getGlobalsin interfaceInternalKnowledgePackage
-
removeFunction
- Specified by:
removeFunctionin interfaceInternalKnowledgePackage
-
getPrototype
- Specified by:
getPrototypein interfaceInternalKnowledgePackage
-
addPrototype
- Specified by:
addPrototypein interfaceInternalKnowledgePackage
-
addRule
Add aRuleto thisPackage.- Specified by:
addRulein interfaceInternalKnowledgePackage- Parameters:
rule- The rule to add.- Throws:
DuplicateRuleNameException- If theRuleattempting to be added has the same name as another previously addedRule.InvalidRuleException- If theRuleis not valid.
-
addProcess
Add a rule flow to this package.- Specified by:
addProcessin interfaceInternalKnowledgePackage
-
getRuleFlows
Get the rule flows for this package. The key is the ruleflow id. It will be Collections.EMPTY_MAP if none have been added.- Specified by:
getRuleFlowsin interfaceInternalKnowledgePackage
-
removeRuleFlow
Rule flows can be removed by ID.- Specified by:
removeRuleFlowin interfaceInternalKnowledgePackage
-
removeRule
- Specified by:
removeRulein interfaceInternalKnowledgePackage
-
getRule
Retrieve aRuleby name.- Specified by:
getRulein interfaceInternalKnowledgePackage- Parameters:
name- The name of theRuleto retrieve.- Returns:
- The named
Rule, ornullif not suchRulehas been added to thisPackage.
-
toString
-
setError
Once this is called, the package will be marked as invalid- Specified by:
setErrorin interfaceInternalKnowledgePackage
-
resetErrors
public void resetErrors()Once this is called, the package will be marked as invalid- Specified by:
resetErrorsin interfaceInternalKnowledgePackage
-
isValid
public boolean isValid()- Specified by:
isValidin interfaceInternalKnowledgePackage- Returns:
- true (default) if there are no build/structural problems.
-
checkValidity
public void checkValidity()This will throw an exception if the package is not valid- Specified by:
checkValidityin interfaceInternalKnowledgePackage
-
getErrorSummary
This will return the error summary (if any) if the package is invalid. -
equals
-
hashCode
public int hashCode() -
clear
public void clear()- Specified by:
clearin interfaceInternalKnowledgePackage
-
getFactType
- Specified by:
getFactTypein interfaceInternalKnowledgePackage
-
wireTypeDeclarations
public void wireTypeDeclarations()- Specified by:
wireTypeDeclarationsin interfaceInternalKnowledgePackage
-
getEntryPointIds
- Specified by:
getEntryPointIdsin interfaceInternalKnowledgePackage
-
addEntryPointId
- Specified by:
addEntryPointIdin interfaceInternalKnowledgePackage
-
getTypeResolver
- Specified by:
getTypeResolverin interfaceInternalKnowledgePackage
-
setClassLoader
- Specified by:
setClassLoaderin interfaceInternalKnowledgePackage
-
getImplicitImports
-
getRuleUnitDescriptionLoader
- Specified by:
getRuleUnitDescriptionLoaderin interfaceInternalKnowledgePackage
-
addWindowDeclaration
- Specified by:
addWindowDeclarationin interfaceInternalKnowledgePackage
-
getWindowDeclarations
- Specified by:
getWindowDeclarationsin interfaceInternalKnowledgePackage
-
removeObjectsGeneratedFromResource
- Specified by:
removeObjectsGeneratedFromResourcein interfaceInternalKnowledgePackage
-
removeFromResourceTypePackageGeneratedFromResource
- Specified by:
removeFromResourceTypePackageGeneratedFromResourcein interfaceInternalKnowledgePackage
-
removeTypesGeneratedFromResource
- Specified by:
removeTypesGeneratedFromResourcein interfaceInternalKnowledgePackage
-
removeTypeFromStore
-
removeRulesGeneratedFromResource
- Specified by:
removeRulesGeneratedFromResourcein interfaceInternalKnowledgePackage
-
getRulesGeneratedFromResource
- Specified by:
getRulesGeneratedFromResourcein interfaceInternalKnowledgePackage
-
removeFunctionsGeneratedFromResource
- Specified by:
removeFunctionsGeneratedFromResourcein interfaceInternalKnowledgePackage
-
removeProcessesGeneratedFromResource
- Specified by:
removeProcessesGeneratedFromResourcein interfaceInternalKnowledgePackage
-
needsStreamMode
public boolean needsStreamMode() -
setNeedStreamMode
public void setNeedStreamMode()- Specified by:
setNeedStreamModein interfaceInternalKnowledgePackage
-
deepCloneIfAlreadyInUse
- Specified by:
deepCloneIfAlreadyInUsein interfaceInternalKnowledgePackage
-
mergeTraitRegistry
- Specified by:
mergeTraitRegistryin interfaceInternalKnowledgePackage
-
addCloningResource
- Specified by:
addCloningResourcein interfaceInternalKnowledgePackage
-