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

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

?? messagehandles.java

?? 一個java方面的消息訂閱發送的源碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/**
 * 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.sql.SQLException;
import java.util.Vector;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.exolab.jms.client.JmsDestination;
import org.exolab.jms.client.JmsTopic;
import org.exolab.jms.messagemgr.PersistentMessageHandle;
import org.exolab.jms.messagemgr.MessageHandle;


/**
 * This class provides persistency for MessageHandle 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>
 */
class MessageHandles {

    /**
     * prepared statement for inserting a message handle
     */
    private static final String INSERT_MSG_HANDLE_STMT =
            "insert into message_handles (messageid, destinationid, consumerid, "
            + "priority, acceptedtime, sequencenumber, expirytime, delivered) "
            + "values (?,?,?,?,?,?,?,?)";

    /**
     * prepared statements for deleting message handle
     */
    private static final String DELETE_MSG_HANDLE_STMT1 =
        "delete from message_handles where messageId=? and consumerId=?";
    private static final String DELETE_MSG_HANDLE_STMT2 =
        "delete from message_handles where messageId=? and destinationId=? " +
        "and consumerId=?";

    /**
     * Delete all message handles with the specified message id
     */
    private static final String DELETE_MSG_HANDLES_STMT =
        "delete from message_handles where messageId=?";

    /**
     * Update a row in the message handles table
     */
    private static final String UPDATE_MSG_HANDLE_STMT =
        "update message_handles set delivered=? where messageId=? and " +
        "destinationId=? and consumerId=?";

    /**
     * Delete all message handles for a destination
     */
    private static final String DELETE_MSG_HANDLES_FOR_DEST =
        "delete from message_handles where destinationId=?";

    /**
     * Retrieve all message handles for a particular consumer
     */
    private static final String GET_MSG_HANDLES_FOR_DEST =
        "select messageid, destinationid, consumerid, priority, acceptedtime, "
        + "sequencenumber, expirytime, delivered from message_handles "
        + "where consumerId=? order by acceptedTime asc";

    /**
     * Retrieve a range of message handles between the specified times
     */
    private static final String GET_MESSAGE_HANDLES_IN_RANGE =
        "select distinct messageId from message_handles where " +
        " acceptedTime >= ? and acceptedTime <=?";

    /**
     * Retrieve a handle with the specified id
     */
    private static final String GET_MESSAGE_HANDLE_WITH_ID =
        "select distinct messageId from message_handles where messageId=?";

    /**
     * Return the number of messages and a specified destination and cousmer
     */
    private static final String GET_MSG_HANDLE_COUNT_FOR_DEST_AND_CONSUMER =
        "select count(messageId) from message_handles where destinationId=? " +
        "and consumerId=?";

    /**
     * Return the number of messages and a specified consumer
     */
    private static final String GET_MSG_HANDLE_COUNT_FOR_CONSUMER =
        "select count(messageId) from message_handles where consumerId=?";

    /**
     * Delete all expired messages
     */
    private static final String DELETE_EXPIRED_MESSAGES =
        "delete from message_handles where consumerId=? and expiryTime != 0 " +
        "and expiryTime<?";

    /**
     * Singleton to this class
     */
    private static MessageHandles _instance;

    /**
     * Used to ensure that only one thread initialises the class
     */
    private static final Object _block = new Object();

    /**
     * The logger
     */
    private static final Log _log = LogFactory.getLog(MessageHandles.class);


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

    /**
     * Constructor
     */
    protected MessageHandles() {
    }

    /**
     * Initialise the singleton _instance
     *
     * @return      MessageHandles
     */
    public static MessageHandles initialise() {
        if (_instance == null) {
            synchronized (_block) {
                if (_instance == null) {
                    _instance = new MessageHandles();
                }
            }
        }

        return _instance;
    }

    /**
     * Add the specified message handle to the database
     *
     * @param connection - the connection to use
     * @param handle - message handle to add
     * @throws PersistenceException - if add does not complete
     */
    public void addMessageHandle(Connection connection,
                                 MessageHandle handle)
        throws PersistenceException {

        if (_log.isDebugEnabled()) {
            _log.debug("addMessageHandle(handle=[consumer="
                       + handle.getConsumerPersistentId()
                       + ", destination=" + handle.getDestination() 
                       + ", id=" + handle.getMessageId() + "])");
        }

        PreparedStatement insert = null;
        try {
            // map the destination name to an actual identity
            long destinationId = Destinations.instance().getId(
                handle.getDestination().getName());
            if (destinationId == 0) {
                throw new PersistenceException(
                    "Cannot add message handle id=" + handle.getMessageId() +
                    " for destination=" + handle.getDestination().getName() +
                    " and consumer=" + handle.getConsumerPersistentId() +
                    " since the destination cannot be mapped to an id");
            }

            // map the consumer name ot an identity
            long consumerId = Consumers.instance().getConsumerId(
                handle.getConsumerPersistentId());
            if (consumerId == 0) {
                throw new PersistenceException(
                    "Cannot add message handle id=" + handle.getMessageId() +
                    " for destination=" + handle.getDestination().getName() +
                    " and consumer=" + handle.getConsumerPersistentId() +
                    " since the consumer cannot be mapped to an id");
            }

            insert = connection.prepareStatement(INSERT_MSG_HANDLE_STMT);
            insert.setString(1, handle.getMessageId());
            insert.setLong(2, destinationId);
            insert.setLong(3, consumerId);
            insert.setInt(4, handle.getPriority());
            insert.setLong(5, handle.getAcceptedTime());
            insert.setLong(6, handle.getSequenceNumber());
            insert.setLong(7, handle.getExpiryTime());
            insert.setInt(8, (handle.getDelivered()) ? 1 : 0);

            // execute the insert
            if (insert.executeUpdate() != 1) {
                _log.error(
                    "Failed to execute addMessageHandle for handle="
                    + handle.getMessageId() + ", destination Id="
                    + destinationId);
            }
        } catch (SQLException exception) {
            throw new PersistenceException("Failed to add message handle=" +
                handle, exception);
        } finally {
            SQLHelper.close(insert);
        }
    }

    /**
     * Remove the specified message handle from the database. Once the handle
     * has been removed check to see whether there are any more message handles
     * referencing the same message. If there are not then remove the
     * corresponding message from the messages tables.
     *
     * @param connection - the connection to use
     * @param  handle - the handle to remove
     * @throws  PersistenceException - sql releated exception
     */
    public void removeMessageHandle(Connection connection,
                                    MessageHandle handle)
        throws PersistenceException {

        if (_log.isDebugEnabled()) {
            _log.debug("removeMessageHandle(handle=[consumer="
                       + handle.getConsumerPersistentId()
                       + ", destination=" + handle.getDestination() 
                       + ", id=" + handle.getMessageId() + "])");
        }

        PreparedStatement delete = null;
        PreparedStatement select = null;
        ResultSet rs = null;

        try {
            // first check to see that the consumer exists and only
            // proceed if it non-zero.
            long consumerId = Consumers.instance().getConsumerId(
                handle.getConsumerPersistentId());
            if (consumerId != 0) {
                // get the message id
                String id = handle.getMessageId();

                // map the destination name to an actual identity. If it is
                // null then the destination does not currently exist but we
                // may need to delete orphaned handles
                long destinationId = Destinations.instance().getId(
                    handle.getDestination().getName());

                if (destinationId == 0) {
                    delete = connection.prepareStatement(
                        DELETE_MSG_HANDLE_STMT1);
                    delete.setString(1, id);
                    delete.setLong(2, consumerId);

                } else {
                    delete = connection.prepareStatement(
                        DELETE_MSG_HANDLE_STMT2);
                    delete.setString(1, id);
                    delete.setLong(2, destinationId);
                    delete.setLong(3, consumerId);
                }

                // execute the delete
                if (delete.executeUpdate() != 1 && !handle.hasExpired()) {
                    // only log if the message hasn't been garbage
                    // collected
                    _log.error("Failed to execute removeMessageHandle for "
                        + "handle=" + id + " destination id="
                        + destinationId + " consumer id=" + consumerId);
                }
            }
        } catch (SQLException exception) {
            throw new PersistenceException("Failed to remove message handle=" +
                handle, exception);
        } finally {
            SQLHelper.close(rs);
            SQLHelper.close(delete);
            SQLHelper.close(select);
        }
    }

    /**
     * Update the specified message handle from the database
     *
     * @param connection - the connection to use
     * @param  handle - the handle to update
     * @throws  PersistenceException - sql releated exception
     */
    public void updateMessageHandle(Connection connection,
                                    MessageHandle handle)
        throws PersistenceException {
        PreparedStatement update = null;

        if (_log.isDebugEnabled()) {
            _log.debug("updateMessageHandle(handle=[consumer="
                       + handle.getConsumerPersistentId()
                       + ", destination=" + handle.getDestination() 
                       + ", id=" + handle.getMessageId() + "])");
        }

        try {
            // get the message id
            String id = handle.getMessageId();

            // map the destination name to an actual identity
            long destinationId = Destinations.instance().getId(
                handle.getDestination().getName());
            if (destinationId == 0) {
                throw new PersistenceException(
                    "Cannot update message handle id=" +

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人午夜电影小说| 免费观看一级特黄欧美大片| 欧美不卡一区二区| 91麻豆精品国产无毒不卡在线观看| 色综合欧美在线| 欧美性感一区二区三区| 欧美色视频在线观看| 欧美日韩色综合| 欧美一卡二卡三卡| 日韩精品中文字幕一区二区三区| 日韩欧美亚洲国产精品字幕久久久| 欧美精品粉嫩高潮一区二区| 日韩欧美专区在线| 26uuu亚洲综合色| 日本一区二区免费在线| 中文字幕中文字幕一区二区| 亚洲精品欧美在线| 麻豆中文一区二区| 成人av电影在线观看| 91啪在线观看| 91精品国产91久久久久久最新毛片| 精品乱人伦小说| 国产精品女同一区二区三区| 亚洲一区二区三区国产| 久久精品国产秦先生| 成人av在线网| 欧美高清视频一二三区 | 青青青爽久久午夜综合久久午夜| 日产欧产美韩系列久久99| 国产精品一线二线三线| 欧洲中文字幕精品| 日韩欧美电影一二三| 亚洲欧美另类小说视频| 日韩在线a电影| 91在线观看高清| 日韩精品一区二区三区四区| 亚洲欧美另类久久久精品| 免费成人美女在线观看.| 91麻豆免费观看| 久久综合色一综合色88| 亚洲国产一二三| 成人中文字幕合集| 日韩欧美国产综合在线一区二区三区| 国产精品美女久久久久久2018| 日韩专区一卡二卡| 91亚洲永久精品| 国产视频不卡一区| 免费在线看成人av| 欧美性感一类影片在线播放| 国产精品无圣光一区二区| 麻豆国产欧美日韩综合精品二区| 色婷婷久久久久swag精品| 国产亚洲精品久| 久久精品国产99国产| 欧美精品少妇一区二区三区| 综合久久久久综合| 99久久精品国产观看| 久久久久久久久久久久久女国产乱| 午夜精品影院在线观看| 91高清视频在线| 国产免费成人在线视频| 国精产品一区一区三区mba视频| 欧美精品视频www在线观看| 一区二区三区不卡视频在线观看| av成人老司机| 亚洲人成伊人成综合网小说| 99视频精品免费视频| 国产日韩三级在线| 成人高清视频免费观看| 国产偷国产偷精品高清尤物| 国产一区二区久久| 国产视频911| 国产成人av资源| 亚洲国产成人一区二区三区| 国产乱一区二区| 国产精品美女久久久久久2018| 国产91在线看| 国产精品家庭影院| 成人激情校园春色| 最新热久久免费视频| 91蜜桃视频在线| 亚洲激情av在线| 欧美精品第1页| 精品无人码麻豆乱码1区2区| 国产亚洲精品aa| 99精品久久99久久久久| 亚洲最新视频在线播放| 欧美一区二区二区| 国产suv一区二区三区88区| 国产精品剧情在线亚洲| 欧美曰成人黄网| 蜜臀av一区二区| 国产精品久久久久久久第一福利| 色婷婷综合五月| 欧美a一区二区| 中文一区二区完整视频在线观看 | 中文字幕制服丝袜成人av| 91亚洲国产成人精品一区二区三 | 日韩一区二区免费在线观看| 久久99国产精品久久99| 亚洲国产激情av| 欧美精品乱码久久久久久按摩| 狠狠色综合播放一区二区| 国产精品久久久久桃色tv| 欧美日韩亚洲高清一区二区| 国产一区亚洲一区| 夜夜嗨av一区二区三区网页| 日韩一级片网站| 99免费精品视频| 性感美女久久精品| 国产欧美视频在线观看| 色妹子一区二区| 韩日欧美一区二区三区| 一区二区三区免费在线观看| 欧美mv日韩mv| 在线观看91视频| 成人黄色小视频在线观看| 五月天久久比比资源色| 国产精品动漫网站| 精品国产123| 欧美亚洲免费在线一区| 成人小视频免费在线观看| 日韩1区2区日韩1区2区| 亚洲精品日产精品乱码不卡| 欧美国产日韩a欧美在线观看| 3d动漫精品啪啪一区二区竹菊 | 欧美日韩国产一级| a级精品国产片在线观看| 韩日欧美一区二区三区| 亚洲a一区二区| 一区二区三区成人| 亚洲人成影院在线观看| 国产精品日韩成人| 久久久国产一区二区三区四区小说 | 欧美性猛交xxxxxxxx| 粉嫩蜜臀av国产精品网站| 日本免费新一区视频| 亚洲综合久久av| 中文字幕一区在线| 国产性天天综合网| 精品国产伦一区二区三区免费 | 欧美激情一区二区三区全黄| 日韩欧美一级在线播放| 337p亚洲精品色噜噜狠狠| 欧美亚洲动漫精品| 在线免费精品视频| 91黄色在线观看| 日本国产一区二区| 在线视频一区二区三| 在线这里只有精品| 在线观看91视频| 欧美日韩一区二区在线观看视频| 色哦色哦哦色天天综合| 欧美亚洲动漫精品| 欧美久久一区二区| 欧美一区二区三区的| 精品卡一卡二卡三卡四在线| 欧美精品一区在线观看| 久久久99久久精品欧美| 中文字幕不卡在线播放| 亚洲精品菠萝久久久久久久| 一区二区不卡在线播放| 亚洲成av人影院在线观看网| 奇米在线7777在线精品| 国产一区二区h| 91一区一区三区| 欧美日韩黄视频| 日韩视频永久免费| 国产亚洲成av人在线观看导航 | 日本伦理一区二区| 777a∨成人精品桃花网| 久久这里只有精品6| 日韩毛片一二三区| 五月天久久比比资源色| 久久成人av少妇免费| 丰满少妇久久久久久久| 欧美午夜片在线观看| 欧美一级片免费看| 国产亚洲综合av| 亚洲精品国产精华液| 蜜臀av一级做a爰片久久| 粉嫩在线一区二区三区视频| 欧美人与z0zoxxxx视频| 国产日产精品1区| 午夜精品成人在线视频| 国产精品一品二品| 欧美麻豆精品久久久久久| 日本一区二区三区国色天香| 香港成人在线视频| 成人美女视频在线观看| 91精品国产综合久久久久久漫画| 中文字幕免费在线观看视频一区| 一区二区三区高清在线| 国产成人午夜视频| 欧美老年两性高潮| 综合激情成人伊人| 国产精品888| 日韩一区二区免费电影| 亚洲精品免费在线观看| 国产黄色精品网站|