Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## it.gotoandplay.smartfoxserver.extensions.examples
Class BuddyListDatabasePersister

    java.lang.Object
      it.gotoandplay.smartfoxserver.data.buddylist.persistence.AbstractBuddyPersister
          it.gotoandplay.smartfoxserver.extensions.examples.BuddyListDatabasePersister

All Implemented Interfaces:
  IBuddyListPersister, it.gotoandplay.smartfoxserver.lib.IService

    public class BuddyListDatabasePersister

extends AbstractBuddyPersister

This class shows how you can implement your own custom persistency system for the SmartFoxServer buddy lists.

You start by extending the AbstractBuddyPersister class and overriding the loadBuddyList() and saveBuddyList() methods. These methods take care of loading and saving the buddy list for the specified user.

There is an additional method that can be overridden called saveAllBuddyLists(). Its default implementation just cycles through all users in the Zone whose buddylist was modified, and passes them to the saveBuddyList method.
If you need a more advanced implementation you can override it.
This method is usually invoked by the server when restarting or shutting down.

Finally there's two usefull methods called init() and destroy() that can be used to start up and shut down the persister object.

Author:
  Lapo

Constructor Summary
`BuddyListDatabasePersister()`

Method Summary
`void` | `init(java.lang.Object param)` Here we initialize the persister class
`StorableBuddyList` | `loadList(java.lang.String userName)` Load the buddy list for the specified user
`boolean` | `saveList(java.lang.String userName, StorableBuddyList buddyList)` Save the buddy list of for the specified user

Methods inherited from class it.gotoandplay.smartfoxserver.data.buddylist.persistence.AbstractBuddyPersister
`destroy, getOfflineVariables, removeOfflineBuddy, saveAll, setZoneName`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### BuddyListDatabasePersister

    public BuddyListDatabasePersister()

Method Detail

### init

    public void init(java.lang.Object param)

  Here we initialize the persister class

  Specified by:
    `init` in interface `it.gotoandplay.smartfoxserver.lib.IService`
  Overrides:
    `init` in class `AbstractBuddyPersister`

### 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`
  Overrides:
    `loadList` in class `AbstractBuddyPersister`
  Parameters:
    `userName` - the user name
  Returns:
    a list of buddies or null if buddy list does not exist

### 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`
  Overrides:
    `saveList` in class `AbstractBuddyPersister`
  Parameters:
    `userName` - the user name
    `buddyList` - the list of buddies

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD