本文整理汇总了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);
});
}
示例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);
});
}
示例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);
});
}
示例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())));
}
}
示例5: BankTransfer
import org.axonframework.commandhandling.CommandHandler; //导入依赖的package包/类
@CommandHandler
public BankTransfer(CreateBankTransferCommand command) {
apply(new BankTransferCreatedEvent(command.getBankTransferId(),
command.getSourceBankAccountId(),
command.getDestinationBankAccountId(),
command.getAmount()));
}
示例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);
}
示例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);
}
示例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()));
}
示例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()));
}
示例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);
}
}
示例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());
}
}
示例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;
}
示例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;
}
示例14: handle
import org.axonframework.commandhandling.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void handle(CreateBasketCommand command) throws Exception {
repository.newInstance(() -> new Basket(command.id()));
}
示例15: handle
import org.axonframework.commandhandling.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void handle(String command) {
getCommandCountDownLatch().countDown();
}