當前位置: 首頁>>代碼示例>>Java>>正文


Java XAException.XAER_INVAL屬性代碼示例

本文整理匯總了Java中javax.transaction.xa.XAException.XAER_INVAL屬性的典型用法代碼示例。如果您正苦於以下問題:Java XAException.XAER_INVAL屬性的具體用法?Java XAException.XAER_INVAL怎麽用?Java XAException.XAER_INVAL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.transaction.xa.XAException的用法示例。


在下文中一共展示了XAException.XAER_INVAL屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: commit

@Override
public void commit(Xid xid, boolean onePhase) throws XAException
{
	if (logger.logDebug())
	{
		debug("committing xid = " + xid + (onePhase ? " (one phase) " : " (two phase)"));
	}

	if (xid == null)
	{
		throw new CloudSpannerXAException("xid must not be null", Code.INVALID_ARGUMENT, XAException.XAER_INVAL);
	}

	if (onePhase)
	{
		commitOnePhase(xid);
	}
	else
	{
		commitPrepared(xid);
	}
}
 
開發者ID:olavloite,項目名稱:spanner-jdbc,代碼行數:22,代碼來源:CloudSpannerXAConnection.java

示例2: start

/**
 * Starts work on behalf of a transaction branch specified in xid.
 * 
 * If TMJOIN is specified, the start applies to joining a transaction
 * previously seen by the resource manager.
 * 
 * If TMRESUME is specified, the start applies to resuming a suspended
 * transaction specified in the parameter xid.
 * 
 * If neither TMJOIN nor TMRESUME is specified and the transaction specified
 * by xid has previously been seen by the resource manager, the resource
 * manager throws the XAException exception with XAER_DUPID error code.
 * 
 * @parameter xid A global transaction identifier to be associated with the
 *            resource.
 * 
 * @parameter flags One of TMNOFLAGS, TMJOIN, or TMRESUME.
 * 
 * @throws XAException
 *             An error has occurred. Possible exceptions are XA_RB*,
 *             XAER_RMERR, XAER_RMFAIL, XAER_DUPID, XAER_OUTSIDE, XAER_NOTA,
 *             XAER_INVAL, or XAER_PROTO.
 */
public void start(Xid xid, int flags) throws XAException {
    StringBuilder commandBuf = new StringBuilder(MAX_COMMAND_LENGTH);
    commandBuf.append("XA START ");
    appendXid(commandBuf, xid);

    switch (flags) {
        case TMJOIN:
            commandBuf.append(" JOIN");
            break;
        case TMRESUME:
            commandBuf.append(" RESUME");
            break;
        case TMNOFLAGS:
            // no-op
            break;
        default:
            throw new XAException(XAException.XAER_INVAL);
    }

    dispatchCommand(commandBuf.toString());

    this.underlyingConnection.setInGlobalTx(true);
}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:46,代碼來源:MysqlXAConnection.java

示例3: end

/**
 * Preconditions: 1. Flags is one of TMSUCCESS, TMFAIL, TMSUSPEND 2. xid !=
 * null 3. Connection is associated with transaction xid
 *
 * Implementation deficiency preconditions: 1. Flags is not TMSUSPEND
 *
 * Postconditions: 1. connection is disassociated from the transaction.
 * 
 * @see XAResource#end(Xid, int)
 */
@Override
public void end(Xid xid, int flags) throws XAException
{
	if (logger.logDebug())
	{
		debug("ending transaction xid = " + xid);
	}

	// Check preconditions

	if (flags != XAResource.TMSUSPEND && flags != XAResource.TMFAIL && flags != XAResource.TMSUCCESS)
	{
		throw new CloudSpannerXAException("Invalid flags", Code.INVALID_ARGUMENT, XAException.XAER_INVAL);
	}

	if (xid == null)
	{
		throw new CloudSpannerXAException("xid must not be null", Code.INVALID_ARGUMENT, XAException.XAER_INVAL);
	}

	if (state != STATE_ACTIVE || !currentXid.equals(xid))
	{
		throw new CloudSpannerXAException("tried to call end without corresponding start call",
				Code.FAILED_PRECONDITION, XAException.XAER_PROTO);
	}

	// Check implementation deficiency preconditions
	if (flags == XAResource.TMSUSPEND)
	{
		throw new CloudSpannerXAException("suspend/resume not implemented", Code.UNIMPLEMENTED,
				XAException.XAER_RMERR);
	}

	// We ignore TMFAIL. It's just a hint to the RM. We could roll back
	// immediately
	// if TMFAIL was given.

	// All clear. We don't have any real work to do.
	state = STATE_ENDED;
}
 
開發者ID:olavloite,項目名稱:spanner-jdbc,代碼行數:50,代碼來源:CloudSpannerXAConnection.java

示例4: end

/**
 * Ends the work performed on behalf of a transaction branch.
 * 
 * The resource manager disassociates the XA resource from the transaction
 * branch specified and lets the transaction complete.
 * 
 * If TMSUSPEND is specified in the flags, the transaction branch is
 * temporarily suspended in an incomplete state. The transaction context is
 * in a suspended state and must be resumed via the start method with
 * TMRESUME specified.
 * 
 * If TMFAIL is specified, the portion of work has failed. The resource
 * manager may mark the transaction as rollback-only
 * 
 * If TMSUCCESS is specified, the portion of work has completed
 * successfully.
 * 
 * @parameter xid A global transaction identifier that is the same as the
 *            identifier used previously in the start method.
 * 
 * @parameter flags One of TMSUCCESS, TMFAIL, or TMSUSPEND.
 * 
 * @throws XAException
 *             -
 *             An error has occurred. Possible XAException values are
 *             XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, XAER_PROTO,
 *             or XA_RB*.
 */
public void end(Xid xid, int flags) throws XAException {
    StringBuilder commandBuf = new StringBuilder(MAX_COMMAND_LENGTH);
    commandBuf.append("XA END ");
    appendXid(commandBuf, xid);

    switch (flags) {
        case TMSUCCESS:
            break; // no-op
        case TMSUSPEND:
            commandBuf.append(" SUSPEND");
            break;
        case TMFAIL:
            break; // no-op
        default:
            throw new XAException(XAException.XAER_INVAL);
    }

    dispatchCommand(commandBuf.toString());
}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:47,代碼來源:MysqlXAConnection.java


注:本文中的javax.transaction.xa.XAException.XAER_INVAL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。