org.apache.felix.cm.impl
Class ConfigurationAdminImpl

java.lang.Object
  extended by org.apache.felix.cm.impl.ConfigurationAdminImpl
All Implemented Interfaces:
ConfigurationAdmin

public class ConfigurationAdminImpl
extends Object
implements ConfigurationAdmin

The ConfigurationAdminImpl is the per-bundle frontend to the configuration manager. Instances of this class are created on-demand for each bundle trying to get hold of the ConfigurationAdmin service.


Field Summary
 
Fields inherited from interface org.osgi.service.cm.ConfigurationAdmin
SERVICE_BUNDLELOCATION, SERVICE_FACTORYPID
 
Method Summary
 Configuration createFactoryConfiguration(String factoryPid)
          Create a new factory Configuration object with a new PID.
 Configuration createFactoryConfiguration(String factoryPid, String location)
          Create a new factory Configuration object with a new PID.
 Configuration getConfiguration(String pid)
          Get an existing or new Configuration object from the persistent store.
 Configuration getConfiguration(String pid, String location)
          Get an existing Configuration object from the persistent store, or create a new Configuration object.
 Configuration[] listConfigurations(String filter)
          List the current Configuration objects which match the filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createFactoryConfiguration

public Configuration createFactoryConfiguration(String factoryPid)
                                         throws IOException
Description copied from interface: ConfigurationAdmin
Create a new factory Configuration object with a new PID. The properties of the new Configuration object are null until the first time that its Configuration.update(Dictionary) method is called.

It is not required that the factoryPid maps to a registered Managed Service Factory.

The Configuration object is bound to the location of the calling bundle.

Specified by:
createFactoryConfiguration in interface ConfigurationAdmin
Parameters:
factoryPid - PID of factory (not null).
Returns:
A new Configuration object.
Throws:
IOException - if access to persistent storage fails.

createFactoryConfiguration

public Configuration createFactoryConfiguration(String factoryPid,
                                                String location)
                                         throws IOException
Description copied from interface: ConfigurationAdmin
Create a new factory Configuration object with a new PID. The properties of the new Configuration object are null until the first time that its Configuration.update(Dictionary) method is called.

It is not required that the factoryPid maps to a registered Managed Service Factory.

The Configuration is bound to the location specified. If this location is null it will be bound to the location of the first bundle that registers a Managed Service Factory with a corresponding PID.

Specified by:
createFactoryConfiguration in interface ConfigurationAdmin
Parameters:
factoryPid - PID of factory (not null).
location - A bundle location string, or null.
Returns:
a new Configuration object.
Throws:
IOException - if access to persistent storage fails.

getConfiguration

public Configuration getConfiguration(String pid)
                               throws IOException
Description copied from interface: ConfigurationAdmin
Get an existing or new Configuration object from the persistent store. If the Configuration object for this PID does not exist, create a new Configuration object for that PID, where properties are null. Bind its location to the calling bundle's location.

Otherwise, if the location of the existing Configuration object is null, set it to the calling bundle's location.

Specified by:
getConfiguration in interface ConfigurationAdmin
Parameters:
pid - persistent identifier.
Returns:
an existing or new Configuration matching the PID.
Throws:
IOException - if access to persistent storage fails.

getConfiguration

public Configuration getConfiguration(String pid,
                                      String location)
                               throws IOException
Description copied from interface: ConfigurationAdmin
Get an existing Configuration object from the persistent store, or create a new Configuration object.

If a Configuration with this PID already exists in Configuration Admin service return it. The location parameter is ignored in this case.

Else, return a new Configuration object. This new object is bound to the location and the properties are set to null. If the location parameter is null, it will be set when a Managed Service with the corresponding PID is registered for the first time.

Specified by:
getConfiguration in interface ConfigurationAdmin
Parameters:
pid - Persistent identifier.
location - The bundle location string, or null.
Returns:
An existing or new Configuration object.
Throws:
IOException - if access to persistent storage fails.

listConfigurations

public Configuration[] listConfigurations(String filter)
                                   throws IOException,
                                          InvalidSyntaxException
Description copied from interface: ConfigurationAdmin
List the current Configuration objects which match the filter.

Only Configuration objects with non- null properties are considered current. That is, Configuration.getProperties() is guaranteed not to return null for each of the returned Configuration objects.

Normally only Configuration objects that are bound to the location of the calling bundle are returned, or all if the caller has ConfigurationPermission[*,CONFIGURE].

The syntax of the filter string is as defined in the Filter class. The filter can test any configuration properties including the following:

The filter can also be null, meaning that all Configuration objects should be returned.

Specified by:
listConfigurations in interface ConfigurationAdmin
Parameters:
filter - A filter string, or null to retrieve all Configuration objects.
Returns:
All matching Configuration objects, or null if there aren't any.
Throws:
IOException - if access to persistent storage fails
InvalidSyntaxException - if the filter string is invalid


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.