forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[jsscripting] Reimplement timer creation method of
ScriptExecution
(o…
…penhab#13695) * [jsscripting] Refactor ThreadsafeTimers to create futures inline instead of in an extra methods * [jsscripting] Introduce utility class for providing easy access to script services * [jsscripting] Reimplement timer creation methods from ScriptExecution for thread-safety * [jsscripting] Add missing JavaDoc for reimplement timer creation methods * [jsscripting] Remove the future from the map when setTimeout expires * [jsscripting] Rename `GraalJSScriptServiceUtil` to `JSScriptServiceUtil` * [jsscripting] Remove the `createTimerWithArgument` method * [jsscripting] Replace the OSGi workaround of `JSScriptServiceUtil` with an injection mechanism * [jsscripting] Use constructor to inject `JSScriptServiceUtil` into `GraalJSScriptEngineFactory` * [jsscripting] Minor improvements by @J-N-K (openhab#1) * [jsscripting] Minor changes related to last commit to keep flexibility of `JSRuntimeFeatures` * [jsscripting] Upgrade openhab-js to v2.1.1 * [jsscripting] Remove unused code Signed-off-by: Florian Hotze <florianh_dev@icloud.com> Co-authored-by: Jan N. Klug <github@klug.nrw>
- Loading branch information
Showing
7 changed files
with
164 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...ipting/src/main/java/org/openhab/automation/jsscripting/internal/JSScriptServiceUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Copyright (c) 2010-2022 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.automation.jsscripting.internal; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.openhab.core.automation.module.script.action.ScriptExecution; | ||
import org.openhab.core.scheduler.Scheduler; | ||
import org.osgi.service.component.annotations.Activate; | ||
import org.osgi.service.component.annotations.Component; | ||
import org.osgi.service.component.annotations.Reference; | ||
|
||
/** | ||
* OSGi utility service for providing easy access to script services. | ||
* | ||
* @author Florian Hotze - Initial contribution | ||
*/ | ||
@Component(immediate = true, service = JSScriptServiceUtil.class) | ||
@NonNullByDefault | ||
public class JSScriptServiceUtil { | ||
private final Scheduler scheduler; | ||
private final ScriptExecution scriptExecution; | ||
|
||
@Activate | ||
public JSScriptServiceUtil(final @Reference Scheduler scheduler, final @Reference ScriptExecution scriptExecution) { | ||
this.scheduler = scheduler; | ||
this.scriptExecution = scriptExecution; | ||
} | ||
|
||
public Scheduler getScheduler() { | ||
return scheduler; | ||
} | ||
|
||
public ScriptExecution getScriptExecution() { | ||
return scriptExecution; | ||
} | ||
|
||
public JSRuntimeFeatures getJSRuntimeFeatures(Object lock) { | ||
return new JSRuntimeFeatures(lock, this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters