亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? jtanonclusteredsemaphore.java

?? Java中非常實用流控制工具
?? JAVA
字號:
/*  * Copyright 2004-2006 OpenSymphony  *  * Licensed under the Apache License, Version 2.0 (the "License"); you may not  * use this file except in compliance with the License. You may obtain a copy  * of the License at  *  *   http://www.apache.org/licenses/LICENSE-2.0  *    * Unless required by applicable law or agreed to in writing, software  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the  * License for the specific language governing permissions and limitations  * under the License. *  */package org.quartz.impl.jdbcjobstore;import java.sql.Connection;import java.util.HashSet;import javax.naming.InitialContext;import javax.naming.NamingException;import javax.transaction.Synchronization;import javax.transaction.SystemException;import javax.transaction.Transaction;import javax.transaction.TransactionManager;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;/** * Provides in memory thread/resource locking that is JTA  * <code>{@link javax.transaction.Transaction}</code> aware.   * It is most appropriate for use when using  * <code>{@link org.quartz.impl.jdbcjobstore.JobStoreCMT}</code> without clustering. *  * <p> * This <code>Semaphore</code> implementation is <b>not</b> Quartz cluster safe.   * </p> *   * <p> * When a lock is obtained/released but there is no active JTA  * <code>{@link javax.transaction.Transaction}</code>, then this <code>Semaphore</code> operates * just like <code>{@link org.quartz.impl.jdbcjobstore.SimpleSemaphore}</code>.  * </p> *  * <p> * By default, this class looks for the <code>{@link javax.transaction.TransactionManager}</code> * in JNDI under name "java:TransactionManager".  If this is not where your Application Server  * registers it, you can modify the JNDI lookup location using the  * "transactionManagerJNDIName" property. * </p> * * <p> * <b>IMPORTANT:</b>  This Semaphore implementation is currently experimental.   * It has been tested a limited amount on JBoss 4.0.3SP1.  If you do choose to  * use it, any feedback would be most appreciated!  * </p> *  * @see org.quartz.impl.jdbcjobstore.SimpleSemaphore */public class JTANonClusteredSemaphore implements Semaphore {    /*     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     *      * Data members.     *      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     */    public static final String DEFAULT_TRANSACTION_MANANGER_LOCATION = "java:TransactionManager";    ThreadLocal lockOwners = new ThreadLocal();    HashSet locks = new HashSet();    private final Log log = LogFactory.getLog(getClass());    private String transactionManagerJNDIName = DEFAULT_TRANSACTION_MANANGER_LOCATION;            /*     * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     *      * Interface.     *      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     */    protected Log getLog() {        return log;    }    public void setTransactionManagerJNDIName(String transactionManagerJNDIName) {        this.transactionManagerJNDIName = transactionManagerJNDIName;    }        private HashSet getThreadLocks() {        HashSet threadLocks = (HashSet) lockOwners.get();        if (threadLocks == null) {            threadLocks = new HashSet();            lockOwners.set(threadLocks);        }        return threadLocks;    }    /**     * Grants a lock on the identified resource to the calling thread (blocking     * until it is available).     *      * @return true if the lock was obtained.     */    public synchronized boolean obtainLock(Connection conn, String lockName) throws LockException {        lockName = lockName.intern();        Log log = getLog();        if(log.isDebugEnabled()) {            log.debug(                "Lock '" + lockName + "' is desired by: "                        + Thread.currentThread().getName());        }        if (!isLockOwner(conn, lockName)) {            if(log.isDebugEnabled()) {                log.debug(                    "Lock '" + lockName + "' is being obtained: "                            + Thread.currentThread().getName());            }                        while (locks.contains(lockName)) {                try {                    this.wait();                } catch (InterruptedException ie) {                    if(log.isDebugEnabled()) {                        log.debug(                            "Lock '" + lockName + "' was not obtained by: "                                    + Thread.currentThread().getName());                    }                }            }            // If we are in a transaction, register a callback to actually release            // the lock when the transaction completes            Transaction t = getTransaction();            if (t != null) {                try {                    t.registerSynchronization(new SemaphoreSynchronization(lockName));                } catch (Exception e) {                    throw new LockException("Failed to register semaphore with Transaction.", e);                }            }                        if(log.isDebugEnabled()) {                log.debug(                    "Lock '" + lockName + "' given to: "                            + Thread.currentThread().getName());            }                                    getThreadLocks().add(lockName);            locks.add(lockName);        } else if(log.isDebugEnabled()) {            log.debug(                "Lock '" + lockName + "' already owned by: "                        + Thread.currentThread().getName()                        + " -- but not owner!",                new Exception("stack-trace of wrongful returner"));        }        return true;    }    /**     * Helper method to get the current <code>{@link javax.transaction.Transaction}</code>     * from the <code>{@link javax.transaction.TransactionManager}</code> in JNDI.     *      * @return The current <code>{@link javax.transaction.Transaction}</code>, null if     * not currently in a transaction.     */    protected Transaction getTransaction() throws LockException{        InitialContext ic = null;         try {            ic = new InitialContext();             TransactionManager tm = (TransactionManager)ic.lookup(transactionManagerJNDIName);                        return tm.getTransaction();        } catch (SystemException e) {            throw new LockException("Failed to get Transaction from TransactionManager", e);        } catch (NamingException e) {            throw new LockException("Failed to find TransactionManager in JNDI under name: " + transactionManagerJNDIName, e);        } finally {            if (ic != null) {                try {                    ic.close();                } catch (NamingException ignored) {                }            }        }    }        /**     * Release the lock on the identified resource if it is held by the calling     * thread, unless currently in a JTA transaction.     */    public synchronized void releaseLock(Connection conn, String lockName) throws LockException {        releaseLock(lockName, false);    }        /**     * Release the lock on the identified resource if it is held by the calling     * thread, unless currently in a JTA transaction.     *      * @param fromSynchronization True if this method is being invoked from     *      <code>{@link Synchronization}</code> notified of the enclosing      *      transaction having completed.     *      * @throws LockException Thrown if there was a problem accessing the JTA      *      <code>Transaction</code>.  Only relevant if <code>fromSynchronization</code>     *      is false.     */    protected synchronized void releaseLock(        String lockName, boolean fromSynchronization) throws LockException {        lockName = lockName.intern();        if (isLockOwner(null, lockName)) {                        if (fromSynchronization == false) {                Transaction t = getTransaction();                if (t != null) {                    if(getLog().isDebugEnabled()) {                        getLog().debug(                            "Lock '" + lockName + "' is in a JTA transaction.  " +                             "Return deferred by: " + Thread.currentThread().getName());                    }                                        // If we are still in a transaction, then we don't want to                     // actually release the lock.                    return;                }            }                        if(getLog().isDebugEnabled()) {                getLog().debug(                    "Lock '" + lockName + "' returned by: "                            + Thread.currentThread().getName());            }            getThreadLocks().remove(lockName);            locks.remove(lockName);            this.notify();        } else if (getLog().isDebugEnabled()) {            getLog().debug(                "Lock '" + lockName + "' attempt to return by: "                        + Thread.currentThread().getName()                        + " -- but not owner!",                new Exception("stack-trace of wrongful returner"));        }    }    /**     * Determine whether the calling thread owns a lock on the identified     * resource.     */    public synchronized boolean isLockOwner(Connection conn, String lockName) {        lockName = lockName.intern();        return getThreadLocks().contains(lockName);    }    /**     * This Semaphore implementation does not use the database.     */    public boolean requiresConnection() {        return false;    }    /**     * Helper class that is registered with the active      * <code>{@link javax.transaction.Transaction}</code> so that the lock     * will be released when the transaction completes.     */    private class SemaphoreSynchronization implements Synchronization {        private String lockName;                public SemaphoreSynchronization(String lockName) {            this.lockName = lockName;        }                public void beforeCompletion() {            // nothing to do...        }            public void afterCompletion(int status) {            try {                releaseLock(lockName, true);            } catch (LockException e) {                // Ignore as can't be thrown with fromSynchronization set to true            }        }    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一级一级性生活免费录像| 亚洲二区在线视频| 国产麻豆精品在线观看| 久久久www成人免费无遮挡大片| 91天堂素人约啪| 九色综合国产一区二区三区| 亚洲国产三级在线| 国产九色精品成人porny| 日韩不卡一二三区| 亚洲成av人片一区二区梦乃| 亚洲最新视频在线观看| 亚洲美女精品一区| 亚洲国产电影在线观看| 精品国产三级a在线观看| 欧美一级精品在线| 精品国产91久久久久久久妲己 | 97精品国产露脸对白| 美美哒免费高清在线观看视频一区二区 | 91视视频在线直接观看在线看网页在线看| 欧美精品久久99| 26uuu亚洲综合色| 日韩小视频在线观看专区| 亚洲人被黑人高潮完整版| 激情五月婷婷综合| 国产成人综合亚洲网站| 国产成人综合亚洲91猫咪| 91麻豆精品国产自产在线| 91精品国产麻豆| 亚洲成人精品影院| 色欧美日韩亚洲| 欧美日韩五月天| 欧美色成人综合| 亚洲综合丁香婷婷六月香| 美国三级日本三级久久99| 欧美日韩精品系列| 欧美精品一区二区三区在线| 奇米精品一区二区三区在线观看 | 欧美喷水一区二区| 亚洲在线视频网站| 欧美亚一区二区| 欧美精品一区二区三区视频| 久久精品二区亚洲w码| av电影天堂一区二区在线| 色欧美日韩亚洲| 亚洲伊人伊色伊影伊综合网 | 国产福利一区二区三区视频 | 国产精品女人毛片| 亚洲一区二区三区美女| 色综合久久中文字幕综合网| 亚洲精品视频在线观看网站| 激情综合色播五月| wwwwww.欧美系列| 国产成人在线色| 18涩涩午夜精品.www| 精品一区二区三区蜜桃| 久久久高清一区二区三区| 丁香天五香天堂综合| 国产原创一区二区| 国产精品免费av| 一本久久a久久免费精品不卡| 亚洲影院理伦片| 久久综合视频网| 99久久精品国产麻豆演员表| 一区二区三区四区视频精品免费| 欧美浪妇xxxx高跟鞋交| 激情综合色综合久久综合| 最近日韩中文字幕| 国产成人在线视频播放| 亚洲综合自拍偷拍| 精品国产青草久久久久福利| 成人黄页毛片网站| 中文字幕乱码亚洲精品一区| 91福利在线播放| 亚洲精品菠萝久久久久久久| 欧美日韩国产欧美日美国产精品| 美女视频黄a大片欧美| 国产精品美女久久久久久| 欧美日韩国产三级| 91久久国产综合久久| 日韩在线卡一卡二| 欧美日韩久久不卡| 国产高清精品网站| 婷婷综合另类小说色区| 在线观看av一区二区| 亚洲免费观看在线观看| 日韩一区二区高清| 99久久99久久免费精品蜜臀| 蜜桃视频在线观看一区二区| 国产精品福利一区二区三区| 97久久精品人人做人人爽50路| 日韩电影免费在线观看网站| 中文字幕亚洲综合久久菠萝蜜| 日韩一级片在线观看| 色欧美乱欧美15图片| 国产91高潮流白浆在线麻豆| 男男gaygay亚洲| 亚洲一级不卡视频| 国产精品久久二区二区| 久久青草国产手机看片福利盒子| 欧美色手机在线观看| eeuss国产一区二区三区| 精品无码三级在线观看视频| 天堂在线一区二区| 亚洲综合色噜噜狠狠| 亚洲免费观看视频| 亚洲另类一区二区| 中文字幕中文乱码欧美一区二区| 欧美精品一区二区三区高清aⅴ| 欧美精品第一页| 欧美日韩国产综合草草| 欧美日韩国产免费一区二区| 在线精品国精品国产尤物884a| 99在线热播精品免费| 懂色av一区二区三区免费看| 丁香婷婷深情五月亚洲| 粗大黑人巨茎大战欧美成人| 国产精一区二区三区| 国产乱人伦精品一区二区在线观看| 蜜臀91精品一区二区三区| 日本美女视频一区二区| 日韩精品一卡二卡三卡四卡无卡| 亚洲va天堂va国产va久| 亚洲va国产va欧美va观看| 亚洲一区二区三区三| 天堂av在线一区| 男人的j进女人的j一区| 久久99久久99小草精品免视看| 日本sm残虐另类| 极品美女销魂一区二区三区 | 成人激情午夜影院| 99久久免费视频.com| 色综合一个色综合| 日韩国产精品91| 日韩黄色在线观看| 国产主播一区二区三区| 国产98色在线|日韩| 99久久免费视频.com| 在线观看成人免费视频| 日韩欧美国产一区在线观看| 色综合天天综合在线视频| 色偷偷久久一区二区三区| 欧美日韩中文另类| 91麻豆精品久久久久蜜臀| 精品国产三级电影在线观看| 婷婷综合另类小说色区| 久久99精品国产.久久久久| 国产成人精品免费一区二区| 97久久精品人人做人人爽| 欧美日韩一区二区不卡| 久久综合精品国产一区二区三区| 国产精品美女久久久久久久久 | 久久久久久久久久看片| 国产精品久久久久久久久久免费看 | 亚洲免费成人av| 免费观看30秒视频久久| 成人爱爱电影网址| 51久久夜色精品国产麻豆| 国产亚洲一本大道中文在线| 日韩精品一区二区三区中文不卡| 国产亚洲欧美一级| 婷婷六月综合网| 成人动漫一区二区三区| 欧美电视剧在线看免费| 亚洲日穴在线视频| 久久se精品一区精品二区| 在线观看亚洲成人| 欧美激情资源网| 久久精品国产网站| 91精品1区2区| 国产精品人人做人人爽人人添| 午夜精品福利一区二区三区av | 91精品啪在线观看国产60岁| 欧美国产日韩一二三区| 日韩av电影天堂| 在线精品视频免费观看| 中文无字幕一区二区三区| 亚洲小少妇裸体bbw| 国产91对白在线观看九色| 亚洲精品一区二区在线观看| 亚洲午夜精品久久久久久久久| aaa亚洲精品| 欧美韩国日本综合| 国产在线播精品第三| 日韩三级视频中文字幕| 亚洲成人黄色小说| 日本高清成人免费播放| 亚洲欧洲日本在线| 高清成人在线观看| 国产午夜精品一区二区| 精品一区二区三区久久久| 日韩丝袜美女视频| 国产精品77777竹菊影视小说| 欧美日韩国产一二三| 亚洲国产日韩精品| 日本久久一区二区| 夜夜精品视频一区二区| 91福利精品第一导航| 亚洲女人的天堂| 日本丶国产丶欧美色综合| 亚洲精品老司机|