本文整理汇总了Java中org.eclipse.emf.cdo.session.CDOSession类的典型用法代码示例。如果您正苦于以下问题:Java CDOSession类的具体用法?Java CDOSession怎么用?Java CDOSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CDOSession类属于org.eclipse.emf.cdo.session包,在下文中一共展示了CDOSession类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: startCDOServer
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
@BeforeClass
public static void startCDOServer() throws IOException, CommitException {
server = new CDOServer(false);
server.start();
IConnector connector = M2DocCDOUtils
.getConnector(CDOServer.PROTOCOL + "://" + CDOServer.IP + ":" + CDOServer.PORT);
CDOSession session = M2DocCDOUtils.openSession(connector, CDOServer.REPOSITORY_NAME, CDOServer.USER_NAME,
CDOServer.PASSWORD);
final CDOTransaction transaction = M2DocCDOUtils.openTransaction(session);
final CDOResource resource = transaction.createResource("anydsl.ecore");
final ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
final Resource anyDSLResource = resourceSet.getResource(URI.createFileURI("resources/anydsl.ecore"), true);
resource.getContents().addAll(anyDSLResource.getContents());
resource.save(null);
transaction.commit();
transaction.close();
session.close();
connector.close();
if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
ConfigurationProviderService.getInstance().register(CONFIGURATION_PROVIDER);
M2DocUtils.registerServicesConfigurator(SERVICES_CONFIGURATOR_DESCRIPTOR);
}
}
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:26,代码来源:ServerWithoutAuthentication.java
示例2: startCDOServer
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
@BeforeClass
public static void startCDOServer() throws IOException, CommitException {
server = new CDOServer(true);
server.start();
IConnector connector = M2DocCDOUtils
.getConnector(CDOServer.PROTOCOL + "://" + CDOServer.IP + ":" + CDOServer.PORT);
CDOSession session = M2DocCDOUtils.openSession(connector, CDOServer.REPOSITORY_NAME, CDOServer.USER_NAME,
CDOServer.PASSWORD);
final CDOTransaction transaction = M2DocCDOUtils.openTransaction(session);
final CDOResource resource = transaction.createResource("anydsl.ecore");
final ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
final Resource anyDSLResource = resourceSet.getResource(URI.createFileURI("resources/anydsl.ecore"), true);
resource.getContents().addAll(anyDSLResource.getContents());
resource.save(null);
transaction.commit();
transaction.close();
session.close();
connector.close();
if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
ConfigurationProviderService.getInstance().register(CONFIGURATION_PROVIDER);
M2DocUtils.registerServicesConfigurator(SERVICES_CONFIGURATOR_DESCRIPTOR);
}
}
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:26,代码来源:ServerWithAuthentication.java
示例3: createResourceSetForModels
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
@Override
public ResourceSet createResourceSetForModels(Generation generation) {
final ResourceSet res;
final Map<String, String> options = GenconfUtils.getOptions(generation);
final String cdoServer = options.get(M2DocCDOUtils.CDO_SERVER_OPTION);
if (cdoServer != null) {
final String repository = options.get(M2DocCDOUtils.CDO_REPOSITORY_OPTION);
final String branch = options.get(M2DocCDOUtils.CDO_BRANCH_OPTION);
final String login = options.get(M2DocCDOUtils.CDO_LOGIN_OPTION);
final String password = options.get(M2DocCDOUtils.CDO_PASSWORD_OPTION);
final IConnector connector = M2DocCDOUtils.getConnector(cdoServer);
connectors.put(generation, connector);
final CDOSession session = M2DocCDOUtils.openSession(connector, repository, login, password);
final CDOTransaction transaction = M2DocCDOUtils.openTransaction(session, branch);
transactions.put(generation, transaction);
res = transaction.getResourceSet();
res.getURIConverter().getURIHandlers().add(0, new M2DocCDOURIHandler((InternalCDOView) transaction));
} else {
res = null;
}
return res;
}
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:25,代码来源:CDOConfigurationProvider.java
示例4: getBranches
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
/**
* Lists all {@link CDOBranch} for the given {@link CDOSession}.
*
* @param session
* the {@link CDOSession} to use to list {@link CDOBranch}
* @return the {@link List} of {@link CDOBranch} for the given {@link CDOSession}
*/
public static List<CDOBranch> getBranches(CDOSession session) {
final List<CDOBranch> res = new ArrayList<CDOBranch>();
session.getBranchManager().getBranches(Integer.MIN_VALUE, Integer.MAX_VALUE, new CDOBranchHandler() {
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.cdo.common.branch.CDOBranchHandler#handleBranch(org.eclipse.emf.cdo.common.branch.CDOBranch)
*/
public void handleBranch(CDOBranch branch) {
res.add(branch);
}
});
return res;
}
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:23,代码来源:M2DocCDOUtils.java
示例5: openSession
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
/**
* Open a new {@link CDOSession}. Caller is responsible of {@link CDOSession#close() closing} the
* resulting session.
*
* @param connector
* the {@link IConnector} to use to open the {@link CDOSession}
* @param repository
* the repository name
* @param login
* the user login if any, if <code>null</code> otherwise no authentication will by used
* @param password
* the user password if an, if <code>null</code> empty {@link String} will be used
* @return a new {@link CDOSession}
*/
public static CDOSession openSession(IConnector connector, String repository, String login,
String password) {
CDOSessionConfiguration sessionConfiguration = CDONet4jUtil.createSessionConfiguration();
sessionConfiguration.setConnector(connector);
sessionConfiguration.setRepositoryName(repository);
if (login != null) {
final String pass;
if (password != null) {
pass = password;
} else {
pass = "";
}
sessionConfiguration.getAuthenticator().setCredentialsProvider(new PasswordCredentialsProvider(
login, pass.toCharArray()));
}
CDOSession res = sessionConfiguration.openSession();
return res;
}
开发者ID:ModelWriter,项目名称:Source,代码行数:35,代码来源:CDOUtils.java
示例6: openTransaction
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
/**
* Open a {@link CDOTransaction} on the given {@link CDOBranch}. Caller is responsible of
* {@link CDOTransaction#close() closing} the resulting transaction.
*
* @param session
* the {@link CDOSession} to use to open the {@link CDOTransaction}
* @param branchName
* the branch name or <code>null</code> for the main branch
* @return a new {@link CDOTransaction}
*/
public static CDOTransaction openTransaction(CDOSession session, String branchName) {
final CDOTransaction res;
if (branchName != null) {
CDOBranch branch = session.getBranchManager().getBranch(branchName);
if (branch != null) {
res = session.openTransaction(branch);
} else {
res = null;
throw new IllegalArgumentException("The branch " + branchName + " doesn't exist.");
}
} else {
res = session.openTransaction();
}
return res;
}
开发者ID:ModelWriter,项目名称:Source,代码行数:26,代码来源:CDOUtils.java
示例7: getBranches
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
/**
* Lists all {@link CDOBranch} for the given {@link CDOSession}.
*
* @param session
* the {@link CDOSession} to use to list {@link CDOBranch}
* @return the {@link List} of {@link CDOBranch} for the given {@link CDOSession}
*/
public static List<CDOBranch> getBranches(CDOSession session) {
final List<CDOBranch> res = new ArrayList<CDOBranch>();
session.getBranchManager().getBranches(Integer.MIN_VALUE, Integer.MAX_VALUE, new CDOBranchHandler() {
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.cdo.common.branch.CDOBranchHandler#handleBranch(org.eclipse.emf.cdo.common.branch.CDOBranch)
*/
public void handleBranch(CDOBranch branch) {
res.add(branch);
}
});
return res;
}
开发者ID:ModelWriter,项目名称:Source,代码行数:23,代码来源:CDOUtils.java
示例8: beforeClass
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
AllTests.startCDOServer();
IConnector connector = CDOUtils.getConnector(CDOServer.PROTOCOL + "://" + CDOServer.IP + ":"
+ CDOServer.PORT);
CDOSession session = CDOUtils.openSession(connector, CDOServer.REPOSITORY_NAME);
transaction = CDOUtils.openTransaction(session);
viewConnector.addSessionToCache(transaction);
folder = transaction.createResourceFolder(CDOResourceNodeConnectorTests.class.getCanonicalName()
+ "/test/");
textResource = transaction.createTextResource(CDOResourceNodeConnectorTests.class.getCanonicalName()
+ "/test/test.txt");
binaryResource = transaction.createBinaryResource(CDOResourceNodeConnectorTests.class
.getCanonicalName() + "/test/test.bin");
resource = transaction.createResource(CDOResourceNodeConnectorTests.class.getCanonicalName()
+ "/test/test.resource");
transaction.commit();
viewConnector.addSessionToCache(transaction);
MappingUtils.getConnectorRegistry().register(viewConnector);
}
开发者ID:ModelWriter,项目名称:Source,代码行数:23,代码来源:CDOResourceNodeConnectorTests.java
示例9: reloadResource
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
private static void reloadResource(Resource r) throws IOException {
if (r instanceof CDOResource) {
CDOResource realResource = (CDOResource) r;
CDOSession session = realResource.cdoView().getSession();
if (session == null) {
throw new IOException("Could not refresh resource because session is not available.");
}
session.refresh();
} else {
r.unload();
ResourceSet rs = r.getResourceSet();
if (rs != null && rs.getURIConverter().exists(r.getURI(), Collections.emptyMap())) {
r.load(Collections.emptyMap());
}
}
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:17,代码来源:ReloadingResourceChangeManager.java
示例10: delete
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
private static boolean delete(IFile launcher) {
CDOSession session = CDOConnectionManager.getInstance().acquireSession(launcher.getProject());
try {
CDOTransaction transaction = session.openTransaction();
try {
if (delete(launcher, transaction)) {
transaction.commit();
return true;
}
return false;
} catch (CommitException e) {
LOGGER.error("Could not commit changes.", e);
return false;
} finally {
IOUtil.closeSilent(transaction);
}
} finally {
CDOConnectionManager.getInstance().releaseSession(session);
}
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:21,代码来源:DeleteDiagramFromRepositoryCommand.java
示例11: reset
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
public static boolean reset(CDOSession session, CDOCommitInfo commit, IResource resource) {
CDOBranch mainBranch = session.getBranchManager().getMainBranch();
CDOBranch branch = mainBranch.createBranch("revert_" + System.currentTimeMillis());
boolean result = reset(session, commit, resource, branch);
if (result) {
CDOTransaction mergeTransaction = session.openTransaction(mainBranch);
try {
String changedObjectLabel = getLabelFor(resource);
DateFormat df = new SimpleDateFormat("dd.MM.yy HH:mm:ss");
String commitComment = String.format("Reset of %s to previous commit (%s) by %s.", changedObjectLabel,
df.format(new Date(commit.getTimeStamp())), System.getProperty("user.name"));
mergeTransaction.setCommitComment(commitComment);
mergeTransaction.merge(branch, new NilFixingCDOMerger());
try {
mergeTransaction.commit();
} catch (CommitException e) {
LOGGER.error("Merge commit of reverted changes failed.", e);
return false;
}
} finally {
IOUtil.closeSilent(mergeTransaction);
}
}
return result;
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:26,代码来源:ResetToPreviousStateCommand.java
示例12: deleteProjectFromRepository
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
private static boolean deleteProjectFromRepository(IProject project) {
CDOSession session = null;
try {
session = CDOConnectionManager.getInstance().acquireSession(project);
CDOTransaction transaction = session.openTransaction();
CDOResourceFolder resource = transaction.getResourceFolder(project.getName());
if (resource == null) {
LOGGER.error("Project {} doesn't exist in repository.", project);
return false;
}
EcoreUtil.delete(resource);
try {
transaction.commit();
} catch (CommitException e) {
LOGGER.error("Could not delete project {} from repository.", project.getName(), e);
return false;
}
} finally {
CDOConnectionManager.getInstance().releaseSession(session);
}
return true;
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:23,代码来源:DeleteProjectFromRepositoryCommand.java
示例13: createCDOResource
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
private static CDOResourceFolder createCDOResource(IProject project, String cdoRepoPath,
IListener listener) throws CommitException {
CDOSession cdoSession = CDOConnectionManager.getInstance().acquireSession(project);
CDOResourceFolder result = null;
try {
CDOView cdoView = cdoSession.openView();
cdoView.addListener(listener);
cdoView.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
if (!cdoView.hasResource(cdoRepoPath)) {
CDOTransaction transaction = cdoSession.openTransaction();
transaction.createResourceFolder(cdoRepoPath);
transaction.commit();
transaction.close();
}
result = cdoView.getResourceFolder(cdoRepoPath);
return result;
} finally {
if (result == null) {
CDOConnectionManager.getInstance().releaseSession(cdoSession);
}
}
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:23,代码来源:CDOHandlingBackgroundTask.java
示例14: fillTable
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
/**
* Opens connection to CDO server with the given connection information from projectProperties. Checks if projects
* on server exist in the workspace.
* Already existing projects are added as grayedElements to the end of the table, others are added at the top of the
* table.
*
* @param projectProperties
* Stores the connection information for the CDO server which stores the cooperate projects.
*/
public static void fillTable(ProjectPropertiesDTO projectProperties) {
CDOSession session = CDOHelper.createCDOSession(projectProperties.getCdoHost(),
projectProperties.getCdoPort(), projectProperties.getCdoRepo());
try {
tv.getTable().removeAll();
Set<String> exists = new TreeSet<>();
for (CDOResourceNode node : session.openView().getElements()) {
String name = node.getName();
if (ResourcesPlugin.getWorkspace().getRoot().getProject(name).exists()) {
String existsName = name + " (Already in your workspace.)";
exists.add(existsName);
} else {
tv.add(name);
}
}
tv.add(exists.toArray());
tv.setGrayedElements(exists.toArray());
tv.setCheckedElements(exists.toArray());
} finally {
IOUtil.closeSilent(session);
}
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:32,代码来源:CooperateProjectImportComposite.java
示例15: createModelNodes
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
private static ModelNode[] createModelNodes(IProject project) {
String resourceName = project.getName(); //TODO this should not be located here but at a central location
CDOSession session = CDOConnectionManager.getInstance().acquireSession(project);
try {
CDOView view = session.openView();
try {
if (!view.hasResource(resourceName)) {
return ArrayUtils.toArray();
}
CDOResourceFolder cdoFolder = view.getResourceFolder(resourceName);
return cdoFolder.getNodes().stream().filter(n -> "notation".equals(n.getExtension())).filter(CDOResource.class::isInstance).map(r -> new ModelNode(getBaseName(r))).toArray(ModelNode[]::new);
} finally {
IOUtil.closeSilent(view);
}
} finally {
CDOConnectionManager.getInstance().releaseSession(session);
}
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:19,代码来源:ModelContentProvider.java
示例16: findPossibleStaleReferences
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
private static Set<CrossReferenceSetting> findPossibleStaleReferences(CDOSession session,
CDOCommitInfo commitInfo) {
CDOView historicView = session.openView(commitInfo.getBranch(), commitInfo.getTimeStamp() - 1);
try {
Set<CDOObject> detachedObjects = commitInfo.getDetachedObjects().stream().map(CDOIDAndVersion::getID)
.map(historicView::getObject).collect(Collectors.toSet());
if (detachedObjects.isEmpty()) {
return Collections.emptySet();
}
return historicView.queryXRefs(detachedObjects, new EReference[0]).stream()
.map(ref -> new CrossReferenceSetting((EReference) ref.getSourceFeature(),
ref.getSourceObject().cdoID()))
.collect(Collectors.toSet());
} finally {
IOUtil.closeSilent(historicView);
}
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:18,代码来源:TransformationManager.java
示例17: isReadOnlyRequired
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
public static boolean isReadOnlyRequired(IFile launcherFile)
throws IOException, ConcreteSyntaxTypeNotAvailableException {
CDOSession session = CDOConnectionManager.getInstance().acquireSession(launcherFile.getProject());
try {
CDOView temporaryView = session.openView();
try {
Diagram launcherModel = loadDiagram(temporaryView, launcherFile);
URI umlURI = determineUMLURI(launcherModel);
return getWriteLock(temporaryView, umlURI).isLockedByOthers();
} finally {
IOUtil.closeSilent(temporaryView);
}
} finally {
CDOConnectionManager.getInstance().releaseSession(session);
}
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:17,代码来源:LockStateInfo.java
示例18: createSession
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
protected CDOSession createSession() {
// Create connector
IConnector connector = createConnector(getManagedContainer());
// Create configuration
CDONet4jSessionConfiguration configuration = CDONet4jUtil.createNet4jSessionConfiguration();
configuration.setRepositoryName(getRepositoryName());
configuration.setConnector(connector);
// Open session
CDONet4jSession session = configuration.openNet4jSession();
session.options().setPassiveUpdateEnabled(true);
session.options().setGeneratedPackageEmulationEnabled(true);
// load persisted EPackages in the session (EPackage emulation must be enabled)
for (CDOPackageInfo info : session.getPackageRegistry() .getPackageInfos()) {
session.getPackageRegistry().put(info.getPackageURI(), info.getEPackage());
}
session.options().getNet4jProtocol().setTimeout(-1L);
session.options().setCommitTimeout(Integer.MAX_VALUE);
session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(0, 300));
return session;
}
开发者ID:opencanarias,项目名称:model-repository-benchmark,代码行数:26,代码来源:AbstractCDOModelRepository.java
示例19: postGenerate
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
@Override
public List<URI> postGenerate(Generation generation, URI templateURI, URI generatedURI,
DocumentTemplate documentTemplate) {
final CDOTransaction transaction = transactions.get(generation);
if (transaction != null) {
final CDOSession session = transaction.getSession();
transaction.close();
session.close();
connectors.remove(generation).close();
}
return Collections.emptyList();
}
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:13,代码来源:CDOConfigurationProvider.java
示例20: openSession
import org.eclipse.emf.cdo.session.CDOSession; //导入依赖的package包/类
/**
* Open a new {@link CDOSession}. Caller is responsible of {@link CDOSession#close() closing} the
* resulting session.
*
* @param connector
* the {@link IConnector} to use to open the {@link CDOSession}
* @param repository
* the repository name
* @param login
* the user login if any, if <code>null</code> otherwise no authentication will by used
* @param password
* the user password if an, if <code>null</code> empty {@link String} will be used
* @return a new {@link CDOSession}
*/
public static CDOSession openSession(IConnector connector, String repository, String login, String password) {
final CDONet4jSessionConfiguration sessionConfiguration = CDONet4jUtil.createNet4jSessionConfiguration();
sessionConfiguration.setConnector(connector);
sessionConfiguration.setRepositoryName(repository);
if (login != null) {
final String pass;
if (password != null) {
pass = password;
} else {
pass = "";
}
sessionConfiguration.setCredentialsProvider(new PasswordCredentialsProvider(login, pass.toCharArray()));
} else {
final IPasswordCredentialsProvider credentialsProvider;
if (SWT.isLoadable()) {
credentialsProvider = new InteractiveCredentialsProvider();
} else {
credentialsProvider = new ShellCredentialsProvider();
}
sessionConfiguration.setCredentialsProvider(credentialsProvider);
}
CDOSession res = sessionConfiguration.openNet4jSession();
return res;
}
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:41,代码来源:M2DocCDOUtils.java
注:本文中的org.eclipse.emf.cdo.session.CDOSession类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论