Class PreferencesManager

java.lang.Object
org.apache.felix.prefs.impl.PreferencesManager
All Implemented Interfaces:
EventListener, BackingStoreManager, org.osgi.framework.BundleActivator, org.osgi.framework.BundleListener, org.osgi.framework.ServiceFactory<org.osgi.service.prefs.PreferencesService>

public class PreferencesManager extends Object implements org.osgi.framework.BundleActivator, org.osgi.framework.BundleListener, org.osgi.framework.ServiceFactory<org.osgi.service.prefs.PreferencesService>, BackingStoreManager
This activator registers itself as a service factory for the preferences service.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.osgi.framework.BundleContext
    The bundle context.
    protected BackingStore
    The default store which is used if no service can be found.
    The map of already created services.
    protected org.osgi.util.tracker.ServiceTracker<BackingStore,BackingStore>
    The backing store service tracker.
    protected int
    Tracking count for the store tracker to detect changes.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    bundleChanged(org.osgi.framework.BundleEvent event)
     
    protected void
    Clean up the store and remove preferences for deleted bundles.
    org.osgi.service.prefs.PreferencesService
    getService(org.osgi.framework.Bundle bundle, org.osgi.framework.ServiceRegistration<org.osgi.service.prefs.PreferencesService> reg)
     
    Return the current backing store.
    protected void
    Save all preferences for this service.
    void
    start(org.osgi.framework.BundleContext context)
     
    void
    stop(org.osgi.framework.BundleContext context)
     
    void
    ungetService(org.osgi.framework.Bundle bundle, org.osgi.framework.ServiceRegistration<org.osgi.service.prefs.PreferencesService> reg, org.osgi.service.prefs.PreferencesService s)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • services

      protected final Map<Long,PreferencesServiceImpl> services
      The map of already created services. For each client bundle a new service is created.
    • context

      protected org.osgi.framework.BundleContext context
      The bundle context.
    • storeTracker

      protected org.osgi.util.tracker.ServiceTracker<BackingStore,BackingStore> storeTracker
      The backing store service tracker.
    • defaultStore

      protected BackingStore defaultStore
      The default store which is used if no service can be found.
    • storeTrackingCount

      protected int storeTrackingCount
      Tracking count for the store tracker to detect changes.
  • Constructor Details

    • PreferencesManager

      public PreferencesManager()
  • Method Details

    • bundleChanged

      public void bundleChanged(org.osgi.framework.BundleEvent event)
      Specified by:
      bundleChanged in interface org.osgi.framework.BundleListener
      See Also:
      • BundleListener.bundleChanged(org.osgi.framework.BundleEvent)
    • start

      public void start(org.osgi.framework.BundleContext context) throws Exception
      Specified by:
      start in interface org.osgi.framework.BundleActivator
      Throws:
      Exception
      See Also:
      • BundleActivator.start(org.osgi.framework.BundleContext)
    • stop

      public void stop(org.osgi.framework.BundleContext context) throws Exception
      Specified by:
      stop in interface org.osgi.framework.BundleActivator
      Throws:
      Exception
      See Also:
      • BundleActivator.stop(org.osgi.framework.BundleContext)
    • getService

      public org.osgi.service.prefs.PreferencesService getService(org.osgi.framework.Bundle bundle, org.osgi.framework.ServiceRegistration<org.osgi.service.prefs.PreferencesService> reg)
      Specified by:
      getService in interface org.osgi.framework.ServiceFactory<org.osgi.service.prefs.PreferencesService>
      See Also:
      • ServiceFactory.getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration)
    • ungetService

      public void ungetService(org.osgi.framework.Bundle bundle, org.osgi.framework.ServiceRegistration<org.osgi.service.prefs.PreferencesService> reg, org.osgi.service.prefs.PreferencesService s)
      Specified by:
      ungetService in interface org.osgi.framework.ServiceFactory<org.osgi.service.prefs.PreferencesService>
      See Also:
      • ServiceFactory.ungetService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration, java.lang.Object)
    • save

      protected void save(PreferencesServiceImpl service)
      Save all preferences for this service.
      Parameters:
      service -
    • getStore

      public BackingStore getStore() throws org.osgi.service.prefs.BackingStoreException
      Description copied from interface: BackingStoreManager
      Return the current backing store.
      Specified by:
      getStore in interface BackingStoreManager
      Throws:
      org.osgi.service.prefs.BackingStoreException
      See Also:
    • cleanupStore

      protected void cleanupStore(BackingStore store)
      Clean up the store and remove preferences for deleted bundles.
      Parameters:
      store -