| 169 | } |
| 170 | |
| 171 | private static void setProperty(Exchange instance, String key, String value) |
| 172 | throws IllegalArgumentException, IllegalAccessException { |
| 173 | |
| 174 | Class<?> clazz = instance.getClass(); |
| 175 | Field field = null; |
| 176 | |
| 177 | // look for the field in this class and its superclasses |
| 178 | while (clazz != null) { |
| 179 | try { |
| 180 | field = clazz.getDeclaredField(key); |
| 181 | break; // found it |
| 182 | } catch (NoSuchFieldException e) { |
| 183 | clazz = clazz.getSuperclass(); // go up the hierarchy |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | if (field != null) { |
| 188 | field.setAccessible(true); |
| 189 | field.set(instance, value); |
| 190 | } else { |
| 191 | System.out.println("No field or setter found for credential: " + key); |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | public static Object callDynamic(Object instance, String methodName, Object... args) { |
| 196 | Class<?> clazz = instance.getClass(); |