⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ipcjmsadminconnection.java

📁 实现了Jms的服务器源码,支持多种适配器,DB,FTP,支持多种数据库
💻 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-2001,2003 (C) Exoffice Technologies Inc. All Rights Reserved.
 *
 * $Id: IpcJmsAdminConnection.java,v 1.17 2003/08/16 09:45:46 tanderson Exp $
 *
 * Date         Author  Changes
 * $Date        jimm    Created
 */
package org.exolab.jms.administration.mipc;

import java.io.IOException;
import java.util.Vector;

import javax.jms.JMSException;

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

import org.exolab.core.ipc.IpcIfc;
import org.exolab.core.mipc.MultiplexConnection;
import org.exolab.core.mipc.MultiplexConnectionIfc;
import org.exolab.core.mipc.ObjectChannel;
import org.exolab.jms.administration.AdminConnection;
import org.exolab.jms.administration.JmsAdminServerIfc;


/**
 * This class is repsonsible for opening a TCP connection to the server
 * and passing and packing all requests for delivery.
 *
 * @version     $Revision: 1.17 $ $Date: 2003/08/16 09:45:46 $
 * @author      <a href="mailto:mourikis@exolab.org">Jim Mourikis</a>
 */
public class IpcJmsAdminConnection implements JmsAdminServerIfc,
    AdminConnection {

    /**
     * This is a reference to the server connection.
     */
    private MultiplexConnectionIfc _mc = null;

    /**
     * The server ipc channel
     */
    private IpcIfc _connection = null;

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


    /**
     * The server host address
     */
    private String _host;

    /**
     * The port number the server is listening to
     */
    private int _port;

    /**
     * The connection identifier, allocated by the server
     */
    private String _connectionId = null;


    /**
     * Construct a new <code>IpcJmsAdminConnection</code>,
     * without establishing a connection
     *
     * @param host the server host
     * @param port the server port
     */
    protected IpcJmsAdminConnection(String host, int port) {
        _host = host;
        _port = port;
    }

    /**
     * Construct a new <code>IpcJmsAdminConnection</code>,
     * establishing a connection to the server
     *
     * @param host the server host
     * @param port the server port
     * @param username the admin user name
     * @param password the admin password
     * @throws JMSEXception if a connection cannot be established
     */
    public IpcJmsAdminConnection(String host, int port, String username,
                                 String password) throws JMSException {
        this(host, port);
        connect(username, password);
    }

    // implementation of JmsAdminServerIfc.addDurableConsumer
    public boolean addDurableConsumer(String topic, String name)
        throws JMSException {
        Vector v = pack("addDurableConsumer", 2);
        v.add(topic);
        v.add(name);
        send(v);
        return checkReply("addDurableConsumer");
    }

    // implementation of JmsAdminServerIfc.removeDurableConsumer
    public boolean removeDurableConsumer(String name) throws JMSException {
        Vector v = pack("removeDurableConsumer", 1);
        v.add(name);
        send(v);
        return checkReply("removeDurableConsumer");
    }

    // implementation of JmsAdminServerIfc.getDurableConsumers
    public Vector getDurableConsumers(String topic) throws JMSException {
        Vector v = pack("getDurableConsumers", 1);
        v.add(topic);
        send(v);
        return (Vector) getReply("getDurableConsumers");
    }

    // implementation of JmsAdminServerIfc.durableConsumerExists
    public boolean durableConsumerExists(String name) throws JMSException {
        Vector v = pack("durableConsumerExists", 1);
        v.add(name);
        send(v);
        return checkReply("durableConsumerExists");
    }

    /**
     * Check to see if the given consumer is currently connected
     *
     * @param       name the name of the onsumer.
     * @return      <code>true</code> if the consumer is connected
     * @throws      JMSException
     */
    public boolean isConnected(String name) throws JMSException {
        Vector v = pack("isConnected", 1);
        v.add(name);
        send(v);
        return checkReply("isConnected");
    }

    // implementation of JmsAdminServerIfc.removeDurableConsumer
    public boolean unregisterConsumer(String name) throws JMSException {
        Vector v = pack("unregisterConsumer", 1);
        v.add(name);
        send(v);
        return checkReply("unregisterConsumer");
    }

    // implementation of JmsAdminServerIfc.addDestination
    public boolean addDestination(String destination, Boolean queue)
        throws JMSException {
        Vector v = pack("addDestination", 2);
        v.add(destination);
        v.add(queue);
        send(v);
        return checkReply("addDestination");
    }

    // implementation of JmsAdminServerIfc.removeDestination
    public boolean removeDestination(String name) throws JMSException {
        Vector v = pack("removeDestination", 1);
        v.add(name);
        send(v);
        return checkReply("removeDestination");
    }

    // implementation of JmsAdminServerIfc.destinationExists
    public boolean destinationExists(String name) throws JMSException {
        Vector v = pack("destinationExists", 1);
        v.add(name);
        send(v);
        return checkReply("destinationExists");
    }

    // implementation of JmsAdminServerIfc.getAllDestinations
    public Vector getAllDestinations() throws JMSException {
        Vector v = pack("getAllDestinations", 0);
        send(v);
        return (Vector) getReply("getAllDestinations");
    }

    // implementation of JmsAdminServerIfc.getDurableConsumerMessageCount
    public int getDurableConsumerMessageCount(String topic, String name)
        throws JMSException {
        Vector v = pack("getDurableConsumerMessageCount", 2);
        v.add(topic);
        v.add(name);
        send(v);
        Integer result = (Integer) getReply("getDurableConsumerMessageCount");
        return result.intValue();
    }

    // implementation of JmsAdminServerIfc.getDurableConsumerMessageCount
    public int getQueueMessageCount(String queue) throws JMSException {
        Vector v = pack("getQueueMessageCount", 1);
        v.add(queue);
        send(v);
        return ((Integer) getReply("getQueueMessageCount")).intValue();
    }

    // implementation of JmsAdminServerIfc.purgeMessages
    public int purgeMessages() throws JMSException {
        Vector v = pack("purgeMessages", 0);
        send(v);
        return ((Integer) getReply("purgeMessages")).intValue();
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -