当前位置: 首页>>代码示例>>Java>>正文


Java TransactionCallbackWithoutResult类代码示例

本文整理汇总了Java中org.springframework.transaction.support.TransactionCallbackWithoutResult的典型用法代码示例。如果您正苦于以下问题:Java TransactionCallbackWithoutResult类的具体用法?Java TransactionCallbackWithoutResult怎么用?Java TransactionCallbackWithoutResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TransactionCallbackWithoutResult类属于org.springframework.transaction.support包,在下文中一共展示了TransactionCallbackWithoutResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: remove

import org.springframework.transaction.support.TransactionCallbackWithoutResult; //导入依赖的package包/类
/**
 * 删除Channel
 */
public void remove(final Long channelId) {
    Assert.assertNotNull(channelId);

    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            try {
                arbitrateManageService.channelEvent().destory(channelId);
                channelDao.delete(channelId);
            } catch (Exception e) {
                logger.error("ERROR ## remove channel has an exception ", e);
                throw new ManagerException(e);
            }
        }
    });

}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:22,代码来源:ChannelServiceImpl.java

示例2: remove

import org.springframework.transaction.support.TransactionCallbackWithoutResult; //导入依赖的package包/类
/**
 * 删除
 */
public void remove(final Long pipelineId) {
    Assert.assertNotNull(pipelineId);
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            try {
                PipelineDO pipelineDO = pipelineDao.findById(pipelineId);
                if (pipelineDO != null) {
                    pipelineDao.delete(pipelineId);
                    pipelineNodeRelationDao.deleteByPipelineId(pipelineId);
                    // 删除历史cursor
                    String destination = pipelineDO.getParameters().getDestinationName();
                    short clientId = pipelineDO.getId().shortValue();
                    arbitrateViewService.removeCanal(destination, clientId);
                    arbitrateManageService.pipelineEvent().destory(pipelineDO.getChannelId(), pipelineId);
                }
            } catch (Exception e) {
                logger.error("ERROR ## remove the pipeline(" + pipelineId + ") has an exception!");
                throw new ManagerException(e);
            }
        }
    });
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:28,代码来源:PipelineServiceImpl.java

示例3: create

import org.springframework.transaction.support.TransactionCallbackWithoutResult; //导入依赖的package包/类
/**
 * 添加
 */
public void create(final DataMatrix matrix) {
    Assert.assertNotNull(matrix);
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        protected void doInTransactionWithoutResult(TransactionStatus status) {

            try {
                DataMatrixDO matrixlDO = modelToDo(matrix);
                matrixlDO.setId(0L);
                matrixlDO.setGroupKey(matrixlDO.getGroupKey()+TimeUtil.getTime0());
                if (!dataMatrixDao.checkUnique(matrixlDO)) {
                    String exceptionCause = "exist the same repeat canal in the database.";
                    logger.warn("WARN ## " + exceptionCause);
                    throw new RepeatConfigureException(exceptionCause);
                }
                dataMatrixDao.insert(matrixlDO);
            } catch (RepeatConfigureException rce) {
                throw rce;
            } catch (Exception e) {
                logger.error("ERROR ## create canal has an exception!");
                throw new ManagerException(e);
            }
        }
    });
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:29,代码来源:DataMatrixServiceImpl.java

示例4: remove

import org.springframework.transaction.support.TransactionCallbackWithoutResult; //导入依赖的package包/类
/**
 * 删除
 */
public void remove(final Long matrixId) {
    Assert.assertNotNull(matrixId);
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        protected void doInTransactionWithoutResult(TransactionStatus status) {

            try {
                dataMatrixDao.delete(matrixId);
            } catch (Exception e) {
                logger.error("ERROR ## remove canal(" + matrixId + ") has an exception!");
                throw new ManagerException(e);
            }
        }
    });

}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:20,代码来源:DataMatrixServiceImpl.java

示例5: modify

import org.springframework.transaction.support.TransactionCallbackWithoutResult; //导入依赖的package包/类
/**
 * 修改
 */
public void modify(final DataMatrix matrix) {
    Assert.assertNotNull(matrix);
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        protected void doInTransactionWithoutResult(TransactionStatus status) {

            try {
                DataMatrixDO matrixDo = modelToDo(matrix);
                if (dataMatrixDao.checkUnique(matrixDo)) {
                    dataMatrixDao.update(matrixDo);
                } else {
                    String exceptionCause = "exist the same repeat matrix in the database.";
                    logger.warn("WARN ## " + exceptionCause);
                    throw new RepeatConfigureException(exceptionCause);
                }
            } catch (RepeatConfigureException rce) {
                throw rce;
            } catch (Exception e) {
                logger.error("ERROR ## modify canal(" + matrix.getId() + ") has an exception!");
                throw new ManagerException(e);
            }
        }
    });

}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:29,代码来源:DataMatrixServiceImpl.java

示例6: remove

import org.springframework.transaction.support.TransactionCallbackWithoutResult; //导入依赖的package包/类
/**
 * 删除
 */
public void remove(final Long canalId) {
    Assert.assertNotNull(canalId);
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        protected void doInTransactionWithoutResult(TransactionStatus status) {

            try {
                Canal canal = findById(canalId);
                canalDao.delete(canalId);
                arbitrateViewService.removeCanal(canal.getName()); // 删除canal节点信息
            } catch (Exception e) {
                logger.error("ERROR ## remove canal(" + canalId + ") has an exception!");
                throw new ManagerException(e);
            }
        }
    });

}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:22,代码来源:CanalServiceImpl.java

示例7: modify

import org.springframework.transaction.support.TransactionCallbackWithoutResult; //导入依赖的package包/类
/**
 * 修改
 */
public void modify(final Canal canal) {
    Assert.assertNotNull(canal);
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        protected void doInTransactionWithoutResult(TransactionStatus status) {

            try {
                CanalDO canalDo = modelToDo(canal);
                if (canalDao.checkUnique(canalDo)) {
                    canalDao.update(canalDo);
                } else {
                    String exceptionCause = "exist the same repeat canal in the database.";
                    logger.warn("WARN ## " + exceptionCause);
                    throw new RepeatConfigureException(exceptionCause);
                }
            } catch (RepeatConfigureException rce) {
                throw rce;
            } catch (Exception e) {
                logger.error("ERROR ## modify canal(" + canal.getId() + ") has an exception!");
                throw new ManagerException(e);
            }
        }
    });

}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:29,代码来源:CanalServiceImpl.java

示例8: create

import org.springframework.transaction.support.TransactionCallbackWithoutResult; //导入依赖的package包/类
/**
 * 添加
 */
public void create(final Node node) {
    Assert.assertNotNull(node);
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        protected void doInTransactionWithoutResult(TransactionStatus status) {

            try {
                NodeDO nodeDo = modelToDo(node);
                nodeDo.setId(0L);
                if (!nodeDao.checkUnique(nodeDo)) {
                    String exceptionCause = "exist the same repeat node in the database.";
                    logger.warn("WARN ## " + exceptionCause);
                    throw new RepeatConfigureException(exceptionCause);
                }
                nodeDao.insert(nodeDo);

            } catch (RepeatConfigureException rce) {
                throw rce;
            } catch (Exception e) {
                logger.error("ERROR ## create node has an exception!");
                throw new ManagerException(e);
            }
        }
    });
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:29,代码来源:NodeServiceImpl.java

示例9: remove

import org.springframework.transaction.support.TransactionCallbackWithoutResult; //导入依赖的package包/类
/**
 * 删除
 */
public void remove(final Long nodeId) {
    Assert.assertNotNull(nodeId);
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        protected void doInTransactionWithoutResult(TransactionStatus status) {

            try {
                nodeDao.delete(nodeId);
            } catch (Exception e) {
                logger.error("ERROR ## remove node(" + nodeId + ") has an exception!");
                throw new ManagerException(e);
            }
        }
    });

}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:20,代码来源:NodeServiceImpl.java

示例10: modify

import org.springframework.transaction.support.TransactionCallbackWithoutResult; //导入依赖的package包/类
/**
 * 修改
 */
public void modify(final Node node) {
    Assert.assertNotNull(node);
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        protected void doInTransactionWithoutResult(TransactionStatus status) {

            try {
                NodeDO nodeDo = modelToDo(node);
                if (nodeDao.checkUnique(nodeDo)) {
                    nodeDao.update(nodeDo);
                } else {
                    String exceptionCause = "exist the same repeat node in the database.";
                    logger.warn("WARN ## " + exceptionCause);
                    throw new RepeatConfigureException(exceptionCause);
                }
            } catch (RepeatConfigureException rce) {
                throw rce;
            } catch (Exception e) {
                logger.error("ERROR ## modify node(" + node.getId() + ") has an exception!");
                throw new ManagerException(e);
            }
        }
    });

}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:29,代码来源:NodeServiceImpl.java

示例11: testInvalidIsolation

import org.springframework.transaction.support.TransactionCallbackWithoutResult; //导入依赖的package包/类
@Test
public void testInvalidIsolation() {
	tt.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE);

	given(manager.isOpen()).willReturn(true);

	try {
		tt.execute(new TransactionCallbackWithoutResult() {
			@Override
			protected void doInTransactionWithoutResult(TransactionStatus status) {
			}
		});
		fail("Should have thrown InvalidIsolationLevelException");
	}
	catch (InvalidIsolationLevelException ex) {
		// expected
	}

	verify(manager).close();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:JpaTransactionManagerTests.java

示例12: testTransactionFlush

import org.springframework.transaction.support.TransactionCallbackWithoutResult; //导入依赖的package包/类
@Test
public void testTransactionFlush() {
	given(manager.getTransaction()).willReturn(tx);

	assertTrue(!TransactionSynchronizationManager.hasResource(factory));
	assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());

	tt.execute(new TransactionCallbackWithoutResult() {
		@Override
		public void doInTransactionWithoutResult(TransactionStatus status) {
			assertTrue(TransactionSynchronizationManager.hasResource(factory));
			status.flush();
		}
	});

	assertTrue(!TransactionSynchronizationManager.hasResource(factory));
	assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());

	verify(tx).commit();
	verify(manager).flush();
	verify(manager).close();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:JpaTransactionManagerTests.java

示例13: testIsolationLevel

import org.springframework.transaction.support.TransactionCallbackWithoutResult; //导入依赖的package包/类
@Test
public void testIsolationLevel() {
	given(pmf.getPersistenceManager()).willReturn(pm);
	given(pm.currentTransaction()).willReturn(tx);

	PlatformTransactionManager tm = new JdoTransactionManager(pmf);
	TransactionTemplate tt = new TransactionTemplate(tm);
	tt.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE);
	tt.execute(new TransactionCallbackWithoutResult() {
		@Override
		protected void doInTransactionWithoutResult(TransactionStatus status) {
		}
	});
	verify(tx).setIsolationLevel(Constants.TX_SERIALIZABLE);
	verify(pm).close();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:JdoTransactionManagerTests.java

示例14: testTransactionFlush

import org.springframework.transaction.support.TransactionCallbackWithoutResult; //导入依赖的package包/类
@Test
public void testTransactionFlush() {
	given(pmf.getPersistenceManager()).willReturn(pm);
	given(pm.currentTransaction()).willReturn(tx);

	PlatformTransactionManager tm = new JdoTransactionManager(pmf);
	TransactionTemplate tt = new TransactionTemplate(tm);
	assertTrue("Hasn't thread pm", !TransactionSynchronizationManager.hasResource(pmf));
	assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());

	tt.execute(new TransactionCallbackWithoutResult() {
		@Override
		public void doInTransactionWithoutResult(TransactionStatus status) {
			assertTrue("Has thread pm", TransactionSynchronizationManager.hasResource(pmf));
			status.flush();
		}
	});

	assertTrue("Hasn't thread pm", !TransactionSynchronizationManager.hasResource(pmf));
	assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());
	verify(pm).flush();
	verify(pm).close();
	verify(tx).begin();
	verify(tx).commit();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:JdoTransactionManagerTests.java

示例15: transactionTemplateWithException

import org.springframework.transaction.support.TransactionCallbackWithoutResult; //导入依赖的package包/类
@Test
public void transactionTemplateWithException() {
	TestTransactionManager tm = new TestTransactionManager(false, true);
	TransactionTemplate template = new TransactionTemplate(tm);
	final RuntimeException ex = new RuntimeException("Some application exception");
	try {
		template.execute(new TransactionCallbackWithoutResult() {
			@Override
			protected void doInTransactionWithoutResult(TransactionStatus status) {
				throw ex;
			}
		});
		fail("Should have propagated RuntimeException");
	}
	catch (RuntimeException caught) {
		// expected
		assertTrue("Correct exception", caught == ex);
		assertTrue("triggered begin", tm.begin);
		assertTrue("no commit", !tm.commit);
		assertTrue("triggered rollback", tm.rollback);
		assertTrue("no rollbackOnly", !tm.rollbackOnly);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:TransactionSupportTests.java


注:本文中的org.springframework.transaction.support.TransactionCallbackWithoutResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。