Package com.sun.gjc.spi
Class XAResourceImpl
- java.lang.Object
-
- com.sun.gjc.spi.XAResourceImpl
-
- All Implemented Interfaces:
XAResource
public class XAResourceImpl extends Object implements XAResource
XAResource
wrapper for Generic JDBC Connector.- Version:
- 1.0, 02/08/23
- Author:
- Evani Sai Surya Kiran
-
-
Field Summary
-
Fields inherited from interface javax.transaction.xa.XAResource
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
-
-
Constructor Summary
Constructors Constructor Description XAResourceImpl(XAResource xar, ManagedConnectionImpl mc)
Constructor for XAResourceImpl
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
commit(Xid xid, boolean onePhase)
Commit the global transaction specified by xid.void
end(Xid xid, int flags)
Ends the work performed on behalf of a transaction branch.void
forget(Xid xid)
Tell the resource manager to forget about a heuristically completed transaction branch.int
getTransactionTimeout()
Obtain the current transaction timeout value set for thisXAResource
instance.boolean
isSameRM(XAResource xares)
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.int
prepare(Xid xid)
Ask the resource manager to prepare for a transaction commit of the transaction specified in xid.Xid[]
recover(int flag)
Obtain a list of prepared transaction branches from a resource manager.void
rollback(Xid xid)
Inform the resource manager to roll back work done on behalf of a transaction branchboolean
setTransactionTimeout(int seconds)
Set the current transaction timeout value for thisXAResource
instance.void
start(Xid xid, int flags)
Start work on behalf of a transaction branch specified in xid.
-
-
-
Constructor Detail
-
XAResourceImpl
public XAResourceImpl(XAResource xar, ManagedConnectionImpl mc)
Constructor for XAResourceImpl- Parameters:
xar
-XAResource
mc
-ManagedConnection
-
-
Method Detail
-
commit
public void commit(Xid xid, boolean onePhase) throws XAException
Commit the global transaction specified by xid.- Specified by:
commit
in interfaceXAResource
- Parameters:
xid
- A global transaction identifieronePhase
- If true, the resource manager should use a one-phase commit protocol to commit the work done on behalf of xid.- Throws:
XAException
-
end
public void end(Xid xid, int flags) throws XAException
Ends the work performed on behalf of a transaction branch.- Specified by:
end
in interfaceXAResource
- Parameters:
xid
- A global transaction identifier that is the same as what was used previously in the start method.flags
- One of TMSUCCESS, TMFAIL, or TMSUSPEND- Throws:
XAException
-
forget
public void forget(Xid xid) throws XAException
Tell the resource manager to forget about a heuristically completed transaction branch.- Specified by:
forget
in interfaceXAResource
- Parameters:
xid
- A global transaction identifier- Throws:
XAException
-
getTransactionTimeout
public int getTransactionTimeout() throws XAException
Obtain the current transaction timeout value set for thisXAResource
instance.- Specified by:
getTransactionTimeout
in interfaceXAResource
- Returns:
- the transaction timeout value in seconds
- Throws:
XAException
-
isSameRM
public boolean isSameRM(XAResource xares) throws XAException
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.- Specified by:
isSameRM
in interfaceXAResource
- Parameters:
xares
- AnXAResource
object whose resource manager instance is to be compared with the resource- Returns:
- true if it's the same RM instance; otherwise false.
- Throws:
XAException
-
prepare
public int prepare(Xid xid) throws XAException
Ask the resource manager to prepare for a transaction commit of the transaction specified in xid.- Specified by:
prepare
in interfaceXAResource
- Parameters:
xid
- A global transaction identifier- Returns:
- A value indicating the resource manager's vote on the
outcome of the transaction. The possible values
are: XA_RDONLY or XA_OK. If the resource manager wants
to roll back the transaction, it should do so
by raising an appropriate
XAException
in the prepare method. - Throws:
XAException
-
recover
public Xid[] recover(int flag) throws XAException
Obtain a list of prepared transaction branches from a resource manager.- Specified by:
recover
in interfaceXAResource
- Parameters:
flag
- One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS must be used when no other flags are set in flags.- Returns:
- The resource manager returns zero or more XIDs for the transaction
branches that are currently in a prepared or heuristically
completed state. If an error occurs during the operation, the resource
manager should throw the appropriate
XAException
. - Throws:
XAException
-
rollback
public void rollback(Xid xid) throws XAException
Inform the resource manager to roll back work done on behalf of a transaction branch- Specified by:
rollback
in interfaceXAResource
- Parameters:
xid
- A global transaction identifier- Throws:
XAException
-
setTransactionTimeout
public boolean setTransactionTimeout(int seconds) throws XAException
Set the current transaction timeout value for thisXAResource
instance.- Specified by:
setTransactionTimeout
in interfaceXAResource
- Parameters:
seconds
- the transaction timeout value in seconds.- Returns:
- true if transaction timeout value is set successfully; otherwise false.
- Throws:
XAException
-
start
public void start(Xid xid, int flags) throws XAException
Start work on behalf of a transaction branch specified in xid.- Specified by:
start
in interfaceXAResource
- Parameters:
xid
- A global transaction identifier to be associated with the resourceflags
- One ofXAResource.TMNOFLAGS
,XAResource.TMJOIN
, orXAResource.TMRESUME
- Throws:
XAException
-
-