use of org.apache.felix.cm.file.FilePersistenceManager in project felix by apache.
the class DynamicBindingsTest method setUp.
protected void setUp() throws Exception {
super.setUp();
configLocation = new File("target/config." + System.currentTimeMillis());
persistenceManager = new FilePersistenceManager(configLocation.getAbsolutePath());
bindingsFile = new File(configLocation, DynamicBindings.BINDINGS_FILE_NAME + ".config");
}
use of org.apache.felix.cm.file.FilePersistenceManager in project felix by apache.
the class ConfigurationManager method start.
@Override
public void start(BundleContext bundleContext) {
// track the log service using a ServiceTracker
logTracker = new ServiceTracker(bundleContext, LOG_SERVICE_NAME, null);
logTracker.open();
// assign the log level
String logLevelProp = bundleContext.getProperty(CM_LOG_LEVEL);
if (logLevelProp == null) {
logLevel = CM_LOG_LEVEL_DEFAULT;
} else {
try {
logLevel = Integer.parseInt(logLevelProp);
} catch (NumberFormatException nfe) {
logLevel = CM_LOG_LEVEL_DEFAULT;
}
}
// set up some fields
this.bundleContext = bundleContext;
// configurationlistener support
configurationListenerTracker = new ServiceTracker(bundleContext, ConfigurationListener.class.getName(), null);
configurationListenerTracker.open();
syncConfigurationListenerTracker = new ServiceTracker(bundleContext, SynchronousConfigurationListener.class.getName(), null);
syncConfigurationListenerTracker.open();
// initialize the asynchonous updater thread
ThreadGroup tg = new ThreadGroup("Configuration Admin Service");
tg.setDaemon(true);
this.updateThread = new UpdateThread(this, tg, "CM Configuration Updater");
this.eventThread = new UpdateThread(this, tg, "CM Event Dispatcher");
// set up the location (might throw IllegalArgumentException)
try {
FilePersistenceManager fpm = new FilePersistenceManager(bundleContext, bundleContext.getProperty(CM_CONFIG_DIR));
Hashtable props = new Hashtable();
props.put(Constants.SERVICE_PID, fpm.getClass().getName());
props.put(Constants.SERVICE_DESCRIPTION, "Platform Filesystem Persistence Manager");
props.put(Constants.SERVICE_VENDOR, "Apache Software Foundation");
props.put(Constants.SERVICE_RANKING, new Integer(Integer.MIN_VALUE));
filepmRegistration = bundleContext.registerService(PersistenceManager.class.getName(), fpm, props);
// setup dynamic configuration bindings
dynamicBindings = new DynamicBindings(bundleContext, fpm);
} catch (IOException ioe) {
log(LogService.LOG_ERROR, "Failure setting up dynamic configuration bindings", ioe);
} catch (IllegalArgumentException iae) {
log(LogService.LOG_ERROR, "Cannot create the FilePersistenceManager", iae);
}
// register as bundle and service listener
handleBundleEvents = true;
bundleContext.addBundleListener(this);
// get all persistence managers to begin with
// make sure to get the persistence managers at least once
pmtCount = 1;
persistenceManagerTracker = new ServiceTracker(bundleContext, PersistenceManager.class.getName(), null);
persistenceManagerTracker.open();
// consider alive now (before clients use Configuration Admin
// service registered in the next step)
isActive = true;
// create and register configuration admin - start after PM tracker ...
ConfigurationAdminFactory caf = new ConfigurationAdminFactory(this);
Hashtable<String, Object> props = new Hashtable<String, Object>();
props.put(Constants.SERVICE_PID, "org.apache.felix.cm.ConfigurationAdmin");
props.put(Constants.SERVICE_DESCRIPTION, "Configuration Admin Service Specification 1.5 Implementation");
props.put(Constants.SERVICE_VENDOR, "Apache Software Foundation");
configurationAdminRegistration = bundleContext.registerService(ConfigurationAdmin.class.getName(), caf, props);
// start handling ManagedService[Factory] services
managedServiceTracker = new ManagedServiceTracker(this);
managedServiceFactoryTracker = new ManagedServiceFactoryTracker(this);
// start processing the event queues only after registering the service
// see FELIX-2813 for details
this.updateThread.start();
this.eventThread.start();
}
use of org.apache.felix.cm.file.FilePersistenceManager in project felix by apache.
the class Activator method registerFilePersistenceManager.
private PersistenceManager registerFilePersistenceManager(final BundleContext bundleContext) {
try {
final FilePersistenceManager fpm = new FilePersistenceManager(bundleContext, bundleContext.getProperty(CM_CONFIG_DIR));
final Dictionary<String, Object> props = new Hashtable<>();
props.put(Constants.SERVICE_DESCRIPTION, "Platform Filesystem Persistence Manager");
props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
props.put(Constants.SERVICE_RANKING, new Integer(Integer.MIN_VALUE));
props.put(PersistenceManager.PROPERTY_NAME, FilePersistenceManager.DEFAULT_PERSISTENCE_MANAGER_NAME);
filepmRegistration = bundleContext.registerService(PersistenceManager.class, fpm, props);
return fpm;
} catch (final IllegalArgumentException iae) {
Log.logger.log(LogService.LOG_ERROR, "Cannot create the FilePersistenceManager", iae);
}
return null;
}
use of org.apache.felix.cm.file.FilePersistenceManager in project ddf by codice.
the class Activator method start.
@Override
public void start(BundleContext bundleContext) throws Exception {
persistenceManager = new DelegatingPersistenceManager(new EncryptingPersistenceManager(new FilePersistenceManager(bundleContext, bundleContext.getProperty("felix.cm.dir"))));
final Dictionary<String, Object> props = new Hashtable<>();
props.put(Constants.SERVICE_DESCRIPTION, "DDF :: Platform :: OSGi :: Configuration Admin");
props.put(Constants.SERVICE_VENDOR, "Codice Foundation");
props.put("name", "CodicePM");
filepmRegistration = bundleContext.registerService(PersistenceManager.class.getName(), persistenceManager, props);
}
Aggregations