it.gotoandplay.smartfoxserver.data.buddylist.persistence
Class AbstractBuddyPersister

java.lang.Object
  extended by it.gotoandplay.smartfoxserver.data.buddylist.persistence.AbstractBuddyPersister
All Implemented Interfaces:
IBuddyListPersister, it.gotoandplay.smartfoxserver.lib.IService
Direct Known Subclasses:
BasicBuddyPersister, BuddyListDatabasePersister

public class AbstractBuddyPersister
extends java.lang.Object
implements IBuddyListPersister

This is the base class of a Buddy List persister. It provides concrete implementation of a few interface methods, leaving the remaining implementation to the child class.

The following methods should be overridden:


Constructor Summary
AbstractBuddyPersister()
           
 
Method Summary
 void destroy(java.lang.Object param)
           
 java.util.Map<java.lang.String,java.lang.String> getOfflineVariables(java.lang.String userName)
          Return a map of off-line variables.
 void init(java.lang.Object param)
           
 StorableBuddyList loadList(java.lang.String userName)
          Load the buddy list for the specified user
 boolean removeOfflineBuddy(java.lang.String owner, java.lang.String buddyName)
          Removes a buddy from a user list when the user is off-line
 void saveAll(java.util.Map<java.lang.String,StorableBuddyList> buddyLists)
          This method is invoked when shutting down the Buddy List Manager, it saves all the buddy lists.
 boolean saveList(java.lang.String userName, StorableBuddyList buddyList)
          Save the buddy list of for the specified user
 void setZoneName(java.lang.String zoneName)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBuddyPersister

public AbstractBuddyPersister()
Method Detail

setZoneName

public void setZoneName(java.lang.String zoneName)

init

public void init(java.lang.Object param)
Specified by:
init in interface it.gotoandplay.smartfoxserver.lib.IService

destroy

public void destroy(java.lang.Object param)
Specified by:
destroy in interface it.gotoandplay.smartfoxserver.lib.IService

loadList

public StorableBuddyList loadList(java.lang.String userName)
Description copied from interface: IBuddyListPersister
Load the buddy list for the specified user

Specified by:
loadList in interface IBuddyListPersister
Parameters:
userName - the user name
Returns:
a list of buddies or null if buddy list does not exist

getOfflineVariables

public java.util.Map<java.lang.String,java.lang.String> getOfflineVariables(java.lang.String userName)
Description copied from interface: IBuddyListPersister
Return a map of off-line variables. Off-line variables always start with a "$" symbol. Valid off-line buddy variables name are: $test, $_name, $3items ...

Specified by:
getOfflineVariables in interface IBuddyListPersister
Parameters:
userName - owner of the variables
Returns:
the map of variables

removeOfflineBuddy

public boolean removeOfflineBuddy(java.lang.String owner,
                                  java.lang.String buddyName)
Description copied from interface: IBuddyListPersister
Removes a buddy from a user list when the user is off-line

Specified by:
removeOfflineBuddy in interface IBuddyListPersister
Parameters:
owner - the buddy list owner
buddyName - the buddy name
Returns:
true, if the operation was successful

saveAll

public void saveAll(java.util.Map<java.lang.String,StorableBuddyList> buddyLists)
This method is invoked when shutting down the Buddy List Manager, it saves all the buddy lists. NOTE: This method should not be overridden.

Specified by:
saveAll in interface IBuddyListPersister
Parameters:
buddyLists - a map of buddy lists where the key is the user name and the value is the buddy list.

saveList

public boolean saveList(java.lang.String userName,
                        StorableBuddyList buddyList)
Description copied from interface: IBuddyListPersister
Save the buddy list of for the specified user

Specified by:
saveList in interface IBuddyListPersister
Parameters:
userName - the user name
buddyList - the list of buddies