Package javax.transaction

Examples of javax.transaction.Transaction


      assertEquals("Event log should be empty", Collections.emptyList(), eventLog1.events);
      assertEquals("Event log should be empty", Collections.emptyList(), eventLog2.events);

      // modify existing node
      tm1.begin();
      Transaction tx = tm1.getTransaction();
      cache1.removeNode(fqn);
      List<Event> expected = new ArrayList<Event>();
      expected.add(new EventImpl(false, cache1, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
      expected.add(new EventImpl(true, cache1, null, oldData, fqn, tx, true, null, false, null, NODE_REMOVED));
      expected.add(new EventImpl(false, cache1, null, null, fqn, tx, true, null, false, null, NODE_REMOVED));
View Full Code Here


      assertEquals("Event log should be empty", Collections.emptyList(), eventLog1.events);
      assertEquals("Event log should be empty", Collections.emptyList(), eventLog2.events);

      // modify existing node
      tm1.begin();
      Transaction tx = tm1.getTransaction();
      Map<String, String> removed = new HashMap<String, String>();
      removed.put("key2", "value2");
      cache1.remove(fqn, "key2");
      List<Event> expected = new LinkedList<Event>();
      expected.add(new EventImpl(false, cache1, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
View Full Code Here

      eventLog2.events.clear();// clear events
      assertEquals("Event log should be empty", Collections.emptyList(), eventLog1.events);
      assertEquals("Event log should be empty", Collections.emptyList(), eventLog2.events);

      tm1.begin();
      Transaction tx = tm1.getTransaction();
      Fqn newFqn = Fqn.fromRelativeElements(newParent, fqn.getLastElement());
      cache1.move(n1.getFqn(), n2.getFqn());
      List<Event> expected = new ArrayList<Event>();
      expected.add(new EventImpl(false, cache1, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
      expected.add(new EventImpl(true, cache1, null, null, fqn, tx, true, newFqn, false, null, NODE_MOVED));
View Full Code Here

    }
   
    private void beginDirect(TransactionContext tc) throws XATransactionException {
    try {
      transactionManager.begin();
      Transaction tx = transactionManager.suspend();
      tc.setTransaction(tx);
      tc.setCreationTime(System.currentTimeMillis());
        } catch (javax.transaction.NotSupportedException err) {
            throw new XATransactionException(err);
        } catch (SystemException err) {
View Full Code Here

     
      //There may already be a JTA transaction associated to the thread
     
      boolean ok;
     
      Transaction toResume = null;
      try
      {
         toResume = tm.suspend();
        
         ok = setupJMSObjects();
View Full Code Here

      //to arrive - 10 years should be enough
      tm.setTransactionTimeout(60 * 60 * 24 * 365 * 10);
     
      tm.begin();
        
      Transaction tx = tm.getTransaction();
     
      //Remove the association between current thread - we don't want it
      //we will be committing /rolling back directly on the transaction object
     
      tm.suspend();
View Full Code Here

     */
    public synchronized EntityManager getCurrent() {
        EntityManager current = null;

        // Get current transaction (if any)
        Transaction currentTx = null;
        try {
            currentTx = JTransactionManager.getTransactionManager().getTransaction();
        } catch (SystemException e) {
            throw new IllegalStateException("Cannot get current transaction", e);
        }
View Full Code Here

     * is active.
     * @throws TransactionRequiredException if there is no transaction
     */
    protected void checkTransaction() throws TransactionRequiredException {
        // Get current transaction (if any)
        Transaction currentTx = null;
        try {
            currentTx = JTransactionManager.getTransactionManager().getTransaction();
        } catch (SystemException e) {
            throw new IllegalStateException("Cannot get current transaction", e);
        }
View Full Code Here

    @Override
    public Object intercept(final EasyBeansInvocationContext invocationContext) throws Exception {
        logger.debug("Calling RequiresNew TX interceptor");

        // Get current transaction
        Transaction transaction;
        try {
            transaction = getTransactionManager().getTransaction();
        } catch (SystemException se) {
            throw new EJBException("Cannot get the current transaction on transaction manager.", se);
        }

        logger.debug("Transaction found = {0}", transaction);


        /*
         * If a client calls with a transaction context, the container
         * suspends the association of the transaction context with the
         * current thread before starting the new transaction and invoking
         * the business method. The container resumes the suspended
         * transaction association after the business method and the new
         * transaction have been completed.
         */
        // Existing transaction
        Transaction suspendedTransaction = null;
        if (transaction != null) {
            try {
                logger.debug("Suspending transaction {0}", transaction);
                suspendedTransaction = getTransactionManager().suspend();
            } catch (SystemException se) {
                throw new EJBException("Cannot call suspend() on the transaction manager.", se);
            }
        }

        /*
         * If the client invokes the enterprise bean's method while the client
         * is not associated with a transaction context, the container
         * automatically starts a new transaction before delegating a method
         * call to the enterprise bean business method. The container
         * automatically enlists all the resource managers accessed by the
         * business method with the transaction. If the business method invokes
         * other enterprise beans, the container passes the transaction context
         * with the invocation. The container attempts to commit the transaction
         * when the business method has completed. The container performs the
         * commit protocol before the method result is sent to the client.
         */
        try {
            getTransactionManager().begin();
        } catch (NotSupportedException nse) {
            throw new EJBException("Transaction Manager implementation does not support nested transactions.", nse);
        } catch (SystemException se) {
            throw new EJBException("Cannot call begin() on the transaction manager.", se);
        }

        boolean gotBusinessException = false;
        try {
            return invocationContext.proceed();
        } catch (Exception e) {
            gotBusinessException = true;
            handleContextContainerTransaction(invocationContext, e);

            // Shouldn't come here
            return null;
        } finally {

            // only do some operations if transaction has been started before
            // invoking the method.
            if (!gotBusinessException) {
                // sanity check.
                Transaction transactionAfter = null;
                try {
                    transactionAfter = getTransactionManager().getTransaction();
                } catch (SystemException se) {
                    throw new EJBException("Cannot get the current transaction on transaction manager.", se);
                }
View Full Code Here

    @Override
    public Object intercept(final EasyBeansInvocationContext invocationContext) throws Exception {
        logger.debug("Calling BMT TX interceptor");

        // Get current transaction
        Transaction transaction;
        try {
            transaction = getTransactionManager().getTransaction();
        } catch (SystemException se) {
            throw new EJBException("Cannot get the current transaction on transaction manager.", se);
        }

        logger.debug("Transaction found = {0}", transaction);

        /*
         * When a client invokes a business method via one of the enterprise
         * bean?s client view interfaces, the container suspends any transaction
         * that may be associated with the client request. If there is a
         * transaction associated with the instance (this would happen if a
         * stateful session bean instance started the transaction in some
         * previous business method), the container associates the method
         * execution with this transaction. If there are interceptor methods
         * associated with the bean instances, these actions are taken before
         * the interceptor methods are invoked.
         */

        Transaction suspendedTransaction = null;
        if (transaction != null) {
            try {
                logger.debug("Suspending transaction {0}", transaction);
                suspendedTransaction = getTransactionManager().suspend();
            } catch (SystemException se) {
View Full Code Here

TOP

Related Classes of javax.transaction.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.