javaswingsaf

Swing Application Framework session store


I have been using the Swing Application Framework, and very pleased with its sessions state storage. I was wondering if it's possible to delete (clean up) the persisted states.

If not, has anyone found a clean way to achieve this (stored files aren't saved in the same location depending on the OS etc..).

Thanks


Solution

  • you can delete the corresponding file/s (forgot the exact details about the naming) via the LocalStorage, here's a code snippet I use (with bsaf, but didn't change much, afair)

    /**
     * Deletes the session state by deleting the file. Useful during development
     * when restoring to old state is not always the desired behaviour.
     * Pending: this is incomplete, deletes the mainframe state only.
     */
    protected void deleteSessionState() {
        ApplicationContext context = getContext();
        try {
            context.getLocalStorage().deleteFile("mainFrame.session.xml");
        } catch (...) {
        }
    }