private static void proxyElements(SearchContext searchContext, Object instance, Class<?> instanceHierarchyClass) { Field[] fields = instanceHierarchyClass.getDeclaredFields(); for (Field field : fields) { if (field.isSynthetic()) continue; FieldDecorator decorator = initDecorator(searchContext, field); Object value = decorator.decorate(instance.getClass().getClassLoader(), field); if (value != null) { try { field.setAccessible(true); field.set(instance, value); } catch (IllegalAccessException e) { throw new ElementInitializationException(field, instance.getClass(), e); } } } }
private static FieldDecorator initDecorator(SearchContext searchContext, Field field) { FieldDecorator decorator; AjaxElement ajaxElementAnnotation = field.getAnnotation(AjaxElement.class); if (ajaxElementAnnotation != null) { int timeout = ajaxElementAnnotation.timeOutInSeconds(); decorator = new WiseDecorator(new AjaxElementLocatorFactory(searchContext, timeout)); } else { decorator = new WiseDecorator(new DefaultElementLocatorFactory(searchContext)); } return decorator; }