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

📄 rmijmsserversession.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-2003 (C) Exoffice Technologies Inc. All Rights Reserved.
 *
 * $Id: RmiJmsServerSession.java,v 1.30 2003/08/07 13:33:10 tanderson Exp $
 *
 * Date         Author  Changes
 * 04/07/2000   jima    Created
 */
package org.exolab.jms.server.rmi;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.Vector;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;

import org.exolab.jms.client.JmsMessageListener;
import org.exolab.jms.client.JmsQueue;
import org.exolab.jms.client.JmsTopic;
import org.exolab.jms.client.rmi.RemoteJmsMessageListenerIfc;
import org.exolab.jms.server.ClientDisconnectionException;
import org.exolab.jms.server.JmsServerSession;


/**
 * This is an implementation of the RemoteJmsServerSessionIfc which delegates
 * all requests to the JmsServerSession class. Actually, an instsnce of this
 * class cannot be created without a JmsServerSession object.
 *
 * @version     $Revision: 1.30 $ $Date: 2003/08/07 13:33:10 $
 * @author      <a href="mailto:jima@exoffice.com">Jim Alateras</a>
 * @see         org.exolab.jms.server.JmsServerSession
 * @see         org.exolab.jms.server.rmi.RemoteJmsServerConnectionIfc
 **/
public class RmiJmsServerSession
    extends UnicastRemoteObject
    implements RemoteJmsServerSessionIfc, JmsMessageListener {

    /**
     * This instance attribute maintains a reference to the delegate. The
     * delegate must be assigned during object construction
     */
    private JmsServerSession _delegate = null;

    /**
     * This is the message listener to the remote object. This is how all the
     * messages are pushed down to the client
     */
    private RemoteJmsMessageListenerIfc _listener = null;


    /**
     * Instantiate an instance of this class given a JmsServerSession.
     * object. If the session object is null then throw the JMSException
     * exception
     *
     * @param       session
     * @exception   JMSException
     * @exception   RemoteException
     */
    public RmiJmsServerSession(JmsServerSession session)
        throws JMSException, RemoteException {
        if (session != null) {
            _delegate = session;
        } else {
            throw new JMSException(
                "Cannot create RmiJmsServerSession with null session");
        }
    }

    /**
     * Return a reference to the client id.
     *
     * @return      String      client id
     * @exception   RemoteException
     */
    public synchronized String getClientId()
        throws RemoteException {
        return _delegate.getClientId();
    }

    /**
     * Return a reference to the session id
     *
     * @return      String      session id
     * @exception   RemoteException
     */
    public synchronized String getSessionId()
        throws JMSException, RemoteException {
        return _delegate.getSessionId();
    }

    /**
     * Close and release any resource allocated to this session. Throw the
     * JMSException exception is a problem is encountered
     *
     * @exception   JMSException
     * @exception   RemoteException
     */
    public synchronized void close()
        throws JMSException, RemoteException {
        _listener = null;
        _delegate.close();
        _delegate = null;
    }

    /**
     * Acknowledge that the message id for the specified client identity. If
     * the acknowledgement faisl then throw JMSException
     *
     * @param       clientId            the client identity.
     * @param       messageId           identity of the message
     * @exception   JMSException        if method does not complete
     * @exception   RemoteException
     */
    public synchronized void acknowledgeMessage(long clientId, String messageId)
        throws JMSException, RemoteException {
        _delegate.acknowledgeMessage(clientId, messageId);
    }

    /**
     * Send the specified message to the server. If there is any problem
     * then throw the JMSException exception
     *
     * @param       message             message to send
     * @exception   JMSException
     * @exception   RemoteException
     */
    public synchronized void sendMessage(Message message)
        throws JMSException, RemoteException {
        _delegate.sendMessage(message);
    }

    /**
     * Send the specified messages to the server. If there is any problem
     * then throw the JMSException exception
     *
     * @param       messages            messages to send
     * @exception   JMSException
     * @exception   RemoteException
     */
    public synchronized void sendMessages(Vector messages)
        throws JMSException, RemoteException {
        _delegate.sendMessages(messages);
    }

    /**
     * Return the next message for the specified client. The <code>wait</code>
     * parameter indicates how long many milliseconds to wait for a message
     * before returning. If <code>wait</code> is 0 then do not wait at all. If
     * <code>wait</code> is -1 then wait indefinitely for the next message
     *
     * @param       clientId            the client identity
     * @param       wait                number of ms to wait
     * @return      Message             the next message or null
     * @exception   JMSException        if there is an app level problem
     * @exception   RemoteException     if there is a RMI based exception.
     */
    public Message receiveMessage(long clientId, long wait)
        throws JMSException, RemoteException {
        return _delegate.receiveMessage(clientId, wait);
    }

    // implementation of RemoteJmsServerSessionIfc.receiveMessages
    public Vector receiveMessages(long clientId, int count)
        throws JMSException, RemoteException {
        return _delegate.receiveMessages(clientId, count);
    }

    /**
     * Create a queue with the specified name. If the queue already exists
     * then simply return a reference to it. If the queue does not exist
     * then create it. If it cannot create the queue then throw the
     * JMSException exception
     *
     * @param       queue               queue to create
     * @exception   JMSException
     * @exception   RemoteException
     */
    public synchronized void createQueue(JmsQueue queue)
        throws JMSException, RemoteException {
        _delegate.createQueue(queue);
    }

    /**
     * Create a topic with the specified name. If the topic already exists
     * then simply return a reference to it. If the topic does not exist
     * then create it. If it cannot create the topic then throw the
     * JMSException exception
     *
     * @param       topic               topic to create
     * @exception   JMSException
     * @exception   RemoteException
     */
    public synchronized void createTopic(JmsTopic topic)
        throws JMSException, RemoteException {
        _delegate.createTopic(topic);
    }

    /**
     * Create a receiver endpoint for this session. A reciever is a message
     * consumer specific to the queue message model. The receiver is
     * associated with a queue.
     * <p>
     * You cannot create more than one receiver for the same destination
     *
     * @param       queue               receiver destination
     * @param       clientId            the session allocated identifier of
     *                                  this consumer
     * @param       selector            the selector to filter messages.
     *                                  This may be null.
     * @exception   JMSException.
     * @exception   RemoteException
     */
    public synchronized void createReceiver(JmsQueue queue, long clientId, String selector)
        throws JMSException, RemoteException {
        _delegate.createReceiver(queue, clientId, selector);
    }

    /**
     * Create a sender endpoint for this session. A sender is a message
     * publisher specific to the queue message model. The sender is associated
     * with a queue.
     * <p>
     * You cannot create more than one receiver for the same destination
     *
     * @param       queue               receiver destination
     * @exception   JMSException.
     * @exception   RemoteException
     */
    public synchronized void createSender(JmsQueue queue)
        throws JMSException, RemoteException {
        _delegate.createSender(queue);
    }

    /**
     * Create a queue browser for this session. This allows clients to browse
     * a queue without removing any messages.
     * <p>
     *
     * You cannot create more than one queue browser for the same queue
     * in a single session.
     *
     * @param       queue               queue to browse
     * @param       clientId            the client identity
     * @param       selector            message selector. This may be null
     * @exception   JMSException
     */
    public synchronized void createBrowser(JmsQueue queue, long clientId, String selector)
        throws JMSException {
        _delegate.createBrowser(queue, clientId, selector);
    }

    /**
     * Delete the receiver for the specified queue. If the receiver does
     * not exist or cannot be deleted throw JMSException
     *
     * @param       id                  identity of receiver
     * @exception   JMSException.
     * @exception   RemoteException
     */
    public synchronized void deleteReceiver(long clientId)
        throws JMSException, RemoteException {
        _delegate.deleteReceiver(clientId);
    }

    /**

⌨️ 快捷键说明

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