added compatibility bundle for old dm version 2.x.x

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@887355 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/compat/LICENSE b/dependencymanager/compat/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/dependencymanager/compat/LICENSE
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
diff --git a/dependencymanager/compat/NOTICE b/dependencymanager/compat/NOTICE
new file mode 100644
index 0000000..cfc3633
--- /dev/null
+++ b/dependencymanager/compat/NOTICE
@@ -0,0 +1,26 @@
+Apache Felix Dependency Manager
+Copyright 2009 The Apache Software Foundation
+
+
+I. Included Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+This product includes software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright (c) OSGi Alliance (2000, 2007).
+Licensed under the Apache License 2.0.
+
+
+II. Used Software
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright (c) OSGi Alliance (2000, 2007).
+Licensed under the Apache License 2.0.
+
+
+III. License Summary
+- Apache License 2.0
diff --git a/dependencymanager/compat/pom.xml b/dependencymanager/compat/pom.xml
new file mode 100644
index 0000000..0b724bc
--- /dev/null
+++ b/dependencymanager/compat/pom.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+    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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.apache.felix</groupId>
+    <artifactId>felix</artifactId>
+    <version>1.0.4</version>
+    <relativePath>../../pom/pom.xml</relativePath>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <packaging>bundle</packaging>
+  <name>Apache Felix Dependency Manager Compatibility</name>
+  <version>3.0.0-SNAPSHOT</version>
+  <artifactId>org.apache.felix.dependencymanager.compat</artifactId>
+  <dependencies>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <version>4.2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.compendium</artifactId>
+      <version>4.2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>${pom.groupId}</groupId>
+      <artifactId>org.apache.felix.dependencymanager</artifactId>
+      <version>3.0.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <version>1.4.0</version>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Bundle-SymbolicName>org.apache.felix.dependencymanager.compat</Bundle-SymbolicName>
+            <Bundle-Name>Apache Felix Dependency Manager Compatibility</Bundle-Name>
+            <Bundle-Description>A bundle that provides compatibility with old 2.x.x dependencymanager.</Bundle-Description>
+            <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
+            <Export-Package>org.apache.felix.dependencymanager</Export-Package>
+            <Import-Package>!org.apache.felix.dependencymanager,*</Import-Package>
+	    <Private-Package>org.apache.felix.dependencymanager.impl</Private-Package>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <scm>
+    <connection>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.dependencymanager-3.0.0</connection>
+    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.dependencymanager-3.0.0</developerConnection>
+    <url>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.dependencymanager-3.0.0</url>
+  </scm>
+</project>
diff --git a/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/ConfigurationDependency.java b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/ConfigurationDependency.java
new file mode 100644
index 0000000..c6af857
--- /dev/null
+++ b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/ConfigurationDependency.java
@@ -0,0 +1,77 @@
+/*
+ * 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.dependencymanager;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Dictionary;
+import java.util.Properties;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+
+/**
+ * Configuration dependency that can track the availability of a (valid) configuration.
+ * To use it, specify a PID for the configuration. The dependency is always required,
+ * because if it is not, it does not make sense to use the dependency manager. In that
+ * scenario, simply register your service as a <code>ManagedService(Factory)</code> and
+ * handle everything yourself. Also, only managed services are supported, not factories.
+ * There are a couple of things you need to be aware of when implementing the
+ * <code>updated(Dictionary)</code> method:
+ * <ul>
+ * <li>Make sure it throws a <code>ConfigurationException</code> when you get a
+ * configuration that is invalid. In this case, the dependency will not change:
+ * if it was not available, it will still not be. If it was available, it will
+ * remain available and implicitly assume you keep working with your old
+ * configuration.</li>
+ * <li>This method will be called before all required dependencies are available.
+ * Make sure you do not depend on these to parse your settings.</li>
+ * </ul>
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public abstract class ConfigurationDependency implements Dependency {
+    /**
+     * Sets a callback which will be invoked when the configuration is available.
+     * The method may take in parameter a Dictionary and may also throw a 
+     * ConfigurationException.
+     * @param callback the callback to invoke when the configuration is available
+     * @return this dependency.
+     */
+	public abstract ConfigurationDependency setCallback(String callback);
+
+	/**
+	 * Sets the <code>service.pid</code> of the configuration you
+	 * are depending on.
+	 */
+	public abstract ConfigurationDependency setPid(String pid);
+
+	/**
+	 * Sets propagation of the configuration properties to the service
+	 * properties. Any additional service properties specified directly
+	 * are merged with these.
+	 */
+	public abstract ConfigurationDependency setPropagate(boolean propagate);
+
+	public abstract boolean isAvailable();
+
+	public abstract boolean isRequired();
+}
diff --git a/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/Dependency.java b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/Dependency.java
new file mode 100644
index 0000000..7970a12
--- /dev/null
+++ b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/Dependency.java
@@ -0,0 +1,50 @@
+/*
+ * 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.dependencymanager;
+
+/**
+ * Generic dependency for a service. A dependency can be required or not.
+ * A dependency will be activated by the service it belongs to. The service
+ * will call the <code>start(Service service)</code> and 
+ * <code>stop(Service service)</code> methods.
+ * 
+ * After it has been started, a dependency must callback
+ * the associated service's <code>dependencyAvailable()</code> and 
+ * <code>dependencyUnavailable()</code>
+ * methods. State changes of the dependency itself may only be made as long as
+ * the dependency is not 'active', meaning it is associated with a running service.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public interface Dependency {
+    /**
+     * Returns <code>true</code> if this a required dependency. Required dependencies
+     * are dependencies that must be available before the service can be activated.
+     * 
+     * @return <code>true</code> if the dependency is required
+     */
+    public boolean isRequired();
+    
+    /**
+     * Returns <code>true</code> if the dependency is available.
+     * 
+     * @return <code>true</code> if the dependency is available
+     */
+    public boolean isAvailable();
+}
diff --git a/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/DependencyActivatorBase.java b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/DependencyActivatorBase.java
new file mode 100644
index 0000000..ce64c15
--- /dev/null
+++ b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/DependencyActivatorBase.java
@@ -0,0 +1,115 @@
+/*
+ * 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.dependencymanager;
+
+import java.util.List;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Base bundle activator class. Subclass this activator if you want to use dependency
+ * management in your bundle. There are two methods you should implement:
+ * <code>init()</code> and <code>destroy()</code>. Both methods take two arguments,
+ * the bundle context and the dependency manager. The dependency manager can be used
+ * to define all the dependencies.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public abstract class DependencyActivatorBase implements BundleActivator {
+    private BundleContext m_context;
+    private DependencyManager m_manager;
+    
+    /**
+     * Initialize the dependency manager. Here you can add all services and their dependencies.
+     * If something goes wrong and you do not want your bundle to be started, you can throw an
+     * exception. This exception will be passed on to the <code>start()</code> method of the
+     * bundle activator, causing the bundle not to start.
+     * 
+     * @param context the bundle context
+     * @param manager the dependency manager
+     * @throws Exception if the initialization fails
+     */
+    public abstract void init(BundleContext context, DependencyManager manager) throws Exception;
+    
+    /**
+     * Destroy the dependency manager. Here you can remove all services and their dependencies.
+     * Actually, the base class will clean up your dependencies anyway, so most of the time you
+     * don't need to do anything here.
+     * If something goes wrong and you do not want your bundle to be stopped, you can throw an
+     * exception. This exception will be passed on to the <code>stop()</code> method of the
+     * bundle activator, causing the bundle not to stop.
+     * 
+     * @param context the bundle context
+     * @param manager the dependency manager
+     * @throws Exception if the destruction fails
+     */
+    public abstract void destroy(BundleContext context, DependencyManager manager) throws Exception;
+
+    /**
+     * Start method of the bundle activator. Initializes the dependency manager
+     * and calls <code>init()</code>.
+     * 
+     * @param context the bundle context
+     */
+    public void start(BundleContext context) throws Exception {
+        m_context = context;
+        m_manager = new DependencyManager(context);
+        init(m_context, m_manager);
+    }
+
+    /**
+     * Stop method of the bundle activator. Calls the <code>destroy()</code> method
+     * and cleans up all left over dependencies.
+     * 
+     * @param context the bundle context
+     */
+    public void stop(BundleContext context) throws Exception {
+        destroy(m_context, m_manager);
+        m_manager = null;
+        m_context = null;
+    }
+    
+    /**
+     * Creates a new service.
+     * 
+     * @return the new service
+     */
+    public Service createService() {
+        return new org.apache.felix.dependencymanager.impl.ServiceImpl(m_manager);
+    }
+    
+    /**
+     * Creates a new service dependency.
+     * 
+     * @return the service dependency
+     */
+    public ServiceDependency createServiceDependency() {
+        return new org.apache.felix.dependencymanager.impl.ServiceDependencyImpl(m_manager);
+    }
+        
+    /**
+     * Creates a new configuration dependency.
+     * 
+     * @return the configuration dependency
+     */
+    public ConfigurationDependency createConfigurationDependency() {
+    	return new org.apache.felix.dependencymanager.impl.ConfigurationDependencyImpl(m_manager);
+    }
+}
diff --git a/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/DependencyManager.java b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/DependencyManager.java
new file mode 100644
index 0000000..b61497e
--- /dev/null
+++ b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/DependencyManager.java
@@ -0,0 +1,114 @@
+/*
+ * 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.dependencymanager;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.osgi.framework.BundleContext;
+
+/**
+ * The dependency manager. Manages all services and their dependencies.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class DependencyManager
+{
+    private org.apache.felix.dm.DependencyManager m_delegate;
+    private List m_services = Collections.synchronizedList(new ArrayList());
+
+    /**
+     * Creates a new dependency manager.
+     * 
+     * @param context the bundle context
+     * @param logger 
+     */
+    public DependencyManager(BundleContext context)
+    {
+        m_delegate = new org.apache.felix.dm.DependencyManager(context);
+    }
+
+    /**
+     * Adds a new service to the dependency manager. After the service was added
+     * it will be started immediately.
+     * 
+     * @param service the service to add
+     */
+    public void add(Service service)
+    {
+        m_services.add(service);
+        service.start();
+    }
+
+    /**
+     * Removes a service from the dependency manager. Before the service is removed
+     * it is stopped first.
+     * 
+     * @param service the service to remove
+     */
+    public void remove(Service service)
+    {
+        service.stop();
+        m_services.remove(service);
+    }
+
+    /**
+     * Creates a new service.
+     * 
+     * @return the new service
+     */
+    public Service createService()
+    {
+        return new org.apache.felix.dependencymanager.impl.ServiceImpl(this);
+    }
+
+    /**
+     * Creates a new service dependency.
+     * 
+     * @return the service dependency
+     */
+    public ServiceDependency createServiceDependency()
+    {
+        return new org.apache.felix.dependencymanager.impl.ServiceDependencyImpl(this);
+    }
+
+    public ConfigurationDependency createConfigurationDependency()
+    {
+        return new org.apache.felix.dependencymanager.impl.ConfigurationDependencyImpl(this);
+    }
+
+    /**
+     * Returns a list of services.
+     * 
+     * @return a list of services
+     */
+    public List getServices()
+    {
+        return Collections.unmodifiableList(m_services);
+    }
+
+    /**
+     * Returns the dependency manager delegate (only used by backward compatibility impl)
+     */
+    public Object getDelegate()
+    {
+        return m_delegate;
+    }
+}
diff --git a/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/Service.java b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/Service.java
new file mode 100644
index 0000000..e8893f1
--- /dev/null
+++ b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/Service.java
@@ -0,0 +1,227 @@
+/*
+ * 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.dependencymanager;
+
+import java.util.Dictionary;
+import java.util.List;
+
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * Service interface.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public interface Service {
+    /**
+     * Adds a new dependency to this service.
+     * 
+     * @param dependency the dependency to add
+     * @return this service
+     */
+    public Service add(Dependency dependency);
+    
+    /**
+     * Removes a dependency from this service.
+     * 
+     * @param dependency the dependency to remove
+     * @return this service
+     */
+    public Service remove(Dependency dependency);
+
+    /**
+     * Sets the public interface under which this service should be registered
+     * in the OSGi service registry.
+     *  
+     * @param serviceName the name of the service interface
+     * @param properties the properties for this service
+     * @return this service
+     */
+    public Service setInterface(String serviceName, Dictionary properties);
+    
+    /**
+     * Sets the public interfaces under which this service should be registered
+     * in the OSGi service registry.
+     *  
+     * @param serviceNames the names of the service interface
+     * @param properties the properties for this service
+     * @return this service
+     */
+    public Service setInterface(String[] serviceNames, Dictionary properties);
+    
+    /**
+     * Sets the implementation for this service. You can actually specify
+     * an instance you have instantiated manually, or a <code>Class</code>
+     * that will be instantiated using its default constructor when the
+     * required dependencies are resolved (effectively giving you a lazy
+     * instantiation mechanism).
+     * 
+     * There are four special methods that are called when found through
+     * reflection to give you some life-cycle management options:
+     * <ol>
+     * <li><code>init()</code> is invoked right after the instance has been
+     * created, and before any dependencies are resolved, and can be used to
+     * initialize the internal state of the instance</li>
+     * <li><code>start()</code> is invoked after the required dependencies
+     * are resolved and injected, and before the service is registered</li>
+     * <li><code>stop()</code> is invoked right after the service is
+     * unregistered</li>
+     * <li><code>destroy()</code> is invoked after all dependencies are
+     * removed</li>
+     * </ol>
+     * In short, this allows you to initialize your instance before it is
+     * registered, perform some post-initialization and pre-destruction code
+     * as well as final cleanup. If a method is not defined, it simply is not
+     * called, so you can decide which one(s) you need. If you need even more
+     * fine-grained control, you can register as a service state listener too.
+     * 
+     * @param implementation the implementation
+     * @return this service
+     * @see ServiceStateListener
+     */
+    public Service setImplementation(Object implementation);
+    
+    /**
+     * Returns a list of dependencies.
+     * 
+     * @return a list of dependencies
+     */
+    public List getDependencies();
+    
+    /**
+     * Returns the service registration for this service. The method
+     * will return <code>null</code> if no service registration is
+     * available.
+     * 
+     * @return the service registration
+     */
+    public ServiceRegistration getServiceRegistration();
+    
+    /**
+     * Returns the service instance for this service. The method will
+     * return <code>null</code> if no service instance is available.
+     * 
+     * @return the service instance
+     */
+    public Object getService();
+
+    /**
+     * Returns the service properties associated with the service.
+     * 
+     * @return the properties or <code>null</code> if there are none
+     */
+    public Dictionary getServiceProperties();
+    
+    /**
+     * Sets the service properties associated with the service. If the service
+     * was already registered, it will be updated.
+     * 
+     * @param serviceProperties the properties
+     */
+    public void setServiceProperties(Dictionary serviceProperties);
+    
+    /**
+     * Sets the names of the methods used as callbacks. These methods, when found, are
+     * invoked as part of the life-cycle management of the service implementation. The
+     * methods should not have any parameters.
+     * 
+     * @param init the name of the init method
+     * @param start the name of the start method
+     * @param stop the name of the stop method
+     * @param destroy the name of the destroy method
+     * @return the service instance
+     */
+    public Service setCallbacks(String init, String start, String stop, String destroy);
+
+    // listener
+    /**
+     * Adds a service state listener to this service.
+     * 
+     * @param listener the state listener
+     */
+    public void addStateListener(ServiceStateListener listener);
+
+    /**
+     * Removes a service state listener from this service.
+     * 
+     * @param listener the state listener
+     */
+    public void removeStateListener(ServiceStateListener listener);
+    
+    /**
+     * Starts the service. This activates the dependency tracking mechanism
+     * for this service.
+     */
+    public void start();
+    
+    /**
+     * Stops the service. This deactivates the dependency tracking mechanism
+     * for this service.
+     */
+    public void stop();
+    
+    /**
+     * Sets the factory to use to create the implementation. You can specify
+     * both the factory class and method to invoke. The method should return
+     * the implementation, and can use any method to create it. Actually, this
+     * can be used together with <code>setComposition</code> to create a
+     * composition of instances that work together to implement a service. The
+     * factory itself can also be instantiated lazily by not specifying an
+     * instance, but a <code>Class</code>.
+     * 
+     * @param factory the factory instance or class
+     * @param createMethod the name of the create method
+     */
+	public Service setFactory(Object factory, String createMethod);
+	
+	/**
+	 * Sets the factory to use to create the implementation. You specify the
+	 * method to invoke. The method should return the implementation, and can
+	 * use any method to create it. Actually, this can be used together with
+	 * <code>setComposition</code> to create a composition of instances that
+	 * work together to implement a service.
+	 * <p>
+	 * Note that currently, there is no default for the factory, so please use
+	 * <code>setFactory(factory, createMethod)</code> instead.
+	 * 
+	 * @param createMethod the name of the create method
+	 */
+	public Service setFactory(String createMethod);
+	
+	/**
+	 * Sets the instance and method to invoke to get back all instances that
+	 * are part of a composition and need dependencies injected. All of them
+	 * will be searched for any of the dependencies. The method that is
+	 * invoked must return an <code>Object[]</code>.
+	 * 
+	 * @param instance the instance that has the method
+	 * @param getMethod the method to invoke
+	 */
+	public Service setComposition(Object instance, String getMethod);
+	
+	/**
+	 * Sets the method to invoke on the service implementation to get back all
+	 * instances that are part of a composition and need dependencies injected.
+	 * All of them will be searched for any of the dependencies. The method that
+	 * is invoked must return an <code>Object[]</code>.
+	 * 
+	 * @param getMethod the method to invoke
+	 */
+	public Service setComposition(String getMethod);
+}
diff --git a/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
new file mode 100644
index 0000000..a3837b9
--- /dev/null
+++ b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
@@ -0,0 +1,173 @@
+/*
+ * 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.dependencymanager;
+
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Service dependency that can track an OSGi service.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public abstract class ServiceDependency implements Dependency
+{
+    /**
+     * Sets the name of the service that should be tracked. 
+     * 
+     * @param serviceName the name of the service
+     * @return this service dependency
+     */
+    public abstract ServiceDependency setService(Class serviceName);
+
+    /**
+     * Sets the name of the service that should be tracked. You can either specify
+     * only the name, or the name and a filter. In the latter case, the filter is used
+     * to track the service and should only return services of the type that was specified
+     * in the name. To make sure of this, the filter is actually extended internally to
+     * filter on the correct name.
+     * 
+     * @param serviceName the name of the service
+     * @param serviceFilter the filter condition
+     * @return this service dependency
+     */
+    public abstract ServiceDependency setService(Class serviceName, String serviceFilter);
+
+    /**
+     * Sets the name of the service that should be tracked. You can either specify
+     * only the name, or the name and a reference. In the latter case, the service reference
+     * is used to track the service and should only return services of the type that was 
+     * specified in the name.
+     * 
+     * @param serviceName the name of the service
+     * @param serviceReference the service reference to track
+     * @return this service dependency
+     */
+    public abstract ServiceDependency setService(Class serviceName,
+        ServiceReference serviceReference);
+
+    /**
+     * Sets the default implementation for this service dependency. You can use this to supply
+     * your own implementation that will be used instead of a Null Object when the dependency is
+     * not available. This is also convenient if the service dependency is not an interface
+     * (which would cause the Null Object creation to fail) but a class.
+     * 
+     * @param implementation the instance to use or the class to instantiate if you want to lazily
+     *     instantiate this implementation
+     * @return this service dependency
+     */
+    public abstract ServiceDependency setDefaultImplementation(Object implementation);
+
+    /**
+     * Sets the required flag which determines if this service is required or not.
+     * 
+     * @param required the required flag
+     * @return this service dependency
+     */
+    public abstract ServiceDependency setRequired(boolean required);
+
+    /**
+     * Sets auto configuration for this service. Auto configuration allows the
+     * dependency to fill in any attributes in the service implementation that
+     * are of the same type as this dependency. Default is on.
+     * 
+     * @param autoConfig the value of auto config
+     * @return this service dependency
+     */
+    public abstract ServiceDependency setAutoConfig(boolean autoConfig);
+
+    /**
+     * Sets auto configuration for this service. Auto configuration allows the
+     * dependency to fill in the attribute in the service implementation that
+     * has the same type and instance name.
+     * 
+     * @param instanceName the name of attribute to auto config
+     * @return this service dependency
+     */
+    public abstract ServiceDependency setAutoConfig(String instanceName);
+
+    /**
+     * Sets the callbacks for this service. These callbacks can be used as hooks whenever a
+     * dependency is added or removed. When you specify callbacks, the default auto configuration 
+     * feature is automatically turned off, because we're assuming you don't need it in this 
+     * case. If you need both features (callbacks + autoconfig), Then, you must explicitly invoke 
+     * setAutoConfig(true) and setCallbacks methods.
+     * 
+     * @param added the method to call when a service was added
+     * @param removed the method to call when a service was removed
+     * @return this service dependency
+     */
+    public ServiceDependency setCallbacks(String added, String removed)
+    {
+        return setCallbacks(null, added, null, removed);
+    }
+
+    /**
+     * Sets the callbacks for this service. These callbacks can be used as hooks whenever a
+     * dependency is added, changed or removed. When you specify callbacks, the default auto 
+     * configuration feature is automatically turned off, because we're assuming you don't 
+     * need it in this case. If you need both features (callbacks + autoconfig),
+     * then, you must explicitly invoke setAutoConfig(true) and setCallbacks methods.
+     * 
+     * @param added the method to call when a service was added
+     * @param changed the method to call when a service was changed
+     * @param removed the method to call when a service was removed
+     * @return this service dependency
+     */
+    public ServiceDependency setCallbacks(String added, String changed, String removed)
+    {
+        return setCallbacks(null, added, changed, removed);
+    }
+
+    /**
+     * Sets the callbacks for this service. These callbacks can be used as hooks whenever a
+     * dependency is added or removed. They are called on the instance you provide. When you
+     * specify callbacks, the default auto configuration feature is automatically turned off, because
+     * we're assuming you don't need it in this case. If you need both features (callbacks + autoconfig),
+     * then, you must explicitly invoke setAutoConfig(true) and setCallbacks methods.
+     * 
+     * @param instance the instance to call the callbacks on
+     * @param added the method to call when a service was added
+     * @param removed the method to call when a service was removed
+     * @return this service dependency
+     */
+    public ServiceDependency setCallbacks(Object instance, String added, String removed)
+    {
+        return setCallbacks(instance, added, null, removed);
+    }
+
+    /**
+     * Sets the callbacks for this service. These callbacks can be used as hooks whenever a
+     * dependency is added, changed or removed. They are called on the instance you provide. When you
+     * specify callbacks, the default auto configuration feature is automatically turned off, because
+     * we're assuming you don't need it in this case. If you need both features (callbacks + autoconfig),
+     * then, you must explicitly invoke setAutoConfig(true) and setCallbacks methods.
+     * 
+     * @param instance the instance to call the callbacks on
+     * @param added the method to call when a service was added
+     * @param changed the method to call when a service was changed
+     * @param removed the method to call when a service was removed
+     * @return this service dependency
+     */
+    public abstract ServiceDependency setCallbacks(Object instance, String added, String changed,
+        String removed);
+
+    public abstract boolean isAvailable();
+
+    public abstract boolean isRequired();
+}
diff --git a/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/ServiceStateListener.java b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/ServiceStateListener.java
new file mode 100644
index 0000000..a655633
--- /dev/null
+++ b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/ServiceStateListener.java
@@ -0,0 +1,62 @@
+/*
+ * 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.dependencymanager;
+
+/**
+ * This interface can be used to register a service state listener. Service
+ * state listeners are called whenever a service state changes. You get notified
+ * when the service is starting, started, stopping and stopped. Each callback
+ * includes a reference to the service in question.
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public interface ServiceStateListener {
+    /**
+     * Called when the service is starting. At this point, the required
+     * dependencies have been injected, but the service has not been registered
+     * yet.
+     * 
+     * @param service the service
+     */
+    public void starting(Service service);
+    
+    /**
+     * Called when the service is started. At this point, the service has been
+     * registered.
+     * 
+     * @param service the service
+     */
+    public void started(Service service);
+    
+    /**
+     * Called when the service is stopping. At this point, the service is still
+     * registered.
+     * 
+     * @param service the service
+     */
+    public void stopping(Service service);
+    
+    /**
+     * Called when the service is stopped. At this point, the service has been
+     * unregistered.
+     * 
+     * @param service the service
+     */
+    public void stopped(Service service);
+}
diff --git a/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/impl/ConfigurationDependencyImpl.java b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/impl/ConfigurationDependencyImpl.java
new file mode 100644
index 0000000..1e7f080
--- /dev/null
+++ b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/impl/ConfigurationDependencyImpl.java
@@ -0,0 +1,97 @@
+/*
+ * 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.dependencymanager.impl;
+
+import java.util.Dictionary;
+
+import org.apache.felix.dependencymanager.ConfigurationDependency;
+import org.apache.felix.dependencymanager.DependencyManager;
+
+/**
+ * Configuration dependency that can track the availability of a (valid) configuration.
+ * To use it, specify a PID for the configuration. The dependency is always required,
+ * because if it is not, it does not make sense to use the dependency manager. In that
+ * scenario, simply register your service as a <code>ManagedService(Factory)</code> and
+ * handle everything yourself. Also, only managed services are supported, not factories.
+ * There are a couple of things you need to be aware of when implementing the
+ * <code>updated(Dictionary)</code> method:
+ * <ul>
+ * <li>Make sure it throws a <code>ConfigurationException</code> when you get a
+ * configuration that is invalid. In this case, the dependency will not change:
+ * if it was not available, it will still not be. If it was available, it will
+ * remain available and implicitly assume you keep working with your old
+ * configuration.</li>
+ * <li>This method will be called before all required dependencies are available.
+ * Make sure you do not depend on these to parse your settings.</li>
+ * </ul>
+ * 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class ConfigurationDependencyImpl extends ConfigurationDependency
+{
+    org.apache.felix.dm.dependencies.ConfigurationDependency m_delegate;
+
+    public ConfigurationDependencyImpl(DependencyManager dm)
+    {
+        org.apache.felix.dm.DependencyManager dmDelegate = (org.apache.felix.dm.DependencyManager) dm.getDelegate();
+        m_delegate = dmDelegate.createConfigurationDependency();
+    }
+
+    public org.apache.felix.dm.dependencies.ConfigurationDependency getDelegate()
+    {
+        return m_delegate;
+    }
+
+    public ConfigurationDependency setCallback(String callback)
+    {
+        m_delegate.setCallback(callback);
+        return this;
+    }
+
+    /**
+     * Sets the <code>service.pid</code> of the configuration you
+     * are depending on.
+     */
+    public ConfigurationDependency setPid(String pid)
+    {
+        m_delegate.setPid(pid);
+        return this;
+    }
+
+    /**
+     * Sets propagation of the configuration properties to the service
+     * properties. Any additional service properties specified directly
+     * are merged with these.
+     */
+    public ConfigurationDependency setPropagate(boolean propagate)
+    {
+        m_delegate.setPropagate(propagate);
+        return this;
+    }
+
+    public boolean isAvailable()
+    {
+        return m_delegate.isAvailable();
+    }
+
+    public boolean isRequired()
+    {
+        return m_delegate.isRequired();
+    }
+}
diff --git a/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/impl/ServiceDependencyImpl.java b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/impl/ServiceDependencyImpl.java
new file mode 100644
index 0000000..c5f0de3
--- /dev/null
+++ b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/impl/ServiceDependencyImpl.java
@@ -0,0 +1,98 @@
+/*
+ * 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.dependencymanager.impl;
+
+import org.apache.felix.dependencymanager.DependencyManager;
+import org.apache.felix.dependencymanager.ServiceDependency;
+import org.osgi.framework.ServiceReference;
+
+public class ServiceDependencyImpl extends ServiceDependency
+{
+    org.apache.felix.dm.dependencies.ServiceDependency m_delegate;
+
+    public ServiceDependencyImpl(DependencyManager dm)
+    {
+        org.apache.felix.dm.DependencyManager dmDelegate = (org.apache.felix.dm.DependencyManager) dm.getDelegate();
+        m_delegate = dmDelegate.createServiceDependency();
+    }
+
+    public org.apache.felix.dm.dependencies.ServiceDependency getDelegate()
+    {
+        return m_delegate;
+    }
+
+    public ServiceDependency setService(Class serviceName)
+    {
+        m_delegate.setService(serviceName);
+        return this;
+    }
+
+    public ServiceDependency setService(Class serviceName, String serviceFilter)
+    {
+        m_delegate.setService(serviceName, serviceFilter);
+        return this;
+    }
+
+    public ServiceDependency setService(Class serviceName, ServiceReference serviceReference)
+    {
+        m_delegate.setService(serviceName, serviceReference);
+        return this;
+    }
+
+    public ServiceDependency setDefaultImplementation(Object implementation)
+    {
+        m_delegate.setDefaultImplementation(implementation);
+        return this;
+    }
+
+    public ServiceDependency setRequired(boolean required)
+    {
+        m_delegate.setRequired(required);
+        return this;
+    }
+
+    public ServiceDependency setAutoConfig(boolean autoConfig)
+    {
+        m_delegate.setAutoConfig(autoConfig);
+        return this;
+    }
+
+    public ServiceDependency setAutoConfig(String instanceName)
+    {
+        m_delegate.setAutoConfig(instanceName);
+        return this;
+    }
+
+    public ServiceDependency setCallbacks(Object instance, String added, String changed,
+        String removed)
+    {
+        m_delegate.setCallbacks(instance, added, changed, removed);
+        return this;
+    }
+
+    public boolean isAvailable()
+    {
+        return m_delegate.isAvailable();
+    }
+
+    public boolean isRequired()
+    {
+        return m_delegate.isRequired();
+    }
+}
diff --git a/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/impl/ServiceImpl.java b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/impl/ServiceImpl.java
new file mode 100644
index 0000000..6f55b3d
--- /dev/null
+++ b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/impl/ServiceImpl.java
@@ -0,0 +1,218 @@
+/*
+ * 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.dependencymanager.impl;
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.felix.dependencymanager.Dependency;
+import org.apache.felix.dependencymanager.DependencyManager;
+import org.apache.felix.dependencymanager.Service;
+import org.apache.felix.dependencymanager.ServiceStateListener;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * Service implementation.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class ServiceImpl implements Service
+{
+    private org.apache.felix.dm.service.Service m_delegate;
+    private Map m_stateListeners = new HashMap();
+    private ArrayList m_dependencies = new ArrayList();
+
+    public ServiceImpl(DependencyManager dm)
+    {
+        org.apache.felix.dm.DependencyManager dmDelegate = (org.apache.felix.dm.DependencyManager) dm.getDelegate();
+        m_delegate = dmDelegate.createService();
+    }
+
+    public Service add(Dependency dependency)
+    {
+        synchronized (this)
+        {
+            m_dependencies.add(dependency);
+        }
+        if (dependency instanceof ServiceDependencyImpl)
+        {
+            m_delegate.add(((org.apache.felix.dependencymanager.impl.ServiceDependencyImpl) dependency).getDelegate());
+
+        }
+        else if (dependency instanceof ConfigurationDependencyImpl)
+        {
+            m_delegate.add(((org.apache.felix.dependencymanager.impl.ConfigurationDependencyImpl) dependency).getDelegate());
+        }
+        else
+        {
+            throw new IllegalArgumentException("dependency type not supported: " + dependency);
+        }
+        return this;
+    }
+
+    public Service remove(Dependency dependency)
+    {
+        if (dependency instanceof ServiceDependencyImpl)
+        {
+            m_delegate.remove(((org.apache.felix.dependencymanager.impl.ConfigurationDependencyImpl) dependency).getDelegate());
+        }
+        else if (dependency instanceof ConfigurationDependencyImpl)
+        {
+            m_delegate.remove(((org.apache.felix.dependencymanager.impl.ServiceDependencyImpl) dependency).getDelegate());
+        }
+        else
+        {
+            throw new IllegalArgumentException("dependency type not supported: " + dependency);
+        }
+        return this;
+    }
+
+    public void addStateListener(final ServiceStateListener listener)
+    {
+        org.apache.felix.dm.service.ServiceStateListener wrappedListener = new org.apache.felix.dm.service.ServiceStateListener()
+        {
+            public void started(org.apache.felix.dm.service.Service service)
+            {
+                listener.started(ServiceImpl.this);
+            }
+
+            public void starting(org.apache.felix.dm.service.Service service)
+            {
+                listener.starting(ServiceImpl.this);
+            }
+
+            public void stopped(org.apache.felix.dm.service.Service service)
+            {
+                listener.stopped(ServiceImpl.this);
+            }
+
+            public void stopping(org.apache.felix.dm.service.Service service)
+            {
+                listener.stopping(ServiceImpl.this);
+            }
+        };
+        synchronized (this)
+        {
+            m_stateListeners.put(listener, wrappedListener);
+        }
+        m_delegate.addStateListener(wrappedListener);
+    }
+
+    public void removeStateListener(ServiceStateListener listener)
+    {
+        org.apache.felix.dm.service.ServiceStateListener wrappedListener = null;
+        synchronized (m_stateListeners)
+        {
+            wrappedListener = (org.apache.felix.dm.service.ServiceStateListener) m_stateListeners.remove(listener);
+        }
+        if (wrappedListener != null)
+        {
+            m_delegate.removeStateListener(wrappedListener);
+        }
+    }
+
+    public List getDependencies()
+    {
+        synchronized (m_dependencies)
+        {
+            return (List) m_dependencies.clone();
+        }
+    }
+
+    public Object getService()
+    {
+        return m_delegate.getService();
+    }
+
+    public Dictionary getServiceProperties()
+    {
+        return m_delegate.getServiceProperties();
+    }
+
+    public ServiceRegistration getServiceRegistration()
+    {
+        return m_delegate.getServiceRegistration();
+    }
+
+    public Service setCallbacks(String init, String start, String stop, String destroy)
+    {
+        m_delegate.setCallbacks(init, start, stop, destroy);
+        return this;
+    }
+
+    public Service setComposition(Object instance, String getMethod)
+    {
+        m_delegate.setComposition(instance, getMethod);
+        return this;
+    }
+
+    public Service setComposition(String getMethod)
+    {
+        m_delegate.setComposition(getMethod);
+        return this;
+    }
+
+    public Service setFactory(Object factory, String createMethod)
+    {
+        m_delegate.setFactory(factory, createMethod);
+        return this;
+    }
+
+    public Service setFactory(String createMethod)
+    {
+        m_delegate.setFactory(createMethod);
+        return this;
+    }
+
+    public Service setImplementation(Object implementation)
+    {
+        m_delegate.setImplementation(implementation);
+        return this;
+    }
+
+    public Service setInterface(String serviceName, Dictionary properties)
+    {
+        m_delegate.setInterface(serviceName, properties);
+        return this;
+    }
+
+    public Service setInterface(String[] serviceNames, Dictionary properties)
+    {
+        m_delegate.setInterface(serviceNames, properties);
+        return this;
+    }
+
+    public void setServiceProperties(Dictionary serviceProperties)
+    {
+        m_delegate.setServiceProperties(serviceProperties);
+    }
+
+    public void start()
+    {
+        m_delegate.start();
+    }
+
+    public void stop()
+    {
+        m_delegate.stop();
+    }
+}