final Dialect.AnalysisResult analysis = dialect.analyzeExpression( context,
accumDescr,
accumDescr.getExpression(),
new Map[]{declarationsMap, context.getPackageBuilder().getGlobals()} );
MVELCompilationUnit unit = dialect.getMVELCompilationUnit( (String) accumDescr.getExpression(),
analysis,
previousDeclarations,
(Declaration[]) source.getOuterDeclarations().values().toArray( new Declaration[source.getOuterDeclarations().size()] ),
null,
context );
AccumulateFunction function = context.getConfiguration().getAccumulateFunction( accumDescr.getFunctionIdentifier() );
accumulator = new MVELAccumulatorFunctionExecutor( unit,
function );
} else {
// it is a custom accumulate
Map<String, Class< ? >> declarationsMap = context.getDeclarationResolver().getDeclarationClasses( context.getRule() );
final MVELAnalysisResult initCodeAnalysis = (MVELAnalysisResult) dialect.analyzeBlock( context,
accumDescr,
accumDescr.getInitCode(),
new Map[]{declarationsMap, context.getPackageBuilder().getGlobals()} );
final MVELAnalysisResult actionCodeAnalysis = (MVELAnalysisResult) dialect.analyzeBlock( context,
accumDescr,
null,
accumDescr.getActionCode(),
new Map[]{declarationsMap, context.getPackageBuilder().getGlobals()},
initCodeAnalysis.getMvelVariables() );
final MVELAnalysisResult resultCodeAnalysis = (MVELAnalysisResult) dialect.analyzeExpression( context,
accumDescr,
accumDescr.getResultCode(),
new Map[]{declarationsMap, context.getPackageBuilder().getGlobals()},
initCodeAnalysis.getMvelVariables() );
Dialect.AnalysisResult reverseCodeAnalysis = null;
if ( accumDescr.getReverseCode() != null ) {
reverseCodeAnalysis = dialect.analyzeBlock( context,
accumDescr,
null,
accumDescr.getActionCode(),
new Map[]{declarationsMap, context.getPackageBuilder().getGlobals()},
initCodeAnalysis.getMvelVariables() );
}
MVELCompilationUnit initUnit = dialect.getMVELCompilationUnit( (String) accumDescr.getInitCode(),
initCodeAnalysis,
previousDeclarations,
(Declaration[]) source.getOuterDeclarations().values().toArray( new Declaration[source.getOuterDeclarations().size()] ),
null,
context );
MVELCompilationUnit actionUnit = dialect.getMVELCompilationUnit( (String) accumDescr.getActionCode(),
actionCodeAnalysis,
previousDeclarations,
(Declaration[]) source.getOuterDeclarations().values().toArray( new Declaration[source.getOuterDeclarations().size()] ),
initCodeAnalysis.getMvelVariables(),
context );
MVELCompilationUnit reverseUnit = null;
if ( accumDescr.getReverseCode() != null ) {
reverseUnit = dialect.getMVELCompilationUnit( (String) accumDescr.getReverseCode(),
reverseCodeAnalysis,
previousDeclarations,
(Declaration[]) source.getOuterDeclarations().values().toArray( new Declaration[source.getOuterDeclarations().size()] ),
initCodeAnalysis.getMvelVariables(),
context );
}
MVELCompilationUnit resultUnit = dialect.getMVELCompilationUnit( (String) accumDescr.getResultCode(),
resultCodeAnalysis,
previousDeclarations,
(Declaration[]) source.getOuterDeclarations().values().toArray( new Declaration[source.getOuterDeclarations().size()] ),
initCodeAnalysis.getMvelVariables(),
context );