ControllerDependencyInjector problem with inject data sources from window parameters #PL-2797

This commit is contained in:
Yuriy Artamonov 2013-10-29 13:44:37 +00:00
parent 82f4cbb74e
commit 64306d21e5

View File

@ -126,14 +126,17 @@ public class ControllerDependencyInjector {
Object instance = getInjectedInstance(type, name, annotationClass); Object instance = getInjectedInstance(type, name, annotationClass);
if (required && instance == null) if (required && instance == null)
log.warn("Unable to find an instance of type " + type + " named " + name); log.warn("CDI - Unable to find an instance of type " + type + " named " + name);
else else
assignValue(element, instance); assignValue(element, instance);
} }
private Object getInjectedInstance(Class<?> type, String name, Class annotationClass) { private Object getInjectedInstance(Class<?> type, String name, Class annotationClass) {
if (annotationClass == WindowParam.class) {
//Injecting a parameter
return params.get(name);
if (Component.class.isAssignableFrom(type)) { } else if (Component.class.isAssignableFrom(type)) {
// Injecting a UI component // Injecting a UI component
return frame.getComponent(name); return frame.getComponent(name);
@ -161,10 +164,6 @@ public class ControllerDependencyInjector {
// Injecting an ExportDisplay // Injecting an ExportDisplay
return AppConfig.createExportDisplay(frame); return AppConfig.createExportDisplay(frame);
} else if (annotationClass == WindowParam.class) {
//Injecting a parameter
return params.get(name);
} else { } else {
Object instance; Object instance;
// Try to find a Spring bean // Try to find a Spring bean
@ -193,7 +192,7 @@ public class ControllerDependencyInjector {
try { try {
((Field) element).set(frame, value); ((Field) element).set(frame, value);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
throw new RuntimeException(e); throw new RuntimeException("CDI - Unable to assign value to field " + ((Field) element).getName(), e);
} }
} else { } else {
Object[] params = new Object[1]; Object[] params = new Object[1];
@ -202,7 +201,7 @@ public class ControllerDependencyInjector {
try { try {
((Method) element).invoke(frame, params); ((Method) element).invoke(frame, params);
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e); throw new RuntimeException("CDI - Unable to assign value through setter " + ((Field) element).getName(),e);
} }
} }
} }