use of com.enonic.xp.context.ContextAccessor in project xp by enonic.
the class ScriptTestSupport method initialize.
protected void initialize() throws Exception {
this.serviceRegistry = new MockServiceRegistry();
this.portalRequest = createPortalRequest();
PortalRequestAccessor.set(this.portalRequest);
this.bundleContext = createBundleContext();
this.contentService = Mockito.mock(ContentService.class);
this.resourceService = createResourceService();
addService(ContentService.class, this.contentService);
addService(ResourceService.class, this.resourceService);
addService(ViewFunctionService.class, new MockViewFunctionService());
this.scriptSettings = ScriptSettings.create();
this.scriptSettings.binding(Context.class, ContextAccessor::current);
this.scriptSettings.binding(PortalRequest.class, () -> this.portalRequest);
this.scriptSettings.debug(new ScriptDebugSettings());
this.scriptSettings.globalVariable("testInstance", this);
this.executor = createExecutor();
}
use of com.enonic.xp.context.ContextAccessor 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