class EmbedXAResource
extends java.lang.Object
implements javax.transaction.xa.XAResource
Modifier and Type | Field and Description |
---|---|
private EmbedPooledConnection |
con |
private XAXactId |
currentXid |
private LanguageConnectionContext |
lcc |
private ResourceAdapter |
ra |
private int |
timeoutSeconds
The value of the transaction timeout on this resource.
|
Constructor and Description |
---|
EmbedXAResource(EmbedPooledConnection con,
ResourceAdapter ra) |
Modifier and Type | Method and Description |
---|---|
private void |
checkUserCredentials(EmbedXAResource original)
Compares the user name and password of the XAResource with
user name and password of this and throws XAException if there is
a mismatch
|
private void |
checkXAActive()
Checks if currently associated connection is active
throws exception if not
|
private static void |
closeUnusedConnection(EmbedConnection conn)
Close an underlying connection object when there is
no active XAResource to hand it to.
|
void |
commit(javax.transaction.xa.Xid xid,
boolean onePhase)
Commit the global transaction specified by xid.
|
void |
end(javax.transaction.xa.Xid xid,
int flags)
Ends the work performed on behalf of a transaction branch.
|
void |
forget(javax.transaction.xa.Xid xid)
Tell the resource manager to forget about a heuristically completed
transaction branch.
|
private static ContextManager |
getContextManager(EmbedConnection conn)
Privileged lookup of the ContextManager.
|
private static ContextService |
getContextService()
Privileged lookup of the ContextService.
|
(package private) javax.transaction.xa.Xid |
getCurrentXid()
Resturns currently active xid
|
private long |
getDefaultXATransactionTimeout()
Returns the default value for the transaction timeout in milliseconds
setted up by the system properties.
|
private LanguageConnectionContext |
getLanguageConnectionContext(EmbedConnection conn)
Gets the LanguageConnectionContext for this connection.
|
private LanguageConnectionContext |
getLanguageConnectionContext(EmbedPooledConnection conn)
Privileged LCC lookup.
|
private XATransactionState |
getTransactionState(XAXactId xid_im)
Returns the XATransactionState of the the transaction
|
int |
getTransactionTimeout()
Obtain the current transaction timeout value set for this XAResource
instance.
|
boolean |
isSameRM(javax.transaction.xa.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(javax.transaction.xa.Xid xid)
Ask the resource manager to prepare for a transaction commit of the
transaction specified in xid.
|
javax.transaction.xa.Xid[] |
recover(int flag)
Obtain a list of prepared transaction branches from a resource
manager.
|
(package private) void |
removeXATransaction(XAXactId xid_im)
Removes the xid from currently active transactions
|
(package private) void |
returnConnectionToResource(XATransactionState tranState,
XAXactId xid_im)
Return an underlying connection object back to its XAResource
if possible.
|
void |
rollback(javax.transaction.xa.Xid xid)
Inform the resource manager to roll back work done on behalf of a
transaction branch
|
(package private) void |
setCurrentXid(XAXactId aCurrentXid) |
boolean |
setTransactionTimeout(int seconds)
Set the current transaction timeout value for this XAResource
instance.
|
void |
start(javax.transaction.xa.Xid xid,
int flags)
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.
|
private static javax.transaction.xa.XAException |
wrapInXAException(java.sql.SQLException se)
Map a SQL exception to appropriate XAException.
|
private static javax.transaction.xa.XAException |
wrapInXAException(StandardException se)
Map a Standard exception to appropriate XAException.
|
private EmbedPooledConnection con
private ResourceAdapter ra
private XAXactId currentXid
private int timeoutSeconds
private LanguageConnectionContext lcc
EmbedXAResource(EmbedPooledConnection con, ResourceAdapter ra)
public final void commit(javax.transaction.xa.Xid xid, boolean onePhase) throws javax.transaction.xa.XAException
commit
in interface javax.transaction.xa.XAResource
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.javax.transaction.xa.XAException
- An error has occurred. Possible XAExceptions are
XA_HEURHAZ, XA_HEURCOM, XA_HEURRB, XA_HEURMIX, XAER_RMERR,
XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or XAER_PROTO.
If the resource manager did not commit the transaction and the paramether onePhase is set to true, the resource manager may throw one of the XA_RB* exceptions. Upon return, the resource manager has rolled back the branch's work and has released all held resources.
public final void end(javax.transaction.xa.Xid xid, int flags) throws javax.transaction.xa.XAException
If TMSUSPEND is specified in flags, the transaction branch is temporarily suspended in incomplete state. The transaction context is in suspened state and must be resumed via start 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.
end
in interface javax.transaction.xa.XAResource
xid
- A global transaction identifier that is the same as what was
used previously in the start method.flags
- One of TMSUCCESS, TMFAIL, or TMSUSPENDjavax.transaction.xa.XAException
- An error has occurred.
Possible XAException values are XAER_RMERR, XAER_RMFAILED, XAER_NOTA,
XAER_INVAL, XAER_PROTO, or XA_RB*.public final int prepare(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAException
prepare
in interface javax.transaction.xa.XAResource
xid
- A global transaction identifierjavax.transaction.xa.XAException
- An error has occurred. Possible exception values
are: XA_RB*, XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or
XAER_PROTO.public int getTransactionTimeout()
getTransactionTimeout
in interface javax.transaction.xa.XAResource
public final boolean isSameRM(javax.transaction.xa.XAResource xares) throws javax.transaction.xa.XAException
isSameRM
in interface javax.transaction.xa.XAResource
xares
- An XAResource object whose resource manager instance is to
be compared with the resource manager instance of the target object.javax.transaction.xa.XAException
- An error has occurred. Possible exception values
are XAER_RMERR, XAER_RMFAIL.public final javax.transaction.xa.Xid[] recover(int flag) throws javax.transaction.xa.XAException
recover
in interface javax.transaction.xa.XAResource
flag
- One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS must
be used when no other flags are set in flags.javax.transaction.xa.XAException
- An error has occurred. Possible values are
XAER_RMERR, XAER_RMFAIL, XAER_INVAL, and XAER_PROTO.public final void forget(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAException
forget
in interface javax.transaction.xa.XAResource
xid
- A global transaction identifierjavax.transaction.xa.XAException
- An error has occurred. Possible exception values
are XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or XAER_PROTO.public final void rollback(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAException
rollback
in interface javax.transaction.xa.XAResource
xid
- A global transaction identifierjavax.transaction.xa.XAException
- - An error has occurredpublic boolean setTransactionTimeout(int seconds) throws javax.transaction.xa.XAException
setTransactionTimeout
in interface javax.transaction.xa.XAResource
seconds
- the transaction timeout value in seconds.
Value of 0 means the reasource manager's default value.
Value of Integer.MAX_VALUE means no timeout.javax.transaction.xa.XAException
- - An error has occurred. Possible exception
values are XAER_RMERR, XAER_RMFAIL, or XAER_INVAL.private long getDefaultXATransactionTimeout() throws javax.transaction.xa.XAException
javax.transaction.xa.XAException
public final void start(javax.transaction.xa.Xid xid, int flags) throws javax.transaction.xa.XAException
start
in interface javax.transaction.xa.XAResource
xid
- A global transaction identifier to be associated with the
resourceflags
- One of TMNOFLAGS, TMJOIN, or TMRESUMEjavax.transaction.xa.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.javax.transaction.xa.Xid getCurrentXid()
private XATransactionState getTransactionState(XAXactId xid_im)
xid_im
- private void checkUserCredentials(EmbedXAResource original) throws javax.transaction.xa.XAException
original
- EmbedXAResourcejavax.transaction.xa.XAException
private void checkXAActive() throws javax.transaction.xa.XAException
javax.transaction.xa.XAException
private static javax.transaction.xa.XAException wrapInXAException(java.sql.SQLException se)
private static javax.transaction.xa.XAException wrapInXAException(StandardException se)
void returnConnectionToResource(XATransactionState tranState, XAXactId xid_im)
tranState
- xid_im
- private static void closeUnusedConnection(EmbedConnection conn)
conn
- void removeXATransaction(XAXactId xid_im)
xid_im
- void setCurrentXid(XAXactId aCurrentXid)
private static ContextService getContextService()
private static ContextManager getContextManager(EmbedConnection conn)
private LanguageConnectionContext getLanguageConnectionContext(EmbedConnection conn)
private LanguageConnectionContext getLanguageConnectionContext(EmbedPooledConnection conn) throws java.sql.SQLException
java.sql.SQLException
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.