public class ConfigurationManager extends Object implements org.osgi.framework.BundleActivator, org.osgi.framework.BundleListener
The ConfigurationManager
is the central class in this implementation of the
Configuration Admin Service Specification. As such it has the following tasks:
BundleActivator
which is called when the bundle is started and
stopped.
BundleListener
which gets informed when the states of bundles change.
Mostly this is needed to unbind any bound configuration in case a bundle is uninstalled.
ServiceListener
which gets informed when ManagedService
and ManagedServiceFactory
services are registered and unregistered. This is
used to provide configuration to these services. As a service listener it also listens for
PersistenceManager
instances being registered to support different configuration
persistence layers.
ConfigurationAdminFactory
instance is registered as the ConfigurationAdmin
service.
FilePersistenceManager
instance is registered as a default PersistenceManager
.
The default FilePersistenceManager
is configured with a configuration location taken
from the felix.cm.dir
framework property. If this property is not set the
config
directory in the current working directory as specified in the user.dir
system property is used.
Modifier and Type | Field and Description |
---|---|
static String |
CM_CONFIG_DIR
The name of the bundle context property defining the location for the configuration files
(value is "felix.cm.dir").
|
static String |
CM_LOG_LEVEL
The name of the bundle context property defining the maximum log level (value is
"felix.cm.loglevel").
|
Constructor and Description |
---|
ConfigurationManager() |
Modifier and Type | Method and Description |
---|---|
void |
bundleChanged(org.osgi.framework.BundleEvent event) |
void |
callPlugins(Dictionary props,
org.osgi.framework.ServiceReference sr,
String configPid,
String factoryPid)
Calls the registered configuration plugins on the given configuration properties from the given
configuration object.
|
void |
configure(String[] pid,
org.osgi.framework.ServiceReference sr,
boolean factory,
org.apache.felix.cm.impl.helper.ConfigurationMap<?> configs)
Schedules the configuration of the referenced service with configuration for the given PID.
|
org.osgi.framework.BundleContext |
getBundleContext() |
boolean |
isLogEnabled(int level) |
void |
log(int level,
String format,
Object[] args) |
void |
log(int level,
String message,
Throwable t) |
void |
start(org.osgi.framework.BundleContext bundleContext) |
void |
stop(org.osgi.framework.BundleContext bundleContext) |
static String |
toString(org.osgi.framework.ServiceReference ref) |
public static final String CM_CONFIG_DIR
start(BundleContext)
,
Constant Field Valuespublic static final String CM_LOG_LEVEL
This value of this property is expected to be an integer number corresponding to the log level values of the OSGi LogService. That is 1 for errors, 2 for warnings, 3 for informational messages and 4 for debug messages. The default value is 2, such that only warnings and errors are logged in the absence of a LogService.
public void start(org.osgi.framework.BundleContext bundleContext)
start
in interface org.osgi.framework.BundleActivator
public void stop(org.osgi.framework.BundleContext bundleContext)
stop
in interface org.osgi.framework.BundleActivator
public org.osgi.framework.BundleContext getBundleContext()
public void bundleChanged(org.osgi.framework.BundleEvent event)
bundleChanged
in interface org.osgi.framework.BundleListener
public void configure(String[] pid, org.osgi.framework.ServiceReference sr, boolean factory, org.apache.felix.cm.impl.helper.ConfigurationMap<?> configs)
pid
- The list of service PID of the configurations to be provided to the referenced
service.sr
- The ServiceReference
to the service to be configured.factory
- true
If the service is considered to be a
ManagedServiceFactory
. Otherwise the service is considered to be a
ManagedService
.public void callPlugins(Dictionary props, org.osgi.framework.ServiceReference sr, String configPid, String factoryPid)
The plugins to be called are selected as ConfigurationPlugin
services
registered with a cm.target
property set to *
or the factory PID of
the configuration (for factory configurations) or the PID of the configuration (for non-factory
configurations).
props
- The configuraiton properties run through the registered ConfigurationPlugin
services. This must not be null
.sr
- The service reference of the managed service (factory) which is to be updated with
configurationconfigPid
- The PID of the configuration object whose properties are to be augmentedfactoryPid
- the factory PID of the configuration object whose properties are to be
augmented. This is non-null
only for a factory configuration.public boolean isLogEnabled(int level)
public static String toString(org.osgi.framework.ServiceReference ref)
This work is licensed under a Creative Commons Attribution 4.0 International License.