org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener Java Examples

The following examples show how to use org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener. 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: JobDefinitionDeletionWithParseListenerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ProcessEngineConfiguration configureEngine(ProcessEngineConfigurationImpl configuration) {
  List<BpmnParseListener> listeners = new ArrayList<>();
  listeners.add(new AbstractBpmnParseListener(){

    @Override
    public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope, ActivityImpl activity) {
      activity.setAsyncBefore(false);
    }
  });

  configuration.setCustomPreBPMNParseListeners(listeners);
  return configuration;
}
 
Example #2
Source File: CustomBpmConfig.java    From wecube-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void preInit(SpringProcessEngineConfiguration processEngineConfiguration) {
    super.preInit(processEngineConfiguration);

    List<BpmnParseListener> preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners();
    if (preParseListeners == null) {
        preParseListeners = new ArrayList<BpmnParseListener>();
        processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners);
    }

    log.info("adding LocalBpmnParseListener:{}", processStartAndEndEventInitializer.getClass().getName());

    preParseListeners.add(processStartAndEndEventInitializer);
}
 
Example #3
Source File: SendEventListenerPlugin.java    From camunda-spring-boot-amqp-microservice-cloud-example with Apache License 2.0 5 votes vote down vote up
@Override
public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
	if (processEngineConfiguration.getCustomPostBPMNParseListeners() == null) {
		processEngineConfiguration.setCustomPostBPMNParseListeners(new ArrayList<BpmnParseListener>());
	}
	processEngineConfiguration.getCustomPostBPMNParseListeners().add(new AddSendEventListenerToBpmnParseListener());

}
 
Example #4
Source File: JobDefinitionCreationAndDeletionWithParseListenerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ProcessEngineConfiguration configureEngine(ProcessEngineConfigurationImpl configuration) {
  List<BpmnParseListener> listeners = new ArrayList<>();
  listeners.add(new AbstractBpmnParseListener(){

    @Override
    public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope, ActivityImpl activity) {
      activity.setAsyncBefore(false);
      activity.setAsyncAfter(true);
    }
  });

  configuration.setCustomPreBPMNParseListeners(listeners);
  return configuration;
}
 
Example #5
Source File: ProcessCoverageConfigurator.java    From camunda-bpm-process-test-coverage with Apache License 2.0 5 votes vote down vote up
private static void initializePathCoverageParseListener(ProcessEngineConfigurationImpl configuration) {
    List<BpmnParseListener> bpmnParseListeners = configuration.getCustomPostBPMNParseListeners();
    if (bpmnParseListeners == null) {
        bpmnParseListeners = new LinkedList<BpmnParseListener>();
        configuration.setCustomPostBPMNParseListeners(bpmnParseListeners);
    }

    bpmnParseListeners.add(new PathCoverageParseListener());
}
 
Example #6
Source File: JobDefinitionCreationWithParseListenerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ProcessEngineConfiguration configureEngine(ProcessEngineConfigurationImpl configuration) {
  List<BpmnParseListener> listeners = new ArrayList<>();
  listeners.add(new AbstractBpmnParseListener(){

    @Override
    public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope, ActivityImpl activity) {
      activity.setAsyncBefore(true);
    }
  });

  configuration.setCustomPreBPMNParseListeners(listeners);
  return configuration;
}
 
Example #7
Source File: JobDefinitionCreationBothAsyncWithParseListenerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public ProcessEngineConfiguration configureEngine(ProcessEngineConfigurationImpl configuration) {
  List<BpmnParseListener> listeners = new ArrayList<>();
  listeners.add(new AbstractBpmnParseListener(){

    @Override
    public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope, ActivityImpl activity) {
      activity.setAsyncBefore(true);
      activity.setAsyncAfter(true);
    }
  });

  configuration.setCustomPreBPMNParseListeners(listeners);
  return configuration;
}
 
Example #8
Source File: OSGiEventBridgeIntegrationTest.java    From camunda-bpm-platform-osgi with Apache License 2.0 5 votes vote down vote up
private ProcessEngine createProcessEngine() {
  StandaloneInMemProcessEngineConfiguration configuration = new StandaloneInMemProcessEngineConfiguration();
  configuration.setCustomPreBPMNParseListeners(Collections.<BpmnParseListener> singletonList(eventBridgeActivator));
  configuration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
  ProcessEngineFactoryWithELResolver engineFactory = new ProcessEngineFactoryWithELResolver();
  engineFactory.setProcessEngineConfiguration(configuration);
  engineFactory.setBundle(bundleContext.getBundle());
  engineFactory.setExpressionManager(new OSGiExpressionManager());
  engineFactory.init();
  return engineFactory.getObject();
}
 
Example #9
Source File: ConnectProcessEnginePlugin.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private void addConnectorParseListener(ProcessEngineConfigurationImpl processEngineConfiguration) {
  List<BpmnParseListener> preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners();
  if(preParseListeners == null) {
    preParseListeners = new ArrayList<BpmnParseListener>();
    processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners);
  }
  preParseListeners.add(new ConnectorParseListener());
}
 
Example #10
Source File: ProcessApplicationEventListenerPlugin.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
  List<BpmnParseListener> preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners();
  if(preParseListeners == null) {
    preParseListeners = new ArrayList<BpmnParseListener>();
    processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners);
  }
  preParseListeners.add(new ProcessApplicationEventParseListener());
}
 
Example #11
Source File: ProcessEngineConfigurationImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected List<BpmnParseListener> getDefaultBPMNParseListeners() {
  List<BpmnParseListener> defaultListeners = new ArrayList<>();
  if (!HistoryLevel.HISTORY_LEVEL_NONE.equals(historyLevel)) {
    defaultListeners.add(new HistoryParseListener(historyEventProducer));
  }
  if (isMetricsEnabled) {
    defaultListeners.add(new MetricsBpmnParseListener());
  }
  return defaultListeners;
}
 
Example #12
Source File: ProcessEngineConfigurationImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public List<BpmnParseListener> getCustomPreBPMNParseListeners() {
  return preParseListeners;
}
 
Example #13
Source File: ProcessEngineConfigurationImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
/**
 * @deprecated use {@link #setCustomPostBPMNParseListeners} instead.
 */
@Deprecated
public void setPostParseListeners(List<BpmnParseListener> postParseListeners) {
  this.postParseListeners = postParseListeners;
}
 
Example #14
Source File: ProcessEngineConfigurationImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
/**
 * @deprecated use {@link #getCustomPostBPMNParseListeners} instead.
 */
@Deprecated
public List<BpmnParseListener> getPostParseListeners() {
  return postParseListeners;
}
 
Example #15
Source File: ProcessEngineConfigurationImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
/**
 * @deprecated use {@link #setCustomPreBPMNParseListeners} instead.
 */
@Deprecated
public void setPreParseListeners(List<BpmnParseListener> preParseListeners) {
  this.preParseListeners = preParseListeners;
}
 
Example #16
Source File: ProcessEngineConfigurationImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
/**
 * @deprecated use {@link #getCustomPreBPMNParseListeners} instead.
 */
@Deprecated
public List<BpmnParseListener> getPreParseListeners() {
  return preParseListeners;
}
 
Example #17
Source File: ProcessEngineConfigurationImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void setCustomPostBPMNParseListeners(List<BpmnParseListener> postParseListeners) {
  this.postParseListeners = postParseListeners;
}
 
Example #18
Source File: ProcessEngineConfigurationImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public List<BpmnParseListener> getCustomPostBPMNParseListeners() {
  return postParseListeners;
}
 
Example #19
Source File: ProcessEngineConfigurationImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void setCustomPreBPMNParseListeners(List<BpmnParseListener> preParseListeners) {
  this.preParseListeners = preParseListeners;
}
 
Example #20
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 4 votes vote down vote up
public ActivityImpl parseServiceTaskLike(String elementName, Element serviceTaskElement, ScopeImpl scope) {
    logger.debug("parse service task like element,elementName={}", elementName);

    ActivityImpl activity = createActivityOnScope(serviceTaskElement, scope);

    String type = serviceTaskElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, TYPE);
    String className = serviceTaskElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, PROPERTYNAME_CLASS);
    String expression = serviceTaskElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, PROPERTYNAME_EXPRESSION);
    String delegateExpression = serviceTaskElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS,
            PROPERTYNAME_DELEGATE_EXPRESSION);
    String resultVariableName = parseResultVariable(serviceTaskElement);

    parseAsynchronousContinuationForActivity(serviceTaskElement, activity);

    parseServiceTaskLikeAttributes(elementName, serviceTaskElement, scope, activity, type, className, expression,
            delegateExpression, resultVariableName);

    parseExecutionListenersOnScope(serviceTaskElement, activity);

    for (BpmnParseListener parseListener : parseListeners) {
        parseListener.parseServiceTask(serviceTaskElement, scope, activity);
    }

    if (activity.getActivityBehavior() == null) {
        String defaultDelegateExpression = "${taskDispatcher}";
        if (resultVariableName != null) {
            addError(PREFIX_ERROR_MSG_VARIABLE_NAME + elementName + " elements using 'delegateExpression'",
                    serviceTaskElement);
        }

        activity.setActivityBehavior(new ServiceTaskDelegateExpressionActivityBehavior(
                expressionManager.createExpression(defaultDelegateExpression),
                parseFieldDeclarations(serviceTaskElement)));
    }

    // activity behavior could be set by a listener (e.g. connector); thus,
    // check is after listener invocation
    if (activity.getActivityBehavior() == null) {
        addError("One of the attributes 'class', 'delegateExpression', 'type', or 'expression' is mandatory on "
                + elementName + ".", serviceTaskElement);
    }

    return activity;
}
 
Example #21
Source File: MostUsefulProcessEngineConfiguration.java    From camunda-bpm-mockito with Apache License 2.0 4 votes vote down vote up
public void addCustomPostBpmnParseListener(final BpmnParseListener bpmnParseListener) {
  getCustomPostBPMNParseListeners().add(Objects.requireNonNull(bpmnParseListener));
}
 
Example #22
Source File: ReactorProcessEnginePlugin.java    From camunda-bpm-reactor with Apache License 2.0 4 votes vote down vote up
private static List<BpmnParseListener> customPreBPMNParseListeners(final ProcessEngineConfigurationImpl processEngineConfiguration) {
  if (processEngineConfiguration.getCustomPreBPMNParseListeners() == null) {
    processEngineConfiguration.setCustomPreBPMNParseListeners(new ArrayList<>());
  }
  return processEngineConfiguration.getCustomPreBPMNParseListeners();
}
 
Example #23
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 4 votes vote down vote up
protected void parseEndEvent(Element parentElement, ScopeImpl scope, Element endEventElement) {
    ActivityImpl activity = createActivityOnScope(endEventElement, scope);

    Element errorEventDefinition = endEventElement.element(ERROR_EVENT_DEFINITION);
    Element cancelEventDefinition = endEventElement.element(CANCEL_EVENT_DEFINITION);
    Element terminateEventDefinition = endEventElement.element("terminateEventDefinition");
    Element messageEventDefinitionElement = endEventElement.element(MESSAGE_EVENT_DEFINITION);
    Element signalEventDefinition = endEventElement.element(SIGNAL_EVENT_DEFINITION);
    Element compensateEventDefinitionElement = endEventElement.element(COMPENSATE_EVENT_DEFINITION);
    Element escalationEventDefinition = endEventElement.element(ESCALATION_EVENT_DEFINITION);

    if (errorEventDefinition != null) { // error end event
        parseErrorEventDefinition(parentElement, scope, endEventElement, activity, errorEventDefinition);
    } else if (cancelEventDefinition != null) {
        parseCancelEventDefinition(parentElement, scope, endEventElement, activity, cancelEventDefinition);
    } else if (terminateEventDefinition != null) {
        parseTerminateEventDefinition(parentElement, scope, endEventElement, activity, terminateEventDefinition);
    } else if (messageEventDefinitionElement != null) {
        parseMessageEventDefinitionElement(parentElement, scope, endEventElement, activity,
                messageEventDefinitionElement);
    } else if (signalEventDefinition != null) {
        parseSignalEventDefinition(parentElement, scope, endEventElement, activity, signalEventDefinition);
    } else if (compensateEventDefinitionElement != null) {
        parseCompensateEventDefinitionElement(parentElement, scope, endEventElement, activity,
                compensateEventDefinitionElement);
    } else if (escalationEventDefinition != null) {
        parseEscalationEventDefinition(parentElement, scope, endEventElement, activity, escalationEventDefinition);
    } else { // default: none end event
        activity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.END_EVENT_NONE);
        activity.setActivityBehavior(new NoneEndEventActivityBehavior());
    }

    if (activity != null) {
        parseActivityInputOutput(endEventElement, activity);
    }

    parseAsynchronousContinuationForActivity(endEventElement, activity);

    parseExecutionListenersOnScope(endEventElement, activity);

    for (BpmnParseListener parseListener : parseListeners) {
        parseListener.parseEndEvent(endEventElement, scope, activity);
    }
}
 
Example #24
Source File: TestCoverageProcessEngineRule.java    From camunda-bpm-process-test-coverage with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the test run state for the coverage listeners. logging.
 * {@see ProcessCoverageInMemProcessEngineConfiguration}
 */
private void initializeListenerRunState() {

    final ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration();

    // Configure activities listener

    final FlowNodeHistoryEventHandler historyEventHandler = (FlowNodeHistoryEventHandler) processEngineConfiguration.getHistoryEventHandler();
    historyEventHandler.setCoverageTestRunState(coverageTestRunState);

    // Configure sequence flow listener

    final List<BpmnParseListener> bpmnParseListeners = processEngineConfiguration.getCustomPostBPMNParseListeners();

    for (BpmnParseListener parseListener : bpmnParseListeners) {

        if (parseListener instanceof PathCoverageParseListener) {

            final PathCoverageParseListener listener = (PathCoverageParseListener) parseListener;
            listener.setCoverageTestRunState(coverageTestRunState);
        }
    }

    // Compensation event handler

    final EventHandler compensationEventHandler = processEngineConfiguration.getEventHandler("compensate");
    if (compensationEventHandler != null && compensationEventHandler instanceof CompensationEventCoverageHandler) {

        final CompensationEventCoverageHandler compensationEventCoverageHandler = (CompensationEventCoverageHandler) compensationEventHandler;
        compensationEventCoverageHandler.setCoverageTestRunState(coverageTestRunState);

    } else {
        logger.warning("CompensationEventCoverageHandler not registered with process engine configuration!"
                + " Compensation boundary events coverage will not be registered.");
    }

}