use of com.enonic.xp.script.runtime.ScriptSettings in project xp by enonic.
the class BeanContextImplTest method getBinding.
@Test
public void getBinding() {
final Supplier<String> binding = () -> "hello";
final ScriptSettings settings = ScriptSettings.create().binding(String.class, binding).build();
Mockito.when(this.executor.getScriptSettings()).thenReturn(settings);
assertNotNull(this.context.getBinding(String.class));
assertSame("hello", this.context.getBinding(String.class).get());
assertNotNull(this.context.getBinding(Integer.class));
assertNull(this.context.getBinding(Integer.class).get());
}
use of com.enonic.xp.script.runtime.ScriptSettings in project xp by enonic.
the class PortalScriptServiceImpl method initialize.
@Activate
public void initialize() {
final ScriptSettings settings = ScriptSettings.create().binding(Context.class, ContextAccessor::current).binding(PortalRequest.class, PortalRequestAccessor::get).build();
this.scriptRuntime = this.scriptRuntimeFactory.create(settings);
}
Aggregations