You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2009/08/20 09:53:25 UTC

svn commit: r806075 - in /felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl: ConfigurationBase.java ConfigurationManager.java

Author: fmeschbe
Date: Thu Aug 20 07:53:25 2009
New Revision: 806075

URL: http://svn.apache.org/viewvc?rev=806075&view=rev
Log:
FELIX-1488 Disable configuration reassignment due to changing the static
bundle location (according to BJ Hargrave there is no such trigger currently)

Modified:
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationBase.java
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java

Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationBase.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationBase.java?rev=806075&r1=806074&r2=806075&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationBase.java (original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationBase.java Thu Aug 20 07:53:25 2009
@@ -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 );
         }
+         *
+         */
     }
 
 

Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java?rev=806075&r1=806074&r2=806075&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java (original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java Thu Aug 20 07:53:25 2009
@@ -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;
         }