|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.drools.compiler.PackageBuilder
public class PackageBuilder
This is the main compiler class for parsing and compiling rules and assembling or merging them into a binary Package instance. This can be done by merging into existing binary packages, or totally from source. If you are using the Java dialect the JavaDialectConfiguration will attempt to validate that the specified compiler is in the classpath, using ClassLoader.loasClass(String). If you intented to just Janino sa the compiler you must either overload the compiler property before instantiating this class or the PackageBuilder, or make sure Eclipse is in the classpath, as Eclipse is the default. Normally, a complete package is built using one of the applicable addPackageFromXXX methods. It is however possible to construct a package incrementally by adding individual component parts. When a package is built incrementally package level attributes are cached and applied to Rules subsequently added. Caution should be exercised when using the same PackageBuilder to construct packages from multiple sources as the cached package level attributes will still apply even if the resource added to PackageBuilder does not explicitly include package level attributes.
Nested Class Summary | |
---|---|
static class |
PackageBuilder.ErrorHandler
This is the super of the error handlers. |
static class |
PackageBuilder.FunctionErrorHandler
|
static class |
PackageBuilder.MissingPackageNameException
|
static class |
PackageBuilder.PackageMergeException
|
static class |
PackageBuilder.RuleErrorHandler
|
static class |
PackageBuilder.RuleInvokerErrorHandler
There isn't much point in reporting invoker errors, as they are no help. |
static class |
PackageBuilder.SrcError
|
static class |
PackageBuilder.SrcErrorHandler
|
Field Summary | |
---|---|
protected DateFormats |
dateFormats
|
static RuleBuilder |
ruleBuilder
|
Constructor Summary | |
---|---|
PackageBuilder()
Use this when package is starting from scratch. |
|
PackageBuilder(Package pkg)
This will allow you to merge rules into this pre existing package. |
|
PackageBuilder(PackageBuilderConfiguration configuration)
Pass a specific configuration for the PackageBuilder PackageBuilderConfiguration is not thread safe and it also contains state. |
|
PackageBuilder(Package pkg,
PackageBuilderConfiguration configuration)
|
|
PackageBuilder(RuleBase ruleBase)
|
|
PackageBuilder(RuleBase ruleBase,
PackageBuilderConfiguration configuration)
|
Method Summary | |
---|---|
void |
addDsl(org.drools.io.Resource resource)
|
void |
addKnowledgeResource(org.drools.io.Resource resource,
org.drools.builder.ResourceType type,
org.drools.builder.ResourceConfiguration configuration)
|
void |
addPackage(Package newPkg)
|
void |
addPackage(PackageDescr packageDescr)
This adds a package from a Descr/AST This will also trigger a compile, if there are any generated classes to compile of course. |
void |
addPackageFromBrl(org.drools.io.Resource resource)
|
void |
addPackageFromDrl(Reader reader)
Load a rule package from DRL source. |
void |
addPackageFromDrl(Reader source,
Reader dsl)
Load a rule package from DRL source using the supplied DSL configuration. |
void |
addPackageFromDrl(org.drools.io.Resource resource)
|
void |
addPackageFromDslr(org.drools.io.Resource resource)
|
void |
addPackageFromXml(Reader reader)
Load a rule package from XML source. |
void |
addPackageFromXml(org.drools.io.Resource resource)
|
void |
addProcessFromXml(Reader processSource)
|
void |
addProcessFromXml(org.drools.io.Resource resource)
|
void |
addRuleFlow(Reader processSource)
Add a ruleflow (.rfm) asset to this package. |
boolean |
buildTypeDeclarationInterfaces(Class cls,
Set<TypeDeclaration> tdecls)
|
void |
buildTypeDeclarations(Class<?> cls,
Set<TypeDeclaration> tdecls)
|
void |
compileAll()
|
DateFormats |
getDateFormats()
|
String |
getDefaultDialect()
|
DefaultExpander |
getDslExpander()
Returns an expander for DSLs (only if there is a DSL configured for this package). |
PackageBuilderErrors |
getErrors()
|
Map<String,Class<?>> |
getGlobals()
|
Package |
getPackage()
|
PackageBuilderConfiguration |
getPackageBuilderConfiguration()
Return the PackageBuilderConfiguration for this PackageBuilder session |
Map<String,PackageRegistry> |
getPackageRegistry()
|
PackageRegistry |
getPackageRegistry(String name)
|
Package[] |
getPackages()
|
org.drools.util.CompositeClassLoader |
getRootClassLoader()
|
TypeDeclaration |
getTypeDeclaration(Class<?> cls)
|
boolean |
hasErrors()
This will return true if there were errors in the package building and compiling phase |
boolean |
isEmpty(String string)
|
void |
reloadAll()
|
protected void |
resetErrors()
Reset the error list. |
static Collection<TypeDeclarationDescr> |
sortByHierarchy(List<TypeDeclarationDescr> typeDeclarations)
Utility method to sort declared beans. |
void |
updateResults()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final RuleBuilder ruleBuilder
protected DateFormats dateFormats
Constructor Detail |
---|
public PackageBuilder()
public PackageBuilder(Package pkg)
public PackageBuilder(RuleBase ruleBase)
public PackageBuilder(PackageBuilderConfiguration configuration)
configuration
- public PackageBuilder(Package pkg, PackageBuilderConfiguration configuration)
public PackageBuilder(RuleBase ruleBase, PackageBuilderConfiguration configuration)
Method Detail |
---|
public void addPackageFromDrl(Reader reader) throws DroolsParserException, IOException
reader
-
DroolsParserException
IOException
public void addPackageFromDrl(org.drools.io.Resource resource) throws DroolsParserException, IOException
DroolsParserException
IOException
public void addPackageFromXml(Reader reader) throws DroolsParserException, IOException
reader
-
DroolsParserException
IOException
public void addPackageFromXml(org.drools.io.Resource resource) throws DroolsParserException, IOException
DroolsParserException
IOException
public void addPackageFromDrl(Reader source, Reader dsl) throws DroolsParserException, IOException
source
- The source of the rules.dsl
- The source of the domain specific language configuration.
DroolsParserException
IOException
public void addPackageFromDslr(org.drools.io.Resource resource) throws DroolsParserException, IOException
DroolsParserException
IOException
public void addPackageFromBrl(org.drools.io.Resource resource) throws DroolsParserException
DroolsParserException
public void addDsl(org.drools.io.Resource resource) throws IOException
IOException
public void addRuleFlow(Reader processSource)
public void addProcessFromXml(org.drools.io.Resource resource)
public void addProcessFromXml(Reader processSource)
public void addKnowledgeResource(org.drools.io.Resource resource, org.drools.builder.ResourceType type, org.drools.builder.ResourceConfiguration configuration)
public void addPackage(PackageDescr packageDescr)
public boolean isEmpty(String string)
public void updateResults()
public void compileAll()
public void reloadAll()
public void addPackage(Package newPkg)
public TypeDeclaration getTypeDeclaration(Class<?> cls)
public void buildTypeDeclarations(Class<?> cls, Set<TypeDeclaration> tdecls)
public boolean buildTypeDeclarationInterfaces(Class cls, Set<TypeDeclaration> tdecls)
public Package getPackage()
public Package[] getPackages()
public PackageBuilderConfiguration getPackageBuilderConfiguration()
public PackageRegistry getPackageRegistry(String name)
public Map<String,PackageRegistry> getPackageRegistry()
public DateFormats getDateFormats()
public DefaultExpander getDslExpander()
public Map<String,Class<?>> getGlobals()
public boolean hasErrors()
public PackageBuilderErrors getErrors()
protected void resetErrors()
public String getDefaultDialect()
public org.drools.util.CompositeClassLoader getRootClassLoader()
public static Collection<TypeDeclarationDescr> sortByHierarchy(List<TypeDeclarationDescr> typeDeclarations)
typeDeclarations
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |