Examples of UserTransaction


Examples of com.arjuna.mw.wst.UserTransaction

{

    public static void testSingleParticipant()
            throws Exception
    {
      UserTransaction ut = UserTransaction.getUserTransaction();
      TransactionManager tm = TransactionManager.getTransactionManager();
      DemoDurableParticipant p = new DemoDurableParticipant();
     
      ut.begin();
      try {
      tm.enlistForDurableTwoPhase(p, p.identifier());
        catch (Exception eouter) {
            try {
                ut.rollback();
            } catch(Exception einner) {
            }
            throw eouter;
        }

      ut.commit();
    }
View Full Code Here

Examples of com.arjuna.mw.wst11.UserTransaction

        PrintWriter out = resp.getWriter();

        out.write("<h1>Quickstart: This example demonstrates the deployment of a WS-AT (WS-AtomicTransaction) enabled JAX-WS Web service bundled in a war archive for deployment to *JBoss WildFly*.</h1>");

        System.out.println("[CLIENT] Creating a new WS-AT User Transaction");
        UserTransaction ut = UserTransactionFactory.userTransaction();
        try {
            System.out
                    .println("[CLIENT] Beginning Atomic Transaction (All calls to Web services that support WS-AT wil be included in this transaction)");
            ut.begin();
            System.out.println("[CLIENT] invoking makeBooking() on WS");
            client.makeBooking();
            System.out.println("[CLIENT] committing Atomic Transaction (This will cause the AT to complete successfully)");
            ut.commit();

            out.write("<p><i>Go to your WildFly console or Server log to see the result of the transaction</i></p>");

        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

Examples of com.arjuna.mw.wstx.UserTransaction

{

    public static void testNullRollbackOnly()
            throws Exception
    {
        UserTransaction ut = UserTransactionFactory.userTransaction();
  try
  {
        ut = UserTransactionFactory.userTransaction();

      ut.begin();
     
      ut.setRollbackOnly();
     
      ut.commit();
  }
  catch (TransactionRolledBackException ex)
  {
      // we should get here
    } catch (Exception eouter) {
        try {
            ut.rollback();
        } catch(Exception einner) {
        }
        throw eouter;
    }
    }
View Full Code Here

Examples of javax.transaction.UserTransaction

      }
   }

   public void executeSql(String resource, Connection conn)
   {
     UserTransaction tx =null;
     try
     {
       tx =  (UserTransaction)new InitialContext().lookup("UserTransaction");
       tx.begin();
      
       log.debug("Execute SQL from resource: "+resource);

       URL url = Thread.currentThread().getContextClassLoader().getResource(resource);
      
       log.debug("Execute SQL from resource URL: "+url);
      
       String sql = getStringFromStream(url.openStream());
       sql = sql.replaceAll("(?m)^--([^\n]+)?$", ""); // Remove all commented lines
       final String[] statements ;
       if (useEOL) {
           statements = sql.split("[\n;]");
       } else {
           statements = sql.split(";");
       }
       for (String statement : statements)
       {
         if ((statement == null) || ("".equals(statement.trim()))) {
         }
         else {
            Statement sqlStatement = conn.createStatement();
            try
            {
               sqlStatement.executeUpdate(statement);
            }
            finally
            {
               sqlStatement.close();
            }
         }
       }

       tx.commit();
     }
     catch (Throwable t)
     {
       if(tx!=null)
         try {
           tx.rollback();
         } catch (SystemException e) {
           //
         }
       throw new RuntimeException("Failed to create database", t);
     }
View Full Code Here

Examples of javax.transaction.UserTransaction

    }

  @SuppressWarnings("unchecked")
  public void clear() {
      try {
          UserTransaction ut = (UserTransaction) new InitialContext().lookup( "java:comp/UserTransaction" );
          ut.begin();
          List<ProcessInstanceLog> processInstances = getEntityManager()
        .createQuery("FROM ProcessInstanceLog").getResultList();
          for (ProcessInstanceLog processInstance: processInstances) {
            getEntityManager().remove(processInstance);
          }
        List<NodeInstanceLog> nodeInstances = getEntityManager()
        .createQuery("FROM NodeInstanceLog").getResultList();
        for (NodeInstanceLog nodeInstance: nodeInstances) {
          getEntityManager().remove(nodeInstance);
        }
        em.joinTransaction();
      ut.commit();
    } catch (SecurityException e) {
      e.printStackTrace();
    } catch (IllegalStateException e) {
      e.printStackTrace();
    } catch (RollbackException e) {
View Full Code Here

Examples of javax.transaction.UserTransaction

  private UserTransaction getUserTransaction()
      throws NamingException
  {
    InitialContext ctx = new InitialContext();
    UserTransaction tx = (UserTransaction)ctx.lookup("UserTransaction");
    return tx;
  }
View Full Code Here

Examples of javax.transaction.UserTransaction

   {
      try
      {
         if (configuration.isUseJTA())
         {
            UserTransaction tx = (UserTransaction)new InitialContext().lookup("java:comp/UserTransaction");
            if (tx.getStatus() == Status.STATUS_NO_TRANSACTION)
            {
               tx.begin();
            }
         }
         else
         {
            if (!idmService_.getIdentitySession().getTransaction().isActive())
View Full Code Here

Examples of javax.transaction.UserTransaction

   {
      try
      {
         if (configuration.isUseJTA())
         {
            UserTransaction tx = (UserTransaction)new InitialContext().lookup("java:comp/UserTransaction");
            tx.commit();
         }           
         else
         {
            idmService_.getIdentitySession().getTransaction().commit();
         }
View Full Code Here

Examples of javax.transaction.UserTransaction

               if (checkAndSetState())
               {
                  return;
               }
               long time = System.currentTimeMillis();
               UserTransaction tx = getTransaction();
               tx.begin();
               if (checkAndSetState())
               {
                  try
                  {
                     tx.rollback();
                  }
                  catch (Exception e)
                  {
                  }
                  return;
               }
               // the first worker would create a new node for the FQN
               // all the others would update the same node
               Fqn fqn = Fqn.fromString("/NODE/" + i);
               for (int m = 0; m < m_modificationsPerTx; m++)
               {
                  cache.put(fqn, m, i);
                  if (checkAndSetState())
                  {
                     try
                     {
                        tx.rollback();
                     }
                     catch (Exception e)
                     {
                     }
                     return;
                  }
               }
               tx.commit();
               if (checkAndSetState())
               {
                  return;
               }
               time = System.currentTimeMillis() - time;
View Full Code Here

Examples of javax.transaction.UserTransaction

        MyEntity myEntity = new MyEntity("This is a test Entity with annotation in fields");
        MyEntityMethods myEntityMethods = new MyEntityMethods("This is a test Entity with annotations in methods");
        MyEntityOnlyFields myEntityOnlyFields = new MyEntityOnlyFields("This is a test Entity with annotations in fields and without accesors methods");
        MyVariableSerializable myVariableSerializable = new MyVariableSerializable("This is a test SerializableObject");
        EntityManager em = emf.createEntityManager();
        UserTransaction utx = (UserTransaction) new InitialContext().lookup( "java:comp/UserTransaction" );
        utx.begin();
        em.joinTransaction();
        em.persist(myEntity);
        em.persist(myEntityMethods);
        em.persist(myEntityOnlyFields);
        utx.commit();
        em.close();
        Environment env =  createEnvironment();
        KnowledgeBase kbase = createKnowledgeBase( "VariablePersistenceStrategyProcess.rf" );
        StatefulKnowledgeSession ksession = createSession( kbase, env );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.