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

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

?? destinations.java

?? 一個java方面的消息訂閱發送的源碼
?? JAVA
字號:
/**
 * Redistribution and use of this software and associated documentation
 * ("Software"), with or without modification, are permitted provided
 * that the following conditions are met:
 *
 * 1. Redistributions of source code must retain copyright
 *    statements and notices.  Redistributions must also contain a
 *    copy of this document.
 *
 * 2. Redistributions in binary form must reproduce the
 *    above copyright notice, this list of conditions and the
 *    following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. The name "Exolab" must not be used to endorse or promote
 *    products derived from this Software without prior written
 *    permission of Exoffice Technologies.  For written permission,
 *    please contact info@exolab.org.
 *
 * 4. Products derived from this Software may not be called "Exolab"
 *    nor may "Exolab" appear in their names without prior written
 *    permission of Exoffice Technologies. Exolab is a registered
 *    trademark of Exoffice Technologies.
 *
 * 5. Due credit should be given to the Exolab Project
 *    (http://www.exolab.org/).
 *
 * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
 * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * Copyright 2000-2005 (C) Exoffice Technologies Inc. All Rights Reserved.
 */
package org.exolab.jms.persistence;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Vector;

import org.exolab.jms.client.JmsDestination;
import org.exolab.jms.client.JmsQueue;
import org.exolab.jms.client.JmsTopic;


/**
 * This class provides persistency for JmsDestination objects
 * in an RDBMS database
 *
 * @version     $Revision: 1.3 $ $Date: 2005/06/09 14:39:51 $
 * @author      <a href="mailto:tma@netspace.net.au">Tim Anderson</a>
 * @see         org.exolab.jms.client.JmsDestination
 * @see         org.exolab.jms.persistence.RDBMSAdapter
 **/
class Destinations {

    /**
     * Cache of all destinations indexed on names
     */
    private HashMap _destinations;

    /**
     * Cache of all destinations indexed on identity
     */
    private HashMap _ids;

    /**
     * Singleton instance of this class
     */
    private static Destinations _instance;

    /**
     * This is used to synchronize the creation of the singleton
     */
    private static final Object _block = new Object();

    /**
     * This is the name of the destination id generator, which uniquely created
     * identities for destinations
     */
    private static final String DESTINATION_ID_SEED = "destinationId";

    /**
     * Constructor
     *
     * @throws PersistenceException - if constructor fails
     */
    private Destinations()
        throws PersistenceException {

        _destinations = new HashMap();
        _ids = new HashMap();
    }

    /**
     * Returns the singleton instance.
     *
     * Note that initialise() must have been invoked first for this
     * to return a valid instance.
     *
     * @return      Destinations       the singleton instance
     */
    public static Destinations instance() {
        return _instance;
    }

    /**
     * Initialise the singleton instance
     *
     * @param connection - the connection to use
     * @return Destinations - the singleton instance
     * @throws PersistenceException - if initialisation fails
     */
    public static Destinations initialise(Connection connection)
        throws PersistenceException {

        if (_instance == null) {
            synchronized (_block) {
                if (_instance == null) {
                    _instance = new Destinations();
                    _instance.load(connection);
                }
            }
        }
        return _instance;
    }

    /**
     * Add a new destination to the database. This method will also assign
     * it a unique identity.
     *
     * @param connection - the connection to use.
     * @param destination - the destination to add
     * @throws PersistenceException - if the destination cannot be added
     */
    public synchronized void add(Connection connection,
                                 JmsDestination destination)
        throws PersistenceException {

        PreparedStatement insert = null;
        try {
            long Id = SeedGenerator.instance().next(connection,
                DESTINATION_ID_SEED);
            boolean isQueue = (destination instanceof JmsQueue);

            insert = connection.prepareStatement(
                "insert into destinations (name, isqueue, destinationid) "
                + "values (?, ?, ?)");
            insert.setString(1, destination.getName());
            insert.setBoolean(2, isQueue);
            insert.setLong(3, Id);
            insert.executeUpdate();
            cache(destination, Id);
        } catch (Exception error) {
            throw new PersistenceException("Destinations.add failed with " +
                error.toString());
        } finally {
            SQLHelper.close(insert);
        }
    }

    /**
     * Remove a destination from the database.
     * This removes all associated consumers, and messages.
     *
     * @param connection - the connection to use
     * @param destination - the destination
     * @return boolean - <tt>true</tt> if it was removed
     * @throws PersistenceException - if the request fails
     */
    public synchronized boolean remove(Connection connection,
                                       JmsDestination destination)
        throws PersistenceException {

        boolean success = false;
        PreparedStatement deleteDestinations = null;
        PreparedStatement deleteMessages = null;
        PreparedStatement deleteConsumers = null;
        PreparedStatement deleteMessageHandles = null;

        Pair pair = (Pair) _destinations.get(destination.getName());
        if (pair != null) {
            try {
                deleteDestinations = connection.prepareStatement(
                    "delete from destinations where name=?");
                deleteDestinations.setString(1, destination.getName());

                deleteMessages = connection.prepareStatement(
                    "delete from messages where destinationId=?");
                deleteMessages.setLong(1, pair.Id);

                deleteMessageHandles = connection.prepareStatement(
                    "delete from message_handles where destinationId=?");
                deleteMessageHandles.setLong(1, pair.Id);

                deleteConsumers = connection.prepareStatement(
                    "delete from consumers where destinationId=?");
                deleteConsumers.setLong(1, pair.Id);


                deleteDestinations.executeUpdate();
                deleteMessages.executeUpdate();
                deleteMessageHandles.executeUpdate();
                deleteConsumers.executeUpdate();

                Consumers.instance().removeCached(pair.Id);
                _destinations.remove(destination.getName());
                _ids.remove(new Long(pair.Id));
                success = true;
            } catch (Exception error) {
                throw new PersistenceException("Destinations.remove failed " +
                    error.toString());
            } finally {
                SQLHelper.close(deleteDestinations);
                SQLHelper.close(deleteMessages);
                SQLHelper.close(deleteConsumers);
                SQLHelper.close(deleteMessageHandles);
            }
        }

        return success;
    }

    /**
     * Returns the destination associated with name
     *
     * @param name - the name of the destination
     * @return JmsDestination - the destination, or null
     */
    public synchronized JmsDestination get(String name) {
        Pair pair = (Pair) _destinations.get(name);
        return (pair != null) ? pair.destination : null;
    }

    /**
     * Returns the destination associated with Id
     *
     * @param id - the destination Id
     * @return JmsDestination - the destination or null
     */
    public synchronized JmsDestination get(long id) {
        Pair pair = (Pair) _ids.get(new Long(id));
        return (pair != null) ? pair.destination : null;
    }

    /**
     * Returns the Id for a given destination name
     *
     * @param name - the destination name
     * @return long - the destination Id, or 0
     */
    public synchronized long getId(String name) {
        Pair pair = (Pair) _destinations.get(name);
        return (pair != null) ? pair.Id : 0;
    }

    /**
     * Returns the list of destination names
     *
     * @return Vector - list of destination names
     */
    public synchronized Vector getNames() {
        // return a Vector for legacy reasons.
        Vector result = new Vector(_destinations.size());
        Iterator iter = _destinations.keySet().iterator();
        while (iter.hasNext()) {
            result.add((String) iter.next());
        }

        return result;
    }

    /**
     * Returns the list of destination objects
     *
     * @return Vector - list of destination objects
     */
    public synchronized Vector getDestinations() {
        // return a Vector for legacy reasons.
        Vector result = new Vector(_destinations.size());
        Iterator iter = _destinations.values().iterator();
        while (iter.hasNext()) {
            result.add(((Pair) iter.next()).destination);
        }

        return result;
    }

    /**
     * Deallocates resources owned or referenced by the instance
     */
    public synchronized void close() {
        _destinations.clear();
        _destinations = null;

        _ids.clear();
        _ids = null;

        _instance = null;
    }

    /**
     * Load all the destinations in memory. It uses the transaction service
     * and the database service to access the appropriate resources.
     *
     * @param connection - the connection to use
     * @throws PersistenceException - problems loading the destinations
     */
    private void load(Connection connection)
        throws PersistenceException {

        PreparedStatement select = null;
        ResultSet set = null;
        try {
            select = connection.prepareStatement(
                "select name, isqueue, destinationid from destinations");

            set = select.executeQuery();
            String name = null;
            boolean isQueue = false;
            JmsDestination destination = null;
            long Id = 0;
            while (set.next()) {
                name = set.getString(1);
                isQueue = set.getBoolean(2);
                destination = (isQueue)
                    ? (JmsDestination) new JmsQueue(name)
                    : (JmsDestination) new JmsTopic(name);
                Id = set.getLong(3);
                destination.setPersistent(true);
                cache(destination, Id);
            }
        } catch (Exception exception) {
            throw new PersistenceException("Failed to load destinations",
                                           exception);
        } finally {
            SQLHelper.close(set);
            SQLHelper.close(select);
        }
    }

    /**
     * This method is used to cache a destination
     *
     * @param destination - the destination to cache
     * @param Id - the destination identity
     */
    private void cache(JmsDestination destination, long Id) {
        Pair pair = new Pair(destination, Id);

        _destinations.put(destination.getName(), pair);
        _ids.put(new Long(Id), pair);
    }


    /**
     * This private static class holds the name and identity of the
     * destination
     */
    private static class Pair {

        public Pair(JmsDestination destination, long Id) {
            this.destination = destination;
            this.Id = Id;
        }

        public JmsDestination destination;
        public long Id;
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
麻豆视频一区二区| 国产精品久久免费看| 三级精品在线观看| 欧美福利视频一区| 麻豆freexxxx性91精品| 久久免费午夜影院| 96av麻豆蜜桃一区二区| 亚洲日韩欧美一区二区在线| 欧美亚洲国产一区二区三区va | 亚洲一二三区不卡| 欧美日韩你懂得| 久久电影网站中文字幕| 亚洲精品一二三区| 日本韩国精品在线| 日韩免费高清电影| 26uuu亚洲综合色| 国产成人亚洲综合a∨猫咪| 中文字幕一区二区三区在线播放| 91国产精品成人| 免费久久99精品国产| 国产欧美1区2区3区| 色综合久久88色综合天天免费| 亚洲国产精品一区二区久久恐怖片 | 国产综合色精品一区二区三区| 国产欧美日本一区视频| 欧美亚洲综合另类| 国产一区二三区| 亚洲影视在线播放| 久久久精品综合| 在线观看亚洲精品视频| 九九精品视频在线看| 尤物在线观看一区| 久久伊人蜜桃av一区二区| 91亚洲精华国产精华精华液| 日本伊人色综合网| 亚洲天堂a在线| 精品国产乱码久久久久久浪潮| 91欧美激情一区二区三区成人| 蜜臀av在线播放一区二区三区| 国产精品卡一卡二卡三| 日韩一级片网站| 91成人看片片| 成人综合婷婷国产精品久久蜜臀 | 国产精品卡一卡二| 精品国产三级电影在线观看| 欧美影院精品一区| 成人高清在线视频| 久久99精品一区二区三区三区| 尤物在线观看一区| 中文字幕高清不卡| 精品国产伦一区二区三区免费 | 久久亚洲捆绑美女| 欧美日韩国产精品成人| 99re热视频精品| 国产高清在线精品| 老司机精品视频在线| 亚洲成人动漫精品| 一区二区三区精品在线观看| 国产精品欧美综合在线| 2019国产精品| 欧美成人精品1314www| 欧美日韩在线电影| 在线视频你懂得一区| 欧美日韩一区二区不卡| 国产成人av电影免费在线观看| 青青草97国产精品免费观看无弹窗版 | 激情综合五月天| 日产欧产美韩系列久久99| 亚洲韩国一区二区三区| 综合久久久久久久| 综合色天天鬼久久鬼色| 中文字幕一区二区不卡| 国产精品人成在线观看免费| 亚洲国产精品成人综合| 国产精品少妇自拍| 国产精品免费av| 中文字幕一区二区在线播放| 国产精品久久久久久一区二区三区| 国产午夜亚洲精品午夜鲁丝片 | 亚洲一卡二卡三卡四卡| 中文字幕亚洲欧美在线不卡| 国产精品大尺度| 一区二区三区日本| 午夜久久久影院| 午夜精彩视频在线观看不卡| 日本中文字幕一区二区视频| 久久精品久久精品| 经典三级视频一区| 国产成a人亚洲精品| 99热99精品| 91国偷自产一区二区开放时间 | 日韩经典中文字幕一区| 免费成人在线视频观看| 国产一区二区三区香蕉| 成人国产亚洲欧美成人综合网| 91麻豆.com| 在线不卡免费欧美| 精品成人私密视频| 国产精品久久久久久妇女6080| 一区av在线播放| 蜜桃一区二区三区在线| 成人精品在线视频观看| 色综合久久中文综合久久牛| 欧美电影在线免费观看| 26uuu国产日韩综合| 亚洲色欲色欲www| 五月天亚洲婷婷| 国产成人免费视频| 欧美影院精品一区| 久久久久久亚洲综合影院红桃| 专区另类欧美日韩| 蜜桃av一区二区| 91视频com| 日韩无一区二区| 中文字幕日本乱码精品影院| 日韩电影在线观看一区| 成人激情综合网站| 欧美一二三四在线| 亚洲欧洲精品一区二区三区不卡| 日韩不卡一区二区| 99热精品一区二区| 精品福利视频一区二区三区| 亚洲色图都市小说| 韩国精品主播一区二区在线观看| 日韩免费电影网站| 国产精品久久久久aaaa| 青青草国产精品亚洲专区无| 97精品电影院| 久久精品水蜜桃av综合天堂| 爽好多水快深点欧美视频| 99久久国产综合精品女不卡| 欧美电影免费观看完整版| 亚洲综合图片区| 国产999精品久久久久久绿帽| 欧美日本韩国一区二区三区视频| 国产片一区二区| 免费亚洲电影在线| 欧美日韩一区小说| 成人欧美一区二区三区黑人麻豆| 看电影不卡的网站| 9191精品国产综合久久久久久| 日韩码欧中文字| 成人高清在线视频| 久久久亚洲国产美女国产盗摄| 美国欧美日韩国产在线播放| 欧美日韩综合一区| 亚洲精品日产精品乱码不卡| 成人午夜在线视频| 国产亚洲福利社区一区| 韩日欧美一区二区三区| 欧美变态tickle挠乳网站| 亚洲国产欧美日韩另类综合| 一本一道久久a久久精品| 国产精品色哟哟| 国产美女久久久久| 精品欧美一区二区三区精品久久| 日韩高清在线电影| 欧美一区二区黄色| 亚洲第一狼人社区| 欧美日韩一区不卡| 天堂影院一区二区| 日韩亚洲电影在线| 美女视频网站久久| 日韩一级成人av| 麻豆国产欧美一区二区三区| 欧美精品一级二级三级| 午夜视频在线观看一区| 精品视频在线免费观看| 天堂va蜜桃一区二区三区漫画版| 欧美性生交片4| 亚洲亚洲人成综合网络| 欧美日韩亚洲综合一区| 日日骚欧美日韩| 日韩欧美国产综合| 国产精品中文字幕欧美| 国产精品视频在线看| 99久久国产综合精品女不卡| 一区二区三区日韩欧美精品| 欧美男男青年gay1069videost | 日韩经典中文字幕一区| 日韩一区二区三区观看| 国内精品久久久久影院一蜜桃| 久久先锋影音av鲁色资源| 国产一区二区女| 国产精品久久久久久久岛一牛影视 | 国产成人av资源| 国产精品不卡在线| 欧美无乱码久久久免费午夜一区| 婷婷亚洲久悠悠色悠在线播放 | 欧美精品高清视频| 奇米一区二区三区| 久久精品视频一区二区| 色婷婷亚洲精品| 三级在线观看一区二区| 久久久久久免费毛片精品| 91天堂素人约啪| 日本亚洲一区二区| 国产精品欧美综合在线| 欧美日韩一级二级三级| 国产一区二区三区av电影 |