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


Java IUnitOfWork.exec方法代码示例

本文整理汇总了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;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:20,代码来源:LoadingResourceAccess.java

示例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;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:24,代码来源:ResourceAccess.java

示例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);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:9,代码来源:SimpleResourceAccess.java

示例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);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:16,代码来源:ForwardingResourceAccess.java

示例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);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:13,代码来源:BatchLinkableResource.java

示例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);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:13,代码来源:TypeResource.java

示例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);
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:13,代码来源:SynchronizedXtextResourceSet.java

示例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);
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:37,代码来源:OutdatedStateManager.java

示例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();
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:OnChangeEvictingCache.java

示例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);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:15,代码来源:WorkspaceResourceAccess.java

示例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);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:AbstractHierarchyBuilder.java

示例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);
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:8,代码来源:SimpleLocalResourceAccess.java

示例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);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:7,代码来源:JavaResource.java


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