org.camunda.bpm.engine.delegate.JavaDelegate Java Examples
The following examples show how to use
org.camunda.bpm.engine.delegate.JavaDelegate.
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: DelegateExpressionExecutionListener.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void notify(DelegateExecution execution) throws Exception { // Note: we can't cache the result of the expression, because the // execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}' Object delegate = expression.getValue(execution); applyFieldDeclaration(fieldDeclarations, delegate); if (delegate instanceof ExecutionListener) { Context.getProcessEngineConfiguration() .getDelegateInterceptor() .handleInvocation(new ExecutionListenerInvocation((ExecutionListener) delegate, execution)); } else if (delegate instanceof JavaDelegate) { Context.getProcessEngineConfiguration() .getDelegateInterceptor() .handleInvocation(new JavaDelegateInvocation((JavaDelegate) delegate, execution)); } else { throw LOG.resolveDelegateExpressionException(expression, ExecutionListener.class, JavaDelegate.class); } }
Example #2
Source File: SpinApplication.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 5 votes |
@Bean public JavaDelegate spinJava8DeserializerDelegate() { return delegateExecution -> { SpinJsonNode jsonNode = S("{\"dateTime\": \"2019-12-12T22:22:22\"}"); Object key = jsonNode.mapTo(SpinJava8Dto.class); delegateExecution.setVariable("dateTime", key); }; }
Example #3
Source File: BpmnBehaviorLogger.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public ProcessEngineException resolveDelegateExpressionException(Expression expression, Class<?> parentClass, Class<JavaDelegate> javaDelegateClass) { return new ProcessEngineException(exceptionMessage( "033", "Delegate Expression '{}' did neither resolve to an implementation of '{}' nor '{}'.", expression, parentClass, javaDelegateClass )); }
Example #4
Source File: ServiceTaskDelegateExpressionActivityBehavior.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected ActivityBehavior getActivityBehaviorInstance(ActivityExecution execution, Object delegateInstance) { if (delegateInstance instanceof ActivityBehavior) { return new CustomActivityBehavior((ActivityBehavior) delegateInstance); } else if (delegateInstance instanceof JavaDelegate) { return new ServiceTaskJavaDelegateActivityBehavior((JavaDelegate) delegateInstance); } else { throw LOG.missingDelegateParentClassException(delegateInstance.getClass().getName(), JavaDelegate.class.getName(), ActivityBehavior.class.getName()); } }
Example #5
Source File: ServiceTaskDelegateExpressionActivityBehavior.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public void performExecution(final ActivityExecution execution) throws Exception { Callable<Void> callable = new Callable<Void>() { @Override public Void call() throws Exception { // Note: we can't cache the result of the expression, because the // execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}' Object delegate = expression.getValue(execution); applyFieldDeclaration(fieldDeclarations, delegate); if (delegate instanceof ActivityBehavior) { Context.getProcessEngineConfiguration() .getDelegateInterceptor() .handleInvocation(new ActivityBehaviorInvocation((ActivityBehavior) delegate, execution)); } else if (delegate instanceof JavaDelegate) { Context.getProcessEngineConfiguration() .getDelegateInterceptor() .handleInvocation(new JavaDelegateInvocation((JavaDelegate) delegate, execution)); leave(execution); } else { throw LOG.resolveDelegateExpressionException(expression, ActivityBehavior.class, JavaDelegate.class); } return null; } }; executeWithErrorPropagation(execution, callable); }
Example #6
Source File: ClassDelegateActivityBehavior.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected ActivityBehavior getActivityBehaviorInstance(ActivityExecution execution) { Object delegateInstance = instantiateDelegate(className, fieldDeclarations); if (delegateInstance instanceof ActivityBehavior) { return new CustomActivityBehavior((ActivityBehavior) delegateInstance); } else if (delegateInstance instanceof JavaDelegate) { return new ServiceTaskJavaDelegateActivityBehavior((JavaDelegate) delegateInstance); } else { throw LOG.missingDelegateParentClassException( delegateInstance.getClass().getName(), JavaDelegate.class.getName(), ActivityBehavior.class.getName() ); } }
Example #7
Source File: ClassDelegateExecutionListener.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected ExecutionListener getExecutionListenerInstance() { Object delegateInstance = instantiateDelegate(className, fieldDeclarations); if (delegateInstance instanceof ExecutionListener) { return (ExecutionListener) delegateInstance; } else if (delegateInstance instanceof JavaDelegate) { return new ServiceTaskJavaDelegateActivityBehavior((JavaDelegate) delegateInstance); } else { throw LOG.missingDelegateParentClassException(delegateInstance.getClass().getName(), ExecutionListener.class.getName(), JavaDelegate.class.getName()); } }
Example #8
Source File: SpinApplication.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Bean public JavaDelegate spinDeserializerDelegate() { return delegateExecution -> { SpinJsonNode jsonNode = S("{\"dateTime\": \"2019-12-12T22:22:22\"}"); Object key = jsonNode.mapTo(SpinDto.class); delegateExecution.setVariables(Variables.createVariables().putValueTyped("dateTime", Variables .objectValue(key) .serializationDataFormat(DataFormats.JSON_DATAFORMAT_NAME) .create())); }; }
Example #9
Source File: SpinApplication.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Bean public JavaDelegate spinJava8DeserializerDelegate() { return delegateExecution -> { SpinJsonNode jsonNode = S("{\"dateTime\": \"2019-12-12T22:22:22\"}"); Object key = jsonNode.mapTo(SpinJava8Dto.class); }; }
Example #10
Source File: SpinApplication.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Bean public JavaDelegate spinJava8DeserializerDelegate() { return delegateExecution -> { SpinJsonNode jsonNode = S("{\"dateTime\": \"2019-12-12T22:22:22\"}"); Object key = jsonNode.mapTo(SpinJava8Dto.class); delegateExecution.setVariable("dateTime", key); }; }
Example #11
Source File: BlueprintELResolver.java From camunda-bpm-platform-osgi with Apache License 2.0 | 5 votes |
/** * @param delegate the delegate, necessary parameter because of Blueprint */ public void unbindService(JavaDelegate delegate, Map<?, ?> props) { String name = (String) props.get("osgi.service.blueprint.compname"); if (delegateMap.containsKey(name)) { delegateMap.remove(name); } LOGGER.info("removed service from delegate cache " + name); }
Example #12
Source File: OSGiELResolverTest.java From camunda-bpm-platform-osgi with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Test(expected = RuntimeException.class) public void getValueForTwoJavaDelegatesWithSameName() throws InvalidSyntaxException { String lookupName = "testJavaDelegate"; ServiceReference<JavaDelegate> reference1 = mockService((JavaDelegate) new TestJavaDelegate()); ServiceReference<JavaDelegate> reference2 = mockService((JavaDelegate) new TestJavaDelegate()); registerServiceRefsAtContext(JavaDelegate.class, null, reference1, reference2); resolver.getValue(elContext, null, lookupName); }
Example #13
Source File: OSGiELResolverTest.java From camunda-bpm-platform-osgi with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Test public void getValueForTwoJavaDelegates() throws InvalidSyntaxException { String lookupName = "testJavaDelegate"; JavaDelegate serviceObject = new TestJavaDelegate(); JavaDelegate anotherServiceObject = mock(JavaDelegate.class); ServiceReference<JavaDelegate> reference1 = mockService(serviceObject); ServiceReference<JavaDelegate> reference2 = mockService(anotherServiceObject); registerServiceRefsAtContext(JavaDelegate.class, null, reference1, reference2); JavaDelegate value = (JavaDelegate) resolver.getValue(elContext, null, lookupName); assertThat(value, is(sameInstance(serviceObject))); wasPropertyResolved(); }
Example #14
Source File: OSGiELResolverTest.java From camunda-bpm-platform-osgi with Apache License 2.0 | 5 votes |
@Test public void getValueForSingleJavaDelegate() throws InvalidSyntaxException { String lookupName = "testJavaDelegate"; JavaDelegate serviceObject = new TestJavaDelegate(); ServiceReference<JavaDelegate> reference = mockService(serviceObject); registerServiceRefsAtContext(JavaDelegate.class, null, reference); JavaDelegate value = (JavaDelegate) resolver.getValue(elContext, null, lookupName); assertThat(value, is(sameInstance(serviceObject))); wasPropertyResolved(); }
Example #15
Source File: OSGiELResolverLdapMethodCallIntegrationTest.java From camunda-bpm-platform-osgi with Apache License 2.0 | 5 votes |
@Test public void runProcess() throws Exception { Hashtable<String, String> properties = new Hashtable<String, String>(); properties.put("processExpression", "thisIsAReallyNeatFeature"); JustAnotherJavaDelegate service = new JustAnotherJavaDelegate(); ctx.registerService(JavaDelegate.class, service, properties); ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceByKey("ldap"); assertThat(service.called, is(true)); assertThat(processInstance.isEnded(), is(true)); }
Example #16
Source File: OSGiELResolverLdapIntegrationTest.java From camunda-bpm-platform-osgi with Apache License 2.0 | 5 votes |
@Test public void runProcess() throws Exception { Hashtable<String, String> properties = new Hashtable<String, String>(); properties.put("processExpression", "thisIsAReallyNeatFeature"); JustAnotherJavaDelegate service = new JustAnotherJavaDelegate(); ctx.registerService(JavaDelegate.class, service, properties); ProcessInstance processInstance = processEngine.getRuntimeService() .startProcessInstanceByKey("ldap"); assertThat(service.called, is(true)); assertThat(processInstance.isEnded(), is(true)); }
Example #17
Source File: OSGiELResolverDelegateIntegrationTest.java From camunda-bpm-platform-osgi with Apache License 2.0 | 5 votes |
@Test public void runProcess() throws Exception { JustAnotherJavaDelegate service = new JustAnotherJavaDelegate(); ctx.registerService(JavaDelegate.class, service, null); ProcessInstance processInstance = processEngine.getRuntimeService() .startProcessInstanceByKey("delegate"); assertThat(service.called, is(true)); assertThat(processInstance.isEnded(), is(true)); }
Example #18
Source File: SpinApplication.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 5 votes |
@Bean public JavaDelegate spinJava8DeserializerDelegate() { return delegateExecution -> { SpinJsonNode jsonNode = S("{\"dateTime\": \"2019-12-12T22:22:22\"}"); Object key = jsonNode.mapTo(SpinJava8Dto.class); }; }
Example #19
Source File: SpinApplication.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 5 votes |
@Bean public JavaDelegate spinDeserializerDelegate() { return delegateExecution -> { SpinJsonNode jsonNode = S("{\"dateTime\": \"2019-12-12T22:22:22\"}"); Object key = jsonNode.mapTo(SpinDto.class); delegateExecution.setVariables(Variables.createVariables().putValueTyped("dateTime", Variables .objectValue(key) .serializationDataFormat(DataFormats.JSON_DATAFORMAT_NAME) .create())); }; }
Example #20
Source File: FluentJavaDelegateMock.java From camunda-bpm-mockito with Apache License 2.0 | 5 votes |
@Override public void onExecutionSetVariables(final VariableMap variables) { doAnswer(new JavaDelegate() { @Override public void execute(final DelegateExecution execution) throws Exception { setVariables(execution, variables); } }); }
Example #21
Source File: FluentJavaDelegateMock.java From camunda-bpm-mockito with Apache License 2.0 | 5 votes |
@Override public void onExecutionThrowBpmnError(final BpmnError bpmnError) { doAnswer(new JavaDelegate() { @Override public void execute(final DelegateExecution execution) throws Exception { throw bpmnError; } }); }
Example #22
Source File: FluentJavaDelegateMock.java From camunda-bpm-mockito with Apache License 2.0 | 5 votes |
@Override public void onExecutionThrowException(final Exception exception) { doAnswer(new JavaDelegate() { @Override public void execute(DelegateExecution execution) throws Exception { throw exception; } }); }
Example #23
Source File: FluentJavaDelegateMock.java From camunda-bpm-mockito with Apache License 2.0 | 5 votes |
private void doAnswer(final JavaDelegate javaDelegate) { try { Mockito.doAnswer(new JavaDelegateAnswer(javaDelegate)).when(mock).execute(any()); } catch (final Exception e) { throw new RuntimeException(e); } }
Example #24
Source File: CallActivityMock.java From camunda-bpm-mockito with Apache License 2.0 | 5 votes |
/** * On execution, the MockProcess will execute the given consumer with a DelegateExecution. * * @param serviceId ... the id of the mock delegate * @param consumer delegate for service task * @return self */ public CallActivityMock onExecutionDo(final String serviceId, final Consumer<DelegateExecution> consumer) { flowNodeBuilder = flowNodeBuilder.serviceTask(serviceId) .camundaDelegateExpression("${id}".replace("id", serviceId)); registerInstance(serviceId, (JavaDelegate) consumer::accept); return this; }
Example #25
Source File: FluentJavaDelegateMockTest.java From camunda-bpm-mockito with Apache License 2.0 | 5 votes |
@Test public void set_single_variable() throws Exception { DelegateExpressions.registerJavaDelegateMock(BEAN_NAME).onExecutionSetVariable("foo", "bar"); final JavaDelegate registeredDelegate = DelegateExpressions.getJavaDelegateMock(BEAN_NAME); final DelegateExecutionFake fake = DelegateExecutionFake.of(); registeredDelegate.execute(fake); Assertions.assertThat(fake.hasVariable("foo")).isTrue(); Assertions.assertThat((String)fake.getVariable("foo")).isEqualTo("bar"); }
Example #26
Source File: BlueprintIntegrationTest.java From camunda-bpm-platform-osgi with Apache License 2.0 | 5 votes |
@Test(timeout = 35000L) public void exportJavaDelegate() throws InterruptedException { Hashtable<String, String> properties = new Hashtable<String, String>(); properties.put("osgi.service.blueprint.compname", "testDelegate"); ctx.registerService(JavaDelegate.class.getName(), new TestDelegate(), properties); // wait a little bit ProcessDefinition definition = null; do { Thread.sleep(500L); definition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("Process_1").singleResult(); } while (definition == null); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(definition.getKey()); assertThat(processInstance.isEnded(), is(true)); assertThat(delegateVisited, is(true)); }
Example #27
Source File: OSGiELResolverLdapMethodCallWithParamIntegrationTest.java From camunda-bpm-platform-osgi with Apache License 2.0 | 5 votes |
@Test public void runProcess() throws Exception { Hashtable<String, String> properties = new Hashtable<String, String>(); properties.put("processExpression", "thisIsAReallyNeatFeature"); JustAnotherJavaDelegate service = new JustAnotherJavaDelegate(); ctx.registerService(JavaDelegate.class, service, properties); ProcessInstance processInstance = processEngine.getRuntimeService() .startProcessInstanceByKey("ldap"); assertThat(service.called, is(true)); assertThat(processInstance.isEnded(), is(true)); }
Example #28
Source File: JavaDelegateVerification.java From camunda-bpm-mockito with Apache License 2.0 | 4 votes |
public JavaDelegateVerification(final JavaDelegate mock) { super(mock, DelegateExecution.class); }
Example #29
Source File: BlueprintELResolver.java From camunda-bpm-platform-osgi with Apache License 2.0 | 4 votes |
public void bindService(JavaDelegate delegate, Map<?, ?> props) { String name = (String) props.get("osgi.service.blueprint.compname"); delegateMap.put(name, delegate); LOGGER.info("added service to delegate cache " + name); }
Example #30
Source File: JavaDelegateAnswer.java From camunda-bpm-mockito with Apache License 2.0 | 4 votes |
public JavaDelegateAnswer(final JavaDelegate javaDelegate) { this.javaDelegate = javaDelegate; }