Non-persistent data storage

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
vitorhugovm
Posts: 11
Joined: Fri Jan 26, 2024 3:31 pm

Non-persistent data storage

Post by vitorhugovm »

Is there a way to store and retrieve non-persistent data using the Java API?
Thanks!
Vitor
Radu
Posts: 9060
Joined: Fri Jul 09, 2004 5:18 pm

Re: Non-persistent data storage

Post by Radu »

Hi Vitor,
Our Java OptionsStorage API also persists the data when Oxygen is closed. Maybe you can create your own HashMap-like structure if you want to cache anything in a non persistent way.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
vitorhugovm
Posts: 11
Joined: Fri Jan 26, 2024 3:31 pm

Re: Non-persistent data storage

Post by vitorhugovm »

Hi Radu!

I found the class EditingSessionContext, which apparently solves the issue by setting and getting attributes with keys and values. Should I have any concern about the use of this class?

Thanks!
Vitor
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: Non-persistent data storage

Post by cristi_talau »

Hello,
EditingSessionContext lifetime is linked to a document that is opened in a browser tab. If you want to store data that is accessible for multiple documents, you may need another storage mechanism, for example a singleton class that holds key-value properties.
Best,
Cristian
vitorhugovm
Posts: 11
Joined: Fri Jan 26, 2024 3:31 pm

Re: Non-persistent data storage

Post by vitorhugovm »

Hello Cristian!

I'm currently using EditingSessionContext and it's doing exactly what I needed. The objective was to store and retrieve data only for the current document, this data must be erased if the document is reloaded or closed.
I'm using it to store external retrieved data that must not be inserted or contained in the XML, but needs to be used more than once for some purposes.

Thanks for the attention!
Vitor
Post Reply