}
return result;
}
protected ScriptContext populateBindings(ScriptEngine engine, Exchange exchange, Map<String, Object> attributes) {
ScriptContext context = engine.getContext();
int scope = ScriptContext.ENGINE_SCOPE;
context.setAttribute("context", exchange.getContext(), scope);
context.setAttribute("camelContext", exchange.getContext(), scope);
context.setAttribute("exchange", exchange, scope);
Message in = exchange.getIn();
context.setAttribute("request", in, scope);
context.setAttribute("headers", in.getHeaders(), scope);
context.setAttribute("body", in.getBody(), scope);
if (exchange.hasOut()) {
Message out = exchange.getOut();
context.setAttribute("out", out , scope);
context.setAttribute("response", out, scope);
}
// to make using properties component easier
context.setAttribute("properties", new ScriptPropertiesFunction(exchange.getContext()), scope);
// any additional attributes
if (attributes != null) {
for (Map.Entry<String, Object> entry : attributes.entrySet()) {
context.setAttribute(entry.getKey(), entry.getValue(), scope);
}
}
return context;
}