How to deserialize implementation classes in OSGi

In an application based on eRCP OSGi, the user can press a button and go to the lock screen, similar to the screen of Windows or Mac OS X. When this happens, the current state of the application is serialized to a file and control is transferred to the lock screen. In this mobile application, the memory is very dense, so we need to get rid of the original view / controller when the lock screen opens.

This works fine and we get a binary serialized file. After re-entering the system, the file is read again and the initial state of the application is restored. This works great, unless the controller that was serialized contained a reference to an object that comes from another package. In my particular case, the source controller (from bundle A) can call the web service and return the result. Nothing unusual, just some lines and numbers in a class of simple values. However, the controller sees this only as an interface Result; the actual runtime object ( ResultImpl) is defined and created in another package (package B, client implementation of webservice) and returned through a service call.

When deserialization now tries to thaw the controller from the file, it throws an exception ClassNotFound, complaining that it is impossible to deserialize the result object, since deserialization is called from package A, which the ResultImplclass from bundle B cannot see .

Any ideas on how to get around this? The only thing I could come up with was to clone all the individual values ​​into another object defined with the controller, but that seems pretty complicated.

+3
source share
2 answers

, , . , (, XML, json), . ​​, .

, , , , (de) , (, , ). , () , , .

+4
+1

Source: https://habr.com/ru/post/1737609/


All Articles