Search in sources :

Example 1 with ProcessHandler

use of io.seata.saga.proctrl.handler.ProcessHandler in project seata by seata.

the class ProcessControllerTests method createProcessorController.

private ProcessControllerImpl createProcessorController(ProcessCtrlEventPublisher eventPublisher) throws Exception {
    DefaultRouterHandler defaultRouterHandler = new DefaultRouterHandler();
    defaultRouterHandler.setEventPublisher(eventPublisher);
    Map<String, ProcessRouter> processRouterMap = new HashMap<>(1);
    processRouterMap.put(ProcessType.STATE_LANG.getCode(), new MockProcessRouter());
    defaultRouterHandler.setProcessRouters(processRouterMap);
    CustomizeBusinessProcessor customizeBusinessProcessor = new CustomizeBusinessProcessor();
    Map<String, ProcessHandler> processHandlerMap = new HashMap<>(1);
    processHandlerMap.put(ProcessType.STATE_LANG.getCode(), new MockProcessHandler());
    customizeBusinessProcessor.setProcessHandlers(processHandlerMap);
    Map<String, RouterHandler> routerHandlerMap = new HashMap<>(1);
    routerHandlerMap.put(ProcessType.STATE_LANG.getCode(), defaultRouterHandler);
    customizeBusinessProcessor.setRouterHandlers(routerHandlerMap);
    ProcessControllerImpl processorController = new ProcessControllerImpl();
    processorController.setBusinessProcessor(customizeBusinessProcessor);
    return processorController;
}
Also used : DefaultRouterHandler(io.seata.saga.proctrl.handler.DefaultRouterHandler) CustomizeBusinessProcessor(io.seata.saga.proctrl.process.impl.CustomizeBusinessProcessor) HashMap(java.util.HashMap) MockProcessRouter(io.seata.saga.proctrl.mock.MockProcessRouter) MockProcessHandler(io.seata.saga.proctrl.mock.MockProcessHandler) ProcessControllerImpl(io.seata.saga.proctrl.impl.ProcessControllerImpl) RouterHandler(io.seata.saga.proctrl.handler.RouterHandler) DefaultRouterHandler(io.seata.saga.proctrl.handler.DefaultRouterHandler) MockProcessRouter(io.seata.saga.proctrl.mock.MockProcessRouter) ProcessHandler(io.seata.saga.proctrl.handler.ProcessHandler) MockProcessHandler(io.seata.saga.proctrl.mock.MockProcessHandler)

Example 2 with ProcessHandler

use of io.seata.saga.proctrl.handler.ProcessHandler in project seata by seata.

the class CustomizeBusinessProcessor method process.

@Override
public void process(ProcessContext context) throws FrameworkException {
    ProcessType processType = matchProcessType(context);
    if (processType == null) {
        if (LOGGER.isWarnEnabled()) {
            LOGGER.warn("Process type not found, context= {}", context);
        }
        throw new FrameworkException(FrameworkErrorCode.ProcessTypeNotFound);
    }
    ProcessHandler processor = processHandlers.get(processType.getCode());
    if (processor == null) {
        LOGGER.error("Cannot find process handler by type {}, context= {}", processType.getCode(), context);
        throw new FrameworkException(FrameworkErrorCode.ProcessHandlerNotFound);
    }
    processor.process(context);
}
Also used : ProcessType(io.seata.saga.proctrl.ProcessType) FrameworkException(io.seata.common.exception.FrameworkException) ProcessHandler(io.seata.saga.proctrl.handler.ProcessHandler)

Example 3 with ProcessHandler

use of io.seata.saga.proctrl.handler.ProcessHandler in project seata by seata.

the class DefaultStateMachineConfig method createProcessorController.

protected ProcessControllerImpl createProcessorController(ProcessCtrlEventPublisher eventPublisher) throws Exception {
    StateMachineProcessRouter stateMachineProcessRouter = new StateMachineProcessRouter();
    stateMachineProcessRouter.initDefaultStateRouters();
    loadStateRouterInterceptors(stateMachineProcessRouter.getStateRouters());
    StateMachineProcessHandler stateMachineProcessHandler = new StateMachineProcessHandler();
    stateMachineProcessHandler.initDefaultHandlers();
    loadStateHandlerInterceptors(stateMachineProcessHandler.getStateHandlers());
    DefaultRouterHandler defaultRouterHandler = new DefaultRouterHandler();
    defaultRouterHandler.setEventPublisher(eventPublisher);
    Map<String, ProcessRouter> processRouterMap = new HashMap<>(1);
    processRouterMap.put(ProcessType.STATE_LANG.getCode(), stateMachineProcessRouter);
    defaultRouterHandler.setProcessRouters(processRouterMap);
    CustomizeBusinessProcessor customizeBusinessProcessor = new CustomizeBusinessProcessor();
    Map<String, ProcessHandler> processHandlerMap = new HashMap<>(1);
    processHandlerMap.put(ProcessType.STATE_LANG.getCode(), stateMachineProcessHandler);
    customizeBusinessProcessor.setProcessHandlers(processHandlerMap);
    Map<String, RouterHandler> routerHandlerMap = new HashMap<>(1);
    routerHandlerMap.put(ProcessType.STATE_LANG.getCode(), defaultRouterHandler);
    customizeBusinessProcessor.setRouterHandlers(routerHandlerMap);
    ProcessControllerImpl processorController = new ProcessControllerImpl();
    processorController.setBusinessProcessor(customizeBusinessProcessor);
    return processorController;
}
Also used : DefaultRouterHandler(io.seata.saga.proctrl.handler.DefaultRouterHandler) CustomizeBusinessProcessor(io.seata.saga.proctrl.process.impl.CustomizeBusinessProcessor) StateMachineProcessHandler(io.seata.saga.engine.pcext.StateMachineProcessHandler) HashMap(java.util.HashMap) StateMachineProcessRouter(io.seata.saga.engine.pcext.StateMachineProcessRouter) ProcessRouter(io.seata.saga.proctrl.ProcessRouter) ProcessControllerImpl(io.seata.saga.proctrl.impl.ProcessControllerImpl) StateMachineProcessRouter(io.seata.saga.engine.pcext.StateMachineProcessRouter) DefaultRouterHandler(io.seata.saga.proctrl.handler.DefaultRouterHandler) RouterHandler(io.seata.saga.proctrl.handler.RouterHandler) ProcessHandler(io.seata.saga.proctrl.handler.ProcessHandler) StateMachineProcessHandler(io.seata.saga.engine.pcext.StateMachineProcessHandler)

Aggregations

ProcessHandler (io.seata.saga.proctrl.handler.ProcessHandler)3 DefaultRouterHandler (io.seata.saga.proctrl.handler.DefaultRouterHandler)2 RouterHandler (io.seata.saga.proctrl.handler.RouterHandler)2 ProcessControllerImpl (io.seata.saga.proctrl.impl.ProcessControllerImpl)2 CustomizeBusinessProcessor (io.seata.saga.proctrl.process.impl.CustomizeBusinessProcessor)2 HashMap (java.util.HashMap)2 FrameworkException (io.seata.common.exception.FrameworkException)1 StateMachineProcessHandler (io.seata.saga.engine.pcext.StateMachineProcessHandler)1 StateMachineProcessRouter (io.seata.saga.engine.pcext.StateMachineProcessRouter)1 ProcessRouter (io.seata.saga.proctrl.ProcessRouter)1 ProcessType (io.seata.saga.proctrl.ProcessType)1 MockProcessHandler (io.seata.saga.proctrl.mock.MockProcessHandler)1 MockProcessRouter (io.seata.saga.proctrl.mock.MockProcessRouter)1