b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

odbc连接scan ip_weblogic连接scan ip_weblogic数据源连接池(17)

电脑杂谈  发布时间:2017-01-31 20:11:17  来源:网络整理

JobStoreTX 控制并发代码

	/**
	 * Execute the given callback having optionally aquired the given lock.
	 * For <code>JobStoreTX</code>, because it manages its own transactions
	 * and only has the one datasource, this is the same behavior as 
	 * executeInNonManagedTXLock(). 
	 * @param lockName The name of the lock to aquire, for example 
	 * "TRIGGER_ACCESS".  If null, then no lock is aquired, but the
	 * lockCallback is still executed in a transaction.
	 * 
	 * @see JobStoreSupport#executeInNonManagedTXLock(String, TransactionCallback)
 	* @see JobStoreCMT#executeInLock(String, TransactionCallback)
 	* @see JobStoreSupport#getNonManagedTXConnection()
 	* @see JobStoreSupport#getConnection()
	*/
    protected Object executeInLock(String lockName, TransactionCallback txCallback) throws JobPersistenceException {
        return executeInNonManagedTXLock(lockName, txCallback);
    }
 
	使用JobStoreSupport.executeInNonManagedTXLock 实现:
	/**
     * Execute the given callback having optionally aquired the given lock.
     * This uses the non-managed transaction connection.
     * 
     * @param lockName The name of the lock to aquire, for example 
     * "TRIGGER_ACCESS".  If null, then no lock is aquired, but the
     * lockCallback is still executed in a non-managed transaction. 
     */
    protected Object executeInNonManagedTXLock(
            String lockName, 
            TransactionCallback txCallback) throws JobPersistenceException {
        boolean transOwner = false;
        Connection conn = null;
        try {
            if (lockName != null) {
                // If we aren't using db locks, then delay getting DB connection 
                // until after acquiring the lock since it isn't needed.
                if (getLockHandler().requiresConnection()) {
                    conn = getNonManagedTXConnection();
                }
				//获取锁
                transOwner = getLockHandler().obtainLock(conn, lockName);
            }
            if (conn == null) {
                conn = getNonManagedTXConnection();
            }
       		//回调需要执行的sql语句如:(更新Trigger为运行中(ACQUIRED),删除执行过的Trigger等)
            Object result = txCallback.execute(conn);
			//JobStoreTX自身维护事务
            commitConnection(conn);
            Long sigTime = clearAndGetSignalSchengChangeOnTxCompletion();
            if(sigTime != null && sigTime >= 0) {
                signalSchengChangeImmediately(sigTime);
            }
            return result;
        } catch (JobPersistenceException e) {
            rollbackConnection(conn);
            throw e;
        } catch (RuntimeException e) {
            rollbackConnection(conn);
            throw new JobPersistenceException("Unexpected runtime exception: " + e.getMessage(), e);
        } finally {
            try {
				//释放锁
                releaseLock(conn, lockName, transOwner);
            } finally {
                cleanupConnection(conn);
            }
        }
    }


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-29777-17.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    • 马俊瑶
      马俊瑶

      让所谓盟国有底气来对抗中国

    热点图片
    拼命载入中...