boolean start = method.equals(startMethod);
boolean end = endTransactionMethodSet.contains(method);
if (start || end || method.equals(prepareMethod) || intraTransactionMethodSet.contains(method))
{
final InvocationStrategy strategy = end ? InvocationStrategies.END_TRANSACTION_INVOKE_ON_ALL : InvocationStrategies.TRANSACTION_INVOKE_ON_ALL;
Xid xid = (Xid) parameters[0];
DatabaseCluster<XADataSource, XADataSourceDatabase> cluster = this.getProxyFactory().getDatabaseCluster();
if (start)
{
final Lock lock = cluster.getLockManager().readLock(null);
// Lock may already exist if we're resuming a suspended transaction
if (lockMap.putIfAbsent(xid, lock) == null)
{
return new InvocationStrategy()
{
@Override
public <Z, D extends Database<Z>, T, R, E extends Exception> SortedMap<D, R> invoke(ProxyFactory<Z, D, T, E> proxy, Invoker<Z, D, T, R, E> invoker) throws E
{
lock.lock();
try
{
return strategy.invoke(proxy, invoker);
}
catch (Exception e)
{
lock.unlock();
throw proxy.getExceptionFactory().createException(e);
}
}
};
}
}
Durability.Phase phase = phaseRegistry.get(method);
if (phase != null)
{
final InvocationStrategy durabilityStrategy = cluster.getDurability().getInvocationStrategy(strategy, phase, xid);
if (endTransactionMethodSet.contains(method))
{
final Lock lock = lockMap.remove(xid);
return new InvocationStrategy()
{
@Override
public <Z, D extends Database<Z>, T, R, E extends Exception> SortedMap<D, R> invoke(ProxyFactory<Z, D, T, E> proxy, Invoker<Z, D, T, R, E> invoker) throws E
{
try
{
return durabilityStrategy.invoke(proxy, invoker);
}
finally
{
if (lock != null)
{