summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Liebig2008-02-15 07:35:26 (EST)
committerStefan Liebig2008-02-15 07:35:26 (EST)
commit563ee6f9b77b637049a9e80bf777bc89efecc5d7 (patch)
tree71551620576eba37fbaf781b768dbea2cd24d07d
parent4a58c7575c14e895ea6a7d8ced03810252e9e3b4 (diff)
downloadorg.eclipse.riena-563ee6f9b77b637049a9e80bf777bc89efecc5d7.zip
org.eclipse.riena-563ee6f9b77b637049a9e80bf777bc89efecc5d7.tar.gz
org.eclipse.riena-563ee6f9b77b637049a9e80bf777bc89efecc5d7.tar.bz2
method selection repaired + service types detection
-rw-r--r--org.eclipse.riena.core/src/org/eclipse/riena/core/service/Injector.java29
1 files changed, 17 insertions, 12 deletions
diff --git a/org.eclipse.riena.core/src/org/eclipse/riena/core/service/Injector.java b/org.eclipse.riena.core/src/org/eclipse/riena/core/service/Injector.java
index 15846b9..4f1fe06 100644
--- a/org.eclipse.riena.core/src/org/eclipse/riena/core/service/Injector.java
+++ b/org.eclipse.riena.core/src/org/eclipse/riena/core/service/Injector.java
@@ -15,8 +15,9 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.riena.core.util.PropertiesUtils;
+import org.eclipse.core.runtime.Assert;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener;
@@ -275,26 +276,30 @@ public class Injector {
return null;
// find most specific method
- Class<?> superType;
- for (Method method : targetedMethods)
- while ((superType = parameterType.getSuperclass()) != null)
+ Class<?> superType = parameterType;
+ while (superType != null) {
+ for (Method method : targetedMethods)
if (!method.getParameterTypes()[0].isAssignableFrom(superType))
return method;
+ superType = superType.getSuperclass();
+ }
return targetedMethods.get(0);
}
class InjectorServiceListener implements ServiceListener {
public void serviceChanged(ServiceEvent event) {
- if (serviceId != null) {
- Object property = event.getServiceReference().getProperty("objectClass");
- String objectClass = PropertiesUtils.accessProperty(property, null);
- // if serviceId set than only handle this event if id is equal.
- if (objectClass.equals(serviceId.getServiceId()))
+ int eventType = event.getType();
+ if (eventType != ServiceEvent.REGISTERED && eventType != ServiceEvent.UNREGISTERING)
+ return;
+ Object value = event.getServiceReference().getProperty(Constants.OBJECTCLASS);
+ Assert.isTrue(value instanceof String[], "Contract vioaltion: property ´objectClass´ is not a String[]");
+ String[] types = (String[]) value;
+ for (String type : types)
+ if (type.equals(serviceId.getServiceId())) {
handleEvent(event);
- } else
- // if no serviceId set handle any event
- handleEvent(event);
+ return;
+ }
}
}