Class GenericXaResource
- java.lang.Object
-
- java.lang.Thread
-
- org.apache.ofbiz.entity.transaction.GenericXaResource
-
- All Implemented Interfaces:
java.lang.Runnable
,XAResource
- Direct Known Subclasses:
DebugXaResource
,ServiceXaWrapper
public abstract class GenericXaResource extends java.lang.Thread implements XAResource
GenericXaResource - Abstract XA Resource implementation supporting a single transaction
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
active
static java.lang.String
module
protected java.lang.Integer
timeout
timeout is an Integer and defaults to null so that we know if it is set on this object; if it isn't set we won't worry about the warning message, etc because we don't know what the real timeout isprotected Transaction
trans
protected Xid
xid
-
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 GenericXaResource()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
commit(Xid xid, boolean onePhase)
void
end(Xid xid, int flag)
void
enlist()
Enlists this resource in the current transactionvoid
enlist(Transaction tx)
Enlists this resource in the current transactionvoid
forget(Xid xid)
Transaction
getTransaction()
int
getTransactionTimeout()
Xid
getXid()
boolean
isSameRM(XAResource xaResource)
int
prepare(Xid xid)
Xid[]
recover(int flag)
abstract void
rollback(Xid xid)
void
run()
void
runOnTimeout()
Method which will run when the transaction times outvoid
setTransaction(Transaction t)
boolean
setTransactionTimeout(int seconds)
void
start(Xid xid, int flag)
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
module
public static final java.lang.String module
-
trans
protected Transaction trans
-
active
protected boolean active
-
timeout
protected java.lang.Integer timeout
timeout is an Integer and defaults to null so that we know if it is set on this object; if it isn't set we won't worry about the warning message, etc because we don't know what the real timeout is
-
xid
protected Xid xid
-
-
Method Detail
-
enlist
public void enlist() throws XAException
Enlists this resource in the current transaction- Throws:
XAException
-
enlist
public void enlist(Transaction tx) throws XAException
Enlists this resource in the current transaction- Throws:
XAException
-
start
public void start(Xid xid, int flag) throws XAException
- Specified by:
start
in interfaceXAResource
- Throws:
XAException
- See Also:
XAResource.start(javax.transaction.xa.Xid xid, int flag)
-
end
public void end(Xid xid, int flag) throws XAException
- Specified by:
end
in interfaceXAResource
- Throws:
XAException
- See Also:
XAResource.end(javax.transaction.xa.Xid xid, int flag)
-
forget
public void forget(Xid xid) throws XAException
- Specified by:
forget
in interfaceXAResource
- Throws:
XAException
- See Also:
XAResource.forget(javax.transaction.xa.Xid xid)
-
prepare
public int prepare(Xid xid) throws XAException
- Specified by:
prepare
in interfaceXAResource
- Throws:
XAException
- See Also:
XAResource.prepare(javax.transaction.xa.Xid xid)
-
recover
public Xid[] recover(int flag) throws XAException
- Specified by:
recover
in interfaceXAResource
- Throws:
XAException
- See Also:
XAResource.recover(int flag)
-
isSameRM
public boolean isSameRM(XAResource xaResource) throws XAException
- Specified by:
isSameRM
in interfaceXAResource
- Throws:
XAException
- See Also:
XAResource.isSameRM(javax.transaction.xa.XAResource xaResource)
-
getTransactionTimeout
public int getTransactionTimeout() throws XAException
- Specified by:
getTransactionTimeout
in interfaceXAResource
- Throws:
XAException
- See Also:
XAResource.getTransactionTimeout()
-
setTransactionTimeout
public boolean setTransactionTimeout(int seconds) throws XAException
- Specified by:
setTransactionTimeout
in interfaceXAResource
- Throws:
XAException
- See Also:
Note: the valus is saved but in the current implementation this is not used.
-
getTransaction
public Transaction getTransaction()
-
setTransaction
public void setTransaction(Transaction t)
-
getXid
public Xid getXid()
-
commit
public abstract void commit(Xid xid, boolean onePhase) throws XAException
- Specified by:
commit
in interfaceXAResource
- Throws:
XAException
- See Also:
XAResource.commit(javax.transaction.xa.Xid xid, boolean onePhase)
-
rollback
public abstract void rollback(Xid xid) throws XAException
- Specified by:
rollback
in interfaceXAResource
- Throws:
XAException
- See Also:
XAResource.rollback(javax.transaction.xa.Xid xid)
-
runOnTimeout
public void runOnTimeout()
Method which will run when the transaction times out
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classjava.lang.Thread
-
-