本文整理汇总了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();
}
}
示例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();
}
示例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());
}
}
示例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);
}
示例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;
}
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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());
}
}