All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.activiti.springboot.ProcessDeployedEventProducer Maven / Gradle / Ivy

The newest version!
//package org.activiti.springboot;///*
//import java.io.IOException;
//import java.io.InputStream;
//import java.nio.charset.StandardCharsets;
//import java.util.ArrayList;
//import java.util.List;
//
////import org.activiti.api.process.model.ProcessDefinition;
////import org.activiti.api.process.model.events.ProcessDeployedEvent;
////import org.activiti.api.process.runtime.events.listener.ProcessRuntimeEventListener;
////import org.activiti.api.runtime.event.impl.ProcessDeployedEvents;
////import org.activiti.api.runtime.event.impl.ProcessDeployedEventImpl;
//import org.activiti.api.process.model.ProcessDefinition;
//import org.activiti.api.process.model.events.ProcessDeployedEvent;
//import org.activiti.api.process.runtime.events.listener.ProcessRuntimeEventListener;
//import org.activiti.api.runtime.event.impl.ProcessDeployedEventImpl;
//import org.activiti.api.runtime.event.impl.ProcessDeployedEvents;
//import org.activiti.engine.ActivitiException;
//import org.activiti.engine.RepositoryService;
////import org.activiti.runtime.api.model.impl.APIProcessDefinitionConverter;
//import org.activiti.runtime.api.model.impl.APIProcessDefinitionConverter;
//import org.apache.commons.io.IOUtils;
//import org.springframework.boot.WebApplicationType;
//import org.springframework.boot.context.event.ApplicationReadyEvent;
//import org.springframework.context.ApplicationEventPublisher;
//import org.springframework.context.ApplicationListener;
//
//public class ProcessDeployedEventProducer implements ApplicationListener {
//
//    private RepositoryService repositoryService;
//    private APIProcessDefinitionConverter converter;
//    private List> listeners;
//    private ApplicationEventPublisher eventPublisher;
//
//    public ProcessDeployedEventProducer(RepositoryService repositoryService,
//                                        APIProcessDefinitionConverter converter,
//                                        List> listeners,
//                                        ApplicationEventPublisher eventPublisher) {
//        this.repositoryService = repositoryService;
//        this.converter = converter;
//        this.listeners = listeners;
//        this.eventPublisher = eventPublisher;
//    }
//
//    @Override
//    public void onApplicationEvent(ApplicationReadyEvent event) {
//        if (!WebApplicationType.NONE.equals(event.getSpringApplication().getWebApplicationType())) {
//            List processDefinitions = converter.from(repositoryService.createProcessDefinitionQuery().list());
//            List processDeployedEvents = new ArrayList<>();
//            for (ProcessDefinition processDefinition : processDefinitions) {
//                try (InputStream inputStream = repositoryService.getProcessModel(processDefinition.getId())) {
//                    String xmlModel = IOUtils.toString(inputStream,
//                                                       StandardCharsets.UTF_8);
//                    ProcessDeployedEventImpl processDeployedEvent = new ProcessDeployedEventImpl(processDefinition, xmlModel);
//                    processDeployedEvents.add(processDeployedEvent);
//                    for (ProcessRuntimeEventListener listener : listeners) {
//                        listener.onEvent(processDeployedEvent);
//                    }
//                } catch (IOException e) {
//                    throw new ActivitiException("Error occurred while getting process model '" + processDefinition.getId() + "' : ",
//                                                e);
//                }
//            }
//            if (!processDeployedEvents.isEmpty()) {
//                eventPublisher.publishEvent(new ProcessDeployedEvents(processDeployedEvents));
//            }
//        }
//    }
//}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy