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);