EventSubProcessStartEventActivityBehavior.java 2.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.activiti5.engine.impl.bpmn.behavior;

import java.util.Collections;

17
import org.activiti.engine.delegate.DelegateExecution;
18 19 20 21
import org.activiti5.engine.impl.pvm.delegate.ActivityExecution;
import org.activiti5.engine.impl.pvm.process.ActivityImpl;
import org.activiti5.engine.impl.pvm.runtime.InterpretableExecution;

22

23 24 25
/**
 * Specialization of the Start Event for Event Sub-Processes.
 * 
26 27
 * Assumes that we enter with the "right" execution, 
 * which is the top-most execution for the current scope
28 29 30 31 32
 * 
 * @author Daniel Meyer
 * @author Falko Menge
 */
public class EventSubProcessStartEventActivityBehavior extends NoneStartEventActivityBehavior {
33
  
34 35 36
  // default = true
  protected boolean isInterrupting = true;
  protected String activityId;
37
  
38 39 40
  public EventSubProcessStartEventActivityBehavior(String activityId) {
    this.activityId = activityId;
  }
41
  
42
  @Override
43 44
  public void execute(DelegateExecution execution) {
    ActivityExecution activityExecution = (ActivityExecution) execution;
45 46
    InterpretableExecution interpretableExecution = (InterpretableExecution) execution;
    ActivityImpl activity = interpretableExecution.getProcessDefinition().findActivity(activityId);
47
    
48
    ActivityExecution outgoingExecution = activityExecution;
49 50
    
    if(isInterrupting) {
51
      activityExecution.destroyScope("Event subprocess triggered using activity "+ activityId);
52
    } else{ 
53
      outgoingExecution = activityExecution.createExecution();
54 55 56 57
      outgoingExecution.setActive(true);
      outgoingExecution.setScope(false);
      outgoingExecution.setConcurrent(true);
    }
58
    
59
    // set the outgoing execution to this activity
60 61
    ((InterpretableExecution)outgoingExecution).setActivity(activity);
    
62 63 64
    // continue execution
    outgoingExecution.takeAll(activity.getOutgoingTransitions(), Collections.EMPTY_LIST);
  }
T
Tijs Rademakers 已提交
65

66 67 68
  public void setInterrupting(boolean b) {
    isInterrupting = b;
  }
69
  
70 71 72
  public boolean isInterrupting() {
    return isInterrupting;
  }
73
  
74
}