Somebody correct me if I'm wrong but may be it'll be good to add here information about necessity to add implementation of PersistentStateComponent to plugin.xml in <extensions> like this:
And the way you can call it:
Another issue I found is that loadState(MyService state) won't be called if you doesn't have getter and setter for stateValue if we talk about second example from section: "Implementing the PersistentStateComponent Interface".
Note, that (if I understand correctly), each field of state class, that should be stored, should be public or have both public getter and setter
UPD: Yeah, I'm not very careful reader:\
Indeed, this is already noted above:
The implementation of PersistentStateComponent works by serializing public fields and bean properties into an XML format