com.buglabs.osgi.cm.impl
Class ConfigurationAdminImpl

java.lang.Object
  extended by com.buglabs.osgi.cm.impl.ConfigurationAdminImpl
All Implemented Interfaces:
ConfigurationAdmin

public class ConfigurationAdminImpl
extends java.lang.Object
implements ConfigurationAdmin

ConfigurationAdmin implementation (OSGi R3 10.14.3)


Field Summary
 
Fields inherited from interface org.osgi.service.cm.ConfigurationAdmin
SERVICE_BUNDLELOCATION, SERVICE_FACTORYPID
 
Constructor Summary
ConfigurationAdminImpl()
           
 
Method Summary
 Configuration createFactoryConfiguration(java.lang.String factoryPid)
          Create a new factory Configuration object with a new PID.
 Configuration createFactoryConfiguration(java.lang.String factoryPid, java.lang.String location)
          Create a new factory Configuration object with a new PID.
 Configuration getConfiguration(java.lang.String pid)
          Get an existing or new Configuration object from the persistent store.
 Configuration getConfiguration(java.lang.String pid, java.lang.String location)
          Get an existing Configuration object from the persistent store, or create a new Configuration object.
 Configuration[] listConfigurations(java.lang.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
 

Constructor Detail

ConfigurationAdminImpl

public ConfigurationAdminImpl()
Method Detail

createFactoryConfiguration

public Configuration createFactoryConfiguration(java.lang.String factoryPid)
                                         throws java.io.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(java.util.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:
java.io.IOException - if access to persistent storage fails.

createFactoryConfiguration

public Configuration createFactoryConfiguration(java.lang.String factoryPid,
                                                java.lang.String location)
                                         throws java.io.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(java.util.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.

This method requires AdminPermission.

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:
java.io.IOException - if access to persistent storage fails.

getConfiguration

public Configuration getConfiguration(java.lang.String pid)
                               throws java.io.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.

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

If the location of the Configuration object does not match the calling bundle, throw a SecurityException.

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

getConfiguration

public Configuration getConfiguration(java.lang.String pid,
                                      java.lang.String location)
                               throws java.io.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.

This method requires AdminPermission.

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:
java.io.IOException - if access to persistent storage fails.

listConfigurations

public Configuration[] listConfigurations(java.lang.String filter)
                                   throws java.io.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. If the caller has AdminPermission, then all matching Configuration objects are returned.

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

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

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