net.sourceforge.hiveutils.service.impl
Class PreferencesManagerImpl

java.lang.Object
  extended by net.sourceforge.hiveutils.service.impl.PreferencesManagerImpl
All Implemented Interfaces:
java.util.EventListener, PreferencesManager, org.apache.hivemind.events.RegistryShutdownListener

public class PreferencesManagerImpl
extends java.lang.Object
implements PreferencesManager, org.apache.hivemind.events.RegistryShutdownListener

Author:
Jean-Francois Poilpret

Constructor Summary
PreferencesManagerImpl(org.apache.commons.logging.Log logger, java.util.Map<java.lang.String,PreferenceContribution> prefsDef, java.util.Map<java.lang.Class,PrefsMapper> mappers, boolean autoWrite)
           
 
Method Summary
protected  java.lang.Object load(PreferenceContribution def)
           
 java.lang.Object read(java.lang.String name)
          Read preferences as a bean.
 void registryDidShutdown()
           
protected  void store(PreferenceContribution def, java.lang.Object pref)
           
 void write(java.lang.String name)
          Require to write a bean to preferences store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PreferencesManagerImpl

public PreferencesManagerImpl(org.apache.commons.logging.Log logger,
                              java.util.Map<java.lang.String,PreferenceContribution> prefsDef,
                              java.util.Map<java.lang.Class,PrefsMapper> mappers,
                              boolean autoWrite)
Method Detail

registryDidShutdown

public void registryDidShutdown()
Specified by:
registryDidShutdown in interface org.apache.hivemind.events.RegistryShutdownListener

read

public java.lang.Object read(java.lang.String name)
Description copied from interface: PreferencesManager
Read preferences as a bean. Any modification to the returned bean will be saved back to the preference store at shutdown time.

Specified by:
read in interface PreferencesManager
Parameters:
name - unique name of the preferences bean to read
Returns:
the bean retrieved from preferences, or a default instance if it does not exists in the preferences store yet; null if name is not configured in hiveutils.Preferences.

load

protected java.lang.Object load(PreferenceContribution def)

write

public void write(java.lang.String name)
Description copied from interface: PreferencesManager
Require to write a bean to preferences store. If an event Channel has been registered for that bean, then an event will be sent to that Channel.

Specified by:
write in interface PreferencesManager
Parameters:
name - unique name of the preferences bean to write

store

protected void store(PreferenceContribution def,
                     java.lang.Object pref)