You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ma...@apache.org on 2006/06/20 13:58:00 UTC
svn commit: r415616 -
/incubator/felix/trunk/org.apache.felix.dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
Author: marrs
Date: Tue Jun 20 04:58:00 2006
New Revision: 415616
URL: http://svn.apache.org/viewvc?rev=415616&view=rev
Log:
FELIX-82 Callback algorithm now also searches through superclasses.
Modified:
incubator/felix/trunk/org.apache.felix.dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
Modified: incubator/felix/trunk/org.apache.felix.dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/org.apache.felix.dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java?rev=415616&r1=415615&r2=415616&view=diff
==============================================================================
--- incubator/felix/trunk/org.apache.felix.dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java (original)
+++ incubator/felix/trunk/org.apache.felix.dependencymanager/src/main/java/org/apache/felix/dependencymanager/ServiceDependency.java Tue Jun 20 04:58:00 2006
@@ -252,43 +252,51 @@
private void invokeCallbackMethod(Object instance, String methodName, ServiceReference reference, Object service) throws NoSuchMethodException {
Method method = null;
Class clazz = instance.getClass();
- AccessibleObject.setAccessible(clazz.getDeclaredMethods(), true);
- try {
- try {
- method = clazz.getDeclaredMethod(methodName, new Class[] {ServiceReference.class, Object.class});
- method.invoke(instance, new Object[] {reference, service});
- }
- catch (NoSuchMethodException e) {
- try {
- method = clazz.getDeclaredMethod(methodName, new Class[] {ServiceReference.class});
- method.invoke(instance, new Object[] {reference});
- }
- catch (NoSuchMethodException e1) {
- try {
- method = clazz.getDeclaredMethod(methodName, new Class[] {Object.class});
- method.invoke(instance, new Object[] {service});
- }
- catch (NoSuchMethodException e2) {
- try {
- method = clazz.getDeclaredMethod(methodName, new Class[] {m_trackedServiceName});
- method.invoke(instance, new Object[] {service});
- }
- catch (NoSuchMethodException e3) {
- method = clazz.getDeclaredMethod(methodName, null);
- method.invoke(instance, null);
- }
- }
- }
- }
- } catch (IllegalArgumentException e1) {
- // TODO handle this exception, probably best to ignore it
- e1.printStackTrace();
- } catch (IllegalAccessException e1) {
- // TODO handle this exception, probably best to ignore it
- e1.printStackTrace();
- } catch (InvocationTargetException e1) {
- // TODO handle this exception, probably best to ignore it
- e1.printStackTrace();
+ while (clazz != null) {
+ AccessibleObject.setAccessible(clazz.getDeclaredMethods(), true);
+ try {
+ try {
+ method = clazz.getDeclaredMethod(methodName, new Class[] {ServiceReference.class, Object.class});
+ method.invoke(instance, new Object[] {reference, service});
+ return;
+ }
+ catch (NoSuchMethodException e) {
+ try {
+ method = clazz.getDeclaredMethod(methodName, new Class[] {ServiceReference.class});
+ method.invoke(instance, new Object[] {reference});
+ return;
+ }
+ catch (NoSuchMethodException e1) {
+ try {
+ method = clazz.getDeclaredMethod(methodName, new Class[] {Object.class});
+ method.invoke(instance, new Object[] {service});
+ return;
+ }
+ catch (NoSuchMethodException e2) {
+ try {
+ method = clazz.getDeclaredMethod(methodName, new Class[] {m_trackedServiceName});
+ method.invoke(instance, new Object[] {service});
+ return;
+ }
+ catch (NoSuchMethodException e3) {
+ method = clazz.getDeclaredMethod(methodName, null);
+ method.invoke(instance, null);
+ return;
+ }
+ }
+ }
+ }
+ }
+ catch (IllegalArgumentException e1) {
+ // ignore this exception
+ }
+ catch (IllegalAccessException e1) {
+ // ignore this exception
+ }
+ catch (InvocationTargetException e1) {
+ // ignore this exception
+ }
+ clazz = clazz.getSuperclass();
}
}