Pluggable Persistence Module
From ZKDesktop
The ZK Desktop (ZKD) provides a data persistence feature for use by all applications through a pluggable persistence module known (simply) as persistence. The persistence feature is implemented as a Java class and dynamically loaded into the ZKD based on the persistence configuration value stored in the zkdesktop.xml file. Using a pluggable persistence system allows the ZKD to be blissfully unaware of what type of database or other storage system is used with it.
To implement the persistence system, you must provide a class that implements the zkdesktop.PersistenceInterface. This interface consists of the following methods:
-
public boolean startup(String webRoot)
Initializes the persistence class and prepares it for use. Use this routine to do any startup actions your class may need (connect to web services, databases, etc.) instead of using the class constructor. webRoot is the path to the root folder of the web application, should you need it. Return true if startup is successful, false if it fails.
-
public boolean clearUserData(String application, String username, String item)
Called when the ZKD wishes to remove a stored piece of data. application is the title of the application making the request (or "ZKD" for the ZK Desktop itself). username is the user name of the currently authenticated user. item is the name of the item to remove. Return true if the item was successfully removed, return false if there was an error or the item didn't exist.
-
public String getUserData(String application, String username, String item)
Called when the ZKD wishes to fetch a stored piece of data. application is the title of the application making the request (or "ZKD" for the ZK Desktop itself). username is the user name of the currently authenticated user. item is the name of the item to retrieve. Return the value of the item on success, or an empty string ("") if there's an error or the item didn't exist.
-
public boolean setUserData(String application, String username, String item, String data)
Called when the ZKD wishes to store piece of data. application is the title of the application making the request (or "ZKD" for the ZK Desktop itself). username is the user name of the currently authenticated user. item is the name of the item to store. data is the actual data to store. Return true if the item was successfully stored, return false if there was an error.
NOTES:
- Although not strictly required, the recommended data sizes for each of the fields you will need to store are:
- APPLICATION_NAME - 255 Characters
- USERNAME - 255 Characters
- ITEM_NAME - 8000 Characters
- DATA - 8000 Characters
These sizes are generous, not insanely large, and fit easily within the varchar data type of most SQL servers.

