本文整理汇总了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;
}
示例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));
}
示例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));
}
示例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);
}