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


Java EventHandler类代码示例

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


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


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