コード例 #1
0
 @Override
 public void flushWorks(TransactionContext transactionContext) {
   if (transactionContext.isTransactionInProgress()) {
     Object transaction = transactionContext.getTransactionIdentifier();
     WorkQueueSynchronization txSync = synchronizationPerTransaction.get(transaction);
     if (txSync != null && !txSync.isConsumed()) {
       txSync.flushWorks();
     }
   }
 }
コード例 #2
0
 @Override
 public void performWork(Work work, TransactionContext transactionContext) {
   final Class<?> entityType = instanceInitializer.getClassFromWork(work);
   EntityIndexBinding indexBindingForEntity = factory.getIndexBinding(entityType);
   if (indexBindingForEntity == null
       && factory.getDocumentBuilderContainedEntity(entityType) == null) {
     throw new SearchException(
         "Unable to perform work. Entity Class is not @Indexed nor hosts @ContainedIn: "
             + entityType);
   }
   work = interceptWork(indexBindingForEntity, work);
   if (work == null) {
     // nothing to do
     return;
   }
   if (transactionContext.isTransactionInProgress()) {
     final Object transactionIdentifier = transactionContext.getTransactionIdentifier();
     WorkQueueSynchronization txSync = synchronizationPerTransaction.get(transactionIdentifier);
     if (txSync == null || txSync.isConsumed()) {
       txSync = createTransactionWorkQueueSynchronization(transactionIdentifier);
       transactionContext.registerSynchronization(txSync);
       synchronizationPerTransaction.put(transactionIdentifier, txSync);
     }
     txSync.add(work);
   } else {
     if (transactionExpected) {
       // this is a workaround: isTransactionInProgress should return "true"
       // for correct configurations.
       log.pushedChangesOutOfTransaction();
     }
     WorkQueue queue = new WorkQueue(factory);
     queueingProcessor.add(work, queue);
     queueingProcessor.prepareWorks(queue);
     queueingProcessor.performWorks(queue);
   }
 }