Java 类org.springframework.jdbc.datasource.JdbcTransactionObjectSupport 实例源码

项目:dubbo-transaction    文件:DubboTransactionDataSourceTransactonManager.java   
@Override
protected void doCommit(DefaultTransactionStatus status) {
    String prefix="";
    if(logger.isDebugEnabled()) {
        prefix += "[" + TransactionId.get().getCurrentId() + "]";
        try {
            Connection connection = ((JdbcTransactionObjectSupport)status.getTransaction()).getConnectionHolder().getConnection();
            prefix += "[" + (null != connection ? connection : "") + "]";
        } catch (Exception e) {}
    }
    logger.debug(prefix+"DataSource doCommit");
    //将status持久化到jvm内存
    if(null!=TransactionContextFactory.getInstance()&& TransactionSupport.isProxy()){
        logger.debug(prefix+"DataSource doCommit before store");
        Transaction transaction=TransactionContextFactory.getInstance().persistent(status);
        if(transaction instanceof DBTransaction){
            logger.debug(prefix+"DataSource doCommit in store");
            DBTransaction dbT=(DBTransaction)transaction;
            dbT.setDataSource(getDataSource());
            dbT.setIsNewConnectionHolder(checkNewConnectionHolder(status.getTransaction()));
        }
    }else{//如果事务容器工厂类初始化失败,执行默认逻辑
        logger.debug(prefix+"DataSource doCommit don't store");
        super.doCommit(status);
        super.doCleanupAfterCompletion(status.getTransaction());
    }
}
项目:dubbo-transaction    文件:DBTransaction.java   
public boolean prepare(){
    try {
        if (status.getTransaction() instanceof JdbcTransactionObjectSupport) {
            JdbcTransactionObjectSupport support = (JdbcTransactionObjectSupport) status.getTransaction();
            ConnectionHolder holder = support.getConnectionHolder();
            Connection con = holder.getConnection();
            return !con.isClosed() && !con.isReadOnly();
        }
    }catch (Exception e){
    }
    return false;
}
项目:dubbo-transaction    文件:DBTransaction.java   
@Override
public boolean commit() throws SQLException {
    logger.debug("[realDbCommit]"+getTransactionId().getCurrentId());
    if(status.getTransaction() instanceof JdbcTransactionObjectSupport){
        JdbcTransactionObjectSupport support=(JdbcTransactionObjectSupport)status.getTransaction();
        ConnectionHolder holder=support.getConnectionHolder();
        Connection con = holder.getConnection();
        con.commit();
        logger.debug("[realDbCommit]["+getTransactionId().getCurrentId()+"]"+con);
    }
    clearConnection();
    return true;
}
项目:dubbo-transaction    文件:DBTransaction.java   
@Override
public boolean rollback() throws SQLException {
    if(status.getTransaction() instanceof JdbcTransactionObjectSupport) {
        JdbcTransactionObjectSupport support = (JdbcTransactionObjectSupport) status.getTransaction();
        ConnectionHolder holder = support.getConnectionHolder();
        Connection con = holder.getConnection();
        con.rollback();
    }
    clearConnection();
    return true;
}
项目:training    文件:TransactionUtilImpl.java   
@Override
public Object getTransactionOpaqueIdentity() {
    JdbcTransactionObjectSupport txImplementation = (JdbcTransactionObjectSupport) ((DefaultTransactionStatus) getCurrentTransactionStatus())
            .getTransaction();
    return txImplementation.getConnectionHolder().getConnectionHandle();
}
项目:training    文件:TransactionUtil.java   
public Object getTransactionOpaqueIdentity() {
    JdbcTransactionObjectSupport txImplementation = (JdbcTransactionObjectSupport) ((DefaultTransactionStatus) getCurrentTransactionStatus())
            .getTransaction();
    return txImplementation.getConnectionHolder().getConnectionHandle();
}