{
preparedXids.add( re.getXid() );
int vote = re.getResource().prepare( re.getXid() );
if ( vote == XAResource.XA_OK )
{
throw new ReadOnlyDbException();
}
else if ( vote == XAResource.XA_RDONLY )
{
re.setStatus( RS_READONLY );
}
else
{
// rollback tx
status = Status.STATUS_MARKED_ROLLBACK;
return;
}
}
else
{
// set it to readonly, only need to commit once
re.setStatus( RS_READONLY );
}
}
status = Status.STATUS_PREPARED;
}
// commit
if ( !onePhase && readOnly )
{
status = Status.STATUS_COMMITTED;
return;
}
status = Status.STATUS_COMMITTING;
Iterator<ResourceElement> itr = resourceList.iterator();
while ( itr.hasNext() )
{
ResourceElement re = itr.next();
if ( re.getStatus() != RS_READONLY )
{
throw new ReadOnlyDbException();
}
}
status = Status.STATUS_COMMITTED;
}