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

📄 jmsxatopicsession.java

📁 实现了Jms的服务器源码,支持多种适配器,DB,FTP,支持多种数据库
💻 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 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
 *
 * $Id: JmsXATopicSession.java,v 1.4 2003/08/07 13:32:51 tanderson Exp $
 *
 * Date         Author  Changes
 * 10/09/2001   jima    Created
 */
package org.exolab.jms.client;

// xa library

import javax.jms.JMSException;
import javax.jms.TopicSession;
import javax.jms.TransactionInProgressException;
import javax.jms.XATopicSession;
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;


/**
 *
 * @version     $Revision: 1.4 $ $Date: 2003/08/07 13:32:51 $
 * @author      <a href="mailto:jima@intalio.com">Jim Alateras</a>
 * @see         javax.jms.XATopicSession
 **/
public class JmsXATopicSession
    extends JmsTopicSession
    implements XATopicSession, XAResource {

    /**
     * caches the resource manager id, which is globally unique so that a test
     * through {@link #isSameRM} doesn't have to go across the wire.
     */
    private Long _rid = null;


    /**
     * Create an instance of this class specifying the creating entity. This is
     * the actual connection managing this session. Also specify whether the
     * session is transacted and the acknowledgement mode.
     * <p>
     * If there is a problem creating this object then throw the JMSException
     * exception.
     *
     * @param connection - owner of the session
     * @param transacted - true if the session is transacted
     * @param ackMode - acknowledgement mode
     * @exception JMSException
     */
    JmsXATopicSession(JmsXATopicConnection connection, boolean transacted, int ackMode)
        throws JMSException {
        super(connection, transacted, ackMode);
    }

    // implementation of XATopicSession.getTopicSession
    public TopicSession getTopicSession()
        throws JMSException {
        return this;
    }

    // implementation of XASession.getXAResource
    public XAResource getXAResource() {
        return this;
    }

    // implementation of XASession.getTransacted
    public boolean getTransacted()
        throws JMSException {
        return true;
    }

    // implementation of XASession.commit
    public void commit()
        throws JMSException {
        throw new TransactionInProgressException(
            "Cannot call commit on XASession");
    }

    // implementation of XASession.rollback
    public void rollback()
        throws JMSException {
        throw new TransactionInProgressException(
            "Cannot call rollback on XASession");
    }

    // implementation of XAResource.commit
    public void commit(Xid xid, boolean onePhase)
        throws XAException {
        getJmsSessionStub().commit(xid, onePhase);
    }

    // implementation of XAResource.end
    public void end(Xid xid, int flags)
        throws XAException {
        getJmsSessionStub().end(xid, flags);
    }

    // implementation of XAResource.forget
    public void forget(Xid xid)
        throws XAException {
        getJmsSessionStub().forget(xid);
    }

    // implementation of XAResource.getTransactionTimeout
    public int getTransactionTimeout()
        throws XAException {
        return getJmsSessionStub().getTransactionTimeout();
    }

    // implementation of XAResource.isSameRM
    public boolean isSameRM(XAResource xares)
        throws XAException {

        boolean result = false;

        if ((xares != null) &&
            (xares instanceof JmsXATopicSession) &&
            (((JmsXATopicSession) xares).getResourceManagerId() ==
            getResourceManagerId())) {
            result = true;
        }

        return result;
    }

    // implementation of XAResource.prepare
    public int prepare(Xid xid)
        throws XAException {
        return getJmsSessionStub().prepare(xid);
    }

    // implementation of XAResource.recover
    public Xid[] recover(int flag)
        throws XAException {
        return getJmsSessionStub().recover(flag);
    }

    // implementation of XAResource.rollback
    public void rollback(Xid xid)
        throws XAException {
        getJmsSessionStub().rollback(xid);
    }

    // implementation of XAResource.setTransactionTimeout
    public boolean setTransactionTimeout(int seconds)
        throws XAException {
        return getJmsSessionStub().setTransactionTimeout(seconds);
    }

    // implementation of XAResource.start
    public void start(Xid xid, int flags)
        throws XAException {
        getJmsSessionStub().start(xid, flags);
    }

    /**
     * Return the identity of the associated resource manager. If the value
     * is not cached locally then grab it from the server
     *
     * @return long - the identity of the resource
     * @exception XAException
     */
    public long getResourceManagerId()
        throws XAException {
        if (_rid == null) {
            _rid = new Long(getJmsSessionStub().getResourceManagerId());
        }

        return _rid.longValue();
    }
}

⌨️ 快捷键说明

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