The main purpose of this interface is to store bundle configuration data
persistently. This information is represented in Configuration
objects. The actual configuration data is a Dictionary of properties
inside a Configuration object.
There are two principally different ways to manage configurations. First there is the concept of a Managed Service, where configuration data is uniquely associated with an object registered with the service registry.
Next, there is the concept of a factory where the Configuration Admin service
will maintain 0 or more Configuration objects for a Managed Service
Factory that is registered with the Framework.
The first concept is intended for configuration data about "things/services" whose existence is defined externally, e.g. a specific printer. Factories are intended for "things/services" that can be created any number of times, e.g. a configuration for a DHCP server for different networks.
Bundles that require configuration should register a Managed Service or a
Managed Service Factory in the service registry. A registration property
named service.pid (persistent identifier or PID) must be used to
identify this Managed Service or Managed Service Factory to the Configuration
Admin service.
When the ConfigurationAdmin detects the registration of a Managed Service, it
checks its persistent storage for a configuration object whose
service.pid property matches the PID service property (
service.pid) of the Managed Service. If found, it calls
ManagedService#updated(Dictionary) method with the new properties.
The implementation of a Configuration Admin service must run these call-backs
asynchronously to allow proper synchronization.
When the Configuration Admin service detects a Managed Service Factory
registration, it checks its storage for configuration objects whose
service.factoryPid property matches the PID service property of the
Managed Service Factory. For each such Configuration objects, it
calls the ManagedServiceFactory.updated method asynchronously with
the new properties. The calls to the updated method of a
ManagedServiceFactory must be executed sequentially and not overlap
in time.
In general, bundles having permission to use the Configuration Admin service
can only access and modify their own configuration information. Accessing or
modifying the configuration of other bundles requires
ConfigurationPermission[location,CONFIGURE], where location is the
configuration location.
Configuration objects can be bound to a specified bundle
location or to a region (configuration location starts with ?). If a
location is not set, it will be learned the first time a target is
registered. If the location is learned this way, the Configuration Admin
service must detect if the bundle corresponding to the location is
uninstalled. If this occurs, the Configuration object must be
unbound, that is its location field is set back to null.
If target's bundle location matches the configuration location it is always updated.
If the configuration location starts with ?, that is, the location is
a region, then the configuration must be delivered to all targets registered
with the given PID. If security is on, the target bundle must have
Configuration Permission[location,TARGET], where location matches given the
configuration location with wildcards as in the Filter substring match. The
security must be verified using the
org. method on the target
bundle.
If a target cannot be updated because the location does not match or it has no permission and security is active then the Configuration Admin service must not do the normal callback.
The method descriptions of this class refer to a concept of "the calling
bundle". This is a loose way of referring to the bundle which obtained the
Configuration Admin service from the service registry. Implementations of
ConfigurationAdmin must use a
org. to support this concept.
| Modifier and Type | Field and Description |
|---|---|
| public static final String | SERVICE_BUNDLELOCATION
Configuration property naming the location of the bundle that is
associated with a |
| public static final String | SERVICE_FACTORYPID
Configuration property naming the Factory PID in the configuration dictionary. |
| Modifier and Type | Method and Description |
|---|---|
| public Configuration | Returns: A newConfiguration object.PID of factory (not factoryPid)null).Create a new factory |
| public Configuration | Returns: a newConfiguration object.PID of factory (not factoryPid, String null).A bundle location string, or location)null.Create a new factory |
| public Configuration | Returns: An existing or newConfiguration object.Persistent identifier. pid, String The bundle location string, or location)null.Get an existing |
| public Configuration | Returns: an existing or newConfiguration matching the PID.persistent identifier. pid)Get an existing or new |
| public Configuration | Returns: An existing or newConfiguration object.PID of factory (not factoryPid, String null).A name for name, String Configuration (not null).The bundle location string, or location)null.Get an existing or new |
| public Configuration | Returns: an existing or newConfiguration matching the PID.PID of factory (not factoryPid, String null).A name for name)Configuration (not null).Get an existing or new |
| public Configuration[] | Returns: All matchingConfiguration objects, or null if
there aren't any.A filter string, or filter)null to retrieve all
Configuration objects.List the current |
| SERVICE_BUNDLELOCATION | back to summary |
|---|---|
| public static final String SERVICE_BUNDLELOCATION Configuration property naming the location of the bundle that is
associated with a
| |
| SERVICE_FACTORYPID | back to summary |
|---|---|
| public static final String SERVICE_FACTORYPID Configuration property naming the Factory PID in the configuration
dictionary. The property's value is of type
| |
| createFactoryConfiguration | back to summary |
|---|---|
| public Configuration createFactoryConfiguration(String factoryPid) throws IOException Create a new factory
It is not required that the
The
| |
| createFactoryConfiguration | back to summary |
|---|---|
| public Configuration createFactoryConfiguration(String factoryPid, String location) throws IOException Create a new factory
It is not required that the
The
If the location starts with
| |
| getConfiguration | back to summary |
|---|---|
| public Configuration getConfiguration(String pid, String location) throws IOException Get an existing
If a
Else, return a new
| |
| getConfiguration | back to summary |
|---|---|
| public Configuration getConfiguration(String pid) throws IOException Get an existing or new
Otherwise, if the location of the existing
| |
| getFactoryConfiguration | back to summary |
|---|---|
| public Configuration getFactoryConfiguration(String factoryPid, String name, String location) throws IOException Get an existing or new
If a
Else, return a new
| |
| getFactoryConfiguration | back to summary |
|---|---|
| public Configuration getFactoryConfiguration(String factoryPid, String name) throws IOException Get an existing or new
If a
Otherwise, if the location of the existing
| |
| listConfigurations | back to summary |
|---|---|
| public Configuration[] listConfigurations(String filter) throws IOException, InvalidSyntaxException List the current
Only When there is no security on then all configurations can be returned. If security is on, the caller must have ConfigurationPermission[location,CONFIGURE].
The syntax of the filter string is as defined in the
null, meaning that all
Configuration objects should be returned.
| |