Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse SmartHome » Serialize ThingType
Serialize ThingType [message #1793040] Sun, 29 July 2018 12:56 Go to next message
Tim Roberts is currently offline Tim RobertsFriend
Messages: 29
Registered: September 2016
Junior Member
I have a custom ThingTypeProvider that I use to dynamically create ThingTypes. However, dynamically creating the ThingType is a fairly heavy process (involving network connections) and instead of recreating the ThingTypes on restarts (or activations) - I'd like to serialize the previously created ThingType(s), store them in a file and then deserialize it on activation to avoid the heavy process.

Question:
1. Is this the right approach or is there a better approach that I'm unaware of?
2. If it is the right approach - is there an 'official' way to serialize/deserialize a ThingType?

I've looked at the Xml thing type provider - but that deserializes from the thing-types.xml and doesn't seem to provide serialization. I have tried a simple GSON (json) approach - serialization seems to work but deserialization fails with some error about UID constructor (haven't looked into it in detail because I'm not sure if that's a good approach either).

Thanks,
Tim
Re: Serialize ThingType [message #1793045 is a reply to message #1793040] Mon, 30 July 2018 01:36 Go to previous messageGo to next message
Tim Roberts is currently offline Tim RobertsFriend
Messages: 29
Registered: September 2016
Junior Member
Note that after thinking about this for awhile - I think I came up with a decent approach. I'm going to serialize/deserialize the information that I use to generate the thing type (after I've fetched and translated it).

That way I it's cache'd in a form that is quick that I control and I can generate a thing type from it (and I'm not dependent on doing something weird like serializing/deserializing the thing type to/from json).

Note: however, I'd like to hear if there was an approach that I'm unaware of...
Re: Serialize ThingType [message #1793274 is a reply to message #1793045] Thu, 02 August 2018 14:47 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Imho there should be hardly any cases where you actually need to dynamically create thing types; you could very often rather define a rather generic thing type statically and then dynamically construct the things.
But to answer your question: No, there isn't any mechanism available for easily de/serialising thing types.
Re: Serialize ThingType [message #1793279 is a reply to message #1793274] Thu, 02 August 2018 17:25 Go to previous messageGo to next message
Tim Roberts is currently offline Tim RobertsFriend
Messages: 29
Registered: September 2016
Junior Member
I agree - the issue is that a thing can't dynamically create a group (you have an issue about this somewhere) and the only way to do that is by dynamically creating thing types. This is a moot point for me right now but something to note..
Re: Serialize ThingType [message #1793292 is a reply to message #1793279] Fri, 03 August 2018 08:19 Go to previous message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Right, ftr, the issue is https://github.com/eclipse/smarthome/issues/1118.
Previous Topic:Auto created Items are not editable
Next Topic:New Prometheus Metrics bundle - Need help attaching to Pax logging
Goto Forum:
  


Current Time: Fri Mar 29 05:09:14 GMT 2024

Powered by FUDForum. Page generated in 0.04243 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top