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

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

?? defaultmessagecache.java

?? 一個java方面的消息訂閱發(fā)送的源碼
?? 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 2001-2003 (C) Exoffice Technologies Inc. All Rights Reserved.
 *
 * $Id: DefaultMessageCache.java,v 1.1 2005/03/18 03:58:39 tanderson Exp $
 *
 * Date         Author  Changes
 * 3/1/2001     jima    Created
 */
package org.exolab.jms.messagemgr;

import java.sql.Connection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.jms.JMSException;

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

import org.exolab.jms.message.MessageImpl;
import org.exolab.jms.persistence.DatabaseService;
import org.exolab.jms.persistence.PersistenceAdapter;
import org.exolab.jms.persistence.SQLHelper;


/**
 * Default implementation of the {@link MessageCache} interface.
 *
 * @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.1 $ $Date: 2005/03/18 03:58:39 $
 */
final class DefaultMessageCache implements MessageCache {

    /**
     * Maintains the pool of transient messages.
     */
    private final Map _transient = Collections.synchronizedMap(
            new HashMap(1023));

    /**
     * Maintains the pool of persistent messages.
     */
    private final Map _persistent = Collections.synchronizedMap(
            new HashMap(1023));

    /**
     * Maintains the references to messages.
     */
    private final Map _references = Collections.synchronizedMap(
            new HashMap(1023));

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


    /**
     * Add a reference and its corresponding message to the cache.
     *
     * @param reference the reference to the message
     * @param message   the message
     */
    public void addMessage(MessageRef reference, MessageImpl message) {
        String messageId = reference.getMessageId();
        if (reference.isPersistent()) {
            _persistent.put(messageId, message);
        } else {
            _transient.put(messageId, message);
        }
        addMessageRef(messageId, reference);
    }

    /**
     * Adds a message reference to the cache.
     *
     * @param reference the message reference to add
     */
    public void addMessageRef(MessageRef reference) {
        addMessageRef(reference.getMessageId(), reference);
    }

    /**
     * Returns a message reference, given its identifier.
     *
     * @param messageId the message identifier
     * @return the message reference associated with <code>messageId</code>, or
     *         <code>null</code>  if none exists
     */
    public MessageRef getMessageRef(String messageId) {
        return (MessageRef) _references.get(messageId);
    }

    /**
     * Returns the message corresponding to the specified reference.
     *
     * @param reference the message reference
     * @return the associated message, or <code>null</code> if none exists
     * @throws JMSException for any error
     */
    public MessageImpl getMessage(MessageRef reference) throws JMSException {
        MessageImpl message = null;
        final String messageId = reference.getMessageId();

        if (reference.isPersistent()) {
            message = (MessageImpl) _persistent.get(messageId);

            // if the message is not cached then try and retrieve it from the
            // database and cache it.
            if (message == null) {
                // fault in at least the next message from the database
                PersistenceAdapter adapter = DatabaseService.getAdapter();
                Connection connection = null;
                try {
                    connection = DatabaseService.getConnection();
                    message = adapter.getMessage(connection, messageId);
                    connection.commit();
                } catch (Exception exception) {
                    SQLHelper.rollback(connection);
                    _log.error("Failed to retrieve message", exception);
                    throw new JMSException("Failed to retrieve message: "
                                           + exception.getMessage());
                } finally {
                    SQLHelper.close(connection);
                }

                // add the message to the persistent cache once it has been
                // retrieved from the datastore
                if (message != null) {
                    _persistent.put(messageId, message);
                }
            }
        } else {
            message = (MessageImpl) _transient.get(messageId);
        }

        if (message != null && !message.getReadOnly()) {
            // mark the message as read-only
            message.setReadOnly(true);
        }

        return message;
    }

    /**
     * Destroys the message corresponding to the reference.
     *
     * @throws JMSException for any error
     */
    public void destroy(MessageRef reference) throws JMSException {
        if (reference.isPersistent()) {
            Connection connection = null;
            try {
                connection = DatabaseService.getConnection();
                destroy(reference, connection);
                connection.commit();
            } catch (JMSException exception) {
                SQLHelper.rollback(connection);
                throw exception;
            } catch (Exception exception) {
                SQLHelper.rollback(connection);
                _log.error("Failed to remove message", exception);
                throw new JMSException("Failed to remove message: "
                                       + exception.getMessage());
            } finally {
                SQLHelper.close(connection);
            }
        } else {
            final String messageId = reference.getMessageId();
            _transient.remove(messageId);
            _references.remove(messageId);
        }
    }

    /**
     * Destroys the message corresponding to the reference.
     *
     * @param connection the database connection to use
     * @throws JMSException for any error
     */
    public void destroy(MessageRef reference, Connection connection)
            throws JMSException {
        final String messageId = reference.getMessageId();

        if (reference.isPersistent()) {
            try {
                PersistenceAdapter adapter = DatabaseService.getAdapter();
                adapter.removeMessage(connection, messageId);
            } catch (Exception exception) {
                _log.error("Failed to remove message", exception);
                throw new JMSException("Failed to remove message: "
                                       + exception.getMessage());
            }
            _persistent.remove(messageId);
        } else {
            _transient.remove(messageId);
        }
        _references.remove(messageId);
    }

    /**
     * Clear the persistent and non-persistent message cache.
     */
    public void clear() {
        _transient.clear();
        _persistent.clear();
        _references.clear();
    }

    /**
     * Clear only the persistent messages in the cache.
     */
    public void clearPersistentMessages() {
        _persistent.clear();
    }

    /**
     * Clear only the transient messages in the cache.
     */
    public void clearTransientMessages() {
        _transient.clear();
    }

    /**
     * Return the number of messages in the transient cache.
     *
     * @return the number of messages in the transient cache
     */
    public int getTransientCount() {
        return _transient.size();
    }

    /**
     * Return the number of messages in the persistent cache.
     *
     * @return the number of messages in the persistent cache
     */
    public int getPersistentCount() {
        return _persistent.size();
    }

    /**
     * Return the number of message references in the cache.
     *
     * @return the number of message references in the cache
     */
    public int getMessageCount() {
        return _references.size();
    }

    /**
     * Add a message reference to the cache.
     *
     * @param messageId the message identifier
     * @param reference the message reference
     */
    private void addMessageRef(String messageId, MessageRef reference) {
        _references.put(messageId, reference);
    }

}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩久久精品一区| 欧美一区二区三区视频在线观看| 国产精品嫩草99a| 成人视屏免费看| 亚洲男同性视频| 欧美日韩国产高清一区二区 | 一区二区三区在线免费观看| 日本福利一区二区| 天堂一区二区在线| 26uuu精品一区二区三区四区在线| 国产精品12区| 亚洲六月丁香色婷婷综合久久| 欧美男同性恋视频网站| 九九**精品视频免费播放| 中文字幕精品在线不卡| 欧美性猛片xxxx免费看久爱| 蜜臀精品一区二区三区在线观看| 国产清纯美女被跳蛋高潮一区二区久久w| av午夜一区麻豆| 三级久久三级久久久| 国产拍揄自揄精品视频麻豆| 欧美亚洲日本国产| 国产资源精品在线观看| 亚洲欧美区自拍先锋| 日韩亚洲欧美在线观看| 国产91在线看| 日本免费新一区视频| 欧美经典一区二区| 欧美一区二区私人影院日本| 成人免费毛片嘿嘿连载视频| 丝袜脚交一区二区| 国产精品免费视频一区| 日韩一卡二卡三卡| 色综合久久天天综合网| 国产在线日韩欧美| 亚洲国产sm捆绑调教视频| 亚洲国产精品99久久久久久久久 | 在线视频一区二区三| 国产在线精品不卡| 香蕉久久夜色精品国产使用方法| 久久九九影视网| 91麻豆精品久久久久蜜臀 | 国产一区二区伦理| 亚洲高清免费视频| 国产精品欧美一级免费| 欧美成人精品二区三区99精品| 91蜜桃免费观看视频| 国产精品一区在线| 日本va欧美va精品发布| 一级精品视频在线观看宜春院| 久久蜜桃一区二区| 91精品国产欧美一区二区18| 色88888久久久久久影院野外| 国产一区不卡精品| 毛片av一区二区| 日韩av一二三| 亚洲国产日日夜夜| 亚洲一区二区三区四区在线免费观看| 欧美激情综合网| 国产女同性恋一区二区| 精品欧美一区二区在线观看| 7777精品伊人久久久大香线蕉经典版下载 | 日本成人在线视频网站| 亚洲成av人片| 亚洲国产精品久久久男人的天堂| 亚洲精品免费在线观看| 国产精品国产三级国产普通话蜜臀 | 国产寡妇亲子伦一区二区| 国产综合色视频| 国产一区二区免费看| 国产精品一区不卡| 国产**成人网毛片九色| 国产91露脸合集magnet| 国产激情视频一区二区三区欧美| 国产麻豆一精品一av一免费| 国产一区二区三区久久久| 国产一区二区看久久| 国产成人亚洲综合色影视| 粗大黑人巨茎大战欧美成人| 成人黄色av电影| 91麻豆蜜桃一区二区三区| 在线视频你懂得一区| 欧美性色欧美a在线播放| 欧美精品乱码久久久久久 | 国产成人免费视频网站| 岛国av在线一区| 色八戒一区二区三区| 欧美午夜不卡在线观看免费| 欧美日韩午夜在线| 日韩精品资源二区在线| 国产婷婷色一区二区三区在线| 国产欧美一区二区精品性色| 国产精品乱人伦中文| 亚洲精品高清在线| 日韩二区三区四区| 激情小说欧美图片| 成人国产亚洲欧美成人综合网| 色综合咪咪久久| 日韩小视频在线观看专区| 久久婷婷综合激情| 亚洲男同性恋视频| 奇米色一区二区| 粉嫩一区二区三区性色av| 色婷婷一区二区| 日韩一区二区三区视频在线| 国产丝袜美腿一区二区三区| 亚洲免费伊人电影| 久久er99热精品一区二区| 不卡免费追剧大全电视剧网站| 欧美性猛片xxxx免费看久爱| 久久女同互慰一区二区三区| 亚洲欧美另类图片小说| 免费在线视频一区| 成人高清视频在线| 在线播放91灌醉迷j高跟美女 | 日韩一级片网站| 中文字幕一区二区三区四区| 免费在线一区观看| 97久久精品人人做人人爽| 日韩视频一区二区三区在线播放| 亚洲国产精品ⅴa在线观看| 天天综合日日夜夜精品| 成人a区在线观看| 日韩一级精品视频在线观看| 国产精品国产三级国产专播品爱网| 日本视频免费一区| 91社区在线播放| 久久午夜色播影院免费高清| 天天色综合成人网| 91丨porny丨中文| 久久综合久久综合久久| 午夜成人在线视频| 97精品国产97久久久久久久久久久久 | 丰满亚洲少妇av| 日韩欧美在线网站| 亚洲激情六月丁香| 国产suv精品一区二区6| 日韩精品自拍偷拍| 丝袜诱惑亚洲看片| 在线观看日韩国产| 国产精品久久久久久久久果冻传媒| 麻豆精品一区二区av白丝在线| 欧美亚洲国产一区二区三区va| 国产精品色婷婷| 国产成人在线色| 久久影院午夜片一区| 老司机精品视频导航| 欧美人与禽zozo性伦| 亚洲精品国产第一综合99久久 | 国产婷婷一区二区| 韩国女主播成人在线| 日韩一区二区三区免费观看| 亚洲成国产人片在线观看| 在线一区二区观看| 亚洲三级电影网站| 99久久99久久精品国产片果冻| 国产亚洲欧美日韩俺去了| 九九国产精品视频| 精品av久久707| 激情综合五月婷婷| 日韩欧美视频一区| 精品一区二区三区久久久| 日韩一区二区电影在线| 久久精品国产网站| 欧美成人高清电影在线| 日韩不卡一二三区| 日韩欧美中文字幕一区| 蜜臀av性久久久久蜜臀av麻豆| 欧美一区二视频| 精品在线亚洲视频| 久久久久青草大香线综合精品| 国产综合色在线视频区| 国产女同互慰高潮91漫画| 成人免费视频视频在线观看免费| 国产精品久久久久久久久动漫| 99久久99久久精品免费观看| 一区二区在线看| 欧美日本乱大交xxxxx| 青青草精品视频| 国产午夜精品一区二区| 99久久久久免费精品国产 | 亚洲国产美国国产综合一区二区| 欧洲视频一区二区| 三级一区在线视频先锋| 日韩免费看网站| 成人污视频在线观看| 亚洲免费资源在线播放| 欧美久久一区二区| 国产一区不卡精品| 亚洲日本青草视频在线怡红院| 色94色欧美sute亚洲线路一ni| 日本欧美在线观看| 国产日韩欧美精品一区| 一本色道久久综合亚洲精品按摩| 日本亚洲一区二区| 久久久噜噜噜久久人人看| 91免费看`日韩一区二区| 首页亚洲欧美制服丝腿| 久久久久久97三级| 欧美亚洲愉拍一区二区|