]> git.basschouten.com Git - openhab-addons.git/blob
faf326c54f5c98160c6d1e9f9dbc34cdc2ac47d9
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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 java.util.concurrent.locks.Lock;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.core.automation.module.script.action.ScriptExecution;
19 import org.openhab.core.scheduler.Scheduler;
20 import org.osgi.service.component.annotations.Activate;
21 import org.osgi.service.component.annotations.Component;
22 import org.osgi.service.component.annotations.Reference;
23
24 /**
25  * OSGi utility service for providing easy access to script services.
26  *
27  * @author Florian Hotze - Initial contribution
28  */
29 @Component(immediate = true, service = JSScriptServiceUtil.class)
30 @NonNullByDefault
31 public class JSScriptServiceUtil {
32     private final Scheduler scheduler;
33     private final ScriptExecution scriptExecution;
34
35     @Activate
36     public JSScriptServiceUtil(final @Reference Scheduler scheduler, final @Reference ScriptExecution scriptExecution) {
37         this.scheduler = scheduler;
38         this.scriptExecution = scriptExecution;
39     }
40
41     public Scheduler getScheduler() {
42         return scheduler;
43     }
44
45     public ScriptExecution getScriptExecution() {
46         return scriptExecution;
47     }
48
49     public JSRuntimeFeatures getJSRuntimeFeatures(Lock lock) {
50         return new JSRuntimeFeatures(lock, this);
51     }
52 }