- added constant "LOG_LEVEL" in Base.jave, in order to enable/disable log level (by default, the level is LOG_WARNING)
- reorganized some annotation tests
- improved Aspect/Adapter annotation tests



git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1086725 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/AdapterTest.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/AdapterTest.java
index 6bfb078..b9a9200 100644
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/AdapterTest.java
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/AdapterTest.java
@@ -18,34 +18,173 @@
  */
 package org.apache.felix.dm.test.bundle.annotation.adapter;
 
+import java.util.Hashtable;
 import java.util.Map;
 
+import org.apache.felix.dm.annotation.api.AdapterService;
 import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.Property;
 import org.apache.felix.dm.annotation.api.ServiceDependency;
 import org.apache.felix.dm.annotation.api.Start;
+import org.apache.felix.dm.annotation.api.Stop;
 import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
+import org.osgi.framework.ServiceRegistration;
 
-@Component
 public class AdapterTest
 {
-    @ServiceDependency
-    Sequencer m_sequencer;
-    private Map<String, String> m_serviceProperties;
-    
-    @ServiceDependency
-    void bind(Map<String, String> serviceProperties, ServiceInterface3 service)
+    public interface S1
     {
-        m_serviceProperties = serviceProperties;
-        service.run3();
+        public void run();
+    }
+
+    public interface S2
+    {
+        public void run2();
+    }
+
+    public interface S3
+    {
+        public void run3();
+    }
+
+    @Component
+    public static class S3Consumer
+    {
+        @ServiceDependency
+        Sequencer m_sequencer;
+        private Map<String, String> m_serviceProperties;
+        private volatile S3 m_s3;
+        
+        @ServiceDependency
+        void bind(Map<String, String> serviceProperties, S3 s3)
+        {
+            m_serviceProperties = serviceProperties;
+            m_s3 = s3;
+        }
+        
+        @Start
+        void start() {
+            // The adapter service must inherit from adaptee service properties ...
+            if ("value1".equals(m_serviceProperties.get("param1")) // adaptee properties
+                && "true".equals(m_serviceProperties.get("adapter"))) // adapter properties
+            {
+                m_s3.run3();
+            }        
+        }
+    }
+
+    @AdapterService(adapteeService = S1.class, 
+                    properties={@Property(name="adapter", value="true")})
+    public static class S1ToS3AdapterAutoConfig implements S3
+    {
+        // This is the adapted service
+        protected S1 m_s1;
+        
+        @ServiceDependency(filter="(name=AdapterAutoConfig)")
+        protected Sequencer m_sequencer;
+
+        public void run3()
+        {
+            m_s1.run();
+            m_sequencer.step(3);
+        }
+    }
+
+    @AdapterService(adapteeService = S1.class, 
+                    properties={@Property(name="adapter", value="true")},
+                    field="m_s1")
+    public static class S1ToS3AdapterAutoConfigField implements S3
+    {
+        // This is the adapted service
+        protected S1 m_s1;
+        
+        @ServiceDependency(filter="(name=AdapterAutoConfigField)")
+        protected Sequencer m_sequencer;
+
+        public void run3()
+        {
+            m_s1.run();
+            m_sequencer.step(3);
+        }
     }
     
-    @Start
-    void start() {
-        // The adapter service must inherit from adaptee service properties ...
-        if ("value1".equals(m_serviceProperties.get("param1")) // adaptee properties
-            && "value2".equals(m_serviceProperties.get("param2"))) // adapter properties
+    @AdapterService(adapteeService = S1.class, 
+                    properties={@Property(name="adapter", value="true")},
+                    added="bind", 
+                    changed="changed",
+                    removed="removed")
+    public static class S1ToS3AdapterCallback implements S3
+    {
+        // This is the adapted service
+        protected Object m_s1;
+        
+        @ServiceDependency(filter="(name=AdapterCallback)")
+        protected Sequencer m_sequencer;
+
+        void bind(S1 s1)
         {
-            m_sequencer.step(4);
-        }        
+            m_s1 = s1;
+        }
+        
+        public void run3()
+        {
+            ((S1) m_s1).run(); // s1 will change its properties here
+        }
+        
+        void changed(S1 s1)
+        {
+            m_sequencer.step(3);            
+        }
+        
+        @Stop
+        void stop() 
+        {
+            m_sequencer.step(4);            
+        }
+        
+        void removed(S1 s1)
+        {
+            m_sequencer.step(5);            
+        }
+    }
+
+    @Component(properties = { @Property(name = "param1", value = "value1") })
+    public static class S1Impl implements S1
+    {
+        @ServiceDependency
+        protected Sequencer m_sequencer;
+
+        @ServiceDependency
+        protected S2 m_s2;
+        
+        // Injected when started
+        ServiceRegistration m_registration;
+
+        public void run()
+        {
+            m_sequencer.step(1);
+            m_s2.run2();
+            Thread update = new Thread() {
+                public void run() {
+                    m_registration.setProperties(new Hashtable<String, String>() {{ 
+                        put("param1", "value1");
+                        put("param2", "value2");
+                    }});
+                }
+            };
+            update.start();
+        }
+    }
+    
+    @Component
+    public static class S2Impl implements S2
+    {
+        @ServiceDependency
+        protected Sequencer m_sequencer;
+        
+        public void run2()
+        {
+            m_sequencer.step(2);
+        }
     }
 }
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ServiceInterface.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ServiceInterface.java
deleted file mode 100644
index 04eb958..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ServiceInterface.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.dm.test.bundle.annotation.adapter;
-
-public interface ServiceInterface
-{
-    public void run();
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ServiceInterface2.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ServiceInterface2.java
deleted file mode 100644
index a4aef3a..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ServiceInterface2.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.dm.test.bundle.annotation.adapter;
-
-public interface ServiceInterface2
-{
-    public void run2();
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ServiceInterface3.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ServiceInterface3.java
deleted file mode 100644
index 38cb21f..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ServiceInterface3.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.dm.test.bundle.annotation.adapter;
-
-public interface ServiceInterface3
-{
-    public void run3();
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ServiceProvider.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ServiceProvider.java
deleted file mode 100644
index 3c40cad..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ServiceProvider.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.dm.test.bundle.annotation.adapter;
-
-import org.apache.felix.dm.annotation.api.Component;
-import org.apache.felix.dm.annotation.api.Property;
-import org.apache.felix.dm.annotation.api.ServiceDependency;
-import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
-
-@Component(properties = { @Property(name = "param1", value = "value1") })
-public class ServiceProvider implements ServiceInterface
-{
-    @ServiceDependency
-    protected Sequencer m_sequencer;
-
-    @ServiceDependency
-    protected ServiceInterface2 m_serviceInterface2;
-
-    public void run()
-    {
-        m_sequencer.step(1);
-        m_serviceInterface2.run2();
-    }
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ServiceProvider2.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ServiceProvider2.java
deleted file mode 100644
index 12cc75b..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ServiceProvider2.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.dm.test.bundle.annotation.adapter;
-
-import org.apache.felix.dm.annotation.api.Component;
-import org.apache.felix.dm.annotation.api.ServiceDependency;
-import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
-
-@Component
-public class ServiceProvider2 implements ServiceInterface2
-{
-    @ServiceDependency
-    protected Sequencer m_sequencer;
-    
-    public void run2()
-    {
-        m_sequencer.step(2);
-    }
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ServiceProviderAdapter.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ServiceProviderAdapter.java
deleted file mode 100644
index 7f7bdd6..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/adapter/ServiceProviderAdapter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.dm.test.bundle.annotation.adapter;
-
-import org.apache.felix.dm.annotation.api.AdapterService;
-import org.apache.felix.dm.annotation.api.Property;
-import org.apache.felix.dm.annotation.api.ServiceDependency;
-import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
-
-@AdapterService(adapteeService = ServiceInterface.class, properties={@Property(name="param2", value="value2")})
-public class ServiceProviderAdapter implements ServiceInterface3
-{
-    // This is the adapted service
-    protected ServiceInterface m_adaptee;
-    
-    @ServiceDependency
-    protected Sequencer m_sequencer;
-
-    public void run3()
-    {
-        m_adaptee.run();
-        m_sequencer.step(3);
-    }
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/AspectChainTest.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/AspectChainTest.java
new file mode 100644
index 0000000..7810f70
--- /dev/null
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/AspectChainTest.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.dm.test.bundle.annotation.aspect;
+
+import java.util.Hashtable;
+
+import org.apache.felix.dm.annotation.api.AspectService;
+import org.apache.felix.dm.annotation.api.Component;
+import org.apache.felix.dm.annotation.api.Destroy;
+import org.apache.felix.dm.annotation.api.Init;
+import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Stop;
+import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
+import org.osgi.framework.ServiceRegistration;
+
+public class AspectChainTest
+{
+    public interface ServiceInterface
+    {
+        public void invoke(Runnable run);
+    }
+
+    @Component
+    public static class ServiceProvider implements ServiceInterface
+    {
+        @ServiceDependency(filter="(name=AspectChainTest.ServiceProvider)")
+        protected Sequencer m_sequencer;
+        // Injected by reflection.
+        protected ServiceRegistration m_sr;
+                
+        public void invoke(Runnable run)
+        {
+            run.run();
+            m_sequencer.step(6);
+            Thread update = new Thread() {
+                public void run() {
+                    m_sr.setProperties(new Hashtable<String, String>() {{ put("foo", "bar");}});      
+                }
+            };
+            update.start();
+        }
+    }
+    
+    @AspectService(ranking = 20)
+    public static class ServiceAspect2 implements ServiceInterface
+    {
+        @ServiceDependency(filter="(name=AspectChainTest.ServiceAspect2)")
+        protected Sequencer m_sequencer;
+        // Injected by reflection.
+        private volatile ServiceInterface m_parentService;
+
+        public void invoke(Runnable run)
+        {
+            m_sequencer.step(3);
+            m_parentService.invoke(run);
+        }
+    }
+
+    @AspectService(ranking = 30, added="add")
+    public static class ServiceAspect3 implements ServiceInterface
+    {
+        @ServiceDependency(filter="(name=AspectChainTest.ServiceAspect3)")
+        protected Sequencer m_sequencer;
+        // Injected using add callback.
+        private volatile ServiceInterface m_parentService;
+
+        void add(ServiceInterface si)
+        {
+            m_parentService = si;
+        }
+        
+        public void invoke(Runnable run)
+        {
+            m_sequencer.step(2);
+            m_parentService.invoke(run);
+        }
+    }
+
+    @AspectService(ranking = 10, added="added", changed="changed", removed="removed")
+    public static class ServiceAspect1 implements ServiceInterface
+    {
+        @ServiceDependency(filter="(name=AspectChainTest.ServiceAspect1)")
+        protected Sequencer m_sequencer;
+        // Injected by reflection.
+        private volatile ServiceInterface m_parentService;
+
+        void added(ServiceInterface si)
+        {
+            m_parentService = si;
+        }
+        
+        void changed(ServiceInterface si)
+        {
+            m_sequencer.step(7);
+        }
+        
+        @Stop
+        void stop()
+        {
+            m_sequencer.step(8);
+        }
+        
+        void removed(ServiceInterface si)
+        {
+            m_sequencer.step(9);
+        }
+        
+        public void invoke(Runnable run)
+        {
+            m_sequencer.step(4);
+            m_parentService.invoke(run);
+        }
+    }
+
+    @Component
+    public static class ServiceConsumer implements Runnable
+    {
+        @ServiceDependency(filter = "(name=AspectChainTest.ServiceConsumer)")
+        protected Sequencer m_sequencer;
+
+        @ServiceDependency
+        private volatile ServiceInterface m_service;
+
+        private Thread m_thread;
+
+        @Init
+        public void init()
+        {
+            m_thread = new Thread(this);
+            m_thread.start();
+        }
+
+        public void run()
+        {
+            m_sequencer.waitForStep(1, 2000);
+            m_service.invoke(new Runnable()
+            {
+                public void run()
+                {
+                    m_sequencer.step(5);
+                }
+            });
+        }
+        
+        @Destroy
+        void destroy()
+        {
+            m_thread.interrupt();
+            try
+            {
+                m_thread.join();
+            }
+            catch (InterruptedException e)
+            {
+            }
+        }
+    }
+}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/AspectTest.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/AspectTest.java
deleted file mode 100644
index e95cc87..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/AspectTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.dm.test.bundle.annotation.aspect;
-
-import org.apache.felix.dm.annotation.api.Component;
-import org.apache.felix.dm.annotation.api.ServiceDependency;
-
-@Component
-public class AspectTest
-{
-    @ServiceDependency
-    void bind(ServiceInterface service)
-    {
-        service.run();
-    }
-
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/ServiceInterface.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/ServiceInterface.java
deleted file mode 100644
index f7f8b76..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/ServiceInterface.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.dm.test.bundle.annotation.aspect;
-
-public interface ServiceInterface
-{
-    public void run();
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/ServiceProvider.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/ServiceProvider.java
deleted file mode 100644
index e05ea1f..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/ServiceProvider.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.dm.test.bundle.annotation.aspect;
-
-import org.apache.felix.dm.annotation.api.Component;
-import org.apache.felix.dm.annotation.api.ServiceDependency;
-import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
-
-@Component
-public class ServiceProvider implements ServiceInterface
-{
-    @ServiceDependency(filter = "(test=aspect.ServiceProvider)")
-    protected Sequencer m_sequencer;
-
-    public void run()
-    {
-        m_sequencer.step(1);
-    }
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/ServiceProviderAspect.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/ServiceProviderAspect.java
deleted file mode 100644
index 1ed28b3..0000000
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/aspect/ServiceProviderAspect.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.dm.test.bundle.annotation.aspect;
-
-import org.apache.felix.dm.annotation.api.AspectService;
-import org.apache.felix.dm.annotation.api.ServiceDependency;
-import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
-
-@AspectService(ranking = 10)
-public class ServiceProviderAspect implements ServiceInterface
-{
-    @ServiceDependency(filter = "(test=aspect.ServiceProviderAspect)")
-    protected Sequencer m_sequencer;
-
-    public void run()
-    {
-        m_sequencer.step(2);
-    }
-}
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/Composite.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/Composite.java
index 62f4244..3366735 100644
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/Composite.java
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/Composite.java
@@ -19,11 +19,11 @@
 public class Composite
 {
     // Injected dependency (from CompositeService)
-    private Sequencer m_sequencer;
+    private volatile Sequencer m_sequencer;
 
     // Injected dependency (from CompositeService)
-    Runnable m_runnable;
-
+    public volatile Runnable m_runnable;
+    
     // lifecycle callback (same method as the one from CompositeService)
     void init()
     {
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/CompositeService.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/CompositeService.java
index 2c66ad4..418ee4d 100644
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/CompositeService.java
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/CompositeService.java
@@ -34,11 +34,11 @@
 
     /* This dependency filter will be configured from our init method */
     @ServiceDependency(name = "D")
-    private Runnable m_runnable;
-
+    public volatile Runnable m_runnable;
+    
     /* Object used to check that methods are called in the proper sequence */
-    @ServiceDependency
-    private Sequencer m_sequencer;
+    @ServiceDependency(filter="(name=CompositeService)")
+    private volatile Sequencer m_sequencer;
 
     /**
      *  Dynamically configure our "D" dependency, using a dependency customization map 
@@ -48,12 +48,9 @@
     {
         m_sequencer.step(1);
         // Configure a filter for our dependency whose name is "D"
-        Map<String, String> customization = new HashMap<String, String>()
-        {
-            {
-                put("D.filter", "(foo=bar2)");
-            }
-        };
+        Map<String, String> customization = new HashMap<String, String>();
+        customization.put("D.filter", "(foo=bar2)");
+        customization.put("D.required", "true");
         return customization;
     }
 
@@ -72,6 +69,7 @@
     @Start
     void start()
     {
+        System.out.println("start: m_runnable=" + m_runnable);
         m_sequencer.step(3);
         m_runnable.run(); /* step 4 */
         // Our Component.start() method should be called once this method returns.
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/Dependency1.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/Dependency1.java
index 6656bf1..8f0d569 100644
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/Dependency1.java
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/Dependency1.java
@@ -14,14 +14,21 @@
 import org.apache.felix.dm.annotation.api.Component;
 import org.apache.felix.dm.annotation.api.Property;
 import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
 import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
 
 @Component(properties = @Property(name = "foo", value = "bar1"))
 public class Dependency1 implements Runnable
 {
-    @ServiceDependency
+    @ServiceDependency(filter="(name=Dependency1)")
     Sequencer m_sequencer;
 
+    @Start
+    void start()
+    {
+        System.out.println("Dependency1.start");
+    }
+    
     public void run()
     {
         m_sequencer.step(Integer.MAX_VALUE); // Makes the test fail.
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/Dependency2.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/Dependency2.java
index f1ffb6b..1f6bb56 100644
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/Dependency2.java
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/composite/Dependency2.java
@@ -14,14 +14,21 @@
 import org.apache.felix.dm.annotation.api.Component;
 import org.apache.felix.dm.annotation.api.Property;
 import org.apache.felix.dm.annotation.api.ServiceDependency;
+import org.apache.felix.dm.annotation.api.Start;
 import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
 
 @Component(properties = @Property(name = "foo", value = "bar2"))
 public class Dependency2 implements Runnable
 {
-    @ServiceDependency
+    @ServiceDependency(filter="(name=Dependency2)")
     Sequencer m_sequencer;
 
+    @Start
+    void start()
+    {
+        System.out.println("Dependency2.start");
+    }
+
     public void run()
     {
         m_sequencer.step();
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/factory/MyService.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/factory/MyService.java
index 3c80adc..b5604a6 100644
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/factory/MyService.java
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/factory/MyService.java
@@ -36,7 +36,8 @@
  * This service will be instantiated by our MyServiceFactory class.
  */
 @Component(factorySet = "MyServiceFactory", 
-         factoryConfigure = "configure", properties = { @Property(name = "foo", value = "bar") })
+           factoryConfigure = "configure",
+           properties = { @Property(name = "foo", value = "bar") })
 public class MyService implements MyServiceInterface
 {
     /**
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/propagate/ServiceDependencyPropagateTest.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/propagate/ServiceDependencyPropagateTest.java
index bce8cc1..1c53353 100644
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/propagate/ServiceDependencyPropagateTest.java
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/propagate/ServiceDependencyPropagateTest.java
@@ -40,7 +40,7 @@
             m_producerProps = props;
         }
         
-        @ServiceDependency(filter="(test=ServiceDependencyPropagateTest)")
+        @ServiceDependency(filter="(name=ServiceDependencyPropagateTest)")
         Sequencer m_sequencer;
         
         @Start
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/AdapterServiceTestWithPublisher.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/AdapterServiceTestWithPublisher.java
index 3b5007d..fd42251 100644
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/AdapterServiceTestWithPublisher.java
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/AdapterServiceTestWithPublisher.java
@@ -46,7 +46,7 @@
     @Component
     public static class Consumer
     {
-        @ServiceDependency(filter="(test=AdapterServiceTestWithPublisher)")
+        @ServiceDependency(filter="(name=AdapterServiceTestWithPublisher)")
         Sequencer m_sequencer;
         
         @ServiceDependency(required=false, removed = "unbind")
@@ -103,7 +103,7 @@
         @LifecycleController(start=false)
         Runnable m_unpublisher; // injected and used to unregister our service
         
-        @ServiceDependency(filter="(test=AdapterServiceTestWithPublisher)")
+        @ServiceDependency(filter="(name=AdapterServiceTestWithPublisher)")
         Sequencer m_sequencer;
 
         @Init
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/BundleAdapterServiceTestWithPublisher.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/BundleAdapterServiceTestWithPublisher.java
index cc3acc1..e92b4f5 100644
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/BundleAdapterServiceTestWithPublisher.java
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/BundleAdapterServiceTestWithPublisher.java
@@ -43,7 +43,7 @@
     @Component
     public static class Consumer
     {
-        @ServiceDependency(filter="(test=BundleAdapterServiceTestWithPublisher)")
+        @ServiceDependency(filter="(name=BundleAdapterServiceTestWithPublisher)")
         Sequencer m_sequencer;
         
         @ServiceDependency(required=false, removed = "unbind")
@@ -88,7 +88,7 @@
         @LifecycleController(start=false)
         Runnable m_unpublisher; // injected and used to unregister our service
         
-        @ServiceDependency(filter="(test=BundleAdapterServiceTestWithPublisher)")
+        @ServiceDependency(filter="(name=BundleAdapterServiceTestWithPublisher)")
         Sequencer m_sequencer;
 
         @Init
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/FactoryConfigurationAdapterServiceTestWithPublisher.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/FactoryConfigurationAdapterServiceTestWithPublisher.java
index 57150d4..9cff105 100644
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/FactoryConfigurationAdapterServiceTestWithPublisher.java
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/FactoryConfigurationAdapterServiceTestWithPublisher.java
@@ -47,7 +47,7 @@
     @Component
     public static class Consumer
     {
-        @ServiceDependency(filter="(test=FactoryConfigurationAdapterServiceTestWithPublisher)")
+        @ServiceDependency(filter="(name=FactoryConfigurationAdapterServiceTestWithPublisher)")
         Sequencer m_sequencer;
         
         @ServiceDependency(required=false, removed = "unbind")
@@ -97,7 +97,7 @@
         @LifecycleController(start=false)
         Runnable m_unpublisher; // injected and used to unregister our service
         
-        @ServiceDependency(filter="(test=FactoryConfigurationAdapterServiceTestWithPublisher)")
+        @ServiceDependency(filter="(name=FactoryConfigurationAdapterServiceTestWithPublisher)")
         Sequencer m_sequencer;
 
         void updated(Dictionary conf) {
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/FactoryServiceTestWthPublisher.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/FactoryServiceTestWthPublisher.java
index d361d04..c63c5e2 100644
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/FactoryServiceTestWthPublisher.java
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/FactoryServiceTestWthPublisher.java
@@ -45,7 +45,7 @@
     @Component
     public static class Consumer
     {
-        @ServiceDependency(filter="(test=FactoryServiceTestWthPublisher)")
+        @ServiceDependency(filter="(name=FactoryServiceTestWthPublisher)")
         Sequencer m_sequencer;
         
         @ServiceDependency(required=false, removed = "unbind")
@@ -81,7 +81,7 @@
         @LifecycleController(start=false)
         Runnable m_unpublisher; // injected and used to unregister our service
         
-        @ServiceDependency(filter="(test=FactoryServiceTestWthPublisher)")
+        @ServiceDependency(filter="(name=FactoryServiceTestWthPublisher)")
         Sequencer m_sequencer;
         
         @Init
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/ResourceAdapterServiceTestWithPublisher.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/ResourceAdapterServiceTestWithPublisher.java
index d232282..f7982f5 100644
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/ResourceAdapterServiceTestWithPublisher.java
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/ResourceAdapterServiceTestWithPublisher.java
@@ -52,7 +52,7 @@
     @Component
     public static class Consumer
     {
-        @ServiceDependency(filter="(test=ResourceAdapterServiceTestWithPublisher)")
+        @ServiceDependency(filter="(name=ResourceAdapterServiceTestWithPublisher)")
         Sequencer m_sequencer;
         
         @ServiceDependency(required=false, removed = "unbind")
@@ -190,7 +190,7 @@
         @LifecycleController(start=false)
         Runnable m_unpublisher; // injected and used to unregister our service
         
-        @ServiceDependency(filter="(test=ResourceAdapterServiceTestWithPublisher)")
+        @ServiceDependency(filter="(name=ResourceAdapterServiceTestWithPublisher)")
         Sequencer m_sequencer;
   
         // Injected by reflection
diff --git a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/ServiceTestWthPublisher.java b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/ServiceTestWthPublisher.java
index 2665a60..bfdddb4 100644
--- a/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/ServiceTestWthPublisher.java
+++ b/dependencymanager/test/src/main/java/org/apache/felix/dm/test/bundle/annotation/publisher/ServiceTestWthPublisher.java
@@ -41,7 +41,7 @@
     @Component
     public static class Consumer
     {
-        @ServiceDependency(filter="(test=ServiceTestWthPublisher)")
+        @ServiceDependency(filter="(name=ServiceTestWthPublisher)")
         Sequencer m_sequencer;
         
         @ServiceDependency(required=false, removed = "unbind")
@@ -73,7 +73,7 @@
         @LifecycleController(start=false)
         Runnable m_unpublisher; // injected and used to unregister our service
         
-        @ServiceDependency(filter="(test=ServiceTestWthPublisher)")
+        @ServiceDependency(filter="(name=ServiceTestWthPublisher)")
         Sequencer m_sequencer;
 
         @Init
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/Base.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/Base.java
index 8e4340e..102634a 100644
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/Base.java
+++ b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/Base.java
@@ -34,6 +34,8 @@
  */
 public class Base implements LogService
 {
+    private final static int LOG_LEVEL=LogService.LOG_WARNING;
+    
     /**
      * Register us as a LogService
      * @param context
@@ -83,33 +85,41 @@
 
     public void log(int level, String message)
     {
-        System.out.println(getLevel(level) + " " + message);
+        if (LOG_LEVEL >= level) {
+            System.out.println(getLevel(level) + " " + message);
+        }
     }
 
     public void log(int level, String message, Throwable exception)
     {
-        StringBuilder sb = new StringBuilder();
-        sb.append(getLevel(level) + " ");
-        sb.append(message);
-        parse(sb, exception);
-        System.out.println(sb.toString());
+        if (LOG_LEVEL >= level) {
+            StringBuilder sb = new StringBuilder();
+            sb.append(getLevel(level) + " ");
+            sb.append(message);
+            parse(sb, exception);
+            System.out.println(sb.toString());
+        }
     }
 
     public void log(ServiceReference sr, int level, String message)
     {
-        StringBuilder sb = new StringBuilder();
-        sb.append(getLevel(level) + " ");
-        sb.append(message);
-        System.out.println(sb.toString());
+        if (LOG_LEVEL >= level) {
+            StringBuilder sb = new StringBuilder();
+            sb.append(getLevel(level) + " ");
+            sb.append(message);
+            System.out.println(sb.toString());
+        }
     }
 
     public void log(ServiceReference sr, int level, String message, Throwable exception)
     {
-        StringBuilder sb = new StringBuilder();
-        sb.append(getLevel(level) + " ");
-        sb.append(message);
-        parse(sb, exception);
-        System.out.println(sb.toString());
+        if (LOG_LEVEL >= level) {
+            StringBuilder sb = new StringBuilder();
+            sb.append(getLevel(level) + " ");
+            sb.append(message);
+            parse(sb, exception);
+            System.out.println(sb.toString());
+        }
     }
 
     private void parse(StringBuilder sb, Throwable t)
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AdapterAnnotationTest.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AdapterAnnotationTest.java
index 67677d7..46dd846 100644
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AdapterAnnotationTest.java
+++ b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AdapterAnnotationTest.java
@@ -23,9 +23,9 @@
 import static org.ops4j.pax.exam.CoreOptions.provision;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
+import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
 import org.apache.felix.dm.test.BundleGenerator;
-import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Option;
@@ -59,12 +59,42 @@
                     .build()));           
     }
 
+    /**
+     * Check if an adapter gets injected with its adaptee using default auto config mode.
+     */
     @Test
-    public void testAnnotatedAdapter(BundleContext context)
+    public void testAnnotatedAdapterAutoConfig(BundleContext context)
     {
         DependencyManager m = new DependencyManager(context);
-        // Provide the Sequencer to the adapeter bundle service (see main/src/.../adapter/*.java). 
-        m.add(m.createComponent().setImplementation(this).setInterface(Sequencer.class.getName(), null));
-        m_ensure.waitForStep(4, 10000);
+        // Provide the Sequencer to the org.apache.felix.dm.test.bundle.annotation.adapter.AdapterTest bundle 
+        m.add(makeSequencer(m, "AdapterAutoConfig"));
+        m_ensure.waitForStep(3, 10000);
+    }
+    
+    /**
+     * Check if an adapter gets injected with its adaptee in a named class field.
+     */
+    @Test
+    public void testAnnotatedAdapterAutoConfigField(BundleContext context)
+    {
+        DependencyManager m = new DependencyManager(context);
+        // Provide the Sequencer to the org.apache.felix.dm.test.bundle.annotation.adapter.AdapterTest bundle 
+        m.add(makeSequencer(m, "AdapterAutoConfigField"));
+        m_ensure.waitForStep(3, 10000);
+    }
+    
+    /**
+     * Check if an adapter gets injected with its adaptee in a callback method.
+     */
+    @Test
+    public void testAnnotatedAdapterCallback(BundleContext context)
+    {
+        DependencyManager m = new DependencyManager(context);
+        // Provide the Sequencer to the org.apache.felix.dm.test.bundle.annotation.adapter.AdapterTest bundle 
+        Component sequencer = makeSequencer(m, "AdapterCallback");
+        m.add(sequencer);
+        m_ensure.waitForStep(3, 10000);
+        m.remove(sequencer);
+        m_ensure.waitForStep(5, 10000);        
     }
 }
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AnnotationBase.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AnnotationBase.java
index 7293166..48f133b 100644
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AnnotationBase.java
+++ b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AnnotationBase.java
@@ -20,6 +20,7 @@
 
 import java.util.Hashtable;
 
+import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
 import org.apache.felix.dm.test.Base;
 import org.apache.felix.dm.test.Ensure;
@@ -78,15 +79,13 @@
     }
 
     /**
-     * Registers the Sequencer interface, for activating a given testcase
+     * Provide a Sequencer with a name service property.
      */
-    protected void registerSequencer(DependencyManager m, final String testName) 
+    protected Component makeSequencer(DependencyManager m, String name)
     {
-        m.add(m.createComponent()
-              .setImplementation(this)
-              .setInterface(Sequencer.class.getName(),new Hashtable() {{
-                  put("test", testName);
-              }}));
+        Hashtable props = new Hashtable();
+        props.put("name", name);
+        return m.createComponent().setImplementation(this).setInterface(Sequencer.class.getName(), props);
     }
     
     // ----------------------- Sequencer interface ------------------------------------------
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AspectAnnotationTest.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AspectAnnotationTest.java
index 6c389aa..854528b 100644
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AspectAnnotationTest.java
+++ b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/AspectAnnotationTest.java
@@ -23,12 +23,9 @@
 import static org.ops4j.pax.exam.CoreOptions.provision;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
-import java.util.Dictionary;
-import java.util.Hashtable;
-
+import org.apache.felix.dm.Component;
 import org.apache.felix.dm.DependencyManager;
 import org.apache.felix.dm.test.BundleGenerator;
-import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Option;
@@ -63,18 +60,31 @@
     }
 
     @Test
-    public void testAnnotatedAspect(BundleContext context)
+    public void testAspectChain(BundleContext context)
     {
         DependencyManager m = new DependencyManager(context);
-        // Provide the Sequencer to the "ServiceProvider" service (see main/src/.../AspectTest.java). 
-        Dictionary props = new Hashtable() {{ put("test", "aspect.ServiceProvider"); }};
-        m.add(m.createComponent().setImplementation(this).setInterface(Sequencer.class.getName(), props));
-        // Check if the ServiceProvider has been injected in the AspectTest service.
-        m_ensure.waitForStep(1, 10000);
-        // Provide the Sequencer for activating the ServiceProviderAspect service
-        props = new Hashtable() {{ put("test", "aspect.ServiceProviderAspect"); }};
-        m.add(m.createComponent().setImplementation(this).setInterface(Sequencer.class.getName(), props));
-        // And check if the AspectTest has been injected with the aspect
-        m_ensure.waitForStep(2, 10000);
-    }
+        // Activate service consumer
+        Component scSequencer = makeSequencer(m, "AspectChainTest.ServiceConsumer");
+        m.add(scSequencer);
+        // Activate service provider
+        Component spSequencer = makeSequencer(m, "AspectChainTest.ServiceProvider");
+        m.add(spSequencer);
+        // Activate service aspect 2
+        Component sa2Sequencer = makeSequencer(m, "AspectChainTest.ServiceAspect2");
+        m.add(sa2Sequencer);
+        // Activate service aspect 3
+        Component sa3Sequencer = makeSequencer(m, "AspectChainTest.ServiceAspect3");
+        m.add(sa3Sequencer);
+        // Activate service aspect 1
+        Component sa1Sequencer = makeSequencer(m, "AspectChainTest.ServiceAspect1");
+        m.add(sa1Sequencer);
+
+        m_ensure.step();
+        m_ensure.waitForStep(7, 10000);
+
+        // Deactivate service provider
+        m.remove(spSequencer);
+        // Make sure that service aspect 1 has been called in ts removed and stop callbacks 
+        m_ensure.waitForStep(9, 10000);
+    }    
 }
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/CompositeAnnotationsTest.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/CompositeAnnotationsTest.java
index 157cf1d..830fd62 100644
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/CompositeAnnotationsTest.java
+++ b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/CompositeAnnotationsTest.java
@@ -25,7 +25,6 @@
 
 import org.apache.felix.dm.DependencyManager;
 import org.apache.felix.dm.test.BundleGenerator;
-import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Option;
@@ -55,7 +54,7 @@
                     .set("Export-Package", "org.apache.felix.dm.test.bundle.annotation.sequencer")
                     .set("Private-Package", "org.apache.felix.dm.test.bundle.annotation.composite")
                     .set("Import-Package", "*")
-                    .set("-plugin", "org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin")
+                    .set("-plugin", "org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=warn")
                     .build()));            
     }
 
@@ -64,7 +63,9 @@
     {
         DependencyManager m = new DependencyManager(context);
         // Provide the Sequencer service to the "Component" service.
-        m.add(m.createComponent() .setImplementation(this).setInterface(Sequencer.class.getName(), null));
+        m.add(makeSequencer(m, "CompositeService"));
+        m.add(makeSequencer(m, "Dependency1"));
+        m.add(makeSequencer(m, "Dependency2"));
         // Check if the components have been initialized orderly
         m_ensure.waitForStep(4, 10000);
         // Stop the bundle
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/PropagateAnnotationTest.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/PropagateAnnotationTest.java
index ee52219..f64782e 100644
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/PropagateAnnotationTest.java
+++ b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/PropagateAnnotationTest.java
@@ -66,7 +66,7 @@
     public void testServiceDependencyPropagate(BundleContext context)
     {
         DependencyManager m = new DependencyManager(context);
-        registerSequencer(m, "ServiceDependencyPropagateTest"); 
+        m.add(makeSequencer(m, "ServiceDependencyPropagateTest")); 
         m_ensure.waitForStep(3, 10000);
     }    
 }
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/PublisherAnnotationTest.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/PublisherAnnotationTest.java
index c722074..a5b530c 100644
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/PublisherAnnotationTest.java
+++ b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/annotation/PublisherAnnotationTest.java
@@ -23,11 +23,8 @@
 import static org.ops4j.pax.exam.CoreOptions.provision;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
-import java.util.Hashtable;
-
 import org.apache.felix.dm.DependencyManager;
 import org.apache.felix.dm.test.BundleGenerator;
-import org.apache.felix.dm.test.bundle.annotation.sequencer.Sequencer;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Option;
@@ -69,7 +66,7 @@
     public void testServiceWithPublisher(BundleContext context)
     {
         DependencyManager m = new DependencyManager(context);
-        registerSequencer(m, "ServiceTestWthPublisher"); 
+        m.add(makeSequencer(m, "ServiceTestWthPublisher")); 
         m_ensure.waitForStep(4, 10000);
     }
     
@@ -81,7 +78,7 @@
     public void testFactoryServiceWithPublisher(BundleContext context)
     {
         DependencyManager m = new DependencyManager(context);
-        registerSequencer(m, "FactoryServiceTestWthPublisher"); 
+        m.add(makeSequencer(m, "FactoryServiceTestWthPublisher")); 
         m_ensure.waitForStep(5, 10000);
     }
 
@@ -92,7 +89,7 @@
     public void testAdapterServiceWithPublisher(BundleContext context)
     {
         DependencyManager m = new DependencyManager(context);
-        registerSequencer(m, "AdapterServiceTestWithPublisher"); 
+        m.add(makeSequencer(m, "AdapterServiceTestWithPublisher")); 
         m_ensure.waitForStep(6, 10000);
     }
 
@@ -103,7 +100,7 @@
     public void testBundleAdapterServiceWithPublisher(BundleContext context)
     {
         DependencyManager m = new DependencyManager(context);
-        registerSequencer(m, "BundleAdapterServiceTestWithPublisher"); 
+        m.add(makeSequencer(m, "BundleAdapterServiceTestWithPublisher")); 
         m_ensure.waitForStep(5, 10000);
     }
 
@@ -114,7 +111,7 @@
     public void TestResourceAdapterServiceWithPublisher(BundleContext context)
     {
         DependencyManager m = new DependencyManager(context);
-        registerSequencer(m, "ResourceAdapterServiceTestWithPublisher"); 
+        m.add(makeSequencer(m, "ResourceAdapterServiceTestWithPublisher")); 
         m_ensure.waitForStep(5, 10000);
     }
 
@@ -125,7 +122,7 @@
     public void testFactoryAdapterServiceWithPublisher(BundleContext context)
     {
         DependencyManager m = new DependencyManager(context);
-        registerSequencer(m, "FactoryConfigurationAdapterServiceTestWithPublisher"); 
+        m.add(makeSequencer(m, "FactoryConfigurationAdapterServiceTestWithPublisher")); 
         m_ensure.waitForStep(5, 10000);
     }
 }