public class FSBuddyStorage extends java.lang.Object implements BuddyStorage
Stores each buddy list under the {SFS2X-folder}/data/buddylists/{Zonename}/{Username} folder
Where {Username} is the "encoded" version of the User name. The encoded name consist simply of the hexadecimal version
of the name. This allows to store any user name in the file system including those containing avoid characters (such as *, :, ? etc...)
Constructor and Description |
---|
FSBuddyStorage() |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Destroy the Storage class.
|
BuddyListManager |
getBuddyListManager()
Get a reference to the BuddyManager managing this BuddyStorage class
|
java.util.List<BuddyVariable> |
getOfflineVariables(java.lang.String buddyName)
Load the off-line persistent variables for a specific User.
|
void |
init()
Initialize the Storage class
Add here all the necessary code to startup your BuddyStorage class.
|
BuddyList |
loadList(java.lang.String ownerName)
Load a Buddy List from your data source.
|
void |
saveList(BuddyList buddyList)
This method is invoked by the Buddy System when a BuddyList needs to be saved.
|
void |
setBuddyListManager(BuddyListManager buddyListManager) |
public void init()
BuddyStorage
Add here all the necessary code to startup your BuddyStorage class. If you are using a database, this is the right place to start up your connection etc...
init
in interface BuddyStorage
public void destroy()
BuddyStorage
This method is invoked by the server when shutting down the Zones. Here you should make sure to release any resources you might have acquired in the init() phase.
destroy
in interface BuddyStorage
public BuddyList loadList(java.lang.String ownerName) throws SFSBuddyListNotFoundException, java.io.IOException
BuddyStorage
loadList
in interface BuddyStorage
ownerName
- name of the BuddyList ownerSFSBuddyListNotFoundException
- thrown if no BuddyList is found for the required Userjava.io.IOException
- thrown if any problem arises during the loading processpublic void saveList(BuddyList buddyList) throws java.io.IOException
BuddyStorage
saveList
in interface BuddyStorage
buddyList
- the BuddyListjava.io.IOException
- thrown if any error arises during the saving processpublic java.util.List<BuddyVariable> getOfflineVariables(java.lang.String buddyName) throws java.io.IOException
BuddyStorage
Since off-line variables are available even when the Buddy is not online this method can be called at any time by the Buddy System. Using a cache to store these variables is usually recommended in order to avoid loading this data multiple timese from a "slow" data sources, such as the Database.
getOfflineVariables
in interface BuddyStorage
buddyName
- the name of the Buddyjava.io.IOException
- thrown if the loading process failspublic BuddyListManager getBuddyListManager()
BuddyStorage
getBuddyListManager
in interface BuddyStorage
public void setBuddyListManager(BuddyListManager buddyListManager)
setBuddyListManager
in interface BuddyStorage