本文整理匯總了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);
}
}
});
}
示例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);
}
}
});
}
示例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);
}
}
});
}
示例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);
}
}
});
}
示例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);
}
}
});
}
示例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);
}
}
});
}
示例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);
}
}
});
}
示例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);
}
}
});
}
示例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);
}
}
});
}
示例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);
}
}
});
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}