Author: marrs
Date: Tue Jun 15 09:11:45 2010
New Revision: 954774
URL: http://svn.apache.org/viewvc?rev=954774&view=rev
Log:
Fixed an issue with invoking methods on instances that have been implemented
using a dynamic proxy. We already handled injection properly, but now callbacks
work fine too.
Modified:
felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/InvocationUtil.java
Modified:
felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/InvocationUtil.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/InvocationUtil.java?rev=954774&r1=954773&r2=954774&view=diff
==============================================================================
---
felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/InvocationUtil.java
(original)
+++
felix/trunk/dependencymanager/core/src/main/java/org/apache/felix/dm/impl/InvocationUtil.java
Tue Jun 15 09:11:45 2010
@@ -3,6 +3,7 @@ package org.apache.felix.dm.impl;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
public class InvocationUtil {
public static void invokeCallbackMethod(Object instance, String
methodName, Class[][] signatures, Object[][] parameters) throws
NoSuchMethodException, IllegalArgumentException, IllegalAccessException,
InvocationTargetException {
@@ -27,6 +28,14 @@ public class InvocationUtil {
if (clazz == null) {
throw new IllegalArgumentException("Class cannot be null");
}
+
+ // if we're talking to a proxy here, dig one level deeper to expose the
+ // underlying invocation handler (we do the same for injecting
instances)
+ if (Proxy.isProxyClass(clazz)) {
+ object = Proxy.getInvocationHandler(object);
+ clazz = object.getClass();
+ }
+
Method m = null;
for (int i = 0; i < signatures.length; i++) {
Class[] signature = signatures[i];