FELIX-1488 Disable configuration reassignment due to changing the static
bundle location (according to BJ Hargrave there is no such trigger currently)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@806075 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationBase.java b/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationBase.java
index b5192cf..0ef0ecd 100644
--- a/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationBase.java
+++ b/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationBase.java
@@ -104,8 +104,38 @@
}
+ /**
+ * Returns the "official" bundle location as visible from the outside
+ * world of code calling into the Configuration.getBundleLocation() method.
+ * <p>
+ * In other words: The {@link #getStaticBundleLocation()} is returned if
+ * not <code>null</code>. Otherwise the {@link #getDynamicBundleLocation()}
+ * is returned (which may also be <code>null</code>).
+ */
String getBundleLocation()
{
+ if ( staticBundleLocation != null )
+ {
+ return staticBundleLocation;
+ }
+
+ return dynamicBundleLocation;
+ }
+
+
+ /**
+ * Returns the bundle location according to actual configuration binding.
+ * <p>
+ * This may be different from the {@link #getBundleLocation()} result if
+ * the <code>Configuration.setBundleLocation(String)</code> method has been
+ * called after the configuration has been dynamically bound to a bundle.
+ * <p>
+ * In other words: The {@link #getDynamicBundleLocation()} is returned if
+ * not <code>null</code>. Otherwise the {@link #getStaticBundleLocation()}
+ * is returned (which may also be <code>null</code>).
+ */
+ String getBoundBundleLocation()
+ {
if ( dynamicBundleLocation != null )
{
return dynamicBundleLocation;
@@ -127,14 +157,6 @@
}
- boolean isStaticallyBound()
- {
- // TODO: consider static location too ? to indicate whether we are
- // actually bound ?
- return dynamicBundleLocation == null;
- }
-
-
void setServiceReference( ServiceReference serviceReference )
{
this.serviceReference = serviceReference;
@@ -157,6 +179,10 @@
// location is statically set, the old binding must be removed
// by removing the configuration from the targets and the new binding
// must be setup by updating the configuration for new targets
+ /*
+ * According to BJ Hargrave configuration is not re-dispatched
+ * due to setting the static bundle location.
+ * The following code is therefore disabled for now
if ( ( this instanceof ConfigurationImpl ) && ( bundleLocation != null ) )
{
// remove configuration from current managed service [factory]
@@ -168,6 +194,8 @@
// check whether we have to assign the configuration to new targets
getConfigurationManager().reassignConfiguration( ( ConfigurationImpl ) this );
}
+ *
+ */
}
@@ -179,10 +207,16 @@
// FELIX-1488: If a dynamically bound configuration is unbound and not
// statically bound, it may be rebound to another bundle asking for it
// (unless the dynamic unbind happens due to configuration deletion)
+ /*
+ * According to BJ Hargrave configuration is not re-dispatched
+ * due to setting the static bundle location.
+ * The following code is therefore disabled for now
if ( bundleLocation == null && getStaticBundleLocation() == null && ( this instanceof ConfigurationImpl ) )
{
getConfigurationManager().reassignConfiguration( ( ConfigurationImpl ) this );
}
+ *
+ */
}
diff --git a/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java b/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
index 7fabdda..7890946 100644
--- a/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
+++ b/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
@@ -1316,7 +1316,7 @@
// find the primary configuration owner
final ServiceReference ownerRef = getOwner( config, srList );
final String bundleLocation = ( ownerRef != null ) ? ownerRef.getBundle().getLocation()
- : config.getBundleLocation();
+ : config.getBoundBundleLocation();
// if the configuration is unbound, bind to owner
if ( config.getBundleLocation() == null )
@@ -1383,13 +1383,14 @@
// find the primary configuration owner
final ServiceReference ownerRef = getOwner( config, srList );
final String bundleLocation = ( ownerRef != null ) ? ownerRef.getBundle().getLocation()
- : config.getBundleLocation();
+ : config.getBoundBundleLocation();
// if the configuration is unbound, bind to owner
if ( config.getBundleLocation() == null )
{
config.setDynamicBundleLocation( bundleLocation );
}
+ final String configBundleLocation = config.getBundleLocation();
// provide configuration to all services from the
// correct bundle
@@ -1399,11 +1400,11 @@
final String refLocation = ref.getBundle().getLocation();
// only consider the entry if in the same bundle
- if ( !refLocation.equals( config.getBundleLocation() ) )
+ if ( !refLocation.equals( configBundleLocation ) )
{
log( LogService.LOG_ERROR, "Cannot use configuration " + config.getPid() + " (factory "
+ config.getFactoryPid() + ") for " + ConfigurationManager.toString( ref )
- + ": Configuration bound to bundle " + config.getBundleLocation(), null );
+ + ": Configuration bound to bundle " + configBundleLocation, null );
continue;
}
@@ -1475,7 +1476,7 @@
// if the configuration is location bound, find a service reference
// from the same bundle
- final String configLocation = config.getBundleLocation();
+ final String configLocation = config.getBoundBundleLocation();
if (configLocation != null) {
for ( int i = 0; i < srList.length; i++ )
{
@@ -1519,7 +1520,7 @@
* final and cannot be reset.
*/
this.config = config;
- this.configLocation = config.getBundleLocation();
+ this.configLocation = config.getBoundBundleLocation();
this.fireEvent = fireEvent;
}