Package com.sun.sgs.service

Examples of com.sun.sgs.service.Transaction


    }  

    /* -- Implement TransactionProxy -- */

    public Transaction getCurrentTransaction() {
  Transaction txn = threadTxn.get();
  if (txn == null) {
      throw new TransactionNotActiveException(
    "No transaction is active");
  }
  txn.checkTimeout();
  return txn;
    }
View Full Code Here


  txn.checkTimeout();
  return txn;
    }

    public boolean inTransaction() {
        Transaction txn = threadTxn.get();
        return (txn != null);
    }
View Full Code Here

    @Test public void runTransactionInTransaction() throws Exception {
        final TransactionProxy proxy = serverNode.getProxy();
        KernelRunnable task = new TestAbstractKernelRunnable() {
                public void run() throws Exception {
                    final Transaction t = proxy.getCurrentTransaction();
                    txnScheduler.runTask(new TestAbstractKernelRunnable() {
                            public void run() throws Exception {
                                Transaction t2 = proxy.getCurrentTransaction();
                                assertTrue(t.equals(t2));
                            }
                        }, taskOwner);
                }
            };
View Full Code Here

        // No need to buffer it.
        if (!proxy.inTransaction()) {
            handler.publish(record);
            return;
        }
  Transaction txn = proxy.getCurrentTransaction();
  if (txn == null) {
      // in the event that a TransactionalHandler is used
      // outside the scope of a transaction (which could happen
      // if it is used by certain classes like DataStoreImpl),
      // then we just pass the log record on through without
      // buffering
      handler.publish(record);
        } else {
      Queue<LogRecord> records = bufferedRecords.get(txn);
      if (records == null) {
    txn.join(this);
    records = new ArrayDeque<LogRecord>();
    // this code path is guaranteed to be unique by way of
    // the transaction's uniqueness, so we don't need to
    // worry about a race condition with putting the queue
    // into the map
View Full Code Here

        try {
            txnScheduler.runTask(new TestAbstractKernelRunnable() {
                public void run() {
                assertEquals(dummy, getBinding(app, service, "dummy"));
                setBinding(app, service, "dummy", dummy2);
                Transaction txn = txnProxy.getCurrentTransaction();
                txn.abort(new TestAbortedTransactionException("abort"));
            }}, taskOwner);
        } catch (TestAbortedTransactionException e) {
            System.err.println(e);
        }
View Full Code Here

        }}, taskOwner);
        try {
            txnScheduler.runTask(new TestAbstractKernelRunnable() {
                public void run() {
                    removeBinding(app, service, "dummy");
                    Transaction txn = txnProxy.getCurrentTransaction();
                    txn.abort(new TestAbortedTransactionException("abort"));
            }}, taskOwner);
        } catch (TestAbortedTransactionException e) {
            System.err.println(e);
        }
View Full Code Here

                public void run() {
                    service.removeBinding("dummy");
                    DummyManagedObject serviceResult =
                        (DummyManagedObject) service.getServiceBinding("dummy");
                    assertEquals(serviceDummy, serviceResult);
                    Transaction txn = txnProxy.getCurrentTransaction();
                    txn.abort(new TestAbortedTransactionException("abort"));
            }}, taskOwner);
        } catch (TestAbortedTransactionException e) {
            System.err.println(e);
        }
View Full Code Here

                assertEquals("zzz-2", nextBoundName(app, service, "zzz-"));
                assertEquals("zzz-2", nextBoundName(app, service, "zzz-1"));
                assertEquals("zzz-2", nextBoundName(app, service, "zzz-1"));
                assertNull(nextBoundName(app, service, "zzz-2"));
                assertNull(nextBoundName(app, service, "zzz-2"));
                Transaction txn = txnProxy.getCurrentTransaction();
                txn.abort(new TestAbortedTransactionException("abort"));
            }}, taskOwner);
        } catch (TestAbortedTransactionException e) {
            System.err.println(e);
        }
View Full Code Here

                        throw (Exception) t;
                    } else {
                        throw (Error) t;
                    }
                }
                Transaction txn = txnProxy.getCurrentTransaction();
                txn.abort(new TestAbortedTransactionException("abort"));
        }}, taskOwner);

        assertTrue(doneFlag.tryAcquire(2, 1, TimeUnit.SECONDS));
        Throwable throwable = error.get();
        if (throwable != null) {
View Full Code Here

                action2 = new ShutdownServiceAction(service);
                action2.assertBlocked();
                action1.interrupt(); // shutdown should not unblock
                action1.assertBlocked();
                action2.assertBlocked();
                Transaction txn = txnProxy.getCurrentTransaction();
                txn.abort(new TestAbortedTransactionException("abort"));
            }
        }

        try {
            TestTask task = new TestTask();
View Full Code Here

TOP

Related Classes of com.sun.sgs.service.Transaction

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.