public static void applyFieldDeclaration(List<FieldDeclaration> fieldDeclarations, Object target) { if(fieldDeclarations != null) { for(FieldDeclaration declaration : fieldDeclarations) { applyFieldDeclaration(declaration, target); } } }
public static Object instantiateDelegate(Class<?> clazz, List<FieldDeclaration> fieldDeclarations) { return instantiateDelegate(clazz.getName(), 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 (Exception e) { throw LOG.exceptionWhileApplyingFieldDeclatation(declaration.getName(), target.getClass().getName(), e); } } else { Field field = ReflectUtil.getField(declaration.getName(), target); ensureNotNull("Field definition uses unexisting field '" + declaration.getName() + "' on class " + target.getClass().getName(), "field", field); // Check if the delegate field's type is correct if (!fieldTypeCompatible(declaration, field)) { throw LOG.incompatibleTypeForFieldDeclaration(declaration, target, field); } ReflectUtil.setField(field, target, declaration.getValue()); } }
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 (Exception e) { throw LOG.exceptionWhileApplyingFieldDeclatation(declaration.getName(), target.getClass().getName(), e); } } else { Field field = ReflectUtil.getField(declaration.getName(), target); ensureNotNull("Field definition uses unexisting field '" + declaration.getName() + "' on class " + target.getClass().getName(), "field", field); // Check if the delegate field's type is correct if (!fieldTypeCompatible(declaration, field)) { throw LOG.incompatibleTypeForFieldDeclaration(declaration, target, field); } ReflectUtil.setField(field, target, declaration.getValue()); } }
public static Object instantiateDelegate(Class<?> clazz, List<FieldDeclaration> fieldDeclarations) { return instantiateDelegate(clazz.getName(), fieldDeclarations); }
public static void applyFieldDeclaration(List<FieldDeclaration> fieldDeclarations, Object target) { if(fieldDeclarations != null) { for(FieldDeclaration declaration : fieldDeclarations) { applyFieldDeclaration(declaration, target); } } }
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 (Exception e) { throw LOG.exceptionWhileApplyingFieldDeclatation(declaration.getName(), target.getClass().getName(), e); } } else { Field field = ReflectUtil.getField(declaration.getName(), target); ensureNotNull("Field definition uses unexisting field '" + declaration.getName() + "' on class " + target.getClass().getName(), "field", field); // Check if the delegate field's type is correct if (!fieldTypeCompatible(declaration, field)) { throw LOG.incompatibleTypeForFieldDeclaration(declaration, target, field); } ReflectUtil.setField(field, target, declaration.getValue()); } }
protected CaseVariableListener getVariableListenerInstance() { Object delegateInstance = instantiateDelegate(className, fieldDeclarations); if (delegateInstance instanceof CaseVariableListener) { return (CaseVariableListener) delegateInstance; } else { throw new ProcessEngineException(delegateInstance.getClass().getName()+" doesn't implement "+CaseVariableListener.class); } }
public static Object instantiateDelegate(String className, List<FieldDeclaration> fieldDeclarations) { ArtifactFactory artifactFactory = Context.getProcessEngineConfiguration().getArtifactFactory(); try { Class<?> clazz = ReflectUtil.loadClass(className); Object object = artifactFactory.getArtifact(clazz); applyFieldDeclaration(fieldDeclarations, object); return object; } catch (Exception e) { throw LOG.exceptionWhileInstantiatingClass(className, e); } }
protected TaskListener getTaskListenerInstance() { Object delegateInstance = instantiateDelegate(className, fieldDeclarations); if (delegateInstance instanceof TaskListener) { return (TaskListener) delegateInstance; } else { throw new ProcessEngineException(delegateInstance.getClass().getName()+" doesn't implement "+TaskListener.class); } }
public static Object instantiateDelegate(String className, List<FieldDeclaration> fieldDeclarations) { ArtifactFactory artifactFactory = Context.getProcessEngineConfiguration().getArtifactFactory(); try { Class<?> clazz = ReflectUtil.loadClass(className); Object object = artifactFactory.getArtifact(clazz); applyFieldDeclaration(fieldDeclarations, object); return object; } catch (Exception e) { throw LOG.exceptionWhileInstantiatingClass(className, e); } }
protected CaseVariableListener getVariableListenerInstance() { Object delegateInstance = instantiateDelegate(className, fieldDeclarations); if (delegateInstance instanceof CaseVariableListener) { return (CaseVariableListener) delegateInstance; } else { throw new ProcessEngineException(delegateInstance.getClass().getName()+" doesn't implement "+CaseVariableListener.class); } }
public void doSignal(final ActivityExecution execution, final String signalName, final Object signalData) throws Exception { Object delegate = expression.getValue(execution); applyFieldDeclaration(fieldDeclarations, delegate); final ActivityBehavior activityBehaviorInstance = getActivityBehaviorInstance(execution, delegate); if (activityBehaviorInstance instanceof CustomActivityBehavior) { CustomActivityBehavior behavior = (CustomActivityBehavior) activityBehaviorInstance; ActivityBehavior delegateActivityBehavior = behavior.getDelegateActivityBehavior(); if (!(delegateActivityBehavior instanceof SignallableActivityBehavior)) { // legacy behavior: do nothing when it is not a signallable activity behavior return; } } executeWithErrorPropagation(execution, new Callable<Void>() { @Override public Void call() throws Exception { ((SignallableActivityBehavior) activityBehaviorInstance).signal(execution, signalName, signalData); return null; } }); }
protected CaseExecutionListener getListenerInstance() { Object delegateInstance = instantiateDelegate(className, fieldDeclarations); if (delegateInstance instanceof CaseExecutionListener) { return (CaseExecutionListener) delegateInstance; } else { throw LOG.missingDelegateParentClassException(delegateInstance.getClass().getName(), CaseExecutionListener.class.getName()); } }
public void doSignal(final ActivityExecution execution, final String signalName, final Object signalData) throws Exception { Object delegate = expression.getValue(execution); applyFieldDeclaration(fieldDeclarations, delegate); final ActivityBehavior activityBehaviorInstance = getActivityBehaviorInstance(execution, delegate); if (activityBehaviorInstance instanceof CustomActivityBehavior) { CustomActivityBehavior behavior = (CustomActivityBehavior) activityBehaviorInstance; ActivityBehavior delegateActivityBehavior = behavior.getDelegateActivityBehavior(); if (!(delegateActivityBehavior instanceof SignallableActivityBehavior)) { // legacy behavior: do nothing when it is not a signallable activity behavior return; } } executeWithErrorPropagation(execution, new Callable<Void>() { @Override public Void call() throws Exception { ((SignallableActivityBehavior) activityBehaviorInstance).signal(execution, signalName, signalData); return null; } }); }
protected TaskListener getTaskListenerInstance() { Object delegateInstance = instantiateDelegate(className, fieldDeclarations); if (delegateInstance instanceof TaskListener) { return (TaskListener) delegateInstance; } else { throw new ProcessEngineException(delegateInstance.getClass().getName()+" doesn't implement "+TaskListener.class); } }
public void notify(DelegateCaseExecution caseExecution) throws Exception { // Note: we can't cache the result of the expression, because the // caseExecution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}' Object delegate = expression.getValue(caseExecution); applyFieldDeclaration(fieldDeclarations, delegate); if (delegate instanceof CaseExecutionListener) { CaseExecutionListener listenerInstance = (CaseExecutionListener) delegate; Context .getProcessEngineConfiguration() .getDelegateInterceptor() .handleInvocation(new CaseExecutionListenerInvocation(listenerInstance, caseExecution)); } else { throw new ProcessEngineException("Delegate expression " + expression + " did not resolve to an implementation of " + CaseExecutionListener.class); } }
protected Object instantiateDelegateClass(ActivityExecution execution) { Object delegate = null; if (expression != null) { delegate = expression.getValue(execution); } else if (className != null) { delegate = ClassDelegateUtil.instantiateDelegate(className, null); } return delegate; }
public void notify(DelegateCaseExecution caseExecution) throws Exception { // Note: we can't cache the result of the expression, because the // caseExecution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}' Object delegate = expression.getValue(caseExecution); applyFieldDeclaration(fieldDeclarations, delegate); if (delegate instanceof CaseExecutionListener) { CaseExecutionListener listenerInstance = (CaseExecutionListener) delegate; Context .getProcessEngineConfiguration() .getDelegateInterceptor() .handleInvocation(new CaseExecutionListenerInvocation(listenerInstance, caseExecution)); } else { throw new ProcessEngineException("Delegate expression " + expression + " did not resolve to an implementation of " + CaseExecutionListener.class); } }
protected CaseExecutionListener getListenerInstance() { Object delegateInstance = instantiateDelegate(className, fieldDeclarations); if (delegateInstance instanceof CaseExecutionListener) { return (CaseExecutionListener) delegateInstance; } else { throw LOG.missingDelegateParentClassException(delegateInstance.getClass().getName(), CaseExecutionListener.class.getName()); } }