当前位置: 首页>>代码示例>>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;未经允许,请勿转载。