當前位置: 首頁>>代碼示例>>Java>>正文


Java MessageEventHandler類代碼示例

本文整理匯總了Java中org.activiti.engine.impl.event.MessageEventHandler的典型用法代碼示例。如果您正苦於以下問題:Java MessageEventHandler類的具體用法?Java MessageEventHandler怎麽用?Java MessageEventHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MessageEventHandler類屬於org.activiti.engine.impl.event包,在下文中一共展示了MessageEventHandler類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initEventHandlers

import org.activiti.engine.impl.event.MessageEventHandler; //導入依賴的package包/類
protected void initEventHandlers() {
    if (eventHandlers == null) {
        eventHandlers = new HashMap<>();

        SignalEventHandler signalEventHander = new SignalEventHandler();
        eventHandlers.put(signalEventHander.getEventHandlerType(), signalEventHander);

        CompensationEventHandler compensationEventHandler = new CompensationEventHandler();
        eventHandlers.put(compensationEventHandler.getEventHandlerType(), compensationEventHandler);

        MessageEventHandler messageEventHandler = new MessageEventHandler();
        eventHandlers.put(messageEventHandler.getEventHandlerType(), messageEventHandler);

    }
    if (customEventHandlers != null) {
        for (EventHandler eventHandler : customEventHandlers) {
            eventHandlers.put(eventHandler.getEventHandlerType(), eventHandler);
        }
    }
}
 
開發者ID:flowable,項目名稱:flowable-engine,代碼行數:21,代碼來源:ProcessEngineConfigurationImpl.java

示例2: execute

import org.activiti.engine.impl.event.MessageEventHandler; //導入依賴的package包/類
@Override
protected Void execute(CommandContext commandContext, ExecutionEntity execution) {
    if (messageName == null) {
        throw new ActivitiIllegalArgumentException("messageName cannot be null");
    }

    List<EventSubscriptionEntity> eventSubscriptions = commandContext.getEventSubscriptionEntityManager()
            .findEventSubscriptionsByNameAndExecution(MessageEventHandler.EVENT_HANDLER_TYPE, messageName, executionId);

    if (eventSubscriptions.isEmpty()) {
        throw new ActivitiException("Execution with id '" + executionId + "' does not have a subscription to a message event with name '" + messageName + "'");
    }

    // there can be only one:
    EventSubscriptionEntity eventSubscriptionEntity = eventSubscriptions.get(0);

    eventSubscriptionEntity.eventReceived(payload, async);

    return null;
}
 
開發者ID:flowable,項目名稱:flowable-engine,代碼行數:21,代碼來源:MessageEventReceivedCmd.java

示例3: initEventHandlers

import org.activiti.engine.impl.event.MessageEventHandler; //導入依賴的package包/類
protected void initEventHandlers() {
  if(eventHandlers == null) {
    eventHandlers = new HashMap<String, EventHandler>();
    
    SignalEventHandler signalEventHander = new SignalEventHandler();
    eventHandlers.put(signalEventHander.getEventHandlerType(), signalEventHander);
    
    CompensationEventHandler compensationEventHandler = new CompensationEventHandler();
    eventHandlers.put(compensationEventHandler.getEventHandlerType(), compensationEventHandler);
    
    MessageEventHandler messageEventHandler = new MessageEventHandler();
    eventHandlers.put(messageEventHandler.getEventHandlerType(), messageEventHandler);
    
  }
  if(customEventHandlers != null) {
    for (EventHandler eventHandler : customEventHandlers) {
      eventHandlers.put(eventHandler.getEventHandlerType(), eventHandler);        
    }
  }
}
 
開發者ID:springvelocity,項目名稱:xbpm5,代碼行數:21,代碼來源:ProcessEngineConfigurationImpl.java

示例4: execute

import org.activiti.engine.impl.event.MessageEventHandler; //導入依賴的package包/類
protected Void execute(CommandContext commandContext, ExecutionEntity execution) {
  if(messageName == null) {
    throw new ActivitiIllegalArgumentException("messageName cannot be null");
  }
  
  List<EventSubscriptionEntity> eventSubscriptions = commandContext.getEventSubscriptionEntityManager()
    .findEventSubscriptionsByNameAndExecution(MessageEventHandler.EVENT_HANDLER_TYPE, messageName, executionId);
  
  if(eventSubscriptions.isEmpty()) {
    throw new ActivitiException("Execution with id '"+executionId+"' does not have a subscription to a message event with name '"+messageName+"'");
  }
  
  // there can be only one:
  EventSubscriptionEntity eventSubscriptionEntity = eventSubscriptions.get(0);
  
  HashMap<String, Object> payload = null;
  if(processVariables != null) {
    payload = new HashMap<String, Object>(processVariables);
  }
  
  eventSubscriptionEntity.eventReceived(payload, false);
  
  return null;
}
 
開發者ID:springvelocity,項目名稱:xbpm5,代碼行數:25,代碼來源:MessageEventReceivedCmd.java

示例5: onEvent

import org.activiti.engine.impl.event.MessageEventHandler; //導入依賴的package包/類
@Override
public void onEvent(FlowableEvent event) {
    if (isValidEvent(event) && event instanceof FlowableEngineEvent) {
        FlowableEngineEvent engineEvent = (FlowableEngineEvent) event;

        if (engineEvent.getProcessInstanceId() == null) {
            throw new ActivitiIllegalArgumentException(
                    "Cannot throw process-instance scoped message, since the dispatched event is not part of an ongoing process instance");
        }

        CommandContext commandContext = Context.getCommandContext();
        List<EventSubscriptionEntity> subscriptionEntities = commandContext.getEventSubscriptionEntityManager()
                .findEventSubscriptionsByNameAndExecution(MessageEventHandler.EVENT_HANDLER_TYPE, messageName, engineEvent.getExecutionId());

        // Revert to messaging the process instance
        if (subscriptionEntities.isEmpty() && engineEvent.getProcessInstanceId() != null &&
                !engineEvent.getExecutionId().equals(engineEvent.getProcessInstanceId())) {

            subscriptionEntities = commandContext.getEventSubscriptionEntityManager()
                    .findEventSubscriptionsByNameAndExecution(MessageEventHandler.EVENT_HANDLER_TYPE, messageName, engineEvent.getProcessInstanceId());
        }

        for (EventSubscriptionEntity signalEventSubscriptionEntity : subscriptionEntities) {
            signalEventSubscriptionEntity.eventReceived(null, false);
        }
    }
}
 
開發者ID:flowable,項目名稱:flowable-engine,代碼行數:28,代碼來源:MessageThrowingEventListener.java

示例6: removeExistingMessageEventSubscriptions

import org.activiti.engine.impl.event.MessageEventHandler; //導入依賴的package包/類
protected void removeExistingMessageEventSubscriptions(ProcessDefinitionEntity processDefinition, ProcessDefinitionEntity latestProcessDefinition) {
    // remove all subscriptions for the previous version
    if (latestProcessDefinition != null) {
        CommandContext commandContext = Context.getCommandContext();

        List<EventSubscriptionEntity> subscriptionsToDelete = commandContext
                .getEventSubscriptionEntityManager()
                .findEventSubscriptionsByTypeAndProcessDefinitionId(MessageEventHandler.EVENT_HANDLER_TYPE, latestProcessDefinition.getId(), latestProcessDefinition.getTenantId());

        for (EventSubscriptionEntity eventSubscriptionEntity : subscriptionsToDelete) {
            eventSubscriptionEntity.delete();
        }

    }
}
 
開發者ID:flowable,項目名稱:flowable-engine,代碼行數:16,代碼來源:BpmnDeployer.java

示例7: removeObsoleteMessageEventSubscriptions

import org.activiti.engine.impl.event.MessageEventHandler; //導入依賴的package包/類
protected void removeObsoleteMessageEventSubscriptions(ProcessDefinitionEntity processDefinition, ProcessDefinitionEntity latestProcessDefinition) {
  // remove all subscriptions for the previous version    
  if(latestProcessDefinition != null) {
    CommandContext commandContext = Context.getCommandContext();
    
    List<EventSubscriptionEntity> subscriptionsToDelete = commandContext
      .getEventSubscriptionManager()
      .findEventSubscriptionsByConfiguration(MessageEventHandler.TYPE, latestProcessDefinition.getId());
    
    for (EventSubscriptionEntity eventSubscriptionEntity : subscriptionsToDelete) {
      eventSubscriptionEntity.delete();        
    } 
    
  }
}
 
開發者ID:iotsap,項目名稱:FiWare-Template-Handler,代碼行數:16,代碼來源:BpmnDeployer.java

示例8: removeObsoleteMessageEventSubscriptions

import org.activiti.engine.impl.event.MessageEventHandler; //導入依賴的package包/類
protected void removeObsoleteMessageEventSubscriptions(ProcessDefinitionEntity processDefinition, ProcessDefinitionEntity latestProcessDefinition) {
  // remove all subscriptions for the previous version    
  if(latestProcessDefinition != null) {
    CommandContext commandContext = Context.getCommandContext();
    
    List<EventSubscriptionEntity> subscriptionsToDelete = commandContext
      .getEventSubscriptionEntityManager()
      .findEventSubscriptionsByConfiguration(MessageEventHandler.EVENT_HANDLER_TYPE, latestProcessDefinition.getId());
    
    for (EventSubscriptionEntity eventSubscriptionEntity : subscriptionsToDelete) {
      eventSubscriptionEntity.delete();        
    } 
    
  }
}
 
開發者ID:springvelocity,項目名稱:xbpm5,代碼行數:16,代碼來源:BpmnDeployer.java

示例9: addMessageEventSubscriptions

import org.activiti.engine.impl.event.MessageEventHandler; //導入依賴的package包/類
@SuppressWarnings("unchecked")
protected void addMessageEventSubscriptions(ProcessDefinitionEntity processDefinition) {
    CommandContext commandContext = Context.getCommandContext();
    List<EventSubscriptionDeclaration> eventDefinitions = (List<EventSubscriptionDeclaration>) processDefinition.getProperty(BpmnParse.PROPERTYNAME_EVENT_SUBSCRIPTION_DECLARATION);
    if (eventDefinitions != null) {

        Set<String> messageNames = new HashSet<>();
        for (EventSubscriptionDeclaration eventDefinition : eventDefinitions) {
            if (eventDefinition.getEventType().equals("message") && eventDefinition.isStartEvent()) {

                if (!messageNames.contains(eventDefinition.getEventName())) {
                    messageNames.add(eventDefinition.getEventName());
                } else {
                    throw new ActivitiException("Cannot deploy process definition '" + processDefinition.getResourceName()
                            + "': there multiple message event subscriptions for the message with name '" + eventDefinition.getEventName() + "'.");
                }

                // look for subscriptions for the same name in db:
                List<EventSubscriptionEntity> subscriptionsForSameMessageName = commandContext.getEventSubscriptionEntityManager()
                        .findEventSubscriptionsByName(MessageEventHandler.EVENT_HANDLER_TYPE,
                                eventDefinition.getEventName(), processDefinition.getTenantId());
                // also look for subscriptions created in the session:
                List<MessageEventSubscriptionEntity> cachedSubscriptions = commandContext
                        .getDbSqlSession()
                        .findInCache(MessageEventSubscriptionEntity.class);
                for (MessageEventSubscriptionEntity cachedSubscription : cachedSubscriptions) {
                    if (eventDefinition.getEventName().equals(cachedSubscription.getEventName())
                            && !subscriptionsForSameMessageName.contains(cachedSubscription)) {
                        subscriptionsForSameMessageName.add(cachedSubscription);
                    }
                }
                // remove subscriptions deleted in the same command
                subscriptionsForSameMessageName = commandContext
                        .getDbSqlSession()
                        .pruneDeletedEntities(subscriptionsForSameMessageName);

                for (EventSubscriptionEntity eventSubscriptionEntity : subscriptionsForSameMessageName) {
                    // throw exception only if there's already a subscription as start event
                    if (eventSubscriptionEntity.getProcessInstanceId() == null || eventSubscriptionEntity.getProcessInstanceId().isEmpty()) {
                        // the event subscription has no instance-id, so it's a message start event
                        throw new ActivitiException("Cannot deploy process definition '" + processDefinition.getResourceName()
                                + "': there already is a message event subscription for the message with name '" + eventDefinition.getEventName() + "'.");
                    }
                }

                MessageEventSubscriptionEntity newSubscription = new MessageEventSubscriptionEntity();
                newSubscription.setEventName(eventDefinition.getEventName());
                newSubscription.setActivityId(eventDefinition.getActivityId());
                newSubscription.setConfiguration(processDefinition.getId());
                newSubscription.setProcessDefinitionId(processDefinition.getId());

                if (processDefinition.getTenantId() != null) {
                    newSubscription.setTenantId(processDefinition.getTenantId());
                }

                newSubscription.insert();
            }
        }
    }
}
 
開發者ID:flowable,項目名稱:flowable-engine,代碼行數:61,代碼來源:BpmnDeployer.java

示例10: addMessageEventSubscriptions

import org.activiti.engine.impl.event.MessageEventHandler; //導入依賴的package包/類
@SuppressWarnings("unchecked")
protected void addMessageEventSubscriptions(ProcessDefinitionEntity processDefinition) {
  CommandContext commandContext = Context.getCommandContext();
  List<MessageEventDefinition> messageEventDefinitions = (List<MessageEventDefinition>) processDefinition.getProperty(BpmnParse.PROPERTYNAME_MESSAGE_EVENT_DEFINITIONS);
  if(messageEventDefinitions != null) {     
    for (MessageEventDefinition messageEventDefinition : messageEventDefinitions) {
      if(messageEventDefinition.isStartEvent()) {
        // look for subscriptions for the same name in db:
        List<EventSubscriptionEntity> subscriptionsForSameMessageName = commandContext
          .getEventSubscriptionManager()
          .findEventSubscriptionByName(MessageEventHandler.TYPE, messageEventDefinition.getName());
        // also look for subscriptions created in the session:
        List<MessageEventSubscriptionEntity> cachedSubscriptions = commandContext
          .getDbSqlSession()
          .findInCache(MessageEventSubscriptionEntity.class);
        for (MessageEventSubscriptionEntity cachedSubscription : cachedSubscriptions) {
          if(messageEventDefinition.getName().equals(cachedSubscription.getEventName())
                  && !subscriptionsForSameMessageName.contains(cachedSubscription)) {
            subscriptionsForSameMessageName.add(cachedSubscription);
          }
        }      
        // remove subscriptions deleted in the same command
        subscriptionsForSameMessageName = commandContext
                .getDbSqlSession()
                .pruneDeletedEntities(subscriptionsForSameMessageName);
              
        if(!subscriptionsForSameMessageName.isEmpty()) {
          throw new ActivitiException("Cannot deploy process definition '" + processDefinition.getResourceName()
                  + "': there already is a message event subscription for the message with name '" + messageEventDefinition.getName() + "'.");
        }
        
        MessageEventSubscriptionEntity newSubscription = new MessageEventSubscriptionEntity();
        newSubscription.setEventName(messageEventDefinition.getName());
        newSubscription.setActivityId(messageEventDefinition.getActivityId());
        newSubscription.setConfiguration(processDefinition.getId());
        
        newSubscription.insert();
      }
    }
  }      
}
 
開發者ID:iotsap,項目名稱:FiWare-Template-Handler,代碼行數:42,代碼來源:BpmnDeployer.java

示例11: addMessageEventSubscriptions

import org.activiti.engine.impl.event.MessageEventHandler; //導入依賴的package包/類
@SuppressWarnings("unchecked")
protected void addMessageEventSubscriptions(ProcessDefinitionEntity processDefinition) {
  CommandContext commandContext = Context.getCommandContext();
  List<EventSubscriptionDeclaration> messageEventDefinitions = (List<EventSubscriptionDeclaration>) processDefinition.getProperty(BpmnParse.PROPERTYNAME_EVENT_SUBSCRIPTION_DECLARATION);
  if(messageEventDefinitions != null) {     
    for (EventSubscriptionDeclaration messageEventDefinition : messageEventDefinitions) {
      if(messageEventDefinition.isStartEvent()) {
        // look for subscriptions for the same name in db:
        List<EventSubscriptionEntity> subscriptionsForSameMessageName = commandContext
          .getEventSubscriptionEntityManager()
          .findEventSubscriptionsByName(MessageEventHandler.EVENT_HANDLER_TYPE, messageEventDefinition.getEventName());
        // also look for subscriptions created in the session:
        List<MessageEventSubscriptionEntity> cachedSubscriptions = commandContext
          .getDbSqlSession()
          .findInCache(MessageEventSubscriptionEntity.class);
        for (MessageEventSubscriptionEntity cachedSubscription : cachedSubscriptions) {
          if(messageEventDefinition.getEventName().equals(cachedSubscription.getEventName())
                  && !subscriptionsForSameMessageName.contains(cachedSubscription)) {
            subscriptionsForSameMessageName.add(cachedSubscription);
          }
        }      
        // remove subscriptions deleted in the same command
        subscriptionsForSameMessageName = commandContext
                .getDbSqlSession()
                .pruneDeletedEntities(subscriptionsForSameMessageName);
              
        if(!subscriptionsForSameMessageName.isEmpty()) {
          throw new ActivitiException("Cannot deploy process definition '" + processDefinition.getResourceName()
                  + "': there already is a message event subscription for the message with name '" + messageEventDefinition.getEventName() + "'.");
        }
        
        MessageEventSubscriptionEntity newSubscription = new MessageEventSubscriptionEntity();
        newSubscription.setEventName(messageEventDefinition.getEventName());
        newSubscription.setActivityId(messageEventDefinition.getActivityId());
        newSubscription.setConfiguration(processDefinition.getId());
        
        newSubscription.insert();
      }
    }
  }      
}
 
開發者ID:springvelocity,項目名稱:xbpm5,代碼行數:42,代碼來源:BpmnDeployer.java


注:本文中的org.activiti.engine.impl.event.MessageEventHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。