summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Liebig2008-02-21 07:49:23 (EST)
committerStefan Liebig2008-02-21 07:49:23 (EST)
commit78a5e10a35d0e663a8f5db1eb37c78609f46c990 (patch)
tree11466cf4d6e488835f2aa99ed75e4809d376a1d4
parent9e9c1f79c64425b9a92fd3f67e969d7d56d0ad8d (diff)
downloadorg.eclipse.riena-78a5e10a35d0e663a8f5db1eb37c78609f46c990.zip
org.eclipse.riena-78a5e10a35d0e663a8f5db1eb37c78609f46c990.tar.gz
org.eclipse.riena-78a5e10a35d0e663a8f5db1eb37c78609f46c990.tar.bz2
added error ´logs´ + cleaning
-rw-r--r--org.eclipse.riena.core/src/org/eclipse/riena/core/service/Injector.java43
1 files changed, 21 insertions, 22 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 7c915cb..ecdb0d4 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
@@ -249,22 +249,16 @@ public abstract class Injector {
context.ungetService(serviceRef);
}
- private void invokeMethod(List<Method> methods, Object service /*
- * ServiceReference
- * serviceRef
- */) {
- // if (serviceRef == null)
- // return;
- // Object service = context.getService(serviceRef);
- // if (service == null)
- // return;
+ private void invokeMethod(List<Method> methods, Object service) {
+ assert service != null;
+
Method method = findMatchingMethod(methods, service);
if (method == null)
return;
invoke(method, service);
}
- private static Method findMatchingMethod(List<Method> methods, Object service) {
+ private Method findMatchingMethod(List<Method> methods, Object service) {
assert methods != null;
assert service != null;
@@ -279,9 +273,11 @@ public abstract class Injector {
if (targetedMethods.size() == 1)
return targetedMethods.get(0);
- if (targetedMethods.isEmpty())
+ if (targetedMethods.isEmpty()) {
+ log("Could not find a matching Bind/Unbind method from '" + methods + "' for target class '"
+ + target.getClass().getName() + "'.", null);
return null;
-
+ }
// find most specific method
Class<?> superType = parameterType;
while (superType != null) {
@@ -299,25 +295,28 @@ public abstract class Injector {
* @param service
*/
private void invoke(Method method, Object service) {
- if (method == null) {
- // TODO logging
- throw new IllegalArgumentException("Bind/Unbind method '" + method + "' does not exist in target class '"
- + target.getClass().getName() + "'.");
- }
+ assert method != null;
+ assert service != null;
+
try {
method.invoke(target, service);
} catch (SecurityException e) {
- // TODO How to handle this and the following
- e.printStackTrace();
+ log("Security exception on invoking '" + method + "' on '" + target.getClass().getName() + "'.", e);
} catch (IllegalArgumentException e) {
- e.printStackTrace();
+ log("Illegal argument exception on invoking '" + method + "' on '" + target.getClass().getName() + "'.", e);
} catch (IllegalAccessException e) {
- e.printStackTrace();
+ log("Illegal access exception on invoking '" + method + "' on '" + target.getClass().getName() + "'.", e);
} catch (InvocationTargetException e) {
- e.printStackTrace();
+ log("Invocation target exception on invoking '" + method + "' on '" + target.getClass().getName() + "'.", e);
}
}
+ private void log(String message, Throwable throwable) {
+ System.err.println("ServiceInjector error: " + message + throwable.getMessage());
+ if (throwable != null)
+ throwable.printStackTrace(System.err);
+ }
+
/**
* The service listener for this injector.
*/