本文整理汇总了Java中org.eclipse.xtext.util.concurrent.IUnitOfWork.exec方法的典型用法代码示例。如果您正苦于以下问题:Java IUnitOfWork.exec方法的具体用法?Java IUnitOfWork.exec怎么用?Java IUnitOfWork.exec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.util.concurrent.IUnitOfWork
的用法示例。
在下文中一共展示了IUnitOfWork.exec方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readOnly
import org.eclipse.xtext.util.concurrent.IUnitOfWork; //导入方法依赖的package包/类
public <R> R readOnly(URI targetURI, IUnitOfWork<R, ResourceSet> work) {
Iterable<Pair<IStorage, IProject>> storages = storage2UriMapper.getStorages(targetURI.trimFragment());
Iterator<Pair<IStorage, IProject>> iterator = storages.iterator();
while(iterator.hasNext()) {
Pair<IStorage, IProject> pair = iterator.next();
IProject project = pair.getSecond();
if (project != null) {
ResourceSet resourceSet = resourceSetProvider.get(project);
if(resourceSet != null)
resourceSet.getResource(targetURI, true);
try {
return work.exec(resourceSet);
} catch (Exception e) {
throw new WrappedException(e);
}
}
}
return null;
}
示例2: readOnly
import org.eclipse.xtext.util.concurrent.IUnitOfWork; //导入方法依赖的package包/类
public <R> R readOnly(URI targetURI, IUnitOfWork<R, ResourceSet> work) {
URI resourceURI = targetURI.trimFragment();
Iterable<Pair<IStorage, IProject>> storages = storage2UriMapper.getStorages(resourceURI);
Iterator<Pair<IStorage, IProject>> iterator = storages.iterator();
ResourceSet resourceSet = fallBackResourceSet;
while(iterator.hasNext()) {
Pair<IStorage, IProject> pair = iterator.next();
IProject project = pair.getSecond();
if (project != null) {
resourceSet = getResourceSet(project);
break;
}
}
if(resourceSet != null) {
resourceSet.getResource(resourceURI, true);
try {
return work.exec(resourceSet);
} catch (Exception e) {
throw new WrappedException(e);
}
}
return null;
}
示例3: readOnly
import org.eclipse.xtext.util.concurrent.IUnitOfWork; //导入方法依赖的package包/类
@Override
public <R> R readOnly(URI resourceURI, IUnitOfWork<R, ResourceSet> work) {
try {
return work.exec(resourceSet);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例4: readOnly
import org.eclipse.xtext.util.concurrent.IUnitOfWork; //导入方法依赖的package包/类
@Override
public <R> R readOnly(URI targetURI, IUnitOfWork<R, ResourceSet> work) {
if (N4Scheme.isN4Scheme(targetURI)) {
if (resourceSet == null) {
resourceSet = resourceSetProvider.get(null);
}
resourceSet.getResource(targetURI, true);
try {
return work.exec(resourceSet);
} catch (Exception e) {
throw new WrappedException(e);
}
}
return delegate.readOnly(targetURI, work);
}
示例5: execute
import org.eclipse.xtext.util.concurrent.IUnitOfWork; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*
* @since 2.4
*/
/* @Nullable */
@Override
public <Result> Result execute(/* @NonNull */ IUnitOfWork<Result, ? super BatchLinkableResource> unit) throws Exception {
synchronized (getLock()) {
return unit.exec(this);
}
}
示例6: execute
import org.eclipse.xtext.util.concurrent.IUnitOfWork; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*
* @since 2.4
*/
/* @Nullable */
@Override
public <Result> Result execute(/* @NonNull */ IUnitOfWork<Result, ? super TypeResource> unit) throws Exception {
synchronized (getLock()) {
return unit.exec(this);
}
}
示例7: execute
import org.eclipse.xtext.util.concurrent.IUnitOfWork; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*
* @since 2.4
*/
/* @Nullable */
@Override
public <Result> Result execute(/* @NonNull */ IUnitOfWork<Result, ? super SynchronizedXtextResourceSet> unit) throws Exception {
synchronized (getLock()) {
return unit.exec(this);
}
}
示例8: exec
import org.eclipse.xtext.util.concurrent.IUnitOfWork; //导入方法依赖的package包/类
public <R extends Object, P extends Resource> R exec(final IUnitOfWork<R, P> work, final P param) {
try {
R _xblockexpression = null;
{
final Boolean wasCancelationAllowed = this.cancelationAllowed.get();
R _xtrycatchfinallyexpression = null;
try {
R _xblockexpression_1 = null;
{
if ((work instanceof CancelableUnitOfWork<?, ?>)) {
CancelIndicator _xifexpression = null;
if ((param == null)) {
final CancelIndicator _function = () -> {
return true;
};
_xifexpression = _function;
} else {
_xifexpression = this.newCancelIndicator(param.getResourceSet());
}
((CancelableUnitOfWork<?, ?>)work).setCancelIndicator(_xifexpression);
} else {
this.cancelationAllowed.set(Boolean.valueOf(false));
}
_xblockexpression_1 = work.exec(param);
}
_xtrycatchfinallyexpression = _xblockexpression_1;
} finally {
this.cancelationAllowed.set(wasCancelationAllowed);
}
_xblockexpression = _xtrycatchfinallyexpression;
}
return _xblockexpression;
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例9: execWithTemporaryCaching
import org.eclipse.xtext.util.concurrent.IUnitOfWork; //导入方法依赖的package包/类
/**
* The transaction will be executed with caching enabled. However, all newly cached values will be discarded as soon
* as the transaction is over.
* @since 2.1
*/
public <Result, Param extends Resource> Result execWithTemporaryCaching(Param resource, IUnitOfWork<Result, Param> transaction) throws WrappedException {
CacheAdapter cacheAdapter = getOrCreate(resource);
IgnoreValuesMemento memento = cacheAdapter.ignoreNewValues();
try {
return transaction.exec(resource);
} catch (Exception e) {
throw new WrappedException(e);
} finally {
memento.done();
}
}
示例10: readOnly
import org.eclipse.xtext.util.concurrent.IUnitOfWork; //导入方法依赖的package包/类
@Override
public <R extends Object> R readOnly(final URI targetURI, final IUnitOfWork<R, ResourceSet> work) {
final Function2<Document, XtextResource, R> _function = (Document document, XtextResource resource) -> {
try {
if ((resource == null)) {
return null;
}
return work.exec(resource.getResourceSet());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
};
return this.workspaceManager.<R>doRead(targetURI, _function);
}
示例11: readOnly
import org.eclipse.xtext.util.concurrent.IUnitOfWork; //导入方法依赖的package包/类
protected <R extends Object> R readOnly(final URI objectURI, final IUnitOfWork<R, EObject> work) {
final IUnitOfWork<R, ResourceSet> _function = (ResourceSet resourceSet) -> {
final EObject targetObject = resourceSet.getEObject(objectURI, true);
return work.exec(targetObject);
};
return this.getResourceAccess().<R>readOnly(objectURI, _function);
}
示例12: readOnly
import org.eclipse.xtext.util.concurrent.IUnitOfWork; //导入方法依赖的package包/类
public <R> R readOnly(URI targetURI, IUnitOfWork<R, ResourceSet> work) {
try {
return work.exec(resourceSet);
} catch(Exception exc) {
throw new WrappedException(exc);
}
}
示例13: execute
import org.eclipse.xtext.util.concurrent.IUnitOfWork; //导入方法依赖的package包/类
@Override
public <Result extends Object> Result execute(final IUnitOfWork<Result, ? super JavaResource> unit) throws Exception {
synchronized (this.getLock()) {
return unit.exec(this);
}
}