FELIX-3005 (Compatibility API does not add components in DependencyManager)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1137588 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/compat/changelog.txt b/dependencymanager/compat/changelog.txt
index dff1ad4..5fa9803 100644
--- a/dependencymanager/compat/changelog.txt
+++ b/dependencymanager/compat/changelog.txt
@@ -1,3 +1,12 @@
+Changes from 3.0.0 to 3.0.1
+---------------------------
+
+** Bug
+
+ [FELIX-3005] - Compatibility API does not add components in DependencyManager
+
+** Improvement
+
Release 3.0.0
-------------
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
index b61497e..747da1a 100644
--- a/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/DependencyManager.java
+++ b/dependencymanager/compat/src/main/java/org/apache/felix/dependencymanager/DependencyManager.java
@@ -20,6 +20,7 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import org.osgi.framework.BundleContext;
@@ -32,7 +33,6 @@
public class DependencyManager
{
private org.apache.felix.dm.DependencyManager m_delegate;
- private List m_services = Collections.synchronizedList(new ArrayList());
/**
* Creates a new dependency manager.
@@ -53,8 +53,8 @@
*/
public void add(Service service)
{
- m_services.add(service);
- service.start();
+ org.apache.felix.dependencymanager.impl.ServiceImpl serviceImpl = (org.apache.felix.dependencymanager.impl.ServiceImpl)service;
+ ((org.apache.felix.dm.DependencyManager) m_delegate).add(serviceImpl.getDelegate());
}
/**
@@ -65,8 +65,8 @@
*/
public void remove(Service service)
{
- service.stop();
- m_services.remove(service);
+ org.apache.felix.dependencymanager.impl.ServiceImpl impl = (org.apache.felix.dependencymanager.impl.ServiceImpl)service;
+ ((org.apache.felix.dm.DependencyManager) m_delegate).remove(impl.getDelegate());
}
/**
@@ -101,7 +101,14 @@
*/
public List getServices()
{
- return Collections.unmodifiableList(m_services);
+ List list = new ArrayList();
+ List components = m_delegate.getComponents();
+ Iterator it = components.iterator();
+ while (it.hasNext()) {
+ org.apache.felix.dm.Component c = (org.apache.felix.dm.Component) it.next();
+ list.add(new org.apache.felix.dependencymanager.impl.ServiceImpl(c));
+ }
+ return Collections.unmodifiableList(list);
}
/**
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
index e2c3fc7..bf456c8 100644
--- 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
@@ -29,6 +29,7 @@
import org.apache.felix.dependencymanager.DependencyManager;
import org.apache.felix.dependencymanager.Service;
import org.apache.felix.dependencymanager.ServiceStateListener;
+import org.apache.felix.dm.Component;
import org.osgi.framework.ServiceRegistration;
/**
@@ -48,6 +49,10 @@
m_delegate = dmDelegate.createComponent();
}
+ public ServiceImpl(Component c) {
+ m_delegate = c;
+ }
+
public Service add(Dependency dependency)
{
if (dependency instanceof ServiceDependencyImpl)
@@ -236,4 +241,8 @@
{
m_delegate.stop();
}
+
+ public Component getDelegate() {
+ return m_delegate;
+ }
}