Package org.jboss.cache.transaction

Examples of org.jboss.cache.transaction.TransactionContext


      GlobalTransaction gtx;

      if (TransactionTable.isValid(tx) && transactions.add(tx))
      {
         gtx = txTable.getCurrentTransaction(tx, true);
         TransactionContext transactionContext;
         if (ctx.getGlobalTransaction() == null)
         {
            ctx.setGlobalTransaction(gtx);
            transactionContext = txTable.get(gtx);
            ctx.setTransactionContext(transactionContext);
View Full Code Here


      // pass up the chain.
      Object retval = invokeNextInterceptor(ctx, command);
      if (!skipReplicationOfTransactionMethod(ctx))
      {
         GlobalTransaction gtx = getGlobalTransaction(ctx);
         TransactionContext transactionContext = ctx.getTransactionContext();
         if (transactionContext.hasLocalModifications())
         {
            OptimisticPrepareCommand replicablePrepareCommand = command.copy(); // makre sure we remove any "local" transactions
            replicablePrepareCommand.removeModifications(transactionContext.getLocalModifications());
            command = replicablePrepareCommand;
         }

         // replicate the prepare call.
         broadcastPrepare(command, gtx, ctx);
View Full Code Here

    * transaction.
    * This is O(N) WRT to the number of modifications so far.
    */
   private boolean wasRemovedInTx(Fqn fqn, InvocationContext ctx)
   {
      TransactionContext transactionContext = ctx.getTransactionContext();
      if (transactionContext == null) return false;

      for (WriteCommand txCacheCommand : transactionContext.getModifications())
      {
         if (txCacheCommand instanceof RemoveNodeCommand && fqn.isChildOrEquals(txCacheCommand.getFqn())) return true;
      }
      return false;
   }
View Full Code Here

    */
   private void unlock(InvocationContext ctx)
   {
      try
      {
         TransactionContext transactionContext = ctx.getTransactionContext();
         if (transactionContext != null)
         {
            lockManager.unlock(ctx);
         }
      }
View Full Code Here

   {
      Option optionOverride = ctx.getOptionOverrides();
      if (optionOverride != null
            && (optionOverride.isForceAsynchronous() || optionOverride.isForceSynchronous()))
      {
         TransactionContext transactionContext = ctx.getTransactionContext();
         if (transactionContext != null)
         {
            if (optionOverride.isForceAsynchronous())
               transactionContext.setForceAsyncReplication(true);
            else
               transactionContext.setForceSyncReplication(true);
         }
      }
   }
View Full Code Here

   @Override
   protected void cleanupStaleLocks(InvocationContext ctx) throws Throwable
   {
      super.cleanupStaleLocks(ctx);
      TransactionContext transactionContext = ctx.getTransactionContext();
      if (transactionContext != null)
      {
         ((OptimisticTransactionContext) transactionContext).getTransactionWorkSpace().clearNodes();
      }
   }
View Full Code Here

   }

   protected void copyInvocationScopeOptionsToTxScope(InvocationContext ctx)
   {
      // notify the transaction tCtx that this override is in place.
      TransactionContext tCtx = txTable.get(ctx.getGlobalTransaction());
      if (tCtx != null)
      {
         Option txScopeOption = new Option();
         txScopeOption.setCacheModeLocal(ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isCacheModeLocal());
         txScopeOption.setSkipCacheStatusCheck(ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isSkipCacheStatusCheck());
         tCtx.setOption(txScopeOption);
      }
   }
View Full Code Here

      if (tx != null)
      {
         if (trace) log.trace("Entering InvalidationInterceptor's prepare phase");
         // fetch the modifications before the transaction is committed (and thus removed from the txTable)
         GlobalTransaction gtx = ctx.getGlobalTransaction();
         TransactionContext transactionContext = ctx.getTransactionContext();
         if (transactionContext == null)
            throw new IllegalStateException("cannot find transaction transactionContext for " + gtx);

         if (transactionContext.hasModifications())
         {
            List<WriteCommand> mods;
            if (transactionContext.hasLocalModifications())
            {
               mods = new ArrayList<WriteCommand>(command.getModifications());
               mods.removeAll(transactionContext.getLocalModifications());
            }
            else
            {
               mods = command.getModifications();
            }
View Full Code Here

      Transaction tx = ctx.getTransaction();
      if (tx != null)
      {
         // here we just record the modifications but actually do the invalidate in commit.
         GlobalTransaction gtx = ctx.getGlobalTransaction();
         TransactionContext transactionContext = ctx.getTransactionContext();
         if (transactionContext == null)
            throw new IllegalStateException("cannot find transaction transactionContext for " + gtx);

         if (transactionContext.hasModifications())
         {
            List<WriteCommand> mods = new ArrayList<WriteCommand>(transactionContext.getModifications());
            if (transactionContext.hasLocalModifications()) mods.removeAll(transactionContext.getLocalModifications());
            txMods.put(gtx, mods);
         }
      }
      return retval;
   }
View Full Code Here

      assertNotNull("Tx should have been set up by now", cache.getInvocationContext().getTransaction());
      assertEquals("The same current transaction should be associated with this invocation ctx.", tm.getTransaction(), cache.getInvocationContext().getTransaction());
      assertNotNull("Gtx should have been set up by now", cache.getInvocationContext().getGlobalTransaction());

      Transaction tx = tm.getTransaction();
      TransactionContext transactionContext = tt.get(tt.get(tx));

      if (commit)
      {
         tm.commit();
      }
      else
      {
         tm.rollback();
      }

      assertNull("Tx should have been scrubbed", cache.getInvocationContext().getTransaction());
      assertNull("Gtx should have been scrubbed", cache.getInvocationContext().getGlobalTransaction());
      assertEquals("Method call should have been scrubbed", null, cache.getInvocationContext().getMethodCall());
      assertEquals("Cache command should have been scrubbed", null, cache.getInvocationContext().getCommand());

      // check that the transaction transactionContext hasn't leaked stuff.
      assert transactionContext.getModifications().isEmpty() : "Should have scrubbed modifications in transaction transactionContext";
      assert transactionContext.getLocks().isEmpty() : "Should have scrubbed modifications in transaction transactionContext";
      assert transactionContext.getOrderedSynchronizationHandler() == null : "Should have removed the ordered sync handler";
   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.transaction.TransactionContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.