srpingTransaction

业务

private void updateDynamicAndSolrInfo(Long leadsId, Long userId) {

Leads leads = baseDao.get(Leads.class, leadsId);

final String leadsName = leads.getCompName();

final UserPhotoVO userPhotoVO = userInfoManager.getById(userId);

final String msg = SecurityUtils.getCurrentUser().getRealName() + "将线索【" + leadsName + "】转移 给了"

+ userPhotoVO.getRealName();

final Long fLeadsId = leadsId;

TransactionUtils.addTransactionCallBack(new TransactionCallBack() {

@Override

public void afterCommit() {

// TODO Auto-generated method stub

addCombineDynamic(fLeadsId, leadsName, msg);

}

});

}

-----------------------

 

 

 

/** 

 * Copyright (C) 2014 Winbons Technology Software Co.,Ltd

 * All Rights Reserved.

 * Development of this softwareWinbons Technology Software Co.,Ltd.

 * Without the formal written consent of the Company, 

 * any other individuals, groups may not use, 

 * copy, modify, or distribute this software

 * @Title: TransactionUtils.java 

 * @Package saas.framework.tx 

 * @Description: TODO(用一句话描述该文件做什么) 

 * @author star.ye 

 * @date 2014年10月15日 下午12:01:53 

 * @version 1.0 

 */

package saas.framework.tx;

import org.springframework.transaction.support.TransactionSynchronizationManager;

/**

 * @ClassName: TransactionUtils

 * @Description: TODO(这里用一句话描述这个类的作用)

 * @author star.ye

 * @date 2014年10月15日 下午12:01:53

 */

public class TransactionUtils {

public static final void addTransactionCallBack(TransactionCallBack transactionCallBack) {

TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdater(

transactionCallBack));

}

}

  

        /** 

         * Copyright (C) 2014 Winbons Technology Software Co.,Ltd

         * All Rights Reserved.

         * Development of this softwareWinbons Technology Software Co.,Ltd.

         * Without the formal written consent of the Company, 

         * any other individuals, groups may not use, 

         * copy, modify, or distribute this software

         * @Title: TransactionSynchronizationAdater.java 

         * @Package saas.framework.tx 

         * @Description: TODO(用一句话描述该文件做什么) 

         * @author star.ye 

         * @date 2014年10月15日 下午12:03:48 

         * @version 1.0 

         */   

     

    

package saas.framework.tx;

import org.springframework.transaction.support.TransactionSynchronizationAdapter;

  

        /** 

 * @ClassName: TransactionSynchronizationAdater 

 * @Description: TODO(这里用一句话描述这个类的作用) 

 * @author star.ye

 * @date 2014年10月15日 下午12:03:48  

 */

public class TransactionSynchronizationAdater extends TransactionSynchronizationAdapter {

private TransactionCallBack transactionCallBack;

public TransactionSynchronizationAdater(TransactionCallBack transactionCallBack) {

super();

this.transactionCallBack = transactionCallBack;

}

public void afterCommit() {

transactionCallBack.afterCommit();

}

}

 

 

 

 

 

  

        /** 

         * Copyright (C) 2014 Winbons Technology Software Co.,Ltd

         * All Rights Reserved.

         * Development of this softwareWinbons Technology Software Co.,Ltd.

         * Without the formal written consent of the Company, 

         * any other individuals, groups may not use, 

         * copy, modify, or distribute this software

         * @Title: TransactionCallBack.java 

         * @Package saas.framework.tx 

         * @Description: TODO(用一句话描述该文件做什么) 

         * @author star.ye 

         * @date 2014年10月15日 下午12:02:59 

         * @version 1.0 

         */   

     

    

package saas.framework.tx;

  

        /** 

 * @ClassName: TransactionCallBack 

 * @Description: TODO(这里用一句话描述这个类的作用) 

 * @author star.ye

 * @date 2014年10月15日 下午12:02:59  

 */

public interface TransactionCallBack {

public void afterCommit();

}

 

猜你喜欢

转载自u011820505.iteye.com/blog/2337291