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

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

?? queuedestinationcache.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 2001-2005 (C) Exoffice Technologies Inc. All Rights Reserved.
 *
 * $Id: QueueDestinationCache.java,v 1.4 2005/03/24 13:41:23 tanderson Exp $
 */
package org.exolab.jms.messagemgr;

import java.sql.Connection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Iterator;
import javax.jms.JMSException;

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

import org.exolab.jms.client.JmsDestination;
import org.exolab.jms.client.JmsQueue;
import org.exolab.jms.client.JmsTemporaryDestination;
import org.exolab.jms.message.MessageImpl;
import org.exolab.jms.persistence.DatabaseService;
import org.exolab.jms.persistence.PersistenceException;
import org.exolab.jms.selector.Selector;
import org.exolab.jms.server.JmsServerConnectionManager;


/**
 * A {@link DestinationCache} for queues.
 *
 * @author <a href="mailto:jima@comware.com.au">Jim Alateras</a>
 * @author <a href="mailto:tma@netspace.net.au">Tim Anderson</a>
 * @version $Revision: 1.4 $ $Date: 2005/03/24 13:41:23 $
 */
public class QueueDestinationCache extends AbstractDestinationCache {

    /**
     * Maintains a list of {@link QueueConsumerMessageHandle} instances.
     */
    private MessageQueue _handles;

    /**
     * Maintains a list of queue browsers for this cache.
     */
    protected List _browsers = Collections.synchronizedList(new LinkedList());

    /**
     * Index of the last {@link QueueConsumerEndpoint} that received a message
     * from this destination.
     * If multiple consumers are attached to this queue then messages will be
     * sent to each in a round robin fashion
     */
    private int _lastConsumerIndex = 0;

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


    /**
     * Construct a new <code>QueueDestinationCache</code> for a non-persistent
     * queue.
     *
     * @param queue the queue to cache messages for
     */
    public QueueDestinationCache(JmsQueue queue) {
        super(queue);
        _handles = new MessageQueue();
    }

    /**
     * Construct a new <code>QueueDestinationCache</code> for a persistent
     * queue.
     *
     * @param queue      the queue to cache messages for
     * @param connection the database connection
     * @throws JMSException for any error
     * @throws PersistenceException if initialisation fails
     */
    public QueueDestinationCache(JmsQueue queue, Connection connection)
            throws JMSException, PersistenceException {
        super(queue, connection);
    }

    /**
     * A Queue can also hav a queue listener, which simply gets informed of all
     * messages that arrive at this destination.
     *
     * @param listener - queue listener
     */
    public void addQueueListener(QueueBrowserEndpoint listener) {
        // add if not present
        if (!_browsers.contains(listener)) {
            _browsers.add(listener);
        }
    }

    /**
     * Remove the queue listener associated with this cache
     *
     * @param listener - queue listener to remove
     */
    public void removeQueueListener(QueueBrowserEndpoint listener) {
        // add if not present
        if (_browsers.contains(listener)) {
            _browsers.remove(listener);
        }
    }

    /**
     * Invoked when the {@link MessageMgr} receives a non-persistent message.
     *
     * @param destination the message's destination
     * @param message     the message
     * @throws JMSException if the listener fails to handle the message
     */
    public void messageAdded(JmsDestination destination, MessageImpl message)
            throws JMSException {
        MessageRef reference = new CachedMessageRef(message, false,
                                                    getMessageCache());
        MessageHandle shared = new SharedMessageHandle(reference, message);
        MessageHandle handle = new QueueConsumerMessageHandle(shared);

        // all messages are added to this queue. Receivers will
        // then pick messages from it as required.
        addMessage(reference, message, handle);

        // if we have any registered consumers then we need to
        // send the message to one of them first.
        QueueConsumerEndpoint endpoint = getEndpointForMessage(message);
        if (endpoint != null) {
            endpoint.messageAdded(handle, message);
        }
    }

    /**
     * Invoked when the {@link MessageMgr} receives a persistent message.
     *
     * @param connection  the database connection
     * @param destination the message's destination
     * @param message     the message
     * @throws JMSException         if the listener fails to handle the message
     * @throws PersistenceException if there is a persistence related problem
     */
    public void persistentMessageAdded(Connection connection,
                                       JmsDestination destination,
                                       MessageImpl message)
            throws JMSException, PersistenceException {
        MessageRef reference = new CachedMessageRef(message, true,
                                                    getMessageCache());
        MessageHandle shared = new SharedMessageHandle(reference, message);
        MessageHandle handle = new QueueConsumerMessageHandle(shared);
        handle.add(connection);

        addMessage(reference, message, handle);

        // if there are any registered consumers, notify one of them that
        // a message has arrived
        QueueConsumerEndpoint endpoint = getEndpointForMessage(message);
        if (endpoint != null) {
            endpoint.persistentMessageAdded(handle, message, connection);
        }
    }

    /**
     * Returns the first available message matching the supplied message
     * selector.
     *
     * @param selector the message selector to use. May be <code>null</code>
     * @return handle to the first message, or <code>null</code> if there
     * are no messages, or none matching <code>selector</code>
     * @throws JMSException for any error
     */
    public synchronized MessageHandle getMessage(Selector selector)
            throws JMSException {
        QueueConsumerMessageHandle handle = null;
        if (selector == null) {
           // if no selector has been specified then remove and return
           // the first message
           handle = (QueueConsumerMessageHandle) _handles.removeFirst();
        } else {
            // for non null selector we must find the first matching
            MessageHandle[] handles = _handles.toArray();
            for (int i = 0; i < handles.length; ++i) {
                MessageHandle hdl = handles[i];
                if (selector.selects(hdl.getMessage())) {
                    handle = (QueueConsumerMessageHandle) hdl;
                    _handles.remove(handle);
                    break;
                }
            }
        }
        return handle;
    }

    /**
     * Playback all the messages in the cache to the specified {@link
     * QueueBrowserEndpoint}.
     *
     * @param browser the queue browser
     * @throws JMSException for any error
     */
    public void playbackMessages(QueueBrowserEndpoint browser)
            throws JMSException {
        MessageHandle[] handles = _handles.toArray();
        for (int i = 0; i < handles.length; ++i) {
            MessageHandle handle = handles[i];
            MessageImpl message = handle.getMessage();
            if (message != null) {
                browser.messageAdded(handle, message);
            }
        }
    }

    /**
     * Return a message handle back to the cache, to recover unsent or
     * unacknowledged messages.
     *

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
bt欧美亚洲午夜电影天堂| 欧美人与z0zoxxxx视频| 一区二区三区四区视频精品免费| 欧美不卡一区二区| 91黄视频在线| 粉嫩aⅴ一区二区三区四区五区| 秋霞午夜av一区二区三区| 亚洲天堂成人在线观看| 久久久亚洲综合| 欧美肥胖老妇做爰| 91黄色免费看| 91视视频在线观看入口直接观看www| 蜜桃av一区二区| 肉色丝袜一区二区| 亚洲高清免费观看高清完整版在线观看| 欧美国产精品中文字幕| 久久综合给合久久狠狠狠97色69| 欧美久久久一区| 欧美性一区二区| 欧洲精品视频在线观看| 99精品国产热久久91蜜凸| 国产成人综合在线播放| 国产真实乱偷精品视频免| 美女久久久精品| 男男gaygay亚洲| 日精品一区二区| 日韩福利电影在线| 日本亚洲免费观看| 免费在线欧美视频| 久久精品国产亚洲5555| 免费观看在线色综合| 蜜桃视频免费观看一区| 久久国产免费看| 国产在线视频一区二区| 国产一区二区三区免费播放| 国产一区二区电影| 成人永久看片免费视频天堂| 丁香五精品蜜臀久久久久99网站| 粉嫩av一区二区三区在线播放| 从欧美一区二区三区| av激情综合网| 欧美最猛性xxxxx直播| 欧美怡红院视频| 777欧美精品| 亚洲精品一区二区三区精华液| 亚洲精品一区二区三区香蕉| 国产亚洲欧美一级| 国产精品精品国产色婷婷| 亚洲欧美日韩精品久久久久| 亚洲图片欧美色图| 免费视频最近日韩| 激情深爱一区二区| 成人18视频日本| 91福利在线播放| 欧美一卡在线观看| 国产日韩高清在线| 亚洲人成伊人成综合网小说| 午夜精品在线看| 国内成人自拍视频| 91蜜桃婷婷狠狠久久综合9色| 日本韩国欧美一区二区三区| 欧美一区二区三区小说| 欧美激情一区二区| 亚洲线精品一区二区三区| 蜜桃av一区二区三区| 高清beeg欧美| 欧美三级资源在线| 欧美精品一区男女天堂| 亚洲欧美日韩中文播放| 日韩不卡一区二区| 成人av在线播放网站| 欧美久久婷婷综合色| 国产欧美日韩卡一| 天天射综合影视| 国产成人av网站| 欧美三级韩国三级日本三斤| 欧美mv和日韩mv国产网站| 亚洲丝袜精品丝袜在线| 蜜臀久久99精品久久久画质超高清 | 国产亚洲综合性久久久影院| 亚洲免费av观看| 国内精品国产成人国产三级粉色| 色乱码一区二区三区88| 久久午夜电影网| 天天av天天翘天天综合网色鬼国产| 国产成人亚洲综合a∨猫咪| 欧美色爱综合网| 国产精品人成在线观看免费| 日本va欧美va精品发布| 91在线国内视频| 久久影院电视剧免费观看| 亚洲一区在线观看免费 | 亚洲欧美怡红院| 麻豆成人av在线| 欧美视频一区二区| 中文字幕一区av| 国产在线视频精品一区| 69久久夜色精品国产69蝌蚪网| 中文字幕制服丝袜一区二区三区| 青青国产91久久久久久| 色国产精品一区在线观看| 日本一二三四高清不卡| 精品在线播放免费| 91麻豆精品91久久久久同性| 亚洲综合丝袜美腿| 99精品久久久久久| 国产日产欧美一区二区视频| 久久超级碰视频| 欧美人牲a欧美精品| 亚洲色图欧美激情| 成人免费毛片aaaaa**| 久久伊人蜜桃av一区二区| 免费久久99精品国产| 欧美性猛交xxxx黑人交| 亚洲女人****多毛耸耸8| 国产 日韩 欧美大片| 久久久五月婷婷| 国产一区二三区好的| 日韩欧美一区二区视频| 日韩1区2区日韩1区2区| 欧美久久一二三四区| 亚洲成a人片综合在线| 欧洲精品一区二区三区在线观看| 一区精品在线播放| 99精品视频中文字幕| 17c精品麻豆一区二区免费| www.日本不卡| 亚洲欧洲性图库| 91丨porny丨最新| 亚洲少妇30p| 欧洲人成人精品| 午夜精品一区在线观看| 欧美精品一二三区| 欧美bbbbb| 精品国产制服丝袜高跟| 极品销魂美女一区二区三区| 26uuu色噜噜精品一区| 国产精品一区二区视频| 国产精品视频yy9299一区| www.av精品| 亚洲乱码国产乱码精品精98午夜| 色婷婷综合五月| 午夜av电影一区| 日韩视频不卡中文| 国产乱码精品一区二区三| 欧美激情综合五月色丁香小说| av不卡在线观看| 一区二区国产视频| 日韩一区二区三区电影在线观看| 极品少妇xxxx精品少妇| 中文字幕乱码亚洲精品一区| 日本精品一级二级| 日本特黄久久久高潮| 久久久不卡影院| 色天天综合色天天久久| 亚洲超丰满肉感bbw| 精品欧美乱码久久久久久| 成人激情图片网| 亚洲国产一区二区三区| 日韩欧美成人激情| 成人动漫视频在线| 午夜精品福利一区二区蜜股av | 一区二区三区四区精品在线视频| 欧美精选一区二区| 国产精品99久久久久久宅男| 亚洲女人小视频在线观看| 制服丝袜亚洲精品中文字幕| 国产成人日日夜夜| 亚洲一区二区三区四区不卡| 日韩精品一区二区三区视频播放 | 国产亚洲精品超碰| 在线视频观看一区| 国产呦精品一区二区三区网站| 日韩理论片中文av| 欧美一区二区三区系列电影| 夫妻av一区二区| 视频一区在线视频| 国产网红主播福利一区二区| 欧美视频第二页| 高清国产一区二区| 日韩激情av在线| 中文字幕综合网| 欧美第一区第二区| 91亚洲精品一区二区乱码| 久久疯狂做爰流白浆xx| 亚洲激情图片qvod| 久久色视频免费观看| 精品视频在线免费看| 丰满少妇在线播放bd日韩电影| 图片区小说区区亚洲影院| 国产精品久久久久久久久久免费看 | 国产成人在线电影| 青青草国产成人99久久| 亚洲精品视频一区二区| 久久精品日产第一区二区三区高清版 | 久久国产福利国产秒拍| 亚洲国产精品久久艾草纯爱| 中文字幕视频一区| 久久久精品免费网站| 日韩三级视频在线看|