Package javax.transaction

Examples of javax.transaction.TransactionManager


      }
   }

   private void destroyCache(CacheSPI c)
   {
      TransactionManager tm = c.getTransactionManager();
      try
      {
         if (tm != null && tm.getTransaction() != null)
            tm.rollback();
      }
      catch (Exception e)
      {
      }
      c.stop();
View Full Code Here


   {
      DataVersion version = new TestVersion("99");
      cache[0].getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache[0].put(fqn, key, "value");// TestVersion-99 should be on both caches now

      TransactionManager mgr = cache[0].getTransactionManager();
      mgr.begin();
      // don't explicitly set a data version.

      // force an IC scrub
      //cache[1].getInvocationContext().setOptionOverrides(null);
      cache[1].put(fqn, key, "value2");
      try
      {
         mgr.commit();

         assertTrue("expected to fail", false);
      }
      catch (RollbackException e)
      {
View Full Code Here

   {
      DataVersion version = new TestVersion("99");
      cache[0].getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache[0].put(fqn, key, "value");// TestVersion-99 should be on both caches now

      TransactionManager mgr = cache[0].getTransactionManager();
      mgr.begin();

      version = new TestVersion("999");
      cache[1].getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache[1].put(fqn, key, "value2");
      mgr.commit();
   }
View Full Code Here

   {
      DataVersion version = new TestVersion("99");
      cache[0].getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache[0].put(fqn, key, "value");// TestVersion-99 should be on both caches now

      TransactionManager mgr = cache[0].getTransactionManager();
      mgr.begin();

      version = new TestVersion("29");
      cache[1].getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache[1].put(fqn, key, "value2");
      try
      {
         mgr.commit();
         assertTrue("expected to fail", false);
      }
      catch (RollbackException e)
      {
         // should fail.
View Full Code Here

    */
   public void testIncompatibleVersionTypes2() throws Exception
   {
      cache[0].put(fqn, key, "value");// default data version should be on both caches now

      TransactionManager mgr = cache[0].getTransactionManager();
      mgr.begin();

      // explicitly set data version
      DataVersion version = new TestVersion("99");
      cache[1].getInvocationContext().getOptionOverrides().setDataVersion(version);

      try
      {
         cache[1].put(fqn, key, "value2");
         mgr.commit();
         assertTrue("expected to fail", false);
      }
      catch (Exception e)
      {
         // should fail.
View Full Code Here

    */
   public void testCompatibleVersionTypes2() throws Exception
   {
      cache[0].put(fqn, key, "value");// TestVersion-99 should be on both caches now

      TransactionManager mgr = cache[0].getTransactionManager();
      mgr.begin();

      DataVersion version = new DefaultDataVersion(300);
      cache[1].getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache[1].put(fqn, key, "value2");
      mgr.commit();
   }
View Full Code Here

   {
      DataVersion version = new DefaultDataVersion(200);
      cache[0].getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache[0].put(fqn, key, "value");// TestVersion-99 should be on both caches now

      TransactionManager mgr = cache[0].getTransactionManager();
      mgr.begin();

      version = new DefaultDataVersion(100);
      cache[1].getInvocationContext().getOptionOverrides().setDataVersion(version);
      cache[1].put(fqn, key, "value2");
      try
      {
         // this call will use implicit versioning and will hence fail.
         mgr.commit();
         assertTrue("expected to fail", false);
      }
      catch (Exception e)
      {
         // should fail.
View Full Code Here

   public void testLocalTransaction() throws Exception
   {

      CacheSPI<Object, Object> cache = createCacheWithListener();

      TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
      assertNull(mgr.getTransaction());

      mgr.begin();

      assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
      assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

      SamplePojo pojo = new SamplePojo(21, "test");

      cache.put("/one/two", "key1", pojo);

      mgr.commit();

      assertNull(mgr.getTransaction());
      assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
      assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

      assertTrue(cache.exists(Fqn.fromString("/one/two")));
      assertNotNull(cache.getRoot().getChild("one"));
View Full Code Here

      TestListener listener = new TestListener();

      CacheSPI<Object, Object> cache = createCacheWithListener(listener);
      LockManager lockManager = TestingUtil.extractLockManager(cache);

      TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
      assertNull(mgr.getTransaction());

      assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
      assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

      SamplePojo pojo = new SamplePojo(21, "test");

      cache.put("/one/two", "key1", pojo);

      assertNull(mgr.getTransaction());
      assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
      assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

      assertTrue(cache.exists(Fqn.fromString("/one/two")));
      assertNotNull(cache.getRoot().getChild("one"));
View Full Code Here

   {
      groupIncreaser++;
      CacheSPI<Object, Object> cache = createCacheWithListener();
      LockManager lockManager = TestingUtil.extractLockManager(cache);

      TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
      assertNull(mgr.getTransaction());

      mgr.begin();

      assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
      assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

      SamplePojo pojo = new SamplePojo(21, "test");

      cache.put("/one/two", "key1", pojo);

      mgr.commit();

      assertNull(mgr.getTransaction());
      assertEquals(0, cache.getTransactionTable().getNumGlobalTransactions());
      assertEquals(0, cache.getTransactionTable().getNumLocalTransactions());

      assertTrue(cache.exists(Fqn.fromString("/one/two")));
      assertNotNull(cache.getRoot().getChild("one"));
View Full Code Here

TOP

Related Classes of javax.transaction.TransactionManager

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.