本文整理汇总了Java中javax.transaction.xa.XAResource.XA_OK属性的典型用法代码示例。如果您正苦于以下问题:Java XAResource.XA_OK属性的具体用法?Java XAResource.XA_OK怎么用?Java XAResource.XA_OK使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.transaction.xa.XAResource
的用法示例。
在下文中一共展示了XAResource.XA_OK属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepare
/**
* Prepare the transaction TODO: Store prepare results
*
* @return - the tx code
*/
@SuppressWarnings("unchecked")
public int prepare() throws IndexerException
{
boolean isPrepared = true;
boolean isModified = false;
Map<StoreRef, LuceneIndexer> indexers = (Map<StoreRef, LuceneIndexer>) AlfrescoTransactionSupport.getResource(indexersKey);
if (indexers != null)
{
for (LuceneIndexer indexer : indexers.values())
{
try
{
isModified |= indexer.isModified();
indexer.prepare();
}
catch (IndexerException e)
{
isPrepared = false;
throw new IndexerException("Failed to prepare: requires rollback", e);
}
}
}
if (isPrepared)
{
if (isModified)
{
return XAResource.XA_OK;
}
else
{
return XAResource.XA_RDONLY;
}
}
else
{
throw new IndexerException("Failed to prepare: requires rollback");
}
}
示例2: prepare
/**
* Prepare to commit At the moment this makes sure we have all the locks TODO: This is not doing proper
* serialisation against the index as would a data base transaction.
*
* @return the tx state
* @throws LuceneIndexException
*/
public int prepare() throws LuceneIndexException
{
if (s_logger.isDebugEnabled())
{
s_logger.debug(Thread.currentThread().getName() + " Starting Prepare");
}
switch (getStatus().getStatus())
{
case Status.STATUS_COMMITTING:
throw new IndexerException("Unable to prepare: Transaction is committing");
case Status.STATUS_COMMITTED:
throw new IndexerException("Unable to prepare: Transaction is commited ");
case Status.STATUS_ROLLING_BACK:
throw new IndexerException("Unable to prepare: Transaction is rolling back");
case Status.STATUS_ROLLEDBACK:
throw new IndexerException("Unable to prepare: Transaction is aleady rolled back");
case Status.STATUS_MARKED_ROLLBACK:
throw new IndexerException("Unable to prepare: Transaction is marked for roll back");
case Status.STATUS_PREPARING:
throw new IndexerException("Unable to prepare: Transaction is already preparing");
case Status.STATUS_PREPARED:
throw new IndexerException("Unable to prepare: Transaction is already prepared");
default:
try
{
setStatus(TransactionStatus.PREPARING);
if (isModified())
{
doPrepare();
if (s_logger.isDebugEnabled())
{
s_logger.debug(Thread.currentThread().getName() + " Waiting to Finish Preparing");
}
}
setStatus(TransactionStatus.PREPARED);
return isModified() ? XAResource.XA_OK : XAResource.XA_RDONLY;
}
catch (LuceneIndexException e)
{
setRollbackOnly();
if (s_logger.isDebugEnabled())
{
s_logger.debug(Thread.currentThread().getName() + " Prepare Failed", e);
}
throw new LuceneIndexException("Index failed to prepare", e);
}
catch (Throwable t)
{
// If anything goes wrong we try and do a roll back
rollback();
if (s_logger.isDebugEnabled())
{
s_logger.debug(Thread.currentThread().getName() + " Prepare Failed", t);
}
throw new LuceneIndexException("Prepared failed", t);
}
finally
{
if (s_logger.isDebugEnabled())
{
s_logger.debug(Thread.currentThread().getName() + " Ending Prepare");
}
}
}
}
示例3: prepare
public int prepare(Xid xid) throws XAException {
//LOG warning that semantics are incorrect...
return XAResource.XA_OK;
}