org.springframework.transaction.event.TransactionalEventListener Java Examples
The following examples show how to use
org.springframework.transaction.event.TransactionalEventListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SearchServiceImpl.java From inception with Apache License 2.0 | 6 votes |
@TransactionalEventListener(fallbackExecution = true) @Transactional public void beforeLayerConfigurationChanged(LayerConfigurationChangedEvent aEvent) { log.trace("Starting beforeLayerConfigurationChanged"); Project project = aEvent.getProject(); Index index = indexByProject.get(project.getId()); // If the index is null, then indexing is not supported. if (index == null) { return; } synchronized (index) { index.setInvalid(true); entityManager.merge(index); } // Schedule re-indexing of the physical index indexScheduler.enqueueReindexTask(aEvent.getProject()); }
Example #2
Source File: FileResourceEventListener.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 6 votes |
@TransactionalEventListener @Async public void deleteFile( FileDeletedEvent deleteFileEvent ) { if ( !fileResourceContentStore.fileResourceContentExists( deleteFileEvent.getStorageKey() ) ) { log.error( String.format( "No file exist for key: %s", deleteFileEvent.getStorageKey() ) ); return; } if ( FileResource.IMAGE_CONTENT_TYPES.contains( deleteFileEvent.getContentType() ) && FileResourceDomain.getDomainForMultipleImages().contains( deleteFileEvent.getDomain() ) ) { String storageKey = deleteFileEvent.getStorageKey(); Stream.of( ImageFileDimension.values() ).forEach(d -> fileResourceContentStore.deleteFileResourceContent( StringUtils.join( storageKey, d.getDimension() ) ) ); } else { fileResourceContentStore.deleteFileResourceContent( deleteFileEvent.getStorageKey() ); } }
Example #3
Source File: SearchServiceImpl.java From inception with Apache License 2.0 | 5 votes |
@TransactionalEventListener(fallbackExecution = true) @Transactional public void afterAnnotationUpdate(AfterCasWrittenEvent aEvent) { log.trace("Starting afterAnnotationUpdate"); // Schedule new document index process indexScheduler.enqueueIndexDocument(aEvent.getDocument(), aEvent.getCas()); }
Example #4
Source File: ElasticsearchIndexManager.java From syncope with Apache License 2.0 | 5 votes |
@TransactionalEventListener public void after(final AnyDeletedEvent event) throws IOException { LOG.debug("About to delete index for {}[{}]", event.getAnyTypeKind(), event.getAnyKey()); DeleteRequest request = new DeleteRequest( ElasticsearchUtils.getContextDomainName(AuthContextUtils.getDomain(), event.getAnyTypeKind()), event.getAnyKey()); DeleteResponse response = client.delete(request, RequestOptions.DEFAULT); LOG.debug("Index successfully deleted for {}[{}]: {}", event.getAnyTypeKind(), event.getAnyKey(), response); }
Example #5
Source File: CasStorageServiceImpl.java From webanno with Apache License 2.0 | 5 votes |
@TransactionalEventListener(fallbackExecution = true) @Transactional public void beforeLayerConfigurationChanged(LayerConfigurationChangedEvent aEvent) { // Tell the known CAS holders for the given project that their type system is outdated // so they can be refreshed when next returned or borrowed exclusiveAccessHolders.stream() .filter(h -> Objects.equals(h.getKey().getProjectId(), aEvent.getProject().getId())) .forEach(h -> h.setTypeSystemOutdated(true)); // Drop all cached CASes from the updated project from the cache so the CASes get loaded // with an updated type system on next access sharedAccessCache.asMap().keySet() .removeIf(key -> Objects.equals(key.getProjectId(), aEvent.getProject().getId())); }
Example #6
Source File: OnsBatchDatabaseTransactionMessageInterceptor.java From onetwo with Apache License 2.0 | 5 votes |
@TransactionalEventListener(phase=TransactionPhase.BEFORE_COMMIT) public void beforeCommit(SendMessageEvent event) { if (event.isBatchMode()) { this.getSendMessageRepository().batchSave(event.getSendMessageContexts()); CURRENT_MESSAGES.remove(); } }
Example #7
Source File: FileResourceEventListener.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
@TransactionalEventListener @Async public void saveImageFile( ImageFileSavedEvent imageFileSavedEvent ) { DateTime startTime = DateTime.now(); Map<ImageFileDimension, File> imageFiles = imageFileSavedEvent.getImageFiles(); FileResource fileResource = fileResourceService.getFileResource( imageFileSavedEvent.getFileResource() ); String storageId = fileResourceContentStore.saveFileResourceContent( fileResource, imageFiles ); if ( storageId != null ) { fileResource.setHasMultipleStorageFiles( true ); fileResourceService.updateFileResource( fileResource ); } Period timeDiff = new Period( startTime, DateTime.now() ); logMessage( storageId, fileResource, timeDiff ); }
Example #8
Source File: TestProductChangeListener.java From cuba with Apache License 2.0 | 5 votes |
@TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT) void beforeCommit(EntityChangedEvent<EceTestProduct, UUID> event) { if (event.getType() == EntityChangedEvent.Type.DELETED) return; EceTestProduct product = tdm.load(event.getEntityId()).one(); if (product.getName() == null) { product.setName("default name"); } tdm.save(product); if (doLog) { EceTestLogEntry logEntry = dm.create(EceTestLogEntry.class); logEntry.setMessage("Saving product: " + product); dm.commit(logEntry); } EceTestStock stock; Optional<EceTestStock> optStock = tdm.load(EceTestStock.class) .query("select e from test_EceTestStock e where e.product = :product") .parameter("product", product) .optional(); if (!optStock.isPresent()) { stock = tdm.create(EceTestStock.class); stock.setProduct(product); } else { stock = optStock.get(); } stock.setQuantity(stock.getQuantity() + 1); tdm.save(stock); }
Example #9
Source File: TestOrderChangedEventListener.java From cuba with Apache License 2.0 | 5 votes |
@TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT) public void onOrderChanged(EntityChangedEvent<Order, UUID> event) { if (!enabled) return; switch (event.getType()) { case DELETED: return; case CREATED: case UPDATED: { Order order = tdm.load(event.getEntityId()) .view(View.LOCAL) .one(); order.setNumber(order.getNumber() + "changed"); tdm.save(order); } } }
Example #10
Source File: SimpleAuthorizationSettingService.java From hsweb-framework with Apache License 2.0 | 5 votes |
@TransactionalEventListener(condition = "!#event.all") @Caching( evict = { @CacheEvict(value = CacheConstants.USER_AUTH_CACHE_NAME, key = "#event.getUserId()"), @CacheEvict(value = CacheConstants.USER_MENU_CACHE_NAME, key = "'user-menu-list:'+#event.getUserId()"), @CacheEvict(value = CacheConstants.USER_MENU_CACHE_NAME, key = "'menu-tree:'+#event.getUserId()") } ) public void clearUserCache(ClearUserAuthorizationCacheEvent event) { logger.debug("clear user:{} authorization cache", event.getUserId()); }
Example #11
Source File: SimpleAuthorizationSettingService.java From hsweb-framework with Apache License 2.0 | 5 votes |
@TransactionalEventListener(condition = "#event.all") @Caching(evict = { @CacheEvict(cacheNames = USER_MENU_CACHE_NAME, allEntries = true), @CacheEvict(cacheNames = USER_AUTH_CACHE_NAME, allEntries = true) }) public void clearAllUserCache(ClearUserAuthorizationCacheEvent event) { logger.debug("clear all user authorization cache"); }
Example #12
Source File: SearchServiceImpl.java From inception with Apache License 2.0 | 5 votes |
@TransactionalEventListener(fallbackExecution = true) @Transactional public void afterDocumentCreate(AfterDocumentCreatedEvent aEvent) { log.trace("Starting afterDocumentCreate"); // Schedule new document index process indexScheduler.enqueueIndexDocument(aEvent.getDocument(), aEvent.getCas()); }
Example #13
Source File: EmailSender.java From sos with Apache License 2.0 | 5 votes |
@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()); }
Example #14
Source File: DocumentServiceImpl.java From webanno with Apache License 2.0 | 4 votes |
@TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT) public void onDocumentStateChangeEvent(DocumentStateChangedEvent aEvent) { projectService.recalculateProjectState(aEvent.getDocument().getProject()); }
Example #15
Source File: PersistentDomainEventIntegrationTest.java From spring-domain-events with Apache License 2.0 | 4 votes |
@TransactionalEventListener public void on(DomainEvent event) { throw new IllegalStateException(); }
Example #16
Source File: TestEventCaptor.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 4 votes |
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT, fallbackExecution = true) public void onTransactionalEvent(HistoryEvent event) { transactionHistoryEvents.push(event); }
Example #17
Source File: TestEventCaptor.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 4 votes |
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT, fallbackExecution = true) public void onTransactionalEvent(DelegateExecution event) { transactionExecutionEvents.push(new ExecutionEvent(event)); }
Example #18
Source File: TestEventCaptor.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 4 votes |
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT, fallbackExecution = true) public void onTransactionalEvent(DelegateTask event) { transactionTaskEvents.push(new TaskEvent(event)); }
Example #19
Source File: TestEventCaptor.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 4 votes |
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT, fallbackExecution = true) public void onTransactionalEvent(ExecutionEvent event) { transactionImmutableExecutionEvents.push(event); }
Example #20
Source File: TestEventCaptor.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 4 votes |
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT, fallbackExecution = true) public void onTransactionalEvent(TaskEvent event) { transactionImmutableTaskEvents.push(event); }
Example #21
Source File: UserRemovedListener.java From code-examples with MIT License | 4 votes |
@TransactionalEventListener(condition = "#event.name eq 'reflectoring'", phase = TransactionPhase.AFTER_COMPLETION) void handleAfterUserRemoved(UserRemovedEvent event) { System.out.println(String.format("User removed (@TransactionalEventListener): %s", event.getName())); }
Example #22
Source File: DatabaseTransactionMessageInterceptor.java From onetwo with Apache License 2.0 | 4 votes |
@TransactionalEventListener(phase=TransactionPhase.AFTER_COMMIT) void afterCommit(SendMessageEvent event);
Example #23
Source File: DatabaseTransactionMessageInterceptor.java From onetwo with Apache License 2.0 | 4 votes |
@TransactionalEventListener(phase=TransactionPhase.AFTER_ROLLBACK) void afterRollback(SendMessageEvent event);
Example #24
Source File: WebhookService.java From webanno with Apache License 2.0 | 4 votes |
@TransactionalEventListener(fallbackExecution = true) @Async public void onApplicationEvent(ApplicationEvent aEvent) { String topic = EVENT_TOPICS.get(aEvent.getClass()); if (topic == null) { return; } Object message; switch (topic) { case PROJECT_STATE: message = new ProjectStateChangeMessage((ProjectStateChangedEvent) aEvent); break; case DOCUMENT_STATE: message = new DocumentStateChangeMessage((DocumentStateChangedEvent) aEvent); break; case ANNOTATION_STATE: message = new AnnotationStateChangeMessage((AnnotationStateChangeEvent) aEvent); break; default: return; } for (Webhook hook : configuration.getGlobalHooks()) { if (!hook.isEnabled() || !hook.getTopics().contains(topic)) { continue; } try { // Configure rest template without SSL certification check if that is disabled. RestTemplate restTemplate; if (hook.isVerifyCertificates()) { restTemplate = restTemplateBuilder.build(); } else { restTemplate = restTemplateBuilder .requestFactory(this::getNonValidatingRequestFactory).build(); } HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.setContentType(MediaType.APPLICATION_JSON_UTF8); requestHeaders.set(X_AERO_NOTIFICATION, topic); // If a secret is set, then add a digest header that allows the client to verify // the message integrity String json = JSONUtil.toJsonString(message); if (isNotBlank(hook.getSecret())) { String digest = DigestUtils.shaHex(hook.getSecret() + json); requestHeaders.set(X_AERO_SIGNATURE, digest); } HttpEntity<?> httpEntity = new HttpEntity<Object>(json, requestHeaders); restTemplate.postForEntity(hook.getUrl(), httpEntity, Void.class); } catch (Exception e) { log.error("Unable to invoke webhook [{}]", hook, e); } } }
Example #25
Source File: ProgramRuleEngineListener.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 4 votes |
@TransactionalEventListener public void onScheduledEvent( StageScheduledEvaluationEvent event ) { programRuleEngineService.evaluateEventAndRunEffects( event.getProgramStageInstance() ); }
Example #26
Source File: DocumentServiceImpl.java From webanno with Apache License 2.0 | 4 votes |
@TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT) public void onAfterDocumentCreatedEvent(AfterDocumentCreatedEvent aEvent) { projectService.recalculateProjectState(aEvent.getDocument().getProject()); }
Example #27
Source File: DocumentServiceImpl.java From webanno with Apache License 2.0 | 4 votes |
@TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT) public void onBeforeDocumentRemovedEvent(BeforeDocumentRemovedEvent aEvent) { projectService.recalculateProjectState(aEvent.getDocument().getProject()); }
Example #28
Source File: AnnotationDrivenEventListener.java From tutorials with MIT License | 4 votes |
@TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT) public void handleCustom(final CustomSpringEvent event) { System.out.println("Handling event inside a transaction BEFORE COMMIT."); hitCustomEventHandler = true; }
Example #29
Source File: TestEventHandler.java From tutorials with MIT License | 4 votes |
@TransactionalEventListener void handleEvent(DomainEvent event);
Example #30
Source File: TestEventCaptor.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT, fallbackExecution = true) public void onTransactionalEvent(HistoryEvent event) { transactionHistoryEvents.push(event); }