How to replace one class of openHAB binary

Tags: #<Tag:0x00007f616d37e2d8> #<Tag:0x00007f616d37e1e8>
  • Platform information:
    • Hardware: Raspberry Pi 3 (ARM/1GB RAM/16GB storage)
    • OS: Raspbian Stretch
    • Java Runtime Environment: Java™ SE Runtime Environment (build 1.8.0_151-b12)
    • openHAB version: 2.5.8

I try to find source of the excessive rule refreshing (discussed on many topics on forum like my own Rules to reload on thing changes), I modify file ModelRepositoryImpl.java
(https://github.com/openhab/openhab-core/blob/61e17ce39e83daa7f1d8c41512dead8d95d6e5d9/bundles/org.openhab.core.model.core/src/main/java/org/openhab/core/model/core/internal/ModelRepositoryImpl.java)
(add stacktrace log), compile it and replace with original file on my openHab installation. It doesn’t work even if I remove the compiled file (for test) (org.openhab.core.model.core-2.5.0.jar) from the path: /usr/share/openhab2/runtime/system/org/openhab/core/bundles/org.openhab.core.model.core/2.5.0
(I can see log …[DEBUG] [el.core.internal.ModelRepositoryImpl] - Refreshing resource… - it’s only in that one class I mentioned)

Does openHab not read these jar source files? So where are the binaries and how to replace it with debug-test version? Can anyone give me some advice?

You will need to clear the cache for the new jar file to be read.

You could also add the jar to the /addons/ directory and then remove the old one using the bundle:uninstall command in the Karaf console.

Another option is to use the bundle:install command to install the new one and then bundle:uninstall to remove the old one.

There are lots of options!

1 Like

What did you modify? Because the link to the source file is of an openHAB 3.0 version of the file. If you compiled an openHAB 3.0 version it’s not going to work, you need to checkout the 2.5 code. Maybe you did this, but it’s not clear from your post.

1 Like

As I said in the other thread, the focal point of all this appears to be a Thing update.

There’s two threads to pull at from there -

Why does a device message lead to a Thing update? There are valid reasons, like a change in properties.

A Thing change clearly requires some kind of renitializing by the binding. Should linked Items be reinitialized? What, in turn, are the consequences of that? E.g. reinitializing rules that refer to those Items? Can we distinguish which rules those are, or must we do them all?

In short I suspect there is no “bug” but rather a strategy that was not expected.

2 Likes