MVELDialectRuntimeData data = (MVELDialectRuntimeData) context.getPkg().getDialectRuntimeRegistry().getDialectData( "mvel" );
ParserConfiguration conf = data.getParserConfiguration();
conf.setClassLoader( context.getKnowledgeBuilder().getRootClassLoader() );
final ParserContext pctx = new ParserContext( conf );
pctx.setStrictTypeEnforcement(false);
pctx.setStrongTyping( false );
pctx.addInput( "this",
thisClass );
pctx.addInput( "empty",
boolean.class ); // overrides the mvel empty label
MVEL.COMPILER_OPT_ALLOW_NAKED_METH_CALL = true;
MVEL.COMPILER_OPT_ALLOW_OVERRIDE_ALL_PROPHANDLING = true;
MVEL.COMPILER_OPT_ALLOW_RESOLVE_INNERCLASSES_WITH_DOTNOTATION = true;
MVEL.COMPILER_OPT_SUPPORT_JAVA_STYLE_CLASS_LITERALS = true;
try {
MVEL.analysisCompile( expr, pctx );
} catch (Exception e) {
// There is a problem in setting the inputs for this expression, but it will be
// reported during expression analysis, so swallow it at the moment
return;
}
if ( !pctx.getInputs().isEmpty() ) {
for ( String v : pctx.getInputs().keySet() ) {
// in the following if, we need to check that the expr actually contains a reference
// to an "empty" property, or the if will evaluate to true even if it doesn't
if ( "this".equals( v ) || (PropertyTools.getFieldOrAccessor( thisClass,
v ) != null && expr.matches( "(^|.*\\W)empty($|\\W.*)" )) ) {
descrBranch.getFieldAccessors().add( v );