Java 类org.springframework.transaction.event.TransactionalEventListener 实例源码

项目:spring-domain-events    文件:CompletionRegisteringBeanPostProcessor.java   
@Override
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {

    if (methodFound) {
        return;
    }

    TransactionalEventListener listener = AnnotatedElementUtils.findMergedAnnotation(method,
            TransactionalEventListener.class);

    if (listener == null) {
        return;
    }

    this.methodFound = true;

    bean = createCompletionRegisteringProxy(bean);
}
项目:cmc-claim-store    文件:CoreCaseDataUploader.java   
@TransactionalEventListener
public void saveClaim(ClaimIssuedEvent event) {
    try {
        coreCaseDataService.save(event.getAuthorisation(), event.getClaim());
    } catch (CoreCaseDataStoreException ex) {
        logger.error(ex.getMessage(), ex);
    }
}
项目:spring-domain-events    文件:PersistentApplicationEventMulticaster.java   
private static boolean isTransactionalApplicationEventListener(ApplicationListener<?> listener) {

        Class<?> targetClass = AopUtils.getTargetClass(listener);

        if (!ApplicationListenerMethodAdapter.class.isAssignableFrom(targetClass)) {
            return false;
        }

        Field field = ReflectionUtils.findField(ApplicationListenerMethodAdapter.class, "method");
        ReflectionUtils.makeAccessible(field);
        Method method = (Method) ReflectionUtils.getField(field, listener);

        return AnnotatedElementUtils.hasAnnotation(method, TransactionalEventListener.class);
    }
项目:sos    文件:EmailSender.java   
@Async
@TransactionalEventListener
void on(OrderCompleted event) {

    log.info("Sending email for order {}.", event.getOrder());

    try {
        Thread.sleep(1000);
    } catch (InterruptedException o_O) {}

    log.info("Successfully sent email for order {}.", event.getOrder());
}
项目:syncope    文件:ElasticsearchIndexManager.java   
@TransactionalEventListener
public void after(final AnyDeletedEvent event) {
    LOG.debug("About to delete index for {}[{}]", event.getAnyTypeKind(), event.getAnyKey());

    DeleteResponse response = client.prepareDelete(
            AuthContextUtils.getDomain().toLowerCase(),
            event.getAnyTypeKind().name(),
            event.getAnyKey()).
            get();

    LOG.debug("Index successfully deleted for {}[{}]: {}",
            event.getAnyTypeKind(), event.getAnyKey(), response);
}
项目:haogrgr-test    文件:TransactionEventListener.java   
@TransactionalEventListener
public void handle(PayloadApplicationEvent<TestModel> event) {
    System.err.println(event.getPayload().getName());
    //这里可以记录日志, 发送消息等操作.
    //这里抛出异常, 会导致addTestModel方法异常, 但不会回滚事务.
    //注意, ApplicationEventPublisher不能使用线程池, 否则不会执行到这里
    //因为, 包装类是通过ThreadLocal来判断当前是否有活动的事务信息.
    //TransactionalEventListener.fallbackExecution就是为了决定当当前线程没有事务上下文时, 
    //是否还调用 handle 方法, 默认不调用.
}
项目:spring-domain-events    文件:PersistentDomainEventIntegrationTest.java   
@TransactionalEventListener
public void on(DomainEvent event) {}
项目:spring-domain-events    文件:PersistentDomainEventIntegrationTest.java   
@TransactionalEventListener
public void on(DomainEvent event) {
    throw new IllegalStateException();
}
项目:spring-domain-events    文件:PersistentDomainEventIntegrationTest.java   
@TransactionalEventListener
public void on(DomainEvent event) {}
项目:spring-data-ebean    文件:UserDomainService.java   
@Async
@TransactionalEventListener
public UserEmailChangedEvent handleUserEmailChanged(UserEmailChangedEvent emailChangedEvent) {
  System.out.println("UserEmailChangedEvent:" + emailChangedEvent.getSource());
  return null;
}
项目:learningJava    文件:TransactionEventClassListener.java   
@TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT)
public void doSomething(TransactionNotifyEvent transactionNotifyEvent) {
    System.out.println("提交之前" + transactionNotifyEvent.getUserName());
}
项目:learningJava    文件:TransactionEventClassListener.java   
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
public void doSomething2(TransactionNotifyEvent transactionNotifyEvent) {
    System.out.println("提交之后" + transactionNotifyEvent.getUserName());
}
项目:learningJava    文件:TransactionEventClassListener.java   
@TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT, fallbackExecution = true)
public void doSomething3(TransactionNotifyEvent transactionNotifyEvent) {
    System.out.println("提交完成" + transactionNotifyEvent.getUserName());
}
项目:workshop-spring-4.0-to-4.2    文件:TransactionEventListener.java   
@TransactionalEventListener
public void afterCommit(TransactionalEvent transactionalEvent){
    allEvents.add(transactionalEvent);
}
项目:workshop-spring-4.0-to-4.2    文件:TransactionEventListener.java   
@TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT)
public void beforeCommit(TransactionalEvent transactionalEvent){
    allEvents.add(transactionalEvent);
}
项目:lapetiterennes    文件:SaleModificationListener.java   
@TransactionalEventListener
public void handleSaleEvent(SaleCreatedEvent event) {
    handleSaleModificationEvent(event);
}
项目:lapetiterennes    文件:SaleModificationListener.java   
@TransactionalEventListener
public void handleSaleEvent(SaleUpdatedEvent event) {
    handleSaleModificationEvent(event);
}
项目:lapetiterennes    文件:SaleDeletedListener.java   
@TransactionalEventListener
public void handleSaleDeleted(SaleDeletedEvent event) {
    this.template.convertAndSend("/topic/deletedSale", event.getSale().getId());
}
项目:grassroot-platform    文件:TransactionalEventsHandler.java   
@TransactionalEventListener()
public void handleAfterTxCommitTask(AfterTxCommitTask task) {
    task.run();
}
项目:code-examples-and-poc    文件:BlogEventListener.java   
@TransactionalEventListener
public void blogAddedTransactional(BlogAddedEvent blogAddedEvent) {
    log.info("Transactional sending external notification for added blog: {}", blogAddedEvent.getBlog());
    notificationSender.blogAddedTransactional(blogAddedEvent);
}
项目:code-examples-and-poc    文件:BlogEventListener.java   
@TransactionalEventListener(fallbackExecution = true)
public void blogAddedTransactionalWithFallback(BlogAddedEvent blogAddedEvent) {
    log.info("Transactional (with fallback) sending external notification for added blog: {}", blogAddedEvent.getBlog());
    notificationSender.blogAddedTransactionalWithFallback(blogAddedEvent);
}