Often times, we have a need to persist some specifics related to our custom plugin in addition to the ones from INTViewer. For example, if you have your own top component class, you might need to save and restore the content of that top component.
INTViewer accomplishes this with the help of ISession interface. The custom plugin has to do the following to save plugin related session.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
<folder name="Services">
<file name="windowcounter.CounterSession.instance" />
</folder>
</filesystem>
Key Notes:
Example:
import com.interactive.intviewerapi.IMemento;
import com.interactive.intviewerapi.ISession;
import com.interactive.intviewerapi.PersistentException;
/**
* This will allow INTViewer to save the "MyPlugin" module
*/
public class MyPluginSession implements ISession {
/**
* Returns "MyPlugin" module as the unique id for "MyPlugin" Sessions
* @return
*/
public String getSessionId() {
return "MyPlugin";
}
/**
* Save MyPluginSession
* @param memento
*/
public void saveState(IMemento memento) {
IMemento m = memento.createChild("MyPlugin");
MyPluginSessionVariablesMgr.getInstance().saveState(m);
}
/**
* Restore MyPluginSession
* @param memento
* @throws com.interactive.intviewerapi.PersistentException
*/
public void restoreState(IMemento memento) throws PersistentException {
IMemento m = memento.getChild("MyPlugin");
if (m != null) {
MyPluginSessionVariablesMgr.getInstance().restoreState(m);
}
}
}