當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultTransactionDefinition.setTimeout方法代碼示例

本文整理匯總了Java中org.springframework.transaction.support.DefaultTransactionDefinition.setTimeout方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultTransactionDefinition.setTimeout方法的具體用法?Java DefaultTransactionDefinition.setTimeout怎麽用?Java DefaultTransactionDefinition.setTimeout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.transaction.support.DefaultTransactionDefinition的用法示例。


在下文中一共展示了DefaultTransactionDefinition.setTimeout方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: TransactionImpl

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
public TransactionImpl(PlatformTransactionManager transactionManager, PersistenceImpl persistence, boolean join,
                       @Nullable TransactionParams params, String storeName) {
    this.tm = transactionManager;
    this.persistence = persistence;
    this.storeName = storeName;

    td = new DefaultTransactionDefinition();
    if (join)
        td.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    else
        td.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);

    if (params != null) {
        if (params.getTimeout() != 0)
            td.setTimeout(params.getTimeout());
        if (params.isReadOnly())
            td.setReadOnly(true);
    }

    ts = tm.getTransaction(td);

    persistence.registerSynchronizations(storeName);
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:24,代碼來源:TransactionImpl.java

示例2: execute

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
@Override
public <T> T execute(final Function<Session, T> callback) {
    try {
        DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
        definition.setIsolationLevel(getTransactionIsolation().getTransactionIsolation());
        int timeout = getTimeout();
        if (timeout  >= 0) {
            definition.setTimeout(timeout);
        }
        definition.setReadOnly(isReadOnly());
        return connectionProvider.connection(false, connection -> {
            Session session =  newSession(connection);
            TransactionTemplate tt = new TransactionTemplate(platformTransactionManager, definition);
            return tt.execute(transactionStatus -> callback.apply(session));
        });
    } catch (final Exception e) {
        throw JdbcTemplateExceptionTranslator.doTranslate(e);
    }
}
 
開發者ID:ufoscout,項目名稱:jporm,代碼行數:20,代碼來源:JdbcTemplateTransaction.java

示例3: beginTransaction

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
private void beginTransaction(Context ctx)
{
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    if (timeout > 0)
    {
        def.setTimeout(timeout);
    }
    TransactionStatus tx = tm.getTransaction(def);
    ctx.put(TX, tx);
}
 
開發者ID:vmantek,項目名稱:chimera,代碼行數:11,代碼來源:Open.java

示例4: newTransactionWithCommitAndTimeout

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
@Test
public void newTransactionWithCommitAndTimeout() {
	MockUOWManager manager = new MockUOWManager();
	WebSphereUowTransactionManager ptm = new WebSphereUowTransactionManager(manager);
	DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
	definition.setTimeout(10);
	definition.setReadOnly(true);

	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
	assertFalse(TransactionSynchronizationManager.isActualTransactionActive());
	assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());

	assertEquals("result", ptm.execute(definition, new TransactionCallback<String>() {
		@Override
		public String doInTransaction(TransactionStatus status) {
			assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
			assertTrue(TransactionSynchronizationManager.isActualTransactionActive());
			assertTrue(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
			return "result";
		}
	}));

	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
	assertFalse(TransactionSynchronizationManager.isActualTransactionActive());
	assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());

	assertEquals(10, manager.getUOWTimeout());
	assertEquals(UOWManager.UOW_TYPE_GLOBAL_TRANSACTION, manager.getUOWType());
	assertFalse(manager.getJoined());
	assertFalse(manager.getRollbackOnly());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:32,代碼來源:WebSphereUowTransactionManagerTests.java

示例5: createTransactionTemplate

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
/**
 * Creates the transaction template.
 * <p>
 * This is Hibernate aware if Hibernate is available.
 * 
 * @param repo  the component repository, only used to register secondary items like lifecycle, not null
 * @param hibernateSessionFactory  the session factory, not null
 * @return the template, not null
 */
protected TransactionTemplate createTransactionTemplate(ComponentRepository repo, SessionFactory hibernateSessionFactory) {
  DefaultTransactionDefinition transactionDef = new DefaultTransactionDefinition();
  transactionDef.setName(getName());
  if (getTransactionIsolationLevel() != null) {
    transactionDef.setIsolationLevelName(getTransactionIsolationLevel());
  }
  if (getTransactionPropagationBehavior() != null) {
    transactionDef.setPropagationBehaviorName(getTransactionPropagationBehavior());
  }
  if (getTransactionTimeout() != 0) {
    transactionDef.setTimeout(getTransactionTimeout());
  }
  return new TransactionTemplate(createTransactionManager(repo, hibernateSessionFactory), transactionDef);
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:24,代碼來源:DbConnectorComponentFactory.java

示例6: createTransactionDefinition

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
/**
 * Creates the transaction definition.
 * 
 * @return the transaction definition, not null
 */
protected DefaultTransactionDefinition createTransactionDefinition() {
  DefaultTransactionDefinition transDefn = new DefaultTransactionDefinition();
  transDefn.setName(getName());
  if (getTransactionIsolationLevelName() != null) {
    transDefn.setIsolationLevelName(getTransactionIsolationLevelName());
  }
  if (getTransactionPropagationBehaviorName() != null) {
    transDefn.setPropagationBehaviorName(getTransactionPropagationBehaviorName());
  }
  if (getTransactionTimeout() != 0) {
    transDefn.setTimeout(getTransactionTimeout());
  }
  return transDefn;
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:20,代碼來源:DbConnectorFactoryBean.java

示例7: start

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
public void start() throws Exception {
	LOG.info("Starting a transaction from TransactionalLifecycle...");
    DefaultTransactionDefinition defaultTransactionDefinition = new DefaultTransactionDefinition();
    defaultTransactionDefinition.setTimeout(3600);
    TRANSACTION_STATUS = getTransactionManager().getTransaction(defaultTransactionDefinition);
    started = true;
}
 
開發者ID:kuali,項目名稱:kc-rice,代碼行數:8,代碼來源:TransactionalLifecycle.java

示例8: testNewTransactionWithCommitAndTimeout

import org.springframework.transaction.support.DefaultTransactionDefinition; //導入方法依賴的package包/類
public void testNewTransactionWithCommitAndTimeout() {
	MockUOWManager manager = new MockUOWManager();
	WebSphereUowTransactionManager ptm = new WebSphereUowTransactionManager(manager);
	DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
	definition.setTimeout(10);
	definition.setReadOnly(true);

	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
	assertFalse(TransactionSynchronizationManager.isActualTransactionActive());
	assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());

	assertEquals("result", ptm.execute(definition, new TransactionCallback() {
		@Override
		public Object doInTransaction(TransactionStatus status) {
			assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
			assertTrue(TransactionSynchronizationManager.isActualTransactionActive());
			assertTrue(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
			return "result";
		}
	}));

	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
	assertFalse(TransactionSynchronizationManager.isActualTransactionActive());
	assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());

	assertEquals(10, manager.getUOWTimeout());
	assertEquals(UOWManager.UOW_TYPE_GLOBAL_TRANSACTION, manager.getUOWType());
	assertFalse(manager.getJoined());
	assertFalse(manager.getRollbackOnly());
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:31,代碼來源:WebSphereUowTransactionManagerTests.java


注:本文中的org.springframework.transaction.support.DefaultTransactionDefinition.setTimeout方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。