📄 xaresource.java
字号:
package com.esri.arcgis.samples.ejb;
import javax.transaction.xa.XAException;
import javax.transaction.xa.Xid;
/**
* The XAResource implements a contract between a transaction manager and a resource
* manager. This type of transaction takes place externally to the resource manager.
* The XAResource transaction management contract supports a two-phase commit protocol
* that ensures that a transaction across multiple resource managers either entirely
* commits or entirely rolls back.
* Implements the javax.transaction.xa.XAResource interface.
*/
public class XAResource implements javax.transaction.xa.XAResource {
private int transactionTimeout;
/**
* Constructs an empty XAResource class.
*/
public XAResource() {
}
/**
* If all resource managers participating in the transaction agree to commit, the
* transaction manager invokes the commit method on each XAResource instance to commit
* the transaction.
*/
public void commit(Xid parm1, boolean parm2) throws XAException {
System.out.println("XAResource Commit");
}
/**
* 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 completed.
*/
public void end(Xid parm1, int parm2) throws XAException {
System.out.println("XAResource End");
}
/**
* Tell the resource manager to forget about a heuristically completed transaction branch.
*/
public void forget(Xid parm1) throws XAException {
System.out.println("XAResource Forget");
}
/**
* Obtain the current transaction timeout value set for this XAResource instance.
* If XAResource.setTransactionTimeout was not use prior to invoking this method,
* the return value is the default timeout set for the resource manager; otherwise,
* the value used in the previous setTransactionTimeout call is returned.
*/
public int getTransactionTimeout() throws XAException {
System.out.println("XAResource getTransactionTimeout");
return transactionTimeout;
}
/**
* This method is called to determine if the resource manager instance
* represented by the target object is the same as the resouce manager instance
* represented by the parameter xares.
*/
public boolean isSameRM(XAResource xares) throws XAException {
System.out.println("XAResource isSameRM");
return this == xares;
}
/**
* Ask the resource manager to prepare for a transaction commit of the transaction specified in xid.
*/
public int prepare(Xid parm1) throws XAException {
System.out.println("XAResource prepare");
return XA_OK;
}
/**
* 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.
*/
public Xid[] recover(int parm1) throws XAException {
System.out.println("XAResource recover");
return null;
}
/**
* If even one resource manager does not vote for the commit, the transaction manager
* rolls back the transaction by calling the rollback method on all participating XAResource
* interfaces.
*/
public void rollback(Xid parm1) throws XAException {
System.out.println("XAResource rollback");
}
/**
* Set the current transaction timeout value for this XAResource instance.
* Once set, this timeout value is effective until setTransactionTimeout is
* invoked again with a different value. To reset the timeout value to the default
* value used by the resource manager, set the value to zero.
* If the timeout operation is performed successfully, the method returns true;
* otherwise false. If a resource manager does not support transaction timeout
* value to be set explicitly, this method returns false.
*/
public boolean setTransactionTimeout(int seconds) throws XAException {
transactionTimeout = seconds;
System.out.println("XAResource setTransactionTimeout");
return true;
}
/**
* 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. If TMRESUME is specified, the start is to resume 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.
*/
public void start(Xid parm1, int parm2) throws XAException {
System.out.println("XAResource start");
}
public boolean isSameRM(javax.transaction.xa.XAResource xAResource) throws XAException {
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -