当前位置: 首页>>代码示例>>Java>>正文


Java Transaction.isReadOnly方法代码示例

本文整理汇总了Java中org.eclipse.emf.transaction.Transaction.isReadOnly方法的典型用法代码示例。如果您正苦于以下问题:Java Transaction.isReadOnly方法的具体用法?Java Transaction.isReadOnly怎么用?Java Transaction.isReadOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.emf.transaction.Transaction的用法示例。


在下文中一共展示了Transaction.isReadOnly方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runExclusive

import org.eclipse.emf.transaction.Transaction; //导入方法依赖的package包/类
public static <T> T runExclusive(TransactionalEditingDomain d, Runnable read) throws InterruptedException {
	InternalTransactionalEditingDomain domain = (InternalTransactionalEditingDomain) d;
	Transaction active = domain.getActiveTransaction();
	Transaction tx = null;
	long start = -1;
	if ((active == null) || !(active.isActive() && active.isReadOnly() && (active.getOwner() == Thread.currentThread()))) {
		start = System.currentTimeMillis();
		// only need to start a new transaction if we don't already have
		// exclusive read-only access
		tx = domain.startTransaction(true, getWritingOptions(domain));
	}
	final RunnableWithResult<?> rwr = (read instanceof RunnableWithResult) ? (RunnableWithResult<?>) read : null;
	try {
		read.run();
	} finally {
		if ((tx != null) && (tx.isActive())) {
			// commit the transaction now
			try {
				tx.commit();
				if (rwr != null) {
					rwr.setStatus(Status.OK_STATUS);
				}
			} catch (RollbackException e) {
				Tracing.catching(TransactionalEditingDomainImpl.class, "runExclusive", e); //$NON-NLS-1$
				EMFTransactionPlugin.INSTANCE.log(new MultiStatus(EMFTransactionPlugin.getPluginId(), EMFTransactionStatusCodes.READ_ROLLED_BACK, new IStatus[] { e.getStatus() }, Messages.readTxRollback, null));
				if (rwr != null) {
					rwr.setStatus(e.getStatus());
				}
			}
		}
	}
	if (start != -1) {
		long duration = System.currentTimeMillis() - start;
		if (duration > 2 * 1000) {
			LogUtil.warn("runnable " + read + " held transaction for " + (duration / 1000.0) + " seconds");
		}
	}
	if (rwr != null) {
		@SuppressWarnings("unchecked")
		T result = (T) rwr.getResult();
		return result;
	}
	return null;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:45,代码来源:TransactionUtils.java

示例2: isUndoEnabled

import org.eclipse.emf.transaction.Transaction; //导入方法依赖的package包/类
/**
 * Queries whether the specified transaction should record undo information,
 * according to its {@link Transaction#getOptions() options} and
 * {@link Transaction#isReadOnly() read-only state}.
 * 
 * @param tx a transaction
 * @return <code>true</code> if the transaction should record undo
 *     information; <code>false</code>, otherwise
 */
protected static boolean isUndoEnabled(Transaction tx) {
	return !(tx.isReadOnly()
			|| hasOption(tx, OPTION_NO_UNDO)
			|| hasOption(tx, OPTION_UNPROTECTED));
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:15,代码来源:FixedTransactionImpl.java

示例3: isTriggerEnabled

import org.eclipse.emf.transaction.Transaction; //导入方法依赖的package包/类
/**
 * Queries whether the specified transaction should invoke pre-commit,
 * listeners, according to its {@link Transaction#getOptions() options} and
 * {@link Transaction#isReadOnly() read-only state}.
 * 
 * @param tx a transaction
 * @return <code>true</code> if the transaction should perform the pre-commit
 *     procedures; <code>false</code>, otherwise
 */
protected static boolean isTriggerEnabled(Transaction tx) {
	return !(tx.isReadOnly()
			|| hasOption(tx, OPTION_NO_TRIGGERS)
			|| hasOption(tx, OPTION_UNPROTECTED));
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:15,代码来源:FixedTransactionImpl.java

示例4: isUnprotected

import org.eclipse.emf.transaction.Transaction; //导入方法依赖的package包/类
/**
 * Queries whether the specified transaction is an unprotected write,
 * according to its {@link Transaction#getOptions() options} and
 * {@link Transaction#isReadOnly() read-only state}.
 * 
 * @param tx a transaction
 * @return <code>true</code> if the transaction is an unprotected write
 *     transaction; <code>false</code>, otherwise
 */
protected static boolean isUnprotected(Transaction tx) {
	return !tx.isReadOnly()
			&& hasOption(tx, OPTION_UNPROTECTED);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:14,代码来源:FixedTransactionImpl.java


注:本文中的org.eclipse.emf.transaction.Transaction.isReadOnly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。