Skip to content

Instantly share code, notes, and snippets.

Created June 19, 2013 18:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anonymous/6f502d28811baaf620fa to your computer and use it in GitHub Desktop.
*/
public class PackageBuildContext {
// current package
private Package pkg;
private PackageBuilder pkgBuilder;
// the contianer descr
private BaseDescr parentDescr;
// errors found when building the current context
private List<DroolsError> errors;
// list of generated methods
private List<String> methods;
// map<String invokerClassName, String invokerCode> of generated invokers
private Map<String, String> invokers;
// map<String invokerClassName, ConditionalElement ce> of generated invoker lookups
private Map invokerLookups;
// map<String invokerClassName, BaseDescr descr> of descriptor lookups
private Map descrLookups;
// a simple counter for generated names
private int counter;
private DialectCompiletimeRegistry dialectRegistry;
private Dialect dialect;
private boolean typesafe;
public PackageBuildContext() {
}
/**
* Default constructor
*/
public void init(final PackageBuilder pkgBuilder,
final Package pkg,
final BaseDescr parentDescr,
final DialectCompiletimeRegistry dialectRegistry,
final Dialect defaultDialect,
final Dialectable component) {
this.pkgBuilder = pkgBuilder;
this.pkg = pkg;
this.parentDescr = parentDescr;
this.methods = new ArrayList();
this.invokers = new HashMap<String, String>();
this.invokerLookups = new HashMap();
this.descrLookups = new HashMap();
this.errors = new ArrayList<DroolsError>();
this.dialectRegistry = dialectRegistry;
this.dialect = (component != null && component.getDialect() != null) ? this.dialectRegistry.getDialect( component.getDialect() ) : defaultDialect;
this.typesafe = ((MVELDialect) dialectRegistry.getDialect( "mvel" )).isStrictMode();
if ( dialect == null && (component != null && component.getDialect() != null) ) {
this.errors.add( new DescrBuildError( null,
parentDescr,
component,
"Unable to load Dialect '" + component.getDialect() + "'" ) );
// dialect is null, but fall back to default dialect so we can attempt to compile rest of rule.
this.dialect = defaultDialect;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment