Class ConfigurationImpl
ConfigurationImpl is the backend implementation of the
Configuration Admin Service Specification Configuration object
(section 104.4). Instances of this class are shared by multiple instances of
the ConfigurationAdapter class, whose instances are actually returned
to clients.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String[]private final TargetedPIDprivate static final StringThe name of a synthetic property stored in the persisted configuration data to indicate that the configuration data is new, that is created but never updated (value is "_felix_.cm.newConfiguration").private final ConfigurationManagerTheconfiguration managerinstance which caused this configuration object to be created.private StringThe bundle location from dynamic binding.private final TargetedPIDThe factory PID of this configuration ornullif this is not a factory configuration.private booleanFlag indicating that this configuration has been deleted.private booleanprivate final PersistenceManagerprivate CaseInsensitiveDictionaryThe configuration data of this configuration instance.private static final Stringprivate static final Stringprivate longConfiguration revision counter incremented each time thepropertiesis set (in the constructor or theconfigure(Dictionary)method.private StringThe statically bound bundle location, which is set explicitly by calling the Configuration.setBundleLocation(String) method or when the configuration was created with the two-argument method. -
Constructor Summary
ConstructorsConstructorDescriptionConfigurationImpl(ConfigurationManager configurationManager, PersistenceManager persistenceManager, String pid, String factoryPid, String bundleLocation) ConfigurationImpl(ConfigurationManager configurationManager, PersistenceManager persistenceManager, Dictionary<String, Object> properties) -
Method Summary
Modifier and TypeMethodDescription(package private) static voidclearAutoProperties(Dictionary<String, Object> properties) private voidconfigure(Dictionary<String, Object> properties) private voidconfigureFromPersistence(Dictionary<String, Object> properties) private static Object[]convertToObjectArray(Object value) Convert the object to an arrayvoiddelete()(package private) voidStores the configuration if it is a newly factory configuration which has not been persisted yet.boolean(package private) static booleanequals(Dictionary<String, Object> props1, Dictionary<String, Object> props2) Compare the two properties, ignoring auto properties(package private) StringReturns the "official" bundle location as visible from the outside world of code calling into the Configuration.getBundleLocation() method.(package private) final ConfigurationManager(package private) static intgetCount(Dictionary<String, Object> props) (package private) StringgetPid()getProperties(boolean deepCopy) Returns an optionally deep copy of the properties of this configuration instance.longReturns the revision of this configuration object.(package private) StringinthashCode()(package private) booleanisActive()Returnstrueif the ConfigurationManager of this configuration is still active.(package private) static booleanisAutoProp(String name) (package private) booleanReturnstrueif this configuration has already been deleted on the persistence.booleanisLocked()(package private) booleanisNew()Returnsfalseif this configuration contains configuration properties.protected static voidreplaceProperty(Dictionary<String, Object> properties, String key, String value) (package private) voidsetAutoProperties(Dictionary<String, Object> properties, boolean withBundleLocation) (package private) static voidsetAutoProperties(Dictionary<String, Object> properties, String pid, String factoryPid) (package private) voidsetDynamicBundleLocation(String bundleLocation, boolean dispatchConfiguration) voidsetLocked(boolean flag) (package private) voidsetStaticBundleLocation(String bundleLocation) (package private) voidstore()private voidPersists a new (freshly created) configuration with a marker for it to be a new configuration.(package private) voidtoString()(package private) voidtryBindLocation(String bundleLocation) Dynamically binds this configuration to the given location unless the configuration is already bound (statically or dynamically).voidupdate()voidupdate(Dictionary<String, ?> properties)
-
Field Details
-
CONFIGURATION_NEW
The name of a synthetic property stored in the persisted configuration data to indicate that the configuration data is new, that is created but never updated (value is "_felix_.cm.newConfiguration").This special property is stored by the
ConfigurationImpl(ConfigurationManager, PersistenceManager, String, String, String)constructor, when the configuration is first created and persisted and is interpreted by theConfigurationImpl(ConfigurationManager, PersistenceManager, Dictionary)method when the configuration data is loaded in a new object.The goal of this property is to keep the information on whether configuration data is new (but persisted as per the spec) or has already been assigned with possible no data.
- See Also:
-
PROPERTY_LOCKED
- See Also:
-
PROPERTY_REVISION
- See Also:
-
factoryPID
The factory PID of this configuration ornullif this is not a factory configuration. -
staticBundleLocation
The statically bound bundle location, which is set explicitly by calling the Configuration.setBundleLocation(String) method or when the configuration was created with the two-argument method. -
dynamicBundleLocation
The bundle location from dynamic binding. This value is set as the configuration or factory is assigned to a ManagedService[Factory]. -
properties
The configuration data of this configuration instance. This is a private copy of the properties of which a copy is made when themethod is called. This field isinvalid reference
#getProperties()nullif the configuration has been created and never been updated with acutal configuration properties. -
isDeleted
private volatile boolean isDeletedFlag indicating that this configuration has been deleted.- See Also:
-
revision
private volatile long revisionConfiguration revision counter incremented each time thepropertiesis set (in the constructor or theconfigure(Dictionary)method. This counter is persisted transparently so thatcan provide a proper change count. The persistence is forward compatible such that previously persisted configurations are handled gracefully.invalid reference
NotCachablePersistenceManager -
locked
private volatile boolean locked -
configurationManager
Theconfiguration managerinstance which caused this configuration object to be created. -
persistenceManager
-
baseId
-
AUTO_PROPS
-
-
Constructor Details
-
ConfigurationImpl
public ConfigurationImpl(ConfigurationManager configurationManager, PersistenceManager persistenceManager, Dictionary<String, Object> properties) -
ConfigurationImpl
ConfigurationImpl(ConfigurationManager configurationManager, PersistenceManager persistenceManager, String pid, String factoryPid, String bundleLocation) throws IOException - Throws:
IOException
-
-
Method Details
-
isActive
boolean isActive()Returnstrueif the ConfigurationManager of this configuration is still active. -
storeSilently
void storeSilently() -
replaceProperty
protected static void replaceProperty(Dictionary<String, Object> properties, String key, String value) -
delete
- Throws:
IOException
-
getPidString
-
getPid
-
getFactoryPidString
-
getFactoryPid
-
getBundleLocation
String getBundleLocation()Returns the "official" bundle location as visible from the outside world of code calling into the Configuration.getBundleLocation() method.In other words: The
getStaticBundleLocation()is returned if notnull. Otherwise thegetDynamicBundleLocation()is returned (which may also benull). -
getDynamicBundleLocation
String getDynamicBundleLocation() -
getStaticBundleLocation
String getStaticBundleLocation() -
setStaticBundleLocation
-
setDynamicBundleLocation
-
tryBindLocation
Dynamically binds this configuration to the given location unless the configuration is already bound (statically or dynamically). In the case of this configuration to be dynamically bound aCM_LOCATION_CHANGEDevent is dispatched. -
getProperties
Returns an optionally deep copy of the properties of this configuration instance.This method returns a copy of the internal dictionary. If the
deepCopyparameter is true array and collection values are copied into new arrays or collections. Otherwise just a new dictionary referring to the same objects is returned.- Parameters:
deepCopy-trueif a deep copy is to be returned.- Returns:
- the configuration properties
-
update
- Throws:
IOException
-
update
- Throws:
IOException- See Also:
-
equals
-
hashCode
public int hashCode() -
toString
-
ensureFactoryConfigPersisted
Stores the configuration if it is a newly factory configuration which has not been persisted yet.This is used to ensure a configuration c as in
Configuration cf = cm.createFactoryConfiguration(factoryPid); Configuration c = cm.getConfiguration(cf.getPid());
is persisted aftergetConfigurationwhilecreateConfigurationalone does not persist yet.- Throws:
IOException
-
storeNewConfiguration
Persists a new (freshly created) configuration with a marker for it to be a new configuration.- Throws:
IOException- If an error occurrs storing the configuraiton
-
store
- Throws:
IOException
-
getRevision
public long getRevision()Returns the revision of this configuration object.When getting both the configuration properties and this revision counter, the two calls should be synchronized on this instance to ensure configuration values and revision counter match.
-
isNew
boolean isNew()Returnsfalseif this configuration contains configuration properties. Otherwisetrueis returned and this is a newly creted configuration object whoseupdate(Dictionary)method has never been called. -
isDeleted
boolean isDeleted()Returnstrueif this configuration has already been deleted on the persistence. -
configureFromPersistence
-
configure
-
setAutoProperties
-
setAutoProperties
-
clearAutoProperties
-
setLocked
- Throws:
IOException
-
equals
Compare the two properties, ignoring auto properties- Parameters:
props1- Set of propertiesprops2- Set of properties- Returns:
trueif the set of properties is equal
-
convertToObjectArray
Convert the object to an array- Parameters:
value- The array- Returns:
- an object array
-
isAutoProp
-
getCount
-
isLocked
public boolean isLocked() -
getConfigurationManager
-