Commit Graph

57 Commits

Author SHA1 Message Date
Florian Hotze
04271c4007 [jsscripting] Implement javax.script.Compilable (#16970)
* [jsscripting] Restructure & Comment POM
* [jsscripting] Use OPENHAB_TRANSFORMATION_SCRIPT constant from core

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
2025-01-02 09:49:01 +02:00
lsiepel
90da4e40cc Apply Spotless after release (#17016)
* Spotless

Signed-off-by: Leo Siepel <leosiepel@gmail.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
2025-01-02 09:49:00 +02:00
openhab-bot
5fa59d316f [unleash-maven-plugin] Preparation for next development cycle.
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
2025-01-02 09:49:00 +02:00
Florian Hotze
a429153b5f [jsscripting] Upgrade to openhab-js 5.3.1 (#16985)
Depends on #16979.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
2025-01-02 09:48:59 +02:00
Florian Hotze
54b32a2236 [jsscripting] Upgrade openhab-js to 5.3.0 (#16951)
This adds the new notification builder.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
2025-01-02 09:48:57 +02:00
Florian Hotze
c81f9635fe [jsscripting] Upgrade openhab-js to 5.2.0 (#16935)
Adds support for https://github.com/openhab/openhab-core/pull/4259.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
2025-01-02 09:48:57 +02:00
Florian Hotze
7940822fa8 [jsscripting] Upgrade openhab-js to 5.1.2 (#16926)
Second attempt to fix a problem, where persisting TimeSeries failed when injection caching was enabled.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
2025-01-02 09:48:56 +02:00
Florian Hotze
62e8289938 [jsscripting] Upgrade openhab-js to 5.1.1 (#16892)
Fixes a problem, where persisting TimeSeries failed when injection caching was enabled.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
2025-01-02 09:48:56 +02:00
Florian Hotze
d8dd139e47 [jsscripting] Upgrade openhab-js to 5.1.0 (#16881)
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
2025-01-02 09:48:55 +02:00
Florian Hotze
b881e06e6b [jsscripting] Upgrade openhab-js to 5.0.0 (#16719)
See https://github.com/openhab/openhab-js/blob/main/CHANGELOG.md#500.

Required to adjust to breaking changes from https://github.com/openhab/openhab-core/pull/3736.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
2025-01-02 09:48:48 +02:00
Holger Friedrich
a8f8ccb24e Update plugins (#16683)
* update multiple dependencies

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
2025-01-02 09:48:47 +02:00
Florian Hotze
a52e5fcf7a [jsscripting] Upgrade to openhab-js 4.9.0 (#16576)
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
2025-01-02 09:48:42 +02:00
Florian Hotze
712edea9fc [jsscripting] Upgrade openhab-js to 4.8.1 (#16353)
* [jsscripting] Upgrade openhab-js to 4.8.0

Changelog: https://github.com/openhab/openhab-js/blob/main/CHANGELOG.md#480

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
2025-01-02 09:48:30 +02:00
Florian Hotze
6540d0dda9
[jsscripting] Upgrade openhab-js to 4.7.3 (#16112)
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-12-25 23:52:59 +01:00
Holger Friedrich
533cc666ab
Apply spotless after release (#16097)
* Apply spotless after release
* itests: resolve bundles

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
2023-12-22 23:30:38 +01:00
openhab-bot
83e0485219 [unleash-maven-plugin] Preparation for next development cycle. 2023-12-22 14:37:48 +00:00
Florian Hotze
7d7acb5dbf
[jsscripting] Upgrade openhab-js to 4.7.2 (#16072)
Fixes a minor issue introduced by openhab-js 4.7.1.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-12-17 12:17:38 +01:00
Florian Hotze
63d71f4865
[jsscripting] Upgrade openhab-js to 4.7.1 (#16069)
You'll find the changelog at the openhab-js repo: https://github.com/openhab/openhab-js/blob/main/CHANGELOG.md#471.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-12-16 13:50:41 +01:00
Florian Hotze
7b16ef1de8
[jsscripting] Upgrade openhab-js to 4.7.0 (#16062)
You'll find the changelog at the openhab-js repo: https://github.com/openhab/openhab-js/blob/main/CHANGELOG.md#470.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-12-14 20:23:37 +01:00
Florian Hotze
bf7f24c099
[jsscripting] Upgrade openhab-js to 4.5.1 to fix cached injection (#15336)
It was found out that a recent change to the webpack config for the library injection bundle heavily affected performance of the evaluation of the cached injection.

openhab-js 4.5.1 fixes that regression and one minor bug, see https://github.com/openhab/openhab-js/blob/main/CHANGELOG.md#451.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-07-30 14:47:03 +02:00
Kai Kreuzer
72607d3bee Apply spotless
Signed-off-by: Kai Kreuzer <kai@openhab.org>
2023-07-24 01:20:31 +02:00
openhab-bot
809fceaff3 [unleash-maven-plugin] Preparation for next development cycle. 2023-07-23 19:19:01 +00:00
Florian Hotze
72c0e1f29f
[jsscripting] Upgrade openhab-js to 4.5.0 (#15219)
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-07-10 23:15:04 +02:00
Florian Hotze
828c895b54
[jsscripting] Bump openhab-js version to 4.4.0 (#15128)
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-06-20 15:40:11 +02:00
Florian Hotze
aa3d6b0dc9
[jsscripting] Add type translation for Instant & Minor improvements (#14984)
* [jsscripting] Minor code improvements
* [jsscripting] Add type mapping for `Instant`
* [jsscripting] Upgrade openhab-js to 4.3.0

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-05-13 12:25:06 +02:00
Florian Hotze
03b305bde2
[jsscripting] Bump openhab-js to 4.2.1 (#14749)
* [jsscripting] Upgrade openhab-js to 4.2.1
* [jsscripting] Note that it is based on GraalJS

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-04-06 15:50:09 +02:00
Florian Hotze
726858b4f1
[jsscripting] Upgrade openhab-js to 4.1.0 (#14495)
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-02-25 10:18:49 +01:00
Florian Hotze
ce2e76d6ee
[jsscripting] Bump openhab-js to 4.0.0 & Clean-Ups (#14375)
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-02-14 21:19:59 +01:00
Florian Hotze
f082df923f
[jsscripting] Fix regressions from #14135 & Log stack on IllegalArgumentException (#14142)
* [jsscripting] Fix bundling of global script & regression from #14135

Fixes the regression from https://github.com/openhab/openhab-addons/pull/14135#issuecomment-1369231126.

While working on this, I also noticed that the cache openhab-js does not work because of wrong webpack commandline args in the pom (wrong entrypoint).

* [jsscripting] Enable stack logging for IllegalArgumentExceptions
* [jsscripting] Upgrade openhab-js to 3.2.4
* [jsscripting] Update README for recent PR

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-01-03 20:45:23 +01:00
Florian Hotze
3c669ad77a
[jsscripting] Cache openhab-js injection to improve performance (#14135)
* [jsscripting] Extend comments for wraprequire
* [jsscripting] Enable openhab-js caching to improve performance

On my dev system (which I guess is much more powerful than most openHAB servers), cached openhab-js injection takes 100-200 ms.
openhab-js injection from file system takes about 1000 ms.

* [jsscripting] Update configuration language
* [jsscripting] Upgrade openhab-js version to 3.2.1 for required webpack changes

Documentation updates will follow in another PR to keep this one clean.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2023-01-02 20:41:35 +01:00
Florian Hotze
931f004ab8
[jsscripting] Upgrade to ECMAScript 2022 & Dependency improvements (#14093)
* [jsscripting] Remove asm from dependencies in pom

GraalJS >= 20.3.0 doesn't require org.ow2.asm as compile dependency anymore, see https://mvnrepository.com/artifact/org.graalvm.js/js/20.3.0.

* [jsscripting] Remove dependency org.graalvm.js/js-launcher as it is not required

js-launcher is GraalVM's JavaScript command line interpreter and not required in the addon.
See https://www.graalvm.org/22.1/reference-manual/js/RunOnJDK/.

* [jsscripting] Add missing com.ibm.icu dependency

GraalJS changelog says that it is not required for GraalJS >= 22.0.0 (see 685e5873af/CHANGELOG.md (version-2200)).
But GraalJS 22.3.0 attempts to load classes from it during runtime.

* [jsscripting] Update GraalJS engine options

Compat, as its additional functionality is not used by openhab-js and user code is not expected to use it.

* [jsscripting] Remove com.ibm.icu/icu4j dependency
* [jsscripting] Don't disable Nashorn compat mode as openhab-js requires it for accessors

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-12-30 23:04:43 +01:00
J-N-K
4d6d6443ef
fix spotless after release (#14014)
Signed-off-by: Jan N. Klug <github@klug.nrw>
2022-12-19 15:22:17 +01:00
openhab-bot
7993786dc9 [unleash-maven-plugin] Preparation for next development cycle. 2022-12-19 00:55:11 +00:00
Florian Hotze
d4ec220925
[jsscripting] Extend synchronization to common ScriptEngine methods (#13924)
* [jsscripting] Extend synchronization to common ScriptEngine methods

This extends the multi-thread synchronization to "eval" and "invokeMethod" and moves synchronization for "invokeFunction" to the DelegatingScriptEngineWithInvocableAndAutocloseableAndSynchronization class. Fixes the multi-thread access requested warnings described in the community (https://community.openhab.org/t/openhab-3-4-milestone-discussion/138093/130) and related to https://github.com/openhab/openhab-core/pull/3180.

* Revert "[jsscripting] Extend synchronization to common ScriptEngine methods"

This reverts commit aadd21e45879c10aad29bf279ddbb0afd789b0aa.

* [jsscripting] Extend synchronization to common ScriptEngine methods & Switch to ReentrantLock

This extends the multi-thread synchronization to "eval" and "invokeMethod" and moves synchronization for "invokeFunction" to the InvocationInterceptingScriptEngineWithInvocableAndAutoCloseable class.
The synchronization mechanism changed from using synchronized to using a ReentrantLock together with catch_finally to avoid having deadlocks when an exception is thrown.
Fixes the multi-thread access requested warnings described in the community (https://community.openhab.org/t/openhab-3-4-milestone-discussion/138093/130) and related to https://github.com/openhab/openhab-core/pull/3180.

* [jsscripting] Reduce compiler warnings
* [jsscripting] Replace finally blocks & Wrap returns in afterInvocation
* [jsscripting] Fix deadlock caused by NoSuchMethodException in Invocable interface methods

During testing my latest changes, I noticed that there is a deadlock when invokeFunction or invokeMethod are called on a non-existing method.
This happens because the NoSuchMethodException keeps afterInvocation from running and therefore the lock never gets released.

* [jsscripting] Also rethrow NPE & Fix PMD warnings/errors
* [jsscripting] Wrap and rethrow other exceptions instead of returning them
* [jsscripting] Address review comment from @jpg0

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-12-14 20:12:54 +01:00
Florian Hotze
438552d485
[jsscripting] Upgrade openhab-js & Remove SharedCache (#13908)
Upgrades the included openhab-js version to 3.1.0, which uses the new
caches from core (introduced in
https://github.com/openhab/openhab-core/pull/2887) and provides many
doc improvements.

Removes the SharedCache from the addon because this functionality is
now provided by core (see
https://github.com/openhab/openhab-core/pull/2887).

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-12-11 15:25:39 +01:00
Florian Hotze
29d2578981
[jsscripting] Fix add-on name in feature/pom (#13764)
* Update pom.xml
* Update feature.xml
* [jsscripting] Rename from JSScripting to JavaScript Scripting

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-11-24 23:23:19 +01:00
Florian Hotze
bfff07bb01
[jsscripting] Reimplement timer creation method of ScriptExecution (#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 (#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>
2022-11-20 22:08:19 +01:00
Florian Hotze
4dde19203a
[jsscripting] Fix maven build (#13747)
This fixed the maven build, that fails because webpack-cli version 5.0.0 doesn’t properly process the given entrypoint.
Instead, webpack tries to use the entrypoint from openhab-js‘ webpack config file.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-11-20 17:30:23 +01:00
Florian Hotze
11d3c641e5
[jsscripting] Fix failure on some platforms & JDKs (#13714)
* [jsscripting] Downgrade GraalVM to fix issue with armv7l & OpenJDK 11.0.16

The community reported several cases where JS Scripting was not working due to some issue with the injection of the global script.
This issue seems to only occur on armv7l (e.g. Raspberry Pi 32bit) and OpenJDK 11.0.16.
Investigation showed that the occurrence of the problem depends on the GraalJS version.

See https://community.openhab.org/t/js-scripting-all-scripts-stop-working-when-upgrading-to-3-4-0-m4/140837.

* [jsscripting] Add logging for injection of JSRuntimeFeatures
* [jsscripting] Lint `@jsscripting-globals.js` with semistandard
* [jsscripting] Remove ICU4J as it moved to `org.graalvm.truffle`

Reference f5661d4655/CHANGELOG.md (version-2200).

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-11-14 20:30:44 +01:00
Florian Hotze
b0d4f5a5fd
[jsscripting] Update openhab-js version to 2.1.0 (#13664)
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-11-06 20:15:10 +01:00
Florian Hotze
cf47dc0f39
[jsscripting] Fix multi-thread access (#13582)
* [jsscripting] Share the lock mechanism that was used only for rules
This change moves the lock object that was originally created for ThreadsafeSimpleRuleDelegate to OpenhabGraalJSScriptEngine to make share it across the whole engine.

* [jsscripting] Inject the lock object into the JS runtime
* [jsscripting] Update `setTimeout` & `setInterval` polyfills to enable threadsafety
* [jsscripting] Upgrade GraalJS from 21.3.0 to 22.3.0
* [jsscripting] Reduce compiler warnings
* [jsscripting] Update node version of frontend-maven-plugin

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-10-24 13:35:33 +02:00
Florian Hotze
bdefe17f08
[jsscripting] Upgrade openhab-js to 2.0.4 (#13565)
Fixes #13563.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-10-18 22:34:33 +02:00
Florian Hotze
39d221d3a8
[jsscripting] Update openhab-js to 2.0.3 (#13385)
* [jsscripting] Update openhab-js to 2.0.3
* [jsscripting] Update README

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-09-13 21:57:09 +02:00
Kai Kreuzer
440f603e88
Apply spotless and resolver (#13027)
Signed-off-by: Kai Kreuzer <kai@openhab.org>
2022-06-27 16:00:37 +02:00
openhab-bot
ed4858ebbb [unleash-maven-plugin] Preparation for next development cycle. 2022-06-26 18:18:40 +00:00
Florian Hotze
b2087e3807
[jsscripting] Upgrade openhab-js to version 2.0.0 (#12945)
* Bump openhab-js version to 2.0.0
* Update README for current openhab-js version
* README: Fix paths to images

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
2022-06-18 13:24:05 +02:00
Dan Cunningham
00da156b1b
[jsscripting] Updates to latest openhab-js library (#12171)
* Updates to latest openhab-js library
* Update for new default log level in 3.3

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
2022-01-30 18:28:58 +01:00
Marcel
cc47ef7f3e
pom update from http to https reference (#11833)
Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
2021-12-23 19:40:44 +01:00
Kai Kreuzer
48746f5e3f Apply spotless
Signed-off-by: Kai Kreuzer <kai@openhab.org>
2021-12-20 09:07:55 +01:00
openhab-bot
6dc031e6cf [unleash-maven-plugin] Preparation for next development cycle. 2021-12-20 00:30:46 +00:00