Package org.springframework.transaction.support

Examples of org.springframework.transaction.support.DefaultTransactionDefinition


   * @param action
   * @return
   */
  private static void executeLogicInNewTransaction(ActivityElement activityXml, ActivityInst activityInst, IAction action) {
    PlatformTransactionManager txManager = ApplicationContextHolder.getBean(PlatformTransactionManager.class);
    DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
    definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    TransactionStatus status = txManager.getTransaction(definition);
    try {
      action.execute(activityXml, activityInst);
      txManager.commit(status);
    } catch (Exception e) {
View Full Code Here


   * @return
   */
  private static void executeLogicInNewTransaction(ProcessDefine processDefine,
      ProcessInstance processInstance, IAction action) {
    PlatformTransactionManager txManager = ApplicationContextHolder.getBean(PlatformTransactionManager.class);
    DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
    definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    TransactionStatus status = txManager.getTransaction(definition);
    try {
      action.execute(processDefine, processInstance);
      txManager.commit(status);
    } catch (Exception e) {
View Full Code Here

    }

  @Override
  public TransactionStatus begin() {
    if(transactionManager != null) {
      DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
      TransactionStatus txStatus = transactionManager.getTransaction(definition);
      return txStatus;
    } else {
      return null;
    }
View Full Code Here

  }
 
  @Override
  public TransactionStatus begin(int propagationBehavior) {
    if(transactionManager != null) {
      DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
      definition.setPropagationBehavior(propagationBehavior);
      TransactionStatus txStatus = transactionManager.getTransaction(definition);
      return txStatus;
    } else {
      return null;
    }
View Full Code Here

  private void setupTransactionManagers(PlatformTransactionManager... transactionManagers) {
    tm = new ChainedTransactionManager(new TestSynchronizationManager(), transactionManagers);
  }

  private void createAndRollbackTransaction() {
    MultiTransactionStatus transaction = tm.getTransaction(new DefaultTransactionDefinition());
    tm.rollback(transaction);
  }
View Full Code Here

    MultiTransactionStatus transaction = tm.getTransaction(new DefaultTransactionDefinition());
    tm.rollback(transaction);
  }

  private void createAndCommitTransaction() {
    MultiTransactionStatus transaction = tm.getTransaction(new DefaultTransactionDefinition());
    tm.commit(transaction);
  }
View Full Code Here

   
    public void testSaveWithCommit() {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Id null before adding:
        assertNull(emp.getId());
        // Save:
        this.template.save(emp);
        // Id not null after adding:
View Full Code Here

   
    public void testDoubleCommit() {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Save:
        this.template.save(emp);
        // Commit the transaction status:
        this.transactionManager.commit(status);
        // The double commit fails:
View Full Code Here

   
    public void testSaveWithTimeout() throws InterruptedException {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Save
        this.template.save(emp);
        // Go to sleep, waiting for timeout:
        Thread.sleep(2000);
        // Trying to commit will failbecause the transaction has been aborted due to the timeout:
View Full Code Here

   
    public void testSaveWithRollback() {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Save
        this.template.save(emp);
        // Verify that the employee has been saved in the current transaction scope:
        EmployeeImpl emp2 = (EmployeeImpl) this.template.get(Employee.class, emp.getId());
        assertNotNull(emp);
View Full Code Here

TOP

Related Classes of org.springframework.transaction.support.DefaultTransactionDefinition

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.