当前位置: 首页>>代码示例>>Java>>正文


Java CommandHandler类代码示例

本文整理汇总了Java中org.axonframework.commandhandling.CommandHandler的典型用法代码示例。如果您正苦于以下问题:Java CommandHandler类的具体用法?Java CommandHandler怎么用?Java CommandHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CommandHandler类属于org.axonframework.commandhandling包,在下文中一共展示了CommandHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handle

import org.axonframework.commandhandling.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void handle(OrgCreateCommand command) throws Exception {
    OrgEntry saved = orgDao.findByCode(command.getCode());
    if (saved != null) {
        throw new BusinessException(UCError.ORG_CODE_IS_EXIST);
    }
    if (StringUtils.isNotEmpty(command.getParentId())) {
        OrgEntry parent = orgDao.findOne(command.getParentId());
        if (parent == null) {
            throw new BusinessException(UCError.ORG_CODE_IS_EXIST);
        }
    }
    repository.newInstance(() -> {
        return new Org(command);
    });
}
 
开发者ID:weechang,项目名称:Taroco,代码行数:17,代码来源:OrgCommandHandler.java

示例2: handle

import org.axonframework.commandhandling.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void handle(RoleCreateCommand command) throws Exception {
    RoleEntry role = roleDao.findByRoleName(command.getRoleName());
    if (role != null) {
        throw new BusinessException(UCError.ROLE_IS_EXIST);
    }
    repository.newInstance(() -> {
        return new Role(command);
    });
}
 
开发者ID:weechang,项目名称:Taroco,代码行数:11,代码来源:RoleCommandHandler.java

示例3: handle

import org.axonframework.commandhandling.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void handle(UserCreateCommand command) throws Exception {
    UserEntry saved = userDao.findByUsername(command.getUsername());
    if (saved != null) {
        throw new BusinessException(UCError.USERNAME_IS_EXIST);
    }
    repository.newInstance(() -> {
        return new User(command);
    });
}
 
开发者ID:weechang,项目名称:Taroco,代码行数:11,代码来源:UserCommandHandler.java

示例4: handle

import org.axonframework.commandhandling.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void handle(DebitSourceBankAccountCommand command) {
    try {
        Aggregate<BankAccount> bankAccountAggregate = repository.load(command.getBankAccountId());
        bankAccountAggregate.execute(bankAccount -> bankAccount
                .debit(command.getAmount(), command.getBankTransferId()));
    } catch (AggregateNotFoundException exception) {
        eventBus.publish(asEventMessage(new SourceBankAccountNotFoundEvent(command.getBankTransferId())));
    }
}
 
开发者ID:AxonFramework,项目名称:AxonBank,代码行数:11,代码来源:BankAccountCommandHandler.java

示例5: BankTransfer

import org.axonframework.commandhandling.CommandHandler; //导入依赖的package包/类
@CommandHandler
public BankTransfer(CreateBankTransferCommand command) {
    apply(new BankTransferCreatedEvent(command.getBankTransferId(),
                                       command.getSourceBankAccountId(),
                                       command.getDestinationBankAccountId(),
                                       command.getAmount()));
}
 
开发者ID:AxonFramework,项目名称:AxonBank,代码行数:8,代码来源:BankTransfer.java

示例6: TaskAggregate

import org.axonframework.commandhandling.CommandHandler; //导入依赖的package包/类
@CommandHandler
public TaskAggregate(CreateTaskCommand command) {
  log.info("CreateTaskCommand received: {}", command);

  // TODO: set id here?
  this.taskId = command.getTaskId();
  TaskCreatedEvent event = new TaskCreatedEvent();
  BeanUtils.copyProperties(command, event);
  apply(event);
}
 
开发者ID:holisticon,项目名称:camunda-bpm-cloud,代码行数:11,代码来源:TaskAggregate.java

示例7: on

import org.axonframework.commandhandling.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void on(CompleteTaskCommand command) {
  log.info("CompleteTaskCommand received: {}", command);
  TaskCompletedEvent event = new TaskCompletedEvent();
  BeanUtils.copyProperties(command, event);
  apply(event);
}
 
开发者ID:holisticon,项目名称:camunda-bpm-cloud,代码行数:8,代码来源:TaskAggregate.java

示例8: Preparation

import org.axonframework.commandhandling.CommandHandler; //导入依赖的package包/类
@CommandHandler
public Preparation(PreparationCreateCommand preparationCC) {
    // check things
    Assert.hasLength(preparationCC.getName());
    // event sourcing here. Never change the state of the aggregator in commandhandlers, do so in Event handlers,
    // see @EvenSourcingHandler methods below.
    apply(new PreparationCreatedEvent(preparationCC.getId(), preparationCC.getName(), preparationCC.getDesc()));
}
 
开发者ID:Talend,项目名称:daikon,代码行数:9,代码来源:Preparation.java

示例9: stepAdd

import org.axonframework.commandhandling.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void stepAdd(StepAddCommand stepAddC) {
    if (NbOfSteps >= 2) {
        throw new IllegalArgumentException();
    }
    apply(new StepAddedEvent(id, stepAddC.getStepType()));
}
 
开发者ID:Talend,项目名称:daikon,代码行数:8,代码来源:Preparation.java

示例10: doWith

import org.axonframework.commandhandling.CommandHandler; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void doWith(final Method method) throws IllegalArgumentException, IllegalAccessException {
	if (method
			.isAnnotationPresent(
					org.axonframework.commandhandling.CommandHandler.class)) {
		result.set(true);
	}
}
 
开发者ID:kamaladafrica,项目名称:axon-cdi,代码行数:12,代码来源:AxonUtils.java

示例11: subscribe

import org.axonframework.commandhandling.CommandHandler; //导入依赖的package包/类
@Override
public <C> void subscribe(String commandName, CommandHandler<? super C> handler) {
    if(m_supportedCmds.add(commandName)) {
        m_localSegment.subscribe(commandName, handler);
        m_cmdHandlers.put(commandName, m_agent.getNodeName());
    }
}
 
开发者ID:lburgazzoli,项目名称:lb-axon,代码行数:8,代码来源:HzCommandBusConnector.java

示例12: unsubscribe

import org.axonframework.commandhandling.CommandHandler; //导入依赖的package包/类
@Override
public <C> boolean unsubscribe(String commandName, CommandHandler<? super C> handler) {
    if (m_localSegment.unsubscribe(commandName, handler)) {
        if(m_supportedCmds.remove(commandName)) {
            m_cmdHandlers.remove(commandName, m_agent.getNodeName());
        }

        return true;
    }

    return false;
}
 
开发者ID:lburgazzoli,项目名称:lb-axon,代码行数:13,代码来源:HzCommandBusConnector.java

示例13: unsubscribe

import org.axonframework.commandhandling.CommandHandler; //导入依赖的package包/类
@Override
public <C> boolean unsubscribe(String commandName, CommandHandler<? super C> handler) {
    if (m_localSegment.unsubscribe(commandName, handler)) {
        if(m_supportedCmds.remove(commandName)) {
        }

        return true;
    }

    return false;
}
 
开发者ID:lburgazzoli,项目名称:lb-axon,代码行数:12,代码来源:HzCommandBusConnector.java

示例14: handle

import org.axonframework.commandhandling.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void handle(CreateBasketCommand command) throws Exception {
    repository.newInstance(() -> new Basket(command.id()));
}
 
开发者ID:AndreasKl,项目名称:event-sourced-basket,代码行数:5,代码来源:BasketCommandHandler.java

示例15: handle

import org.axonframework.commandhandling.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void handle(String command) {
    getCommandCountDownLatch().countDown();
}
 
开发者ID:flux-capacitor-io,项目名称:flux-capacitor-client,代码行数:5,代码来源:AxonRunner.java


注:本文中的org.axonframework.commandhandling.CommandHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。