org.apache.felix.prefs.impl
Class PreferencesManager

java.lang.Object
  extended by org.apache.felix.prefs.impl.PreferencesManager
All Implemented Interfaces:
EventListener, BackingStoreManager, BundleActivator, BundleListener, ServiceFactory

public class PreferencesManager
extends Object
implements BundleActivator, BundleListener, ServiceFactory, BackingStoreManager

This activator registers itself as a service factory for the preferences service.


Field Summary
protected  BundleContext context
          The bundle context.
protected  BackingStore defaultStore
          The default store which is used if no service can be found.
protected  ServiceTracker logTracker
          The service tracker for the log service.
protected  Map services
          The map of already created services.
protected  ServiceTracker storeTracker
          The backing store service tracker.
protected  int storeTrackingCount
          Tracking count for the store tracker to detect changes.
 
Constructor Summary
PreferencesManager()
           
 
Method Summary
 void bundleChanged(BundleEvent event)
           
protected  void cleanupStore(BackingStore store)
          Clean up the store and remove preferences for deleted bundles.
 Object getService(Bundle bundle, ServiceRegistration reg)
           
 BackingStore getStore()
          Return the current backing store.
protected  void log(int level, String message, Throwable t)
           
protected  void save(PreferencesServiceImpl service)
          Save all preferences for this service.
 void start(BundleContext context)
           
 void stop(BundleContext context)
           
 void ungetService(Bundle bundle, ServiceRegistration reg, Object s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

services

protected final Map services
The map of already created services. For each client bundle a new service is created.


context

protected BundleContext context
The bundle context.


storeTracker

protected ServiceTracker storeTracker
The backing store service tracker.


logTracker

protected ServiceTracker logTracker
The service tracker for the log service.


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 Detail

PreferencesManager

public PreferencesManager()
Method Detail

bundleChanged

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

start

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

stop

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

getService

public Object getService(Bundle bundle,
                         ServiceRegistration reg)
Specified by:
getService in interface ServiceFactory
See Also:
ServiceFactory.getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration)

ungetService

public void ungetService(Bundle bundle,
                         ServiceRegistration reg,
                         Object s)
Specified by:
ungetService in interface ServiceFactory
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 -

log

protected void log(int level,
                   String message,
                   Throwable t)

getStore

public BackingStore getStore()
Description copied from interface: BackingStoreManager
Return the current backing store.

Specified by:
getStore in interface BackingStoreManager
See Also:
BackingStoreManager.getStore()

cleanupStore

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

Parameters:
store -


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.