FELIX-4858: Added missing createCopy in TemporalServiceDependencyImpl, this dependency can now be used from any adapter.
Also added corresponding test case in TemporalServiceDependencyTest.java.
see testFELIX4858_ServiceAdapterConsumptionWithCallbackAndIntermittentAvailability method.
Fixed releaserepo.


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1676646 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/cnf/localrepo/index.xml b/dependencymanager/cnf/localrepo/index.xml
index 62bdb93..51ad4f1 100644
--- a/dependencymanager/cnf/localrepo/index.xml
+++ b/dependencymanager/cnf/localrepo/index.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<repository increment="1430224821199" name="Local" xmlns="http://www.osgi.org/xmlns/repository/v1.0.0">
+<repository increment="1430261259438" name="Local" xmlns="http://www.osgi.org/xmlns/repository/v1.0.0">
   <resource>
     <capability namespace="osgi.identity">
       <attribute name="osgi.identity" value="de.twentyeleven.skysail.org.json-osgi"/>
diff --git a/dependencymanager/cnf/localrepo/index.xml.sha b/dependencymanager/cnf/localrepo/index.xml.sha
index 44ea4f2..6893479 100644
--- a/dependencymanager/cnf/localrepo/index.xml.sha
+++ b/dependencymanager/cnf/localrepo/index.xml.sha
@@ -1 +1 @@
-dcd46191ad0465fb9a1033741b1d53e6dd19f0ba88fadcc8459891ca1151358c
\ No newline at end of file
+73c970e02d8128b75650acabf9ce24372794a93eff20efe95972bcc66de8ab4e
\ No newline at end of file
diff --git a/dependencymanager/cnf/releaserepo/index.xml b/dependencymanager/cnf/releaserepo/index.xml
index e7d0b51..1f230e0 100644
--- a/dependencymanager/cnf/releaserepo/index.xml
+++ b/dependencymanager/cnf/releaserepo/index.xml
@@ -1,30 +1,30 @@
 <?xml version="1.0" encoding="utf-8"?>
-<repository increment="1430224818881" name="Release" xmlns="http://www.osgi.org/xmlns/repository/v1.0.0">
+<repository increment="1430261259416" name="Release" xmlns="http://www.osgi.org/xmlns/repository/v1.0.0">
   <resource>
     <capability namespace="osgi.identity">
       <attribute name="osgi.identity" value="org.apache.felix.dependencymanager.annotation"/>
       <attribute name="type" value="osgi.bundle"/>
-      <attribute name="version" type="Version" value="4.0.1"/>
+      <attribute name="version" type="Version" value="4.0.0"/>
     </capability>
     <capability namespace="osgi.content">
-      <attribute name="osgi.content" value="f0354985434d8644d9a32aaabe285b8632d449de8d32ebe8c1b125888a581021"/>
-      <attribute name="url" value="org.apache.felix.dependencymanager.annotation/org.apache.felix.dependencymanager.annotation-4.0.1.jar"/>
-      <attribute name="size" type="Long" value="93799"/>
+      <attribute name="osgi.content" value="abbf6a81daccc472530b216fdaacf3c184dd901ec28900666e7aad288bb8daf2"/>
+      <attribute name="url" value="org.apache.felix.dependencymanager.annotation/org.apache.felix.dependencymanager.annotation-4.0.0.jar"/>
+      <attribute name="size" type="Long" value="93763"/>
       <attribute name="mime" value="application/vnd.osgi.bundle"/>
     </capability>
     <capability namespace="osgi.wiring.bundle">
       <attribute name="osgi.wiring.bundle" value="org.apache.felix.dependencymanager.annotation"/>
-      <attribute name="bundle-version" type="Version" value="4.0.1"/>
+      <attribute name="bundle-version" type="Version" value="4.0.0"/>
     </capability>
     <capability namespace="osgi.wiring.host">
       <attribute name="osgi.wiring.host" value="org.apache.felix.dependencymanager.annotation"/>
-      <attribute name="bundle-version" type="Version" value="4.0.1"/>
+      <attribute name="bundle-version" type="Version" value="4.0.0"/>
     </capability>
     <capability namespace="osgi.wiring.package">
       <attribute name="osgi.wiring.package" value="org.apache.felix.dm.annotation.api"/>
       <attribute name="version" type="Version" value="1.0.0"/>
       <attribute name="bundle-symbolic-name" value="org.apache.felix.dependencymanager.annotation"/>
-      <attribute name="bundle-version" type="Version" value="4.0.1"/>
+      <attribute name="bundle-version" type="Version" value="4.0.0"/>
     </capability>
     <requirement namespace="osgi.wiring.package">
       <directive name="filter" value="(&amp;(osgi.wiring.package=aQute.bnd.osgi)(version&gt;=2.3.0)(!(version&gt;=3.0.0)))"/>
@@ -46,27 +46,27 @@
     <capability namespace="osgi.identity">
       <attribute name="osgi.identity" value="org.apache.felix.dependencymanager.runtime"/>
       <attribute name="type" value="osgi.bundle"/>
-      <attribute name="version" type="Version" value="4.0.1"/>
+      <attribute name="version" type="Version" value="4.0.0"/>
     </capability>
     <capability namespace="osgi.content">
-      <attribute name="osgi.content" value="3f3a4f2b3742b422252962274ef5803529509c125bed5158a173765a01d36cec"/>
-      <attribute name="url" value="org.apache.felix.dependencymanager.runtime/org.apache.felix.dependencymanager.runtime-4.0.1.jar"/>
-      <attribute name="size" type="Long" value="106753"/>
+      <attribute name="osgi.content" value="661d603a4d94dc69f9e2b0b7ab8c6a8de17bf2fc593906cd9dc2bc04b6330bec"/>
+      <attribute name="url" value="org.apache.felix.dependencymanager.runtime/org.apache.felix.dependencymanager.runtime-4.0.0.jar"/>
+      <attribute name="size" type="Long" value="106750"/>
       <attribute name="mime" value="application/vnd.osgi.bundle"/>
     </capability>
     <capability namespace="osgi.wiring.bundle">
       <attribute name="osgi.wiring.bundle" value="org.apache.felix.dependencymanager.runtime"/>
-      <attribute name="bundle-version" type="Version" value="4.0.1"/>
+      <attribute name="bundle-version" type="Version" value="4.0.0"/>
     </capability>
     <capability namespace="osgi.wiring.host">
       <attribute name="osgi.wiring.host" value="org.apache.felix.dependencymanager.runtime"/>
-      <attribute name="bundle-version" type="Version" value="4.0.1"/>
+      <attribute name="bundle-version" type="Version" value="4.0.0"/>
     </capability>
     <capability namespace="osgi.wiring.package">
       <attribute name="osgi.wiring.package" value="org.apache.felix.dm.runtime.api"/>
       <attribute name="version" type="Version" value="1.0.0"/>
       <attribute name="bundle-symbolic-name" value="org.apache.felix.dependencymanager.runtime"/>
-      <attribute name="bundle-version" type="Version" value="4.0.1"/>
+      <attribute name="bundle-version" type="Version" value="4.0.0"/>
     </capability>
     <capability namespace="osgi.extender">
       <attribute name="osgi.extender" value="org.apache.felix.dependencymanager.runtime"/>
@@ -99,21 +99,21 @@
     <capability namespace="osgi.identity">
       <attribute name="osgi.identity" value="org.apache.felix.dependencymanager.shell"/>
       <attribute name="type" value="osgi.bundle"/>
-      <attribute name="version" type="Version" value="4.0.1"/>
+      <attribute name="version" type="Version" value="4.0.0"/>
     </capability>
     <capability namespace="osgi.content">
-      <attribute name="osgi.content" value="ccc1f8c612eaa9137b7b5bc826327a26a588d712a281f83f00b7c189804d316a"/>
-      <attribute name="url" value="org.apache.felix.dependencymanager.shell/org.apache.felix.dependencymanager.shell-4.0.1.jar"/>
-      <attribute name="size" type="Long" value="21408"/>
+      <attribute name="osgi.content" value="6828e22e1e765659c1a0c6abb30515b6887d6cd7a7b61fd8cad14ad625f1c51b"/>
+      <attribute name="url" value="org.apache.felix.dependencymanager.shell/org.apache.felix.dependencymanager.shell-4.0.0.jar"/>
+      <attribute name="size" type="Long" value="21409"/>
       <attribute name="mime" value="application/vnd.osgi.bundle"/>
     </capability>
     <capability namespace="osgi.wiring.bundle">
       <attribute name="osgi.wiring.bundle" value="org.apache.felix.dependencymanager.shell"/>
-      <attribute name="bundle-version" type="Version" value="4.0.1"/>
+      <attribute name="bundle-version" type="Version" value="4.0.0"/>
     </capability>
     <capability namespace="osgi.wiring.host">
       <attribute name="osgi.wiring.host" value="org.apache.felix.dependencymanager.shell"/>
-      <attribute name="bundle-version" type="Version" value="4.0.1"/>
+      <attribute name="bundle-version" type="Version" value="4.0.0"/>
     </capability>
     <requirement namespace="osgi.wiring.package">
       <directive name="filter" value="(&amp;(osgi.wiring.package=org.apache.felix.dm)(version&gt;=4.0.0)(!(version&gt;=5.0.0)))"/>
diff --git a/dependencymanager/cnf/releaserepo/index.xml.sha b/dependencymanager/cnf/releaserepo/index.xml.sha
index 7c54e3c..0c256e2 100644
--- a/dependencymanager/cnf/releaserepo/index.xml.sha
+++ b/dependencymanager/cnf/releaserepo/index.xml.sha
@@ -1 +1 @@
-bde678f8ebb83da0c0f591348000f069a8a5cddfdc67ce6522f2087837553cd7
\ No newline at end of file
+d03ee8fdf41b1cab1a9a035aeaa657cb8685d503d3eaeaa998ae91e90a63d3ff
\ No newline at end of file
diff --git a/dependencymanager/cnf/releaserepo/org.apache.felix.dependencymanager.annotation/org.apache.felix.dependencymanager.annotation-4.0.1.jar b/dependencymanager/cnf/releaserepo/org.apache.felix.dependencymanager.annotation/org.apache.felix.dependencymanager.annotation-4.0.0.jar
similarity index 87%
rename from dependencymanager/cnf/releaserepo/org.apache.felix.dependencymanager.annotation/org.apache.felix.dependencymanager.annotation-4.0.1.jar
rename to dependencymanager/cnf/releaserepo/org.apache.felix.dependencymanager.annotation/org.apache.felix.dependencymanager.annotation-4.0.0.jar
index 11ed0ff..164454f 100644
--- a/dependencymanager/cnf/releaserepo/org.apache.felix.dependencymanager.annotation/org.apache.felix.dependencymanager.annotation-4.0.1.jar
+++ b/dependencymanager/cnf/releaserepo/org.apache.felix.dependencymanager.annotation/org.apache.felix.dependencymanager.annotation-4.0.0.jar
Binary files differ
diff --git a/dependencymanager/cnf/releaserepo/org.apache.felix.dependencymanager.runtime/org.apache.felix.dependencymanager.runtime-4.0.1.jar b/dependencymanager/cnf/releaserepo/org.apache.felix.dependencymanager.runtime/org.apache.felix.dependencymanager.runtime-4.0.0.jar
similarity index 90%
rename from dependencymanager/cnf/releaserepo/org.apache.felix.dependencymanager.runtime/org.apache.felix.dependencymanager.runtime-4.0.1.jar
rename to dependencymanager/cnf/releaserepo/org.apache.felix.dependencymanager.runtime/org.apache.felix.dependencymanager.runtime-4.0.0.jar
index 1a4a641..5e23325 100644
--- a/dependencymanager/cnf/releaserepo/org.apache.felix.dependencymanager.runtime/org.apache.felix.dependencymanager.runtime-4.0.1.jar
+++ b/dependencymanager/cnf/releaserepo/org.apache.felix.dependencymanager.runtime/org.apache.felix.dependencymanager.runtime-4.0.0.jar
Binary files differ
diff --git a/dependencymanager/cnf/releaserepo/org.apache.felix.dependencymanager.shell/org.apache.felix.dependencymanager.shell-4.0.1.jar b/dependencymanager/cnf/releaserepo/org.apache.felix.dependencymanager.shell/org.apache.felix.dependencymanager.shell-4.0.0.jar
similarity index 87%
rename from dependencymanager/cnf/releaserepo/org.apache.felix.dependencymanager.shell/org.apache.felix.dependencymanager.shell-4.0.1.jar
rename to dependencymanager/cnf/releaserepo/org.apache.felix.dependencymanager.shell/org.apache.felix.dependencymanager.shell-4.0.0.jar
index 76e43a6..8b72f3f 100644
--- a/dependencymanager/cnf/releaserepo/org.apache.felix.dependencymanager.shell/org.apache.felix.dependencymanager.shell-4.0.1.jar
+++ b/dependencymanager/cnf/releaserepo/org.apache.felix.dependencymanager.shell/org.apache.felix.dependencymanager.shell-4.0.0.jar
Binary files differ
diff --git a/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/TemporalServiceDependencyTest.java b/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/TemporalServiceDependencyTest.java
index 97b1565..2926ff2 100644
--- a/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/TemporalServiceDependencyTest.java
+++ b/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/TemporalServiceDependencyTest.java
@@ -100,6 +100,46 @@
         m.clear();
     }
 
+    // Same test as testServiceConsumptionWithCallbackAndIntermittentAvailability, but the consumer is now
+    // an adapter for the Adaptee interface.
+    public void testFELIX4858_ServiceAdapterConsumptionWithCallbackAndIntermittentAvailability() {
+        final DependencyManager m = getDM();
+        // helper class that ensures certain steps get executed in sequence
+        Ensure e = new Ensure();
+        // create a service provider and consumer
+        TemporalServiceProvider provider = new TemporalServiceProvider(e);
+        Component sp = m.createComponent().setImplementation(provider).setInterface(TemporalServiceInterface.class.getName(), null);
+        TemporalServiceProvider2 provider2 = new TemporalServiceProvider2(e);
+        Component sp2 = m.createComponent().setImplementation(provider2).setInterface(TemporalServiceInterface.class.getName(), null);
+        TemporalServiceConsumerAdapterWithCallback consumer = new TemporalServiceConsumerAdapterWithCallback(e);
+        ServiceDependency temporalDep =  m.createTemporalServiceDependency(10000).setService(TemporalServiceInterface.class).setRequired(true).setCallbacks("add", "remove");
+        Component sc = m.createAdapterService(Adaptee.class, null).setImplementation(consumer).add(temporalDep);            
+        Component adaptee = m.createComponent().setImplementation(new Adaptee()).setInterface(Adaptee.class.getName(), null);
+            
+        // add the adapter service consumer
+        m.add(sc);
+        // add the adaptee (the adapter service depends on it)
+        m.add(adaptee);
+        // now add the first provider
+        m.add(sp);
+        e.waitForStep(2, 5000);
+        // and remove it again (this should not affect the consumer yet)
+        m.remove(sp);
+        // now add the second provider
+        m.add(sp2);
+        e.step(3);
+        e.waitForStep(4, 5000);
+        // and remove it again
+        m.remove(sp2);
+        // finally remove the consumer
+        m.remove(sc);
+        // Wait for the consumer.remove callback
+        e.waitForStep(6, 5000);
+        // ensure we executed all steps inside the component instance
+        e.step(7);
+        m.clear();
+    }
+
     public void testFelix4602_PropagateServiceInvocationException() {
         final DependencyManager m = getDM();
         final Ensure ensure = new Ensure();
@@ -203,4 +243,28 @@
             m_ensure.step(6);
         }
     }
+    
+    public static class Adaptee {       
+    }
+       
+    static class TemporalServiceConsumerAdapterWithCallback extends TemporalServiceConsumer {
+        volatile Adaptee m_adaptee;
+        
+        public TemporalServiceConsumerAdapterWithCallback(Ensure e) {
+            super(e);
+        }
+        
+        public void start() {
+            Assert.assertTrue(m_adaptee != null);
+        }
+        
+        public void add(TemporalServiceInterface service) {
+            m_service = service;
+        }
+        
+        public void remove(TemporalServiceInterface service) {
+            Assert.assertTrue(m_service == service);
+            m_ensure.step(6);
+        }
+    }
 }
diff --git a/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/TemporalServiceDependencyImpl.java b/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/TemporalServiceDependencyImpl.java
index c329307..d213dd7 100644
--- a/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/TemporalServiceDependencyImpl.java
+++ b/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/TemporalServiceDependencyImpl.java
@@ -25,6 +25,7 @@
 
 import org.apache.felix.dm.DependencyActivatorBase;
 import org.apache.felix.dm.ServiceDependency;
+import org.apache.felix.dm.context.DependencyContext;
 import org.apache.felix.dm.context.EventType;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -61,6 +62,21 @@
         m_timeout = timeout;
         m_frameworkBundle = context.getBundle(0);
     }
+    
+    /**
+     * Creates a clone of an existing temporal service dependency.
+     */
+    public TemporalServiceDependencyImpl(TemporalServiceDependencyImpl prototype) {
+        super(prototype);
+        super.setRequired(true);
+        m_timeout = prototype.m_timeout;
+        m_frameworkBundle = prototype.m_frameworkBundle;
+    }
+
+    @Override
+    public DependencyContext createCopy() {
+        return new TemporalServiceDependencyImpl(this);
+    }
 
     /**
      * Sets the required flag which determines if this service is required or not. This method