• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CommandHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: handleRegisterUserAggregate

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public UserIdentifier handleRegisterUserAggregate(RegisterUserCommand command) {
    if (log.isDebugEnabled()) {
        log.debug("Handling: " + command.getClass().getSimpleName());
    }

    UserIdentifier id = command.getUserId();
    UserAggregate u = new UserAggregate(
            id,
            UserConstants.SITE_SOURCE,
            command.getUsername(),
            passwordEncryptor.encryptPassword(command.getPassword()),
            command.getEmail(),
            command.getFirstName(),
            command.getLastName(),
            command.getProfilePictureUrl(),
            command.getGender(),
            Collections.singletonList(PlatformConstants.DEFAULT_USER_ROLE)
    );

    // persist user aggregate
    userAggregateRepository.add(u);

    return id;
}
 
开发者ID:bjornharvold,项目名称:bearchoke,代码行数:26,代码来源:UserCommandHandler.java


示例2: handleCreateUserAggregate

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public UserIdentifier handleCreateUserAggregate(CreateUserCommand command) {
    if (log.isDebugEnabled()) {
        log.debug("Handling: " + command.getClass().getSimpleName());
    }

    UserIdentifier id = command.getUserId();
    UserAggregate u = new UserAggregate(
            id,
            UserConstants.SITE_SOURCE,
            command.getUsername(),
            passwordEncryptor.encryptPassword(command.getPassword()),
            command.getEmail(),
            command.getFirstName(),
            command.getLastName(),
            command.getProfilePictureUrl(),
            command.getGender(),
            command.getRoles()
    );

    // persist user aggregate
    userAggregateRepository.add(u);

    return id;
}
 
开发者ID:bjornharvold,项目名称:bearchoke,代码行数:26,代码来源:UserCommandHandler.java


示例3: handle

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void handle(AddOrganizationAlias command) {
    AliasService aliasService = ApplicationServiceRegistry.aliasService();
    if (aliasService.isDefined(AliasGroups.USERS_AND_ORGANIZATIONS.name(), command.getAlias())) {
        if (aliasService.isIdentical(AliasGroups.USERS_AND_ORGANIZATIONS.name(), command.getAlias(), command.getOrganizationId().identifier())) {
            // idempotent, ok to register same alias and instance twice
            return;
        }
        // alias already in use by other target -> action denied
        //apply(new OrganizationAliasRegistrationDenied(command.getOrganizationId(), command.getServiceInstanceId(), command.getAlias()));
        return;
    }
    if (aliasService.hasTarget(AliasGroups.USERS_AND_ORGANIZATIONS.name(), command.getOrganizationId().identifier())) {
        apply(new OrganizationAliasAdded(command.getOrganizationId(), command.getAlias()));
    } else {
        // there's a first time for everything
        apply(new OrganizationPrimaryAliasAdded(command.getOrganizationId(), command.getAlias()));
    }
}
 
开发者ID:dma-graveyard,项目名称:MaritimeCloudPortalTestbed,代码行数:20,代码来源:Organization.java


示例4: handle

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void handle(AuthorizeMembershipToOrganizationCreator command) {

    Organization organization = repository.load(command.getOrganizationId());

    if (organization.isDeleted()) {
        throw new IllegalArgumentException("Organization exists no more. " + command.getOrganizationId());
    }

    Membership membership = new Membership(
            command.getMembershipId(), 
            command.getOrganizationId(),
            command.getUsername(), 
            "",
            Membership.ApplicationType.CREATOR
    );
    
    membershipRepository.add(membership);
}
 
开发者ID:dma-graveyard,项目名称:MaritimeCloudPortalTestbed,代码行数:20,代码来源:OrganizationCommandHandler.java


示例5: User

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public User(RegisterUser command) {
    this();
    assertValidEmailAddress(command.getEmailAddress());
    assertValidUsername(command.getPrefferedUsername());
    assertPasswordComply(command.getPrefferedUsername(), command.getPassword());
    String emailVerificationCode = new UnconfirmedEmailAddress(command.getEmailAddress()).activationCode().toString();

    // HACK: FIXME: TODO: 
    // supply hardcoded code in odrer to auto-create users for test and demo without reading mails
    emailVerificationCode = a_HACK_TEST_useStaticVerificationCode(command.getEmailAddress(), emailVerificationCode);

    apply(new UserRegistered(
            command.getUserId(),
            command.getPrefferedUsername(),
            command.getEmailAddress(),
            asEncryptedValue(command.getPassword()),
            emailVerificationCode)
    );
}
 
开发者ID:dma-graveyard,项目名称:MaritimeCloudPortalTestbed,代码行数:21,代码来源:User.java


示例6: handle

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void handle(SendResetPasswordInstructions command) {

    try {
        // lookup userId by email
        InternalUserEntry userView = internalUserQueryRepository.findByEmailAddressIgnoreCase(command.getEmailAddress());

        if (userView == null) {
            // silently ignore errors like user not found 
            return;
        }

        // lookup user aggregate
        UserId userId = new UserId(userView.getUserId());
        User user = userAggregateRepository.load(userId);
        if (!user.isDeleted()) {
            user.registerResetPasswordKey(generateResetPasswordKey());
        }

    } catch (AggregateNotFoundException e) {
        // we silently ignore errors like user not found 
    }

}
 
开发者ID:dma-graveyard,项目名称:MaritimeCloudPortalTestbed,代码行数:25,代码来源:UserCommandHandler.java


示例7: onCommand

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void onCommand(@SuppressWarnings("unused") final ChangeTestAggregate command, final MetaData metaData) {
   if (timesChanged == 5000) {
      throw new IllegalStateException("More than 5000 changes");
   }
   apply(new TestAggregateChanged(aggregateId), metaData);
}
 
开发者ID:Qyotta,项目名称:axon-eventstore,代码行数:8,代码来源:MyTestAggregate.java


示例8: onCommand

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void onCommand(final ChangeTestAggregate command, final MetaData metaData) {
   if (!command.getAggregateId().equals(aggregateId)) {
      throw new IllegalStateException("Maximum number of events reached ;)"); //$NON-NLS-1$
   }
   apply(new TestAggregateChanged(command.getAggregateId()), metaData);
}
 
开发者ID:Qyotta,项目名称:axon-eventstore,代码行数:8,代码来源:MyTestAggregate.java


示例9: markSaleable

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void markSaleable(MarkProductAsSaleableCommand command) {
    LOG.debug("Command: 'MarkProductAsSaleableCommand' received.");
    if (!this.isSaleable()) {
        apply(new ProductSaleableEvent(id));
    } else {
        throw new IllegalStateException("This ProductAggregate (" + this.getId() + ") is already Saleable.");
    }
}
 
开发者ID:benwilcock,项目名称:cf-cqrs-microservice-sampler,代码行数:10,代码来源:ProductAggregate.java


示例10: markUnsaleable

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void markUnsaleable(MarkProductAsUnsaleableCommand command) {
    LOG.debug("Command: 'MarkProductAsUnsaleableCommand' received.");
    if (this.isSaleable()) {
        apply(new ProductUnsaleableEvent(id));
    } else {
        throw new IllegalStateException("This ProductAggregate (" + this.getId() + ") is already off-sale.");
    }
}
 
开发者ID:benwilcock,项目名称:cf-cqrs-microservice-sampler,代码行数:10,代码来源:ProductAggregate.java


示例11: ShoppingCart

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public ShoppingCart(AddItemCommand command) {
	id=command.getItemId();
	//put here the business logic
	//....
	
    apply(new ItemAddedEvent(command.getItemId()));
}
 
开发者ID:feliciatucci,项目名称:cqrs-sample,代码行数:9,代码来源:ShoppingCart.java


示例12: markCompleted

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void markCompleted(MarkCompletedCommand command) {
    System.out.println("Command: 'MarkCompleted' received.");
    System.out.println("Event: 'ToDoItemCompleted' applying...");
    if(!this.isComplete()){
        apply(new ToDoItemCompletedEvent(id));
    } else {
        throw new IllegalStateException("This ToDoItem ("+this.getId()+") is already Done.");
    }
}
 
开发者ID:benwilcock,项目名称:axon-cqrs-sample,代码行数:11,代码来源:ToDoItem.java


示例13: handleCreateRoleAggregate

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public RoleIdentifier handleCreateRoleAggregate(CreateRoleCommand command) {
    if (log.isDebugEnabled()) {
        log.debug("Handling: " + command.getClass().getSimpleName());
    }
    RoleIdentifier id = command.getRoleId();
    RoleAggregate u = new RoleAggregate(id, command.getName(), command.getRights());
    roleAggregateRepository.add(u);

    return id;
}
 
开发者ID:bjornharvold,项目名称:bearchoke,代码行数:12,代码来源:RoleCommandHandler.java


示例14: handleAuthenticateUser

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
    public UserDetailsExtended handleAuthenticateUser(AuthenticateUserCommand command) {
        if (log.isDebugEnabled()) {
            log.debug("Handling: " + command.getClass().getSimpleName());
        }
        User user = userRepository.findByUsername(command.getUsername());

        if (user == null) {
            return null;
        }

        boolean success = passwordEncryptor.checkPassword(command.getPassword(), user.getPassword());

        if (log.isDebugEnabled()) {
            log.debug("Authentication successful: " + success);
        }

        // if we wanted other event listeners to know that the user was authenticated, we could mark it like so
        // A UserAuthenticatedEvent would get dispatched
//        if (success) {
//            onUser(user.getUserIdentifier()).userAuthenticated();
//        }

        return success ? new Principal(user.getId(), user.getUserIdentifier(), user.getUsername(), user.getName(),
                user.getFirstName(), user.getLastName(), user.getProfilePictureUrl(), user.getGender(),
                user.getPassword(), user.getAuthorities(), user.getNonExpired(), user.getNonLocked(), user.getCredentialsNonExpired(),
                user.getEnabled()) : null;
    }
 
开发者ID:bjornharvold,项目名称:bearchoke,代码行数:29,代码来源:UserCommandHandler.java


示例15: handleCreateToDoItem

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public ToDoIdentifier handleCreateToDoItem(CreateToDoItemCommand command) {
    ToDoIdentifier id = command.getTodoId();
    ToDoItemAggregate tdi = new ToDoItemAggregate(id, command.getDescription(), command.getUsername());
    repository.add(tdi);

    return id;
}
 
开发者ID:bjornharvold,项目名称:bearchoke,代码行数:9,代码来源:ToDoCommandHandler.java


示例16: handle

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void handle(AcceptUsersMembershipApplication command) {
    if (!acceptedByOrganization) {
        apply(new OrganizationAcceptedMembershipApplication(membershipId, organizationId, username));

        if (acceptedByUser) {
            activate();
        }
    }
}
 
开发者ID:dma-graveyard,项目名称:MaritimeCloudPortalTestbed,代码行数:11,代码来源:Membership.java


示例17: handle

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public void handle(ChangeUserEmailAddress command) {
    assertValidEmailAddress(command.getEmailAddress());
    if (!command.getEmailAddress().equalsIgnoreCase(emailAddress())) {
        String emailVerificationCode = new UnconfirmedEmailAddress(command.getEmailAddress()).activationCode().toString();

        // HACK: FIXME: TODO: 
        // supply hardcoded code in order to auto-create users for test and demo without reading mails
        emailVerificationCode = a_HACK_TEST_useStaticVerificationCode(command.getEmailAddress(), emailVerificationCode);

        apply(new UnconfirmedUserEmailAddressSupplied(command.getUserId(), this.username(), command.getEmailAddress(), emailVerificationCode));
    }
}
 
开发者ID:dma-graveyard,项目名称:MaritimeCloudPortalTestbed,代码行数:14,代码来源:User.java


示例18: DataItem

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public DataItem(DataItemCmd.Create command) {
    m_id   = null;
    m_text = null;

    apply(new DataItemEvt.Create(command.getId(),command.getText()));
}
 
开发者ID:lburgazzoli,项目名称:lb-axon,代码行数:8,代码来源:DataItem.java


示例19: OrderAggregate

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public OrderAggregate(CreateOrderCommand c) {
  Assert.hasLength(c.getDescription());
  apply(new OrderCreatedEvent(c.getId(), c.getDescription()));
}
 
开发者ID:drm317,项目名称:cloud-native-reference,代码行数:6,代码来源:OrderAggregate.java


示例20: SomeAggreagate

import org.axonframework.commandhandling.annotation.CommandHandler; //导入依赖的package包/类
@CommandHandler
public SomeAggreagate(final SomeCommand command) {
   apply(SomeEvent.builder()
         .someField(command.someValue())
         .build());
}
 
开发者ID:Herumgeisterer,项目名称:visualaxon,代码行数:7,代码来源:SomeAggregate.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Processor类代码示例发布时间:2022-05-21
下一篇:
Java ObjectProperty类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap