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

📄 ipcjmssessionconnection.java

📁 实现了Jms的服务器源码,支持多种适配器,DB,FTP,支持多种数据库
💻 JAVA
📖 第 1 页 / 共 3 页
字号:

    /**
     * Unsubscribe a durable subscription
     *
     * @param       session             the session the request is for
     * @param       name                the name used to identify the
     *                                  subscription
     * @return      Vector              the result of the request.
     */
    public Vector unsubscribe(JmsServerSession session, String name) {
        try {
            session.unsubscribe(name);
        } catch (JMSException exception) {
            return pack(Boolean.FALSE, exception);
        }
        return pack(Boolean.TRUE, null);
    }

    /**
     * Stop message delivery for this session.
     *
     * @param session The session the request is for.
     * @return Vector The result of the request.
     *
     */
    protected Vector stopMessageDelivery(JmsServerSession session) {
        try {
            session.stopMessageDelivery();
        } catch (JMSException exception) {
            return pack(Boolean.FALSE, exception);
        }

        return pack(Boolean.TRUE, null);
    }


    /**
     * Enable or disable asynchronous message delivery.
     *
     * @param session - the session the request is for.
     * @param clientId - consumer identity
     * @param enable - true to enable
     * @return Vector - the result of the request.
     *
     */
    protected Vector enableAsynchronousDelivery(JmsServerSession session,
                                                Long clientId, String id,
                                                Boolean enable) {
        try {
            session.enableAsynchronousDelivery(
                clientId.longValue(), id, enable.booleanValue());
        } catch (JMSException exception) {
            return pack(Boolean.FALSE, exception);
        }

        return pack(Boolean.TRUE, null);
    }

    /**
     * Start message delivery for this session.
     *
     * @param session The session the request is for.
     * @return Vector The result of the request.
     *
     */
    protected Vector startMessageDelivery(JmsServerSession session) {
        try {
            session.startMessageDelivery();
        } catch (JMSException exception) {
            return pack(Boolean.FALSE, exception);
        }

        return pack(Boolean.TRUE, null);
    }

    /**
     * recover the session
     *
     * @param session The session the request is for.
     * @return Vector The result of the request.
     */
    protected Vector recover(JmsServerSession session) {
        try {
            session.recover();
        } catch (JMSException exception) {
            return pack(Boolean.FALSE, exception);
        }

        return pack(Boolean.TRUE, null);
    }

    /**
     * commit the session
     *
     * @param session The session the request is for.
     * @return Vector The result of the request.
     */
    protected Vector commit(JmsServerSession session) {
        try {
            session.commit();
        } catch (JMSException exception) {
            return pack(Boolean.FALSE, exception);
        }

        return pack(Boolean.TRUE, null);
    }

    /**
     * rollback the session
     *
     * @param session The session the request is for.
     * @return Vector The result of the request.
     */
    protected Vector rollback(JmsServerSession session) {
        try {
            session.rollback();
        } catch (JMSException exception) {
            return pack(Boolean.FALSE, exception);
        }

        return pack(Boolean.TRUE, null);
    }

    /**
     * Commits an XA transaction that is in progress.
     *
     * @param xid - the xa transaction identity
     * @param onePhase - treu if it is a one phase commit
     * @return Vector
     */
    protected Vector XACommit(JmsServerSession session, Xid xid,
                              Boolean onePhase) {
        try {
            session.commit(xid, onePhase.booleanValue());
        } catch (Exception exception) {
            return pack(Boolean.FALSE, exception);
        }

        return pack(Boolean.TRUE, null);
    }

    /**
     * Ends the work performed on behalf of a transaction branch. The resource
     * manager disassociates the XA resource from the transaction branch
     * specified and let the transaction be completedCommits an XA transaction
     * that is in progress.
     *
     * @param xid - the xa transaction identity
     * @param flags - one of TMSUCCESS, TMFAIL, or TMSUSPEND
     * @return Vector
     */
    protected Vector XAEnd(JmsServerSession session, Xid xid, Integer flags) {
        try {
            session.end(xid, flags.intValue());
        } catch (Exception exception) {
            return pack(Boolean.FALSE, exception);
        }

        return pack(Boolean.TRUE, null);
    }

    /**
     * Tell the resource manager to forget about a heuristically completed
     * transaction branch.
     *
     * @param xid - the xa transaction identity
     * @return Vector
     */
    protected Vector XAForget(JmsServerSession session, Xid xid) {
        try {
            session.forget(xid);
        } catch (Exception exception) {
            return pack(Boolean.FALSE, exception);
        }

        return pack(Boolean.TRUE, null);
    }

    /**
     * Return the transaction timeout for this instance of the resource
     * manager.
     *
     * @return int - the timeout in seconds
     * @return Vector
     */
    protected Vector XAGetTransactionTimeout(JmsServerSession session) {
        int seconds = 0;
        try {
            seconds = session.getTransactionTimeout();
        } catch (Exception exception) {
            return pack(Boolean.FALSE, exception);
        }

        return pack(Boolean.TRUE, new Integer(seconds));
    }

    /**
     * Ask the resource manager to prepare for a transaction commit of the
     * transaction specified in xid
     *
     * @param xid - the xa transaction identity
     * @return Vector
     */
    protected Vector XAPrepare(JmsServerSession session, Xid xid) {
        try {
            session.prepare(xid);
        } catch (Exception exception) {
            return pack(Boolean.FALSE, exception);
        }

        return pack(Boolean.TRUE, null);
    }

    /**
     * Obtain a list of prepared transaction branches from a resource manager.
     * The transaction manager calls this method during recovery to obtain the
     * list of transaction branches that are currently in prepared or
     * heuristically completed states.
     *
     * @param flag - One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS
     * @param Xid[] - the set of Xids to recover
     * @return Vector
     */
    public Vector XARecover(JmsServerSession session, Integer flag) {
        Xid[] xids = null;
        try {
            xids = session.recover(flag.intValue());
        } catch (Exception exception) {
            return pack(Boolean.FALSE, exception);
        }

        return pack(Boolean.TRUE, xids);
    }

    /**
     * Inform the resource manager to roll back work done on behalf of a
     * transaction branch
     *
     * @param xid - the xa transaction identity
     * @author Vector
     */
    protected Vector XARollback(JmsServerSession session, Xid xid) {
        try {
            session.rollback(xid);
        } catch (Exception exception) {
            return pack(Boolean.FALSE, exception);
        }

        return pack(Boolean.TRUE, null);
    }

    /**
     * Set the current transaction timeout value for this XAResource instance.
     *
     * @param seconds - timeout in seconds
     * @return boolean - true if the new transaction timeout was accepted
     * @return Vector
     */
    protected Vector XASetTransactionTimeout(JmsServerSession session,
                                             Integer seconds) {
        boolean result = false;
        try {
            result = session.setTransactionTimeout(seconds.intValue());
        } catch (Exception exception) {
            return pack(Boolean.FALSE, exception);
        }

        return pack(Boolean.TRUE, new Boolean(result));
    }

    /**
     * Start work on behalf of a transaction branch specified in xid If TMJOIN
     * is specified, the start is for joining a transaction previously seen by
     * the resource manager
     *
     * @param xid - the xa transaction identity
     * @param flags - One of TMNOFLAGS, TMJOIN, or TMRESUME
     * @return Vector
     */
    protected Vector XAStart(JmsServerSession session, Xid xid,
                             Integer flags) {
        try {
            session.start(xid, flags.intValue());
        } catch (Exception exception) {
            return pack(Boolean.FALSE, exception);
        }

        return pack(Boolean.TRUE, null);
    }

    /**
     * Return the identity of the resource manager.
     *
     * @param session - the session identity
     * @return Vector
     */
    protected Vector XAGetResourceManagerId(JmsServerSession session) {
        String id = null;
        try {
            id = session.getResourceManagerId();
        } catch (Exception exception) {
            return pack(Boolean.FALSE, exception);
        }

        return pack(Boolean.TRUE, id);
    }

    /**
     * Pack all the data that is required by the server in a vector.
     * Set the size of the vector to be exactly the right size for efficiency.
     *
     * @param success Boolean indicating success or failure of request.
     * @param ob The Object being returned.
     * @return Vector The vector containing all the data.
     *
     */
    protected Vector pack(Boolean success, Object ob) {
        Vector v = new Vector(2);
        v.add(success);
        v.add(ob);
        return v;
    }

}

⌨️ 快捷键说明

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