org.activiti.engine.delegate.VariableScope Java Examples
The following examples show how to use
org.activiti.engine.delegate.VariableScope.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpringExpressionManager.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override protected ELResolver createElResolver(VariableScope variableScope) { CompositeELResolver compositeElResolver = new CompositeELResolver(); compositeElResolver.add(new VariableScopeElResolver(variableScope)); if (beans != null) { // Only expose limited set of beans in expressions compositeElResolver.add(new ReadOnlyMapELResolver(beans)); } else { // Expose full application-context in expressions compositeElResolver.add(new ApplicationContextElResolver(applicationContext)); } compositeElResolver.add(new ArrayELResolver()); compositeElResolver.add(new ListELResolver()); compositeElResolver.add(new MapELResolver()); compositeElResolver.add(new JsonNodeELResolver()); compositeElResolver.add(new BeanELResolver()); return compositeElResolver; }
Example #2
Source File: ExpressionManager.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public ELContext getElContext(VariableScope variableScope) { ELContext elContext = null; if (variableScope instanceof VariableScopeImpl) { VariableScopeImpl variableScopeImpl = (VariableScopeImpl) variableScope; elContext = variableScopeImpl.getCachedElContext(); } if (elContext==null) { elContext = createElContext(variableScope); if (variableScope instanceof VariableScopeImpl) { ((VariableScopeImpl)variableScope).setCachedElContext(elContext); } } return elContext; }
Example #3
Source File: JuelExpression.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public Object getValue(VariableScope variableScope) { ELContext elContext = Context.getProcessEngineConfiguration().getExpressionManager().getElContext(variableScope); try { ExpressionGetInvocation invocation = new ExpressionGetInvocation(valueExpression, elContext); Context.getProcessEngineConfiguration() .getDelegateInterceptor() .handleInvocation(invocation); return invocation.getInvocationResult(); } catch (PropertyNotFoundException pnfe) { throw new ActivitiException("Unknown property used in expression: " + expressionText, pnfe); } catch (MethodNotFoundException mnfe) { throw new ActivitiException("Unknown method used in expression: " + expressionText, mnfe); } catch(ELException ele) { throw new ActivitiException("Error while evaluating expression: " + expressionText, ele); } catch (Exception e) { throw new ActivitiException("Error while evaluating expression: " + expressionText, e); } }
Example #4
Source File: ExpressionManager.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected ELResolver createElResolver(VariableScope variableScope) { CompositeELResolver elResolver = new CompositeELResolver(); elResolver.add(new VariableScopeElResolver(variableScope)); if(beans != null) { // ACT-1102: Also expose all beans in configuration when using standalone activiti, not // in spring-context elResolver.add(new ReadOnlyMapELResolver(beans)); } elResolver.add(new ArrayELResolver()); elResolver.add(new ListELResolver()); elResolver.add(new MapELResolver()); elResolver.add(new DynamicBeanPropertyELResolver(ItemInstance.class, "getFieldValue", "setFieldValue")); //TODO: needs verification elResolver.add(new BeanELResolver()); return elResolver; }
Example #5
Source File: DelegateExpressionUtil.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public static Object resolveDelegateExpression(Expression expression, VariableScope variableScope, List<FieldDeclaration> fieldDeclarations) { // Note: we can't cache the result of the expression, because the // execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}' Object delegate = expression.getValue(variableScope); if (fieldDeclarations != null && fieldDeclarations.size() > 0) { DelegateExpressionFieldInjectionMode injectionMode = Context.getProcessEngineConfiguration().getDelegateExpressionFieldInjectionMode(); if (injectionMode.equals(DelegateExpressionFieldInjectionMode.COMPATIBILITY)) { ClassDelegate.applyFieldDeclaration(fieldDeclarations, delegate, true); } else if (injectionMode.equals(DelegateExpressionFieldInjectionMode.MIXED)) { ClassDelegate.applyFieldDeclaration(fieldDeclarations, delegate, false); } } return delegate; }
Example #6
Source File: DelegateExpressionUtil.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public static Object resolveDelegateExpression(Expression expression, VariableScope variableScope, List<FieldDeclaration> fieldDeclarations) { // Note: we can't cache the result of the expression, because the // execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}' Object delegate = expression.getValue(variableScope); if (fieldDeclarations != null && fieldDeclarations.size() > 0) { DelegateExpressionFieldInjectionMode injectionMode = Context.getProcessEngineConfiguration().getDelegateExpressionFieldInjectionMode(); if (injectionMode.equals(DelegateExpressionFieldInjectionMode.COMPATIBILITY)) { ClassDelegate.applyFieldDeclaration(fieldDeclarations, delegate, true); } else if (injectionMode.equals(DelegateExpressionFieldInjectionMode.MIXED)) { ClassDelegate.applyFieldDeclaration(fieldDeclarations, delegate, false); } } return delegate; }
Example #7
Source File: SimpleSimulationRun.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override protected void initSimulationRunContext(VariableScope execution) {// init new process engine try { // add context in which simulation run is executed SimulationRunContext.setEventCalendar(eventCalendar); SimulationRunContext.setProcessEngine(processEngine); SimulationRunContext.setExecution(execution); // run simulation // init context and task calendar and simulation time is set to current SimulationRunContext.getClock().setCurrentTime(simulationStartDate); if (dueDate != null) SimulationRunContext.getEventCalendar().addEvent(new SimulationEvent.Builder(SimulationConstants.TYPE_END_SIMULATION).simulationTime(dueDate.getTime()).build()); } catch (Exception e) { throw new ActivitiException("Unable to initialize simulation run", e); } }
Example #8
Source File: ExpressionManager.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected ELResolver createElResolver(VariableScope variableScope) { CompositeELResolver elResolver = new CompositeELResolver(); elResolver.add(new VariableScopeElResolver(variableScope)); if (beans != null) { // ACT-1102: Also expose all beans in configuration when using // standalone activiti, not // in spring-context elResolver.add(new ReadOnlyMapELResolver(beans)); } elResolver.add(new ArrayELResolver()); elResolver.add(new ListELResolver()); elResolver.add(new MapELResolver()); elResolver.add(new JsonNodeELResolver()); elResolver.add(new DynamicBeanPropertyELResolver(ItemInstance.class, "getFieldValue", "setFieldValue")); // TODO: needs verification elResolver.add(new BeanELResolver()); return elResolver; }
Example #9
Source File: ExpressionManager.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public ELContext getElContext(VariableScope variableScope) { ELContext elContext = null; if (variableScope instanceof VariableScopeImpl) { VariableScopeImpl variableScopeImpl = (VariableScopeImpl) variableScope; elContext = variableScopeImpl.getCachedElContext(); } if (elContext == null) { elContext = createElContext(variableScope); if (variableScope instanceof VariableScopeImpl) { ((VariableScopeImpl) variableScope).setCachedElContext(elContext); } } return elContext; }
Example #10
Source File: VariableScopeResolver.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public VariableScopeResolver(ProcessEngineConfigurationImpl processEngineConfiguration, VariableScope variableScope) { this.processEngineConfiguration = processEngineConfiguration; if (variableScope == null) { throw new ActivitiIllegalArgumentException("variableScope cannot be null"); } if (variableScope instanceof ExecutionEntity) { variableScopeKey = "execution"; } else if (variableScope instanceof TaskEntity) { variableScopeKey = "task"; } else { throw new ActivitiException("unsupported variable scope type: " + variableScope.getClass().getName()); } this.variableScope = variableScope; }
Example #11
Source File: JuelExpression.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public Object getValue(VariableScope variableScope) { ELContext elContext = Context.getProcessEngineConfiguration().getExpressionManager().getElContext(variableScope); try { ExpressionGetInvocation invocation = new ExpressionGetInvocation(valueExpression, elContext); Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(invocation); return invocation.getInvocationResult(); } catch (PropertyNotFoundException pnfe) { throw new ActivitiException("Unknown property used in expression: " + expressionText, pnfe); } catch (MethodNotFoundException mnfe) { throw new ActivitiException("Unknown method used in expression: " + expressionText, mnfe); } catch (ELException ele) { throw new ActivitiException("Error while evaluating expression: " + expressionText, ele); } catch (Exception e) { throw new ActivitiException("Error while evaluating expression: " + expressionText, e); } }
Example #12
Source File: TimerJobEntityManagerImpl.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override public TimerJobEntity createAndCalculateNextTimer(JobEntity timerEntity, VariableScope variableScope) { int repeatValue = calculateRepeatValue(timerEntity); if (repeatValue != 0) { if (repeatValue > 0) { setNewRepeat(timerEntity, repeatValue); } Date newTimer = calculateNextTimer(timerEntity, variableScope); if (newTimer != null && isValidTime(timerEntity, newTimer, variableScope)) { TimerJobEntity te = createTimer(timerEntity); te.setDuedate(newTimer); return te; } } return null; }
Example #13
Source File: ScriptEventHandler.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void handle(SimulationEvent event) { ScriptingEngines scriptingEngines = Context.getProcessEngineConfiguration().getScriptingEngines(); VariableScope execution = SimulationRunContext.getExecution(); try { scriptingEngines.evaluate((String) event.getProperty(this.scriptPropertyName), language, execution, false); } catch (ActivitiException e) { log.warn("Exception while executing simulation event " + event + " scriptPropertyName :" + this.scriptPropertyName + "\n script: " + event.getProperty(this.scriptPropertyName) + "\n exception is:" + e.getMessage()); throw e; } }
Example #14
Source File: JuelExpression.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void setValue(Object value, VariableScope variableScope) { ELContext elContext = Context.getProcessEngineConfiguration().getExpressionManager().getElContext(variableScope); try { ExpressionSetInvocation invocation = new ExpressionSetInvocation(valueExpression, elContext, value); Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(invocation); } catch (Exception e) { throw new ActivitiException("Error while evaluating expression: " + expressionText, e); } }
Example #15
Source File: VariableScopeImpl.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public boolean hasVariable(String variableName) { if (hasVariableLocal(variableName)) { return true; } VariableScope parentScope = getParentVariableScope(); if (parentScope!=null) { return parentScope.hasVariable(variableName); } return false; }
Example #16
Source File: SimulationExpressionManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override protected ELResolver createElResolver(VariableScope variableScope) { CompositeELResolver compositeElResolver = new CompositeELResolver(); compositeElResolver.add(new SimulationScopeElResolver(variableScope)); compositeElResolver.add(super.createElResolver(variableScope)); return compositeElResolver; }
Example #17
Source File: ActivitiScriptBase.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
protected String getStringValue(Expression expression, VariableScope scope) { if (expression != null) { return (String) expression.getValue(scope); } return null; }
Example #18
Source File: SecureJavascriptUtil.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public static Object evaluateScript(VariableScope variableScope, String script, Map<Object, Object> beans) { Context context = Context.enter(); try { Scriptable scope = context.initStandardObjects(); SecureScriptScope secureScriptScope = new SecureScriptScope(variableScope, beans); scope.setPrototype(secureScriptScope); return context.evaluateString(scope, script, "<script>", 0, null); } finally { Context.exit(); } }
Example #19
Source File: ScriptBindingsFactory.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected List<Resolver> createResolvers(VariableScope variableScope) { List<Resolver> scriptResolvers = new ArrayList<Resolver>(); for (ResolverFactory scriptResolverFactory: resolverFactories) { Resolver resolver = scriptResolverFactory.createResolver(variableScope); if (resolver!=null) { scriptResolvers.add(resolver); } } return scriptResolvers; }
Example #20
Source File: AbstractSimulationRun.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void execute(VariableScope execution) { init(execution); runContinue(); close(); }
Example #21
Source File: ReplaySimulationRun.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override protected void initSimulationRunContext(VariableScope execution) { SimulationRunContext.setEventCalendar(eventCalendar); SimulationRunContext.setProcessEngine(processEngine); ProcessEngineConfigurationImpl configuration = (ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration(); SimulationRunContext.setSimulationRunId(configuration.getIdGenerator().getNextId()); }
Example #22
Source File: VariableScopeResolver.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public VariableScopeResolver(VariableScope variableScope) { if (variableScope==null) { throw new ActivitiIllegalArgumentException("variableScope cannot be null"); } if (variableScope instanceof ExecutionEntity) { variableScopeKey = "execution"; } else if (variableScope instanceof TaskEntity){ variableScopeKey = "task"; } else { throw new ActivitiException("unsupported variable scope type: "+variableScope.getClass().getName()); } this.variableScope = variableScope; }
Example #23
Source File: VariableScopeImpl.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public boolean hasVariables() { if (transientVariabes != null && !transientVariabes.isEmpty()) { return true; } ensureVariableInstancesInitialized(); if (!variableInstances.isEmpty()) { return true; } VariableScope parentScope = getParentVariableScope(); if (parentScope != null) { return parentScope.hasVariables(); } return false; }
Example #24
Source File: CdiExpressionManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override protected ELResolver createElResolver(VariableScope variableScope) { CompositeELResolver compositeElResolver = new CompositeELResolver(); compositeElResolver.add(new VariableScopeElResolver(variableScope)); compositeElResolver.add(new CdiResolver()); compositeElResolver.add(new ArrayELResolver()); compositeElResolver.add(new ListELResolver()); compositeElResolver.add(new MapELResolver()); compositeElResolver.add(new BeanELResolver()); return compositeElResolver; }
Example #25
Source File: VariableScopeImpl.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public boolean hasVariable(String variableName) { if (hasVariableLocal(variableName)) { return true; } VariableScope parentScope = getParentVariableScope(); if (parentScope != null) { return parentScope.hasVariable(variableName); } return false; }
Example #26
Source File: MockExpressionManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override protected ELResolver createElResolver(VariableScope variableScope) { CompositeELResolver compositeElResolver = new CompositeELResolver(); compositeElResolver.add(new VariableScopeElResolver(variableScope)); compositeElResolver.add(new MockElResolver()); compositeElResolver.add(new ArrayELResolver()); compositeElResolver.add(new ListELResolver()); compositeElResolver.add(new MapELResolver()); compositeElResolver.add(new BeanELResolver()); return compositeElResolver; }
Example #27
Source File: ScriptBindingsFactory.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected List<Resolver> createResolvers(VariableScope variableScope) { List<Resolver> scriptResolvers = new ArrayList<Resolver>(); for (ResolverFactory scriptResolverFactory : resolverFactories) { Resolver resolver = scriptResolverFactory.createResolver(processEngineConfiguration, variableScope); if (resolver != null) { scriptResolvers.add(resolver); } } return scriptResolvers; }
Example #28
Source File: TimerJobEntityManagerImpl.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected String getBusinessCalendarName(String calendarName, VariableScope variableScope) { String businessCalendarName = CycleBusinessCalendar.NAME; if (StringUtils.isNotEmpty(calendarName)) { businessCalendarName = (String) Context.getProcessEngineConfiguration().getExpressionManager() .createExpression(calendarName).getValue(variableScope); } return businessCalendarName; }
Example #29
Source File: DefaultJobManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void executeTimerJob(JobEntity timerEntity) { TimerJobEntityManager timerJobEntityManager = processEngineConfiguration.getTimerJobEntityManager(); VariableScope variableScope = null; if (timerEntity.getExecutionId() != null) { variableScope = getExecutionEntityManager().findById(timerEntity.getExecutionId()); } if (variableScope == null) { variableScope = NoExecutionVariableScope.getSharedInstance(); } // set endDate if it was set to the definition restoreExtraData(timerEntity, variableScope); if (timerEntity.getDuedate() != null && !isValidTime(timerEntity, timerEntity.getDuedate(), variableScope)) { if (logger.isDebugEnabled()) { logger.debug("Timer {} fired. but the dueDate is after the endDate. Deleting timer.", timerEntity.getId()); } processEngineConfiguration.getJobEntityManager().delete(timerEntity); return; } executeJobHandler(timerEntity); processEngineConfiguration.getJobEntityManager().delete(timerEntity); if (logger.isDebugEnabled()) { logger.debug("Timer {} fired. Deleting timer.", timerEntity.getId()); } if (timerEntity.getRepeat() != null) { TimerJobEntity newTimerJobEntity = timerJobEntityManager.createAndCalculateNextTimer(timerEntity, variableScope); if (newTimerJobEntity != null) { scheduleTimerJob(newTimerJobEntity); } } }
Example #30
Source File: DefaultJobManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected String getBusinessCalendarName(String calendarName, VariableScope variableScope) { String businessCalendarName = CycleBusinessCalendar.NAME; if (StringUtils.isNotEmpty(calendarName)) { businessCalendarName = (String) Context.getProcessEngineConfiguration().getExpressionManager() .createExpression(calendarName).getValue(variableScope); } return businessCalendarName; }