@Override public String getName() { return exprExecutor.getName(); } };
private Object evaluateHeaders(InputStream headers) { String hs = IOUtils.toString(headers); BindingContext context = BindingContext.builder().addBinding("payload", new TypedValue<>(hs, DataType.XML_STRING)).build(); return expressionExecutor.evaluate("%dw 2.0 \n" + "output application/java \n" + "---\n" + "payload.headers mapObject (value, key) -> {\n" + " '$key' : write((key): value, \"application/xml\")\n" + "}", context).getValue(); }
@Benchmark public Object withParent() { return BindingContext.builder(globalCtx) .addBinding("onChild", new TypedValue<>("hello!", DataType.STRING)) .build(); }
@Test public void shouldBeAddedToBindingContext() { BindingContext.Builder bindingContextBuilder = BindingContext.builder(); ExpressionModule.Builder builder = ExpressionModule.builder(namespace); builder.addBinding("id", typedValue); ExpressionModule module = builder.build(); bindingContextBuilder.addModule(module); BindingContext bindingContext = bindingContextBuilder.build(); assertThat(bindingContext.modules(), hasSize(1)); assertThat(bindingContext.modules(), hasItem(module)); }
@Benchmark public Object parentLookup() { return childCtx.lookup("onParent"); } }
@Benchmark public Object fromEvent() { return addEventBindings(event, NULL_BINDING_CONTEXT); }
private BindingContext globalBinding() { return BindingContext.builder().addBinding("g", new TypedValue<>("gValue", STRING)).build(); }
@Benchmark public Object payloadBinding() { return bctx.lookup(BindingContextUtils.PAYLOAD); }
@Override public BindingContext getBindingContext() { TestExpressionFunction function = new TestExpressionFunction(); return builder() .addBinding("number", new TypedValue(1, NUMBER)) .addBinding("repeat", new TypedValue(function, fromFunction(function))) .build(); } }