• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RollbackException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



RollbackException类属于org.eclipse.emf.transaction包,在下文中一共展示了RollbackException类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: commitCurrentTransaction

import org.eclipse.emf.transaction.RollbackException; //导入依赖的package包/类
private void commitCurrentTransaction() {
	if (currentTransaction != null) {
		try {
			currentTransaction.commit();
		} catch (RollbackException t) {

			cleanCurrentTransactionCommand();

			// Extracting the real error from the RollbackException
			Throwable realT = t.getStatus().getException();

			// And we put it inside our own sort of exception, as a cause
			SequentialExecutionException enclosingException = new SequentialExecutionException(getCurrentMSEOccurrence(), realT);
			enclosingException.initCause(realT);
			throw enclosingException;
		}
		currentTransaction = null;
	}
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:20,代码来源:AbstractExecutionEngine.java


示例2: handleRollback

import org.eclipse.emf.transaction.RollbackException; //导入依赖的package包/类
private static RuntimeException handleRollback(RollbackException e) {
	Logger logger = Logger.getLogger(TransactionUtils.class);
	IStatus status = e.getStatus();
	switch (status.getCode()) {
	case IStatus.ERROR:
		logger.error(status.getMessage(), status.getException());
		break;
	case IStatus.WARNING:
		logger.warn(status.getMessage(), status.getException());
		break;
	case IStatus.INFO:
		logger.info(status.getMessage(), status.getException());
		break;
	}

	final Throwable exception = Option.fromNull(status.getException()).orSome(e);
	if (exception instanceof RuntimeException)
		return (RuntimeException) exception;

	return new RuntimeException(exception);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:22,代码来源:TransactionUtils.java


示例3: handleRollback

import org.eclipse.emf.transaction.RollbackException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * @see org.eclipse.emf.transaction.impl.TransactionalCommandStackImpl#handleRollback(org.eclipse.emf.common.command.Command,
 *      org.eclipse.emf.transaction.RollbackException)
 */
@Override
protected void handleRollback(Command command, RollbackException rbe) {
	super.handleRollback(command, rbe);
	Exception exception = null;
	if (rbe != null) {
		if (rbe.getCause() != null && rbe.getCause() instanceof Exception) {
			exception = (Exception) rbe.getCause();
		} else {
			exception = rbe;
		}
	}
	notifier.notifiyListenersAboutCommandFailed(command, exception);

	if (currentCommand == command) {
		currentCommand = null;
	}
}
 
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:24,代码来源:EMFStoreTransactionalCommandStack.java


示例4: transactionAboutToCommit

import org.eclipse.emf.transaction.RollbackException; //导入依赖的package包/类
/**
 * @see org.eclipse.emf.transaction.ResourceSetListener#transactionAboutToCommit(org.eclipse.emf.transaction.ResourceSetChangeEvent)
 */
@SuppressWarnings("unchecked")
public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {

    List notifications = event.getNotifications();
    CompoundCommand compoundCommand = new CompoundCommand();
    Set handledModels = new HashSet();
    Notification notification = null;
    EObject notifier = null;

    for (Iterator i = notifications.iterator(); i.hasNext();) {
        notification = (Notification) i.next();

        if (notification.getNotifier() instanceof EObject && !handledModels.contains(notification)) {
            notifier = (EObject) notification.getNotifier();
            if (notifier.eClass() == UMLPackage.eINSTANCE.getModel()) {
                final Model model = (Model) notifier;
                String name = model.getName();

                // Model should have some name
                if (name == null || name.equals("")) { //$NON-NLS-1$
                    // We can use any EMF command here
                    compoundCommand.append(new SetCommand(event.getEditingDomain(),
                        model,
                        (EStructuralFeature) UMLPackage.eINSTANCE.getModel(),
                        "SomeName")); //$NON-NLS-1$
                }

                handledModels.add(model);
            }
        }
    }

    // It is important to return null if we have nothing to
    // contribute to this transaction.
    return compoundCommand.isEmpty() ? null : compoundCommand;

}
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:41,代码来源:UMLResourceSetListener.java


示例5: handleException

import org.eclipse.emf.transaction.RollbackException; //导入依赖的package包/类
/**
 * Documentation copied from the inherited specification
 * 
 * @see org.eclipse.emf.transaction.ExceptionHandler#handleException(java.lang.Exception)
 */
public void handleException(final Exception e) {
    PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
        /**
         * @see java.lang.Runnable#run()
         */
        public void run() {
            Shell shell = null;
            IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

            if (window != null) {
                shell = window.getShell();
            }

            if (e instanceof RollbackException) {
                RollbackException rbe = (RollbackException) e;

                ErrorDialog.openError(shell,
                    UMLMessage.MESSAGE_COMMAND_FAILED,
                    UMLMessage.MESSAGE_COMMAND_ROLLBACK,
                    rbe.getStatus());
            } else {
                ErrorDialog.openError(shell,
                    UMLMessage.MESSAGE_COMMAND_FAILED,
                    UMLMessage.MESSAGE_COMMAND_ROLLBACK,
                    new Status(IStatus.ERROR,
                        UMLEditorPlugin.getPlugin().getSymbolicName(),
                        1,
                        e.getLocalizedMessage(),
                        e));
            }
        }
    });
}
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:39,代码来源:CommandStackExceptionHandler.java


示例6: dispose

import org.eclipse.emf.transaction.RollbackException; //导入依赖的package包/类
public static void dispose(final EPlan ePlan) {
	if (ePlan == null) {
		return;
	}
	EPlanUtils.clearConsolidatedPlanElementsCache();
	HibernateMember member = ePlan.getMember(HibernateMember.class, true);
	final Plan wrapper = (Plan)member.getWrapper();
	TransactionalEditingDomain domain = TransactionUtils.getDomain(ePlan);
	if (wrapper != null) {
		if (domain != null) {
			domain.addResourceSetListener(new PreCommitListener() {
				@Override
				public Command transactionAboutToCommit(ResourceSetChangeEvent event)
						throws RollbackException {
					if (event.getNotifications().isEmpty()) {
						return null;
					}
					LogUtil.error("event during disposal of plan: " + ePlan.getName());
					throw new RollbackException(Status.CANCEL_STATUS);
				}
			});
		}
		if (wrapper != null) {
			wrapper.dispose();
		}
		member.setWrapper(null);
	}
	Resource resource = ePlan.eResource();
	if (domain != null) {
		domain.dispose();
		domain.getResourceSet().getResources().remove(resource);
	}
	if (resource != null) {
		resource.getContents().remove(ePlan);
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:37,代码来源:WrapperUtils.java


示例7: checkedWriting

import org.eclipse.emf.transaction.RollbackException; //导入依赖的package包/类
public static <T> T checkedWriting(Object object, final RunnableWithResult<T> runnable, Map<Object, Object> options) throws InterruptedException, RollbackException {

		final EditingDomain domain = EMFUtils.getAnyDomain(object);
		if (domain instanceof TransactionalEditingDomain) {
			TransactionalEditingDomain transactionDomain = (TransactionalEditingDomain) domain;
			checkForDeadlock(transactionDomain);
			InternalTransaction transaction = ((TransactionalEditingDomainImpl) transactionDomain).getActiveTransaction();
			if ((transaction != null) && (transaction.getOwner() == Thread.currentThread()) && !transaction.isReadOnly()) {
				// nested writing
				runnable.run();
				return runnable.getResult();
			}
			TransactionalCommandStack stack = (TransactionalCommandStack) domain.getCommandStack();
			if (stack != null) {
				Map writingOptions = getWritingOptions(domain);
				Map newOptions = new HashMap();
				if (options != null) {
					newOptions.putAll(options);
				}
				if (writingOptions != null) {
					newOptions.putAll(writingOptions);
				}
				writingOptions = newOptions;
				stack.execute(new RunnableRecordingCommand("writing", runnable), writingOptions);
			} else {
				runnable.run();
			}
		} else {
			runnable.run();
		}
		return runnable.getResult();
	}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:33,代码来源:TransactionUtils.java


示例8: transactionAboutToCommit

import org.eclipse.emf.transaction.RollbackException; //导入依赖的package包/类
/**
 * @see org.eclipse.emf.transaction.ResourceSetListener#transactionAboutToCommit(org.eclipse.emf.transaction.ResourceSetChangeEvent)
 */
public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {
    // TODO Auto-generated method stub
    return null;
}
 
开发者ID:SK-HOLDINGS-CC,项目名称:NEXCORE-UML-Modeler,代码行数:8,代码来源:CreateDiagramAction.java


示例9: transactionAboutToCommit

import org.eclipse.emf.transaction.RollbackException; //导入依赖的package包/类
public Command transactionAboutToCommit(ResourceSetChangeEvent event)
		throws RollbackException {
	return null;
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:5,代码来源:DirtyStateListener.java


示例10: transactionAboutToCommit

import org.eclipse.emf.transaction.RollbackException; //导入依赖的package包/类
@Override
public abstract Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException;
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:3,代码来源:PreCommitListener.java


示例11: runExclusive

import org.eclipse.emf.transaction.RollbackException; //导入依赖的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


示例12: doExecute

import org.eclipse.emf.transaction.RollbackException; //导入依赖的package包/类
@Override
protected void doExecute(Command command, Map<?, ?> options) throws InterruptedException, RollbackException {
	// default the transaction options to not perform EMF validation or allow undo 
	if (options == null) {
		options = DEFAULT_TRANSACTION_OPTIONS;
	}
	InternalTransaction tx = createTransaction(command, options);
	boolean completed = false;
	
	try {
		basicExecute(command);
		
		// new in EMF 2.4:  AbortExecutionException can cause the
		// command not to be added to the undo stack
		completed = mostRecentCommand == command;
		
		// commit the transaction now
		TransactionalEditingDomainImpl domain = (TransactionalEditingDomainImpl)tx.getEditingDomain();
		if (domain != null && domain.getChangeRecorder() != null) {
			tx.commit();
		} else {
			tx = null;
		}
	} catch (OperationCanceledException e) {
		// snuff the exception, because this is expected (user asked to
		//    cancel the model change).  We will rollback, below
	} finally {
		if (tx != null) {
			if (tx.isActive()) {
				// roll back (some exception, possibly being thrown now or
				//    an operation cancel, has occurred)
				rollback(tx);
                handleRollback(command, null);
			} else {
				// the transaction has already incorporated the triggers
				//    into its change description, so the recording command
				//    doesn't need them again
				if (!(command instanceof RecordingCommand) && completed) {
					Command triggerCommand = tx.getTriggers();
					if (triggerCommand != null) {
						// replace the executed command by a compound of the
						//    original and the trigger commands
						CompoundCommand compound = new ConditionalRedoCommand.Compound();
						compound.append(mostRecentCommand);
						compound.append(triggerCommand);
						mostRecentCommand = compound;
					}
				}
			}
		}
	}
       clearStack(command);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:54,代码来源:FixedTransactionalCommandStackImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileInfo类代码示例发布时间:2022-05-22
下一篇:
Java ListDialogField类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap