for (ComponentProperty prop : compProps) {
boolean hasSetProp = false;
String propName = prop.getName();
ObjectFactory objFactory = propertyValueFactory.createValueFactory(prop, prop.getValue());
try {
Field field = implClass.getDeclaredField(propName);
org.osoa.sca.annotations.Property propAnn;
if ((propAnn = field.getAnnotation(org.osoa.sca.annotations.Property.class)) != null
|| Modifier.isPublic(field.getModifiers())) {
try {
if (!field.isAccessible())
field.setAccessible(true);
field.set(instance, objFactory.getInstance());
hasSetProp = true;
} catch (IllegalAccessException e) {
if (propAnn.required())
throw new RuntimeException(e);
}
}
} catch (NoSuchFieldException e) {
// Ignore exception
}
if (!hasSetProp) {
Method[] methods = implClass.getDeclaredMethods();
org.osoa.sca.annotations.Property propAnn = null;
for (Method method : methods) {
if (!method.getName().startsWith("set"))
continue;
if ((propAnn = method.getAnnotation(org.osoa.sca.annotations.Property.class)) != null
|| Modifier.isPublic(method.getModifiers())) {
String methodPropName = Introspector.decapitalize(method.getName().substring(3));
if (!propName.equals(methodPropName))
continue;
}
try {
if (!method.isAccessible())
method.setAccessible(true);
method.invoke(instance, objFactory.getInstance());
hasSetProp = true;
} catch (Exception e) {
if (propAnn != null && propAnn.required())
throw new RuntimeException(e);
}