|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.neo4j.kernel.impl.transaction.xaframework.XaConnectionHelpImpl
public abstract class XaConnectionHelpImpl
XaConnectionHelpImpl
helps with basic implementation that is
needed to fit a non XA compatible resource in the xaframework
.
Put your methods that perform any transactional work towards the resource in
your extention of this class. Create a instance of the
XaResourceHelpImpl
as your XAResource
. Add a
try-finally block in your work methods around the command creations and
enlist/delist the XAResource
with the transaction. Use the
protected getTransaction
method to get a XaTransaction
and add your commands to the transaction. Here is an example implementation:
public class MyConnection extends XaConnectionHelpImpl
{
private static class MyResource extends XaResourceHelpImpl
{
public boolean isSameRM( XAResource rm )
{
if ( rm instanceof MyResource )
{
return true;
}
return false;
}
}
private XaResource xaResource = new MyResource();
public XaResource getXaResource()
{
return xaResource;
}
public void doWork1() throws SomeException
{
enlistResourceWithTx();
try
{
getTransaction().addCommand( new Work1Command( params ) );
}
finally
{
delistResourceFromTx();
}
}
}
Constructor Summary | |
---|---|
XaConnectionHelpImpl(XaResourceManager xaRm)
|
Method Summary | |
---|---|
void |
clearAllTransactions()
Will clear the resource manager of all transactions. |
void |
destroy()
Destroys this connection and depending on XAResource
implementation the work done on the resource will be rolled back, saved
or committed (may also depend on transactional state). |
protected XaTransaction |
getTransaction()
Returns the XaTransaction associated with this connection. |
abstract XAResource |
getXaResource()
Returns the XAResource associated with this connection. |
void |
validate()
Makes sure the resource is enlisted as active in the transaction. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XaConnectionHelpImpl(XaResourceManager xaRm)
Method Detail |
---|
public abstract XAResource getXaResource()
getXaResource
in interface XaConnection
public void destroy()
XaConnection
XAResource
implementation the work done on the resource will be rolled back, saved
or committed (may also depend on transactional state).
This method is only valid to call once and there after it is illegal to
invoke getXaResource
or any other method that creates
transactions or performs work using the XAResource
.
destroy
in interface XaConnection
public void validate() throws XAException
XAException
- If resource not enlisted or suspendedprotected XaTransaction getTransaction() throws XAException
XaTransaction
associated with this connection. If
transaction is already completed it will still be returned.
XaTransaction
associated with this connection
XAException
- If the transaction hasn't completed and the resource isn't
enlistedpublic void clearAllTransactions()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |