private void addExceptionMapAsFieldDeclaration(List<FieldDeclaration> fieldDeclarations, List<MapExceptionEntry> mapExceptions) { FieldDeclaration exceptionMapsFieldDeclaration = new FieldDeclaration(EXCEPTION_MAP_FIELD, mapExceptions.getClass().toString(), mapExceptions); fieldDeclarations.add(exceptionMapsFieldDeclaration); }
public static void applyFieldDeclaration(FieldDeclaration declaration, Object target) { Method setterMethod = ReflectUtil.getSetter(declaration.getName(), target.getClass(), declaration.getValue().getClass()); if (setterMethod != null) { try { setterMethod.invoke(target, declaration.getValue()); } catch (IllegalArgumentException e) { throw new ActivitiException("Error while invoking '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } catch (IllegalAccessException e) { throw new ActivitiException("Illegal access when calling '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } catch (InvocationTargetException e) { throw new ActivitiException("Exception while invoking '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } } else { Field field = ReflectUtil.getField(declaration.getName(), target); if (field == null) { throw new ActivitiIllegalArgumentException("Field definition uses non-existing field '" + declaration.getName() + "' on class " + target.getClass().getName()); } // Check if the delegate field's type is correct if (!fieldTypeCompatible(declaration, field)) { throw new ActivitiIllegalArgumentException("Incompatible type set on field declaration '" + declaration.getName() + "' for class " + target.getClass().getName() + ". Declared value has type " + declaration.getValue().getClass().getName() + ", while expecting " + field.getType().getName()); } ReflectUtil.setField(field, target, declaration.getValue()); } }
public static void applyFieldDeclaration(FieldDeclaration declaration, Object target, boolean throwExceptionOnMissingField) { Method setterMethod = ReflectUtil.getSetter(declaration.getName(), target.getClass(), declaration.getValue().getClass()); setterMethod.invoke(target, declaration.getValue()); } catch (IllegalArgumentException e) { throw new ActivitiException("Error while invoking '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } catch (IllegalAccessException e) { throw new ActivitiException("Illegal acces when calling '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } catch (InvocationTargetException e) { throw new ActivitiException("Exception while invoking '" + declaration.getName() + "' on class " + target.getClass().getName(), e); Field field = ReflectUtil.getField(declaration.getName(), target); if(field == null) { if (throwExceptionOnMissingField) { throw new ActivitiIllegalArgumentException("Field definition uses unexisting field '" + declaration.getName() + "' on class " + target.getClass().getName()); } else { return; throw new ActivitiIllegalArgumentException("Incompatible type set on field declaration '" + declaration.getName() + "' for class " + target.getClass().getName() + ". Declared value has type " + declaration.getValue().getClass().getName() + ", while expecting " + field.getType().getName()); ReflectUtil.setField(field, target, declaration.getValue());
private ClassDelegate createNoOpServiceTask(ServiceTask serviceTask) { List<FieldDeclaration> fieldDeclarations = new ArrayList<FieldDeclaration>(); fieldDeclarations.add(new FieldDeclaration("name", Expression.class.getName(), new FixedValue(serviceTask.getImplementation()))); return new ClassDelegate(NoOpServiceTask.class, fieldDeclarations); }
public static void applyFieldDeclaration(FieldDeclaration declaration, Object target) { Method setterMethod = ReflectUtil.getSetter(declaration.getName(), target.getClass(), declaration.getValue().getClass()); if(setterMethod != null) { try { setterMethod.invoke(target, declaration.getValue()); } catch (IllegalArgumentException e) { throw new ActivitiException("Error while invoking '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } catch (IllegalAccessException e) { throw new ActivitiException("Illegal acces when calling '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } catch (InvocationTargetException e) { throw new ActivitiException("Exception while invoking '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } } else { Field field = ReflectUtil.getField(declaration.getName(), target); if(field == null) { throw new ActivitiIllegalArgumentException("Field definition uses unexisting field '" + declaration.getName() + "' on class " + target.getClass().getName()); } // Check if the delegate field's type is correct if(!fieldTypeCompatible(declaration, field)) { throw new ActivitiIllegalArgumentException("Incompatible type set on field declaration '" + declaration.getName() + "' for class " + target.getClass().getName() + ". Declared value has type " + declaration.getValue().getClass().getName() + ", while expecting " + field.getType().getName()); } ReflectUtil.setField(field, target, declaration.getValue()); } }
public List<FieldDeclaration> createFieldDeclarations(List<FieldExtension> fieldList) { List<FieldDeclaration> fieldDeclarations = new ArrayList<FieldDeclaration>(); for (FieldExtension fieldExtension : fieldList) { FieldDeclaration fieldDeclaration = null; if (StringUtils.isNotEmpty(fieldExtension.getExpression())) { fieldDeclaration = new FieldDeclaration(fieldExtension.getFieldName(), Expression.class.getName(), expressionManager.createExpression(fieldExtension.getExpression())); } else { fieldDeclaration = new FieldDeclaration(fieldExtension.getFieldName(), Expression.class.getName(), new FixedValue(fieldExtension.getStringValue())); } fieldDeclarations.add(fieldDeclaration); } return fieldDeclarations; }
public static void applyFieldDeclaration(FieldDeclaration declaration, Object target) { Method setterMethod = ReflectUtil.getSetter(declaration.getName(), target.getClass(), declaration.getValue().getClass()); if(setterMethod != null) { try { setterMethod.invoke(target, declaration.getValue()); } catch (IllegalArgumentException e) { throw new ActivitiException("Error while invoking '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } catch (IllegalAccessException e) { throw new ActivitiException("Illegal acces when calling '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } catch (InvocationTargetException e) { throw new ActivitiException("Exception while invoking '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } } else { Field field = ReflectUtil.getField(declaration.getName(), target); if(field == null) { throw new ActivitiIllegalArgumentException("Field definition uses unexisting field '" + declaration.getName() + "' on class " + target.getClass().getName()); } // Check if the delegate field's type is correct if(!fieldTypeCompatible(declaration, field)) { throw new ActivitiIllegalArgumentException("Incompatible type set on field declaration '" + declaration.getName() + "' for class " + target.getClass().getName() + ". Declared value has type " + declaration.getValue().getClass().getName() + ", while expecting " + field.getType().getName()); } ReflectUtil.setField(field, target, declaration.getValue()); } }
private void addExceptionMapAsFieldDeclaration(List<FieldDeclaration> fieldDeclarations, List<MapExceptionEntry> mapExceptions) { FieldDeclaration exceptionMapsFieldDeclaration = new FieldDeclaration(EXCEPTION_MAP_FIELD, mapExceptions.getClass().toString(), mapExceptions); fieldDeclarations.add(exceptionMapsFieldDeclaration); }
public static void applyFieldDeclaration(FieldDeclaration declaration, Object target) { Method setterMethod = ReflectUtil.getSetter(declaration.getName(), target.getClass(), declaration.getValue().getClass()); if (setterMethod != null) { try { setterMethod.invoke(target, declaration.getValue()); } catch (IllegalArgumentException e) { throw new ActivitiException("Error while invoking '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } catch (IllegalAccessException e) { throw new ActivitiException("Illegal access when calling '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } catch (InvocationTargetException e) { throw new ActivitiException("Exception while invoking '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } } else { Field field = ReflectUtil.getField(declaration.getName(), target); if (field == null) { throw new ActivitiIllegalArgumentException("Field definition uses non-existing field '" + declaration.getName() + "' on class " + target.getClass().getName()); } // Check if the delegate field's type is correct if (!fieldTypeCompatible(declaration, field)) { throw new ActivitiIllegalArgumentException("Incompatible type set on field declaration '" + declaration.getName() + "' for class " + target.getClass().getName() + ". Declared value has type " + declaration.getValue().getClass().getName() + ", while expecting " + field.getType().getName()); } ReflectUtil.setField(field, target, declaration.getValue()); } }
private void addExceptionMapAsFieldDeclaration(List<FieldDeclaration> fieldDeclarations, List<MapExceptionEntry> mapExceptions) { FieldDeclaration exceptionMapsFieldDeclaration = new FieldDeclaration(EXCEPTION_MAP_FIELD, mapExceptions.getClass().toString(), mapExceptions); fieldDeclarations.add(exceptionMapsFieldDeclaration); }
public static void applyFieldDeclaration(FieldDeclaration declaration, Object target) { Method setterMethod = ReflectUtil.getSetter(declaration.getName(), target.getClass(), declaration.getValue().getClass()); if (setterMethod != null) { try { setterMethod.invoke(target, declaration.getValue()); } catch (IllegalArgumentException e) { throw new ActivitiException("Error while invoking '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } catch (IllegalAccessException e) { throw new ActivitiException("Illegal access when calling '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } catch (InvocationTargetException e) { throw new ActivitiException("Exception while invoking '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } } else { Field field = ReflectUtil.getField(declaration.getName(), target); if (field == null) { throw new ActivitiIllegalArgumentException("Field definition uses unexisting field '" + declaration.getName() + "' on class " + target.getClass().getName()); } // Check if the delegate field's type is correct if (!fieldTypeCompatible(declaration, field)) { throw new ActivitiIllegalArgumentException("Incompatible type set on field declaration '" + declaration.getName() + "' for class " + target.getClass().getName() + ". Declared value has type " + declaration.getValue().getClass().getName() + ", while expecting " + field.getType().getName()); } ReflectUtil.setField(field, target, declaration.getValue()); } }
private ClassDelegate createNoOpServiceTask(ServiceTask serviceTask) { List<FieldDeclaration> fieldDeclarations = new ArrayList<FieldDeclaration>(); fieldDeclarations.add(new FieldDeclaration("name", Expression.class.getName(), new FixedValue(serviceTask.getImplementation()))); return new ClassDelegate(NoOpServiceTask.class, fieldDeclarations); }
public static void applyFieldDeclaration(FieldDeclaration declaration, Object target, boolean throwExceptionOnMissingField) { Method setterMethod = ReflectUtil.getSetter(declaration.getName(), target.getClass(), declaration.getValue().getClass()); setterMethod.invoke(target, declaration.getValue()); } catch (IllegalArgumentException e) { throw new ActivitiException("Error while invoking '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } catch (IllegalAccessException e) { throw new ActivitiException("Illegal acces when calling '" + declaration.getName() + "' on class " + target.getClass().getName(), e); } catch (InvocationTargetException e) { throw new ActivitiException("Exception while invoking '" + declaration.getName() + "' on class " + target.getClass().getName(), e); Field field = ReflectUtil.getField(declaration.getName(), target); if(field == null) { if (throwExceptionOnMissingField) { throw new ActivitiIllegalArgumentException("Field definition uses unexisting field '" + declaration.getName() + "' on class " + target.getClass().getName()); } else { return; throw new ActivitiIllegalArgumentException("Incompatible type set on field declaration '" + declaration.getName() + "' for class " + target.getClass().getName() + ". Declared value has type " + declaration.getValue().getClass().getName() + ", while expecting " + field.getType().getName()); ReflectUtil.setField(field, target, declaration.getValue());