FELIX-3481 - Targeted PID support:
  - bindsStronger applies wrong logic thus resulting in
     false negatives
  - provideReplacement reassigns the deleted configuration
      instead of the replacement configuration

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1357744 13f79535-47bb-0310-9956-ffa450edef68
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 38afd65..33d6eb4 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
@@ -510,7 +510,7 @@
             for ( String candidate : names )
             {
                 ConfigurationImpl config = getConfiguration( candidate );
-                if ( config != null )
+                if ( config != null && !config.isDeleted() )
                 {
                     // check visibility to use and dynamically bind
                     if ( canReceive( serviceBundle, config.getBundleLocation() ) )
@@ -1612,14 +1612,14 @@
                         final TargetedPID configPid;
                         final Dictionary properties;
                         final long revision;
-                        synchronized ( config )
+                        synchronized ( rc )
                         {
-                            configPid = config.getPid();
-                            properties = config.getProperties( true );
-                            revision = config.getRevision();
+                            configPid = rc.getPid();
+                            properties = rc.getProperties( true );
+                            revision = rc.getRevision();
                         }
 
-                        helper.provideConfiguration( sr, configPid, null, properties, revision );
+                        helper.provideConfiguration( sr, configPid, null, properties, -revision );
 
                         return true;
                     }
diff --git a/configadmin/src/main/java/org/apache/felix/cm/impl/helper/TargetedPID.java b/configadmin/src/main/java/org/apache/felix/cm/impl/helper/TargetedPID.java
index 06dfdb7..6e00547 100644
--- a/configadmin/src/main/java/org/apache/felix/cm/impl/helper/TargetedPID.java
+++ b/configadmin/src/main/java/org/apache/felix/cm/impl/helper/TargetedPID.java
@@ -208,8 +208,8 @@
 
 
     /**
-     * Returns <code>true</code> if the <code>other</code> {@link TargetedPID}
-     * binds stronger than this.
+     * Returns <code>true</code> if this targeted PID binds stronger than
+     * the <code>other</code> {@link TargetedPID}.
      * <p>
      * This method assumes both targeted PIDs have already been checked for
      * suitability for the bundle encoded in the targetting.
@@ -221,7 +221,7 @@
      */
     boolean bindsStronger( final TargetedPID other )
     {
-        return other.bindingLevel > this.bindingLevel;
+        return this.bindingLevel > other.bindingLevel;
     }