Fixed an issue with not all callbacks being invoked on service compositions, introduced as part of the refactoring of Friday.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@930846 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/InvocationUtil.java b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/InvocationUtil.java
index 2083d8d..ecaeeb1 100644
--- a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/InvocationUtil.java
+++ b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/InvocationUtil.java
@@ -5,13 +5,6 @@
import java.lang.reflect.Modifier;
public class InvocationUtil {
- public static void invokeCallbackMethod(Object[] instances, String methodName, Class[][] signatures, Object[][] parameters) throws NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
- for (int i = 0; i < instances.length; i++) {
- invokeCallbackMethod(instances[i], methodName, signatures, parameters);
- }
- throw new NoSuchMethodException("Method '" + methodName + "' does not exist. Callback skipped.");
- }
-
public static void invokeCallbackMethod(Object instance, String methodName, Class[][] signatures, Object[][] parameters) throws NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Class currentClazz = instance.getClass();
while (currentClazz != null) {
@@ -43,6 +36,6 @@
// ignore this and keep looking
}
}
- throw new NoSuchMethodException();
+ throw new NoSuchMethodException(name);
}
}
diff --git a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/DependencyBase.java b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/DependencyBase.java
index ac70c71..3728ed3 100644
--- a/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/DependencyBase.java
+++ b/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/dependencies/DependencyBase.java
@@ -30,14 +30,16 @@
}
protected void invokeCallbackMethod(Object[] instances, String methodName, Class[][] signatures, Object[][] parameters) {
- try {
- InvocationUtil.invokeCallbackMethod(instances, methodName, signatures, parameters);
- }
- catch (NoSuchMethodException e) {
- m_logger.log(Logger.LOG_DEBUG, "Method '" + methodName + "' does not exist. Callback skipped.");
- }
- catch (Exception e) {
- m_logger.log(Logger.LOG_DEBUG, "Invocation of '" + methodName + "' failed.", e);
+ for (int i = 0; i < instances.length; i++) {
+ try {
+ InvocationUtil.invokeCallbackMethod(instances[i], methodName, signatures, parameters);
+ }
+ catch (NoSuchMethodException e) {
+ // if the method does not exist, ignore it
+ }
+ catch (Exception e) {
+ m_logger.log(Logger.LOG_WARNING, "Invocation of '" + methodName + "' failed.", e);
+ }
}
}
}
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/FELIX2078_ServiceDependencyTest.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/FELIX2078_ServiceDependencyTest.java
index 199cf9b..832200f 100644
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/FELIX2078_ServiceDependencyTest.java
+++ b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/FELIX2078_ServiceDependencyTest.java
@@ -54,8 +54,9 @@
Service sc = m.createService().setImplementation(new ServiceConsumer(e)).add(m.createServiceDependency().setService(ServiceInterface.class).setRequired(true).setCallbacks("add", "remove"));
m.add(sp);
m.add(sp2);
- System.out.println("test");
+ System.out.println("adding client");
m.add(sc);
+ System.out.println("waiting");
// wait until both services have been added to our consumer
e.waitForStep(2, 5000);
m.remove(sc);
@@ -105,6 +106,7 @@
}
public void add(ServiceInterface i) {
+ System.out.println("add " + i);
m_ensure.step();
}