Class FSBuddyStorage
- java.lang.Object
-
- com.smartfoxserver.v2.buddylist.storage.FSBuddyStorage
-
- All Implemented Interfaces:
BuddyStorage
public class FSBuddyStorage extends java.lang.Object implements BuddyStorage
Default (file system based) BuddyStorage classStores 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 Summary
Constructors Constructor Description FSBuddyStorage()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
Destroy the Storage class.BuddyListManager
getBuddyListManager()
Get a reference to the BuddyManager managing this BuddyStorage classjava.util.List<BuddyVariable>
getOfflineVariables(java.lang.String buddyName)
Load the off-line persistent variables for a specific User.void
init()
Initialize the Storage classBuddyList
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)
-
-
-
Method Detail
-
init
public void init()
Description copied from interface:BuddyStorage
Initialize the Storage classAdd 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...
- Specified by:
init
in interfaceBuddyStorage
-
destroy
public void destroy()
Description copied from interface:BuddyStorage
Destroy the Storage class.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.
- Specified by:
destroy
in interfaceBuddyStorage
-
loadList
public BuddyList loadList(java.lang.String ownerName) throws SFSBuddyListNotFoundException, java.io.IOException
Description copied from interface:BuddyStorage
Load a Buddy List from your data source. This method is invoked by the Buddy System when Buddy data needs to be loaded.- Specified by:
loadList
in interfaceBuddyStorage
- Parameters:
ownerName
- name of the BuddyList owner- Returns:
- the BuddyList
- Throws:
SFSBuddyListNotFoundException
- thrown if no BuddyList is found for the required Userjava.io.IOException
- thrown if any problem arises during the loading process
-
saveList
public void saveList(BuddyList buddyList) throws java.io.IOException
Description copied from interface:BuddyStorage
This method is invoked by the Buddy System when a BuddyList needs to be saved.- Specified by:
saveList
in interfaceBuddyStorage
- Parameters:
buddyList
- the BuddyList- Throws:
java.io.IOException
- thrown if any error arises during the saving process
-
getOfflineVariables
public java.util.List<BuddyVariable> getOfflineVariables(java.lang.String buddyName) throws java.io.IOException
Description copied from interface:BuddyStorage
Load the off-line persistent variables for a specific User.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.
- Specified by:
getOfflineVariables
in interfaceBuddyStorage
- Parameters:
buddyName
- the name of the Buddy- Returns:
- the List of off-line BuddyVariables
- Throws:
java.io.IOException
- thrown if the loading process fails
-
getBuddyListManager
public BuddyListManager getBuddyListManager()
Description copied from interface:BuddyStorage
Get a reference to the BuddyManager managing this BuddyStorage class- Specified by:
getBuddyListManager
in interfaceBuddyStorage
- Returns:
- the BuddyManager
-
setBuddyListManager
public void setBuddyListManager(BuddyListManager buddyListManager)
- Specified by:
setBuddyListManager
in interfaceBuddyStorage
-
-