Package org.springframework.transaction

Examples of org.springframework.transaction.PlatformTransactionManager


   * @param activityInst
   * @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) {
      txManager.rollback(status);
      throw new ProcessEngineException("触发事件执行失败", e);
    }
  }
View Full Code Here


    Assert.notNull(applicationContext);
    this.applicationContext = applicationContext;
    this.configuration = configuration;
   
    //获取事务Bean
    PlatformTransactionManager transactionManager = null;
    if(this.applicationContext.containsBean(TRANSACTION_MANAGER_NAME) &&
        configuration.getBoolean(Environment.IS_USE_TRANSACTION)) {
      transactionManager = (PlatformTransactionManager)this.applicationContext.getBean(TRANSACTION_MANAGER_NAME);
    } else {
      logger.warn("Process Engine no Transaction");
View Full Code Here

   * @param action
   * @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) {
      txManager.rollback(status);
      throw new ProcessEngineException("触发事件执行失败", e);
    }
  }
View Full Code Here

    context.register(BatchConfiguration.class);
    context.refresh();
    JobRepository jobRepository = context.getBean(JobRepository.class);
    jobLauncher = context.getBean(JobLauncher.class);
    jobs = new JobBuilderFactory(jobRepository);
    PlatformTransactionManager transactionManager = this.context.getBean(PlatformTransactionManager.class);
    steps = new StepBuilderFactory(jobRepository, transactionManager);
    step = steps.get("step").tasklet(new Tasklet() {
      @Override
      public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
        return null;
View Full Code Here

    MultiTransactionStatus multiTransactionStatus = (MultiTransactionStatus) status;

    boolean commit = true;
    Exception commitException = null;
    PlatformTransactionManager commitExceptionTransactionManager = null;

    for (PlatformTransactionManager transactionManager : reverse(transactionManagers)) {

      if (commit) {
View Full Code Here

   * @see org.springframework.transaction.PlatformTransactionManager#rollback(org.springframework.transaction.TransactionStatus)
   */
  public void rollback(TransactionStatus status) throws TransactionException {

    Exception rollbackException = null;
    PlatformTransactionManager rollbackExceptionTransactionManager = null;

    MultiTransactionStatus multiTransactionStatus = (MultiTransactionStatus) status;

    for (PlatformTransactionManager transactionManager : reverse(transactionManagers)) {
      try {
View Full Code Here

  ChainedTransactionManager tm;

  @Test
  public void shouldCompleteSuccessfully() throws Exception {

    PlatformTransactionManager transactionManager = createNonFailingTransactionManager("single");
    setupTransactionManagers(transactionManager);

    createAndCommitTransaction();

    assertThat(transactionManager, isCommitted());
View Full Code Here

  }

  @Test
  public void shouldCommitAllRegisteredTransactionManagers() {

    PlatformTransactionManager first = createNonFailingTransactionManager("first");
    PlatformTransactionManager second = createNonFailingTransactionManager("second");

    setupTransactionManagers(first, second);
    createAndCommitTransaction();

    assertThat(first, isCommitted());
View Full Code Here

  }

  @Test
  public void shouldCommitInReverseOrder() {

    PlatformTransactionManager first = createNonFailingTransactionManager("first");
    PlatformTransactionManager second = createNonFailingTransactionManager("second");

    setupTransactionManagers(first, second);
    createAndCommitTransaction();

    assertThat("second tm commited before first ", commitTime(first) >= commitTime(second), is(true));
View Full Code Here

  }

  @Test
  public void shouldRollbackAllTransactionManagers() throws Exception {

    PlatformTransactionManager first = createNonFailingTransactionManager("first");
    PlatformTransactionManager second = createNonFailingTransactionManager("second");

    setupTransactionManagers(first, second);
    createAndRollbackTransaction();

    assertThat(first, wasRolledback());
View Full Code Here

TOP

Related Classes of org.springframework.transaction.PlatformTransactionManager

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.