diff options
author | Eike Stepper | 2009-06-22 11:45:34 +0000 |
---|---|---|
committer | Eike Stepper | 2009-06-22 11:45:34 +0000 |
commit | 910a80e9f4d8d19abbb33962cb7545f82f3581af (patch) | |
tree | c0a49dcde9b731cc9850eca36d626e59cf93b5aa /plugins/org.eclipse.emf.cdo.examples/src | |
parent | 6b243611ce24466ed4aa618c21a655b3973ecc33 (diff) | |
download | cdo-910a80e9f4d8d19abbb33962cb7545f82f3581af.tar.gz cdo-910a80e9f4d8d19abbb33962cb7545f82f3581af.tar.xz cdo-910a80e9f4d8d19abbb33962cb7545f82f3581af.zip |
examples
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.examples/src')
-rw-r--r-- | plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/VariousExamples.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/VariousExamples.java b/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/VariousExamples.java new file mode 100644 index 0000000000..e3ad186cf5 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples/src/org/eclipse/emf/cdo/examples/VariousExamples.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.examples; + +import org.eclipse.emf.cdo.net4j.CDONet4jUtil; +import org.eclipse.emf.cdo.net4j.CDOSession; +import org.eclipse.emf.cdo.net4j.CDOSessionConfiguration; +import org.eclipse.emf.cdo.transaction.CDOTransaction; + +import org.eclipse.net4j.connector.IConnector; +import org.eclipse.net4j.util.container.IPluginContainer; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; + +/** + * @author Eike Stepper + * @since 2.0 + */ +public class VariousExamples +{ + public static void openSessionAndUseTransaction() + { + ResourceSet resourceSet = new ResourceSetImpl(); + IConnector connector = (IConnector)IPluginContainer.INSTANCE.getElement("org.eclipse.net4j.connectors", "tcp", + "repos.foo.org:2036"); + + CDOSessionConfiguration configuration = CDONet4jUtil.createSessionConfiguration(); + configuration.setConnector(connector); + configuration.setRepositoryName("MyRepo"); + + CDOSession session = configuration.openSession(); + CDOTransaction transaction = session.openTransaction(resourceSet); + + // Work with the resource set.... + transaction.commit(); + session.close(); + } + + public static void registerSessionWithPluginContainer() + { + CDOSession session = (CDOSession)IPluginContainer.INSTANCE.getElement("org.eclipse.emf.cdo.sessions", "cdo", + "tcp://repos.foo.org:2036/MyRepo"); + CDOTransaction transaction = session.openTransaction(); + // ... + transaction.commit(); + } +} |