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


Java TransactionDefinition.PROPAGATION_REQUIRED屬性代碼示例

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


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

示例1: invoke

@Override
public EasyTransResult invoke(EasyTransFilterChain filterChain, Map<String, Object> header,
		EasyTransRequest<?, ?> request) {

	Integer pTrxStatus = MetaDataFilter.getMetaData(EasytransConstant.CallHeadKeys.PARENT_TRANSACTION_STATUS);
	if(!pTrxStatus.equals(com.yiqiniu.easytrans.datasource.TransStatusLogger.TransactionStatus.UNKNOWN)){
		// start transaction to update 
		PlatformTransactionManager transactionManager = getTransactionManager(filterChain, request);
		TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager,
				new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED));
		TransactionId pTrxId = MetaDataFilter.getMetaData(EasytransConstant.CallHeadKeys.PARENT_TRX_ID_KEY);
		transactionTemplate.execute(new TransactionCallback<Object>() {
			@Override
			public Object doInTransaction(TransactionStatus status) {
				TransactionId trxId = pTrxId;
				transStatusLogger.updateExecuteFlagForSlaveTrx(trxId, request, pTrxStatus);
				return null;
			}
		});
		boolean commited = pTrxStatus.equals(com.yiqiniu.easytrans.datasource.TransStatusLogger.TransactionStatus.COMMITTED);
		//may be concurrent,but it's ok
		easyTransSynchronizer.cascadeExecuteCachedTransaction(pTrxId, commited);
	}
	
	return filterChain.invokeFilterChain(header, request);
}
 
開發者ID:QNJR-GROUP,項目名稱:EasyTransaction,代碼行數:26,代碼來源:ParentTrxStatusUpdateFilter.java

示例2: execGroovyRetObjByDbTranNest

public Object execGroovyRetObjByDbTranNest(String groovyName, String methodName, Integer nestDef,
			Object... paramArray) throws Exception{
/*		MicroMetaDao microDao=MicroMetaDao.getInstance(dbName,dbType);
		DataSource dataSource=microDao.getMicroDataSource();
		PlatformTransactionManager  transactionManager=new DataSourceTransactionManager(dataSource);*/
		PlatformTransactionManager  transactionManager=MicroTranManagerHolder.getTransactionManager(dbName);
	    DefaultTransactionDefinition def =new DefaultTransactionDefinition();
	    def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_COMMITTED);
	    if(nestDef==null){
	    	nestDef=TransactionDefinition.PROPAGATION_REQUIRED;
	    }
	    def.setPropagationBehavior(nestDef);
	    TransactionStatus status=transactionManager.getTransaction(def);
	    try
	    {
	    	Object retObj= GroovyExecUtil.execGroovyRetObj(groovyName, methodName, paramArray);
	    	transactionManager.commit(status);
	    	return retObj;
	    }
	    catch(Exception ex)
	    {
	    	transactionManager.rollback(status);
	        throw ex;
	    }
		
	}
 
開發者ID:jeffreyning,項目名稱:nh-micro,代碼行數:26,代碼來源:MicroServiceTemplateSupport.java

示例3: testToStringMatchesEditor

@Test
public void testToStringMatchesEditor() {
	List<RollbackRuleAttribute> list = new LinkedList<RollbackRuleAttribute>();
	list.add(new NoRollbackRuleAttribute("Throwable"));
	RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, list);

	TransactionAttributeEditor tae = new TransactionAttributeEditor();
	tae.setAsText(rta.toString());
	rta = (RuleBasedTransactionAttribute) tae.getValue();

	assertFalse(rta.rollbackOn(new Throwable()));
	assertFalse(rta.rollbackOn(new RuntimeException()));
	assertFalse(rta.rollbackOn(new MyRuntimeException("")));
	assertFalse(rta.rollbackOn(new Exception()));
	assertFalse(rta.rollbackOn(new IOException()));
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:16,代碼來源:RuleBasedTransactionAttributeTests.java

示例4: getNextEntities

/**
 * @return List of next entities for this connection or none if there are no one left.
 * @throws Exception
 *             Exception.
 * */
public Collection<T> getNextEntities() throws Exception {
    if (externalHighestCommittedUSN <= internalHighestCommittedUSN) {
        return null;
    }
    LdapSearchBaseDefinition searchBase = getSearchBaseDefinitions().get(
            currentSearchBaseIndex);
    Collection<T> entities = null;
    while ((entities = getNextEntities(searchBase)) == null || entities.size() == 0) {
        currentSearchBaseIndex++;
        if (currentSearchBaseIndex >= getSearchBaseDefinitions().size()) {
            return null;
        }
        transactionDefinition = new DefaultTransactionDefinition(
                TransactionDefinition.PROPAGATION_REQUIRED);
        pagedResultsControl = new PagedResultsDirContextProcessor(pagingSize);
        noEntitiesLeft = false;
        searchBase = getSearchBaseDefinitions().get(currentSearchBaseIndex);
    }
    return entities;
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:25,代碼來源:Retriever.java

示例5: getTxn

private UserTransaction getTxn()
{
    return new SpringAwareUserTransaction(
            transactionManager,
            false,
            TransactionDefinition.ISOLATION_DEFAULT,
            TransactionDefinition.PROPAGATION_REQUIRED,
            TransactionDefinition.TIMEOUT_DEFAULT);
}
 
開發者ID:Alfresco,項目名稱:alfresco-core,代碼行數:9,代碼來源:SpringAwareUserTransactionTest.java

示例6: getFailingTxn

private UserTransaction getFailingTxn()
{
    return new SpringAwareUserTransaction(
            failingTransactionManager,
            false,
            TransactionDefinition.ISOLATION_DEFAULT,
            TransactionDefinition.PROPAGATION_REQUIRED,
            TransactionDefinition.TIMEOUT_DEFAULT);
}
 
開發者ID:Alfresco,項目名稱:alfresco-core,代碼行數:9,代碼來源:SpringAwareUserTransactionTest.java

示例7: testRuleForRollbackOnChecked

/**
 * Test one checked exception that should roll back.
 */
@Test
public void testRuleForRollbackOnChecked() {
	List<RollbackRuleAttribute> list = new LinkedList<RollbackRuleAttribute>();
	list.add(new RollbackRuleAttribute(IOException.class.getName()));
	RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, list);

	assertTrue(rta.rollbackOn(new RuntimeException()));
	assertTrue(rta.rollbackOn(new MyRuntimeException("")));
	assertFalse(rta.rollbackOn(new Exception()));
	// Check that default behaviour is overridden
	assertTrue(rta.rollbackOn(new IOException()));
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:15,代碼來源:RuleBasedTransactionAttributeTests.java

示例8: testRuleForCommitOnUnchecked

@Test
public void testRuleForCommitOnUnchecked() {
	List<RollbackRuleAttribute> list = new LinkedList<RollbackRuleAttribute>();
	list.add(new NoRollbackRuleAttribute(MyRuntimeException.class.getName()));
	list.add(new RollbackRuleAttribute(IOException.class.getName()));
	RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, list);

	assertTrue(rta.rollbackOn(new RuntimeException()));
	// Check default behaviour is overridden
	assertFalse(rta.rollbackOn(new MyRuntimeException("")));
	assertFalse(rta.rollbackOn(new Exception()));
	// Check that default behaviour is overridden
	assertTrue(rta.rollbackOn(new IOException()));
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:14,代碼來源:RuleBasedTransactionAttributeTests.java

示例9: testRuleForSelectiveRollbackOnCheckedWithString

@Test
public void testRuleForSelectiveRollbackOnCheckedWithString() {
	List<RollbackRuleAttribute> l = new LinkedList<RollbackRuleAttribute>();
	l.add(new RollbackRuleAttribute(java.rmi.RemoteException.class.getName()));
	RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, l);
	doTestRuleForSelectiveRollbackOnChecked(rta);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:7,代碼來源:RuleBasedTransactionAttributeTests.java

示例10: testRuleForCommitOnSubclassOfChecked

/**
 * Check that a rule can cause commit on a IOException
 * when Exception prompts a rollback.
 */
@Test
public void testRuleForCommitOnSubclassOfChecked() {
	List<RollbackRuleAttribute> list = new LinkedList<RollbackRuleAttribute>();
	// Note that it's important to ensure that we have this as
	// a FQN: otherwise it will match everything!
	list.add(new RollbackRuleAttribute("java.lang.Exception"));
	list.add(new NoRollbackRuleAttribute("IOException"));
	RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, list);

	assertTrue(rta.rollbackOn(new RuntimeException()));
	assertTrue(rta.rollbackOn(new Exception()));
	// Check that default behaviour is overridden
	assertFalse(rta.rollbackOn(new IOException()));
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:18,代碼來源:RuleBasedTransactionAttributeTests.java

示例11: testRollbackNever

@Test
public void testRollbackNever() {
	List<RollbackRuleAttribute> list = new LinkedList<RollbackRuleAttribute>();
	list.add(new NoRollbackRuleAttribute("Throwable"));
	RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, list);

	assertFalse(rta.rollbackOn(new Throwable()));
	assertFalse(rta.rollbackOn(new RuntimeException()));
	assertFalse(rta.rollbackOn(new MyRuntimeException("")));
	assertFalse(rta.rollbackOn(new Exception()));
	assertFalse(rta.rollbackOn(new IOException()));
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:12,代碼來源:RuleBasedTransactionAttributeTests.java

示例12: testConflictingRulesToDetermineExactContract

/**
 * See <a href="http://forum.springframework.org/showthread.php?t=41350">this forum post</a>.
 */
@Test
public void testConflictingRulesToDetermineExactContract() {
	List<RollbackRuleAttribute> list = new LinkedList<RollbackRuleAttribute>();
	list.add(new NoRollbackRuleAttribute(MyBusinessWarningException.class));
	list.add(new RollbackRuleAttribute(MyBusinessException.class));
	RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, list);

	assertTrue(rta.rollbackOn(new MyBusinessException()));
	assertFalse(rta.rollbackOn(new MyBusinessWarningException()));
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:13,代碼來源:RuleBasedTransactionAttributeTests.java

示例13: propagationBehaviorToString

private static String propagationBehaviorToString(int propagationBehavior) {
    String rc;
    switch (propagationBehavior) {
    case TransactionDefinition.PROPAGATION_MANDATORY:
        rc = "PROPAGATION_MANDATORY";
        break;
    case TransactionDefinition.PROPAGATION_NESTED:
        rc = "PROPAGATION_NESTED";
        break;
    case TransactionDefinition.PROPAGATION_NEVER:
        rc = "PROPAGATION_NEVER";
        break;
    case TransactionDefinition.PROPAGATION_NOT_SUPPORTED:
        rc = "PROPAGATION_NOT_SUPPORTED";
        break;
    case TransactionDefinition.PROPAGATION_REQUIRED:
        rc = "PROPAGATION_REQUIRED";
        break;
    case TransactionDefinition.PROPAGATION_REQUIRES_NEW:
        rc = "PROPAGATION_REQUIRES_NEW";
        break;
    case TransactionDefinition.PROPAGATION_SUPPORTS:
        rc = "PROPAGATION_SUPPORTS";
        break;
    default:
        rc = "UNKNOWN";
    }
    return rc;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:29,代碼來源:TransactionErrorHandler.java

示例14: testRuleForSelectiveRollbackOnCheckedWithClass

@Test
public void testRuleForSelectiveRollbackOnCheckedWithClass() {
	List<RollbackRuleAttribute> l = Collections.singletonList(new RollbackRuleAttribute(RemoteException.class));
	RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, l);
	doTestRuleForSelectiveRollbackOnChecked(rta);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:6,代碼來源:RuleBasedTransactionAttributeTests.java

示例15: createTransactionDefinition

/**
 * Returns a <code>TransactionDefinition</code> object containing the
 * necessary transaction parameters. Simply returns a default
 * <code>DefaultTransactionDefinition</code> object with the 'propagation
 * required' attribute
 *
 * @param testObject The test object, not null
 * @return The default TransactionDefinition
 */
protected TransactionDefinition createTransactionDefinition(Object testObject) {
    return new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED);
}
 
開發者ID:linux-china,項目名稱:unitils,代碼行數:12,代碼來源:DefaultUnitilsTransactionManager.java


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