Package jodd.jtx

Examples of jodd.jtx.JtxTransactionMode


      // start, 0 transactions, no session
      assertEquals(0, jtxManager.totalTransactions());

      // start transaction
      jtxManager.requestTransaction(new JtxTransactionMode());

      // get session from provider!
      DbSession dbSession = sessionProvider.getDbSession();
      assertNotNull(dbSession);
View Full Code Here


    // prepare manager
    JtxTransactionManager manager = new JtxTransactionManager();
    manager.registerResourceManager(new DbJtxResourceManager(cp));

    // request transaction
    JtxTransaction tx = manager.requestTransaction(new JtxTransactionMode().propagationRequired().readOnly(false));
    DbSession session = tx.requestResource(DbSession.class);
    assertNotNull(session);

    // insert two records
    DbQuery query = new DbQuery(session, "insert into GIRL values(4, 'Jeniffer', 'fighting')");
View Full Code Here

  DbSession s0;

  void service0() {
    assertTotals(0, 0);
    DbJtxTransaction tx = dbtxm.requestTransaction(new JtxTransactionMode().propagationRequired());
    assertTotals(1, 1);
    s0 = tx.requestResource();
    service0_1(tx);
    tx.commit();
    assertTotals(0, 0);
View Full Code Here

    assertTotals(0, 0);
  }

  void service0_1(JtxTransaction uptx) {
    assertTotals(1, 1);
    DbJtxTransaction tx = dbtxm.requestTransaction(new JtxTransactionMode().propagationSupports());
    assertTotals(1, 1);
    assertEquals(uptx, tx);
    DbSession s1 = tx.requestResource();
    assertEquals(s0, s1);
  }
View Full Code Here

  DbSession s1;

  // service #1 REQUIRED
  JtxTransaction service1() {
    assertTotals(0, 0);
    DbJtxTransaction tx = dbtxm.requestTransaction(new JtxTransactionMode().propagationRequired());
    assertTotals(1, 1);
    s1 = tx.requestResource();
    return tx;
  }
View Full Code Here

  }

  // service #2 REQUIRES NEW
  void service2(JtxTransaction tx1) {
    assertTotals(1, 1);
    DbJtxTransaction tx = dbtxm.requestTransaction(new JtxTransactionMode().propagationRequiresNew());
    assertTotals(2, 2);
    assertNotSame(tx1, tx);
    assertNotSame(s1, tx.requestResource());
    tx.commit();
    assertTotals(1, 1);
View Full Code Here

  }

  // service #3 REQUIRED
  void service3(JtxTransaction tx1) {
    assertTotals(1, 1);
    DbJtxTransaction tx = dbtxm.requestTransaction(new JtxTransactionMode().propagationRequired());
    assertEquals(tx1, tx);
    assertTotals(1, 1);
    assertEquals(s1, tx.requestResource());
    service3_1(tx);
    assertEquals(s1, tx.requestResource());
View Full Code Here

  }

  // service #3_1 NOT SUPPORTED
  void service3_1(JtxTransaction tx3) {
    assertTotals(1, 1);
    DbJtxTransaction tx = dbtxm.requestTransaction(new JtxTransactionMode().propagationNotSupported());
    assertNotSame(tx3, tx);
    assertTotals(2, 1);
    assertNotSame(s1, tx.requestResource());
    assertNotSame(s1, tx.requestResource());
    tx.commit();
View Full Code Here

  @Test
  public void testTime() {
    JtxTransactionManager manager = new JtxTransactionManager();
    manager.registerResourceManager(new DbJtxResourceManager(cp));

    JtxTransaction tx1 = manager.requestTransaction(new JtxTransactionMode().propagationRequired().transactionTimeout(1));
    DbSession session1 = tx1.requestResource(DbSession.class);
    assertNotNull(session1);
    executeCount(session1, "select count(*) from GIRL");

    ThreadUtil.sleep(2000);
View Full Code Here

    final int[] count = new int[1];

    new Thread() {
      @Override
      public void run() {
        JtxTransaction tx = manager.requestTransaction(new JtxTransactionMode().propagationRequired().transactionTimeout(1));
        count[0]++;
        assertEquals(count[0], manager.totalTransactions());
        assertEquals(1, manager.totalTransactions());
        assertEquals(1, manager.totalThreadTransactions());
        ThreadUtil.sleep(1000);
        tx.commit();
        count[0]--;
      }
    }.start();
    ThreadUtil.sleep(500);
    new Thread() {
      @Override
      public void run() {
        JtxTransaction tx = manager.requestTransaction(new JtxTransactionMode().propagationRequired().transactionTimeout(1));
        count[0]++;
        assertEquals(count[0], manager.totalTransactions());
        assertEquals(2, manager.totalTransactions());
        assertEquals(1, manager.totalThreadTransactions());
        ThreadUtil.sleep(1000);
View Full Code Here

TOP

Related Classes of jodd.jtx.JtxTransactionMode

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.