当前位置: 首页>>代码示例>>Java>>正文


Java JavaDelegate类代码示例

本文整理汇总了Java中org.activiti.engine.delegate.JavaDelegate的典型用法代码示例。如果您正苦于以下问题:Java JavaDelegate类的具体用法?Java JavaDelegate怎么用?Java JavaDelegate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JavaDelegate类属于org.activiti.engine.delegate包,在下文中一共展示了JavaDelegate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: notify

import org.activiti.engine.delegate.JavaDelegate; //导入依赖的package包/类
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);
  
  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 new ActivitiException("Delegate expression " + expression 
            + " did not resolve to an implementation of " + ExecutionListener.class 
            + " nor " + JavaDelegate.class);
  }
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:20,代码来源:DelegateExpressionExecutionListener.java

示例2: execute

import org.activiti.engine.delegate.JavaDelegate; //导入依赖的package包/类
public void execute(ActivityExecution 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);
  
  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 new ActivitiException("Delegate expression " + expression 
            + " did not resolve to an implementation of " + ActivityBehavior.class 
            + " nor " + JavaDelegate.class);
  }
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:24,代码来源:ServiceTaskDelegateExpressionActivityBehavior.java

示例3: getActivityBehaviorInstance

import org.activiti.engine.delegate.JavaDelegate; //导入依赖的package包/类
protected ActivityBehavior getActivityBehaviorInstance(ActivityExecution execution) {
  Object delegateInstance = instantiateDelegate(className, fieldDeclarations);
  
  if (delegateInstance instanceof ActivityBehavior) {
    return determineBehaviour((ActivityBehavior) delegateInstance, execution);
  } else if (delegateInstance instanceof JavaDelegate) {
    return determineBehaviour(new ServiceTaskJavaDelegateActivityBehavior((JavaDelegate) delegateInstance), execution);
  } else {
    throw new ActivitiException(delegateInstance.getClass().getName()+" doesn't implement "+JavaDelegate.class.getName()+" nor "+ActivityBehavior.class.getName());
  }
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:12,代码来源:ClassDelegate.java

示例4: testWithAListOfEndedProcesses

import org.activiti.engine.delegate.JavaDelegate; //导入依赖的package包/类
@Test
public void testWithAListOfEndedProcesses() throws Exception {
    DelegateExecution execution = mock(DelegateExecution.class);
    when(execution.getVariable(eq(PROCESS_IDS))).thenReturn(Lists.newArrayList("1", "2"));

    ProcessVariablesCollector collector = new ProcessVariablesCollector();
    collector.install(execution);

    RuntimeService runtimeService = mockRuntimeService(ImmutableMap.of(
        "1", mockProcessInstance(/* ended= */ true),
        "2", mockProcessInstance(/* ended= */ true)
    ));

    JavaDelegate delegate = new CheckProcessesEnded(runtimeService, PROCESS_IDS, RESULT);
    delegate.execute(execution);

    assertThat((Boolean) collector.getVariable(RESULT)).isTrue();
}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:19,代码来源:CheckProcessesEndedTest.java

示例5: testWithOneEndedAndOneStillRunning

import org.activiti.engine.delegate.JavaDelegate; //导入依赖的package包/类
@Test
public void testWithOneEndedAndOneStillRunning() throws Exception {
    DelegateExecution execution = mock(DelegateExecution.class);
    when(execution.getVariable(eq(PROCESS_IDS))).thenReturn(Lists.newArrayList("1", "2"));

    ProcessVariablesCollector collector = new ProcessVariablesCollector();
    collector.install(execution);

    RuntimeService runtimeService = mockRuntimeService(ImmutableMap.of(
        "1", mockProcessInstance(/* ended= */ true),
        "2", mockProcessInstance(/* ended= */ false)
    ));

    JavaDelegate delegate = new CheckProcessesEnded(runtimeService, PROCESS_IDS, RESULT);
    delegate.execute(execution);

    assertThat((Boolean) collector.getVariable(RESULT)).isFalse();
}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:19,代码来源:CheckProcessesEndedTest.java

示例6: testWithOneInvalidProcessId

import org.activiti.engine.delegate.JavaDelegate; //导入依赖的package包/类
/**
 * We consider an invalid process instance ID as ended by default
 */
@Test
public void testWithOneInvalidProcessId() throws Exception {
    DelegateExecution execution = mock(DelegateExecution.class);
    when(execution.getVariable(eq(PROCESS_IDS))).thenReturn(Lists.newArrayList("1", "invalid"));

    ProcessVariablesCollector collector = new ProcessVariablesCollector();
    collector.install(execution);

    RuntimeService runtimeService = mockRuntimeService(ImmutableMap.of(
        "1", mockProcessInstance(/* ended= */ true)), "invalid");

    JavaDelegate delegate = new CheckProcessesEnded(runtimeService, PROCESS_IDS, RESULT);
    delegate.execute(execution);

    assertThat((Boolean) collector.getVariable(RESULT)).isTrue();
}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:20,代码来源:CheckProcessesEndedTest.java

示例7: testWithRandomOpenPort

import org.activiti.engine.delegate.JavaDelegate; //导入依赖的package包/类
@Test
public void testWithRandomOpenPort() throws Exception {
    DelegateExecution execution = mock(DelegateExecution.class);

    when(execution.getVariable(eq(IsMachinePortOpen.MACHINE)))
        .thenReturn(Machine.builder().localhost().createMachine());

    ProcessVariablesCollector collector = new ProcessVariablesCollector();
    collector.install(execution);

    ServerSocket socket = null;
    try {
        socket = new ServerSocket(0);

        JavaDelegate delegate = new IsMachinePortOpen(RESULT, socket.getLocalPort());
        delegate.execute(execution);

        assertThat((Boolean) collector.getVariable(RESULT)).isTrue();

    } finally {
        if (socket != null) {
            socket.close();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:26,代码来源:IsMachinePortOpenTest.java

示例8: getActivityBehaviorInstance

import org.activiti.engine.delegate.JavaDelegate; //导入依赖的package包/类
protected ActivityBehavior getActivityBehaviorInstance(ActivityExecution execution) {
  Object delegateInstance = instantiateDelegate(className, fieldDeclarations);
  
  if (delegateInstance instanceof ActivityBehavior) {
    return determineBehaviour((ActivityBehavior) delegateInstance, execution);
  } else if (delegateInstance instanceof JavaDelegate) {
    return determineBehaviour(new ServiceTaskJavaDelegateActivityBehavior((JavaDelegate) delegateInstance), execution);
  } else {
    throw new ActivitiIllegalArgumentException(delegateInstance.getClass().getName()+" doesn't implement "+JavaDelegate.class.getName()+" nor "+ActivityBehavior.class.getName());
  }
}
 
开发者ID:springvelocity,项目名称:xbpm5,代码行数:12,代码来源:ClassDelegate.java

示例9: notify

import org.activiti.engine.delegate.JavaDelegate; //导入依赖的package包/类
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);
  ClassDelegate.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 new ActivitiIllegalArgumentException("Delegate expression " + expression 
            + " did not resolve to an implementation of " + ExecutionListener.class 
            + " nor " + JavaDelegate.class);
  }
}
 
开发者ID:springvelocity,项目名称:xbpm5,代码行数:21,代码来源:DelegateExpressionExecutionListener.java

示例10: getExecutionListenerInstance

import org.activiti.engine.delegate.JavaDelegate; //导入依赖的package包/类
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 new ActivitiException(delegateInstance.getClass().getName()+" doesn't implement "+ExecutionListener.class+" nor "+JavaDelegate.class);
  }
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:11,代码来源:ClassDelegate.java

示例11: unbindService

import org.activiti.engine.delegate.JavaDelegate; //导入依赖的package包/类
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 Activiti service from delegate cache " + name);
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:8,代码来源:BlueprintELResolver.java

示例12: javaDelegateFromExistingBean

import org.activiti.engine.delegate.JavaDelegate; //导入依赖的package包/类
protected JavaDelegate javaDelegateFromExistingBean(final Object o) throws BeansException {
    // first create a proxy that implements JavaDelegate
    // then setup logic to dispatch to a cached metadata map containing the methods on the class as well as
    // the particular runtime arguments those methods require, including access to things like @ProcessVariable annotations

    if (o instanceof JavaDelegate) {
        return (JavaDelegate) o;
    }

    final Method javaDelegateExecutionMethod =
            MethodUtils.getAccessibleMethod(JavaDelegate.class, "execute", DelegateExecution.class);

    ProxyFactory proxyFactory = new ProxyFactory(o);
    proxyFactory.setProxyTargetClass(true);
    proxyFactory.addInterface(JavaDelegate.class);
    proxyFactory.addAdvice(new MethodInterceptor() {
        @Override
        public Object invoke(MethodInvocation invocation) throws Throwable {
            // if its one type of method handle it our selves
            // by looking up the appropriate handler method and invoking it dynamically

            Method method = invocation.getMethod();

            // either its a request we can handle
            if (method.equals(javaDelegateExecutionMethod)) {
                DelegateExecution delegateExecution = (DelegateExecution) invocation.getArguments()[0];
                delegateTo(o, delegateExecution);
                return null;
            }

            // otherwise pass thru
            return invocation.proceed();
        }
    });
    return (JavaDelegate) proxyFactory.getProxy();
}
 
开发者ID:joshlong,项目名称:javaconfig-ftw,代码行数:37,代码来源:StateAnnotationBeanPostProcessor.java

示例13: testSpawnSampleProcessForLocalhost

import org.activiti.engine.delegate.JavaDelegate; //导入依赖的package包/类
@Test
public void testSpawnSampleProcessForLocalhost() throws Exception {
    DelegateExecution execution = mock(DelegateExecution.class);
    Pool pool = mock(Pool.class, withSettings().serializable());
    Software software = mock(Software.class, withSettings().serializable());
    when(software.isCachedImage()).thenReturn(false);
    when(pool.getSoftware()).thenReturn(software);
    when(execution.getVariable(eq(CoreProcessVariables.POOL))).thenReturn(pool);
    when(execution.getVariable(eq(CoreProcessVariables.POOL_BUSINESS_KEY))).thenReturn(BUSINESS_KEY);

    List<Machine> machines = Lists.newArrayList(
        Machine.builder().localhost().createMachine(),
        Machine.builder().localhost().externalId("local-2").createMachine()
    );
    when(execution.getVariable(eq(CoreProcessVariables.MACHINES))).thenReturn(machines);

    ProcessVariablesCollector collector = new ProcessVariablesCollector();
    collector.install(execution);

    ProcessEngine processEngine = new StandaloneInMemProcessEngineConfiguration()
        .setJobExecutorActivate(true).buildProcessEngine();
    processEngine.getRepositoryService().createDeployment()
        .addClasspathResource("diagrams/empty.bpmn20.xml").deploy();

    try {
        JavaDelegate delegate = new SpawnProcessForEachMachine(processEngine, EMPTY_PROCESS_KEY, "test", RESULT);
        delegate.execute(execution);

        @SuppressWarnings("unchecked")
        List<String> processInstanceIds = (List<String>) collector.getVariable(RESULT);

        assertThat(processInstanceIds).hasSize(2);

    } finally {
        processEngine.close();
    }
}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:38,代码来源:SpawnProcessForEachMachineTest.java

示例14: testWithRandomClosedPort

import org.activiti.engine.delegate.JavaDelegate; //导入依赖的package包/类
@Test
public void testWithRandomClosedPort() throws Exception {
    DelegateExecution execution = mock(DelegateExecution.class);

    when(execution.getVariable(eq(IsMachinePortOpen.MACHINE)))
        .thenReturn(Machine.builder().localhost().createMachine());

    ProcessVariablesCollector collector = new ProcessVariablesCollector();
    collector.install(execution);

    JavaDelegate delegate = new IsMachinePortOpen(RESULT, findRandomNotUsedPort());
    delegate.execute(execution);

    assertThat((Boolean) collector.getVariable(RESULT)).isFalse();
}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:16,代码来源:IsMachinePortOpenTest.java

示例15: runTest

import org.activiti.engine.delegate.JavaDelegate; //导入依赖的package包/类
private RuntimeService runTest(List<String> processIds, Map<String, ProcessInstance> processMap) throws Exception {
    DelegateExecution execution = mock(DelegateExecution.class);
    when(execution.getVariable(eq(PROCESS_IDS))).thenReturn(processIds);

    ProcessVariablesCollector collector = new ProcessVariablesCollector();
    collector.install(execution);

    RuntimeService runtimeService = mockRuntimeService(processMap, "invalid");

    JavaDelegate delegate = new KillMachineSetUpProcesses(runtimeService, PROCESS_IDS);
    delegate.execute(execution);

    return runtimeService;
}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:15,代码来源:KillMachineSetUpProcessesTest.java


注:本文中的org.activiti.engine.delegate.JavaDelegate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。