]> git.basschouten.com Git - openhab-addons.git/blob
8531cacfd80e841e33987e36193f8be45fd35e9a
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.automation.jsscripting.internal;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.core.automation.module.script.action.ScriptExecution;
17 import org.openhab.core.scheduler.Scheduler;
18 import org.osgi.service.component.annotations.Activate;
19 import org.osgi.service.component.annotations.Component;
20 import org.osgi.service.component.annotations.Reference;
21
22 /**
23  * OSGi utility service for providing easy access to script services.
24  *
25  * @author Florian Hotze - Initial contribution
26  */
27 @Component(immediate = true, service = JSScriptServiceUtil.class)
28 @NonNullByDefault
29 public class JSScriptServiceUtil {
30     private final Scheduler scheduler;
31     private final ScriptExecution scriptExecution;
32
33     @Activate
34     public JSScriptServiceUtil(final @Reference Scheduler scheduler, final @Reference ScriptExecution scriptExecution) {
35         this.scheduler = scheduler;
36         this.scriptExecution = scriptExecution;
37     }
38
39     public Scheduler getScheduler() {
40         return scheduler;
41     }
42
43     public ScriptExecution getScriptExecution() {
44         return scriptExecution;
45     }
46
47     public JSRuntimeFeatures getJSRuntimeFeatures(Object lock) {
48         return new JSRuntimeFeatures(lock, this);
49     }
50 }