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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? consumermanager.java

?? 一個(gè)java方面的消息訂閱發(fā)送的源碼
?? JAVA
?? 第 1 頁(yè) / 共 3 頁(yè)
字號(hào):
/**
 * 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: ConsumerManager.java,v 1.2 2005/03/18 03:58:39 tanderson Exp $
 */
package org.exolab.jms.messagemgr;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.jms.InvalidDestinationException;
import javax.jms.InvalidSelectorException;
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.JmsTopic;
import org.exolab.jms.persistence.DatabaseService;
import org.exolab.jms.persistence.PersistenceAdapter;
import org.exolab.jms.persistence.SQLHelper;
import org.exolab.jms.scheduler.Scheduler;
import org.exolab.jms.server.JmsServerSession;
import org.exolab.jms.service.ServiceException;


/**
 * The consumer manager is responsible for creating and managing the lifecycle
 * of consumers. The consumer manager maintains a list of all active consumers.
 *
 * @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.2 $ $Date: 2005/03/18 03:58:39 $
 */
public class ConsumerManager {

    /**
     * Maintains a cache of all active endpoints.
     */
    private HashMap _endpoints = new HashMap();

    /**
     * Maintains a list of all unique consumers, durable and non-durable. Each
     * entry has an associated {@link ConsumerEntry} record. All durable
     * subscribers are maintained in memory until they are removed from the
     * system entirely. All non-durable subscribers are maintained in memory
     * until their endpoint is removed.
     */
    private HashMap _consumerCache = new HashMap();

    /**
     * Maintains a mapping between destinations and consumers. A destination can
     * have more than one consumer and a consumer can also be registered to more
     * than one destination
     */
    private HashMap _destToConsumerMap = new HashMap();

    /**
     * Maintains a list of wildcard subscriptions using subscription name and
     * the JmsTopic.
     */
    private HashMap _wildcardConsumers = new HashMap();

    /**
     * Cache a copy of the scheduler instance
     */
    private Scheduler _scheduler = null;

    /**
     * The consumer Id seed to allocate to new consumers
     */
    private long _consumerIdSeed = 0;

    /**
     * The singleton instance of the consumer manager
     */
    private static ConsumerManager _instance = null;

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


    /**
     * Create the singleton instance of the consumer manager
     *
     * @return the singleton instance
     * @throws ServiceException if the service cannot be initialised
     */
    public static ConsumerManager createInstance() throws ServiceException {
        _instance = new ConsumerManager();
        return _instance;
    }

    /**
     * Return the singleton instance of the ConsumerManager
     *
     * @return ConsumerManager
     */
    public static ConsumerManager instance() {
        return _instance;
    }

    /**
     * Construct the <code>ConsumerManager</code>
     *
     * @throws ServiceException - if it fails to initialise
     */
    private ConsumerManager() throws ServiceException {
        init();
    }

    /**
     * This method creates an actual durable consumer for the specified and
     * caches it. It does not create and endpoint. To create the endpoint the
     * client should call createDurableConsumerEndpoint.
     *
     * @param topic the topic destination
     * @param name  the consumer name
     * @throws JMSException if it cannot be created
     */
    public synchronized void createDurableConsumer(JmsTopic topic, String name)
            throws JMSException {

        PersistenceAdapter adapter = DatabaseService.getAdapter();

        Connection connection = null;
        try {

            connection = DatabaseService.getConnection();

            // ensure that we are trying to create a durable consumer to an
            // administered destination.
            if (!adapter.checkDestination(connection, topic.getName())) {
                throw new JMSException("Cannot create durable consumer, name="
                                       + name
                                       + ", for non-administered topic="
                                       + topic.getName());
            }

            if (!adapter.durableConsumerExists(connection, name)) {
                adapter.addDurableConsumer(connection, topic.getName(), name);
            }

            connection.commit();
            // cache the consumer locally
            addToConsumerCache(name, topic, true);
        } catch (JMSException exception) {
            throw exception;
        } catch (Exception exception) { // PersistenceException, SQLException
            SQLHelper.rollback(connection);
            String msg = "Failed to create durable consumer, name=" + name
                    + ", for topic=" + topic.getName();
            _log.error(msg, exception);
            throw new JMSException(msg + ": " + exception.getMessage());
        } finally {
            SQLHelper.close(connection);
        }
    }


    /**
     * This method will remove the durable consumer from the database and from
     * transient memory only if it exists and is inactive. If there is an active
     * endpoint then it cannot be deleted and an exception will be raise.
     * <p/>
     * If the durable consumer does not exist then an exception is also raised.
     *
     * @param name - the consumer name
     * @throws JMSException - if it cannot be removed
     */
    public synchronized void removeDurableConsumer(String name)
            throws JMSException {
        if (_log.isDebugEnabled()) {
            _log.debug("removeDurableConsumer(name=" + name + ")");
        }

        // check to see that the durable consumer exists
        if (!durableConsumerExists(name)) {
            throw new JMSException("Durable consumer " + name
                                   + " is not defined.");
        }
        if (isDurableConsumerActive(name)) {
            throw new JMSException("Cannot remove durable consumer=" + name
                                   + ": consumer is active");
        }

        // remove it from the persistent store.
        Connection connection = null;
        try {
            connection = DatabaseService.getConnection();

            DatabaseService.getAdapter().removeDurableConsumer(connection,
                                                               name);
            // if it has been successfully removed from persistent store then
            // clear up the transient references.
            ConsumerEndpoint endpoint = getConsumerEndpoint(name);
            if (endpoint != null) {
                deleteConsumerEndpoint(endpoint);
            }
            removeFromConsumerCache(name);
            connection.commit();
        } catch (Exception exception) { // PersistenceException, SQLException
            SQLHelper.rollback(connection);
            String msg = "Failed to remove durable consumer, name=" + name;
            _log.error(msg, exception);
            throw new JMSException(msg + ":" + exception.getMessage());
        } finally {
            SQLHelper.close(connection);
        }
    }

    /**
     * This method will remove all the durable consumers from the database and
     * from transient memory whether they are active or not.
     * <p/>
     * If we have problems removing the durable consumers then throw the
     * JMSException.
     *
     * @param topic the topic to remove consumers for
     * @throws JMSException if the consumers cannot be removed
     */
    public synchronized void removeDurableConsumers(JmsDestination topic)
            throws JMSException {

        List consumers = (List) _destToConsumerMap.get(topic);
        if (consumers != null) {
            Iterator iterator = consumers.iterator();
            while (iterator.hasNext()) {
                ConsumerEntry entry = (ConsumerEntry) iterator.next();
                if (entry.isDurable()) {
                    // remove the actual durable consumer from transient and
                    // secondary memory.
                    removeDurableConsumer(entry.getName());
                }
            }
        }

        // remove all consumers for the specified destination
        removeFromConsumerCache(topic);
    }

    /**
     * Create a transient consumer for the specified destination
     *
     * @param destination the destination to consume messages from
     * @param selector    the message selector. May be <code>null</code>
     * @param noLocal     if true, and the destination is a topic, inhibits the
     *                    delivery of messages published by its own connection.
     *                    The behavior for <code>noLocal</code> is not specified
     *                    if the destination is a queue.
     * @return a new transient consumer
     */
    public synchronized ConsumerEndpoint createConsumerEndpoint(
            JmsServerSession session, JmsDestination destination,
            String selector, boolean noLocal)
            throws JMSException, InvalidSelectorException {

        if (_log.isDebugEnabled()) {
            _log.debug("createConsumerEndpoint(session=" + session
                       + ", destination=" + destination
                       + ", selector=" + selector
                       + ", noLocal=" + noLocal + ")");
        }

        ConsumerEndpoint endpoint = null;

        // ensure that the destination is valid before proceeding
        checkDestination(destination);

        long consumerId = getNextConsumerId();

        // determine what type of consumer endpoint to create based on
        // the destination it subscribes to.

        if (destination instanceof JmsTopic) {
            JmsTopic topic = (JmsTopic) destination;
            endpoint
                    = new TopicConsumerEndpoint(consumerId, session, topic,
                                                selector, noLocal, _scheduler);
        } else if (destination instanceof JmsQueue) {
            endpoint = new QueueConsumerEndpoint(consumerId, session,
                                                 (JmsQueue) destination,
                                                 selector, _scheduler);
        }

        if (endpoint != null) {
            // add it to the list of managed consumers. If it has a persistent
            // identity, use that as the key, otherwise use its transient
            // identity.
            Object key = ConsumerEntry.getConsumerKey(endpoint);
            _endpoints.put(key, endpoint);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区高清免费观看影视大全| 亚洲资源中文字幕| 欧美专区在线观看一区| 国产真实乱对白精彩久久| 亚洲欧洲av色图| wwwwxxxxx欧美| 在线观看91av| 91视频一区二区三区| 国产一区二区精品在线观看| 午夜精品福利久久久| 国产精品欧美经典| 久久综合九色综合97_久久久| 欧美日韩在线播放一区| 成人福利视频在线看| 精品一区二区三区在线观看国产| 一区二区高清视频在线观看| 国产精品久久久久久久久动漫 | 欧美一区二区在线看| 99免费精品在线| 国产盗摄视频一区二区三区| 日韩电影在线一区二区| 夜夜嗨av一区二区三区四季av| 国产欧美精品日韩区二区麻豆天美| 日韩小视频在线观看专区| 精品视频一区二区不卡| 色94色欧美sute亚洲线路一久| 国产精品系列在线观看| 国产一区激情在线| 久久国产日韩欧美精品| 麻豆精品在线播放| 免费成人在线播放| 美女一区二区视频| 秋霞午夜鲁丝一区二区老狼| 亚洲成国产人片在线观看| 亚洲高清免费在线| 午夜精品在线看| 日韩av在线发布| 视频一区视频二区在线观看| 午夜精品福利一区二区三区av | 国产精品女主播av| 国产精品美女久久久久aⅴ| 中文一区二区完整视频在线观看| 久久精品视频在线看| 国产日产欧产精品推荐色 | 777午夜精品视频在线播放| 欧美三级电影在线观看| 这里只有精品电影| 日韩欧美不卡在线观看视频| 精品美女在线观看| 久久这里只有精品视频网| 久久久精品综合| 国产精品天干天干在线综合| 亚洲人成亚洲人成在线观看图片| 亚洲色图欧美在线| 亚洲精品水蜜桃| 香港成人在线视频| 精一区二区三区| 国产经典欧美精品| 91网站在线播放| 欧美人牲a欧美精品| 日韩欧美一二三四区| 久久色成人在线| 国产精品灌醉下药二区| 一区二区不卡在线视频 午夜欧美不卡在 | 91精品中文字幕一区二区三区| 欧美一区二区三区啪啪| 久久综合五月天婷婷伊人| 国产蜜臀97一区二区三区| 综合在线观看色| 天天操天天色综合| 国产91综合网| 欧美性大战久久久久久久| 日韩欧美国产电影| 中文字幕一区二区三区色视频| 亚洲综合清纯丝袜自拍| 青青草国产精品97视觉盛宴| 国产成人免费在线视频| 欧美在线免费视屏| 久久色视频免费观看| 一区二区三国产精华液| 国产在线国偷精品产拍免费yy| 91网站在线播放| 精品国产精品一区二区夜夜嗨| 国产精品嫩草影院com| 日韩高清欧美激情| 91亚洲精品久久久蜜桃网站| 欧美一级在线免费| 亚洲日本中文字幕区| 精品一区二区三区免费观看| 在线观看视频91| 久久久久久久久一| 偷窥少妇高潮呻吟av久久免费| 成人福利电影精品一区二区在线观看| 欧美日韩国产经典色站一区二区三区| 久久久精品日韩欧美| 日韩精品亚洲一区| 91丨porny丨蝌蚪视频| 精品国产凹凸成av人导航| 亚洲与欧洲av电影| www.在线成人| 欧美岛国在线观看| 亚洲电影一区二区| 99精品久久久久久| 久久精品一区二区| 日本成人在线视频网站| 色婷婷av久久久久久久| 国产精品无圣光一区二区| 久久精品理论片| 欧美另类高清zo欧美| 亚洲美女视频在线| 成人av中文字幕| 久久亚洲精品国产精品紫薇| 视频在线观看国产精品| 欧洲人成人精品| 亚洲品质自拍视频| www.亚洲激情.com| 国产欧美一区二区三区在线看蜜臀 | 夜夜嗨av一区二区三区网页| av一区二区不卡| 欧美激情艳妇裸体舞| 精品一区二区三区在线观看 | 91福利小视频| 亚洲色图另类专区| 99精品欧美一区| 亚洲丝袜自拍清纯另类| 成人教育av在线| 中文字幕的久久| 国产成人免费在线视频| 国产欧美日产一区| 成人综合在线观看| 国产日韩成人精品| 从欧美一区二区三区| 国产欧美视频一区二区三区| 国产v日产∨综合v精品视频| 欧美va天堂va视频va在线| 美女脱光内衣内裤视频久久影院| 欧美精品久久天天躁| 天堂蜜桃一区二区三区| 日韩一区二区精品| 久久er99热精品一区二区| 日韩欧美在线1卡| 激情综合五月天| 国产日韩欧美制服另类| av亚洲产国偷v产偷v自拍| 亚洲私人影院在线观看| 在线观看免费亚洲| 午夜精品一区在线观看| 日韩欧美aaaaaa| 国产成a人无v码亚洲福利| 国产精品久久久久久一区二区三区| 99久久精品久久久久久清纯| 亚洲欧美激情插| 欧美日韩日日摸| 紧缚奴在线一区二区三区| 日本一区二区视频在线观看| 91香蕉视频污在线| 日韩国产欧美视频| 精品成人佐山爱一区二区| 国产成人高清视频| 亚洲少妇最新在线视频| 欧美精品国产精品| 韩国成人福利片在线播放| 中文字幕一区二区三区四区不卡 | 日韩欧美一区二区视频| 国产精品综合视频| 成人免费视频在线观看| 欧美色综合久久| 国产美女视频一区| 亚洲精品自拍动漫在线| 欧美一区二区三区思思人| 国产成人精品影视| 亚洲一二三四区| 26uuuu精品一区二区| 99久久99久久精品免费看蜜桃| 日日摸夜夜添夜夜添亚洲女人| 久久精品欧美日韩| 欧美日韩一区高清| 国产成人午夜精品影院观看视频 | 精品国产免费人成在线观看| av网站一区二区三区| 日韩精品一二区| 中文字幕一区二区三区乱码在线| 欧美精品tushy高清| 成人亚洲精品久久久久软件| 亚洲第一综合色| 欧美国产丝袜视频| 日韩亚洲欧美一区| 日本久久电影网| 国产精品一区二区三区99| 亚洲国产欧美另类丝袜| 欧美国产亚洲另类动漫| 日韩一区二区三区免费看 | 5566中文字幕一区二区电影| 国产成人三级在线观看| 日本中文字幕一区| 亚洲另类在线制服丝袜| 欧美国产欧美综合| 欧美va亚洲va香蕉在线| 欧美巨大另类极品videosbest | 91精品国产综合久久香蕉麻豆|