{
if (log.isDebugEnabled())
log.debug("Using cached ruleset for event [" + event + "] from provider [" + provider + "].");
for (int j = list.size() - 1; j >= 0; j--)
{
Rule rule = list.get(j);
event.getEvaluatedRules().add(rule);
context.clear();
DefaultParameterValueStore values = new DefaultParameterValueStore();
context.put(ParameterValueStore.class, values);
context.setState(RewriteState.EVALUATING);
if (rule.evaluate(event, context))
{
if (handleBindings(event, context, values))
{
context.setState(RewriteState.PERFORMING);
if (log.isDebugEnabled())
log.debug("Rule [" + rule + "] matched and will be performed.");
List<Operation> preOperations = context.getPreOperations();
for (int k = 0; k < preOperations.size(); k++)
{
preOperations.get(k).perform(event, context);
}
if (event.getFlow().is(ServletRewriteFlow.HANDLED))
{
return;
}
rule.perform(event, context);
if (event.getFlow().is(ServletRewriteFlow.HANDLED))
{
return;
}
List<Operation> postOperations = context.getPostOperations();
for (int k = 0; k < postOperations.size(); k++)
{
postOperations.get(k).perform(event, context);
}
if (event.getFlow().is(ServletRewriteFlow.HANDLED))
{
return;
}
}
}
else
{
event.getEvaluatedRules().remove(rule);
break;
}
}
}
}
/*
* Highly optimized loop - for performance reasons. Think before you change this!
*/
List<Rule> cacheable = new ArrayList<Rule>();
for (int i = rules.size() - 1; i >= 0; i--)
{
Rule rule = rules.get(i);
event.getEvaluatedRules().add(rule);
context.clear();
DefaultParameterValueStore values = new DefaultParameterValueStore();
context.put(ParameterValueStore.class, values);
context.setState(RewriteState.EVALUATING);
if (rule.evaluate(event, context))
{
if (handleBindings(event, context, values))
{
context.setState(RewriteState.PERFORMING);
if (log.isDebugEnabled())
log.debug("Rule [" + rule + "] matched and will be performed.");
cacheable.add(rule);
List<Operation> preOperations = context.getPreOperations();
for (int k = 0; k < preOperations.size(); k++)
{
preOperations.get(k).perform(event, context);
}
if (event.getFlow().is(ServletRewriteFlow.HANDLED))
{
break;
}
rule.perform(event, context);
if (event.getFlow().is(ServletRewriteFlow.HANDLED))
{
break;
}