-
-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[automation] Some classes are internal but exposed "accidentally" #2438
Comments
Objects of those classes are put into the script engine scope and are then normally accessible (and resolvable) - this works for all the existing scripting languages afaik. |
Sure. The issue is that the used implementation of Java scripting (https://github.com/eobermuhlner/java-scriptengine) relies on the compilation of the script. This is done via the compiler obtained with Scripts are classes implementing When compiling the script, all classes used have to be present on the classpath and during instantiation of the class object, the classloader has to be able to resolve the classes, otherwise a CNFE is thrown. |
Ok, thanks for the infos - looks like an interesting script engine. I guess it should be ok to move the affected classes to an exported package. Would you like to create a PR for it? |
I wonder if we should really expose the classes themselves or if we should add an interface. The reason is that some of the methods (e.g. the constructor of |
Is it a concurrent approach to https://github.com/seaside1/jrule ? |
Originally I started with the code presented there. But unfortunately it has some limitations:
Therefore I decided to retry my approach from a year ago or so with the library mentioned above and finally succeeded. Biggest issue was that I missed the "Dynamic-Import: *" instruction, which I found in the groovy JSR 223 addon. So: it's a different approach. |
Ok, thank you for the explanation. I am interested to test such rule engine. |
I'd agree that this would be the cleaner approach as it decouples the implementation. So we could rename the existing classes to *Impl and keep them in the internal package and introduce according interfaces for them in a public package. |
I'll check how that works and provide a PR. |
I'm currently working on a JSR223 compatible Java scripting addon.
The core exposes adds a binding
scriptExtension
orevents
(and probably more that I didn't encounter yet) to the ScriptEngine. Unfortunately the classes for these bindings (ScriptExtensionManagerWrapper
andScriptBusEvent
) are in internal bundles:org.openhab.core.automation.module.script.internal
andorg.openhab.core.automation.module.script.internal.defaultscope
and are therefore not available in the classloader and the script loading fails (internal bundles are not exported).Would it make sense to move these to public packages? My guess would be that this is not a breaking change since they can't be accessed at the moment anyway.
The text was updated successfully, but these errors were encountered: