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

Java EventHandler类代码示例

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

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



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

示例1: handle

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
public void handle(TwistRatedEvent event) {
    Twist twist = Twist.find.byId(event.getTwistId());
    if (twist != null) {
        switch (event.getRating()) {
            case 1:
                twist.likeCount++;
                break;
            case 0:
                twist.neutralCount++;
                break;
            case -1:
                twist.dislikeCount++;
                break;
        }
        System.out.println("Added rating for twist:" + event.getTwistId() + " (rating:" + event.getRating() + ")");
        twist.save();
    }
}
 
开发者ID:tipsy,项目名称:twistrating,代码行数:20,代码来源:RatingEventHandler.java


示例2: onUserCreated

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
public void onUserCreated(UserCreatedEvent event) {
    if (log.isDebugEnabled()) {
        log.debug("Caught: " + event.getClass().getSimpleName());
    }

    this.id = event.getUserId();
    this.source = event.getSource();
    this.username = event.getUsername();
    this.password = event.getPassword();
    this.email = event.getEmail();
    this.firstName = event.getFirstName();
    this.lastName = event.getLastName();
    this.profilePictureUrl = event.getProfilePictureUrl();
    this.gender = event.getGender();
    this.roles = event.getRoles();
}
 
开发者ID:bjornharvold,项目名称:bearchoke,代码行数:18,代码来源:UserAggregate.java


示例3: handleCreateUser

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
public void handleCreateUser(UserCreatedEvent event) {
    if (log.isDebugEnabled()) {
        log.debug("Caught: " + event.getClass().getSimpleName());
    }

    User user = new User(event);
    if (event.getRoles() != null && event.getRoles().size() > 0) {
        for (String roleName : event.getRoles()) {
            Role role = roleRepository.findByName(roleName);

            if (role != null) {
                user.addRole(role);
            }
        }
    }

    user = userRepository.save(user);

    if (log.isDebugEnabled()) {
        log.debug("Saved user object: " + user.toString());
    }
}
 
开发者ID:bjornharvold,项目名称:bearchoke,代码行数:24,代码来源:UserEventListener.java


示例4: on

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
public void on(OrganizationMembershipAssignedToOwner event) {
    logger.debug("About to handle the OrganizationMembershipAssignedToOwner: {}", event);
    OrganizationMembershipEntry entry = organizationMemberQueryRepository.findOne(event.getMembershipId().identifier());
    if (entry == null) {
        // new organization
        entry = new OrganizationMembershipEntry();
        entry.setMembershipId(event.getMembershipId().identifier());
        entry.setOrganizationId(event.getOrganizationId().identifier());
        entry.setUsername(event.getUsername());
    }
    entry.setAcceptedByOrganization(true);
    entry.setAcceptedByUser(true);
    entry.setActive(true);
    organizationMemberQueryRepository.save(entry);
}
 
开发者ID:dma-graveyard,项目名称:MaritimeCloudPortalTestbed,代码行数:17,代码来源:OrganizationMembershipListener.java


示例5: on

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
@Subscribe
public void on(Task_mixinActAbstract.ActionDomainEvent ev) {
    if(ev.getSemantics().isSafeInNature()) {
        return;
    }

    final Class stateTransitionClass = ev.getStateTransitionClass();
    final Task task = (Task) ev.getMixedIn();
    final StateTransition transition = stateTransitionService.findFor(task);
    if(transition == null) {
        // shouldn't occur
        return;
    }
    final Class taskTransitionClass = stateTransitionService.transitionClassFor(transition.getTransitionType());
    if(stateTransitionClass != taskTransitionClass) {
        // just ignore; this mixin action on task doesn't apply to the domain object that the task applies to.

        // or, maybe should hide (and then we can delete code in the subtypes of the mixinAbstract
        return;
    }

    final Object domainObject = transition.getDomainObject();
    applyPolicy(stateTransitionClass, domainObject, ev);
}
 
开发者ID:estatio,项目名称:estatio,代码行数:26,代码来源:EnforceTaskAssignmentPolicySubscriber.java


示例6: on

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
@Subscribe
public void on(Communication.IconUiEvent ev) {
    if(ev.getIconName() != null) {
        return;
    }
    switch (ev.getSource().getType()) {
    case POSTAL_ADDRESS:
        ev.setIconName("postal");
        break;
    case EMAIL_ADDRESS:
        ev.setIconName("email");
        break;
    case PHONE_NUMBER:
        break;
    case FAX_NUMBER:
        break;
    }
}
 
开发者ID:estatio,项目名称:estatio,代码行数:20,代码来源:Communication.java


示例7: on

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
@Subscribe
public void on(Document.IconUiEvent ev) {
    if(ev.getIconName() != null) {
        return;
    }
    final Document document = ev.getSource();
    final String documentName = document.getName();
    String iconName = "";
    if(documentName.endsWith(".xls") || documentName.endsWith(".xlsx")) {
        iconName = "xlsx";
    }
    if(documentName.endsWith(".doc") || documentName.endsWith(".docx")) {
        iconName = "docx";
    }
    if(documentName.endsWith(".ppt") || documentName.endsWith(".pptx")) {
        iconName = "pptx";
    }
    if(documentName.endsWith(".pdf")) {
        iconName = "pdf";
    }
    if(documentName.endsWith(".html")) {
        iconName = "html";
    }
    ev.setIconName(iconName);
}
 
开发者ID:estatio,项目名称:estatio,代码行数:27,代码来源:Document.java


示例8: handle

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
public void handle(ProductSaleableEvent event) {
    LOG.info("ProductSaleableEvent: [{}]", event.getId());
    if (productRepository.exists(event.getId())) {
        Product product = productRepository.findOne(event.getId());
        if (!product.isSaleable()) {
            product.setSaleable(true);
            productRepository.save(product);
        }
    }
}
 
开发者ID:benwilcock,项目名称:cf-cqrs-microservice-sampler,代码行数:12,代码来源:ProductViewEventHandler.java


示例9: on

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
void on(ItemHasBeenMarkedAsPicked event) {
    AllTimeTopPickers picker = this.repository.findOne(event.getStoreAssistantId().toString());
    picker.increment();

    repository.save(picker);
}
 
开发者ID:psamatt,项目名称:OrderFulfilmentCQRSDemo,代码行数:8,代码来源:AllTimeTopPickersProjector.java


示例10: on

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
void on(ItemHasBeenMarkedAsPicked event) {
    String id = buildId(event.getOrderId(), event.getSku(), event.getStoreAssistantId());

    StoreAssistantPickedItem mostPicked = new StoreAssistantPickedItem(id, event.getSku().toString(), event.getStoreAssistantId().toString(), event.getStoreAssistantName());
    this.repository.save(mostPicked);
}
 
开发者ID:psamatt,项目名称:OrderFulfilmentCQRSDemo,代码行数:8,代码来源:StoreAssistantPickedItemProjector.java


示例11: on

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
void on(DeliverySlotReserved event) {
    AvailableSlotsForDay daySlots = repository.findOne(event.getDeliveryDayId().toString());
    daySlots.decrementCapacity();

    repository.save(daySlots);
}
 
开发者ID:psamatt,项目名称:OrderFulfilmentCQRSDemo,代码行数:8,代码来源:AvailableSlotsForDayProjector.java


示例12: on

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
void on(NewReaderRegisteredEvent event) {
	
	ReaderEntry reader = new ReaderEntry();
	reader.setId(event.getReaderId());
	reader.setLibraryId(event.getLibraryId());
	reader.setName(event.getName());
	readerRepository.save(reader);
}
 
开发者ID:yizhuan,项目名称:library-saga,代码行数:10,代码来源:ReaderEventListener.java


示例13: on

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
void on(NewBookRegisteredEvent event) {
	BookEntry book = new BookEntry();
	book.setId(event.getBookId());
	book.setLibraryId(event.getLibraryId());
	book.setTitle(event.getTitle());
	book.setAuthor(event.getAuthor());
	book.setBorrowerId(null);
	bookEntryRepository.save(book);
}
 
开发者ID:yizhuan,项目名称:library-saga,代码行数:11,代码来源:BookEventListener.java


示例14: onRoleCreated

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
public void onRoleCreated(RoleCreatedEvent event) {
    if (log.isDebugEnabled()) {
        log.debug("Caught: " + event.getClass().getSimpleName());
    }

    this.id = event.getRoleId();
    this.name = event.getName();
    this.rights = event.getRights();
}
 
开发者ID:bjornharvold,项目名称:bearchoke,代码行数:11,代码来源:RoleAggregate.java


示例15: handleCreateRole

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
public void handleCreateRole(RoleCreatedEvent event) {
    if (log.isDebugEnabled()) {
        log.debug("Caught: " + event.getClass().getSimpleName());
    }
    
    Role role = roleRepository.save(new Role(event));

    if (log.isDebugEnabled()) {
        log.debug("Saved role object: " + role.toString());
    }
}
 
开发者ID:bjornharvold,项目名称:bearchoke,代码行数:13,代码来源:RoleEventListener.java


示例16: handle

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
    public void handle(ToDoItemCreatedEvent event) {

        ToDoDto dto = new ToDoDto(event);
        if (log.isDebugEnabled()) {
            log.debug("Publishing to websocket channel: " + event);
            log.debug("Dto: " + dto);
        }

        // send event over web socket to user subscriber
        this.simpMessagingTemplate.convertAndSend("/topic/todos." + event.getUsername(), dto);
//        this.simpMessagingTemplate.convertAndSendToUser(event.getUsername(), "/topic/todos", event);
    }
 
开发者ID:bjornharvold,项目名称:bearchoke,代码行数:14,代码来源:ToDoEventListener.java


示例17: on

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
public void on(ServiceSpecificationCreated event) {
    logger.debug("About to handle the ServiceSpecificationCreatedEvent: {}", event);
    ServiceSpecificationEntry entry = new ServiceSpecificationEntry();
    entry.setServiceSpecificationId(event.getServiceSpecificationId().identifier());
    entry.setOwnerId(event.getOwnerId().identifier());
    entry.setServiceType(event.getServiceType());
    entry.setName(event.getName());
    entry.setSummary(event.getSummary());
    serviceSpecificationQueryRepository.save(entry);
}
 
开发者ID:dma-graveyard,项目名称:MaritimeCloudPortalTestbed,代码行数:12,代码来源:ServiceSpecificationListener.java


示例18: on

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
public void on(ServiceInstanceAliasAdded event) {
    AliasRegistryEntry entry = new AliasRegistryEntry(
            event.getOrganizationId().identifier(),
            ServiceInstanceId.class.getName(),
            event.getAlias(),
            event.getServiceInstanceId().identifier()
    );
    save(entry);
}
 
开发者ID:dma-graveyard,项目名称:MaritimeCloudPortalTestbed,代码行数:11,代码来源:AliasRegistryListener.java


示例19: on

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
public void on(OrganizationCreated event) {
    logger.debug("About to handle the OrganizationCreatedEvent: {}", event);
    OrganizationEntry organizationEntry = new OrganizationEntry();
    organizationEntry.setOrganizationId(event.getOrganizationId().identifier());
    organizationEntry.setName(event.getName());
    organizationEntry.setSummary(event.getSummary());
    organizationEntry.setUrl(event.getUrl());
    organizationQueryRepository.save(organizationEntry);
}
 
开发者ID:dma-graveyard,项目名称:MaritimeCloudPortalTestbed,代码行数:11,代码来源:OrganizationListener.java


示例20: on

import org.axonframework.eventhandling.annotation.EventHandler; //导入依赖的package包/类
@EventHandler
public void on(ServiceInstanceCreated event) {
    ServiceInstanceEntry entry = new ServiceInstanceEntry();
    entry.setServiceInstanceId(event.getServiceInstanceId().identifier());
    entry.setProviderId(event.getProviderId().identifier());
    entry.setSpecificationId(event.getSpecificationId().identifier());
    entry.setName(event.getName());
    entry.setSummary(event.getSummary());
    entry.setCoverage(event.getCoverage());
    entry.setSpecificationServiceType(event.getServiceType());
    save(entry);
}
 
开发者ID:dma-graveyard,项目名称:MaritimeCloudPortalTestbed,代码行数:13,代码来源:ServiceInstanceListener.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java RecordFactoryProvider类代码示例发布时间:2022-05-21
下一篇:
Java SimpleMessage类代码示例发布时间: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